Skip to content

Commit

Permalink
Adapt to OZ 0.5.0 account (0xSpaceShard#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabijanC authored Oct 25, 2022
1 parent ccdc9aa commit 14c6bb4
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion page/docs/guide/Predeployed-accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 13

Devnet predeploys `--accounts` with some `--initial-balance`. To hide the details of these accounts use `--hide-predeployed-accounts`. The accounts get charged for transactions according to the `--gas-price`. A `--seed` can be used to regenerate the same set of accounts. Read more about it in the [Run section](run.md).

To get the code of the account (currently fork of OpenZeppelin's [v0.4.0b](https://github.com/OpenZeppelin/cairo-contracts/releases/tag/v0.4.0b)), use one of the following:
To get the code of the account (currently OpenZeppelin [v0.5.0](https://github.com/OpenZeppelin/cairo-contracts/releases/tag/v0.5.0)), use one of the following:

- `GET /get_code?contractAddress=<ACCOUNT_ADDRESS>`
- [StarkNet CLI](https://www.cairo-lang.org/docs/hello_starknet/cli.html#get-code): `starknet get_code --contract_address <ACCOUNT_ADDRESS> --feeder_gateway_url <DEVNET_URL>`
Expand Down
5 changes: 3 additions & 2 deletions page/docs/guide/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ After adding a new cairo-lang version, you will probably want to recompile contr
- Predeployed account addresses should be intact

6. Update directory/file names containing the version
7. Update expected test paths and addresses
8. Update docs
7. Adapt to ABI changes
8. Update expected test paths and addresses
9. Update docs

## Development - Build

Expand Down
2 changes: 1 addition & 1 deletion page/docs/guide/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ optional arguments:
--account-class ACCOUNT_CLASS
Specify the account implementation to be used for predeploying;
should be a path to the compiled JSON artifact;
defaults to a fork of OpenZeppelin v0.4.0b
defaults to OpenZeppelin v0.5.0
```

You can run `starknet-devnet` in a separate shell, or you can run it in background with `starknet-devnet &`.
Expand Down

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"members":[{"name":"to","offset":0,"type":"felt"},{"name":"selector","offset":1,"type":"felt"},{"name":"data_offset","offset":2,"type":"felt"},{"name":"data_len","offset":3,"type":"felt"}],"name":"AccountCallArray","size":4,"type":"struct"},{"inputs":[{"name":"publicKey","type":"felt"}],"name":"constructor","outputs":[],"type":"constructor"},{"inputs":[],"name":"getPublicKey","outputs":[{"name":"publicKey","type":"felt"}],"stateMutability":"view","type":"function"},{"inputs":[{"name":"interfaceId","type":"felt"}],"name":"supportsInterface","outputs":[{"name":"success","type":"felt"}],"stateMutability":"view","type":"function"},{"inputs":[{"name":"newPublicKey","type":"felt"}],"name":"setPublicKey","outputs":[],"type":"function"},{"inputs":[{"name":"hash","type":"felt"},{"name":"signature_len","type":"felt"},{"name":"signature","type":"felt*"}],"name":"isValidSignature","outputs":[{"name":"isValid","type":"felt"}],"stateMutability":"view","type":"function"},{"inputs":[{"name":"call_array_len","type":"felt"},{"name":"call_array","type":"AccountCallArray*"},{"name":"calldata_len","type":"felt"},{"name":"calldata","type":"felt*"}],"name":"__validate__","outputs":[],"type":"function"},{"inputs":[{"name":"class_hash","type":"felt"}],"name":"__validate_declare__","outputs":[],"type":"function"},{"inputs":[{"name":"call_array_len","type":"felt"},{"name":"call_array","type":"AccountCallArray*"},{"name":"calldata_len","type":"felt"},{"name":"calldata","type":"felt*"}],"name":"__execute__","outputs":[{"name":"response_len","type":"felt"},{"name":"response","type":"felt*"}],"type":"function"}]
4 changes: 2 additions & 2 deletions starknet_devnet/contract_class_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class ContractClassWrapper:
os.pardir,
"accounts_artifacts",
"OpenZeppelin",
"0.4.0b-fork",
"0.5.0",
"Account.cairo",
"Account.json",
)
)
DEFAULT_ACCOUNT_HASH_BYTES = to_bytes(
250058203962332945652607154704986145054927159797127109843768594742871092378
2308850740939678659398575035812067402979543458539300415910488838841673668983
)
2 changes: 1 addition & 1 deletion starknet_devnet/devnet_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def parse_args(raw_args: List[str]):
"--account-class",
help="Specify the account implementation to be used for predeploying; "
"should be a path to the compiled JSON artifact; "
"defaults to a fork of OpenZeppelin v0.4.0b",
"defaults to OpenZeppelin v0.5.0",
type=_parse_account_class,
default=DEFAULT_ACCOUNT_PATH,
)
Expand Down
2 changes: 1 addition & 1 deletion test/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

ACCOUNT_ARTIFACTS_PATH = "starknet_devnet/accounts_artifacts"
ACCOUNT_AUTHOR = "OpenZeppelin"
ACCOUNT_VERSION = "0.4.0b-fork"
ACCOUNT_VERSION = "0.5.0"

ACCOUNT_PATH = f"{ACCOUNT_ARTIFACTS_PATH}/{ACCOUNT_AUTHOR}/{ACCOUNT_VERSION}/Account.cairo/Account.json"
ACCOUNT_ABI_PATH = f"{ACCOUNT_ARTIFACTS_PATH}/{ACCOUNT_AUTHOR}/{ACCOUNT_VERSION}/Account.cairo/Account_abi.json"
Expand Down
8 changes: 4 additions & 4 deletions test/expected/invoke_function_invocation.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"execution_resources": {
"n_steps": 243,
"n_steps": 269,
"builtin_instance_counter": {
"range_check_builtin": 3
"range_check_builtin": 7
},
"n_memory_holes": 3
"n_memory_holes": 11
},
"messages": [],
"call_type": "CALL",
"class_hash": "0x8d8726481b7b8a4a8f95aa2ce6a18932c33148600c75b1b4fe40c5987c6c9a",
"class_hash": "0x51ac361b170bfbaeb1f5b3a33cc8827ae9990a5060103cb11d30be8b5375977",
"result": ["0x0"],
"events": [],
"calldata": [
Expand Down
10 changes: 5 additions & 5 deletions test/expected/invoke_receipt.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"actual_fee": "0x15fe22d104800",
"actual_fee": "0x16010bdfe1800",
"block_hash": "0x2",
"block_number": 2,
"events": [
{
"data": [
"0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"0x388ca486b82e20cc81965d056b4cdcaacdffe0cf08e20ed8ba10ea97a487004",
"0x15fe22d104800",
"0x16010bdfe1800",
"0x0"
],
"from_address": "0x62230ea046a9a5fbc261ac77d03c8d41e5d442db2284587570ab46455fd2488",
Expand All @@ -18,10 +18,10 @@
],
"execution_resources": {
"builtin_instance_counter": {
"range_check_builtin": 3
"range_check_builtin": 7
},
"n_memory_holes": 3,
"n_steps": 243
"n_memory_holes": 11,
"n_steps": 269
},
"l2_to_l1_messages": [],
"status": "ACCEPTED_ON_L2",
Expand Down
2 changes: 1 addition & 1 deletion test/expected/invoke_receipt_account_event.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"data": [
"0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"0x388ca486b82e20cc81965d056b4cdcaacdffe0cf08e20ed8ba10ea97a487004",
"0x5a50a44700",
"0x5a569a2800",
"0x0"
],
"from_address": "0x62230ea046a9a5fbc261ac77d03c8d41e5d442db2284587570ab46455fd2488",
Expand Down
2 changes: 1 addition & 1 deletion test/expected/invoke_receipt_event.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"data": [
"0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a",
"0x388ca486b82e20cc81965d056b4cdcaacdffe0cf08e20ed8ba10ea97a487004",
"0x160cb01b55800",
"0x160e24a2c4000",
"0x0"
],
"from_address": "0x62230ea046a9a5fbc261ac77d03c8d41e5d442db2284587570ab46455fd2488",
Expand Down
4 changes: 2 additions & 2 deletions test/rpc/test_data/get_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@
EVENT_FEE_1 = [
int(PREDEPLOYED_ACCOUNT_ADDRESS, 16),
EVENT_FEE_ADDRESS_2,
143100000000000, # WEI
143200000000000, # WEI
0,
]
EVENT_FEE_2 = [
int(PREDEPLOYED_ACCOUNT_ADDRESS, 16),
EVENT_FEE_ADDRESS_2,
387900000000000, # WEI
388000000000000, # WEI
0,
]

Expand Down
2 changes: 1 addition & 1 deletion test/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
INVOKE_CONTENT = load_file_content("invoke.json")
DEPLOY_CONTENT = load_file_content("deploy.json")
SALTY_ACCOUNT_ADDRESS = (
"0x00e5cadfe20c4192c560a8e803f779e21775d5288697f23487d256f1013510aa"
"0x030dec1363f9fc6ecf36be88845e43025861a851dce1439a61c1e7b148a9892b"
)
INVALID_HASH = "0x58d4d4ed7580a7a98ab608883ec9fe722424ce52c19f2f369eeea301f535914"
SALT = "0x99"
Expand Down

0 comments on commit 14c6bb4

Please sign in to comment.