starknet-io / SNIPs

Starknet Improvement Proposal repository
MIT License
155 stars 96 forks source link

SNIP-9: Adding a new Cairo-2 compatible version for OutsideExecution type hashing #76

Closed maorveitsman closed 7 months ago

maorveitsman commented 8 months ago

This change is Reviewable

sgc-code commented 8 months ago

It would make sense to have a new interface ID. Accounts could implement both versions (or just one) and dapps could be able to tell what's supported by the account. To achieve that i propose renaming the cairo methods execute_from_outside to execute_from_outside_v2?, And the same for the other external method

sgc-code commented 8 months ago

For version 2 I suggest the following:

  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*" },
  ]

There are two changes here:

There is also an additional change that needs to be done to be compliant with SNIP-12 rev1. That's escaping the names with quotes (JSON escape) as mentioned here https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-12.md#specification That will generate different type hashes For instance the Call will be encoded as: starknet_keccak('Call("To":"ContractAddress","Selector":"selector","Calldata":"felt*")')