-
Notifications
You must be signed in to change notification settings - Fork 822
Description
Describe the bug
encodeType
of type data does not encode preset types correctly.
You can verify this from the SNIP:
Where for every preset type, it says:
It will be encoded as the following object.
And per the X is an object, every object should encoded as follows:
escape(name) || "(" || escape(param1_name) || ":" || escape(param1_type) || "," || ... || escape(paramN_name) || ":"|| escape(paramN_type) || ")"
If the object references other objects/enum which can also reference other objects/enums, the set of referenced objects/enums is collected, sorted by name, and appended to the encoding.
The spec also refers to this repo for examples, where preset type u256
is included along with its properties.
To Reproduce
Run this test:
`"\\"Example\\"(\\"n0\\":\\"TokenAmount\\",\\"n1\\":\\"NftId\\")"` |
Expected behavior
All preset types are encoded as objects:
"Example"("n0":"TokenAmount","n1":"NftId")"NftId"("collection_address":"ContractAddress","token_id":"u256")"TokenAmount"("token_address":"ContractAddress","amount":"u256")"u256"("low":"u128","high":"u128")
Actual behavior
All preset types are encoded as basic types:
"Example"("n0":"TokenAmount","n1":"NftId")
Desktop (please complete the following information):
- Starknet.js version cb20590