status-desktop/storybook/qmlTests/tests/tst_SessionRequest.qml

72 lines
22 KiB
QML
Raw Blame History

import QtQuick 2.15
import QtTest 1.15
import AppLayouts.Wallet.services.dapps.types 1.0
Item {
id: root
TestCase {
id: sessionRequestTest
function test_parse_data() {
return [
{
// valid eth_sign
expected: {"request":{"event":{"id":1730896224189361,"params":{"chainId":"eip155:1","request":{"method":"eth_sign","params":["0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","requestId":1730896224189361,"method":"eth_sign","account":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","data":{"message":"\u0005=H\u0000Æ5NvÇ])\"È/µ³ôW{/àTòà"},"preparedData":"\u0005=H\u0000Æ5NvÇ])\"È/µ³ôW{/àTòà","value":"0","chainId":1},"error":0},
event: {"id":1730896224189361,"params":{"chainId":"eip155:1","request":{"method":"eth_sign","params":["0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}}
},
{
// valid personal_sign
expected: {"request":{"event":{"id":1730896110928724,"params":{"chainId":"eip155:1","request":{"method":"personal_sign","params":["0x4578616d706c652060706572736f6e616c5f7369676e60206d657373616765","0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","Example password"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","requestId":1730896110928724,"method":"personal_sign","account":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","data":{"message":"Example `personal_sign` message"},"preparedData":"Example `personal_sign` message","value":"0","chainId":1},"error":0},
event: {"id":1730896110928724,"params":{"chainId":"eip155:1","request":{"method":"personal_sign","params":["0x4578616d706c652060706572736f6e616c5f7369676e60206d657373616765","0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","Example password"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}}
},
{
// valid typed_data
expected: {"request":{"event":{"id":1730896224189361,"params":{"chainId":"eip155:1","request":{"method":"eth_sign","params":["0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","requestId":1730896224189361,"method":"eth_sign","account":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","data":{"message":`<EFBFBD><EFBFBD>\u0005=H\u0000<EFBFBD>5NvǘZ<EFBFBD>])\"<22>/<2F><><EFBFBD>W{/<2F><><EFBFBD><EFBFBD>T<EFBFBD><54>`},"preparedData":"<EFBFBD><EFBFBD>\u0005=H\u0000<EFBFBD>5NvǘZ<EFBFBD>])\"<22>/<2F><><EFBFBD>W{/<2F><><EFBFBD><EFBFBD>T<EFBFBD><54>","value":"0","chainId":1}, "error":0},
event: {"id":1730896224189361,"params":{"chainId":"eip155:1","request":{"method":"eth_sign","params":["0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}}
},
{
// valid eth_signTypedData_v4
expected: {"request":{"event":{"id":1730896495619543,"params":{"chainId":"eip155:1","request":{"method":"eth_signTypedData_v4","params":["0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","{\"domain\":{\"chainId\":\"1\",\"name\":\"Ether Mail\",\"verifyingContract\":\"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC\",\"version\":\"1\"},\"message\":{\"contents\":\"Hello, Bob!\",\"from\":{\"name\":\"Cow\",\"wallets\":[\"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826\",\"0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF\"]},\"to\":[{\"name\":\"Bob\",\"wallets\":[\"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB\",\"0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57\",\"0xB0B0b0b0b0b0B000000000000000000000000000\"]}],\"attachment\":\"0x\"},\"primaryType\":\"Mail\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Group\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"members\",\"type\":\"Person[]\"}],\"Mail\":[{\"name\":\"from\",\"type\":\"Person\"},{\"name\":\"to\",\"type\":\"Person[]\"},{\"name\":\"contents\",\"type\":\"string\"},{\"name\":\"attachment\",\"type\":\"bytes\"}],\"Person\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"wallets\",\"type\":\"address[]\"}]}}"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","requestId":1730896495619543,"method":"eth_signTypedData_v4","account":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","data":{"message":"{\"domain\":{\"chainId\":\"1\",\"name\":\"Ether Mail\",\"verifyingContract\":\"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC\",\"version\":\"1\"},\"message\":{\"contents\":\"Hello, Bob!\",\"from\":{\"name\":\"Cow\",\"wallets\":[\"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826\",\"0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF\"]},\"to\":[{\"name\":\"Bob\",\"wallets\":[\"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB\",\"0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57\",\"0xB0B0b0b0b0b0B000000000000000000000000000\"]}],\"attachment\":\"0x\"},\"primaryType\":\"Mail\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Group\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"members\",\"type\":\"Person[]\"}],\"Mail\":[{\"name\":\"from\",\"type\":\"Person\"},{\"name\":\"to\",\"type\":\"Person[]\"},{\"name\":\"contents\",\"type\":\"string\"},{\"name\":\"attachment\",\"type\":\"bytes\"}],\"Person\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"wallets\",\"type\":\"address[]\"}]}}"},"preparedData":"{\n \"domain\": {\n \"chainId\": \"1\",\n \"name\": \"Ether Mail\",\n \"verifyingContract\": \"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC\",\n \"version\": \"1\"\n },\n \"message\": {\n \"contents\": \"Hello, Bob!\",\n \"from\": {\n \"name\": \"Cow\",\n \"wallets\": [\n \"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826\",\n \"0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF\"\n ]\n },\n \"to\": [\n {\n \"name\": \"Bob\",\n \"wallets\": [\n \"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB\",\n \"0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57\",\n \"0xB0B0b0b0b0b0B000000000000000000000000000\"\n ]\n }\n ],\n \"attachment\": \"0x\"\n },\n \"primaryType\": \"Mail\",\n \"types\": {\n \"EIP712Domain\": [\n {\n \"name\": \"name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"version\",\n \"type\": \"string\"\n },\n {\n \"name\": \"chainId\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"verifyingContract\",\n \"type\": \"address\"\n }\n ],\n \"Group\": [\n {\n \"name\": \"name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"members\",\n \"type\": \"Person[]\"\n }\n ],\n \"Mail\": [\n {\n \"name\": \"from\",\n \"type\": \"Person\"\n },\n {\n \"name\": \"to\",\n \"type\": \"Person[]\"\n },\n {\n \"name\": \"contents\",\n \"type\": \"string\"\n },\n {\n \"name\": \"attachment\",\n \"type\": \"bytes\"\n }\n ],\n \"Person\": [\n {\n \"name\": \"name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"wallets\",\n \"type\": \"address[]\"\n }\n ]\n }\n}","value":"0","chainId":1},"error":0},
event: {"id":1730896495619543,"params":{"chainId":"eip155:1","request":{"method":"eth_signTypedData_v4","params":["0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","{\"domain\":{\"chainId\":\"1\",\"name\":\"Ether Mail\",\"verifyingContract\":\"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC\",\"version\":\"1\"},\"message\":{\"contents\":\"Hello, Bob!\",\"from\":{\"name\":\"Cow\",\"wallets\":[\"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826\",\"0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF\"]},\"to\":[{\"name\":\"Bob\",\"wallets\":[\"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB\",\"0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57\",\"0xB0B0b0b0b0b0B000000000000000000000000000\"]}],\"attachment\":\"0x\"},\"primaryType\":\"Mail\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Group\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"members\",\"type\":\"Person[]\"}],\"Mail\":[{\"name\":\"from\",\"type\":\"Person\"},{\"name\":\"to\",\"type\":\"Person[]\"},{\"name\":\"contents\",\"type\":\"string\"},{\"name\":\"attachment\",\"type\":\"bytes\"}],\"Person\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"wallets\",\"type\":\"address[]\"}]}}"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}}
},
{
// valid sign permit
expected: {"request":{"event":{"id":1730896621650994,"params":{"chainId":"eip155:1","request":{"method":"eth_signTypedData_v4","params":["0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","{\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Permit\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"deadline\",\"type\":\"uint256\"}]},\"primaryType\":\"Permit\",\"domain\":{\"name\":\"MyToken\",\"version\":\"1\",\"verifyingContract\":\"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC\",\"chainId\":null},\"message\":{\"owner\":\"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240\",\"spender\":\"0x5B38Da6a701c568545dCfcB03FcB875f56beddC4\",\"value\":3000,\"nonce\":0,\"deadline\":50000000000}}"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","requestId":1730896621650994,"method":"eth_signTypedData_v4","account":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","data":{"message":"{\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Permit\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"deadline\",\"type\":\"uint256\"}]},\"primaryType\":\"Permit\",\"domain\":{\"name\":\"MyToken\",\"version\":\"1\",\"verifyingContract\":\"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC\",\"chainId\":null},\"message\":{\"owner\":\"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240\",\"spender\":\"0x5B38Da6a701c568545dCfcB03FcB875f56beddC4\",\"value\":3000,\"nonce\":0,\"deadline\":50000000000}}"},"preparedData":"{\n \"types\": {\n \"EIP712Domain\": [\n {\n \"name\": \"name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"version\",\n \"type\": \"string\"\n },\n {\n \"name\": \"chainId\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"verifyingContract\",\n \"type\": \"address\"\n }\n ],\n \"Permit\": [\n {\n \"name\": \"owner\",\n \"type\": \"address\"\n },\n {\n \"name\": \"spender\",\n \"type\": \"address\"\n },\n {\n \"name\": \"value\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"nonce\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"deadline\",\n \"type\": \"uint256\"\n }\n ]\n },\n \"primaryType\": \"Permit\",\n \"domain\": {\n \"name\": \"MyToken\",\n \"version\": \"1\",\n \"verifyingContract\": \"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC\",\n \"chainId\": null\n },\n \"message\": {\n \"owner\": \"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240\",\n \"spender\": \"0x5B38Da6a701c568545dCfcB03FcB875f56beddC4\",\n \"value\": 3000,\n \"nonce\": 0,\n \"deadline\": 50000000000\n }\n}","value":"0","chainId":1},"error":0},
event: {"id":1730896621650994,"params":{"chainId":"eip155:1","request":{"method":"eth_signTypedData_v4","params":["0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","{\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Permit\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"deadline\",\"type\":\"uint256\"}]},\"primaryType\":\"Permit\",\"domain\":{\"name\":\"MyToken\",\"version\":\"1\",\"verifyingContract\":\"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC\",\"chainId\":null},\"message\":{\"owner\":\"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240\",\"spender\":\"0x5B38Da6a701c568545dCfcB03FcB875f56beddC4\",\"value\":3000,\"nonce\":0,\"deadline\":50000000000}}"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}}
},
{
// valid SIWE
expected: {"request":{"event":{"id":1730896696709302,"params":{"chainId":"eip155:1","request":{"method":"personal_sign","params":["0x6d6574616d61736b2e6769746875622e696f2077616e747320796f7520746f207369676e20696e207769746820796f757220457468657265756d206163636f756e743a0a3078374634374332653138613442426635343837453666623038326543324439416230453664373234300a0a492061636365707420746865204d6574614d61736b205465726d73206f6620536572766963653a2068747470733a2f2f636f6d6d756e6974792e6d6574616d61736b2e696f2f746f730a0a5552493a2068747470733a2f2f6d6574616d61736b2e6769746875622e696f0a56657273696f6e3a20310a436861696e2049443a20310a4e6f6e63653a2033323839313735370a4973737565642041743a20323032312d30392d33305431363a32353a32342e3030305a","0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","Example password"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","requestId":1730896696709302,"method":"personal_sign","account":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","data":{"message":"metamask.github.io wants you to sign in with your Ethereum account:\n0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240\n\nI accept the MetaMask Terms of Service: https://community.metamask.io/tos\n\nURI: https://metamask.github.io\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z"},"preparedData":"metamask.github.io wants you to sign in with your Ethereum account:\n0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240\n\nI accept the MetaMask Terms of Service: https://community.metamask.io/tos\n\nURI: https://metamask.github.io\nVersion: 1\nChain ID: 1\nNonce: 32891757\nIssued At: 2021-09-30T16:25:24.000Z","value":"0","chainId":1},"error":0},
event: {"id":1730896696709302,"params":{"chainId":"eip155:1","request":{"method":"personal_sign","params":["0x6d6574616d61736b2e6769746875622e696f2077616e747320796f7520746f207369676e20696e207769746820796f757220457468657265756d206163636f756e743a0a3078374634374332653138613442426635343837453666623038326543324439416230453664373234300a0a492061636365707420746865204d6574614d61736b205465726d73206f6620536572766963653a2068747470733a2f2f636f6d6d756e6974792e6d6574616d61736b2e696f2f746f730a0a5552493a2068747470733a2f2f6d6574616d61736b2e6769746875622e696f0a56657273696f6e3a20310a436861696e2049443a20310a4e6f6e63653a2033323839313735370a4973737565642041743a20323032312d30392d33305431363a32353a32342e3030305a","0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","Example password"]}},"topic":"43a74a4c6c71e3ab67ef80283dc43f392445642c8dce3dabe63f89ab83cfcfc3","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}}
},
{
// valid EIP 1159 transaction
expected: {"request":{"event":{"id":1730899979094571,"params":{"chainId":"eip155:1","request":{"method":"eth_sendTransaction","params":[{"from":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","gasLimit":"0x5028","maxFeePerGas":"0x2540be400","maxPriorityFeePerGas":"0x3b9aca00","to":"0x0c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb","value":"0x0"}]}},"topic":"147fa9ddffcf9d782b5e002eb36b041e43a1db2bad79a598da6926105ce6680f","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}},"topic":"147fa9ddffcf9d782b5e002eb36b041e43a1db2bad79a598da6926105ce6680f","requestId":1730899979094571,"method":"eth_sendTransaction","account":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","data":{"tx":{"from":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","gasLimit":"0x5028","maxFeePerGas":"0x2540be400","maxPriorityFeePerGas":"0x3b9aca00","to":"0x0c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb","value":"0x0"}},"preparedData":"{\n \"from\": \"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240\",\n \"gasLimit\": 20520,\n \"maxFeePerGas\": \"10\",\n \"maxPriorityFeePerGas\": \"1\",\n \"to\": \"0x0c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb\",\n \"value\": \"0\"\n}","value":"0","transaction":{"from":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","gasLimit":"0x5028","maxFeePerGas":"0x2540be400","maxPriorityFeePerGas":"0x3b9aca00","to":"0x0c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb","value":"0x0"},"chainId":1},"error":0},
event: {"id":1730899979094571,"params":{"chainId":"eip155:1","request":{"method":"eth_sendTransaction","params":[{"from":"0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240","gasLimit":"0x5028","maxFeePerGas":"0x2540be400","maxPriorityFeePerGas":"0x3b9aca00","to":"0x0c54FcCd2e384b4BB6f2E405Bf5Cbc15a017AaFb","value":"0x0"}]}},"topic":"147fa9ddffcf9d782b5e002eb36b041e43a1db2bad79a598da6926105ce6680f","verifyContext":{"verified":{"origin":"https://metamask.github.io/test-dapp/","validation":"UNKNOWN","verifyUrl":"https://verify.walletconnect.org"}}}
}
]
}
function test_parse(data) {
const { expected, event } = data
const result = SessionRequest.parse(event)
compare(result.error, expected.error)
compare(result.request.topic, expected.request.topic)
compare(result.request.requestId, expected.request.requestId)
compare(result.request.method, expected.request.method)
compare(result.request.account, expected.request.account)
compare(result.request.value, expected.request.value)
compare(result.request.chainId, expected.request.chainId)
compare(!!result.request.transaction, !!expected.request.transaction)
if (!!result.request.transaction) {
compare(result.request.transaction.from, expected.request.transaction.from)
compare(result.request.transaction.gasLimit, expected.request.transaction.gasLimit)
compare(result.request.transaction.maxFeePerGas, expected.request.transaction.maxFeePerGas)
compare(result.request.transaction.maxPriorityFeePerGas, expected.request.transaction.maxPriorityFeePerGas)
compare(result.request.transaction.to, expected.request.transaction.to)
compare(result.request.transaction.value, expected.request.transaction.value)
}
}
}
}