Skip to content

Commit

Permalink
Adds new examples from starknet.js and implements new mock logic
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagodeev committed Nov 21, 2024
1 parent 2ba0749 commit a1f7a01
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 21 deletions.
41 changes: 41 additions & 0 deletions typed/tests/example_baseTypes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"types": {
"StarknetDomain": [
{ "name": "name", "type": "shortstring" },
{ "name": "version", "type": "shortstring" },
{ "name": "chainId", "type": "shortstring" },
{ "name": "revision", "type": "shortstring" }
],
"Example": [
{ "name": "n0", "type": "felt" },
{ "name": "n1", "type": "bool" },
{ "name": "n2", "type": "string" },
{ "name": "n3", "type": "selector" },
{ "name": "n4", "type": "u128" },
{ "name": "n5", "type": "i128" },
{ "name": "n6", "type": "ContractAddress" },
{ "name": "n7", "type": "ClassHash" },
{ "name": "n8", "type": "timestamp" },
{ "name": "n9", "type": "shortstring" }
]
},
"primaryType": "Example",
"domain": {
"name": "StarkNet Mail",
"version": "1",
"chainId": "1",
"revision": "1"
},
"message": {
"n0": "0x3e8",
"n1": true,
"n2": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"n3": "transfer",
"n4": 10,
"n5": -10,
"n6": "0x3e8",
"n7": "0x3e8",
"n8": 1000,
"n9": "transfer"
}
}
38 changes: 38 additions & 0 deletions typed/tests/example_enum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"types": {
"StarknetDomain": [
{ "name": "name", "type": "shortstring" },
{ "name": "version", "type": "shortstring" },
{ "name": "chainId", "type": "shortstring" },
{ "name": "revision", "type": "shortstring" }
],
"Example": [
{ "name": "someEnum1", "type": "enum", "contains": "EnumA" },
{ "name": "someEnum2", "type": "enum", "contains": "EnumB" }
],
"EnumA": [
{ "name": "Variant 1", "type": "()" },
{ "name": "Variant 2", "type": "(u128,u128*)" },
{ "name": "Variant 3", "type": "(u128)" }
],
"EnumB": [
{ "name": "Variant 1", "type": "()" },
{ "name": "Variant 2", "type": "(u128)" }
]
},
"primaryType": "Example",
"domain": {
"name": "StarkNet Mail",
"version": "1",
"chainId": "1",
"revision": "1"
},
"message": {
"someEnum1": {
"Variant 2": [2, [0, 1]]
},
"someEnum2": {
"Variant 1": []
}
}
}
37 changes: 37 additions & 0 deletions typed/tests/example_presetTypes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"types": {
"StarknetDomain": [
{ "name": "name", "type": "shortstring" },
{ "name": "version", "type": "shortstring" },
{ "name": "chainId", "type": "shortstring" },
{ "name": "revision", "type": "shortstring" }
],
"Example": [
{ "name": "n0", "type": "TokenAmount" },
{ "name": "n1", "type": "NftId" }
]
},
"primaryType": "Example",
"domain": {
"name": "StarkNet Mail",
"version": "1",
"chainId": "1",
"revision": "1"
},
"message": {
"n0": {
"token_address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"amount": {
"low": "0x3e8",
"high": "0x0"
}
},
"n1": {
"collection_address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"token_id": {
"low": "0x3e8",
"high": "0x0"
}
}
}
}
44 changes: 44 additions & 0 deletions typed/tests/mail_StructArray.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"types": {
"StarkNetDomain": [
{ "name": "name", "type": "felt" },
{ "name": "version", "type": "felt" },
{ "name": "chainId", "type": "felt" }
],
"Person": [
{ "name": "name", "type": "felt" },
{ "name": "wallet", "type": "felt" }
],
"Post": [
{ "name": "title", "type": "felt" },
{ "name": "content", "type": "felt" }
],
"Mail": [
{ "name": "from", "type": "Person" },
{ "name": "to", "type": "Person" },
{ "name": "posts_len", "type": "felt" },
{ "name": "posts", "type": "Post*" }
]
},
"primaryType": "Mail",
"domain": {
"name": "StarkNet Mail",
"version": "1",
"chainId": 1
},
"message": {
"from": {
"name": "Cow",
"wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
},
"to": {
"name": "Bob",
"wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
},
"posts_len": 2,
"posts": [
{ "title": "Greeting", "content": "Hello, Bob!" },
{ "title": "Farewell", "content": "Goodbye, Bob!" }
]
}
}
42 changes: 42 additions & 0 deletions typed/tests/session_MerkleTree.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"primaryType": "Session",
"types": {
"Policy": [
{ "name": "contractAddress", "type": "felt" },
{ "name": "selector", "type": "selector" }
],
"Session": [
{ "name": "key", "type": "felt" },
{ "name": "expires", "type": "felt" },
{ "name": "root", "type": "merkletree", "contains": "Policy" }
],
"StarkNetDomain": [
{ "name": "name", "type": "felt" },
{ "name": "version", "type": "felt" },
{ "name": "chain_id", "type": "felt" }
]
},
"domain": {
"name": "StarkNet Mail",
"version": "1",
"chain_id": 1
},
"message": {
"key": "0x0000000000000000000000000000000000000000000000000000000000000000",
"expires": "0x0000000000000000000000000000000000000000000000000000000000000000",
"root": [
{
"contractAddress": "0x1",
"selector": "transfer"
},
{
"contractAddress": "0x2",
"selector": "transfer"
},
{
"contractAddress": "0x3",
"selector": "transfer"
}
]
}
}
126 changes: 126 additions & 0 deletions typed/tests/v1Nested.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"domain": {
"name": "Dappland",
"chainId": "0x534e5f5345504f4c4941",
"version": "1.0.2",
"revision": "1"
},
"message": {
"MessageId": 345,
"From": {
"Name": "Edmund",
"Address": "0x7e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a"
},
"To": {
"Name": "Alice",
"Address": "0x69b49c2cc8b16e80e86bfc5b0614a59aa8c9b601569c7b80dde04d3f3151b79"
},
"Nft_to_transfer": {
"Collection": "Stupid monkeys",
"Address": "0x69b49c2cc8b16e80e86bfc5b0614a59aa8c9b601569c7b80dde04d3f3151b79",
"Nft_id": 112,
"Negotiated_for": {
"Qty": "18.4569325643",
"Unit": "ETH",
"Token_address": "0x69b49c2cc8b16e80e86bfc5b0614a59aa8c9b601569c7b80dde04d3f3151b79",
"Amount": "0x100243260D270EB00"
}
},
"Comment1": "Monkey with banana, sunglasses,",
"Comment2": "and red hat.",
"Comment3": ""
},
"primaryType": "TransferERC721",
"types": {
"Account1": [
{
"name": "Name",
"type": "string"
},
{
"name": "Address",
"type": "felt"
}
],
"Nft": [
{
"name": "Collection",
"type": "string"
},
{
"name": "Address",
"type": "felt"
},
{
"name": "Nft_id",
"type": "felt"
},
{
"name": "Negotiated_for",
"type": "Transaction"
}
],
"Transaction": [
{
"name": "Qty",
"type": "string"
},
{
"name": "Unit",
"type": "string"
},
{
"name": "Token_address",
"type": "felt"
},
{
"name": "Amount",
"type": "felt"
}
],
"TransferERC721": [
{
"name": "MessageId",
"type": "felt"
},
{
"name": "From",
"type": "Account1"
},
{
"name": "To",
"type": "Account1"
},
{
"name": "Nft_to_transfer",
"type": "Nft"
},
{
"name": "Comment1",
"type": "string"
},
{
"name": "Comment2",
"type": "string"
},
{
"name": "Comment3",
"type": "string"
}
],
"StarknetDomain": [
{
"name": "name",
"type": "string"
},
{
"name": "chainId",
"type": "felt"
},
{
"name": "version",
"type": "string"
}
]
}
}
Loading

0 comments on commit a1f7a01

Please sign in to comment.