-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Big things: - Added new Transaction models: InvokeOutsideV1, InvokeOutsideV2 - Added method for SNIP9 nonce verification - Added Account methods for population and broadcasting(execution) of InvokeOutside transactions Small fixes: - Allowed for incomplete definition of ParameterDict as `contains` fiels is often missing and linter is complaining. WIP: miss docs and tests * - Added outside execution model, defined hashing - Extended base account interface - Added all utilities to deal with SNIP-9 nonce and generating OutsideExecution call - Bugfix type data generation - Cleaned up as much as I could to keep changes minimal - Added docs - Added test for positive scenario - Added one test for wrong caller scenario * * lint * test fixes * ok. so I am not allowed to change ci configs * fixing tests * lint * switched back to increase balance * tiny revert * comment documentation test to check if that is what affects test account balance * Revert "comment documentation test to check if that is what affects test account balance" This reverts commit 5851f12. * change for another call in documentation. removed account deployment. * fix * fix doctest * more fixes * remove balance change calls * Fixed naming * fix documentation * added secrets * trigger build * Review comments fixws * linter * fixup * Added comment * fix * lost empty line * comments fixes * Update starknet_py/constants.py Co-authored-by: Franciszek Job <[email protected]> * comment fixupi * fix wordings * fix * fixes * more fixes * more fixes * rename * Fix * linter * Update starknet_py/tests/e2e/docs/guide/test_account_sign_outside_transaction.py Co-authored-by: Franciszek Job <[email protected]> * Update starknet_py/tests/e2e/docs/guide/test_account_sign_outside_transaction.py Co-authored-by: Franciszek Job <[email protected]> * Update starknet_py/net/account/base_account.py Co-authored-by: Franciszek Job <[email protected]> * a bit more review comment fixes * revert execute_v1 * remove auto fee estimation * Update docs/guide/account_and_client.rst Co-authored-by: Franciszek Job <[email protected]> * Update starknet_py/tests/e2e/docs/guide/test_account_sign_outside_transaction.py Co-authored-by: Franciszek Job <[email protected]> * import fix * fix doctest * Update starknet_py/tests/e2e/account/outside_execution_test.py Co-authored-by: Franciszek Job <[email protected]> * Update starknet_py/tests/e2e/account/outside_execution_test.py Co-authored-by: Franciszek Job <[email protected]> * changelog * Update docs/migration_guide.rst Co-authored-by: Franciszek Job <[email protected]> * fixing fixes --------- Co-authored-by: Franciszek Job <[email protected]>
- Loading branch information
1 parent
3996323
commit a8d7353
Showing
15 changed files
with
577 additions
and
25 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
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
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
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,121 @@ | ||
from starknet_py.constants import OutsideExecutionInterfaceID | ||
from starknet_py.net.client_models import OutsideExecution | ||
from starknet_py.net.schemas.common import Revision | ||
from starknet_py.utils.typed_data import TypedData | ||
|
||
OUTSIDE_EXECUTION_INTERFACE_ID_TO_TYPED_DATA_REVISION = { | ||
OutsideExecutionInterfaceID.V1: Revision.V0, | ||
OutsideExecutionInterfaceID.V2: Revision.V1, | ||
} | ||
|
||
|
||
# TODO(#1537): Implement as method of OutsideExecution | ||
def outside_execution_to_typed_data( | ||
outside_execution: OutsideExecution, | ||
outside_execution_version: OutsideExecutionInterfaceID, | ||
chain_id: int, | ||
) -> TypedData: | ||
""" | ||
SNIP-12 Typed Data for OutsideExecution implementation. For revision V0 and V1. | ||
""" | ||
|
||
revision = OUTSIDE_EXECUTION_INTERFACE_ID_TO_TYPED_DATA_REVISION[ | ||
outside_execution_version | ||
] | ||
|
||
if revision == Revision.V0: | ||
return TypedData.from_dict( | ||
{ | ||
"types": { | ||
"StarkNetDomain": [ | ||
{"name": "name", "type": "felt"}, | ||
{"name": "version", "type": "felt"}, | ||
{"name": "chainId", "type": "felt"}, | ||
], | ||
"OutsideExecution": [ | ||
{"name": "caller", "type": "felt"}, | ||
{"name": "nonce", "type": "felt"}, | ||
{"name": "execute_after", "type": "felt"}, | ||
{"name": "execute_before", "type": "felt"}, | ||
{"name": "calls_len", "type": "felt"}, | ||
{"name": "calls", "type": "OutsideCall*"}, | ||
], | ||
"OutsideCall": [ | ||
{"name": "to", "type": "felt"}, | ||
{"name": "selector", "type": "felt"}, | ||
{"name": "calldata_len", "type": "felt"}, | ||
{"name": "calldata", "type": "felt*"}, | ||
], | ||
}, | ||
"primaryType": "OutsideExecution", | ||
"domain": { | ||
"name": "Account.execute_from_outside", | ||
"version": "1", | ||
"chainId": str(chain_id), | ||
"revision": Revision.V0, | ||
}, | ||
"message": { | ||
"caller": outside_execution.caller, | ||
"nonce": outside_execution.nonce, | ||
"execute_after": outside_execution.execute_after, | ||
"execute_before": outside_execution.execute_before, | ||
"calls_len": len(outside_execution.calls), | ||
"calls": [ | ||
{ | ||
"to": call.to_addr, | ||
"selector": call.selector, | ||
"calldata_len": len(call.calldata), | ||
"calldata": call.calldata, | ||
} | ||
for call in outside_execution.calls | ||
], | ||
}, | ||
} | ||
) | ||
|
||
# revision == Revision.V1 | ||
return TypedData.from_dict( | ||
{ | ||
"types": { | ||
"StarknetDomain": [ | ||
{"name": "name", "type": "shortstring"}, | ||
{"name": "version", "type": "shortstring"}, | ||
{"name": "chainId", "type": "shortstring"}, | ||
{"name": "revision", "type": "shortstring"}, | ||
], | ||
"OutsideExecution": [ | ||
{"name": "Caller", "type": "ContractAddress"}, | ||
{"name": "Nonce", "type": "felt"}, | ||
{"name": "Execute After", "type": "u128"}, | ||
{"name": "Execute Before", "type": "u128"}, | ||
{"name": "Calls", "type": "Call*"}, | ||
], | ||
"Call": [ | ||
{"name": "To", "type": "ContractAddress"}, | ||
{"name": "Selector", "type": "selector"}, | ||
{"name": "Calldata", "type": "felt*"}, | ||
], | ||
}, | ||
"primaryType": "OutsideExecution", | ||
"domain": { | ||
"name": "Account.execute_from_outside", | ||
"version": "2", | ||
"chainId": str(chain_id), | ||
"revision": Revision.V1, | ||
}, | ||
"message": { | ||
"Caller": outside_execution.caller, | ||
"Nonce": outside_execution.nonce, | ||
"Execute After": outside_execution.execute_after, | ||
"Execute Before": outside_execution.execute_before, | ||
"Calls": [ | ||
{ | ||
"To": call.to_addr, | ||
"Selector": call.selector, | ||
"Calldata": call.calldata, | ||
} | ||
for call in outside_execution.calls | ||
], | ||
}, | ||
} | ||
) |
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
Oops, something went wrong.