-
Notifications
You must be signed in to change notification settings - Fork 91
Support SNIP-9 #1530
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
Merged
franciszekjob
merged 54 commits into
software-mansion:development
from
baitcode:feat-snip-9
Dec 16, 2024
Merged
Support SNIP-9 #1530
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
e25729f
Big things:
baitcode 40b01ed
- Added outside execution model, defined hashing
baitcode 9137b40
* lint
baitcode ac7b2cc
ok. so I am not allowed to change ci configs
baitcode 6a9fdc9
Merge branch 'development' into feat-snip-9
baitcode dcb044b
fixing tests
baitcode 0487bd6
lint
baitcode a79ab75
switched back to increase balance
baitcode aceded7
tiny revert
baitcode 5851f12
comment documentation test to check if that is what affects test acco…
baitcode e54e510
Revert "comment documentation test to check if that is what affects t…
baitcode 7ea8760
change for another call in documentation. removed account deployment.
baitcode 14531b1
fix
baitcode 37f24df
fix doctest
baitcode fb9829e
more fixes
baitcode 4f72882
remove balance change calls
baitcode 1881d84
Fixed naming
baitcode d369165
fix documentation
baitcode 2c2be9f
added secrets
baitcode f7867c1
trigger build
baitcode 799b399
Merge branch 'development' into feat-snip-9
baitcode a6b7774
Review comments fixws
baitcode 92d651c
linter
baitcode 585e8df
fixup
baitcode 9b12024
Added comment
baitcode 81da8fe
fix
baitcode 2bb0282
lost empty line
baitcode 812429d
comments fixes
baitcode 6e2b7f4
Update starknet_py/constants.py
baitcode 44faa3b
comment fixupi
baitcode 37b6ce4
fix wordings
baitcode 6cacd8b
fix
baitcode 11069b4
fixes
baitcode 45644f9
more fixes
baitcode 51f0f7f
more fixes
baitcode a449d8c
rename
baitcode a4e75c4
Fix
baitcode e3a3bed
linter
baitcode 0ac1845
Update starknet_py/tests/e2e/docs/guide/test_account_sign_outside_tra…
baitcode 8d98dbd
Update starknet_py/tests/e2e/docs/guide/test_account_sign_outside_tra…
baitcode dfdc252
Update starknet_py/net/account/base_account.py
baitcode c97df0f
a bit more review comment fixes
baitcode 86e8f84
revert execute_v1
baitcode 4b0b0a2
remove auto fee estimation
baitcode ee9a064
Update docs/guide/account_and_client.rst
baitcode 9776344
Update starknet_py/tests/e2e/docs/guide/test_account_sign_outside_tra…
baitcode 13d8fe0
Merge branch 'development' into feat-snip-9
baitcode ceaa8ca
import fix
baitcode a9aa417
fix doctest
baitcode df4079d
Update starknet_py/tests/e2e/account/outside_execution_test.py
baitcode 817d679
Update starknet_py/tests/e2e/account/outside_execution_test.py
baitcode b931c5c
changelog
baitcode e5e76e4
Update docs/migration_guide.rst
baitcode 7434a25
fixing fixes
baitcode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.