Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update for API route change #47

Merged
merged 5 commits into from
Jun 6, 2024
Merged

fix: update for API route change #47

merged 5 commits into from
Jun 6, 2024

Conversation

fubuloubu
Copy link
Member

@fubuloubu fubuloubu commented Jun 5, 2024

What I did

just changed the API route

fixes: #46

How I did it

How to verify it

Checklist

  • Passes all linting checks (pre-commit and CI jobs)
  • New test cases have been added and are passing
  • Documentation has been updated
  • PR title follows Conventional Commit standard (will be automatically included in the changelog)

@fubuloubu fubuloubu mentioned this pull request Jun 5, 2024
@fubuloubu fubuloubu marked this pull request as draft June 5, 2024 22:26
@fubuloubu
Copy link
Member Author

TODO:

  • Check all endpoints for changes

@solarthesis
Copy link
Contributor

solarthesis commented Jun 6, 2024

Hey @fubuloubu I believe we still have issues, here is what it is throwing

*** pydantic_core._pydantic_core.ValidationError: 13 validation errors for UnexecutedTxData
safe
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
value
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
operation
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
gasToken
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
safeTxGas
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
baseGas
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
gasPrice
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
refundReceiver
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
nonce
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
submissionDate
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
modified
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
safeTxHash
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
confirmationsRequired
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
Here is an example I am trying to push, just sending 1 wei wETH from the safe to the safe.
from ape import Contract, networks
from ape.exceptions import SignatureError as SigError
from ape_safe import multisend
from functools import wraps
from ape import accounts

class GnosisSafe():
    
    def __init__(self):
        self.setup_deployer()
        self.setup_safe()

    def with_provider(func):
        @wraps(func)
        def wrapper(self,*args, **kwargs):
            provider  = getattr(getattr(networks,"optimism"),"mainnet")
            with provider.use_default_provider():
                return func(self,*args, **kwargs)
        return wrapper
        
    @with_provider
    def setup_safe(self):
        self.safe = accounts.load("test-safe")
    
    def setup_deployer(self):  
        self.deployer = accounts.load("test")
        self.deployer.set_autosign(True,passphrase='abc123')
                
    
    @with_provider
    def get_signers(self):
        return self.safe.signers
    
    @with_provider
    def get_next_safe_nonce(self):
        return self.safe.new_nonce

    @with_provider
    def post_gnosis_transaction(self,contractName,functionName,args):
        nonce          = self.get_next_safe_nonce()
        apeContract    = self.apeContracts[contractName]
        func           = getattr(apeContract,functionName)
        txn            = multisend.MultiSend()
        [txn.add(func,*arg) for arg in args]
        try:        
            txn(sender=self.safe,gas=0,submit_transaction=False,nonce=nonce)
        except SigError:                
            pass
        except Exception as e: 
            print(f"error staging transaction {e}")
            
            
    @with_provider
    def stage_test_transaction(self):
        abi='''[{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]'''
        self.apeContracts = {}
        self.apeContracts["test"] = Contract(address="0x4200000000000000000000000000000000000006",abi=abi)
        self.post_gnosis_transaction(contractName='test', functionName='transfer', args=[[self.safe.address,1]]) 
    
#%%
if __name__ == '__main__':
    self = GnosisSafe()
    self.stage_test_transaction()

And here is the versions installed

(gnosis_perp_ape) thesis@ks:~$ ape --version
0.8.2

Installed Plugins
 alchemy      0.8.0
 etherscan    0.8.0
 solidity     0.8.0

Third-party Plugins
 optimism     0.8.0
 safe         0.8.1.dev1+g6ff9246

@fubuloubu
Copy link
Member Author

@solarthesis confirmed this locally just using ape safe all-txns

@solarthesis
Copy link
Contributor

@fubuloubu believe there are still things i'ts not liking

(gnosis_perp_ape) thesis@ks:~$ ape safe all-txns --network optimism:mainnet 0x2008A7DDf4770840B9C301A2722564b07ec7800c
INFO: Connecting to existing Geth node at https://mainnet.optimism.io/[hidden].
Traceback (most recent call last):
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/bin/ape", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/ape/_cli.py", line 88, in invoke
    return super().invoke(ctx)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/ape/cli/commands.py", line 98, in invoke
    return self._invoke(ctx, provider=provider)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/ape/cli/commands.py", line 135, in _invoke
    return ctx.invoke(self.callback or (lambda: None), **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/ape_safe/_cli/safe_mgmt.py", line 145, in all_txns
    for txn in client.get_transactions(confirmed=confirmed):
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/ape_safe/client/base.py", line 82, in get_transactions
    for txn in self._all_transactions():
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/ape_safe/client/__init__.py", line 95, in _all_transactions
    yield UnexecutedTxData.model_validate(txn)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thesis/miniconda3/envs/gnosis_perp_ape/lib/python3.11/site-packages/pydantic/main.py", line 551, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 13 validation errors for UnexecutedTxData
safe
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
value
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
operation
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
gasToken
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
safeTxGas
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
baseGas
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
gasPrice
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
refundReceiver
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
nonce
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
submissionDate
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
modified
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
safeTxHash
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
confirmationsRequired
  Field required [type=missing, input_value={'executionDate': '2024-0...934F4F0C45f893042B190b'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing
(gnosis_perp_ape) thesis@ks:~$ 


@fubuloubu
Copy link
Member Author

Yeah was just saying I got the same issue that way haha, working on debugging

@fubuloubu fubuloubu marked this pull request as ready for review June 6, 2024 14:48
@fubuloubu
Copy link
Member Author

@solarthesis should be fixed now!

@fubuloubu fubuloubu enabled auto-merge (squash) June 6, 2024 14:49
@solarthesis
Copy link
Contributor

ok let me test it out, 1 second

@solarthesis
Copy link
Contributor

Works perfectly @fubuloubu
image

Copy link
Member

@antazoey antazoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple o' nits / small-refactor opportunities

"""
View and filter all transactions for a given Safe using Safe API
"""
if account in cli_ctx.account_manager.aliases:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic seems argument-callback worthy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but I think could be upstreamed to ape.cli

ape_safe/client/__init__.py Show resolved Hide resolved
@solarthesis
Copy link
Contributor

@Uxio0 please take note of breaking changes on gnosis api, which is causing issues for integrations like this safe-global/safe-transaction-service@6753c7a

@fubuloubu fubuloubu merged commit 6797e66 into main Jun 6, 2024
28 checks passed
@fubuloubu fubuloubu deleted the fix/api-update branch June 6, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Api Update
3 participants