-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"""Simple vault helpers. | ||
- Simple vault is a simplified vault implementation to test GuardV0 smart contract | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Tuple | ||
|
||
from eth_typing import ChecksumAddress, HexStr | ||
from web3._utils.contracts import get_function_info, encode_abi | ||
from web3.contract.contract import ContractFunction | ||
|
||
|
||
def encode_simple_vault_transaction(func: ContractFunction) -> Tuple[ChecksumAddress, HexStr]: | ||
"""Encode a bound web3 function call as a simple vault transaction. | ||
:param call: | ||
Bound function prepared for a call. | ||
:return: | ||
Address, call data tuple. | ||
""" | ||
assert isinstance(func, ContractFunction) | ||
|
||
w3 = func.w3 | ||
contract_abi = func.contract_abi | ||
fn_abi = func.abi | ||
fn_identifier = func.function_identifier | ||
args = func.args | ||
fn_abi, fn_selector, fn_arguments = get_function_info( | ||
# type ignored b/c fn_id here is always str b/c FallbackFn is handled above | ||
fn_identifier, # type: ignore | ||
w3.codec, | ||
contract_abi, | ||
fn_abi, | ||
args, | ||
) | ||
encoded = encode_abi(w3, fn_abi, fn_arguments, fn_selector) | ||
return func.address, encoded | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters