git.delta.rocks / unique-network / refs/commits / d48c5e7c30b1

difftreelog

Merge branch 'develop' into feature/ci-refactoring

Max Andreev2022-11-07parents: #8ad52a6 #71a39d0.patch.diff
in: master

73 files changed

modified.docker/forkless-config/launch-config-forkless-data.j2diffbeforeafterboth
107 "--rpc-cors=all",107 "--rpc-cors=all",
108 "--unsafe-rpc-external",108 "--unsafe-rpc-external",
109 "--unsafe-ws-external",109 "--unsafe-ws-external",
110 "-lxcm=trace"110 "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug"
111 ]111 ]
112 },112 },
113 {113 {
119 "--rpc-cors=all",119 "--rpc-cors=all",
120 "--unsafe-rpc-external",120 "--unsafe-rpc-external",
121 "--unsafe-ws-external",121 "--unsafe-ws-external",
122 "-lxcm=trace"122 "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug"
123 ]123 ]
124 }124 }
125 ]125 ]
modified.docker/forkless-config/launch-config-forkless-nodata.j2diffbeforeafterboth
101 "--rpc-cors=all",101 "--rpc-cors=all",
102 "--unsafe-rpc-external",102 "--unsafe-rpc-external",
103 "--unsafe-ws-external",103 "--unsafe-ws-external",
104 "-lxcm=trace",104 "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug",
105 "--ws-max-connections=1000"105 "--ws-max-connections=1000"
106 ]106 ]
107 },107 },
114 "--rpc-cors=all",114 "--rpc-cors=all",
115 "--unsafe-rpc-external",115 "--unsafe-rpc-external",
116 "--unsafe-ws-external",116 "--unsafe-ws-external",
117 "-lxcm=trace",117 "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug",
118 "--ws-max-connections=1000"118 "--ws-max-connections=1000"
119 ]119 ]
120 }120 }
modified.docker/forkless-config/launch-config-node-update-only-v3.j2diffbeforeafterboth
101 "--rpc-cors=all",101 "--rpc-cors=all",
102 "--unsafe-rpc-external",102 "--unsafe-rpc-external",
103 "--unsafe-ws-external",103 "--unsafe-ws-external",
104 "-lxcm=trace",104 "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug",
105 "--ws-max-connections=1000"105 "--ws-max-connections=1000"
106 ]106 ]
107 },107 },
114 "--rpc-cors=all",114 "--rpc-cors=all",
115 "--unsafe-rpc-external",115 "--unsafe-rpc-external",
116 "--unsafe-ws-external",116 "--unsafe-ws-external",
117 "-lxcm=trace",117 "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug",
118 "--ws-max-connections=1000"118 "--ws-max-connections=1000"
119 ]119 ]
120 }120 }
modified.docker/xcm-config/launch-config-xcm-opal.jsondiffbeforeafterboth
91 "name": "alice",91 "name": "alice",
92 "flags": [92 "flags": [
93 "--unsafe-rpc-external",93 "--unsafe-rpc-external",
94 "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug",
94 "--unsafe-ws-external"95 "--unsafe-ws-external"
95 ]96 ]
96 }97 }
modified.docker/xcm-config/launch-config-xcm-quartz.jsondiffbeforeafterboth
90 "rpcPort": 9933,90 "rpcPort": 9933,
91 "name": "alice",91 "name": "alice",
92 "flags": [92 "flags": [
93 "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug",
93 "--unsafe-rpc-external",94 "--unsafe-rpc-external",
94 "--unsafe-ws-external"95 "--unsafe-ws-external"
95 ]96 ]
modified.docker/xcm-config/launch-config-xcm-unique.jsondiffbeforeafterboth
90 "rpcPort": 9933,90 "rpcPort": 9933,
91 "name": "alice",91 "name": "alice",
92 "flags": [92 "flags": [
93 "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug",
93 "--unsafe-rpc-external",94 "--unsafe-rpc-external",
94 "--unsafe-ws-external"95 "--unsafe-ws-external"
95 ]96 ]
modified.maintain/scripts/compile_stub.shdiffbeforeafterboth
6tmp=$(mktemp -d)6tmp=$(mktemp -d)
7cd $tmp7cd $tmp
8cp $dir/$INPUT input.sol8cp $dir/$INPUT input.sol
9echo "Tmp file: $tmp/input.sol"
9solcjs --optimize --bin input.sol -o $PWD10solcjs --optimize --bin input.sol -o $PWD
1011
11mv input_sol_$(basename $OUTPUT .raw).bin out.bin12mv input_sol_$(basename $OUTPUT .raw).bin out.bin
modified.maintain/scripts/generate_sol.shdiffbeforeafterboth
4PRETTIER_CONFIG="$(pwd)""/.prettierrc"4PRETTIER_CONFIG="$(pwd)""/.prettierrc"
55
6tmp=$(mktemp)6tmp=$(mktemp)
7cargo test --package $PACKAGE -- $NAME --exact --nocapture --ignored | tee $tmp7cargo test --package=$PACKAGE --features=stubgen -- $NAME --exact --nocapture --ignored | tee $tmp
8raw=$(mktemp --suffix .sol)8raw=$(mktemp --suffix .sol)
9sed -n '/=== SNIP START ===/, /=== SNIP END ===/{ /=== SNIP START ===/! { /=== SNIP END ===/! p } }' $tmp > $raw9sed -n '/=== SNIP START ===/, /=== SNIP END ===/{ /=== SNIP START ===/! { /=== SNIP END ===/! p } }' $tmp > $raw
1010
modifiedCargo.lockdiffbeforeafterboth
252252
253[[package]]253[[package]]
254name = "async-lock"254name = "async-lock"
255version = "2.5.0"255version = "2.6.0"
256source = "registry+https://github.com/rust-lang/crates.io-index"256source = "registry+https://github.com/rust-lang/crates.io-index"
257checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6"257checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685"
258dependencies = [258dependencies = [
259 "event-listener",259 "event-listener",
260 "futures-lite",
260]261]
261262
262[[package]]263[[package]]
977978
978[[package]]979[[package]]
979name = "clap"980name = "clap"
980version = "3.2.22"981version = "3.2.23"
981source = "registry+https://github.com/rust-lang/crates.io-index"982source = "registry+https://github.com/rust-lang/crates.io-index"
982checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750"983checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
983dependencies = [984dependencies = [
984 "atty",985 "atty",
985 "bitflags",986 "bitflags",
18711872
1872[[package]]1873[[package]]
1873name = "cxx"1874name = "cxx"
1874version = "1.0.78"1875version = "1.0.80"
1875source = "registry+https://github.com/rust-lang/crates.io-index"1876source = "registry+https://github.com/rust-lang/crates.io-index"
1876checksum = "19f39818dcfc97d45b03953c1292efc4e80954e1583c4aa770bac1383e2310a4"1877checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a"
1877dependencies = [1878dependencies = [
1878 "cc",1879 "cc",
1879 "cxxbridge-flags",1880 "cxxbridge-flags",
18831884
1884[[package]]1885[[package]]
1885name = "cxx-build"1886name = "cxx-build"
1886version = "1.0.78"1887version = "1.0.80"
1887source = "registry+https://github.com/rust-lang/crates.io-index"1888source = "registry+https://github.com/rust-lang/crates.io-index"
1888checksum = "3e580d70777c116df50c390d1211993f62d40302881e54d4b79727acb83d0199"1889checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827"
1889dependencies = [1890dependencies = [
1890 "cc",1891 "cc",
1891 "codespan-reporting",1892 "codespan-reporting",
18981899
1899[[package]]1900[[package]]
1900name = "cxxbridge-flags"1901name = "cxxbridge-flags"
1901version = "1.0.78"1902version = "1.0.80"
1902source = "registry+https://github.com/rust-lang/crates.io-index"1903source = "registry+https://github.com/rust-lang/crates.io-index"
1903checksum = "56a46460b88d1cec95112c8c363f0e2c39afdb237f60583b0b36343bf627ea9c"1904checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a"
19041905
1905[[package]]1906[[package]]
1906name = "cxxbridge-macro"1907name = "cxxbridge-macro"
1907version = "1.0.78"1908version = "1.0.80"
1908source = "registry+https://github.com/rust-lang/crates.io-index"1909source = "registry+https://github.com/rust-lang/crates.io-index"
1909checksum = "747b608fecf06b0d72d440f27acc99288207324b793be2c17991839f3d4995ea"1910checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7"
1910dependencies = [1911dependencies = [
1911 "proc-macro2",1912 "proc-macro2",
1912 "quote",1913 "quote",
21282129
2129[[package]]2130[[package]]
2130name = "ed25519-zebra"2131name = "ed25519-zebra"
2131version = "3.0.0"2132version = "3.1.0"
2132source = "registry+https://github.com/rust-lang/crates.io-index"2133source = "registry+https://github.com/rust-lang/crates.io-index"
2133checksum = "403ef3e961ab98f0ba902771d29f842058578bb1ce7e3c59dad5a6a93e784c69"2134checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6"
2134dependencies = [2135dependencies = [
2135 "curve25519-dalek 3.2.0",2136 "curve25519-dalek 3.2.0",
2137 "hashbrown",
2136 "hex",2138 "hex",
2137 "rand_core 0.6.4",2139 "rand_core 0.6.4",
2138 "sha2 0.9.9",2140 "sha2 0.9.9",
2139 "thiserror",
2140 "zeroize",2141 "zeroize",
2141]2142]
21422143
23312332
2332[[package]]2333[[package]]
2333name = "evm-coder"2334name = "evm-coder"
2334version = "0.1.3"2335version = "0.1.4"
2335dependencies = [2336dependencies = [
2336 "concat-idents",2337 "concat-idents",
2337 "ethereum",2338 "ethereum",
2341 "hex",2342 "hex",
2342 "hex-literal",2343 "hex-literal",
2343 "impl-trait-for-tuples",2344 "impl-trait-for-tuples",
2345 "pallet-evm",
2344 "primitive-types",2346 "primitive-types",
2347 "sha3-const",
2345 "similar-asserts",2348 "similar-asserts",
2346 "sp-std",2349 "sp-std",
2350 "trybuild",
2347]2351]
23482352
2349[[package]]2353[[package]]
2350name = "evm-coder-procedural"2354name = "evm-coder-procedural"
2351version = "0.2.0"2355version = "0.2.1"
2352dependencies = [2356dependencies = [
2353 "Inflector",2357 "Inflector",
2354 "hex",2358 "hex",
33363340
3337[[package]]3341[[package]]
3338name = "h2"3342name = "h2"
3339version = "0.3.14"3343version = "0.3.15"
3340source = "registry+https://github.com/rust-lang/crates.io-index"3344source = "registry+https://github.com/rust-lang/crates.io-index"
3341checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be"3345checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4"
3342dependencies = [3346dependencies = [
3343 "bytes",3347 "bytes",
3344 "fnv",3348 "fnv",
35613565
3562[[package]]3566[[package]]
3563name = "iana-time-zone-haiku"3567name = "iana-time-zone-haiku"
3564version = "0.1.0"3568version = "0.1.1"
3565source = "registry+https://github.com/rust-lang/crates.io-index"3569source = "registry+https://github.com/rust-lang/crates.io-index"
3566checksum = "fde6edd6cef363e9359ed3c98ba64590ba9eecba2293eb5a723ab32aee8926aa"3570checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
3567dependencies = [3571dependencies = [
3568 "cxx",3572 "cxx",
3569 "cxx-build",3573 "cxx-build",
37023706
3703[[package]]3707[[package]]
3704name = "io-lifetimes"3708name = "io-lifetimes"
3705version = "0.7.3"3709version = "0.7.4"
3706source = "registry+https://github.com/rust-lang/crates.io-index"3710source = "registry+https://github.com/rust-lang/crates.io-index"
3707checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06"3711checksum = "e6e481ccbe3dea62107216d0d1138bb8ad8e5e5c43009a098bd1990272c497b0"
37083712
3709[[package]]3713[[package]]
3710name = "ip_network"3714name = "ip_network"
40934097
4094[[package]]4098[[package]]
4095name = "libc"4099name = "libc"
4096version = "0.2.135"4100version = "0.2.137"
4097source = "registry+https://github.com/rust-lang/crates.io-index"4101source = "registry+https://github.com/rust-lang/crates.io-index"
4098checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"4102checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
40994103
4100[[package]]4104[[package]]
4101name = "libloading"4105name = "libloading"
49674971
4968[[package]]4972[[package]]
4969name = "mio"4973name = "mio"
4970version = "0.8.4"4974version = "0.8.5"
4971source = "registry+https://github.com/rust-lang/crates.io-index"4975source = "registry+https://github.com/rust-lang/crates.io-index"
4972checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf"4976checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
4973dependencies = [4977dependencies = [
4974 "libc",4978 "libc",
4975 "log",4979 "log",
4976 "wasi 0.11.0+wasi-snapshot-preview1",4980 "wasi 0.11.0+wasi-snapshot-preview1",
4977 "windows-sys 0.36.1",4981 "windows-sys 0.42.0",
4978]4982]
49794983
4980[[package]]4984[[package]]
58265830
5827[[package]]5831[[package]]
5828name = "pallet-common"5832name = "pallet-common"
5829version = "0.1.9"5833version = "0.1.10"
5830dependencies = [5834dependencies = [
5831 "ethereum",5835 "ethereum",
5832 "evm-coder",5836 "evm-coder",
61166120
6117[[package]]6121[[package]]
6118name = "pallet-fungible"6122name = "pallet-fungible"
6119version = "0.1.5"6123version = "0.1.6"
6120dependencies = [6124dependencies = [
6121 "ethereum",6125 "ethereum",
6122 "evm-coder",6126 "evm-coder",
63596363
6360[[package]]6364[[package]]
6361name = "pallet-nonfungible"6365name = "pallet-nonfungible"
6362version = "0.1.6"6366version = "0.1.7"
6363dependencies = [6367dependencies = [
6364 "ethereum",6368 "ethereum",
6365 "evm-coder",6369 "evm-coder",
64816485
6482[[package]]6486[[package]]
6483name = "pallet-refungible"6487name = "pallet-refungible"
6484version = "0.2.5"6488version = "0.2.6"
6485dependencies = [6489dependencies = [
6486 "derivative",6490 "derivative",
6487 "ethereum",6491 "ethereum",
72487252
7249[[package]]7253[[package]]
7250name = "pkg-config"7254name = "pkg-config"
7251version = "0.3.25"7255version = "0.3.26"
7252source = "registry+https://github.com/rust-lang/crates.io-index"7256source = "registry+https://github.com/rust-lang/crates.io-index"
7253checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"7257checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
72547258
7255[[package]]7259[[package]]
7256name = "platforms"7260name = "platforms"
85018505
8502[[package]]8506[[package]]
8503name = "polling"8507name = "polling"
8504version = "2.3.0"8508version = "2.4.0"
8505source = "registry+https://github.com/rust-lang/crates.io-index"8509source = "registry+https://github.com/rust-lang/crates.io-index"
8506checksum = "899b00b9c8ab553c743b3e11e87c5c7d423b2a2de229ba95b24a756344748011"8510checksum = "ab4609a838d88b73d8238967b60dd115cc08d38e2bbaf51ee1e4b695f89122e2"
8507dependencies = [8511dependencies = [
8508 "autocfg",8512 "autocfg",
8509 "cfg-if 1.0.0",8513 "cfg-if 1.0.0",
94089412
9409[[package]]9413[[package]]
9410name = "rustix"9414name = "rustix"
9411version = "0.35.11"9415version = "0.35.12"
9412source = "registry+https://github.com/rust-lang/crates.io-index"9416source = "registry+https://github.com/rust-lang/crates.io-index"
9413checksum = "fbb2fda4666def1433b1b05431ab402e42a1084285477222b72d6c564c417cef"9417checksum = "985947f9b6423159c4726323f373be0a21bdb514c5af06a849cb3d2dce2d01e8"
9414dependencies = [9418dependencies = [
9415 "bitflags",9419 "bitflags",
9416 "errno",9420 "errno",
1068310687
10684[[package]]10688[[package]]
10685name = "secp256k1"10689name = "secp256k1"
10686version = "0.24.0"10690version = "0.24.1"
10687source = "registry+https://github.com/rust-lang/crates.io-index"10691source = "registry+https://github.com/rust-lang/crates.io-index"
10688checksum = "b7649a0b3ffb32636e60c7ce0d70511eda9c52c658cd0634e194d5a19943aeff"10692checksum = "ff55dc09d460954e9ef2fa8a7ced735a964be9981fd50e870b2b3b0705e14964"
10689dependencies = [10693dependencies = [
10690 "secp256k1-sys",10694 "secp256k1-sys",
10691]10695]
1076610770
10767[[package]]10771[[package]]
10768name = "serde"10772name = "serde"
10769version = "1.0.146"10773version = "1.0.147"
10770source = "registry+https://github.com/rust-lang/crates.io-index"10774source = "registry+https://github.com/rust-lang/crates.io-index"
10771checksum = "6df50b7a60a0ad48e1b42eb38373eac8ff785d619fb14db917b4e63d5439361f"10775checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
10772dependencies = [10776dependencies = [
10773 "serde_derive",10777 "serde_derive",
10774]10778]
1077510779
10776[[package]]10780[[package]]
10777name = "serde_derive"10781name = "serde_derive"
10778version = "1.0.146"10782version = "1.0.147"
10779source = "registry+https://github.com/rust-lang/crates.io-index"10783source = "registry+https://github.com/rust-lang/crates.io-index"
10780checksum = "a714fd32ba1d66047ce7d53dabd809e9922d538f9047de13cc4cffca47b36205"10784checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
10781dependencies = [10785dependencies = [
10782 "proc-macro2",10786 "proc-macro2",
10783 "quote",10787 "quote",
1078610790
10787[[package]]10791[[package]]
10788name = "serde_json"10792name = "serde_json"
10789version = "1.0.86"10793version = "1.0.87"
10790source = "registry+https://github.com/rust-lang/crates.io-index"10794source = "registry+https://github.com/rust-lang/crates.io-index"
10791checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074"10795checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45"
10792dependencies = [10796dependencies = [
10793 "itoa",10797 "itoa",
10794 "ryu",10798 "ryu",
10874 "keccak",10878 "keccak",
10875]10879]
10880
10881[[package]]
10882name = "sha3-const"
10883version = "0.1.1"
10884source = "registry+https://github.com/rust-lang/crates.io-index"
10885checksum = "b04774de876479a8f712e787f8271b14712971329a4be66c6dff144db7cfc343"
1087610886
10877[[package]]10887[[package]]
10878name = "sharded-slab"10888name = "sharded-slab"
1206712077
12068[[package]]12078[[package]]
12069name = "syn"12079name = "syn"
12070version = "1.0.102"12080version = "1.0.103"
12071source = "registry+https://github.com/rust-lang/crates.io-index"12081source = "registry+https://github.com/rust-lang/crates.io-index"
12072checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1"12082checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
12073dependencies = [12083dependencies = [
12074 "proc-macro2",12084 "proc-macro2",
12075 "quote",12085 "quote",
1219812208
12199[[package]]12209[[package]]
12200name = "textwrap"12210name = "textwrap"
12201version = "0.15.1"12211version = "0.16.0"
12202source = "registry+https://github.com/rust-lang/crates.io-index"12212source = "registry+https://github.com/rust-lang/crates.io-index"
12203checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"12213checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
1220412214
12205[[package]]12215[[package]]
12206name = "thiserror"12216name = "thiserror"
12642 "zstd",12652 "zstd",
12643]12653]
12654
12655[[package]]
12656name = "trybuild"
12657version = "1.0.71"
12658source = "registry+https://github.com/rust-lang/crates.io-index"
12659checksum = "ea496675d71016e9bc76aa42d87f16aefd95447cc5818e671e12b2d7e269075d"
12660dependencies = [
12661 "glob",
12662 "once_cell",
12663 "serde",
12664 "serde_derive",
12665 "serde_json",
12666 "termcolor",
12667 "toml",
12668]
1264412669
12645[[package]]12670[[package]]
12646name = "tt-call"12671name = "tt-call"
modifiedcrates/evm-coder/CHANGELOG.mddiffbeforeafterboth
22
3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.
44
5<!-- bureaucrate goes here -->
5## [0.1.3] - 2022-08-296## [v0.1.4] - 2022-11-02
7### Added
8 - Named structures support.
69
10## [v0.1.3] - 2022-08-29
11
7### Fixed12### Fixed
813
9 - Parsing simple values.14 - Parsing simple values.
1015
11<!-- bureaucrate goes here -->
12## [v0.1.2] 2022-08-1916## [v0.1.2] 2022-08-19
1317
14### Added18### Added
modifiedcrates/evm-coder/Cargo.tomldiffbeforeafterboth
1[package]1[package]
2name = "evm-coder"2name = "evm-coder"
3version = "0.1.3"3version = "0.1.4"
4license = "GPLv3"4license = "GPLv3"
5edition = "2021"5edition = "2021"
66
7[dependencies]7[dependencies]
8sha3-const = { version = "0.1.1", default-features = false }
8# evm-coder reexports those proc-macro9# evm-coder reexports those proc-macro
9evm-coder-procedural = { path = "./procedural" }10evm-coder-procedural = { path = "./procedural" }
10# Evm uses primitive-types for H160, H256 and others11# Evm uses primitive-types for H160, H256 and others
18# We have tuple-heavy code in solidity.rs19# We have tuple-heavy code in solidity.rs
19impl-trait-for-tuples = "0.2.2"20impl-trait-for-tuples = "0.2.2"
21
22pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.30" }
2023
21[dev-dependencies]24[dev-dependencies]
22# We want to assert some large binary blobs equality in tests25# We want to assert some large binary blobs equality in tests
23hex = "0.4.3"26hex = "0.4.3"
24hex-literal = "0.3.4"27hex-literal = "0.3.4"
25similar-asserts = "1.4.2"28similar-asserts = "1.4.2"
26concat-idents = "1.1.3"29concat-idents = "1.1.3"
30trybuild = "1.0"
2731
28[features]32[features]
29default = ["std"]33default = ["std"]
33 "evm-core/std",37 "evm-core/std",
34 "frame-support/std",38 "frame-support/std",
35]39]
40# Stub/interface generation
41stubgen = []
3642
modifiedcrates/evm-coder/procedural/Cargo.tomldiffbeforeafterboth
1[package]1[package]
2name = "evm-coder-procedural"2name = "evm-coder-procedural"
3version = "0.2.0"3version = "0.2.1"
4license = "GPLv3"4license = "GPLv3"
5edition = "2021"5edition = "2021"
66
modifiedcrates/evm-coder/procedural/src/lib.rsdiffbeforeafterboth
107 if path.segments.len() != 1 {107 if path.segments.len() != 1 {
108 return Err(syn::Error::new(108 return Err(syn::Error::new(
109 path.span(),109 path.span(),
110 "expected path to have only segment",110 "expected path to have only one segment",
111 ));111 ));
112 }112 }
113 let last_segment = &path.segments.last().unwrap();113 let last_segment = &path.segments.last().unwrap();
modifiedcrates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth
20// about Procedural Macros in Rust book:20// about Procedural Macros in Rust book:
21// https://doc.rust-lang.org/reference/procedural-macros.html21// https://doc.rust-lang.org/reference/procedural-macros.html
2222
23use proc_macro2::TokenStream;
23use quote::{quote, ToTokens};24use quote::{quote, format_ident};
24use inflector::cases;25use inflector::cases;
25use std::fmt::Write;
26use syn::{26use syn::{
27 Expr, FnArg, GenericArgument, Generics, Ident, ImplItem, ImplItemMethod, ItemImpl, Lit, Meta,27 Expr, FnArg, Generics, Ident, ImplItem, ImplItemMethod, ItemImpl, Lit, Meta, MetaNameValue,
28 MetaNameValue, PatType, PathArguments, ReturnType, Type,28 PatType, ReturnType, Type,
29 spanned::Spanned,29 spanned::Spanned,
30 parse::{Parse, ParseStream},30 parse::{Parse, ParseStream},
31 parenthesized, Token, LitInt, LitStr,31 parenthesized, Token, LitInt, LitStr,
32};32};
3333
34use crate::{34use crate::{
35 fn_selector_str, parse_ident_from_pat, parse_ident_from_path, parse_path, parse_path_segment,35 parse_ident_from_pat, parse_ident_from_path, parse_path, parse_path_segment, parse_result_ok,
36 parse_result_ok, pascal_ident_to_call, pascal_ident_to_snake_call, snake_ident_to_pascal,36 pascal_ident_to_call, pascal_ident_to_snake_call, snake_ident_to_pascal,
37 snake_ident_to_screaming,37 snake_ident_to_screaming,
38};38};
328 }328 }
329}329}
330330
331enum AbiType {331trait AbiType {
332 // type
333 Plain(Ident),332 fn plain(&self) -> syn::Result<&Ident>;
334 // (type1,type2)
335 Tuple(Vec<AbiType>),333 fn is_value(&self) -> bool;
336 // type[]
337 Vec(Box<AbiType>),334 fn is_caller(&self) -> bool;
338 // type[20]
339 Array(Box<AbiType>, usize),335 fn is_special(&self) -> bool;
340}336}
337
341impl AbiType {338impl AbiType for Type {
342 fn try_from(value: &Type) -> syn::Result<Self> {
343 let value = Self::try_maybe_special_from(value)?;
344 if value.is_special() {
345 return Err(syn::Error::new(value.span(), "unexpected special type"));
346 }
347 Ok(value)
348 }
349 fn try_maybe_special_from(value: &Type) -> syn::Result<Self> {339 fn plain(&self) -> syn::Result<&Ident> {
350 match value {
351 Type::Array(arr) => {
352 let wrapped = AbiType::try_from(&arr.elem)?;
353 match &arr.len {
354 Expr::Lit(l) => match &l.lit {
355 Lit::Int(i) => {
356 let num = i.base10_parse::<usize>()?;
357 Ok(AbiType::Array(Box::new(wrapped), num as usize))
358 }
359 _ => Err(syn::Error::new(arr.len.span(), "should be int literal")),
360 },
361 _ => Err(syn::Error::new(arr.len.span(), "should be literal")),
362 }
363 }
364 Type::Path(_) => {
365 let path = parse_path(value)?;340 let path = parse_path(self)?;
366 let segment = parse_path_segment(path)?;341 let segment = parse_path_segment(path)?;
367 if segment.ident == "Vec" {342 if !segment.arguments.is_empty() {
368 let args = match &segment.arguments {
369 PathArguments::AngleBracketed(e) => e,
370 _ => {
371 return Err(syn::Error::new(
372 segment.arguments.span(),
373 "missing Vec generic",
374 ))
375 }
376 };
377 let args = &args.args;
378 if args.len() != 1 {
379 return Err(syn::Error::new(
380 args.span(),
381 "expected only one generic for vec",
382 ));
383 }
384 let arg = args.first().expect("first arg");
385
386 let ty = match arg {
387 GenericArgument::Type(ty) => ty,
388 _ => {
389 return Err(syn::Error::new(
390 arg.span(),
391 "expected first generic to be type",
392 ))
393 }
394 };
395
396 let wrapped = AbiType::try_from(ty)?;
397 Ok(Self::Vec(Box::new(wrapped)))
398 } else {
399 if !segment.arguments.is_empty() {
400 return Err(syn::Error::new(343 return Err(syn::Error::new(self.span(), "Not plain type"));
401 segment.arguments.span(),
402 "unexpected generic arguments for non-vec type",
403 ));
404 }344 }
405 Ok(Self::Plain(segment.ident.clone()))345 Ok(&segment.ident)
406 }
407 }346 }
408 Type::Tuple(t) => {347
409 let mut out = Vec::with_capacity(t.elems.len());
410 for el in t.elems.iter() {
411 out.push(AbiType::try_from(el)?)
412 }
413 Ok(Self::Tuple(out))
414 }
415 _ => Err(syn::Error::new(
416 value.span(),
417 "unexpected type, only arrays, plain types and tuples are supported",
418 )),
419 }
420 }
421 fn is_value(&self) -> bool {348 fn is_value(&self) -> bool {
422 matches!(self, Self::Plain(v) if v == "value")349 if let Ok(ident) = self.plain() {
350 return ident == "value";
351 }
352 false
423 }353 }
354
424 fn is_caller(&self) -> bool {355 fn is_caller(&self) -> bool {
425 matches!(self, Self::Plain(v) if v == "caller")356 if let Ok(ident) = self.plain() {
357 return ident == "caller";
358 }
359 false
426 }360 }
361
427 fn is_special(&self) -> bool {362 fn is_special(&self) -> bool {
428 self.is_caller() || self.is_value()363 self.is_caller() || self.is_value()
429 }364 }
430 fn selector_ty_buf(&self, buf: &mut String) -> std::fmt::Result {365}
431 match self {366
432 AbiType::Plain(t) => {367#[derive(Debug)]
433 write!(buf, "{}", t)
434 }
435 AbiType::Tuple(t) => {
436 write!(buf, "(")?;
437 for (i, t) in t.iter().enumerate() {
438 if i != 0 {
439 write!(buf, ",")?;
440 }
441 t.selector_ty_buf(buf)?;
442 }
443 write!(buf, ")")
444 }
445 AbiType::Vec(v) => {
446 v.selector_ty_buf(buf)?;
447 write!(buf, "[]")
448 }
449 AbiType::Array(v, len) => {
450 v.selector_ty_buf(buf)?;
451 write!(buf, "[{}]", len)
452 }
453 }
454 }
455 fn selector_ty(&self) -> String {
456 let mut out = String::new();
457 self.selector_ty_buf(&mut out).expect("no fmt error");
458 out
459 }
460}
461impl ToTokens for AbiType {
462 fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
463 match self {
464 AbiType::Plain(t) => tokens.extend(quote! {#t}),
465 AbiType::Tuple(t) => {
466 tokens.extend(quote! {(
467 #(#t),*
468 )});
469 }
470 AbiType::Vec(v) => tokens.extend(quote! {Vec<#v>}),
471 AbiType::Array(v, l) => tokens.extend(quote! {[#v; #l]}),
472 }
473 }
474}
475
476struct MethodArg {368struct MethodArg {
477 name: Ident,369 name: Ident,
478 camel_name: String,370 camel_name: String,
479 ty: AbiType,371 ty: Type,
480}372}
481impl MethodArg {373impl MethodArg {
482 fn try_from(value: &PatType) -> syn::Result<Self> {374 fn try_from(value: &PatType) -> syn::Result<Self> {
483 let name = parse_ident_from_pat(&value.pat)?.clone();375 let name = parse_ident_from_pat(&value.pat)?.clone();
484 Ok(Self {376 Ok(Self {
485 camel_name: cases::camelcase::to_camel_case(&name.to_string()),377 camel_name: cases::camelcase::to_camel_case(&name.to_string()),
486 name,378 name,
487 ty: AbiType::try_maybe_special_from(&value.ty)?,379 ty: value.ty.as_ref().clone(),
488 })380 })
489 }381 }
490 fn is_value(&self) -> bool {382 fn is_value(&self) -> bool {
496 fn is_special(&self) -> bool {388 fn is_special(&self) -> bool {
497 self.ty.is_special()389 self.ty.is_special()
498 }390 }
499 fn selector_ty(&self) -> String {
500 assert!(!self.is_special());
501 self.ty.selector_ty()
502 }
503391
504 fn expand_call_def(&self) -> proc_macro2::TokenStream {392 fn expand_call_def(&self) -> proc_macro2::TokenStream {
505 assert!(!self.is_special());393 assert!(!self.is_special());
514 fn expand_parse(&self) -> proc_macro2::TokenStream {402 fn expand_parse(&self) -> proc_macro2::TokenStream {
515 assert!(!self.is_special());403 assert!(!self.is_special());
516 let name = &self.name;404 let name = &self.name;
405 let ty = &self.ty;
517 quote! {406 quote! {
518 #name: reader.abi_read()?407 #name: <#ty>::abi_read(reader)?
519 }408 }
520 }409 }
521410
575 camel_name: String,464 camel_name: String,
576 pascal_name: Ident,465 pascal_name: Ident,
577 screaming_name: Ident,466 screaming_name: Ident,
578 selector_str: String,
579 selector: u32,
580 hide: bool,467 hide: bool,
581 args: Vec<MethodArg>,468 args: Vec<MethodArg>,
582 has_normal_args: bool,469 has_normal_args: bool,
667 let camel_name = info554 let camel_name = info
668 .rename_selector555 .rename_selector
669 .unwrap_or_else(|| cases::camelcase::to_camel_case(&ident.to_string()));556 .unwrap_or_else(|| cases::camelcase::to_camel_case(&ident.to_string()));
670 let mut selector_str = camel_name.clone();
671 selector_str.push('(');
672 let mut has_normal_args = false;557 let has_normal_args = args.iter().filter(|arg| !arg.is_special()).count() != 0;
673 for (i, arg) in args.iter().filter(|arg| !arg.is_special()).enumerate() {
674 if i != 0 {
675 selector_str.push(',');
676 }
677 write!(selector_str, "{}", arg.selector_ty()).unwrap();
678 has_normal_args = true;
679 }
680 let has_value_args = args.iter().any(|a| a.is_value());558 let has_value_args = args.iter().any(|a| a.is_value());
681 selector_str.push(')');
682 let selector = fn_selector_str(&selector_str);
683559
684 Ok(Self {560 Ok(Self {
685 name: ident.clone(),561 name: ident.clone(),
686 camel_name,562 camel_name,
687 pascal_name: snake_ident_to_pascal(ident),563 pascal_name: snake_ident_to_pascal(ident),
688 screaming_name: snake_ident_to_screaming(ident),564 screaming_name: snake_ident_to_screaming(ident),
689 selector_str,
690 selector,
691 hide: info.hide,565 hide: info.hide,
692 args,566 args,
693 has_normal_args,567 has_normal_args,
728602
729 fn expand_const(&self) -> proc_macro2::TokenStream {603 fn expand_const(&self) -> proc_macro2::TokenStream {
730 let screaming_name = &self.screaming_name;604 let screaming_name = &self.screaming_name;
731 let selector = u32::to_be_bytes(self.selector);605 let screaming_name_signature = format_ident!("{}_SIGNATURE", &self.screaming_name);
732 let selector_str = &self.selector_str;606 let custom_signature = self.expand_custom_signature();
733 quote! {607 quote! {
734 #[doc = #selector_str]608 const #screaming_name_signature: ::evm_coder::custom_signature::SignatureUnit = #custom_signature;
735 const #screaming_name: ::evm_coder::types::bytes4 = [#(#selector,)*];609 const #screaming_name: ::evm_coder::types::bytes4 = {
610 let mut sum = ::evm_coder::sha3_const::Keccak256::new();
611 let mut pos = 0;
612 while pos < Self::#screaming_name_signature.len {
613 sum = sum.update(&[Self::#screaming_name_signature.data[pos]; 1]);
614 pos += 1;
615 }
616 let a = sum.finalize();
617 [a[0], a[1], a[2], a[3]]
618 };
736 }619 }
737 }620 }
738621
836 }719 }
837 }720 }
721
722 fn expand_custom_signature(&self) -> proc_macro2::TokenStream {
723 let mut args = TokenStream::new();
724
725 let mut has_params = false;
726 for arg in self.args.iter().filter(|a| !a.is_special()) {
727 has_params = true;
728 let ty = &arg.ty;
729 args.extend(quote! {nameof(<#ty>::SIGNATURE)});
730 args.extend(quote! {fixed(",")})
731 }
732
733 // Remove trailing comma
734 if has_params {
735 args.extend(quote! {shift_left(1)})
736 }
737
738 let func_name = self.camel_name.clone();
739 quote! { ::evm_coder::make_signature!(new fixed(#func_name) fixed("(") #args fixed(")")) }
740 }
838741
839 fn expand_solidity_function(&self) -> proc_macro2::TokenStream {742 fn expand_solidity_function(&self) -> proc_macro2::TokenStream {
840 let camel_name = &self.camel_name;743 let camel_name = &self.camel_name;
851 .filter(|a| !a.is_special())754 .filter(|a| !a.is_special())
852 .map(MethodArg::expand_solidity_argument);755 .map(MethodArg::expand_solidity_argument);
853 let docs = &self.docs;756 let docs = &self.docs;
854 let selector_str = &self.selector_str;757 let screaming_name = &self.screaming_name;
855 let selector = self.selector;758 let hide = self.hide;
856 let hide = self.hide;759 let custom_signature = self.expand_custom_signature();
857 let is_payable = self.has_value_args;760 let is_payable = self.has_value_args;
761
858 quote! {762 quote! {
859 SolidityFunction {763 SolidityFunction {
860 docs: &[#(#docs),*],764 docs: &[#(#docs),*],
861 selector_str: #selector_str,765 hide: #hide,
862 selector: #selector,766 selector: u32::from_be_bytes(Self::#screaming_name),
863 hide: #hide,767 custom_signature: #custom_signature,
864 name: #camel_name,768 name: #camel_name,
865 mutability: #mutability,769 mutability: #mutability,
866 is_payable: #is_payable,770 is_payable: #is_payable,
1027931
1028 let docs = &self.docs;932 let docs = &self.docs;
1029
1030 if let Some(expect_selector) = &self.info.expect_selector {
1031 if !self.info.inline_is.0.is_empty() {
1032 return syn::Error::new(
1033 name.span(),
1034 "expect_selector is not compatible with inline_is",
1035 )
1036 .to_compile_error();
1037 }
1038 let selector = self
1039 .methods
1040 .iter()
1041 .map(|m| m.selector)
1042 .fold(0, |a, b| a ^ b);
1043
1044 if *expect_selector != selector {
1045 let mut methods = String::new();
1046 for meth in self.methods.iter() {
1047 write!(methods, "\n- {}", meth.selector_str).expect("write to string");
1048 }
1049 return syn::Error::new(name.span(), format!("expected selector mismatch, expected {expect_selector:0>8x}, but implementation has {selector:0>8x}{methods}")).to_compile_error();
1050 }
1051 }
1052 // let methods = self.methods.iter().map(Method::solidity_def);
1053933
1054 quote! {934 quote! {
1055 #[derive(Debug)]935 #[derive(Debug)]
1076 u32::to_be_bytes(interface_id)956 u32::to_be_bytes(interface_id)
1077 }957 }
1078 /// Generate solidity definitions for methods described in this interface958 /// Generate solidity definitions for methods described in this interface
959 #[cfg(feature = "stubgen")]
1079 pub fn generate_solidity_interface(tc: &evm_coder::solidity::TypeCollector, is_impl: bool) {960 pub fn generate_solidity_interface(tc: &evm_coder::solidity::TypeCollector, is_impl: bool) {
1080 use evm_coder::solidity::*;961 use evm_coder::solidity::*;
1081 use core::fmt::Write;962 use core::fmt::Write;
modifiedcrates/evm-coder/procedural/src/to_log.rsdiffbeforeafterboth
196 )*196 )*
197
197 /// Generate solidity definitions for methods described in this interface198 /// Generate solidity definitions for methods described in this interface
199 #[cfg(feature = "stubgen")]
198 pub fn generate_solidity_interface(tc: &evm_coder::solidity::TypeCollector, is_impl: bool) {200 pub fn generate_solidity_interface(tc: &evm_coder::solidity::TypeCollector, is_impl: bool) {
199 use evm_coder::solidity::*;201 use evm_coder::solidity::*;
200 use core::fmt::Write;202 use core::fmt::Write;
modifiedcrates/evm-coder/src/abi.rsdiffbeforeafterboth
26use crate::{26use crate::{
27 execution::{Error, ResultWithPostInfo, WithPostDispatchInfo},27 execution::{Error, ResultWithPostInfo, WithPostDispatchInfo},
28 types::*,28 types::*,
29 make_signature,
30 custom_signature::{SignatureUnit},
29};31};
30use crate::execution::Result;32use crate::execution::Result;
3133
340 }342 }
341}343}
342344
343/// [`AbiReader`] implements reading of many types, but it should345/// [`AbiReader`] implements reading of many types.
344/// be limited to types defined in spec
345///
346/// As this trait can't be made sealed,
347/// instead of having `impl AbiRead for T`, we have `impl AbiRead<T> for AbiReader`
348pub trait AbiRead<T> {346pub trait AbiRead {
349 /// Read item from current position, advanding decoder347 /// Read item from current position, advanding decoder
350 fn abi_read(&mut self) -> Result<T>;348 fn abi_read(reader: &mut AbiReader) -> Result<Self>
349 where
350 Self: Sized;
351}351}
352352
353macro_rules! impl_abi_readable {353macro_rules! impl_abi_readable {
354 ($ty:ty, $method:ident, $dynamic:literal) => {354 ($ty:ty, $method:ident, $dynamic:literal) => {
355 impl sealed::CanBePlacedInVec for $ty {}
356
355 impl TypeHelper for $ty {357 impl TypeHelper for $ty {
356 fn is_dynamic() -> bool {358 fn is_dynamic() -> bool {
362 }364 }
363 }365 }
366
364 impl AbiRead<$ty> for AbiReader<'_> {367 impl AbiRead for $ty {
365 fn abi_read(&mut self) -> Result<$ty> {368 fn abi_read(reader: &mut AbiReader) -> Result<$ty> {
366 self.$method()369 reader.$method()
367 }370 }
368 }371 }
369 };372 };
370}373}
371374
372impl_abi_readable!(bool, bool, false);375impl_abi_readable!(bool, bool, false);
373impl_abi_readable!(uint8, uint8, false);
374impl_abi_readable!(uint32, uint32, false);376impl_abi_readable!(uint32, uint32, false);
375impl_abi_readable!(uint64, uint64, false);377impl_abi_readable!(uint64, uint64, false);
376impl_abi_readable!(uint128, uint128, false);378impl_abi_readable!(uint128, uint128, false);
377impl_abi_readable!(uint256, uint256, false);379impl_abi_readable!(uint256, uint256, false);
378impl_abi_readable!(bytes4, bytes4, false);380impl_abi_readable!(bytes4, bytes4, false);
379impl_abi_readable!(address, address, false);381impl_abi_readable!(address, address, false);
380impl_abi_readable!(string, string, true);382impl_abi_readable!(string, string, true);
381// impl_abi_readable!(bytes, bytes, true);383
384impl TypeHelper for uint8 {
385 fn is_dynamic() -> bool {
386 false
387 }
388 fn size() -> usize {
389 ABI_ALIGNMENT
390 }
391}
392impl AbiRead for uint8 {
393 fn abi_read(reader: &mut AbiReader) -> Result<uint8> {
394 reader.uint8()
395 }
396}
382397
383impl TypeHelper for bytes {398impl TypeHelper for bytes {
384 fn is_dynamic() -> bool {399 fn is_dynamic() -> bool {
388 ABI_ALIGNMENT403 ABI_ALIGNMENT
389 }404 }
390}405}
391impl AbiRead<bytes> for AbiReader<'_> {406impl AbiRead for bytes {
392 fn abi_read(&mut self) -> Result<bytes> {407 fn abi_read(reader: &mut AbiReader) -> Result<bytes> {
393 Ok(bytes(self.bytes()?))408 Ok(bytes(reader.bytes()?))
394 }409 }
395}410}
396411
399 pub trait CanBePlacedInVec {}414 pub trait CanBePlacedInVec {}
400}415}
401
402impl sealed::CanBePlacedInVec for U256 {}
403impl sealed::CanBePlacedInVec for string {}
404impl sealed::CanBePlacedInVec for H160 {}
405416
406impl<R: sealed::CanBePlacedInVec> AbiRead<Vec<R>> for AbiReader<'_>417impl<R: AbiRead + sealed::CanBePlacedInVec> AbiRead for Vec<R> {
407where
408 Self: AbiRead<R>,
409{
410 fn abi_read(&mut self) -> Result<Vec<R>> {418 fn abi_read(reader: &mut AbiReader) -> Result<Vec<R>> {
411 let mut sub = self.subresult(None)?;419 let mut sub = reader.subresult(None)?;
412 let size = sub.uint32()? as usize;420 let size = sub.uint32()? as usize;
413 sub.subresult_offset = sub.offset;421 sub.subresult_offset = sub.offset;
414 let mut out = Vec::with_capacity(size);422 let mut out = Vec::with_capacity(size);
415 for _ in 0..size {423 for _ in 0..size {
416 out.push(<Self as AbiRead<R>>::abi_read(&mut sub)?);424 out.push(<R>::abi_read(&mut sub)?);
417 }425 }
418 Ok(out)426 Ok(out)
419 }427 }
420}428}
429
430impl<R: Signature> Signature for Vec<R> {
431 const SIGNATURE: SignatureUnit = make_signature!(new nameof(R::SIGNATURE) fixed("[]"));
432}
433
434impl sealed::CanBePlacedInVec for EthCrossAccount {}
435
436impl TypeHelper for EthCrossAccount {
437 fn is_dynamic() -> bool {
438 address::is_dynamic() || uint256::is_dynamic()
439 }
440
441 fn size() -> usize {
442 <address as TypeHelper>::size() + <uint256 as TypeHelper>::size()
443 }
444}
445
446impl AbiRead for EthCrossAccount {
447 fn abi_read(reader: &mut AbiReader) -> Result<EthCrossAccount> {
448 let size = if !EthCrossAccount::is_dynamic() {
449 Some(<EthCrossAccount as TypeHelper>::size())
450 } else {
451 None
452 };
453 let mut subresult = reader.subresult(size)?;
454 let eth = <address>::abi_read(&mut subresult)?;
455 let sub = <uint256>::abi_read(&mut subresult)?;
456
457 Ok(EthCrossAccount { eth, sub })
458 }
459}
460
461impl AbiWrite for EthCrossAccount {
462 fn abi_write(&self, writer: &mut AbiWriter) {
463 self.eth.abi_write(writer);
464 self.sub.abi_write(writer);
465 }
466}
421467
422macro_rules! impl_tuples {468macro_rules! impl_tuples {
423 ($($ident:ident)+) => {469 ($($ident:ident)+) => {
487
441 impl<$($ident),+> sealed::CanBePlacedInVec for ($($ident,)+) {}488 impl<$($ident),+> sealed::CanBePlacedInVec for ($($ident,)+) {}
489
442 impl<$($ident),+> AbiRead<($($ident,)+)> for AbiReader<'_>490 impl<$($ident),+> AbiRead for ($($ident,)+)
443 where491 where
444 $(492 $($ident: AbiRead,)+
445 Self: AbiRead<$ident>,
446 )+
447 ($($ident,)+): TypeHelper,493 ($($ident,)+): TypeHelper,
448 {494 {
449 fn abi_read(&mut self) -> Result<($($ident,)+)> {495 fn abi_read(reader: &mut AbiReader) -> Result<($($ident,)+)> {
450 let size = if !<($($ident,)+)>::is_dynamic() { Some(<($($ident,)+)>::size()) } else { None };496 let size = if !<($($ident,)+)>::is_dynamic() { Some(<($($ident,)+)>::size()) } else { None };
451 let mut subresult = self.subresult(size)?;497 let mut subresult = reader.subresult(size)?;
452 Ok((498 Ok((
453 $(<Self as AbiRead<$ident>>::abi_read(&mut subresult)?,)+499 $(<$ident>::abi_read(&mut subresult)?,)+
454 ))500 ))
455 }501 }
456 }502 }
471 }518 }
472 }519 }
520
521 impl<$($ident),+> Signature for ($($ident,)+)
522 where
523 $($ident: Signature,)+
524 {
525 const SIGNATURE: SignatureUnit = make_signature!(
526 new fixed("(")
527 $(nameof(<$ident>::SIGNATURE) fixed(","))+
528 shift_left(1)
529 fixed(")")
530 );
531 }
473 };532 };
474}533}
475534
630689
631 let (call, mut decoder) = AbiReader::new_call(encoded_data).unwrap();690 let (call, mut decoder) = AbiReader::new_call(encoded_data).unwrap();
632 assert_eq!(call, u32::to_be_bytes(function_identifier));691 assert_eq!(call, u32::to_be_bytes(function_identifier));
633 let data = <AbiReader<'_> as AbiRead<$type>>::abi_read(&mut decoder).unwrap();692 let data = <$type>::abi_read(&mut decoder).unwrap();
634 assert_eq!(data, decoded_data);693 assert_eq!(data, decoded_data);
635694
636 let mut writer = AbiWriter::new_call(function_identifier);695 let mut writer = AbiWriter::new_call(function_identifier);
695 ),754 ),
696 ],755 ],
697 &hex!(756 &hex!(
698 "757 "
699 1ACF2D55758 1ACF2D55
700 0000000000000000000000000000000000000000000000000000000000000020 // offset of (address, uint256)[]759 0000000000000000000000000000000000000000000000000000000000000020 // offset of (address, uint256)[]
701 0000000000000000000000000000000000000000000000000000000000000003 // length of (address, uint256)[]760 0000000000000000000000000000000000000000000000000000000000000003 // length of (address, uint256)[]
702 761
703 0000000000000000000000002D2FF76104B7BACB2E8F6731D5BFC184EBECDDBC // address762 0000000000000000000000002D2FF76104B7BACB2E8F6731D5BFC184EBECDDBC // address
704 000000000000000000000000000000000000000000000000000000000000000A // uint256763 000000000000000000000000000000000000000000000000000000000000000A // uint256
705 764
706 000000000000000000000000AB8E3D9134955566483B11E6825C9223B6737B10 // address765 000000000000000000000000AB8E3D9134955566483B11E6825C9223B6737B10 // address
707 0000000000000000000000000000000000000000000000000000000000000014 // uint256766 0000000000000000000000000000000000000000000000000000000000000014 // uint256
708 767
709 0000000000000000000000008C582BDF2953046705FC56F189385255EFC1BE18 // address768 0000000000000000000000008C582BDF2953046705FC56F189385255EFC1BE18 // address
710 000000000000000000000000000000000000000000000000000000000000001E // uint256769 000000000000000000000000000000000000000000000000000000000000001E // uint256
711 "770 "
712 )771 )
713 );772 );
714773
837 assert_eq!(call, u32::to_be_bytes(decoded_data.0));896 assert_eq!(call, u32::to_be_bytes(decoded_data.0));
838 let address = decoder.address().unwrap();897 let address = decoder.address().unwrap();
839 let data =898 let data = <Vec<(uint256, string)>>::abi_read(&mut decoder).unwrap();
840 <AbiReader<'_> as AbiRead<Vec<(uint256, string)>>>::abi_read(&mut decoder).unwrap();
841 assert_eq!(data, decoded_data.1);899 assert_eq!(data, decoded_data.1);
842900
843 let mut writer = AbiWriter::new_call(decoded_data.0);901 let mut writer = AbiWriter::new_call(decoded_data.0);
addedcrates/evm-coder/src/custom_signature.rsdiffbeforeafterboth

no changes

modifiedcrates/evm-coder/src/lib.rsdiffbeforeafterboth
1616
17#![doc = include_str!("../README.md")]17#![doc = include_str!("../README.md")]
18#![deny(missing_docs)]18#![deny(missing_docs)]
19#![macro_use]
19#![cfg_attr(not(feature = "std"), no_std)]20#![cfg_attr(not(feature = "std"), no_std)]
20#[cfg(not(feature = "std"))]21#[cfg(not(feature = "std"))]
21extern crate alloc;22extern crate alloc;
26pub use events::{ToLog, ToTopic};27pub use events::{ToLog, ToTopic};
27use execution::DispatchInfo;28use execution::DispatchInfo;
28pub mod execution;29pub mod execution;
30#[macro_use]
31pub mod custom_signature;
2932
30/// Derives call enum implementing [`crate::Callable`], [`crate::Weighted`]33/// Derives call enum implementing [`crate::Callable`], [`crate::Weighted`]
31/// and [`crate::Call`] from impl block.34/// and [`crate::Call`] from impl block.
90pub use evm_coder_procedural::solidity;93pub use evm_coder_procedural::solidity;
91/// See [`solidity_interface`]94/// See [`solidity_interface`]
92pub use evm_coder_procedural::weight;95pub use evm_coder_procedural::weight;
96pub use sha3_const;
9397
94/// Derives [`ToLog`] for enum98/// Derives [`ToLog`] for enum
95///99///
104#[doc(hidden)]108#[doc(hidden)]
105pub mod events;109pub mod events;
106#[doc(hidden)]110#[doc(hidden)]
111#[cfg(feature = "stubgen")]
107pub mod solidity;112pub mod solidity;
108113
109/// Solidity type definitions (aliases from solidity name to rust type)114/// Solidity type definitions (aliases from solidity name to rust type)
114119
115 #[cfg(not(feature = "std"))]120 #[cfg(not(feature = "std"))]
116 use alloc::{vec::Vec};121 use alloc::{vec::Vec};
122 use pallet_evm::account::CrossAccountId;
117 use primitive_types::{U256, H160, H256};123 use primitive_types::{U256, H160, H256};
124 use core::str::from_utf8;
125
126 use crate::custom_signature::SignatureUnit;
127
128 pub trait Signature {
129 const SIGNATURE: SignatureUnit;
130
131 fn as_str() -> &'static str {
132 from_utf8(&Self::SIGNATURE.data[..Self::SIGNATURE.len]).expect("bad utf-8")
133 }
134 }
135
136 impl Signature for bool {
137 const SIGNATURE: SignatureUnit = make_signature!(new fixed("bool"));
138 }
139
140 macro_rules! define_simple_type {
141 (type $ident:ident = $ty:ty) => {
142 pub type $ident = $ty;
143 impl Signature for $ty {
144 const SIGNATURE: SignatureUnit = make_signature!(new fixed(stringify!($ident)));
145 }
146 };
147 }
118148
119 pub type address = H160;149 define_simple_type!(type address = H160);
120150
121 pub type uint8 = u8;151 define_simple_type!(type uint8 = u8);
122 pub type uint16 = u16;152 define_simple_type!(type uint16 = u16);
123 pub type uint32 = u32;153 define_simple_type!(type uint32 = u32);
124 pub type uint64 = u64;154 define_simple_type!(type uint64 = u64);
125 pub type uint128 = u128;155 define_simple_type!(type uint128 = u128);
126 pub type uint256 = U256;156 define_simple_type!(type uint256 = U256);
127
128 pub type bytes4 = [u8; 4];157 define_simple_type!(type bytes4 = [u8; 4]);
129158
130 pub type topic = H256;159 define_simple_type!(type topic = H256);
131160
132 #[cfg(not(feature = "std"))]161 #[cfg(not(feature = "std"))]
133 pub type string = ::alloc::string::String;162 define_simple_type!(type string = ::alloc::string::String);
134 #[cfg(feature = "std")]163 #[cfg(feature = "std")]
135 pub type string = ::std::string::String;164 define_simple_type!(type string = ::std::string::String);
136165
137 #[derive(Default, Debug)]166 #[derive(Default, Debug)]
138 pub struct bytes(pub Vec<u8>);167 pub struct bytes(pub Vec<u8>);
168 impl Signature for bytes {
169 const SIGNATURE: SignatureUnit = make_signature!(new fixed("bytes"));
170 }
139171
140 /// Solidity doesn't have `void` type, however we have special implementation172 /// Solidity doesn't have `void` type, however we have special implementation
141 /// for empty tuple return type173 /// for empty tuple return type
166 }198 }
167 }199 }
168200
201 #[allow(clippy::from_over_into)]
169 impl Into<Vec<u8>> for bytes {202 impl Into<Vec<u8>> for bytes {
170 fn into(self) -> Vec<u8> {203 fn into(self) -> Vec<u8> {
171 self.0204 self.0
184 }217 }
185 }218 }
219
220 #[derive(Debug, Default)]
221 pub struct EthCrossAccount {
222 pub(crate) eth: address,
223 pub(crate) sub: uint256,
224 }
225
226 impl EthCrossAccount {
227 pub fn from_sub_cross_account<T>(cross_account_id: &T::CrossAccountId) -> Self
228 where
229 T: pallet_evm::account::Config,
230 T::AccountId: AsRef<[u8; 32]>,
231 {
232 if cross_account_id.is_canonical_substrate() {
233 Self {
234 eth: Default::default(),
235 sub: convert_cross_account_to_uint256::<T>(cross_account_id),
236 }
237 } else {
238 Self {
239 eth: *cross_account_id.as_eth(),
240 sub: Default::default(),
241 }
242 }
243 }
244
245 pub fn into_sub_cross_account<T>(&self) -> crate::execution::Result<T::CrossAccountId>
246 where
247 T: pallet_evm::account::Config,
248 T::AccountId: From<[u8; 32]>,
249 {
250 if self.eth == Default::default() && self.sub == Default::default() {
251 Err("All fields of cross account is zeroed".into())
252 } else if self.eth == Default::default() {
253 Ok(convert_uint256_to_cross_account::<T>(self.sub))
254 } else if self.sub == Default::default() {
255 Ok(T::CrossAccountId::from_eth(self.eth))
256 } else {
257 Err("All fields of cross account is non zeroed".into())
258 }
259 }
260 }
261
262 impl Signature for EthCrossAccount {
263 const SIGNATURE: SignatureUnit = make_signature!(new fixed("(address,uint256)"));
264 }
265
266 /// Convert `CrossAccountId` to `uint256`.
267 pub fn convert_cross_account_to_uint256<T: pallet_evm::account::Config>(
268 from: &T::CrossAccountId,
269 ) -> uint256
270 where
271 T::AccountId: AsRef<[u8; 32]>,
272 {
273 let slice = from.as_sub().as_ref();
274 uint256::from_big_endian(slice)
275 }
276
277 /// Convert `uint256` to `CrossAccountId`.
278 pub fn convert_uint256_to_cross_account<T: pallet_evm::account::Config>(
279 from: uint256,
280 ) -> T::CrossAccountId
281 where
282 T::AccountId: From<[u8; 32]>,
283 {
284 let mut new_admin_arr = [0_u8; 32];
285 from.to_big_endian(&mut new_admin_arr);
286 let account_id = T::AccountId::from(new_admin_arr);
287 T::CrossAccountId::from_sub(account_id)
288 }
186}289}
187290
188/// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro291/// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro
239 return Ok(None);342 return Ok(None);
240 }343 }
241 Ok(Some(Self::SupportsInterface {344 Ok(Some(Self::SupportsInterface {
242 interface_id: input.abi_read()?,345 interface_id: types::bytes4::abi_read(input)?,
243 }))346 }))
244 }347 }
245}348}
252#[macro_export]355#[macro_export]
253macro_rules! generate_stubgen {356macro_rules! generate_stubgen {
254 ($name:ident, $decl:ty, $is_impl:literal) => {357 ($name:ident, $decl:ty, $is_impl:literal) => {
358 #[cfg(feature = "stubgen")]
255 #[test]359 #[test]
256 #[ignore]360 #[ignore]
257 fn $name() {361 fn $name() {
modifiedcrates/evm-coder/src/solidity.rsdiffbeforeafterboth
32 cmp::Reverse,32 cmp::Reverse,
33};33};
34use impl_trait_for_tuples::impl_for_tuples;34use impl_trait_for_tuples::impl_for_tuples;
35use crate::types::*;35use crate::{types::*, custom_signature::SignatureUnit};
3636
37#[derive(Default)]37#[derive(Default)]
38pub struct TypeCollector {38pub struct TypeCollector {
72 self.anonymous.borrow_mut().insert(names, id);72 self.anonymous.borrow_mut().insert(names, id);
73 format!("Tuple{}", id)73 format!("Tuple{}", id)
74 }74 }
75 pub fn collect_struct<T: StructCollect>(&self) -> String {
76 self.collect(<T as StructCollect>::declaration());
77 <T as StructCollect>::name()
78 }
75 pub fn finish(self) -> Vec<string> {79 pub fn finish(self) -> Vec<string> {
76 let mut data = self.structs.into_inner().into_iter().collect::<Vec<_>>();80 let mut data = self.structs.into_inner().into_iter().collect::<Vec<_>>();
77 data.sort_by_key(|(_, id)| Reverse(*id));81 data.sort_by_key(|(_, id)| Reverse(*id));
78 data.into_iter().map(|(code, _)| code).collect()82 data.into_iter().map(|(code, _)| code).collect()
79 }83 }
80}84}
85
86pub trait StructCollect: 'static {
87 /// Structure name.
88 fn name() -> String;
89 /// Structure declaration.
90 fn declaration() -> String;
91}
8192
82pub trait SolidityTypeName: 'static {93pub trait SolidityTypeName: 'static {
83 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;94 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result;
145impl sealed::CanBePlacedInVec for uint256 {}156impl sealed::CanBePlacedInVec for uint256 {}
146impl sealed::CanBePlacedInVec for string {}157impl sealed::CanBePlacedInVec for string {}
147impl sealed::CanBePlacedInVec for address {}158impl sealed::CanBePlacedInVec for address {}
159impl sealed::CanBePlacedInVec for EthCrossAccount {}
148160
149impl<T: SolidityTypeName + sealed::CanBePlacedInVec> SolidityTypeName for Vec<T> {161impl<T: SolidityTypeName + sealed::CanBePlacedInVec> SolidityTypeName for Vec<T> {
150 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {162 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
161 }173 }
162}174}
175
176impl SolidityTupleType for EthCrossAccount {
177 fn names(tc: &TypeCollector) -> Vec<string> {
178 let mut collected = Vec::with_capacity(Self::len());
179 {
180 let mut out = string::new();
181 address::solidity_name(&mut out, tc).expect("no fmt error");
182 collected.push(out);
183 }
184 {
185 let mut out = string::new();
186 uint256::solidity_name(&mut out, tc).expect("no fmt error");
187 collected.push(out);
188 }
189 collected
190 }
191
192 fn len() -> usize {
193 2
194 }
195}
196impl SolidityTypeName for EthCrossAccount {
197 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
198 write!(writer, "{}", tc.collect_struct::<Self>())
199 }
200
201 fn is_simple() -> bool {
202 false
203 }
204
205 fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
206 write!(writer, "{}(", tc.collect_struct::<Self>())?;
207 address::solidity_default(writer, tc)?;
208 write!(writer, ",")?;
209 uint256::solidity_default(writer, tc)?;
210 write!(writer, ")")
211 }
212}
213
214impl StructCollect for EthCrossAccount {
215 fn name() -> String {
216 "EthCrossAccount".into()
217 }
218
219 fn declaration() -> String {
220 let mut str = String::new();
221 writeln!(str, "/// @dev Cross account struct").unwrap();
222 writeln!(str, "struct {} {{", Self::name()).unwrap();
223 writeln!(str, "\taddress eth;").unwrap();
224 writeln!(str, "\tuint256 sub;").unwrap();
225 writeln!(str, "}}").unwrap();
226 str
227 }
228}
163229
164pub trait SolidityTupleType {230pub trait SolidityTupleType {
165 fn names(tc: &TypeCollector) -> Vec<String>;231 fn names(tc: &TypeCollector) -> Vec<String>;
418}484}
419pub struct SolidityFunction<A, R> {485pub struct SolidityFunction<A, R> {
420 pub docs: &'static [&'static str],486 pub docs: &'static [&'static str],
421 pub selector_str: &'static str,
422 pub selector: u32,487 pub selector: u32,
423 pub hide: bool,488 pub hide: bool,
489 pub custom_signature: SignatureUnit,
424 pub name: &'static str,490 pub name: &'static str,
425 pub args: A,491 pub args: A,
426 pub result: R,492 pub result: R,
446 writeln!(512 writeln!(
447 writer,513 writer,
448 "\t{hide_comment}/// or in textual repr: {}",514 "\t{hide_comment}/// or in textual repr: {}",
449 self.selector_str515 self.custom_signature.as_str().expect("bad utf-8")
450 )?;516 )?;
451 write!(writer, "\t{hide_comment}function {}(", self.name)?;517 write!(writer, "\t{hide_comment}function {}(", self.name)?;
452 self.args.solidity_name(writer, tc)?;518 self.args.solidity_name(writer, tc)?;
addedcrates/evm-coder/tests/build_failed/custom_signature_over_max_size.rsdiffbeforeafterboth

no changes

addedcrates/evm-coder/tests/build_failed/custom_signature_over_max_size.stderrdiffbeforeafterboth

no changes

modifiedcrates/evm-coder/tests/random.rsdiffbeforeafterboth
17#![allow(dead_code)] // This test only checks that macros is not panicking17#![allow(dead_code)] // This test only checks that macros is not panicking
1818
19use evm_coder::{ToLog, execution::Result, solidity_interface, types::*, solidity, weight};19use evm_coder::{ToLog, execution::Result, solidity_interface, types::*, solidity, weight};
20use evm_coder::{types::Signature};
2021
21pub struct Impls;22pub struct Impls;
2223
modifiedcrates/evm-coder/tests/solidity_generation.rsdiffbeforeafterboth
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17use evm_coder::{execution::Result, generate_stubgen, solidity_interface, types::*};17use evm_coder::{execution::Result, generate_stubgen, solidity_interface, types::*};
18use evm_coder::{types::Signature};
1819
19pub struct ERC20;20pub struct ERC20;
2021
modifiedpallets/common/CHANGELOG.mddiffbeforeafterboth
22
3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.
44
5## [0.1.10] - 2022-11-02
6### Changed
7 - Use named structure `EthCrossAccount` in eth functions.
8
5## [0.1.9] - 2022-10-139## [0.1.9] - 2022-10-13
610
7## Added11## Added
modifiedpallets/common/Cargo.tomldiffbeforeafterboth
1[package]1[package]
2name = "pallet-common"2name = "pallet-common"
3version = "0.1.9"3version = "0.1.10"
4license = "GPLv3"4license = "GPLv3"
5edition = "2021"5edition = "2021"
66
45 "up-data-structs/runtime-benchmarks",45 "up-data-structs/runtime-benchmarks",
46]46]
47try-runtime = ["frame-support/try-runtime"]47try-runtime = ["frame-support/try-runtime"]
48stubgen = ["evm-coder/stubgen"]
4849
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
3333
34use crate::{34use crate::{
35 Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,35 Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,
36 eth::{36 eth::convert_cross_account_to_uint256, weights::WeightInfo,
37 convert_cross_account_to_uint256, convert_cross_account_to_tuple,
38 convert_tuple_to_cross_account,
39 },
40 weights::WeightInfo,
41};37};
4238
230 fn set_collection_sponsor_cross(226 fn set_collection_sponsor_cross(
231 &mut self,227 &mut self,
232 caller: caller,228 caller: caller,
233 sponsor: (address, uint256),229 sponsor: EthCrossAccount,
234 ) -> Result<void> {230 ) -> Result<void> {
235 self.consume_store_reads_and_writes(1, 1)?;231 self.consume_store_reads_and_writes(1, 1)?;
236232
237 check_is_owner_or_admin(caller, self)?;233 check_is_owner_or_admin(caller, self)?;
238234
239 let sponsor = convert_tuple_to_cross_account::<T>(sponsor)?;235 let sponsor = sponsor.into_sub_cross_account::<T>()?;
240 self.set_sponsor(sponsor.as_sub().clone())236 self.set_sponsor(sponsor.as_sub().clone())
241 .map_err(dispatch_to_evm::<T>)?;237 .map_err(dispatch_to_evm::<T>)?;
242 save(self)238 save(self)
387 fn add_collection_admin_cross(383 fn add_collection_admin_cross(
388 &mut self,384 &mut self,
389 caller: caller,385 caller: caller,
390 new_admin: (address, uint256),386 new_admin: EthCrossAccount,
391 ) -> Result<void> {387 ) -> Result<void> {
392 self.consume_store_writes(2)?;388 self.consume_store_writes(2)?;
393389
394 let caller = T::CrossAccountId::from_eth(caller);390 let caller = T::CrossAccountId::from_eth(caller);
395 let new_admin = convert_tuple_to_cross_account::<T>(new_admin)?;391 let new_admin = new_admin.into_sub_cross_account::<T>()?;
396 <Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;392 <Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;
397 Ok(())393 Ok(())
398 }394 }
402 fn remove_collection_admin_cross(398 fn remove_collection_admin_cross(
403 &mut self,399 &mut self,
404 caller: caller,400 caller: caller,
405 admin: (address, uint256),401 admin: EthCrossAccount,
406 ) -> Result<void> {402 ) -> Result<void> {
407 self.consume_store_writes(2)?;403 self.consume_store_writes(2)?;
408404
409 let caller = T::CrossAccountId::from_eth(caller);405 let caller = T::CrossAccountId::from_eth(caller);
410 let admin = convert_tuple_to_cross_account::<T>(admin)?;406 let admin = admin.into_sub_cross_account::<T>()?;
411 <Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;407 <Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;
412 Ok(())408 Ok(())
413 }409 }
565 fn add_to_collection_allow_list_cross(561 fn add_to_collection_allow_list_cross(
566 &mut self,562 &mut self,
567 caller: caller,563 caller: caller,
568 user: (address, uint256),564 user: EthCrossAccount,
569 ) -> Result<void> {565 ) -> Result<void> {
570 self.consume_store_writes(1)?;566 self.consume_store_writes(1)?;
571567
572 let caller = T::CrossAccountId::from_eth(caller);568 let caller = T::CrossAccountId::from_eth(caller);
573 let user = convert_tuple_to_cross_account::<T>(user)?;569 let user = user.into_sub_cross_account::<T>()?;
574 Pallet::<T>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;570 Pallet::<T>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;
575 Ok(())571 Ok(())
576 }572 }
593 fn remove_from_collection_allow_list_cross(589 fn remove_from_collection_allow_list_cross(
594 &mut self,590 &mut self,
595 caller: caller,591 caller: caller,
596 user: (address, uint256),592 user: EthCrossAccount,
597 ) -> Result<void> {593 ) -> Result<void> {
598 self.consume_store_writes(1)?;594 self.consume_store_writes(1)?;
599595
600 let caller = T::CrossAccountId::from_eth(caller);596 let caller = T::CrossAccountId::from_eth(caller);
601 let user = convert_tuple_to_cross_account::<T>(user)?;597 let user = user.into_sub_cross_account::<T>()?;
602 Pallet::<T>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;598 Pallet::<T>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;
603 Ok(())599 Ok(())
604 }600 }
638 ///634 ///
639 /// @param user User cross account to verify635 /// @param user User cross account to verify
640 /// @return "true" if account is the owner or admin636 /// @return "true" if account is the owner or admin
641 fn is_owner_or_admin_cross(&self, user: (address, uint256)) -> Result<bool> {637 fn is_owner_or_admin_cross(&self, user: EthCrossAccount) -> Result<bool> {
642 let user = convert_tuple_to_cross_account::<T>(user)?;638 let user = user.into_sub_cross_account::<T>()?;
643 Ok(self.is_owner_or_admin(&user))639 Ok(self.is_owner_or_admin(&user))
644 }640 }
645641
657653
658 /// Get collection owner.654 /// Get collection owner.
659 ///655 ///
660 /// @return Tuple with sponsor address and his substrate mirror.656 /// @return Tuble with sponsor address and his substrate mirror.
661 /// If address is canonical then substrate mirror is zero and vice versa.657 /// If address is canonical then substrate mirror is zero and vice versa.
662 fn collection_owner(&self) -> Result<(address, uint256)> {658 fn collection_owner(&self) -> Result<EthCrossAccount> {
663 Ok(convert_cross_account_to_tuple::<T>(659 Ok(EthCrossAccount::from_sub_cross_account::<T>(
664 &T::CrossAccountId::from_sub(self.owner.clone()),660 &T::CrossAccountId::from_sub(self.owner.clone()),
665 ))661 ))
666 }662 }
683 ///679 ///
684 /// @return Vector of tuples with admins address and his substrate mirror.680 /// @return Vector of tuples with admins address and his substrate mirror.
685 /// If address is canonical then substrate mirror is zero and vice versa.681 /// If address is canonical then substrate mirror is zero and vice versa.
686 fn collection_admins(&self) -> Result<Vec<(address, uint256)>> {682 fn collection_admins(&self) -> Result<Vec<EthCrossAccount>> {
687 let result = crate::IsAdmin::<T>::iter_prefix((self.id,))683 let result = crate::IsAdmin::<T>::iter_prefix((self.id,))
688 .map(|(admin, _)| crate::eth::convert_cross_account_to_tuple::<T>(&admin))684 .map(|(admin, _)| EthCrossAccount::from_sub_cross_account::<T>(&admin))
689 .collect();685 .collect();
690 Ok(result)686 Ok(result)
691 }687 }
694 ///690 ///
695 /// @dev Owner can be changed only by current owner691 /// @dev Owner can be changed only by current owner
696 /// @param newOwner new owner cross account692 /// @param newOwner new owner cross account
697 fn set_owner_cross(&mut self, caller: caller, new_owner: (address, uint256)) -> Result<void> {693 fn set_owner_cross(&mut self, caller: caller, new_owner: EthCrossAccount) -> Result<void> {
698 self.consume_store_writes(1)?;694 self.consume_store_writes(1)?;
699695
700 let caller = T::CrossAccountId::from_eth(caller);696 let caller = T::CrossAccountId::from_eth(caller);
701 let new_owner = convert_tuple_to_cross_account::<T>(new_owner)?;697 let new_owner = new_owner.into_sub_cross_account::<T>()?;
702 self.set_owner_internal(caller, new_owner)698 self.set_owner_internal(caller, new_owner)
703 .map_err(dispatch_to_evm::<T>)699 .map_err(dispatch_to_evm::<T>)
704 }700 }
modifiedpallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth
52 "up-sponsorship/std",52 "up-sponsorship/std",
53]53]
54try-runtime = ["frame-support/try-runtime"]54try-runtime = ["frame-support/try-runtime"]
55stubgen = ["evm-coder/stubgen"]
5556
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
1616
17//! Implementation of magic contract17//! Implementation of magic contract
1818
19extern crate alloc;
19use core::marker::PhantomData;20use core::marker::PhantomData;
20use evm_coder::{21use evm_coder::{
21 abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,22 abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,
modifiedpallets/fungible/CHANGELOG.mddiffbeforeafterboth
22
3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.
44
5## [0.1.6] - 2022-11-02
6### Changed
7 - Use named structure `EthCrossAccount` in eth functions.
58
6## [0.1.5] - 2022-08-299## [0.1.5] - 2022-08-29
710
modifiedpallets/fungible/Cargo.tomldiffbeforeafterboth
1[package]1[package]
2name = "pallet-fungible"2name = "pallet-fungible"
3version = "0.1.5"3version = "0.1.6"
4license = "GPLv3"4license = "GPLv3"
5edition = "2021"5edition = "2021"
66
46]46]
47runtime-benchmarks = ['frame-benchmarking', 'pallet-common/runtime-benchmarks']47runtime-benchmarks = ['frame-benchmarking', 'pallet-common/runtime-benchmarks']
48try-runtime = ["frame-support/try-runtime"]48try-runtime = ["frame-support/try-runtime"]
49stubgen = ["evm-coder/stubgen", "pallet-common/stubgen"]
4950
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
1616
17//! ERC-20 standart support implementation.17//! ERC-20 standart support implementation.
1818
19extern crate alloc;
19use core::char::{REPLACEMENT_CHARACTER, decode_utf16};20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};
20use core::convert::TryInto;21use core::convert::TryInto;
21use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};22use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};
22use pallet_common::eth::convert_tuple_to_cross_account;
23use up_data_structs::CollectionMode;23use up_data_structs::CollectionMode;
24use pallet_common::erc::{CommonEvmHandler, PrecompileResult};24use pallet_common::erc::{CommonEvmHandler, PrecompileResult};
25use sp_std::vec::Vec;25use sp_std::vec::Vec;
158 fn approve_cross(158 fn approve_cross(
159 &mut self,159 &mut self,
160 caller: caller,160 caller: caller,
161 spender: (address, uint256),161 spender: EthCrossAccount,
162 amount: uint256,162 amount: uint256,
163 ) -> Result<bool> {163 ) -> Result<bool> {
164 let caller = T::CrossAccountId::from_eth(caller);164 let caller = T::CrossAccountId::from_eth(caller);
165 let spender = convert_tuple_to_cross_account::<T>(spender)?;165 let spender = spender.into_sub_cross_account::<T>()?;
166 let amount = amount.try_into().map_err(|_| "amount overflow")?;166 let amount = amount.try_into().map_err(|_| "amount overflow")?;
167167
168 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)168 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)
198 fn burn_from_cross(198 fn burn_from_cross(
199 &mut self,199 &mut self,
200 caller: caller,200 caller: caller,
201 from: (address, uint256),201 from: EthCrossAccount,
202 amount: uint256,202 amount: uint256,
203 ) -> Result<bool> {203 ) -> Result<bool> {
204 let caller = T::CrossAccountId::from_eth(caller);204 let caller = T::CrossAccountId::from_eth(caller);
205 let from = convert_tuple_to_cross_account::<T>(from)?;205 let from = from.into_sub_cross_account::<T>()?;
206 let amount = amount.try_into().map_err(|_| "amount overflow")?;206 let amount = amount.try_into().map_err(|_| "amount overflow")?;
207 let budget = self207 let budget = self
208 .recorder208 .recorder
240 fn transfer_from_cross(240 fn transfer_from_cross(
241 &mut self,241 &mut self,
242 caller: caller,242 caller: caller,
243 from: (address, uint256),243 from: EthCrossAccount,
244 to: (address, uint256),244 to: EthCrossAccount,
245 amount: uint256,245 amount: uint256,
246 ) -> Result<bool> {246 ) -> Result<bool> {
247 let caller = T::CrossAccountId::from_eth(caller);247 let caller = T::CrossAccountId::from_eth(caller);
248 let from = convert_tuple_to_cross_account::<T>(from)?;248 let from = from.into_sub_cross_account::<T>()?;
249 let to = convert_tuple_to_cross_account::<T>(to)?;249 let to = to.into_sub_cross_account::<T>()?;
250 let amount = amount.try_into().map_err(|_| "amount overflow")?;250 let amount = amount.try_into().map_err(|_| "amount overflow")?;
251 let budget = self251 let budget = self
252 .recorder252 .recorder
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
38 /// @param properties Vector of properties key/value pair.38 /// @param properties Vector of properties key/value pair.
39 /// @dev EVM selector for this function is: 0x50b26b2a,39 /// @dev EVM selector for this function is: 0x50b26b2a,
40 /// or in textual repr: setCollectionProperties((string,bytes)[])40 /// or in textual repr: setCollectionProperties((string,bytes)[])
41 function setCollectionProperties(Tuple10[] memory properties) public {41 function setCollectionProperties(Tuple14[] memory properties) public {
42 require(false, stub_error);42 require(false, stub_error);
43 properties;43 properties;
44 dummy = 0;44 dummy = 0;
87 /// @return Vector of properties key/value pairs.87 /// @return Vector of properties key/value pairs.
88 /// @dev EVM selector for this function is: 0x285fb8e6,88 /// @dev EVM selector for this function is: 0x285fb8e6,
89 /// or in textual repr: collectionProperties(string[])89 /// or in textual repr: collectionProperties(string[])
90 function collectionProperties(string[] memory keys) public view returns (Tuple10[] memory) {90 function collectionProperties(string[] memory keys) public view returns (Tuple14[] memory) {
91 require(false, stub_error);91 require(false, stub_error);
92 keys;92 keys;
93 dummy;93 dummy;
94 return new Tuple10[](0);94 return new Tuple14[](0);
95 }95 }
9696
97 /// Set the sponsor of the collection.97 /// Set the sponsor of the collection.
114 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.114 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
115 /// @dev EVM selector for this function is: 0x84a1d5a8,115 /// @dev EVM selector for this function is: 0x84a1d5a8,
116 /// or in textual repr: setCollectionSponsorCross((address,uint256))116 /// or in textual repr: setCollectionSponsorCross((address,uint256))
117 function setCollectionSponsorCross(Tuple6 memory sponsor) public {117 function setCollectionSponsorCross(EthCrossAccount memory sponsor) public {
118 require(false, stub_error);118 require(false, stub_error);
119 sponsor;119 sponsor;
120 dummy = 0;120 dummy = 0;
152 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.152 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
153 /// @dev EVM selector for this function is: 0x6ec0a9f1,153 /// @dev EVM selector for this function is: 0x6ec0a9f1,
154 /// or in textual repr: collectionSponsor()154 /// or in textual repr: collectionSponsor()
155 function collectionSponsor() public view returns (Tuple6 memory) {155 function collectionSponsor() public view returns (Tuple8 memory) {
156 require(false, stub_error);156 require(false, stub_error);
157 dummy;157 dummy;
158 return Tuple6(0x0000000000000000000000000000000000000000, 0);158 return Tuple8(0x0000000000000000000000000000000000000000, 0);
159 }159 }
160160
161 /// Set limits for the collection.161 /// Set limits for the collection.
206 /// @param newAdmin Cross account administrator address.206 /// @param newAdmin Cross account administrator address.
207 /// @dev EVM selector for this function is: 0x859aa7d6,207 /// @dev EVM selector for this function is: 0x859aa7d6,
208 /// or in textual repr: addCollectionAdminCross((address,uint256))208 /// or in textual repr: addCollectionAdminCross((address,uint256))
209 function addCollectionAdminCross(Tuple6 memory newAdmin) public {209 function addCollectionAdminCross(EthCrossAccount memory newAdmin) public {
210 require(false, stub_error);210 require(false, stub_error);
211 newAdmin;211 newAdmin;
212 dummy = 0;212 dummy = 0;
216 /// @param admin Cross account administrator address.216 /// @param admin Cross account administrator address.
217 /// @dev EVM selector for this function is: 0x6c0cd173,217 /// @dev EVM selector for this function is: 0x6c0cd173,
218 /// or in textual repr: removeCollectionAdminCross((address,uint256))218 /// or in textual repr: removeCollectionAdminCross((address,uint256))
219 function removeCollectionAdminCross(Tuple6 memory admin) public {219 function removeCollectionAdminCross(EthCrossAccount memory admin) public {
220 require(false, stub_error);220 require(false, stub_error);
221 admin;221 admin;
222 dummy = 0;222 dummy = 0;
307 /// @param user User cross account address.307 /// @param user User cross account address.
308 /// @dev EVM selector for this function is: 0xa0184a3a,308 /// @dev EVM selector for this function is: 0xa0184a3a,
309 /// or in textual repr: addToCollectionAllowListCross((address,uint256))309 /// or in textual repr: addToCollectionAllowListCross((address,uint256))
310 function addToCollectionAllowListCross(Tuple6 memory user) public {310 function addToCollectionAllowListCross(EthCrossAccount memory user) public {
311 require(false, stub_error);311 require(false, stub_error);
312 user;312 user;
313 dummy = 0;313 dummy = 0;
329 /// @param user User cross account address.329 /// @param user User cross account address.
330 /// @dev EVM selector for this function is: 0x09ba452a,330 /// @dev EVM selector for this function is: 0x09ba452a,
331 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))331 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))
332 function removeFromCollectionAllowListCross(Tuple6 memory user) public {332 function removeFromCollectionAllowListCross(EthCrossAccount memory user) public {
333 require(false, stub_error);333 require(false, stub_error);
334 user;334 user;
335 dummy = 0;335 dummy = 0;
365 /// @return "true" if account is the owner or admin365 /// @return "true" if account is the owner or admin
366 /// @dev EVM selector for this function is: 0x3e75a905,366 /// @dev EVM selector for this function is: 0x3e75a905,
367 /// or in textual repr: isOwnerOrAdminCross((address,uint256))367 /// or in textual repr: isOwnerOrAdminCross((address,uint256))
368 function isOwnerOrAdminCross(Tuple6 memory user) public view returns (bool) {368 function isOwnerOrAdminCross(EthCrossAccount memory user) public view returns (bool) {
369 require(false, stub_error);369 require(false, stub_error);
370 user;370 user;
371 dummy;371 dummy;
385385
386 /// Get collection owner.386 /// Get collection owner.
387 ///387 ///
388 /// @return Tuple with sponsor address and his substrate mirror.388 /// @return Tuble with sponsor address and his substrate mirror.
389 /// If address is canonical then substrate mirror is zero and vice versa.389 /// If address is canonical then substrate mirror is zero and vice versa.
390 /// @dev EVM selector for this function is: 0xdf727d3b,390 /// @dev EVM selector for this function is: 0xdf727d3b,
391 /// or in textual repr: collectionOwner()391 /// or in textual repr: collectionOwner()
392 function collectionOwner() public view returns (Tuple6 memory) {392 function collectionOwner() public view returns (EthCrossAccount memory) {
393 require(false, stub_error);393 require(false, stub_error);
394 dummy;394 dummy;
395 return Tuple6(0x0000000000000000000000000000000000000000, 0);395 return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
396 }396 }
397397
398 /// Changes collection owner to another account398 /// Changes collection owner to another account
413 /// If address is canonical then substrate mirror is zero and vice versa.413 /// If address is canonical then substrate mirror is zero and vice versa.
414 /// @dev EVM selector for this function is: 0x5813216b,414 /// @dev EVM selector for this function is: 0x5813216b,
415 /// or in textual repr: collectionAdmins()415 /// or in textual repr: collectionAdmins()
416 function collectionAdmins() public view returns (Tuple6[] memory) {416 function collectionAdmins() public view returns (EthCrossAccount[] memory) {
417 require(false, stub_error);417 require(false, stub_error);
418 dummy;418 dummy;
419 return new Tuple6[](0);419 return new EthCrossAccount[](0);
420 }420 }
421421
422 /// Changes collection owner to another account422 /// Changes collection owner to another account
425 /// @param newOwner new owner cross account425 /// @param newOwner new owner cross account
426 /// @dev EVM selector for this function is: 0xe5c9913f,426 /// @dev EVM selector for this function is: 0xe5c9913f,
427 /// or in textual repr: setOwnerCross((address,uint256))427 /// or in textual repr: setOwnerCross((address,uint256))
428 function setOwnerCross(Tuple6 memory newOwner) public {428 function setOwnerCross(EthCrossAccount memory newOwner) public {
429 require(false, stub_error);429 require(false, stub_error);
430 newOwner;430 newOwner;
431 dummy = 0;431 dummy = 0;
432 }432 }
433}433}
434
435/// @dev Cross account struct
436struct EthCrossAccount {
437 address eth;
438 uint256 sub;
439}
434440
435/// @dev anonymous struct441/// @dev anonymous struct
436struct Tuple10 {442struct Tuple14 {
437 string field_0;443 string field_0;
438 bytes field_1;444 bytes field_1;
439}445}
442contract ERC20UniqueExtensions is Dummy, ERC165 {448contract ERC20UniqueExtensions is Dummy, ERC165 {
443 /// @dev EVM selector for this function is: 0x0ecd0ab0,449 /// @dev EVM selector for this function is: 0x0ecd0ab0,
444 /// or in textual repr: approveCross((address,uint256),uint256)450 /// or in textual repr: approveCross((address,uint256),uint256)
445 function approveCross(Tuple6 memory spender, uint256 amount) public returns (bool) {451 function approveCross(EthCrossAccount memory spender, uint256 amount) public returns (bool) {
446 require(false, stub_error);452 require(false, stub_error);
447 spender;453 spender;
448 amount;454 amount;
472 /// @param amount The amount that will be burnt.478 /// @param amount The amount that will be burnt.
473 /// @dev EVM selector for this function is: 0xbb2f5a58,479 /// @dev EVM selector for this function is: 0xbb2f5a58,
474 /// or in textual repr: burnFromCross((address,uint256),uint256)480 /// or in textual repr: burnFromCross((address,uint256),uint256)
475 function burnFromCross(Tuple6 memory from, uint256 amount) public returns (bool) {481 function burnFromCross(EthCrossAccount memory from, uint256 amount) public returns (bool) {
476 require(false, stub_error);482 require(false, stub_error);
477 from;483 from;
478 amount;484 amount;
484 /// @param amounts array of pairs of account address and amount490 /// @param amounts array of pairs of account address and amount
485 /// @dev EVM selector for this function is: 0x1acf2d55,491 /// @dev EVM selector for this function is: 0x1acf2d55,
486 /// or in textual repr: mintBulk((address,uint256)[])492 /// or in textual repr: mintBulk((address,uint256)[])
487 function mintBulk(Tuple6[] memory amounts) public returns (bool) {493 function mintBulk(Tuple8[] memory amounts) public returns (bool) {
488 require(false, stub_error);494 require(false, stub_error);
489 amounts;495 amounts;
490 dummy = 0;496 dummy = 0;
494 /// @dev EVM selector for this function is: 0xd5cf430b,500 /// @dev EVM selector for this function is: 0xd5cf430b,
495 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)501 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
496 function transferFromCross(502 function transferFromCross(
497 Tuple6 memory from,503 EthCrossAccount memory from,
498 Tuple6 memory to,504 EthCrossAccount memory to,
499 uint256 amount505 uint256 amount
500 ) public returns (bool) {506 ) public returns (bool) {
501 require(false, stub_error);507 require(false, stub_error);
508}514}
509515
510/// @dev anonymous struct516/// @dev anonymous struct
511struct Tuple6 {517struct Tuple8 {
512 address field_0;518 address field_0;
513 uint256 field_1;519 uint256 field_1;
514}520}
modifiedpallets/nonfungible/CHANGELOG.mddiffbeforeafterboth
3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.
44
5<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->
6## [v0.1.7] - 2022-11-02
7### Changed
8 - Use named structure `EthCrossAccount` in eth functions.
69
7## [v0.1.6] - 2022-20-1010## [v0.1.6] - 2022-20-10
811
modifiedpallets/nonfungible/Cargo.tomldiffbeforeafterboth
1[package]1[package]
2name = "pallet-nonfungible"2name = "pallet-nonfungible"
3version = "0.1.6"3version = "0.1.7"
4license = "GPLv3"4license = "GPLv3"
5edition = "2021"5edition = "2021"
66
52 'up-data-structs/runtime-benchmarks',52 'up-data-structs/runtime-benchmarks',
53]53]
54try-runtime = ["frame-support/try-runtime"]54try-runtime = ["frame-support/try-runtime"]
55stubgen = ["evm-coder/stubgen", "pallet-common/stubgen"]
5556
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
35use pallet_common::{35use pallet_common::{
36 erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},36 erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},
37 CollectionHandle, CollectionPropertyPermissions,37 CollectionHandle, CollectionPropertyPermissions,
38 eth::convert_tuple_to_cross_account,
39};38};
40use pallet_evm::{account::CrossAccountId, PrecompileHandle};39use pallet_evm::{account::CrossAccountId, PrecompileHandle};
41use pallet_evm_coder_substrate::call;40use pallet_evm_coder_substrate::call;
675 fn approve_cross(674 fn approve_cross(
676 &mut self,675 &mut self,
677 caller: caller,676 caller: caller,
678 approved: (address, uint256),677 approved: EthCrossAccount,
679 token_id: uint256,678 token_id: uint256,
680 ) -> Result<void> {679 ) -> Result<void> {
681 let caller = T::CrossAccountId::from_eth(caller);680 let caller = T::CrossAccountId::from_eth(caller);
682 let approved = convert_tuple_to_cross_account::<T>(approved)?;681 let approved = approved.into_sub_cross_account::<T>()?;
683 let token = token_id.try_into()?;682 let token = token_id.try_into()?;
684683
685 <Pallet<T>>::set_allowance(self, &caller, token, Some(&approved))684 <Pallet<T>>::set_allowance(self, &caller, token, Some(&approved))
715 fn transfer_from_cross(714 fn transfer_from_cross(
716 &mut self,715 &mut self,
717 caller: caller,716 caller: caller,
718 from: (address, uint256),717 from: EthCrossAccount,
719 to: (address, uint256),718 to: EthCrossAccount,
720 token_id: uint256,719 token_id: uint256,
721 ) -> Result<void> {720 ) -> Result<void> {
722 let caller = T::CrossAccountId::from_eth(caller);721 let caller = T::CrossAccountId::from_eth(caller);
723 let from = convert_tuple_to_cross_account::<T>(from)?;722 let from = from.into_sub_cross_account::<T>()?;
724 let to = convert_tuple_to_cross_account::<T>(to)?;723 let to = to.into_sub_cross_account::<T>()?;
725 let token_id = token_id.try_into()?;724 let token_id = token_id.try_into()?;
726 let budget = self725 let budget = self
727 .recorder726 .recorder
761 fn burn_from_cross(760 fn burn_from_cross(
762 &mut self,761 &mut self,
763 caller: caller,762 caller: caller,
764 from: (address, uint256),763 from: EthCrossAccount,
765 token_id: uint256,764 token_id: uint256,
766 ) -> Result<void> {765 ) -> Result<void> {
767 let caller = T::CrossAccountId::from_eth(caller);766 let caller = T::CrossAccountId::from_eth(caller);
768 let from = convert_tuple_to_cross_account::<T>(from)?;767 let from = from.into_sub_cross_account::<T>()?;
769 let token = token_id.try_into()?;768 let token = token_id.try_into()?;
770 let budget = self769 let budget = self
771 .recorder770 .recorder
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
67 /// @param properties settable properties67 /// @param properties settable properties
68 /// @dev EVM selector for this function is: 0x14ed3a6e,68 /// @dev EVM selector for this function is: 0x14ed3a6e,
69 /// or in textual repr: setProperties(uint256,(string,bytes)[])69 /// or in textual repr: setProperties(uint256,(string,bytes)[])
70 function setProperties(uint256 tokenId, Tuple19[] memory properties) public {70 function setProperties(uint256 tokenId, Tuple21[] memory properties) public {
71 require(false, stub_error);71 require(false, stub_error);
72 tokenId;72 tokenId;
73 properties;73 properties;
124 /// @param properties Vector of properties key/value pair.124 /// @param properties Vector of properties key/value pair.
125 /// @dev EVM selector for this function is: 0x50b26b2a,125 /// @dev EVM selector for this function is: 0x50b26b2a,
126 /// or in textual repr: setCollectionProperties((string,bytes)[])126 /// or in textual repr: setCollectionProperties((string,bytes)[])
127 function setCollectionProperties(Tuple19[] memory properties) public {127 function setCollectionProperties(Tuple21[] memory properties) public {
128 require(false, stub_error);128 require(false, stub_error);
129 properties;129 properties;
130 dummy = 0;130 dummy = 0;
173 /// @return Vector of properties key/value pairs.173 /// @return Vector of properties key/value pairs.
174 /// @dev EVM selector for this function is: 0x285fb8e6,174 /// @dev EVM selector for this function is: 0x285fb8e6,
175 /// or in textual repr: collectionProperties(string[])175 /// or in textual repr: collectionProperties(string[])
176 function collectionProperties(string[] memory keys) public view returns (Tuple19[] memory) {176 function collectionProperties(string[] memory keys) public view returns (Tuple21[] memory) {
177 require(false, stub_error);177 require(false, stub_error);
178 keys;178 keys;
179 dummy;179 dummy;
180 return new Tuple19[](0);180 return new Tuple21[](0);
181 }181 }
182182
183 /// Set the sponsor of the collection.183 /// Set the sponsor of the collection.
200 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.200 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
201 /// @dev EVM selector for this function is: 0x84a1d5a8,201 /// @dev EVM selector for this function is: 0x84a1d5a8,
202 /// or in textual repr: setCollectionSponsorCross((address,uint256))202 /// or in textual repr: setCollectionSponsorCross((address,uint256))
203 function setCollectionSponsorCross(Tuple6 memory sponsor) public {203 function setCollectionSponsorCross(EthCrossAccount memory sponsor) public {
204 require(false, stub_error);204 require(false, stub_error);
205 sponsor;205 sponsor;
206 dummy = 0;206 dummy = 0;
238 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.238 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
239 /// @dev EVM selector for this function is: 0x6ec0a9f1,239 /// @dev EVM selector for this function is: 0x6ec0a9f1,
240 /// or in textual repr: collectionSponsor()240 /// or in textual repr: collectionSponsor()
241 function collectionSponsor() public view returns (Tuple6 memory) {241 function collectionSponsor() public view returns (Tuple24 memory) {
242 require(false, stub_error);242 require(false, stub_error);
243 dummy;243 dummy;
244 return Tuple6(0x0000000000000000000000000000000000000000, 0);244 return Tuple24(0x0000000000000000000000000000000000000000, 0);
245 }245 }
246246
247 /// Set limits for the collection.247 /// Set limits for the collection.
292 /// @param newAdmin Cross account administrator address.292 /// @param newAdmin Cross account administrator address.
293 /// @dev EVM selector for this function is: 0x859aa7d6,293 /// @dev EVM selector for this function is: 0x859aa7d6,
294 /// or in textual repr: addCollectionAdminCross((address,uint256))294 /// or in textual repr: addCollectionAdminCross((address,uint256))
295 function addCollectionAdminCross(Tuple6 memory newAdmin) public {295 function addCollectionAdminCross(EthCrossAccount memory newAdmin) public {
296 require(false, stub_error);296 require(false, stub_error);
297 newAdmin;297 newAdmin;
298 dummy = 0;298 dummy = 0;
302 /// @param admin Cross account administrator address.302 /// @param admin Cross account administrator address.
303 /// @dev EVM selector for this function is: 0x6c0cd173,303 /// @dev EVM selector for this function is: 0x6c0cd173,
304 /// or in textual repr: removeCollectionAdminCross((address,uint256))304 /// or in textual repr: removeCollectionAdminCross((address,uint256))
305 function removeCollectionAdminCross(Tuple6 memory admin) public {305 function removeCollectionAdminCross(EthCrossAccount memory admin) public {
306 require(false, stub_error);306 require(false, stub_error);
307 admin;307 admin;
308 dummy = 0;308 dummy = 0;
393 /// @param user User cross account address.393 /// @param user User cross account address.
394 /// @dev EVM selector for this function is: 0xa0184a3a,394 /// @dev EVM selector for this function is: 0xa0184a3a,
395 /// or in textual repr: addToCollectionAllowListCross((address,uint256))395 /// or in textual repr: addToCollectionAllowListCross((address,uint256))
396 function addToCollectionAllowListCross(Tuple6 memory user) public {396 function addToCollectionAllowListCross(EthCrossAccount memory user) public {
397 require(false, stub_error);397 require(false, stub_error);
398 user;398 user;
399 dummy = 0;399 dummy = 0;
415 /// @param user User cross account address.415 /// @param user User cross account address.
416 /// @dev EVM selector for this function is: 0x09ba452a,416 /// @dev EVM selector for this function is: 0x09ba452a,
417 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))417 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))
418 function removeFromCollectionAllowListCross(Tuple6 memory user) public {418 function removeFromCollectionAllowListCross(EthCrossAccount memory user) public {
419 require(false, stub_error);419 require(false, stub_error);
420 user;420 user;
421 dummy = 0;421 dummy = 0;
451 /// @return "true" if account is the owner or admin451 /// @return "true" if account is the owner or admin
452 /// @dev EVM selector for this function is: 0x3e75a905,452 /// @dev EVM selector for this function is: 0x3e75a905,
453 /// or in textual repr: isOwnerOrAdminCross((address,uint256))453 /// or in textual repr: isOwnerOrAdminCross((address,uint256))
454 function isOwnerOrAdminCross(Tuple6 memory user) public view returns (bool) {454 function isOwnerOrAdminCross(EthCrossAccount memory user) public view returns (bool) {
455 require(false, stub_error);455 require(false, stub_error);
456 user;456 user;
457 dummy;457 dummy;
471471
472 /// Get collection owner.472 /// Get collection owner.
473 ///473 ///
474 /// @return Tuple with sponsor address and his substrate mirror.474 /// @return Tuble with sponsor address and his substrate mirror.
475 /// If address is canonical then substrate mirror is zero and vice versa.475 /// If address is canonical then substrate mirror is zero and vice versa.
476 /// @dev EVM selector for this function is: 0xdf727d3b,476 /// @dev EVM selector for this function is: 0xdf727d3b,
477 /// or in textual repr: collectionOwner()477 /// or in textual repr: collectionOwner()
478 function collectionOwner() public view returns (Tuple6 memory) {478 function collectionOwner() public view returns (EthCrossAccount memory) {
479 require(false, stub_error);479 require(false, stub_error);
480 dummy;480 dummy;
481 return Tuple6(0x0000000000000000000000000000000000000000, 0);481 return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
482 }482 }
483483
484 /// Changes collection owner to another account484 /// Changes collection owner to another account
499 /// If address is canonical then substrate mirror is zero and vice versa.499 /// If address is canonical then substrate mirror is zero and vice versa.
500 /// @dev EVM selector for this function is: 0x5813216b,500 /// @dev EVM selector for this function is: 0x5813216b,
501 /// or in textual repr: collectionAdmins()501 /// or in textual repr: collectionAdmins()
502 function collectionAdmins() public view returns (Tuple6[] memory) {502 function collectionAdmins() public view returns (EthCrossAccount[] memory) {
503 require(false, stub_error);503 require(false, stub_error);
504 dummy;504 dummy;
505 return new Tuple6[](0);505 return new EthCrossAccount[](0);
506 }506 }
507507
508 /// Changes collection owner to another account508 /// Changes collection owner to another account
511 /// @param newOwner new owner cross account511 /// @param newOwner new owner cross account
512 /// @dev EVM selector for this function is: 0xe5c9913f,512 /// @dev EVM selector for this function is: 0xe5c9913f,
513 /// or in textual repr: setOwnerCross((address,uint256))513 /// or in textual repr: setOwnerCross((address,uint256))
514 function setOwnerCross(Tuple6 memory newOwner) public {514 function setOwnerCross(EthCrossAccount memory newOwner) public {
515 require(false, stub_error);515 require(false, stub_error);
516 newOwner;516 newOwner;
517 dummy = 0;517 dummy = 0;
518 }518 }
519}519}
520
521/// @dev Cross account struct
522struct EthCrossAccount {
523 address eth;
524 uint256 sub;
525}
526
527/// @dev anonymous struct
528struct Tuple24 {
529 address field_0;
530 uint256 field_1;
531}
520532
521/// @dev anonymous struct533/// @dev anonymous struct
522struct Tuple19 {534struct Tuple21 {
523 string field_0;535 string field_0;
524 bytes field_1;536 bytes field_1;
525}537}
696 /// @param tokenId The NFT to approve708 /// @param tokenId The NFT to approve
697 /// @dev EVM selector for this function is: 0x0ecd0ab0,709 /// @dev EVM selector for this function is: 0x0ecd0ab0,
698 /// or in textual repr: approveCross((address,uint256),uint256)710 /// or in textual repr: approveCross((address,uint256),uint256)
699 function approveCross(Tuple6 memory approved, uint256 tokenId) public {711 function approveCross(EthCrossAccount memory approved, uint256 tokenId) public {
700 require(false, stub_error);712 require(false, stub_error);
701 approved;713 approved;
702 tokenId;714 tokenId;
726 /// @dev EVM selector for this function is: 0xd5cf430b,738 /// @dev EVM selector for this function is: 0xd5cf430b,
727 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)739 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
728 function transferFromCross(740 function transferFromCross(
729 Tuple6 memory from,741 EthCrossAccount memory from,
730 Tuple6 memory to,742 EthCrossAccount memory to,
731 uint256 tokenId743 uint256 tokenId
732 ) public {744 ) public {
733 require(false, stub_error);745 require(false, stub_error);
760 /// @param tokenId The NFT to transfer772 /// @param tokenId The NFT to transfer
761 /// @dev EVM selector for this function is: 0xbb2f5a58,773 /// @dev EVM selector for this function is: 0xbb2f5a58,
762 /// or in textual repr: burnFromCross((address,uint256),uint256)774 /// or in textual repr: burnFromCross((address,uint256),uint256)
763 function burnFromCross(Tuple6 memory from, uint256 tokenId) public {775 function burnFromCross(EthCrossAccount memory from, uint256 tokenId) public {
764 require(false, stub_error);776 require(false, stub_error);
765 from;777 from;
766 tokenId;778 tokenId;
797 // /// @param tokens array of pairs of token ID and token URI for minted tokens809 // /// @param tokens array of pairs of token ID and token URI for minted tokens
798 // /// @dev EVM selector for this function is: 0x36543006,810 // /// @dev EVM selector for this function is: 0x36543006,
799 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])811 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
800 // function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) public returns (bool) {812 // function mintBulkWithTokenURI(address to, Tuple10[] memory tokens) public returns (bool) {
801 // require(false, stub_error);813 // require(false, stub_error);
802 // to;814 // to;
803 // tokens;815 // tokens;
808}820}
809821
810/// @dev anonymous struct822/// @dev anonymous struct
811struct Tuple8 {823struct Tuple10 {
812 uint256 field_0;824 uint256 field_0;
813 string field_1;825 string field_1;
814}826}
815
816/// @dev anonymous struct
817struct Tuple6 {
818 address field_0;
819 uint256 field_1;
820}
821827
822/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension828/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
823/// @dev See https://eips.ethereum.org/EIPS/eip-721829/// @dev See https://eips.ethereum.org/EIPS/eip-721
modifiedpallets/refungible/CHANGELOG.mddiffbeforeafterboth
22
3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.
44
5## [v0.2.6] - 2022-11-02
6### Changed
7 - Use named structure `EthCrossAccount` in eth functions.
8
5## [v0.2.5] - 2022-20-109## [v0.2.5] - 2022-20-10
610
7### Change11### Change
modifiedpallets/refungible/Cargo.tomldiffbeforeafterboth
1[package]1[package]
2name = "pallet-refungible"2name = "pallet-refungible"
3version = "0.2.5"3version = "0.2.6"
4license = "GPLv3"4license = "GPLv3"
5edition = "2021"5edition = "2021"
66
52 'up-data-structs/runtime-benchmarks',54 'up-data-structs/runtime-benchmarks',
53]55]
54try-runtime = ["frame-support/try-runtime"]56try-runtime = ["frame-support/try-runtime"]
57stubgen = ["evm-coder/stubgen", "pallet-common/stubgen"]
5558
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
30use pallet_common::{30use pallet_common::{
31 CollectionHandle, CollectionPropertyPermissions,31 CollectionHandle, CollectionPropertyPermissions,
32 erc::{CommonEvmHandler, CollectionCall, static_property::key},32 erc::{CommonEvmHandler, CollectionCall, static_property::key},
33 eth::convert_tuple_to_cross_account,
34};33};
35use pallet_evm::{account::CrossAccountId, PrecompileHandle};34use pallet_evm::{account::CrossAccountId, PrecompileHandle};
36use pallet_evm_coder_substrate::{call, dispatch_to_evm};35use pallet_evm_coder_substrate::{call, dispatch_to_evm};
725 fn transfer_from_cross(724 fn transfer_from_cross(
726 &mut self,725 &mut self,
727 caller: caller,726 caller: caller,
728 from: (address, uint256),727 from: EthCrossAccount,
729 to: (address, uint256),728 to: EthCrossAccount,
730 token_id: uint256,729 token_id: uint256,
731 ) -> Result<void> {730 ) -> Result<void> {
732 let caller = T::CrossAccountId::from_eth(caller);731 let caller = T::CrossAccountId::from_eth(caller);
733 let from = convert_tuple_to_cross_account::<T>(from)?;732 let from = from.into_sub_cross_account::<T>()?;
734 let to = convert_tuple_to_cross_account::<T>(to)?;733 let to = to.into_sub_cross_account::<T>()?;
735 let token_id = token_id.try_into()?;734 let token_id = token_id.try_into()?;
736 let budget = self735 let budget = self
737 .recorder736 .recorder
780 fn burn_from_cross(779 fn burn_from_cross(
781 &mut self,780 &mut self,
782 caller: caller,781 caller: caller,
783 from: (address, uint256),782 from: EthCrossAccount,
784 token_id: uint256,783 token_id: uint256,
785 ) -> Result<void> {784 ) -> Result<void> {
786 let caller = T::CrossAccountId::from_eth(caller);785 let caller = T::CrossAccountId::from_eth(caller);
787 let from = convert_tuple_to_cross_account::<T>(from)?;786 let from = from.into_sub_cross_account::<T>()?;
788 let token = token_id.try_into()?;787 let token = token_id.try_into()?;
789 let budget = self788 let budget = self
790 .recorder789 .recorder
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
67 /// @param properties settable properties67 /// @param properties settable properties
68 /// @dev EVM selector for this function is: 0x14ed3a6e,68 /// @dev EVM selector for this function is: 0x14ed3a6e,
69 /// or in textual repr: setProperties(uint256,(string,bytes)[])69 /// or in textual repr: setProperties(uint256,(string,bytes)[])
70 function setProperties(uint256 tokenId, Tuple19[] memory properties) public {70 function setProperties(uint256 tokenId, Tuple20[] memory properties) public {
71 require(false, stub_error);71 require(false, stub_error);
72 tokenId;72 tokenId;
73 properties;73 properties;
124 /// @param properties Vector of properties key/value pair.124 /// @param properties Vector of properties key/value pair.
125 /// @dev EVM selector for this function is: 0x50b26b2a,125 /// @dev EVM selector for this function is: 0x50b26b2a,
126 /// or in textual repr: setCollectionProperties((string,bytes)[])126 /// or in textual repr: setCollectionProperties((string,bytes)[])
127 function setCollectionProperties(Tuple19[] memory properties) public {127 function setCollectionProperties(Tuple20[] memory properties) public {
128 require(false, stub_error);128 require(false, stub_error);
129 properties;129 properties;
130 dummy = 0;130 dummy = 0;
173 /// @return Vector of properties key/value pairs.173 /// @return Vector of properties key/value pairs.
174 /// @dev EVM selector for this function is: 0x285fb8e6,174 /// @dev EVM selector for this function is: 0x285fb8e6,
175 /// or in textual repr: collectionProperties(string[])175 /// or in textual repr: collectionProperties(string[])
176 function collectionProperties(string[] memory keys) public view returns (Tuple19[] memory) {176 function collectionProperties(string[] memory keys) public view returns (Tuple20[] memory) {
177 require(false, stub_error);177 require(false, stub_error);
178 keys;178 keys;
179 dummy;179 dummy;
180 return new Tuple19[](0);180 return new Tuple20[](0);
181 }181 }
182182
183 /// Set the sponsor of the collection.183 /// Set the sponsor of the collection.
200 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.200 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
201 /// @dev EVM selector for this function is: 0x84a1d5a8,201 /// @dev EVM selector for this function is: 0x84a1d5a8,
202 /// or in textual repr: setCollectionSponsorCross((address,uint256))202 /// or in textual repr: setCollectionSponsorCross((address,uint256))
203 function setCollectionSponsorCross(Tuple6 memory sponsor) public {203 function setCollectionSponsorCross(EthCrossAccount memory sponsor) public {
204 require(false, stub_error);204 require(false, stub_error);
205 sponsor;205 sponsor;
206 dummy = 0;206 dummy = 0;
238 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.238 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
239 /// @dev EVM selector for this function is: 0x6ec0a9f1,239 /// @dev EVM selector for this function is: 0x6ec0a9f1,
240 /// or in textual repr: collectionSponsor()240 /// or in textual repr: collectionSponsor()
241 function collectionSponsor() public view returns (Tuple6 memory) {241 function collectionSponsor() public view returns (Tuple23 memory) {
242 require(false, stub_error);242 require(false, stub_error);
243 dummy;243 dummy;
244 return Tuple6(0x0000000000000000000000000000000000000000, 0);244 return Tuple23(0x0000000000000000000000000000000000000000, 0);
245 }245 }
246246
247 /// Set limits for the collection.247 /// Set limits for the collection.
292 /// @param newAdmin Cross account administrator address.292 /// @param newAdmin Cross account administrator address.
293 /// @dev EVM selector for this function is: 0x859aa7d6,293 /// @dev EVM selector for this function is: 0x859aa7d6,
294 /// or in textual repr: addCollectionAdminCross((address,uint256))294 /// or in textual repr: addCollectionAdminCross((address,uint256))
295 function addCollectionAdminCross(Tuple6 memory newAdmin) public {295 function addCollectionAdminCross(EthCrossAccount memory newAdmin) public {
296 require(false, stub_error);296 require(false, stub_error);
297 newAdmin;297 newAdmin;
298 dummy = 0;298 dummy = 0;
302 /// @param admin Cross account administrator address.302 /// @param admin Cross account administrator address.
303 /// @dev EVM selector for this function is: 0x6c0cd173,303 /// @dev EVM selector for this function is: 0x6c0cd173,
304 /// or in textual repr: removeCollectionAdminCross((address,uint256))304 /// or in textual repr: removeCollectionAdminCross((address,uint256))
305 function removeCollectionAdminCross(Tuple6 memory admin) public {305 function removeCollectionAdminCross(EthCrossAccount memory admin) public {
306 require(false, stub_error);306 require(false, stub_error);
307 admin;307 admin;
308 dummy = 0;308 dummy = 0;
393 /// @param user User cross account address.393 /// @param user User cross account address.
394 /// @dev EVM selector for this function is: 0xa0184a3a,394 /// @dev EVM selector for this function is: 0xa0184a3a,
395 /// or in textual repr: addToCollectionAllowListCross((address,uint256))395 /// or in textual repr: addToCollectionAllowListCross((address,uint256))
396 function addToCollectionAllowListCross(Tuple6 memory user) public {396 function addToCollectionAllowListCross(EthCrossAccount memory user) public {
397 require(false, stub_error);397 require(false, stub_error);
398 user;398 user;
399 dummy = 0;399 dummy = 0;
415 /// @param user User cross account address.415 /// @param user User cross account address.
416 /// @dev EVM selector for this function is: 0x09ba452a,416 /// @dev EVM selector for this function is: 0x09ba452a,
417 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))417 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))
418 function removeFromCollectionAllowListCross(Tuple6 memory user) public {418 function removeFromCollectionAllowListCross(EthCrossAccount memory user) public {
419 require(false, stub_error);419 require(false, stub_error);
420 user;420 user;
421 dummy = 0;421 dummy = 0;
451 /// @return "true" if account is the owner or admin451 /// @return "true" if account is the owner or admin
452 /// @dev EVM selector for this function is: 0x3e75a905,452 /// @dev EVM selector for this function is: 0x3e75a905,
453 /// or in textual repr: isOwnerOrAdminCross((address,uint256))453 /// or in textual repr: isOwnerOrAdminCross((address,uint256))
454 function isOwnerOrAdminCross(Tuple6 memory user) public view returns (bool) {454 function isOwnerOrAdminCross(EthCrossAccount memory user) public view returns (bool) {
455 require(false, stub_error);455 require(false, stub_error);
456 user;456 user;
457 dummy;457 dummy;
471471
472 /// Get collection owner.472 /// Get collection owner.
473 ///473 ///
474 /// @return Tuple with sponsor address and his substrate mirror.474 /// @return Tuble with sponsor address and his substrate mirror.
475 /// If address is canonical then substrate mirror is zero and vice versa.475 /// If address is canonical then substrate mirror is zero and vice versa.
476 /// @dev EVM selector for this function is: 0xdf727d3b,476 /// @dev EVM selector for this function is: 0xdf727d3b,
477 /// or in textual repr: collectionOwner()477 /// or in textual repr: collectionOwner()
478 function collectionOwner() public view returns (Tuple6 memory) {478 function collectionOwner() public view returns (EthCrossAccount memory) {
479 require(false, stub_error);479 require(false, stub_error);
480 dummy;480 dummy;
481 return Tuple6(0x0000000000000000000000000000000000000000, 0);481 return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
482 }482 }
483483
484 /// Changes collection owner to another account484 /// Changes collection owner to another account
499 /// If address is canonical then substrate mirror is zero and vice versa.499 /// If address is canonical then substrate mirror is zero and vice versa.
500 /// @dev EVM selector for this function is: 0x5813216b,500 /// @dev EVM selector for this function is: 0x5813216b,
501 /// or in textual repr: collectionAdmins()501 /// or in textual repr: collectionAdmins()
502 function collectionAdmins() public view returns (Tuple6[] memory) {502 function collectionAdmins() public view returns (EthCrossAccount[] memory) {
503 require(false, stub_error);503 require(false, stub_error);
504 dummy;504 dummy;
505 return new Tuple6[](0);505 return new EthCrossAccount[](0);
506 }506 }
507507
508 /// Changes collection owner to another account508 /// Changes collection owner to another account
511 /// @param newOwner new owner cross account511 /// @param newOwner new owner cross account
512 /// @dev EVM selector for this function is: 0xe5c9913f,512 /// @dev EVM selector for this function is: 0xe5c9913f,
513 /// or in textual repr: setOwnerCross((address,uint256))513 /// or in textual repr: setOwnerCross((address,uint256))
514 function setOwnerCross(Tuple6 memory newOwner) public {514 function setOwnerCross(EthCrossAccount memory newOwner) public {
515 require(false, stub_error);515 require(false, stub_error);
516 newOwner;516 newOwner;
517 dummy = 0;517 dummy = 0;
518 }518 }
519}519}
520
521/// @dev Cross account struct
522struct EthCrossAccount {
523 address eth;
524 uint256 sub;
525}
526
527/// @dev anonymous struct
528struct Tuple23 {
529 address field_0;
530 uint256 field_1;
531}
520532
521/// @dev anonymous struct533/// @dev anonymous struct
522struct Tuple19 {534struct Tuple20 {
523 string field_0;535 string field_0;
524 bytes field_1;536 bytes field_1;
525}537}
710 /// @dev EVM selector for this function is: 0xd5cf430b,722 /// @dev EVM selector for this function is: 0xd5cf430b,
711 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)723 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
712 function transferFromCross(724 function transferFromCross(
713 Tuple6 memory from,725 EthCrossAccount memory from,
714 Tuple6 memory to,726 EthCrossAccount memory to,
715 uint256 tokenId727 uint256 tokenId
716 ) public {728 ) public {
717 require(false, stub_error);729 require(false, stub_error);
746 /// @param tokenId The RFT to transfer758 /// @param tokenId The RFT to transfer
747 /// @dev EVM selector for this function is: 0xbb2f5a58,759 /// @dev EVM selector for this function is: 0xbb2f5a58,
748 /// or in textual repr: burnFromCross((address,uint256),uint256)760 /// or in textual repr: burnFromCross((address,uint256),uint256)
749 function burnFromCross(Tuple6 memory from, uint256 tokenId) public {761 function burnFromCross(EthCrossAccount memory from, uint256 tokenId) public {
750 require(false, stub_error);762 require(false, stub_error);
751 from;763 from;
752 tokenId;764 tokenId;
784 // /// @param tokens array of pairs of token ID and token URI for minted tokens796 // /// @param tokens array of pairs of token ID and token URI for minted tokens
785 // /// @dev EVM selector for this function is: 0x36543006,797 // /// @dev EVM selector for this function is: 0x36543006,
786 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])798 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
787 // function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) public returns (bool) {799 // function mintBulkWithTokenURI(address to, Tuple9[] memory tokens) public returns (bool) {
788 // require(false, stub_error);800 // require(false, stub_error);
789 // to;801 // to;
790 // tokens;802 // tokens;
806}818}
807819
808/// @dev anonymous struct820/// @dev anonymous struct
809struct Tuple8 {821struct Tuple9 {
810 uint256 field_0;822 uint256 field_0;
811 string field_1;823 string field_1;
812}824}
813
814/// @dev anonymous struct
815struct Tuple6 {
816 address field_0;
817 uint256 field_1;
818}
819825
820/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension826/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
821/// @dev See https://eips.ethereum.org/EIPS/eip-721827/// @dev See https://eips.ethereum.org/EIPS/eip-721
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
26use pallet_common::{25use pallet_common::{
27 CollectionById,26 CollectionById, dispatch::CollectionDispatch, erc::static_property::key, Pallet as PalletCommon,
28 dispatch::CollectionDispatch,
29 erc::{static_property::key, CollectionHelpersEvents},
30 Pallet as PalletCommon,
31};27};
32use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};28use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
169]169]
170limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']170limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
171unique-runtime = []171unique-runtime = []
172stubgen = ["evm-coder/stubgen"]
172173
173refungible = []174refungible = []
174scheduler = []175scheduler = []
modifiedtests/src/eth/allowlist.test.tsdiffbeforeafterboth
89 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;89 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;
90 });90 });
9191
92 //itEth('Collection allowlist can be added and removed by [cross] address', async ({helper}) => {92 itEth('Collection allowlist can be added and removed by [cross] address', async ({helper}) => {
93 // const owner = await helper.eth.createAccountWithBalance(donor);93 const owner = await helper.eth.createAccountWithBalance(donor);
94 // const user = donor;94 const user = donor;
95 // 95
96 // const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');96 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
97 // const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);97 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
98 // const userCross = helper.ethCrossAccount.fromKeyringPair(user);98 const userCross = helper.ethCrossAccount.fromKeyringPair(user);
99 // 99
100 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;100 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
101 // await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});101 await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});
102 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;102 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
103 // 103
104 // await collectionEvm.methods.removeFromCollectionAllowListCross(userCross).send({from: owner});104 await collectionEvm.methods.removeFromCollectionAllowListCross(userCross).send({from: owner});
105 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;105 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
106 //});106 });
107107
108 itEth('Collection allowlist can not be add and remove [eth] address by not owner', async ({helper}) => {108 itEth('Collection allowlist can not be add and remove [eth] address by not owner', async ({helper}) => {
109 const owner = await helper.eth.createAccountWithBalance(donor);109 const owner = await helper.eth.createAccountWithBalance(donor);
122 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.true;122 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.true;
123 });123 });
124124
125 //itEth('Collection allowlist can not be add and remove [cross] address by not owner', async ({helper}) => {125 itEth('Collection allowlist can not be add and remove [cross] address by not owner', async ({helper}) => {
126 // const owner = await helper.eth.createAccountWithBalance(donor);126 const owner = await helper.eth.createAccountWithBalance(donor);
127 // const notOwner = await helper.eth.createAccountWithBalance(donor);127 const notOwner = await helper.eth.createAccountWithBalance(donor);
128 // const user = donor;128 const user = donor;
129 // 129
130 // const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');130 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
131 // const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);131 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
132 // 132
133 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;133 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
134 // const userCross = helper.ethCrossAccount.fromKeyringPair(user);134 const userCross = helper.ethCrossAccount.fromKeyringPair(user);
135 // await expect(collectionEvm.methods.addToCollectionAllowListCross(userCross).call({from: notOwner})).to.be.rejectedWith('NoPermission');135 await expect(collectionEvm.methods.addToCollectionAllowListCross(userCross).call({from: notOwner})).to.be.rejectedWith('NoPermission');
136 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;136 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
137 // await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});137 await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});
138 // 138
139 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;139 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
140 // await expect(collectionEvm.methods.removeFromCollectionAllowListCross(userCross).call({from: notOwner})).to.be.rejectedWith('NoPermission');140 await expect(collectionEvm.methods.removeFromCollectionAllowListCross(userCross).call({from: notOwner})).to.be.rejectedWith('NoPermission');
141 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;141 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
142 //});142 });
143});143});
144144
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
28 /// @param properties Vector of properties key/value pair.28 /// @param properties Vector of properties key/value pair.
29 /// @dev EVM selector for this function is: 0x50b26b2a,29 /// @dev EVM selector for this function is: 0x50b26b2a,
30 /// or in textual repr: setCollectionProperties((string,bytes)[])30 /// or in textual repr: setCollectionProperties((string,bytes)[])
31 function setCollectionProperties(Tuple10[] memory properties) external;31 function setCollectionProperties(Tuple14[] memory properties) external;
3232
33 /// Delete collection property.33 /// Delete collection property.
34 ///34 ///
60 /// @return Vector of properties key/value pairs.60 /// @return Vector of properties key/value pairs.
61 /// @dev EVM selector for this function is: 0x285fb8e6,61 /// @dev EVM selector for this function is: 0x285fb8e6,
62 /// or in textual repr: collectionProperties(string[])62 /// or in textual repr: collectionProperties(string[])
63 function collectionProperties(string[] memory keys) external view returns (Tuple10[] memory);63 function collectionProperties(string[] memory keys) external view returns (Tuple14[] memory);
6464
65 /// Set the sponsor of the collection.65 /// Set the sponsor of the collection.
66 ///66 ///
78 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.78 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
79 /// @dev EVM selector for this function is: 0x84a1d5a8,79 /// @dev EVM selector for this function is: 0x84a1d5a8,
80 /// or in textual repr: setCollectionSponsorCross((address,uint256))80 /// or in textual repr: setCollectionSponsorCross((address,uint256))
81 function setCollectionSponsorCross(Tuple6 memory sponsor) external;81 function setCollectionSponsorCross(EthCrossAccount memory sponsor) external;
8282
83 /// Whether there is a pending sponsor.83 /// Whether there is a pending sponsor.
84 /// @dev EVM selector for this function is: 0x058ac185,84 /// @dev EVM selector for this function is: 0x058ac185,
102 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.102 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
103 /// @dev EVM selector for this function is: 0x6ec0a9f1,103 /// @dev EVM selector for this function is: 0x6ec0a9f1,
104 /// or in textual repr: collectionSponsor()104 /// or in textual repr: collectionSponsor()
105 function collectionSponsor() external view returns (Tuple6 memory);105 function collectionSponsor() external view returns (Tuple8 memory);
106106
107 /// Set limits for the collection.107 /// Set limits for the collection.
108 /// @dev Throws error if limit not found.108 /// @dev Throws error if limit not found.
138 /// @param newAdmin Cross account administrator address.138 /// @param newAdmin Cross account administrator address.
139 /// @dev EVM selector for this function is: 0x859aa7d6,139 /// @dev EVM selector for this function is: 0x859aa7d6,
140 /// or in textual repr: addCollectionAdminCross((address,uint256))140 /// or in textual repr: addCollectionAdminCross((address,uint256))
141 function addCollectionAdminCross(Tuple6 memory newAdmin) external;141 function addCollectionAdminCross(EthCrossAccount memory newAdmin) external;
142142
143 /// Remove collection admin.143 /// Remove collection admin.
144 /// @param admin Cross account administrator address.144 /// @param admin Cross account administrator address.
145 /// @dev EVM selector for this function is: 0x6c0cd173,145 /// @dev EVM selector for this function is: 0x6c0cd173,
146 /// or in textual repr: removeCollectionAdminCross((address,uint256))146 /// or in textual repr: removeCollectionAdminCross((address,uint256))
147 function removeCollectionAdminCross(Tuple6 memory admin) external;147 function removeCollectionAdminCross(EthCrossAccount memory admin) external;
148148
149 /// Add collection admin.149 /// Add collection admin.
150 /// @param newAdmin Address of the added administrator.150 /// @param newAdmin Address of the added administrator.
201 /// @param user User cross account address.201 /// @param user User cross account address.
202 /// @dev EVM selector for this function is: 0xa0184a3a,202 /// @dev EVM selector for this function is: 0xa0184a3a,
203 /// or in textual repr: addToCollectionAllowListCross((address,uint256))203 /// or in textual repr: addToCollectionAllowListCross((address,uint256))
204 function addToCollectionAllowListCross(Tuple6 memory user) external;204 function addToCollectionAllowListCross(EthCrossAccount memory user) external;
205205
206 /// Remove the user from the allowed list.206 /// Remove the user from the allowed list.
207 ///207 ///
215 /// @param user User cross account address.215 /// @param user User cross account address.
216 /// @dev EVM selector for this function is: 0x09ba452a,216 /// @dev EVM selector for this function is: 0x09ba452a,
217 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))217 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))
218 function removeFromCollectionAllowListCross(Tuple6 memory user) external;218 function removeFromCollectionAllowListCross(EthCrossAccount memory user) external;
219219
220 /// Switch permission for minting.220 /// Switch permission for minting.
221 ///221 ///
238 /// @return "true" if account is the owner or admin238 /// @return "true" if account is the owner or admin
239 /// @dev EVM selector for this function is: 0x3e75a905,239 /// @dev EVM selector for this function is: 0x3e75a905,
240 /// or in textual repr: isOwnerOrAdminCross((address,uint256))240 /// or in textual repr: isOwnerOrAdminCross((address,uint256))
241 function isOwnerOrAdminCross(Tuple6 memory user) external view returns (bool);241 function isOwnerOrAdminCross(EthCrossAccount memory user) external view returns (bool);
242242
243 /// Returns collection type243 /// Returns collection type
244 ///244 ///
249249
250 /// Get collection owner.250 /// Get collection owner.
251 ///251 ///
252 /// @return Tuple with sponsor address and his substrate mirror.252 /// @return Tuble with sponsor address and his substrate mirror.
253 /// If address is canonical then substrate mirror is zero and vice versa.253 /// If address is canonical then substrate mirror is zero and vice versa.
254 /// @dev EVM selector for this function is: 0xdf727d3b,254 /// @dev EVM selector for this function is: 0xdf727d3b,
255 /// or in textual repr: collectionOwner()255 /// or in textual repr: collectionOwner()
256 function collectionOwner() external view returns (Tuple6 memory);256 function collectionOwner() external view returns (EthCrossAccount memory);
257257
258 /// Changes collection owner to another account258 /// Changes collection owner to another account
259 ///259 ///
269 /// If address is canonical then substrate mirror is zero and vice versa.269 /// If address is canonical then substrate mirror is zero and vice versa.
270 /// @dev EVM selector for this function is: 0x5813216b,270 /// @dev EVM selector for this function is: 0x5813216b,
271 /// or in textual repr: collectionAdmins()271 /// or in textual repr: collectionAdmins()
272 function collectionAdmins() external view returns (Tuple6[] memory);272 function collectionAdmins() external view returns (EthCrossAccount[] memory);
273273
274 /// Changes collection owner to another account274 /// Changes collection owner to another account
275 ///275 ///
276 /// @dev Owner can be changed only by current owner276 /// @dev Owner can be changed only by current owner
277 /// @param newOwner new owner cross account277 /// @param newOwner new owner cross account
278 /// @dev EVM selector for this function is: 0xe5c9913f,278 /// @dev EVM selector for this function is: 0xe5c9913f,
279 /// or in textual repr: setOwnerCross((address,uint256))279 /// or in textual repr: setOwnerCross((address,uint256))
280 function setOwnerCross(Tuple6 memory newOwner) external;280 function setOwnerCross(EthCrossAccount memory newOwner) external;
281}281}
282
283/// @dev Cross account struct
284struct EthCrossAccount {
285 address eth;
286 uint256 sub;
287}
282288
283/// @dev anonymous struct289/// @dev anonymous struct
284struct Tuple10 {290struct Tuple14 {
285 string field_0;291 string field_0;
286 bytes field_1;292 bytes field_1;
287}293}
290interface ERC20UniqueExtensions is Dummy, ERC165 {296interface ERC20UniqueExtensions is Dummy, ERC165 {
291 /// @dev EVM selector for this function is: 0x0ecd0ab0,297 /// @dev EVM selector for this function is: 0x0ecd0ab0,
292 /// or in textual repr: approveCross((address,uint256),uint256)298 /// or in textual repr: approveCross((address,uint256),uint256)
293 function approveCross(Tuple6 memory spender, uint256 amount) external returns (bool);299 function approveCross(EthCrossAccount memory spender, uint256 amount) external returns (bool);
294300
295 /// Burn tokens from account301 /// Burn tokens from account
296 /// @dev Function that burns an `amount` of the tokens of a given account,302 /// @dev Function that burns an `amount` of the tokens of a given account,
308 /// @param amount The amount that will be burnt.314 /// @param amount The amount that will be burnt.
309 /// @dev EVM selector for this function is: 0xbb2f5a58,315 /// @dev EVM selector for this function is: 0xbb2f5a58,
310 /// or in textual repr: burnFromCross((address,uint256),uint256)316 /// or in textual repr: burnFromCross((address,uint256),uint256)
311 function burnFromCross(Tuple6 memory from, uint256 amount) external returns (bool);317 function burnFromCross(EthCrossAccount memory from, uint256 amount) external returns (bool);
312318
313 /// Mint tokens for multiple accounts.319 /// Mint tokens for multiple accounts.
314 /// @param amounts array of pairs of account address and amount320 /// @param amounts array of pairs of account address and amount
315 /// @dev EVM selector for this function is: 0x1acf2d55,321 /// @dev EVM selector for this function is: 0x1acf2d55,
316 /// or in textual repr: mintBulk((address,uint256)[])322 /// or in textual repr: mintBulk((address,uint256)[])
317 function mintBulk(Tuple6[] memory amounts) external returns (bool);323 function mintBulk(Tuple8[] memory amounts) external returns (bool);
318324
319 /// @dev EVM selector for this function is: 0xd5cf430b,325 /// @dev EVM selector for this function is: 0xd5cf430b,
320 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)326 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
321 function transferFromCross(327 function transferFromCross(
322 Tuple6 memory from,328 EthCrossAccount memory from,
323 Tuple6 memory to,329 EthCrossAccount memory to,
324 uint256 amount330 uint256 amount
325 ) external returns (bool);331 ) external returns (bool);
326}332}
327333
328/// @dev anonymous struct334/// @dev anonymous struct
329struct Tuple6 {335struct Tuple8 {
330 address field_0;336 address field_0;
331 uint256 field_1;337 uint256 field_1;
332}338}
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
49 /// @param properties settable properties49 /// @param properties settable properties
50 /// @dev EVM selector for this function is: 0x14ed3a6e,50 /// @dev EVM selector for this function is: 0x14ed3a6e,
51 /// or in textual repr: setProperties(uint256,(string,bytes)[])51 /// or in textual repr: setProperties(uint256,(string,bytes)[])
52 function setProperties(uint256 tokenId, Tuple19[] memory properties) external;52 function setProperties(uint256 tokenId, Tuple21[] memory properties) external;
5353
54 /// @notice Delete token property value.54 /// @notice Delete token property value.
55 /// @dev Throws error if `msg.sender` has no permission to edit the property.55 /// @dev Throws error if `msg.sender` has no permission to edit the property.
85 /// @param properties Vector of properties key/value pair.85 /// @param properties Vector of properties key/value pair.
86 /// @dev EVM selector for this function is: 0x50b26b2a,86 /// @dev EVM selector for this function is: 0x50b26b2a,
87 /// or in textual repr: setCollectionProperties((string,bytes)[])87 /// or in textual repr: setCollectionProperties((string,bytes)[])
88 function setCollectionProperties(Tuple19[] memory properties) external;88 function setCollectionProperties(Tuple21[] memory properties) external;
8989
90 /// Delete collection property.90 /// Delete collection property.
91 ///91 ///
117 /// @return Vector of properties key/value pairs.117 /// @return Vector of properties key/value pairs.
118 /// @dev EVM selector for this function is: 0x285fb8e6,118 /// @dev EVM selector for this function is: 0x285fb8e6,
119 /// or in textual repr: collectionProperties(string[])119 /// or in textual repr: collectionProperties(string[])
120 function collectionProperties(string[] memory keys) external view returns (Tuple19[] memory);120 function collectionProperties(string[] memory keys) external view returns (Tuple21[] memory);
121121
122 /// Set the sponsor of the collection.122 /// Set the sponsor of the collection.
123 ///123 ///
135 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.135 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
136 /// @dev EVM selector for this function is: 0x84a1d5a8,136 /// @dev EVM selector for this function is: 0x84a1d5a8,
137 /// or in textual repr: setCollectionSponsorCross((address,uint256))137 /// or in textual repr: setCollectionSponsorCross((address,uint256))
138 function setCollectionSponsorCross(Tuple6 memory sponsor) external;138 function setCollectionSponsorCross(EthCrossAccount memory sponsor) external;
139139
140 /// Whether there is a pending sponsor.140 /// Whether there is a pending sponsor.
141 /// @dev EVM selector for this function is: 0x058ac185,141 /// @dev EVM selector for this function is: 0x058ac185,
159 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.159 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
160 /// @dev EVM selector for this function is: 0x6ec0a9f1,160 /// @dev EVM selector for this function is: 0x6ec0a9f1,
161 /// or in textual repr: collectionSponsor()161 /// or in textual repr: collectionSponsor()
162 function collectionSponsor() external view returns (Tuple6 memory);162 function collectionSponsor() external view returns (Tuple24 memory);
163163
164 /// Set limits for the collection.164 /// Set limits for the collection.
165 /// @dev Throws error if limit not found.165 /// @dev Throws error if limit not found.
195 /// @param newAdmin Cross account administrator address.195 /// @param newAdmin Cross account administrator address.
196 /// @dev EVM selector for this function is: 0x859aa7d6,196 /// @dev EVM selector for this function is: 0x859aa7d6,
197 /// or in textual repr: addCollectionAdminCross((address,uint256))197 /// or in textual repr: addCollectionAdminCross((address,uint256))
198 function addCollectionAdminCross(Tuple6 memory newAdmin) external;198 function addCollectionAdminCross(EthCrossAccount memory newAdmin) external;
199199
200 /// Remove collection admin.200 /// Remove collection admin.
201 /// @param admin Cross account administrator address.201 /// @param admin Cross account administrator address.
202 /// @dev EVM selector for this function is: 0x6c0cd173,202 /// @dev EVM selector for this function is: 0x6c0cd173,
203 /// or in textual repr: removeCollectionAdminCross((address,uint256))203 /// or in textual repr: removeCollectionAdminCross((address,uint256))
204 function removeCollectionAdminCross(Tuple6 memory admin) external;204 function removeCollectionAdminCross(EthCrossAccount memory admin) external;
205205
206 /// Add collection admin.206 /// Add collection admin.
207 /// @param newAdmin Address of the added administrator.207 /// @param newAdmin Address of the added administrator.
258 /// @param user User cross account address.258 /// @param user User cross account address.
259 /// @dev EVM selector for this function is: 0xa0184a3a,259 /// @dev EVM selector for this function is: 0xa0184a3a,
260 /// or in textual repr: addToCollectionAllowListCross((address,uint256))260 /// or in textual repr: addToCollectionAllowListCross((address,uint256))
261 function addToCollectionAllowListCross(Tuple6 memory user) external;261 function addToCollectionAllowListCross(EthCrossAccount memory user) external;
262262
263 /// Remove the user from the allowed list.263 /// Remove the user from the allowed list.
264 ///264 ///
272 /// @param user User cross account address.272 /// @param user User cross account address.
273 /// @dev EVM selector for this function is: 0x09ba452a,273 /// @dev EVM selector for this function is: 0x09ba452a,
274 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))274 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))
275 function removeFromCollectionAllowListCross(Tuple6 memory user) external;275 function removeFromCollectionAllowListCross(EthCrossAccount memory user) external;
276276
277 /// Switch permission for minting.277 /// Switch permission for minting.
278 ///278 ///
295 /// @return "true" if account is the owner or admin295 /// @return "true" if account is the owner or admin
296 /// @dev EVM selector for this function is: 0x3e75a905,296 /// @dev EVM selector for this function is: 0x3e75a905,
297 /// or in textual repr: isOwnerOrAdminCross((address,uint256))297 /// or in textual repr: isOwnerOrAdminCross((address,uint256))
298 function isOwnerOrAdminCross(Tuple6 memory user) external view returns (bool);298 function isOwnerOrAdminCross(EthCrossAccount memory user) external view returns (bool);
299299
300 /// Returns collection type300 /// Returns collection type
301 ///301 ///
306306
307 /// Get collection owner.307 /// Get collection owner.
308 ///308 ///
309 /// @return Tuple with sponsor address and his substrate mirror.309 /// @return Tuble with sponsor address and his substrate mirror.
310 /// If address is canonical then substrate mirror is zero and vice versa.310 /// If address is canonical then substrate mirror is zero and vice versa.
311 /// @dev EVM selector for this function is: 0xdf727d3b,311 /// @dev EVM selector for this function is: 0xdf727d3b,
312 /// or in textual repr: collectionOwner()312 /// or in textual repr: collectionOwner()
313 function collectionOwner() external view returns (Tuple6 memory);313 function collectionOwner() external view returns (EthCrossAccount memory);
314314
315 /// Changes collection owner to another account315 /// Changes collection owner to another account
316 ///316 ///
326 /// If address is canonical then substrate mirror is zero and vice versa.326 /// If address is canonical then substrate mirror is zero and vice versa.
327 /// @dev EVM selector for this function is: 0x5813216b,327 /// @dev EVM selector for this function is: 0x5813216b,
328 /// or in textual repr: collectionAdmins()328 /// or in textual repr: collectionAdmins()
329 function collectionAdmins() external view returns (Tuple6[] memory);329 function collectionAdmins() external view returns (EthCrossAccount[] memory);
330330
331 /// Changes collection owner to another account331 /// Changes collection owner to another account
332 ///332 ///
333 /// @dev Owner can be changed only by current owner333 /// @dev Owner can be changed only by current owner
334 /// @param newOwner new owner cross account334 /// @param newOwner new owner cross account
335 /// @dev EVM selector for this function is: 0xe5c9913f,335 /// @dev EVM selector for this function is: 0xe5c9913f,
336 /// or in textual repr: setOwnerCross((address,uint256))336 /// or in textual repr: setOwnerCross((address,uint256))
337 function setOwnerCross(Tuple6 memory newOwner) external;337 function setOwnerCross(EthCrossAccount memory newOwner) external;
338}338}
339
340/// @dev Cross account struct
341struct EthCrossAccount {
342 address eth;
343 uint256 sub;
344}
345
346/// @dev anonymous struct
347struct Tuple24 {
348 address field_0;
349 uint256 field_1;
350}
339351
340/// @dev anonymous struct352/// @dev anonymous struct
341struct Tuple19 {353struct Tuple21 {
342 string field_0;354 string field_0;
343 bytes field_1;355 bytes field_1;
344}356}
458 /// @param tokenId The NFT to approve470 /// @param tokenId The NFT to approve
459 /// @dev EVM selector for this function is: 0x0ecd0ab0,471 /// @dev EVM selector for this function is: 0x0ecd0ab0,
460 /// or in textual repr: approveCross((address,uint256),uint256)472 /// or in textual repr: approveCross((address,uint256),uint256)
461 function approveCross(Tuple6 memory approved, uint256 tokenId) external;473 function approveCross(EthCrossAccount memory approved, uint256 tokenId) external;
462474
463 /// @notice Transfer ownership of an NFT475 /// @notice Transfer ownership of an NFT
464 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`476 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
478 /// @dev EVM selector for this function is: 0xd5cf430b,490 /// @dev EVM selector for this function is: 0xd5cf430b,
479 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)491 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
480 function transferFromCross(492 function transferFromCross(
481 Tuple6 memory from,493 EthCrossAccount memory from,
482 Tuple6 memory to,494 EthCrossAccount memory to,
483 uint256 tokenId495 uint256 tokenId
484 ) external;496 ) external;
485497
501 /// @param tokenId The NFT to transfer513 /// @param tokenId The NFT to transfer
502 /// @dev EVM selector for this function is: 0xbb2f5a58,514 /// @dev EVM selector for this function is: 0xbb2f5a58,
503 /// or in textual repr: burnFromCross((address,uint256),uint256)515 /// or in textual repr: burnFromCross((address,uint256),uint256)
504 function burnFromCross(Tuple6 memory from, uint256 tokenId) external;516 function burnFromCross(EthCrossAccount memory from, uint256 tokenId) external;
505517
506 /// @notice Returns next free NFT ID.518 /// @notice Returns next free NFT ID.
507 /// @dev EVM selector for this function is: 0x75794a3c,519 /// @dev EVM selector for this function is: 0x75794a3c,
523 // /// @param tokens array of pairs of token ID and token URI for minted tokens535 // /// @param tokens array of pairs of token ID and token URI for minted tokens
524 // /// @dev EVM selector for this function is: 0x36543006,536 // /// @dev EVM selector for this function is: 0x36543006,
525 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])537 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
526 // function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) external returns (bool);538 // function mintBulkWithTokenURI(address to, Tuple10[] memory tokens) external returns (bool);
527539
528}540}
529541
530/// @dev anonymous struct542/// @dev anonymous struct
531struct Tuple8 {543struct Tuple10 {
532 uint256 field_0;544 uint256 field_0;
533 string field_1;545 string field_1;
534}546}
535
536/// @dev anonymous struct
537struct Tuple6 {
538 address field_0;
539 uint256 field_1;
540}
541547
542/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension548/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
543/// @dev See https://eips.ethereum.org/EIPS/eip-721549/// @dev See https://eips.ethereum.org/EIPS/eip-721
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
49 /// @param properties settable properties49 /// @param properties settable properties
50 /// @dev EVM selector for this function is: 0x14ed3a6e,50 /// @dev EVM selector for this function is: 0x14ed3a6e,
51 /// or in textual repr: setProperties(uint256,(string,bytes)[])51 /// or in textual repr: setProperties(uint256,(string,bytes)[])
52 function setProperties(uint256 tokenId, Tuple19[] memory properties) external;52 function setProperties(uint256 tokenId, Tuple20[] memory properties) external;
5353
54 /// @notice Delete token property value.54 /// @notice Delete token property value.
55 /// @dev Throws error if `msg.sender` has no permission to edit the property.55 /// @dev Throws error if `msg.sender` has no permission to edit the property.
85 /// @param properties Vector of properties key/value pair.85 /// @param properties Vector of properties key/value pair.
86 /// @dev EVM selector for this function is: 0x50b26b2a,86 /// @dev EVM selector for this function is: 0x50b26b2a,
87 /// or in textual repr: setCollectionProperties((string,bytes)[])87 /// or in textual repr: setCollectionProperties((string,bytes)[])
88 function setCollectionProperties(Tuple19[] memory properties) external;88 function setCollectionProperties(Tuple20[] memory properties) external;
8989
90 /// Delete collection property.90 /// Delete collection property.
91 ///91 ///
117 /// @return Vector of properties key/value pairs.117 /// @return Vector of properties key/value pairs.
118 /// @dev EVM selector for this function is: 0x285fb8e6,118 /// @dev EVM selector for this function is: 0x285fb8e6,
119 /// or in textual repr: collectionProperties(string[])119 /// or in textual repr: collectionProperties(string[])
120 function collectionProperties(string[] memory keys) external view returns (Tuple19[] memory);120 function collectionProperties(string[] memory keys) external view returns (Tuple20[] memory);
121121
122 /// Set the sponsor of the collection.122 /// Set the sponsor of the collection.
123 ///123 ///
135 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.135 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
136 /// @dev EVM selector for this function is: 0x84a1d5a8,136 /// @dev EVM selector for this function is: 0x84a1d5a8,
137 /// or in textual repr: setCollectionSponsorCross((address,uint256))137 /// or in textual repr: setCollectionSponsorCross((address,uint256))
138 function setCollectionSponsorCross(Tuple6 memory sponsor) external;138 function setCollectionSponsorCross(EthCrossAccount memory sponsor) external;
139139
140 /// Whether there is a pending sponsor.140 /// Whether there is a pending sponsor.
141 /// @dev EVM selector for this function is: 0x058ac185,141 /// @dev EVM selector for this function is: 0x058ac185,
159 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.159 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
160 /// @dev EVM selector for this function is: 0x6ec0a9f1,160 /// @dev EVM selector for this function is: 0x6ec0a9f1,
161 /// or in textual repr: collectionSponsor()161 /// or in textual repr: collectionSponsor()
162 function collectionSponsor() external view returns (Tuple6 memory);162 function collectionSponsor() external view returns (Tuple23 memory);
163163
164 /// Set limits for the collection.164 /// Set limits for the collection.
165 /// @dev Throws error if limit not found.165 /// @dev Throws error if limit not found.
195 /// @param newAdmin Cross account administrator address.195 /// @param newAdmin Cross account administrator address.
196 /// @dev EVM selector for this function is: 0x859aa7d6,196 /// @dev EVM selector for this function is: 0x859aa7d6,
197 /// or in textual repr: addCollectionAdminCross((address,uint256))197 /// or in textual repr: addCollectionAdminCross((address,uint256))
198 function addCollectionAdminCross(Tuple6 memory newAdmin) external;198 function addCollectionAdminCross(EthCrossAccount memory newAdmin) external;
199199
200 /// Remove collection admin.200 /// Remove collection admin.
201 /// @param admin Cross account administrator address.201 /// @param admin Cross account administrator address.
202 /// @dev EVM selector for this function is: 0x6c0cd173,202 /// @dev EVM selector for this function is: 0x6c0cd173,
203 /// or in textual repr: removeCollectionAdminCross((address,uint256))203 /// or in textual repr: removeCollectionAdminCross((address,uint256))
204 function removeCollectionAdminCross(Tuple6 memory admin) external;204 function removeCollectionAdminCross(EthCrossAccount memory admin) external;
205205
206 /// Add collection admin.206 /// Add collection admin.
207 /// @param newAdmin Address of the added administrator.207 /// @param newAdmin Address of the added administrator.
258 /// @param user User cross account address.258 /// @param user User cross account address.
259 /// @dev EVM selector for this function is: 0xa0184a3a,259 /// @dev EVM selector for this function is: 0xa0184a3a,
260 /// or in textual repr: addToCollectionAllowListCross((address,uint256))260 /// or in textual repr: addToCollectionAllowListCross((address,uint256))
261 function addToCollectionAllowListCross(Tuple6 memory user) external;261 function addToCollectionAllowListCross(EthCrossAccount memory user) external;
262262
263 /// Remove the user from the allowed list.263 /// Remove the user from the allowed list.
264 ///264 ///
272 /// @param user User cross account address.272 /// @param user User cross account address.
273 /// @dev EVM selector for this function is: 0x09ba452a,273 /// @dev EVM selector for this function is: 0x09ba452a,
274 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))274 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))
275 function removeFromCollectionAllowListCross(Tuple6 memory user) external;275 function removeFromCollectionAllowListCross(EthCrossAccount memory user) external;
276276
277 /// Switch permission for minting.277 /// Switch permission for minting.
278 ///278 ///
295 /// @return "true" if account is the owner or admin295 /// @return "true" if account is the owner or admin
296 /// @dev EVM selector for this function is: 0x3e75a905,296 /// @dev EVM selector for this function is: 0x3e75a905,
297 /// or in textual repr: isOwnerOrAdminCross((address,uint256))297 /// or in textual repr: isOwnerOrAdminCross((address,uint256))
298 function isOwnerOrAdminCross(Tuple6 memory user) external view returns (bool);298 function isOwnerOrAdminCross(EthCrossAccount memory user) external view returns (bool);
299299
300 /// Returns collection type300 /// Returns collection type
301 ///301 ///
306306
307 /// Get collection owner.307 /// Get collection owner.
308 ///308 ///
309 /// @return Tuple with sponsor address and his substrate mirror.309 /// @return Tuble with sponsor address and his substrate mirror.
310 /// If address is canonical then substrate mirror is zero and vice versa.310 /// If address is canonical then substrate mirror is zero and vice versa.
311 /// @dev EVM selector for this function is: 0xdf727d3b,311 /// @dev EVM selector for this function is: 0xdf727d3b,
312 /// or in textual repr: collectionOwner()312 /// or in textual repr: collectionOwner()
313 function collectionOwner() external view returns (Tuple6 memory);313 function collectionOwner() external view returns (EthCrossAccount memory);
314314
315 /// Changes collection owner to another account315 /// Changes collection owner to another account
316 ///316 ///
326 /// If address is canonical then substrate mirror is zero and vice versa.326 /// If address is canonical then substrate mirror is zero and vice versa.
327 /// @dev EVM selector for this function is: 0x5813216b,327 /// @dev EVM selector for this function is: 0x5813216b,
328 /// or in textual repr: collectionAdmins()328 /// or in textual repr: collectionAdmins()
329 function collectionAdmins() external view returns (Tuple6[] memory);329 function collectionAdmins() external view returns (EthCrossAccount[] memory);
330330
331 /// Changes collection owner to another account331 /// Changes collection owner to another account
332 ///332 ///
333 /// @dev Owner can be changed only by current owner333 /// @dev Owner can be changed only by current owner
334 /// @param newOwner new owner cross account334 /// @param newOwner new owner cross account
335 /// @dev EVM selector for this function is: 0xe5c9913f,335 /// @dev EVM selector for this function is: 0xe5c9913f,
336 /// or in textual repr: setOwnerCross((address,uint256))336 /// or in textual repr: setOwnerCross((address,uint256))
337 function setOwnerCross(Tuple6 memory newOwner) external;337 function setOwnerCross(EthCrossAccount memory newOwner) external;
338}338}
339
340/// @dev Cross account struct
341struct EthCrossAccount {
342 address eth;
343 uint256 sub;
344}
345
346/// @dev anonymous struct
347struct Tuple23 {
348 address field_0;
349 uint256 field_1;
350}
339351
340/// @dev anonymous struct352/// @dev anonymous struct
341struct Tuple19 {353struct Tuple20 {
342 string field_0;354 string field_0;
343 bytes field_1;355 bytes field_1;
344}356}
467 /// @dev EVM selector for this function is: 0xd5cf430b,479 /// @dev EVM selector for this function is: 0xd5cf430b,
468 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)480 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
469 function transferFromCross(481 function transferFromCross(
470 Tuple6 memory from,482 EthCrossAccount memory from,
471 Tuple6 memory to,483 EthCrossAccount memory to,
472 uint256 tokenId484 uint256 tokenId
473 ) external;485 ) external;
474486
492 /// @param tokenId The RFT to transfer504 /// @param tokenId The RFT to transfer
493 /// @dev EVM selector for this function is: 0xbb2f5a58,505 /// @dev EVM selector for this function is: 0xbb2f5a58,
494 /// or in textual repr: burnFromCross((address,uint256),uint256)506 /// or in textual repr: burnFromCross((address,uint256),uint256)
495 function burnFromCross(Tuple6 memory from, uint256 tokenId) external;507 function burnFromCross(EthCrossAccount memory from, uint256 tokenId) external;
496508
497 /// @notice Returns next free RFT ID.509 /// @notice Returns next free RFT ID.
498 /// @dev EVM selector for this function is: 0x75794a3c,510 /// @dev EVM selector for this function is: 0x75794a3c,
515 // /// @param tokens array of pairs of token ID and token URI for minted tokens527 // /// @param tokens array of pairs of token ID and token URI for minted tokens
516 // /// @dev EVM selector for this function is: 0x36543006,528 // /// @dev EVM selector for this function is: 0x36543006,
517 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])529 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
518 // function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) external returns (bool);530 // function mintBulkWithTokenURI(address to, Tuple9[] memory tokens) external returns (bool);
519531
520 /// Returns EVM address for refungible token532 /// Returns EVM address for refungible token
521 ///533 ///
526}538}
527539
528/// @dev anonymous struct540/// @dev anonymous struct
529struct Tuple8 {541struct Tuple9 {
530 uint256 field_0;542 uint256 field_0;
531 string field_1;543 string field_1;
532}544}
533
534/// @dev anonymous struct
535struct Tuple6 {
536 address field_0;
537 uint256 field_1;
538}
539545
540/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension546/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
541/// @dev See https://eips.ethereum.org/EIPS/eip-721547/// @dev See https://eips.ethereum.org/EIPS/eip-721
modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
116 await checkInterface(helper, '0x780e9d63', true, true);116 await checkInterface(helper, '0x780e9d63', true, true);
117 });117 });
118118
119 itEth('ERC721UniqueExtensions - 0x244543ee - support', async ({helper}) => {119 itEth('ERC721UniqueExtensions support', async ({helper}) => {
120 await checkInterface(helper, '0x244543ee', true, true);120 await checkInterface(helper, '0x244543ee', true, true);
121 });121 });
122122
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
14// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.14// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1515
16import {IKeyringPair} from '@polkadot/types/types';16import {IKeyringPair} from '@polkadot/types/types';
17import {expect} from 'chai';
18import {IEthCrossAccountId} from '../util/playgrounds/types';
17import {usingEthPlaygrounds, itEth, expect, EthUniqueHelper} from './util';19import {usingEthPlaygrounds, itEth} from './util';
20import {EthUniqueHelper} from './util/playgrounds/unique.dev';
1821
19async function recordEthFee(helper: EthUniqueHelper, userAddress: string, call: () => Promise<any>) {22async function recordEthFee(helper: EthUniqueHelper, userAddress: string, call: () => Promise<any>) {
20 const before = await helper.balance.getSubstrate(helper.address.ethToSubstrate(userAddress));23 const before = await helper.balance.getSubstrate(helper.address.ethToSubstrate(userAddress));
63 expect(adminList).to.be.like([{Substrate: newAdmin.address}]);66 expect(adminList).to.be.like([{Substrate: newAdmin.address}]);
64 });67 });
6568
66 // itEth('Check adminlist', async ({helper, privateKey}) => {69 itEth('Check adminlist', async ({helper, privateKey}) => {
67 // const owner = await helper.eth.createAccountWithBalance(donor);70 const owner = await helper.eth.createAccountWithBalance(donor);
68 71
69 // const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');72 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
70 // const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);73 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
7174
72 // const admin1 = helper.eth.createAccount();75 const admin1 = helper.eth.createAccount();
73 // const admin2 = await privateKey('admin');76 const admin2 = await privateKey('admin');
74 // await collectionEvm.methods.addCollectionAdmin(admin1).send();77 const admin2Cross = helper.ethCrossAccount.fromKeyringPair(admin2);
75 // await collectionEvm.methods.addCollectionAdminCross(helper.ethCrossAccount.fromKeyringPair(admin2)).send();78 await collectionEvm.methods.addCollectionAdmin(admin1).send();
7679 await collectionEvm.methods.addCollectionAdminCross(admin2Cross).send();
77 // const adminListRpc = await helper.collection.getAdmins(collectionId);80
78 // let adminListEth = await collectionEvm.methods.collectionAdmins().call();81 const adminListRpc = await helper.collection.getAdmins(collectionId);
79 // adminListEth = adminListEth.map((element: IEthCrossAccountId) => {82 let adminListEth = await collectionEvm.methods.collectionAdmins().call();
80 // return helper.address.convertCrossAccountFromEthCrossAcoount(element);83 adminListEth = adminListEth.map((element: IEthCrossAccountId) => {
81 // });84 return helper.address.convertCrossAccountFromEthCrossAcoount(element);
82 // expect(adminListRpc).to.be.like(adminListEth);85 });
83 // });86 expect(adminListRpc).to.be.like(adminListEth);
87 });
8488
85 itEth('Verify owner or admin', async ({helper}) => {89 itEth('Verify owner or admin', async ({helper}) => {
86 const owner = await helper.eth.createAccountWithBalance(donor);90 const owner = await helper.eth.createAccountWithBalance(donor);
94 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;98 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;
95 });99 });
96100
97 // itEth.skip('Check adminlist', async ({helper, privateKey}) => {
98 // const owner = await helper.eth.createAccountWithBalance(donor);
99
100 // const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
101 // const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
102
103 // const admin1 = helper.eth.createAccount();
104 // const admin2 = await privateKey('admin');
105 // await collectionEvm.methods.addCollectionAdmin(admin1).send();
106 // await collectionEvm.methods.addCollectionAdminSubstrate(admin2.addressRaw).send();
107
108 // const adminListRpc = await helper.collection.getAdmins(collectionId);
109 // let adminListEth = await collectionEvm.methods.collectionAdmins().call();
110 // adminListEth = adminListEth.map((element: IEthCrossAccountId) => {
111 // return helper.address.convertCrossAccountFromEthCrossAcoount(element);
112 // });
113 // expect(adminListRpc).to.be.like(adminListEth);
114 // });
115
116 itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {101 itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {
117 const owner = await helper.eth.createAccountWithBalance(donor);102 const owner = await helper.eth.createAccountWithBalance(donor);
146 expect(adminList.length).to.be.eq(0);131 expect(adminList.length).to.be.eq(0);
147 });132 });
148133
149 itEth.skip('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({helper}) => {134 itEth('(!negative tests!) Add [cross] admin by ADMIN is not allowed', async ({helper}) => {
150 const owner = await helper.eth.createAccountWithBalance(donor);135 const owner = await helper.eth.createAccountWithBalance(donor);
151 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');136 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
152137
155 await collectionEvm.methods.addCollectionAdmin(admin).send();140 await collectionEvm.methods.addCollectionAdmin(admin).send();
156141
157 const [notAdmin] = await helper.arrange.createAccounts([10n], donor);142 const [notAdmin] = await helper.arrange.createAccounts([10n], donor);
143 const notAdminCross = helper.ethCrossAccount.fromKeyringPair(notAdmin);
158 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))144 await expect(collectionEvm.methods.addCollectionAdminCross(notAdminCross).call({from: admin}))
159 .to.be.rejectedWith('NoPermission');145 .to.be.rejectedWith('NoPermission');
160146
161 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);147 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);
164 .to.be.eq(admin.toLocaleLowerCase());150 .to.be.eq(admin.toLocaleLowerCase());
165 });151 });
166152
167 itEth.skip('(!negative tests!) Add substrate admin by USER is not allowed', async ({helper}) => {153 itEth('(!negative tests!) Add [cross] admin by USER is not allowed', async ({helper}) => {
168 const owner = await helper.eth.createAccountWithBalance(donor);154 const owner = await helper.eth.createAccountWithBalance(donor);
169 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');155 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
170156
171 const notAdmin0 = await helper.eth.createAccountWithBalance(donor);157 const notAdmin0 = await helper.eth.createAccountWithBalance(donor);
172 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);158 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
173 const [notAdmin1] = await helper.arrange.createAccounts([10n], donor);159 const [notAdmin1] = await helper.arrange.createAccounts([10n], donor);
160 const notAdmin1Cross = helper.ethCrossAccount.fromKeyringPair(notAdmin1);
174 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))161 await expect(collectionEvm.methods.addCollectionAdminCross(notAdmin1Cross).call({from: notAdmin0}))
175 .to.be.rejectedWith('NoPermission');162 .to.be.rejectedWith('NoPermission');
176163
177 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);164 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);
208 expect(adminList.length).to.be.eq(0);195 expect(adminList.length).to.be.eq(0);
209 });196 });
210197
211 itEth.skip('Remove substrate admin by owner', async ({helper}) => {198 itEth('Remove [cross] admin by owner', async ({helper}) => {
212 const owner = await helper.eth.createAccountWithBalance(donor);199 const owner = await helper.eth.createAccountWithBalance(donor);
213 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');200 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
214201
215 const [newAdmin] = await helper.arrange.createAccounts([10n], donor);202 const [newAdmin] = await helper.arrange.createAccounts([10n], donor);
203 const newAdminCross = helper.ethCrossAccount.fromKeyringPair(newAdmin);
216 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);204 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
217 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();205 await collectionEvm.methods.addCollectionAdminCross(newAdminCross).send();
218 {206 {
219 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);207 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);
220 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())208 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())
221 .to.be.eq(newAdmin.address.toLocaleLowerCase());209 .to.be.eq(newAdmin.address.toLocaleLowerCase());
222 }210 }
223211
224 await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();212 await collectionEvm.methods.removeCollectionAdminCross(newAdminCross).send();
225 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);213 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);
226 expect(adminList.length).to.be.eq(0);214 expect(adminList.length).to.be.eq(0);
227 });215 });
268 }256 }
269 });257 });
270258
271 itEth.skip('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({helper}) => {259 itEth('(!negative tests!) Remove [cross] admin by ADMIN is not allowed', async ({helper}) => {
272 const owner = await helper.eth.createAccountWithBalance(donor);260 const owner = await helper.eth.createAccountWithBalance(donor);
273 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');261 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
274262
275 const [adminSub] = await helper.arrange.createAccounts([10n], donor);263 const [adminSub] = await helper.arrange.createAccounts([10n], donor);
264 const adminSubCross = helper.ethCrossAccount.fromKeyringPair(adminSub);
276 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);265 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
277 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();266 await collectionEvm.methods.addCollectionAdminCross(adminSubCross).send();
278 const adminEth = await helper.eth.createAccountWithBalance(donor);267 const adminEth = await helper.eth.createAccountWithBalance(donor);
279 await collectionEvm.methods.addCollectionAdmin(adminEth).send();268 await collectionEvm.methods.addCollectionAdmin(adminEth).send();
280269
281 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))270 await expect(collectionEvm.methods.removeCollectionAdminCross(adminSubCross).call({from: adminEth}))
282 .to.be.rejectedWith('NoPermission');271 .to.be.rejectedWith('NoPermission');
283272
284 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);273 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);
288 .to.be.deep.contains(adminEth.toLocaleLowerCase());277 .to.be.deep.contains(adminEth.toLocaleLowerCase());
289 });278 });
290279
291 itEth.skip('(!negative tests!) Remove substrate admin by USER is not allowed', async ({helper}) => {280 itEth('(!negative tests!) Remove [cross] admin by USER is not allowed', async ({helper}) => {
292 const owner = await helper.eth.createAccountWithBalance(donor);281 const owner = await helper.eth.createAccountWithBalance(donor);
293 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');282 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
294283
295 const [adminSub] = await helper.arrange.createAccounts([10n], donor);284 const [adminSub] = await helper.arrange.createAccounts([10n], donor);
285 const adminSubCross = helper.ethCrossAccount.fromKeyringPair(adminSub);
296 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);286 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
297 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();287 await collectionEvm.methods.addCollectionAdminCross(adminSubCross).send();
298 const notAdminEth = await helper.eth.createAccountWithBalance(donor);288 const notAdminEth = await helper.eth.createAccountWithBalance(donor);
299289
300 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))290 await expect(collectionEvm.methods.removeCollectionAdminCross(adminSubCross).call({from: notAdminEth}))
301 .to.be.rejectedWith('NoPermission');291 .to.be.rejectedWith('NoPermission');
302292
303 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);293 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);
358 });348 });
359 });349 });
360350
361 itEth.skip('Change owner', async ({helper}) => {351 itEth('Change owner [cross]', async ({helper}) => {
362 const owner = await helper.eth.createAccountWithBalance(donor);352 const owner = await helper.eth.createAccountWithBalance(donor);
363 const [newOwner] = await helper.arrange.createAccounts([10n], donor);353 const [newOwner] = await helper.arrange.createAccounts([10n], donor);
354 const newOwnerCross = helper.ethCrossAccount.fromKeyringPair(newOwner);
364 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');355 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
365 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);356 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
366357
367 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.true;358 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.true;
368 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;359 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.false;
369360
370 await collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send();361 await collectionEvm.methods.setOwnerCross(newOwnerCross).send();
371362
372 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;363 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;
373 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.true;364 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.true;
374 });365 });
375366
376 itEth.skip('change owner call fee', async ({helper}) => {367 itEth.skip('change owner call fee', async ({helper}) => {
384 expect(cost > 0);375 expect(cost > 0);
385 });376 });
386377
387 itEth.skip('(!negative tests!) call setOwner by non owner', async ({helper}) => {378 itEth('(!negative tests!) call setOwner by non owner [cross]', async ({helper}) => {
388 const owner = await helper.eth.createAccountWithBalance(donor);379 const owner = await helper.eth.createAccountWithBalance(donor);
389 const otherReceiver = await helper.eth.createAccountWithBalance(donor);380 const otherReceiver = await helper.eth.createAccountWithBalance(donor);
390 const [newOwner] = await helper.arrange.createAccounts([10n], donor);381 const [newOwner] = await helper.arrange.createAccounts([10n], donor);
382 const newOwnerCross = helper.ethCrossAccount.fromKeyringPair(newOwner);
391 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');383 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
392 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);384 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
393385
394 await expect(collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send({from: otherReceiver})).to.be.rejected;386 await expect(collectionEvm.methods.setOwnerCross(newOwnerCross).send({from: otherReceiver})).to.be.rejected;
395 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;387 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.false;
396 });388 });
397});389});
398390
addedtests/src/eth/createFTCollection.seqtest.tsdiffbeforeafterboth

no changes

modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
31 });31 });
32 });32 });
3333
34 itEth('Create collection', async ({helper}) => {
35 const owner = await helper.eth.createAccountWithBalance(donor);
36
37 const name = 'CollectionEVM';
38 const description = 'Some description';
39 const prefix = 'token prefix';
40
41 // todo:playgrounds this might fail when in async environment.
42 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
43
44 const {collectionId} = await helper.eth.createFungibleCollection(owner, name, DECIMALS, description, prefix);
45
46 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
47 const data = (await helper.ft.getData(collectionId))!;
48
49 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
50 expect(collectionId).to.be.eq(collectionCountAfter);
51 expect(data.name).to.be.eq(name);
52 expect(data.description).to.be.eq(description);
53 expect(data.raw.tokenPrefix).to.be.eq(prefix);
54 expect(data.raw.mode).to.be.deep.eq({Fungible: DECIMALS.toString()});
55 });
56
57 // todo:playgrounds this test will fail when in async environment.
58 itEth('Check collection address exist', async ({helper}) => {
59 const owner = await helper.eth.createAccountWithBalance(donor);
60
61 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;
62 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);
63 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
64
65 expect(await collectionHelpers.methods
66 .isCollectionExist(expectedCollectionAddress)
67 .call()).to.be.false;
68
69
70 await helper.eth.createFungibleCollection(owner, 'A', DECIMALS, 'A', 'A');
71
72
73 expect(await collectionHelpers.methods
74 .isCollectionExist(expectedCollectionAddress)
75 .call()).to.be.true;
76 });
77
78 itEth('Set sponsorship', async ({helper}) => {34 itEth('Set sponsorship', async ({helper}) => {
79 const owner = await helper.eth.createAccountWithBalance(donor);35 const owner = await helper.eth.createAccountWithBalance(donor);
addedtests/src/eth/createNFTCollection.seqtest.tsdiffbeforeafterboth

no changes

modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
28 });28 });
29 });29 });
30
31 itEth('Create collection', async ({helper}) => {
32 const owner = await helper.eth.createAccountWithBalance(donor);
33
34 const name = 'CollectionEVM';
35 const description = 'Some description';
36 const prefix = 'token prefix';
37
38 // todo:playgrounds this might fail when in async environment.
39 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
40 const {collectionId, collectionAddress, events} = await helper.eth.createNFTCollection(owner, name, description, prefix);
41
42 expect(events).to.be.deep.equal([
43 {
44 address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',
45 event: 'CollectionCreated',
46 args: {
47 owner: owner,
48 collectionId: collectionAddress,
49 },
50 },
51 ]);
52
53 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
54
55 const collection = helper.nft.getCollectionObject(collectionId);
56 const data = (await collection.getData())!;
57
58 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
59 expect(collectionId).to.be.eq(collectionCountAfter);
60 expect(data.name).to.be.eq(name);
61 expect(data.description).to.be.eq(description);
62 expect(data.raw.tokenPrefix).to.be.eq(prefix);
63 expect(data.raw.mode).to.be.eq('NFT');
64
65 const options = await collection.getOptions();
66
67 expect(options.tokenPropertyPermissions).to.be.empty;
68 });
6930
70 itEth('Create collection with properties', async ({helper}) => {31 itEth('Create collection with properties', async ({helper}) => {
71 const owner = await helper.eth.createAccountWithBalance(donor);32 const owner = await helper.eth.createAccountWithBalance(donor);
109 ]);70 ]);
110 });71 });
111
112 // this test will occasionally fail when in async environment.
113 itEth.skip('Check collection address exist', async ({helper}) => {
114 const owner = await helper.eth.createAccountWithBalance(donor);
115
116 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;
117 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);
118 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
119
120 expect(await collectionHelpers.methods
121 .isCollectionExist(expectedCollectionAddress)
122 .call()).to.be.false;
123
124 await collectionHelpers.methods
125 .createNFTCollection('A', 'A', 'A')
126 .send({value: Number(2n * helper.balance.getOneTokenNominal())});
127
128 expect(await collectionHelpers.methods
129 .isCollectionExist(expectedCollectionAddress)
130 .call()).to.be.true;
131 });
13272
133 itEth('Set sponsorship', async ({helper}) => {73 itEth('Set sponsorship', async ({helper}) => {
134 const owner = await helper.eth.createAccountWithBalance(donor);74 const owner = await helper.eth.createAccountWithBalance(donor);
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
52describe('Fungible: Plain calls', () => {52describe('Fungible: Plain calls', () => {
53 let donor: IKeyringPair;53 let donor: IKeyringPair;
54 let alice: IKeyringPair;54 let alice: IKeyringPair;
55 let owner: IKeyringPair;
5556
56 before(async function() {57 before(async function() {
57 await usingEthPlaygrounds(async (helper, privateKey) => {58 await usingEthPlaygrounds(async (helper, privateKey) => {
58 donor = await privateKey({filename: __filename});59 donor = await privateKey({filename: __filename});
59 [alice] = await helper.arrange.createAccounts([20n], donor);60 [alice, owner] = await helper.arrange.createAccounts([20n, 20n], donor);
60 });61 });
61 });62 });
6263
148 }149 }
149 });150 });
150151
151 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {152 itEth('Can perform burnFromCross()', async ({helper}) => {
152 const alice = await privateKey('//Alice');
153 const sender = await helper.eth.createAccountWithBalance(alice, 100n);153 const sender = await helper.eth.createAccountWithBalance(donor, 100n);
154154
155 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);155 const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
156156
157 await collection.mint(alice, 200n, {Substrate: alice.address});157 await collection.mint(owner, 200n, {Substrate: owner.address});
158 await collection.approveTokens(alice, {Ethereum: sender}, 100n);158 await collection.approveTokens(owner, {Ethereum: sender}, 100n);
159159
160 const address = helper.ethAddress.fromCollectionId(collection.collectionId);160 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
161 const contract = helper.ethNativeContract.collection(address, 'ft');161 const contract = helper.ethNativeContract.collection(address, 'ft');
162162
163 const fromBalanceBefore = await collection.getBalance({Substrate: alice.address});163 const fromBalanceBefore = await collection.getBalance({Substrate: owner.address});
164 164
165 const ownerCross = helper.ethCrossAccount.fromKeyringPair(alice);165 const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);
166 const result = await contract.methods.burnFromCross(ownerCross, 49).send({from: sender});166 const result = await contract.methods.burnFromCross(ownerCross, 49).send({from: sender});
167 const events = result.events;167 const events = result.events;
168168
171 address: helper.ethAddress.fromCollectionId(collection.collectionId),171 address: helper.ethAddress.fromCollectionId(collection.collectionId),
172 event: 'Transfer',172 event: 'Transfer',
173 returnValues: {173 returnValues: {
174 from: helper.address.substrateToEth(alice.address),174 from: helper.address.substrateToEth(owner.address),
175 to: '0x0000000000000000000000000000000000000000',175 to: '0x0000000000000000000000000000000000000000',
176 value: '49',176 value: '49',
177 },177 },
178 },178 },
179 Approval: {179 Approval: {
180 address: helper.ethAddress.fromCollectionId(collection.collectionId),180 address: helper.ethAddress.fromCollectionId(collection.collectionId),
181 returnValues: {181 returnValues: {
182 owner: helper.address.substrateToEth(alice.address),182 owner: helper.address.substrateToEth(owner.address),
183 spender: sender,183 spender: sender,
184 value: '51',184 value: '51',
185 },185 },
186 event: 'Approval',186 event: 'Approval',
187 },187 },
188 });188 });
189189
190 const fromBalanceAfter = await collection.getBalance({Substrate: alice.address});190 const fromBalanceAfter = await collection.getBalance({Substrate: owner.address});
191 expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(49n);191 expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(49n);
192 });192 });
193193
261 });261 });
262262
263 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {263 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
264 const alice = await privateKey('//Alice');
265 const sender = await helper.eth.createAccountWithBalance(alice, 100n);264 const sender = await helper.eth.createAccountWithBalance(donor, 100n);
266265
267 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);266 const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
268267
269 const receiver = helper.eth.createAccount();268 const receiver = helper.eth.createAccount();
270269
271 await collection.mint(alice, 200n, {Substrate: alice.address});270 await collection.mint(owner, 200n, {Substrate: owner.address});
272 await collection.approveTokens(alice, {Ethereum: sender}, 100n);271 await collection.approveTokens(owner, {Ethereum: sender}, 100n);
273272
274 const address = helper.ethAddress.fromCollectionId(collection.collectionId);273 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
275 const contract = helper.ethNativeContract.collection(address, 'ft');274 const contract = helper.ethNativeContract.collection(address, 'ft');
276275
277 const from = helper.ethCrossAccount.fromKeyringPair(alice);276 const from = helper.ethCrossAccount.fromKeyringPair(owner);
278 const to = helper.ethCrossAccount.fromAddress(receiver);277 const to = helper.ethCrossAccount.fromAddress(receiver);
279278
280 const fromBalanceBefore = await collection.getBalance({Substrate: alice.address});279 const fromBalanceBefore = await collection.getBalance({Substrate: owner.address});
281 const toBalanceBefore = await collection.getBalance({Ethereum: receiver});280 const toBalanceBefore = await collection.getBalance({Ethereum: receiver});
282 281
283 const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});282 const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});
287 address,286 address,
288 event: 'Transfer',287 event: 'Transfer',
289 returnValues: {288 returnValues: {
290 from: helper.address.substrateToEth(alice.address),289 from: helper.address.substrateToEth(owner.address),
291 to: receiver,290 to: receiver,
292 value: '51',291 value: '51',
293 },292 },
296 address,295 address,
297 event: 'Approval',296 event: 'Approval',
298 returnValues: {297 returnValues: {
299 owner: helper.address.substrateToEth(alice.address),298 owner: helper.address.substrateToEth(owner.address),
300 spender: sender,299 spender: sender,
301 value: '49',300 value: '49',
302 },301 },
303 }});302 }});
304303
305 const fromBalanceAfter = await collection.getBalance({Substrate: alice.address});304 const fromBalanceAfter = await collection.getBalance({Substrate: owner.address});
306 expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(51n);305 expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(51n);
307 const toBalanceAfter = await collection.getBalance({Ethereum: receiver});306 const toBalanceAfter = await collection.getBalance({Ethereum: receiver});
308 expect(toBalanceAfter - toBalanceBefore).to.be.eq(51n);307 expect(toBalanceAfter - toBalanceBefore).to.be.eq(51n);
365describe('Fungible: Substrate calls', () => {364describe('Fungible: Substrate calls', () => {
366 let donor: IKeyringPair;365 let donor: IKeyringPair;
367 let alice: IKeyringPair;366 let alice: IKeyringPair;
367 let owner: IKeyringPair;
368368
369 before(async function() {369 before(async function() {
370 await usingEthPlaygrounds(async (helper, privateKey) => {370 await usingEthPlaygrounds(async (helper, privateKey) => {
371 donor = await privateKey({filename: __filename});371 donor = await privateKey({filename: __filename});
372 [alice] = await helper.arrange.createAccounts([20n], donor);372 [alice, owner] = await helper.arrange.createAccounts([20n, 20n], donor);
373 });373 });
374 });374 });
375375
455 });455 });
456456
457 itEth('Events emitted for transferFromCross()', async ({helper, privateKey}) => {457 itEth('Events emitted for transferFromCross()', async ({helper, privateKey}) => {
458 const alice = await privateKey('//Alice');
459 const sender = await helper.eth.createAccountWithBalance(alice, 100n);458 const sender = await helper.eth.createAccountWithBalance(donor, 100n);
460459
461 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);460 const collection = await helper.ft.mintCollection(owner, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
462461
463 const receiver = helper.eth.createAccount();462 const receiver = helper.eth.createAccount();
464463
465 await collection.mint(alice, 200n, {Substrate: alice.address});464 await collection.mint(owner, 200n, {Substrate: owner.address});
466 await collection.approveTokens(alice, {Ethereum: sender}, 100n);465 await collection.approveTokens(owner, {Ethereum: sender}, 100n);
467466
468 const address = helper.ethAddress.fromCollectionId(collection.collectionId);467 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
469 const contract = helper.ethNativeContract.collection(address, 'ft');468 const contract = helper.ethNativeContract.collection(address, 'ft');
470469
471 const from = helper.ethCrossAccount.fromKeyringPair(alice);470 const from = helper.ethCrossAccount.fromKeyringPair(owner);
472 const to = helper.ethCrossAccount.fromAddress(receiver);471 const to = helper.ethCrossAccount.fromAddress(receiver);
473 472
474 const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});473 const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});
478 address,477 address,
479 event: 'Transfer',478 event: 'Transfer',
480 returnValues: {479 returnValues: {
481 from: helper.address.substrateToEth(alice.address),480 from: helper.address.substrateToEth(owner.address),
482 to: receiver,481 to: receiver,
483 value: '51',482 value: '51',
484 },483 },
487 address,486 address,
488 event: 'Approval',487 event: 'Approval',
489 returnValues: {488 returnValues: {
490 owner: helper.address.substrateToEth(alice.address),489 owner: helper.address.substrateToEth(owner.address),
491 spender: sender,490 spender: sender,
492 value: '49',491 value: '49',
493 },492 },
modifiedtests/src/eth/fungibleAbi.jsondiffbeforeafterboth
62 "inputs": [62 "inputs": [
63 {63 {
64 "components": [64 "components": [
65 { "internalType": "address", "name": "field_0", "type": "address" },65 { "internalType": "address", "name": "eth", "type": "address" },
66 { "internalType": "uint256", "name": "field_1", "type": "uint256" }66 { "internalType": "uint256", "name": "sub", "type": "uint256" }
67 ],67 ],
68 "internalType": "struct Tuple6",68 "internalType": "struct EthCrossAccount",
69 "name": "newAdmin",69 "name": "newAdmin",
70 "type": "tuple"70 "type": "tuple"
71 }71 }
88 "inputs": [88 "inputs": [
89 {89 {
90 "components": [90 "components": [
91 { "internalType": "address", "name": "field_0", "type": "address" },91 { "internalType": "address", "name": "eth", "type": "address" },
92 { "internalType": "uint256", "name": "field_1", "type": "uint256" }92 { "internalType": "uint256", "name": "sub", "type": "uint256" }
93 ],93 ],
94 "internalType": "struct Tuple6",94 "internalType": "struct EthCrossAccount",
95 "name": "user",95 "name": "user",
96 "type": "tuple"96 "type": "tuple"
97 }97 }
134 "inputs": [134 "inputs": [
135 {135 {
136 "components": [136 "components": [
137 { "internalType": "address", "name": "field_0", "type": "address" },137 { "internalType": "address", "name": "eth", "type": "address" },
138 { "internalType": "uint256", "name": "field_1", "type": "uint256" }138 { "internalType": "uint256", "name": "sub", "type": "uint256" }
139 ],139 ],
140 "internalType": "struct Tuple6",140 "internalType": "struct EthCrossAccount",
141 "name": "spender",141 "name": "spender",
142 "type": "tuple"142 "type": "tuple"
143 },143 },
171 "inputs": [171 "inputs": [
172 {172 {
173 "components": [173 "components": [
174 { "internalType": "address", "name": "field_0", "type": "address" },174 { "internalType": "address", "name": "eth", "type": "address" },
175 { "internalType": "uint256", "name": "field_1", "type": "uint256" }175 { "internalType": "uint256", "name": "sub", "type": "uint256" }
176 ],176 ],
177 "internalType": "struct Tuple6",177 "internalType": "struct EthCrossAccount",
178 "name": "from",178 "name": "from",
179 "type": "tuple"179 "type": "tuple"
180 },180 },
200 "outputs": [200 "outputs": [
201 {201 {
202 "components": [202 "components": [
203 { "internalType": "address", "name": "field_0", "type": "address" },203 { "internalType": "address", "name": "eth", "type": "address" },
204 { "internalType": "uint256", "name": "field_1", "type": "uint256" }204 { "internalType": "uint256", "name": "sub", "type": "uint256" }
205 ],205 ],
206 "internalType": "struct Tuple6[]",206 "internalType": "struct EthCrossAccount[]",
207 "name": "",207 "name": "",
208 "type": "tuple[]"208 "type": "tuple[]"
209 }209 }
217 "outputs": [217 "outputs": [
218 {218 {
219 "components": [219 "components": [
220 { "internalType": "address", "name": "field_0", "type": "address" },220 { "internalType": "address", "name": "eth", "type": "address" },
221 { "internalType": "uint256", "name": "field_1", "type": "uint256" }221 { "internalType": "uint256", "name": "sub", "type": "uint256" }
222 ],222 ],
223 "internalType": "struct Tuple6",223 "internalType": "struct EthCrossAccount",
224 "name": "",224 "name": "",
225 "type": "tuple"225 "type": "tuple"
226 }226 }
239 { "internalType": "string", "name": "field_0", "type": "string" },239 { "internalType": "string", "name": "field_0", "type": "string" },
240 { "internalType": "bytes", "name": "field_1", "type": "bytes" }240 { "internalType": "bytes", "name": "field_1", "type": "bytes" }
241 ],241 ],
242 "internalType": "struct Tuple10[]",242 "internalType": "struct Tuple14[]",
243 "name": "",243 "name": "",
244 "type": "tuple[]"244 "type": "tuple[]"
245 }245 }
263 { "internalType": "address", "name": "field_0", "type": "address" },263 { "internalType": "address", "name": "field_0", "type": "address" },
264 { "internalType": "uint256", "name": "field_1", "type": "uint256" }264 { "internalType": "uint256", "name": "field_1", "type": "uint256" }
265 ],265 ],
266 "internalType": "struct Tuple6",266 "internalType": "struct Tuple8",
267 "name": "",267 "name": "",
268 "type": "tuple"268 "type": "tuple"
269 }269 }
328 "inputs": [328 "inputs": [
329 {329 {
330 "components": [330 "components": [
331 { "internalType": "address", "name": "field_0", "type": "address" },331 { "internalType": "address", "name": "eth", "type": "address" },
332 { "internalType": "uint256", "name": "field_1", "type": "uint256" }332 { "internalType": "uint256", "name": "sub", "type": "uint256" }
333 ],333 ],
334 "internalType": "struct Tuple6",334 "internalType": "struct EthCrossAccount",
335 "name": "user",335 "name": "user",
336 "type": "tuple"336 "type": "tuple"
337 }337 }
358 { "internalType": "address", "name": "field_0", "type": "address" },358 { "internalType": "address", "name": "field_0", "type": "address" },
359 { "internalType": "uint256", "name": "field_1", "type": "uint256" }359 { "internalType": "uint256", "name": "field_1", "type": "uint256" }
360 ],360 ],
361 "internalType": "struct Tuple6[]",361 "internalType": "struct Tuple8[]",
362 "name": "amounts",362 "name": "amounts",
363 "type": "tuple[]"363 "type": "tuple[]"
364 }364 }
388 "inputs": [388 "inputs": [
389 {389 {
390 "components": [390 "components": [
391 { "internalType": "address", "name": "field_0", "type": "address" },391 { "internalType": "address", "name": "eth", "type": "address" },
392 { "internalType": "uint256", "name": "field_1", "type": "uint256" }392 { "internalType": "uint256", "name": "sub", "type": "uint256" }
393 ],393 ],
394 "internalType": "struct Tuple6",394 "internalType": "struct EthCrossAccount",
395 "name": "admin",395 "name": "admin",
396 "type": "tuple"396 "type": "tuple"
397 }397 }
421 "inputs": [421 "inputs": [
422 {422 {
423 "components": [423 "components": [
424 { "internalType": "address", "name": "field_0", "type": "address" },424 { "internalType": "address", "name": "eth", "type": "address" },
425 { "internalType": "uint256", "name": "field_1", "type": "uint256" }425 { "internalType": "uint256", "name": "sub", "type": "uint256" }
426 ],426 ],
427 "internalType": "struct Tuple6",427 "internalType": "struct EthCrossAccount",
428 "name": "user",428 "name": "user",
429 "type": "tuple"429 "type": "tuple"
430 }430 }
496 { "internalType": "string", "name": "field_0", "type": "string" },496 { "internalType": "string", "name": "field_0", "type": "string" },
497 { "internalType": "bytes", "name": "field_1", "type": "bytes" }497 { "internalType": "bytes", "name": "field_1", "type": "bytes" }
498 ],498 ],
499 "internalType": "struct Tuple10[]",499 "internalType": "struct Tuple14[]",
500 "name": "properties",500 "name": "properties",
501 "type": "tuple[]"501 "type": "tuple[]"
502 }502 }
529 "inputs": [529 "inputs": [
530 {530 {
531 "components": [531 "components": [
532 { "internalType": "address", "name": "field_0", "type": "address" },532 { "internalType": "address", "name": "eth", "type": "address" },
533 { "internalType": "uint256", "name": "field_1", "type": "uint256" }533 { "internalType": "uint256", "name": "sub", "type": "uint256" }
534 ],534 ],
535 "internalType": "struct Tuple6",535 "internalType": "struct EthCrossAccount",
536 "name": "sponsor",536 "name": "sponsor",
537 "type": "tuple"537 "type": "tuple"
538 }538 }
546 "inputs": [546 "inputs": [
547 {547 {
548 "components": [548 "components": [
549 { "internalType": "address", "name": "field_0", "type": "address" },549 { "internalType": "address", "name": "eth", "type": "address" },
550 { "internalType": "uint256", "name": "field_1", "type": "uint256" }550 { "internalType": "uint256", "name": "sub", "type": "uint256" }
551 ],551 ],
552 "internalType": "struct Tuple6",552 "internalType": "struct EthCrossAccount",
553 "name": "newOwner",553 "name": "newOwner",
554 "type": "tuple"554 "type": "tuple"
555 }555 }
607 "inputs": [607 "inputs": [
608 {608 {
609 "components": [609 "components": [
610 { "internalType": "address", "name": "field_0", "type": "address" },610 { "internalType": "address", "name": "eth", "type": "address" },
611 { "internalType": "uint256", "name": "field_1", "type": "uint256" }611 { "internalType": "uint256", "name": "sub", "type": "uint256" }
612 ],612 ],
613 "internalType": "struct Tuple6",613 "internalType": "struct EthCrossAccount",
614 "name": "from",614 "name": "from",
615 "type": "tuple"615 "type": "tuple"
616 },616 },
617 {617 {
618 "components": [618 "components": [
619 { "internalType": "address", "name": "field_0", "type": "address" },619 { "internalType": "address", "name": "eth", "type": "address" },
620 { "internalType": "uint256", "name": "field_1", "type": "uint256" }620 { "internalType": "uint256", "name": "sub", "type": "uint256" }
621 ],621 ],
622 "internalType": "struct Tuple6",622 "internalType": "struct EthCrossAccount",
623 "name": "to",623 "name": "to",
624 "type": "tuple"624 "type": "tuple"
625 },625 },
addedtests/src/eth/migration.seqtest.tsdiffbeforeafterboth

no changes

deletedtests/src/eth/migration.test.tsdiffbeforeafterboth

no changes

modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
138138
139describe('NFT: Plain calls', () => {139describe('NFT: Plain calls', () => {
140 let donor: IKeyringPair;140 let donor: IKeyringPair;
141 let alice: IKeyringPair;141 let minter: IKeyringPair;
142 let bob: IKeyringPair;
143 let charlie: IKeyringPair;
142144
143 before(async function() {145 before(async function() {
144 await usingEthPlaygrounds(async (helper, privateKey) => {146 await usingEthPlaygrounds(async (helper, privateKey) => {
145 donor = await privateKey({filename: __filename});147 donor = await privateKey({filename: __filename});
146 [alice] = await helper.arrange.createAccounts([10n], donor);148 [minter, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
147 });149 });
148 });150 });
149151
176 const caller = await helper.eth.createAccountWithBalance(donor);178 const caller = await helper.eth.createAccountWithBalance(donor);
177 const receiver = helper.eth.createAccount();179 const receiver = helper.eth.createAccount();
178180
179 const collection = await helper.nft.mintCollection(alice);181 const collection = await helper.nft.mintCollection(minter);
180 await collection.addAdmin(alice, {Ethereum: caller});182 await collection.addAdmin(minter, {Ethereum: caller});
181183
182 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);184 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
183 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);185 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);
208 itEth('Can perform burn()', async ({helper}) => {210 itEth('Can perform burn()', async ({helper}) => {
209 const caller = await helper.eth.createAccountWithBalance(donor);211 const caller = await helper.eth.createAccountWithBalance(donor);
210212
211 const collection = await helper.nft.mintCollection(alice, {});213 const collection = await helper.nft.mintCollection(minter, {});
212 const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});214 const {tokenId} = await collection.mintToken(minter, {Ethereum: caller});
213215
214 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);216 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
215 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);217 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);
229 const owner = await helper.eth.createAccountWithBalance(donor);231 const owner = await helper.eth.createAccountWithBalance(donor);
230 const spender = helper.eth.createAccount();232 const spender = helper.eth.createAccount();
231233
232 const collection = await helper.nft.mintCollection(alice, {});234 const collection = await helper.nft.mintCollection(minter, {});
233 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});235 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});
234236
235 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);237 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
236 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);238 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
246 }248 }
247 });249 });
248250
249 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {251 itEth('Can perform burnFromCross()', async ({helper}) => {
250 const alice = await privateKey('//Alice');
251 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});252 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
252253
253 const owner = await privateKey('//Bob');254 const owner = bob;
254 const spender = await helper.eth.createAccountWithBalance(alice, 100n);255 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
255256
256 const token = await collection.mintToken(alice, {Substrate: owner.address});257 const token = await collection.mintToken(minter, {Substrate: owner.address});
257258
258 const address = helper.ethAddress.fromCollectionId(collection.collectionId);259 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
259 const contract = helper.ethNativeContract.collection(address, 'nft');260 const contract = helper.ethNativeContract.collection(address, 'nft');
276 }277 }
277 });278 });
278279
279 itEth('Can perform approveCross()', async ({helper, privateKey}) => {280 itEth('Can perform approveCross()', async ({helper}) => {
280 const alice = await privateKey('//Alice');
281 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});281 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
282282
283 const owner = await helper.eth.createAccountWithBalance(alice, 100n);283 const owner = await helper.eth.createAccountWithBalance(donor, 100n);
284 const receiver = await privateKey('//Charlie');284 const receiver = charlie;
285285
286 const token = await collection.mintToken(alice, {Ethereum: owner});286 const token = await collection.mintToken(minter, {Ethereum: owner});
287287
288 const address = helper.ethAddress.fromCollectionId(collection.collectionId);288 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
289 const contract = helper.ethNativeContract.collection(address, 'nft');289 const contract = helper.ethNativeContract.collection(address, 'nft');
309 const spender = await helper.eth.createAccountWithBalance(donor);309 const spender = await helper.eth.createAccountWithBalance(donor);
310 const receiver = helper.eth.createAccount();310 const receiver = helper.eth.createAccount();
311311
312 const collection = await helper.nft.mintCollection(alice, {});312 const collection = await helper.nft.mintCollection(minter, {});
313 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});313 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});
314314
315 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);315 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
316 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);316 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
338 }338 }
339 });339 });
340
341 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
342 const minter = await privateKey('//Alice');
343 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
344
345 const owner = await privateKey('//Bob');
346 const spender = await helper.eth.createAccountWithBalance(donor);
347 const receiver = await privateKey('//Charlie');
348
349 const token = await collection.mintToken(minter, {Substrate: owner.address});
350
351 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
352 const contract = helper.ethNativeContract.collection(address, 'nft');
353
354 await token.approve(owner, {Ethereum: spender});
355
356 {
357 const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);
358 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);
359 const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});
360 const event = result.events.Transfer;
361 expect(event).to.be.like({
362 address: helper.ethAddress.fromCollectionId(collection.collectionId),
363 event: 'Transfer',
364 returnValues: {
365 from: helper.address.substrateToEth(owner.address),
366 to: helper.address.substrateToEth(receiver.address),
367 tokenId: token.tokenId.toString(),
368 },
369 });
370 }
371
372 expect(await token.getOwner()).to.be.like({Substrate: receiver.address});
373 });
340374
341 itEth('Can perform transfer()', async ({helper}) => {375 itEth('Can perform transfer()', async ({helper}) => {
342 const collection = await helper.nft.mintCollection(alice, {});376 const collection = await helper.nft.mintCollection(minter, {});
343 const owner = await helper.eth.createAccountWithBalance(donor);377 const owner = await helper.eth.createAccountWithBalance(donor);
344 const receiver = helper.eth.createAccount();378 const receiver = helper.eth.createAccount();
345379
346 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});380 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});
347381
348 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);382 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
349 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);383 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
373describe('NFT: Fees', () => {407describe('NFT: Fees', () => {
374 let donor: IKeyringPair;408 let donor: IKeyringPair;
375 let alice: IKeyringPair;409 let alice: IKeyringPair;
410 let bob: IKeyringPair;
411 let charlie: IKeyringPair;
376412
377 before(async function() {413 before(async function() {
378 await usingEthPlaygrounds(async (helper, privateKey) => {414 await usingEthPlaygrounds(async (helper, privateKey) => {
379 donor = await privateKey({filename: __filename});415 donor = await privateKey({filename: __filename});
380 [alice] = await helper.arrange.createAccounts([10n], donor);416 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
381 });417 });
382 });418 });
383419
410 });446 });
411447
412 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {448 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
413 const alice = await privateKey('//Alice');449 const collectionMinter = alice;
450 const owner = bob;
451 const receiver = charlie;
414 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});452 const collection = await helper.nft.mintCollection(collectionMinter, {name: 'A', description: 'B', tokenPrefix: 'C'});
415453
416 const owner = await privateKey('//Bob');
417 const spender = await helper.eth.createAccountWithBalance(alice, 100n);454 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
418 const receiver = await privateKey('//Charlie');
419455
420 const token = await collection.mintToken(alice, {Substrate: owner.address});456 const token = await collection.mintToken(collectionMinter, {Substrate: owner.address});
421457
422 const address = helper.ethAddress.fromCollectionId(collection.collectionId);458 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
423 const contract = helper.ethNativeContract.collection(address, 'nft');459 const contract = helper.ethNativeContract.collection(address, 'nft');
modifiedtests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth
93 "inputs": [93 "inputs": [
94 {94 {
95 "components": [95 "components": [
96 { "internalType": "address", "name": "field_0", "type": "address" },96 { "internalType": "address", "name": "eth", "type": "address" },
97 { "internalType": "uint256", "name": "field_1", "type": "uint256" }97 { "internalType": "uint256", "name": "sub", "type": "uint256" }
98 ],98 ],
99 "internalType": "struct Tuple6",99 "internalType": "struct EthCrossAccount",
100 "name": "newAdmin",100 "name": "newAdmin",
101 "type": "tuple"101 "type": "tuple"
102 }102 }
119 "inputs": [119 "inputs": [
120 {120 {
121 "components": [121 "components": [
122 { "internalType": "address", "name": "field_0", "type": "address" },122 { "internalType": "address", "name": "eth", "type": "address" },
123 { "internalType": "uint256", "name": "field_1", "type": "uint256" }123 { "internalType": "uint256", "name": "sub", "type": "uint256" }
124 ],124 ],
125 "internalType": "struct Tuple6",125 "internalType": "struct EthCrossAccount",
126 "name": "user",126 "name": "user",
127 "type": "tuple"127 "type": "tuple"
128 }128 }
155 "inputs": [155 "inputs": [
156 {156 {
157 "components": [157 "components": [
158 { "internalType": "address", "name": "field_0", "type": "address" },158 { "internalType": "address", "name": "eth", "type": "address" },
159 { "internalType": "uint256", "name": "field_1", "type": "uint256" }159 { "internalType": "uint256", "name": "sub", "type": "uint256" }
160 ],160 ],
161 "internalType": "struct Tuple6",161 "internalType": "struct EthCrossAccount",
162 "name": "approved",162 "name": "approved",
163 "type": "tuple"163 "type": "tuple"
164 },164 },
201 "inputs": [201 "inputs": [
202 {202 {
203 "components": [203 "components": [
204 { "internalType": "address", "name": "field_0", "type": "address" },204 { "internalType": "address", "name": "eth", "type": "address" },
205 { "internalType": "uint256", "name": "field_1", "type": "uint256" }205 { "internalType": "uint256", "name": "sub", "type": "uint256" }
206 ],206 ],
207 "internalType": "struct Tuple6",207 "internalType": "struct EthCrossAccount",
208 "name": "from",208 "name": "from",
209 "type": "tuple"209 "type": "tuple"
210 },210 },
230 "outputs": [230 "outputs": [
231 {231 {
232 "components": [232 "components": [
233 { "internalType": "address", "name": "field_0", "type": "address" },233 { "internalType": "address", "name": "eth", "type": "address" },
234 { "internalType": "uint256", "name": "field_1", "type": "uint256" }234 { "internalType": "uint256", "name": "sub", "type": "uint256" }
235 ],235 ],
236 "internalType": "struct Tuple6[]",236 "internalType": "struct EthCrossAccount[]",
237 "name": "",237 "name": "",
238 "type": "tuple[]"238 "type": "tuple[]"
239 }239 }
247 "outputs": [247 "outputs": [
248 {248 {
249 "components": [249 "components": [
250 { "internalType": "address", "name": "field_0", "type": "address" },250 { "internalType": "address", "name": "eth", "type": "address" },
251 { "internalType": "uint256", "name": "field_1", "type": "uint256" }251 { "internalType": "uint256", "name": "sub", "type": "uint256" }
252 ],252 ],
253 "internalType": "struct Tuple6",253 "internalType": "struct EthCrossAccount",
254 "name": "",254 "name": "",
255 "type": "tuple"255 "type": "tuple"
256 }256 }
269 { "internalType": "string", "name": "field_0", "type": "string" },269 { "internalType": "string", "name": "field_0", "type": "string" },
270 { "internalType": "bytes", "name": "field_1", "type": "bytes" }270 { "internalType": "bytes", "name": "field_1", "type": "bytes" }
271 ],271 ],
272 "internalType": "struct Tuple19[]",272 "internalType": "struct Tuple21[]",
273 "name": "",273 "name": "",
274 "type": "tuple[]"274 "type": "tuple[]"
275 }275 }
293 { "internalType": "address", "name": "field_0", "type": "address" },293 { "internalType": "address", "name": "field_0", "type": "address" },
294 { "internalType": "uint256", "name": "field_1", "type": "uint256" }294 { "internalType": "uint256", "name": "field_1", "type": "uint256" }
295 ],295 ],
296 "internalType": "struct Tuple6",296 "internalType": "struct Tuple24",
297 "name": "",297 "name": "",
298 "type": "tuple"298 "type": "tuple"
299 }299 }
387 "inputs": [387 "inputs": [
388 {388 {
389 "components": [389 "components": [
390 { "internalType": "address", "name": "field_0", "type": "address" },390 { "internalType": "address", "name": "eth", "type": "address" },
391 { "internalType": "uint256", "name": "field_1", "type": "uint256" }391 { "internalType": "uint256", "name": "sub", "type": "uint256" }
392 ],392 ],
393 "internalType": "struct Tuple6",393 "internalType": "struct EthCrossAccount",
394 "name": "user",394 "name": "user",
395 "type": "tuple"395 "type": "tuple"
396 }396 }
470 "inputs": [470 "inputs": [
471 {471 {
472 "components": [472 "components": [
473 { "internalType": "address", "name": "field_0", "type": "address" },473 { "internalType": "address", "name": "eth", "type": "address" },
474 { "internalType": "uint256", "name": "field_1", "type": "uint256" }474 { "internalType": "uint256", "name": "sub", "type": "uint256" }
475 ],475 ],
476 "internalType": "struct Tuple6",476 "internalType": "struct EthCrossAccount",
477 "name": "admin",477 "name": "admin",
478 "type": "tuple"478 "type": "tuple"
479 }479 }
503 "inputs": [503 "inputs": [
504 {504 {
505 "components": [505 "components": [
506 { "internalType": "address", "name": "field_0", "type": "address" },506 { "internalType": "address", "name": "eth", "type": "address" },
507 { "internalType": "uint256", "name": "field_1", "type": "uint256" }507 { "internalType": "uint256", "name": "sub", "type": "uint256" }
508 ],508 ],
509 "internalType": "struct Tuple6",509 "internalType": "struct EthCrossAccount",
510 "name": "user",510 "name": "user",
511 "type": "tuple"511 "type": "tuple"
512 }512 }
611 { "internalType": "string", "name": "field_0", "type": "string" },611 { "internalType": "string", "name": "field_0", "type": "string" },
612 { "internalType": "bytes", "name": "field_1", "type": "bytes" }612 { "internalType": "bytes", "name": "field_1", "type": "bytes" }
613 ],613 ],
614 "internalType": "struct Tuple19[]",614 "internalType": "struct Tuple21[]",
615 "name": "properties",615 "name": "properties",
616 "type": "tuple[]"616 "type": "tuple[]"
617 }617 }
644 "inputs": [644 "inputs": [
645 {645 {
646 "components": [646 "components": [
647 { "internalType": "address", "name": "field_0", "type": "address" },647 { "internalType": "address", "name": "eth", "type": "address" },
648 { "internalType": "uint256", "name": "field_1", "type": "uint256" }648 { "internalType": "uint256", "name": "sub", "type": "uint256" }
649 ],649 ],
650 "internalType": "struct Tuple6",650 "internalType": "struct EthCrossAccount",
651 "name": "sponsor",651 "name": "sponsor",
652 "type": "tuple"652 "type": "tuple"
653 }653 }
661 "inputs": [661 "inputs": [
662 {662 {
663 "components": [663 "components": [
664 { "internalType": "address", "name": "field_0", "type": "address" },664 { "internalType": "address", "name": "eth", "type": "address" },
665 { "internalType": "uint256", "name": "field_1", "type": "uint256" }665 { "internalType": "uint256", "name": "sub", "type": "uint256" }
666 ],666 ],
667 "internalType": "struct Tuple6",667 "internalType": "struct EthCrossAccount",
668 "name": "newOwner",668 "name": "newOwner",
669 "type": "tuple"669 "type": "tuple"
670 }670 }
682 { "internalType": "string", "name": "field_0", "type": "string" },682 { "internalType": "string", "name": "field_0", "type": "string" },
683 { "internalType": "bytes", "name": "field_1", "type": "bytes" }683 { "internalType": "bytes", "name": "field_1", "type": "bytes" }
684 ],684 ],
685 "internalType": "struct Tuple19[]",685 "internalType": "struct Tuple21[]",
686 "name": "properties",686 "name": "properties",
687 "type": "tuple[]"687 "type": "tuple[]"
688 }688 }
791 "inputs": [791 "inputs": [
792 {792 {
793 "components": [793 "components": [
794 { "internalType": "address", "name": "field_0", "type": "address" },794 { "internalType": "address", "name": "eth", "type": "address" },
795 { "internalType": "uint256", "name": "field_1", "type": "uint256" }795 { "internalType": "uint256", "name": "sub", "type": "uint256" }
796 ],796 ],
797 "internalType": "struct Tuple6",797 "internalType": "struct EthCrossAccount",
798 "name": "from",798 "name": "from",
799 "type": "tuple"799 "type": "tuple"
800 },800 },
801 {801 {
802 "components": [802 "components": [
803 { "internalType": "address", "name": "field_0", "type": "address" },803 { "internalType": "address", "name": "eth", "type": "address" },
804 { "internalType": "uint256", "name": "field_1", "type": "uint256" }804 { "internalType": "uint256", "name": "sub", "type": "uint256" }
805 ],805 ],
806 "internalType": "struct Tuple6",806 "internalType": "struct EthCrossAccount",
807 "name": "to",807 "name": "to",
808 "type": "tuple"808 "type": "tuple"
809 },809 },
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
104104
105describe('Refungible: Plain calls', () => {105describe('Refungible: Plain calls', () => {
106 let donor: IKeyringPair;106 let donor: IKeyringPair;
107 let minter: IKeyringPair;
108 let bob: IKeyringPair;
109 let charlie: IKeyringPair;
107110
108 before(async function() {111 before(async function() {
109 await usingEthPlaygrounds(async (helper, privateKey) => {112 await usingEthPlaygrounds(async (helper, privateKey) => {
110 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);113 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
111114
112 donor = await privateKey({filename: __filename});115 donor = await privateKey({filename: __filename});
116 [minter, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
113 });117 });
114 });118 });
115119
227 }231 }
228 });232 });
229233
230 itEth('Can perform burnFrom()', async ({helper, privateKey}) => {234 itEth('Can perform burnFrom()', async ({helper}) => {
231 const alice = await privateKey('//Alice');
232 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});235 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
233236
234 const owner = await helper.eth.createAccountWithBalance(alice, 100n);237 const owner = await helper.eth.createAccountWithBalance(donor, 100n);
235 const spender = await helper.eth.createAccountWithBalance(alice, 100n);238 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
236239
237 const token = await collection.mintToken(alice, 100n, {Ethereum: owner});240 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});
238241
239 const address = helper.ethAddress.fromCollectionId(collection.collectionId);242 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
240 const contract = helper.ethNativeContract.collection(address, 'rft');243 const contract = helper.ethNativeContract.collection(address, 'rft');
261 expect(await collection.getTokenBalance(token.tokenId, {Ethereum: owner})).to.be.eq(0n);264 expect(await collection.getTokenBalance(token.tokenId, {Ethereum: owner})).to.be.eq(0n);
262 });265 });
263266
264 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {267 itEth('Can perform burnFromCross()', async ({helper}) => {
265 const alice = await privateKey('//Alice');
266 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});268 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
267269
268 const owner = await privateKey('//Bob');270 const owner = bob;
269 const spender = await helper.eth.createAccountWithBalance(alice, 100n);271 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
270272
271 const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});273 const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});
272274
273 const address = helper.ethAddress.fromCollectionId(collection.collectionId);275 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
274 const contract = helper.ethNativeContract.collection(address, 'rft');276 const contract = helper.ethNativeContract.collection(address, 'rft');
294 expect(await collection.getTokenBalance(token.tokenId, {Substrate: owner.address})).to.be.eq(0n);296 expect(await collection.getTokenBalance(token.tokenId, {Substrate: owner.address})).to.be.eq(0n);
295 });297 });
296298
297 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {299 itEth('Can perform transferFromCross()', async ({helper}) => {
298 const alice = await privateKey('//Alice');
299 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});300 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
300301
301 const owner = await privateKey('//Bob');302 const owner = bob;
302 const spender = await helper.eth.createAccountWithBalance(alice, 100n);303 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
303 const receiver = await privateKey('//Charlie');304 const receiver = charlie;
304305
305 const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});306 const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});
306307
307 const address = helper.ethAddress.fromCollectionId(collection.collectionId);308 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
308 const contract = helper.ethNativeContract.collection(address, 'rft');309 const contract = helper.ethNativeContract.collection(address, 'rft');
modifiedtests/src/eth/reFungibleAbi.jsondiffbeforeafterboth
93 "inputs": [93 "inputs": [
94 {94 {
95 "components": [95 "components": [
96 { "internalType": "address", "name": "field_0", "type": "address" },96 { "internalType": "address", "name": "eth", "type": "address" },
97 { "internalType": "uint256", "name": "field_1", "type": "uint256" }97 { "internalType": "uint256", "name": "sub", "type": "uint256" }
98 ],98 ],
99 "internalType": "struct Tuple6",99 "internalType": "struct EthCrossAccount",
100 "name": "newAdmin",100 "name": "newAdmin",
101 "type": "tuple"101 "type": "tuple"
102 }102 }
119 "inputs": [119 "inputs": [
120 {120 {
121 "components": [121 "components": [
122 { "internalType": "address", "name": "field_0", "type": "address" },122 { "internalType": "address", "name": "eth", "type": "address" },
123 { "internalType": "uint256", "name": "field_1", "type": "uint256" }123 { "internalType": "uint256", "name": "sub", "type": "uint256" }
124 ],124 ],
125 "internalType": "struct Tuple6",125 "internalType": "struct EthCrossAccount",
126 "name": "user",126 "name": "user",
127 "type": "tuple"127 "type": "tuple"
128 }128 }
183 "inputs": [183 "inputs": [
184 {184 {
185 "components": [185 "components": [
186 { "internalType": "address", "name": "field_0", "type": "address" },186 { "internalType": "address", "name": "eth", "type": "address" },
187 { "internalType": "uint256", "name": "field_1", "type": "uint256" }187 { "internalType": "uint256", "name": "sub", "type": "uint256" }
188 ],188 ],
189 "internalType": "struct Tuple6",189 "internalType": "struct EthCrossAccount",
190 "name": "from",190 "name": "from",
191 "type": "tuple"191 "type": "tuple"
192 },192 },
212 "outputs": [212 "outputs": [
213 {213 {
214 "components": [214 "components": [
215 { "internalType": "address", "name": "field_0", "type": "address" },215 { "internalType": "address", "name": "eth", "type": "address" },
216 { "internalType": "uint256", "name": "field_1", "type": "uint256" }216 { "internalType": "uint256", "name": "sub", "type": "uint256" }
217 ],217 ],
218 "internalType": "struct Tuple6[]",218 "internalType": "struct EthCrossAccount[]",
219 "name": "",219 "name": "",
220 "type": "tuple[]"220 "type": "tuple[]"
221 }221 }
229 "outputs": [229 "outputs": [
230 {230 {
231 "components": [231 "components": [
232 { "internalType": "address", "name": "field_0", "type": "address" },232 { "internalType": "address", "name": "eth", "type": "address" },
233 { "internalType": "uint256", "name": "field_1", "type": "uint256" }233 { "internalType": "uint256", "name": "sub", "type": "uint256" }
234 ],234 ],
235 "internalType": "struct Tuple6",235 "internalType": "struct EthCrossAccount",
236 "name": "",236 "name": "",
237 "type": "tuple"237 "type": "tuple"
238 }238 }
251 { "internalType": "string", "name": "field_0", "type": "string" },251 { "internalType": "string", "name": "field_0", "type": "string" },
252 { "internalType": "bytes", "name": "field_1", "type": "bytes" }252 { "internalType": "bytes", "name": "field_1", "type": "bytes" }
253 ],253 ],
254 "internalType": "struct Tuple19[]",254 "internalType": "struct Tuple20[]",
255 "name": "",255 "name": "",
256 "type": "tuple[]"256 "type": "tuple[]"
257 }257 }
275 { "internalType": "address", "name": "field_0", "type": "address" },275 { "internalType": "address", "name": "field_0", "type": "address" },
276 { "internalType": "uint256", "name": "field_1", "type": "uint256" }276 { "internalType": "uint256", "name": "field_1", "type": "uint256" }
277 ],277 ],
278 "internalType": "struct Tuple6",278 "internalType": "struct Tuple23",
279 "name": "",279 "name": "",
280 "type": "tuple"280 "type": "tuple"
281 }281 }
369 "inputs": [369 "inputs": [
370 {370 {
371 "components": [371 "components": [
372 { "internalType": "address", "name": "field_0", "type": "address" },372 { "internalType": "address", "name": "eth", "type": "address" },
373 { "internalType": "uint256", "name": "field_1", "type": "uint256" }373 { "internalType": "uint256", "name": "sub", "type": "uint256" }
374 ],374 ],
375 "internalType": "struct Tuple6",375 "internalType": "struct EthCrossAccount",
376 "name": "user",376 "name": "user",
377 "type": "tuple"377 "type": "tuple"
378 }378 }
452 "inputs": [452 "inputs": [
453 {453 {
454 "components": [454 "components": [
455 { "internalType": "address", "name": "field_0", "type": "address" },455 { "internalType": "address", "name": "eth", "type": "address" },
456 { "internalType": "uint256", "name": "field_1", "type": "uint256" }456 { "internalType": "uint256", "name": "sub", "type": "uint256" }
457 ],457 ],
458 "internalType": "struct Tuple6",458 "internalType": "struct EthCrossAccount",
459 "name": "admin",459 "name": "admin",
460 "type": "tuple"460 "type": "tuple"
461 }461 }
485 "inputs": [485 "inputs": [
486 {486 {
487 "components": [487 "components": [
488 { "internalType": "address", "name": "field_0", "type": "address" },488 { "internalType": "address", "name": "eth", "type": "address" },
489 { "internalType": "uint256", "name": "field_1", "type": "uint256" }489 { "internalType": "uint256", "name": "sub", "type": "uint256" }
490 ],490 ],
491 "internalType": "struct Tuple6",491 "internalType": "struct EthCrossAccount",
492 "name": "user",492 "name": "user",
493 "type": "tuple"493 "type": "tuple"
494 }494 }
593 { "internalType": "string", "name": "field_0", "type": "string" },593 { "internalType": "string", "name": "field_0", "type": "string" },
594 { "internalType": "bytes", "name": "field_1", "type": "bytes" }594 { "internalType": "bytes", "name": "field_1", "type": "bytes" }
595 ],595 ],
596 "internalType": "struct Tuple19[]",596 "internalType": "struct Tuple20[]",
597 "name": "properties",597 "name": "properties",
598 "type": "tuple[]"598 "type": "tuple[]"
599 }599 }
626 "inputs": [626 "inputs": [
627 {627 {
628 "components": [628 "components": [
629 { "internalType": "address", "name": "field_0", "type": "address" },629 { "internalType": "address", "name": "eth", "type": "address" },
630 { "internalType": "uint256", "name": "field_1", "type": "uint256" }630 { "internalType": "uint256", "name": "sub", "type": "uint256" }
631 ],631 ],
632 "internalType": "struct Tuple6",632 "internalType": "struct EthCrossAccount",
633 "name": "sponsor",633 "name": "sponsor",
634 "type": "tuple"634 "type": "tuple"
635 }635 }
643 "inputs": [643 "inputs": [
644 {644 {
645 "components": [645 "components": [
646 { "internalType": "address", "name": "field_0", "type": "address" },646 { "internalType": "address", "name": "eth", "type": "address" },
647 { "internalType": "uint256", "name": "field_1", "type": "uint256" }647 { "internalType": "uint256", "name": "sub", "type": "uint256" }
648 ],648 ],
649 "internalType": "struct Tuple6",649 "internalType": "struct EthCrossAccount",
650 "name": "newOwner",650 "name": "newOwner",
651 "type": "tuple"651 "type": "tuple"
652 }652 }
664 { "internalType": "string", "name": "field_0", "type": "string" },664 { "internalType": "string", "name": "field_0", "type": "string" },
665 { "internalType": "bytes", "name": "field_1", "type": "bytes" }665 { "internalType": "bytes", "name": "field_1", "type": "bytes" }
666 ],666 ],
667 "internalType": "struct Tuple19[]",667 "internalType": "struct Tuple20[]",
668 "name": "properties",668 "name": "properties",
669 "type": "tuple[]"669 "type": "tuple[]"
670 }670 }
782 "inputs": [782 "inputs": [
783 {783 {
784 "components": [784 "components": [
785 { "internalType": "address", "name": "field_0", "type": "address" },785 { "internalType": "address", "name": "eth", "type": "address" },
786 { "internalType": "uint256", "name": "field_1", "type": "uint256" }786 { "internalType": "uint256", "name": "sub", "type": "uint256" }
787 ],787 ],
788 "internalType": "struct Tuple6",788 "internalType": "struct EthCrossAccount",
789 "name": "from",789 "name": "from",
790 "type": "tuple"790 "type": "tuple"
791 },791 },
792 {792 {
793 "components": [793 "components": [
794 { "internalType": "address", "name": "field_0", "type": "address" },794 { "internalType": "address", "name": "eth", "type": "address" },
795 { "internalType": "uint256", "name": "field_1", "type": "uint256" }795 { "internalType": "uint256", "name": "sub", "type": "uint256" }
796 ],796 ],
797 "internalType": "struct Tuple6",797 "internalType": "struct EthCrossAccount",
798 "name": "to",798 "name": "to",
799 "type": "tuple"799 "type": "tuple"
800 },800 },
modifiedtests/src/eth/scheduling.test.tsdiffbeforeafterboth
27 });27 });
2828
29 itEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {29 itEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {
30 const alice = await privateKey('//Alice');30 const donor = await privateKey({filename: __filename});
31 const [alice] = await helper.arrange.createAccounts([1000n], donor);
3132
32 const scheduledId = await helper.arrange.makeScheduledId();33 const scheduledId = await helper.arrange.makeScheduledId();
3334
modifiedtests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth
14 args: { [key: string]: string }14 args: { [key: string]: string }
15};15};
16export interface TEthCrossAccount {16export interface TEthCrossAccount {
17 readonly 0: string,17 readonly eth: string,
18 readonly 1: string | Uint8Array,18 readonly sub: string | Uint8Array,
19 readonly field_0: string,
20 readonly field_1: string | Uint8Array,
21}19}
2220
23export type EthProperty = string[];21export type EthProperty = string[];
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
364export class EthCrossAccountGroup extends EthGroupBase {364export class EthCrossAccountGroup extends EthGroupBase {
365 fromAddress(address: TEthereumAccount): TEthCrossAccount {365 fromAddress(address: TEthereumAccount): TEthCrossAccount {
366 return {366 return {
367 0: address,367 eth: address,
368 1: '0',368 sub: '0',
369 field_0: address,
370 field_1: '0',
371 };369 };
372 }370 }
373371
374 fromKeyringPair(keyring: IKeyringPair): TEthCrossAccount {372 fromKeyringPair(keyring: IKeyringPair): TEthCrossAccount {
375 return {373 return {
376 0: '0x0000000000000000000000000000000000000000',374 eth: '0x0000000000000000000000000000000000000000',
377 1: keyring.addressRaw,375 sub: keyring.addressRaw,
378 field_0: '0x0000000000000000000000000000000000000000',
379 field_1: keyring.addressRaw,
380 };376 };
381 }377 }
382}378}
387383
388 eth: EthGroup;384 eth: EthGroup;
389 ethAddress: EthAddressGroup;385 ethAddress: EthAddressGroup;
386 ethCrossAccount: EthCrossAccountGroup;
390 ethNativeContract: NativeContractGroup;387 ethNativeContract: NativeContractGroup;
391 ethContract: ContractGroup;388 ethContract: ContractGroup;
392 ethCrossAccount: EthCrossAccountGroup;
393 ethProperty: EthPropertyGroup;389 ethProperty: EthPropertyGroup;
394390
395 constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {391 constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {
addedtests/src/inflation.seqtest.tsdiffbeforeafterboth

no changes

deletedtests/src/inflation.test.tsdiffbeforeafterboth

no changes

addedtests/src/scheduler.seqtest.tsdiffbeforeafterboth

no changes

deletedtests/src/scheduler.test.tsdiffbeforeafterboth

no changes

modifiedtests/src/util/playgrounds/types.tsdiffbeforeafterboth
73export interface IEthCrossAccountId {73export interface IEthCrossAccountId {
74 0: TEthereumAccount;74 0: TEthereumAccount;
75 1: TSubstrateAccount;75 1: TSubstrateAccount;
76 field_0: TEthereumAccount;76 eth: TEthereumAccount;
77 field_1: TSubstrateAccount;77 sub: TSubstrateAccount;
78}78}
7979
80export interface ICollectionLimits {80export interface ICollectionLimits {
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
422 return promise;422 return promise;
423 }423 }
424424
425 async forParachainBlockNumber(blockNumber: bigint, timeout?: number) {425 async forParachainBlockNumber(blockNumber: bigint | number, timeout?: number) {
426 timeout = timeout ?? 300_000;426 timeout = timeout ?? 30 * 60 * 1000;
427 // eslint-disable-next-line no-async-promise-executor427 // eslint-disable-next-line no-async-promise-executor
428 const promise = new Promise<void>(async (resolve) => {428 const promise = new Promise<void>(async (resolve) => {
429 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads((data: any) => {429 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads((data: any) => {
437 return promise;437 return promise;
438 }438 }
439 439
440 async forRelayBlockNumber(blockNumber: bigint, timeout?: number) {440 async forRelayBlockNumber(blockNumber: bigint | number, timeout?: number) {
441 timeout = timeout ?? 300_000;441 timeout = timeout ?? 30 * 60 * 1000;
442 // eslint-disable-next-line no-async-promise-executor442 // eslint-disable-next-line no-async-promise-executor
443 const promise = new Promise<void>(async (resolve) => {443 const promise = new Promise<void>(async (resolve) => {
444 const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData((data: any) => {444 const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData((data: any) => {
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
77
8import {ApiPromise, WsProvider, Keyring} from '@polkadot/api';8import {ApiPromise, WsProvider, Keyring} from '@polkadot/api';
9import {ApiInterfaceEvents, SignerOptions} from '@polkadot/api/types';9import {ApiInterfaceEvents, SignerOptions} from '@polkadot/api/types';
10import {encodeAddress, decodeAddress, keccakAsHex, evmToAddress, addressToEvm} from '@polkadot/util-crypto';10import {encodeAddress, decodeAddress, keccakAsHex, evmToAddress, addressToEvm, base58Encode, blake2AsU8a} from '@polkadot/util-crypto';
11import {IKeyringPair} from '@polkadot/types/types';11import {IKeyringPair} from '@polkadot/types/types';
12import {hexToU8a} from '@polkadot/util/hex';
13import {u8aConcat} from '@polkadot/util/u8a';
12import {14import {
13 IApiListeners,15 IApiListeners,
14 IBlock,16 IBlock,
38 AcalaAssetMetadata,40 AcalaAssetMetadata,
39 MoonbeamAssetInfo,41 MoonbeamAssetInfo,
40 DemocracyStandardAccountVote,42 DemocracyStandardAccountVote,
43 IEthCrossAccountId,
41} from './types';44} from './types';
42import {RuntimeDispatchInfo} from '@polkadot/types/interfaces';45import {RuntimeDispatchInfo} from '@polkadot/types/interfaces';
4346
2368 return CrossAccountId.translateSubToEth(subAddress);2371 return CrossAccountId.translateSubToEth(subAddress);
2369 }2372 }
2373
2374 /**
2375 * Encode key to substrate address
2376 * @param key key for encoding address
2377 * @param ss58Format prefix for encoding to the address of the corresponding network
2378 * @returns encoded substrate address
2379 */
2380 encodeSubstrateAddress (key: Uint8Array | string | bigint, ss58Format = 42): string {
2381 const u8a :Uint8Array = typeof key === 'string'
2382 ? hexToU8a(key)
2383 : typeof key === 'bigint'
2384 ? hexToU8a(key.toString(16))
2385 : key;
2386
2387 if (ss58Format < 0 || ss58Format > 16383 || [46, 47].includes(ss58Format)) {
2388 throw new Error(`ss58Format is not valid, received ${typeof ss58Format} "${ss58Format}"`);
2389 }
2390
2391 const allowedDecodedLengths = [1, 2, 4, 8, 32, 33];
2392 if (!allowedDecodedLengths.includes(u8a.length)) {
2393 throw new Error(`key length is not valid, received ${u8a.length}, valid values are ${allowedDecodedLengths.join(', ')}`);
2394 }
2395
2396 const u8aPrefix = ss58Format < 64
2397 ? new Uint8Array([ss58Format])
2398 : new Uint8Array([
2399 ((ss58Format & 0xfc) >> 2) | 0x40,
2400 (ss58Format >> 8) | ((ss58Format & 0x03) << 6),
2401 ]);
2402
2403 const input = u8aConcat(u8aPrefix, u8a);
2404
2405 return base58Encode(u8aConcat(
2406 input,
2407 blake2AsU8a(input).subarray(0, [32, 33].includes(u8a.length) ? 2 : 1),
2408 ));
2409 }
2410
2411 /**
2412 * Restore substrate address from bigint representation
2413 * @param number decimal representation of substrate address
2414 * @returns substrate address
2415 */
2416 restoreCrossAccountFromBigInt(number: bigint): TSubstrateAccount {
2417 if (this.helper.api === null) {
2418 throw 'Not connected';
2419 }
2420 const res = this.helper.api.registry.createType('AccountId', '0x' + number.toString(16).padStart(64, '0')).toJSON();
2421 if (res === undefined || res === null) {
2422 throw 'Restore address error';
2423 }
2424 return res.toString();
2425 }
2426
2427 /**
2428 * Convert etherium cross account id to substrate cross account id
2429 * @param ethCrossAccount etherium cross account
2430 * @returns substrate cross account id
2431 */
2432 convertCrossAccountFromEthCrossAcoount(ethCrossAccount: IEthCrossAccountId): ICrossAccountId {
2433 if (ethCrossAccount.sub === '0') {
2434 return {Ethereum: ethCrossAccount.eth.toLocaleLowerCase()};
2435 }
2436
2437 const ss58 = this.restoreCrossAccountFromBigInt(BigInt(ethCrossAccount.sub));
2438 return {Substrate: ss58};
2439 }
23702440
2371 paraSiblingSovereignAccount(paraid: number) {2441 paraSiblingSovereignAccount(paraid: number) {
2372 // We are getting a *sibling* parachain sovereign account,2442 // We are getting a *sibling* parachain sovereign account,