Skip to content

Commit

Permalink
* Fix types in SNIP 12 to be an object
Browse files Browse the repository at this point in the history
* Add revisions to TYPED_DATA
* Change SYMBOL to TOKEN_SYMBOL
* Change TXN_HASH to PADDED_TXN_HASH
* Rename chain_id to chainId and primary_type to primaryType to fit SNIP
  12 definitions
  • Loading branch information
amanusk committed Apr 24, 2024
1 parent 78c9052 commit cf2a8c2
Showing 1 changed file with 42 additions and 15 deletions.
57 changes: 42 additions & 15 deletions wallet-api/wallet_rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
"properties": {
"transaction_hash": {
"title": "Transaction Hash",
"$ref": "#/components/schemas/TXN_HASH"
"$ref": "#/components/schemas/PADDED_TXN_HASH"
}
},
"required": ["transaction_hash"]
Expand Down Expand Up @@ -275,7 +275,7 @@
"properties": {
"transaction_hash": {
"title": "The hash of the declare transaction",
"$ref": "#/components/schemas/TXN_HASH"
"$ref": "#/components/schemas/PADDED_TXN_HASH"
},
"class_hash": {
"title": "The hash of the declared class",
Expand Down Expand Up @@ -334,18 +334,18 @@
"components": {
"contentDescriptors": {},
"schemas": {
"TXN_HASH": {
"title": "Transaction hash",
"description": "The transaction hash, as assigned in Starknet",
"PADDED_TXN_HASH": {
"title": "Padded Transaction Hash",
"description": "The transaction hash, as assigned in Starknet, padded to 64 hex digits",
"$ref": "#/components/schemas/PADDED_FELT"
},
"ADDRESS": {
"title": "Address",
"$ref": "#/components/schemas/FELT"
},
"SYMBOL": {
"TOKEN_SYMBOL": {
"title": "ERC20 Token Symbol",
"description": "The symbol of an contract",
"description": "The symbol of the token",
"type": "string",
"minLength": 1,
"maxLength": 6,
Expand Down Expand Up @@ -381,7 +381,7 @@
},
"symbol": {
"title": "Token Symbol",
"$ref": "#/components/schemas/SYMBOL"
"$ref": "#/components/schemas/TOKEN_SYMBOL"
},
"decimals": {
"type": "number",
Expand Down Expand Up @@ -577,6 +577,23 @@
},
"required": ["name", "type", "contains"]
},
"STARKNET_ENUM_TYPE": {
"title": "Starknet Enum Type",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string",
"enum": ["enum"]
},
"contains": {
"type": "string"
}
},
"required": ["name", "type", "contains"]
},
"STARKNET_TYPE": {
"title": "Starknet Type",
"description": "A single type, as part of a struct. The `type` field can be any of the EIP-712 supported types",
Expand All @@ -592,6 +609,9 @@
},
{
"$ref": "#/components/schemas/STARKNET_MERKLE_TYPE"
},
{
"$ref": "#/components/schemas/STARKNET_ENUM_TYPE"
}
]
}
Expand All @@ -602,12 +622,15 @@
"properties": {
"types": {
"description": "Defines the types of the typed data object",
"type": "array",
"itmes": {
"$ref": "#/components/schemas/STARKNET_TYPE"
"type": "object",
"additionalProperties": {
"type": "array",
"itmes": {
"$ref": "#/components/schemas/STARKNET_TYPE"
}
}
},
"primary_type": {
"primaryType": {
"type": "string",
"description": "primaryType represents the top-level type of the object in the message"
},
Expand All @@ -620,7 +643,7 @@
"description": "The message to be signed"
}
},
"required": ["types", "primary_type", "domain", "message"]
"required": ["types", "primaryType", "domain", "message"]
},
"STARKNET_DOMAIN": {
"title": "Starknet Domain",
Expand All @@ -629,16 +652,20 @@
"properties": {
"name": { "type": "string" },
"version": { "type": "string" },
"chain_id": {
"chainId": {
"anyOf": [{ "type": "string" }, { "type": "number" }]
},
"revision": {
"type": "string",
"enum": ["0", "1"]
}
}
},
"PADDED_FELT": {
"type": "string",
"title": "Padded felt",
"description": "A padded felt represented as 62 hex digits, 3 bits, and 5 leading zero bits.",
"pattern": "^0x(0[0-7]{1}[a-fA-F0-9]{62}$)"
"pattern": "^0x(0[0-8]{1}[a-fA-F0-9]{62}$)"
},
"CONTRACT_CLASS": {
"$ref": "./api/starknet_api_openrpc.json#/components/schemas/CONTRACT_CLASS"
Expand Down

0 comments on commit cf2a8c2

Please sign in to comment.