git.delta.rocks / unique-network / refs/commits / 9f4fc065e116

difftreelog

Merge pull request #871 from UniqueNetwork/feature/move_TokenChanged_event

Yaroslav Bolyukin2023-02-13parents: #3563d09 #40d2262.patch.diff
in: master

21 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2445,8 +2445,8 @@
 
 [[package]]
 name = "evm-coder"
-version = "0.3.0"
-source = "git+https://github.com/uniquenetwork/evm-coder?tag=v0.3.0#c4bfdf39d84fbe74c6178417177f2a7f81d92bdd"
+version = "0.3.1"
+source = "git+https://github.com/uniquenetwork/evm-coder?tag=v0.3.1#21e61c627f71337d6b8a03899fe8de14bfbf67aa"
 dependencies = [
  "ethereum",
  "evm-coder-procedural",
@@ -2457,8 +2457,8 @@
 
 [[package]]
 name = "evm-coder-procedural"
-version = "0.3.0"
-source = "git+https://github.com/uniquenetwork/evm-coder?tag=v0.3.0#c4bfdf39d84fbe74c6178417177f2a7f81d92bdd"
+version = "0.3.1"
+source = "git+https://github.com/uniquenetwork/evm-coder?tag=v0.3.1#21e61c627f71337d6b8a03899fe8de14bfbf67aa"
 dependencies = [
  "Inflector",
  "hex",
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,16 +19,9 @@
 
 [workspace.dependencies]
 # Unique
-evm-coder = { git = "https://github.com/uniquenetwork/evm-coder", tag = "v0.3.0", default-features = false }
-struct-versioning = { path = "crates/struct-versioning" }
-precompile-utils-macro = { path = "runtime/common/ethereum/precompiles/utils/macro" }
-up-common = { path = "primitives/common", default-features = false }
-up-data-structs = { path = "primitives/data-structs", default-features = false }
-up-pov-estimate-rpc = { path = "primitives/pov-estimate-rpc", default-features = false }
-up-rpc = { path = "primitives/rpc", default-features = false }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.37" }
-uc-rpc = { path =  "client/rpc" }
-unique-rpc = { path = "node/rpc" }
+app-promotion-rpc = { path = "primitives/app_promotion_rpc", default-features = false }
+evm-coder = { git = "https://github.com/uniquenetwork/evm-coder", tag = "v0.3.1", default-features = false }
+pallet-app-promotion = { path = "pallets/app-promotion", default-features = false }
 pallet-charge-transaction = { package = "pallet-template-transaction-payment", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.37" }
 pallet-collator-selection = { default-features = false, path = "pallets/collator-selection" }
 pallet-common = { default-features = false, path = "pallets/common" }
@@ -45,56 +38,59 @@
 pallet-nonfungible = { default-features = false, path = "pallets/nonfungible" }
 pallet-refungible = { default-features = false, path = "pallets/refungible" }
 pallet-structure = { default-features = false, path = "pallets/structure" }
+pallet-test-utils = { default-features = false, path = "test-pallets/utils" }
 pallet-unique = { path = "pallets/unique", default-features = false }
 pallet-unique-scheduler-v2 = { path = "pallets/scheduler-v2", default-features = false }
-pallet-test-utils = { default-features = false, path = "test-pallets/utils" }
-pallet-app-promotion = { path = "pallets/app-promotion", default-features = false }
-app-promotion-rpc = { path = "primitives/app_promotion_rpc", default-features = false }
+precompile-utils-macro = { path = "runtime/common/ethereum/precompiles/utils/macro" }
+struct-versioning = { path = "crates/struct-versioning" }
+uc-rpc = { path = "client/rpc" }
+unique-rpc = { path = "node/rpc" }
+up-common = { path = "primitives/common", default-features = false }
+up-data-structs = { path = "primitives/data-structs", default-features = false }
+up-pov-estimate-rpc = { path = "primitives/pov-estimate-rpc", default-features = false }
+up-rpc = { path = "primitives/rpc", default-features = false }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.37" }
 
 # Unique: Runtimes
+opal-runtime = { path = "runtime/opal" }
+quartz-runtime = { path = "runtime/quartz" }
 unique-runtime = { path = "runtime/unique" }
-quartz-runtime = { path = "runtime/quartz" }
-opal-runtime = { path = "runtime/opal" }
 
 # Frontier (Unique patches over the Parity version)
+fc-consensus = { git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
+fc-db = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
+fc-mapping-sync = { git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
+fc-rpc = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
+fc-rpc-core = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
 fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
 fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
 fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
 fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
-fc-db = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
-fc-rpc = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
-fc-rpc-core = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
 fp-storage = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
-fc-consensus = { git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
-fc-mapping-sync = { git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
+pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
 pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
 pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
-pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
 pallet-evm-precompile-simple = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.37" }
 
 # Parity
 codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = "3.2.2" }
-scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
-polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" }
-polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" }
-polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" }
 cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
 cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
 cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
 cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
 cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
-cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
-cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
-cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
-cumulus-relay-chain-minimal-node = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
 cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false }
 cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false }
 cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false }
 cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false }
 cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false }
 cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false }
+cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
 cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false }
 cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false }
+cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
+cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
+cumulus-relay-chain-minimal-node = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
 frame-executive = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
@@ -107,67 +103,71 @@
 pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 pallet-transaction-payment = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 pallet-treasury = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37", default-features = false }
-pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 parachain-info = { default-features = false, git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" }
+polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" }
 polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37", default-features = false }
+polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" }
+polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" }
+sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
 sp-api = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-arithmetic = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-block-builder = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-consensus-aura = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-inherents = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-offchain = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-session = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sp-transaction-pool = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sp-version = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sp-transaction-pool = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 sp-trie = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+sp-version = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
+substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37", default-features = false }
 xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37", default-features = false }
 xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37", default-features = false }
 
 # Parity: Build utils
+substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 
 # Parity: Benchmarking
+frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 frame-system-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 
 # Parity: Try Runtime
+frame-try-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
-frame-try-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
 
 # ORML
 orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.37", default-features = false }
@@ -176,15 +176,15 @@
 orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.37", default-features = false }
 
 # Other
-smallvec = "1.6.1"
 derivative = { version = "2.2.0", features = ["use_core"] }
-serde = { default-features = false, features = ['derive'], version = "1.0.136" }
-log = { version = "0.4.16", default-features = false }
-num_enum = { version = "0.5.3", default-features = false }
+ethereum = { version = "0.14.0", default-features = false }
+evm-core = { default-features = false, version = "0.37.0" }
 hex-literal = "0.3.4"
 impl-trait-for-tuples = "0.2.2"
+jsonrpsee = { version = "0.16.2", features = ["macros", "server"] }
+log = { version = "0.4.16", default-features = false }
 logtest = "2.0.0"
-ethereum = { version = "0.14.0", default-features = false }
-evm-core = { default-features = false, version = "0.37.0" }
+num_enum = { version = "0.5.3", default-features = false }
 primitive-types = { version = "0.12.1", default-features = false }
-jsonrpsee = { version = "0.16.2", features = ["macros", "server"] }
+serde = { default-features = false, features = ['derive'], version = "1.0.136" }
+smallvec = "1.6.1"
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
before · pallets/common/src/erc.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! This module contains the implementation of pallet methods for evm.1819pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};20use pallet_evm_coder_substrate::{21	abi::AbiType,22	solidity_interface, ToLog,23	types::*,24	execution::{Result, Error, PreDispatch},25	frontier_contract,26};27use pallet_evm_coder_substrate::dispatch_to_evm;28use sp_std::{vec, vec::Vec};29use sp_core::U256;30use up_data_structs::{31	CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property, SponsoringRateLimit,32	SponsorshipState,33};3435use crate::{36	Pallet, CollectionHandle, Config, CollectionProperties, eth, SelfWeightOf, weights::WeightInfo,37};3839frontier_contract! {40	macro_rules! CollectionHandle_result {...}41	impl<T: Config> Contract for CollectionHandle<T> {...}42}4344/// Events for ethereum collection helper.45#[derive(ToLog)]46pub enum CollectionHelpersEvents {47	/// The collection has been created.48	CollectionCreated {49		/// Collection owner.50		#[indexed]51		owner: Address,5253		/// Collection ID.54		#[indexed]55		collection_id: Address,56	},57	/// The collection has been destroyed.58	CollectionDestroyed {59		/// Collection ID.60		#[indexed]61		collection_id: Address,62	},63	/// The collection has been changed.64	CollectionChanged {65		/// Collection ID.66		#[indexed]67		collection_id: Address,68	},6970	/// The token has been changed.71	TokenChanged {72		/// Collection ID.73		#[indexed]74		collection_id: Address,75		/// Token ID.76		token_id: U256,77	},78}7980/// Does not always represent a full collection, for RFT it is either81/// collection (Implementing ERC721), or specific collection token (Implementing ERC20).82pub trait CommonEvmHandler {83	/// Raw compiled binary code of the contract stub84	const CODE: &'static [u8];8586	/// Call precompiled handle.87	fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult>;88}8990/// @title A contract that allows you to work with collections.91#[solidity_interface(name = Collection, enum(derive(PreDispatch)), enum_attr(weight))]92impl<T: Config> CollectionHandle<T>93where94	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,95{96	/// Set collection property.97	///98	/// @param key Property key.99	/// @param value Propery value.100	#[solidity(hide)]101	#[weight(<SelfWeightOf<T>>::set_collection_properties(1))]102	fn set_collection_property(&mut self, caller: Caller, key: String, value: Bytes) -> Result<()> {103		let caller = T::CrossAccountId::from_eth(caller);104		let key = <Vec<u8>>::from(key)105			.try_into()106			.map_err(|_| "key too large")?;107		let value = value.0.try_into().map_err(|_| "value too large")?;108109		<Pallet<T>>::set_collection_property(self, &caller, Property { key, value })110			.map_err(dispatch_to_evm::<T>)111	}112113	/// Set collection properties.114	///115	/// @param properties Vector of properties key/value pair.116	#[weight(<SelfWeightOf<T>>::set_collection_properties(properties.len() as u32))]117	fn set_collection_properties(118		&mut self,119		caller: Caller,120		properties: Vec<eth::Property>,121	) -> Result<()> {122		let caller = T::CrossAccountId::from_eth(caller);123124		let properties = properties125			.into_iter()126			.map(eth::Property::try_into)127			.collect::<Result<Vec<_>>>()?;128129		<Pallet<T>>::set_collection_properties(self, &caller, properties.into_iter())130			.map_err(dispatch_to_evm::<T>)131	}132133	/// Delete collection property.134	///135	/// @param key Property key.136	#[solidity(hide)]137	#[weight(<SelfWeightOf<T>>::delete_collection_properties(1))]138	fn delete_collection_property(&mut self, caller: Caller, key: String) -> Result<()> {139		let caller = T::CrossAccountId::from_eth(caller);140		let key = <Vec<u8>>::from(key)141			.try_into()142			.map_err(|_| "key too large")?;143144		<Pallet<T>>::delete_collection_property(self, &caller, key).map_err(dispatch_to_evm::<T>)145	}146147	/// Delete collection properties.148	///149	/// @param keys Properties keys.150	#[weight(<SelfWeightOf<T>>::delete_collection_properties(keys.len() as u32))]151	fn delete_collection_properties(&mut self, caller: Caller, keys: Vec<String>) -> Result<()> {152		let caller = T::CrossAccountId::from_eth(caller);153		let keys = keys154			.into_iter()155			.map(|key| {156				<Vec<u8>>::from(key)157					.try_into()158					.map_err(|_| Error::Revert("key too large".into()))159			})160			.collect::<Result<Vec<_>>>()?;161162		<Pallet<T>>::delete_collection_properties(self, &caller, keys.into_iter())163			.map_err(dispatch_to_evm::<T>)164	}165166	/// Get collection property.167	///168	/// @dev Throws error if key not found.169	///170	/// @param key Property key.171	/// @return bytes The property corresponding to the key.172	fn collection_property(&self, key: String) -> Result<Bytes> {173		let key = <Vec<u8>>::from(key)174			.try_into()175			.map_err(|_| "key too large")?;176177		let props = CollectionProperties::<T>::get(self.id);178		let prop = props.get(&key).ok_or("key not found")?;179180		Ok(Bytes(prop.to_vec()))181	}182183	/// Get collection properties.184	///185	/// @param keys Properties keys. Empty keys for all propertyes.186	/// @return Vector of properties key/value pairs.187	fn collection_properties(&self, keys: Vec<String>) -> Result<Vec<eth::Property>> {188		let keys = keys189			.into_iter()190			.map(|key| {191				<Vec<u8>>::from(key)192					.try_into()193					.map_err(|_| Error::Revert("key too large".into()))194			})195			.collect::<Result<Vec<_>>>()?;196197		let properties = Pallet::<T>::filter_collection_properties(198			self.id,199			if keys.is_empty() { None } else { Some(keys) },200		)201		.map_err(dispatch_to_evm::<T>)?;202203		let properties = properties204			.into_iter()205			.map(Property::try_into)206			.collect::<Result<Vec<_>>>()?;207		Ok(properties)208	}209210	/// Set the sponsor of the collection.211	///212	/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.213	///214	/// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.215	#[solidity(hide)]216	fn set_collection_sponsor(&mut self, caller: Caller, sponsor: Address) -> Result<()> {217		self.consume_store_reads_and_writes(1, 1)?;218219		let caller = T::CrossAccountId::from_eth(caller);220221		let sponsor = T::CrossAccountId::from_eth(sponsor);222		self.set_sponsor(&caller, sponsor.as_sub().clone())223			.map_err(dispatch_to_evm::<T>)224	}225226	/// Set the sponsor of the collection.227	///228	/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.229	///230	/// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.231	fn set_collection_sponsor_cross(232		&mut self,233		caller: Caller,234		sponsor: eth::CrossAddress,235	) -> Result<()> {236		self.consume_store_reads_and_writes(1, 1)?;237238		let caller = T::CrossAccountId::from_eth(caller);239240		let sponsor = sponsor.into_sub_cross_account::<T>()?;241		self.set_sponsor(&caller, sponsor.as_sub().clone())242			.map_err(dispatch_to_evm::<T>)243	}244245	/// Whether there is a pending sponsor.246	fn has_collection_pending_sponsor(&self) -> Result<bool> {247		Ok(matches!(248			self.collection.sponsorship,249			SponsorshipState::Unconfirmed(_)250		))251	}252253	/// Collection sponsorship confirmation.254	///255	/// @dev After setting the sponsor for the collection, it must be confirmed with this function.256	fn confirm_collection_sponsorship(&mut self, caller: Caller) -> Result<()> {257		self.consume_store_writes(1)?;258259		let caller = T::CrossAccountId::from_eth(caller);260		self.confirm_sponsorship(caller.as_sub())261			.map_err(dispatch_to_evm::<T>)262	}263264	/// Remove collection sponsor.265	fn remove_collection_sponsor(&mut self, caller: Caller) -> Result<()> {266		self.consume_store_reads_and_writes(1, 1)?;267		let caller = T::CrossAccountId::from_eth(caller);268		self.remove_sponsor(&caller).map_err(dispatch_to_evm::<T>)269	}270271	/// Get current sponsor.272	///273	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.274	fn collection_sponsor(&self) -> Result<eth::CrossAddress> {275		let sponsor = match self.collection.sponsorship.sponsor() {276			Some(sponsor) => sponsor,277			None => return Ok(Default::default()),278		};279280		Ok(eth::CrossAddress::from_sub::<T>(sponsor))281	}282283	/// Get current collection limits.284	///285	/// @return Array of collection limits286	fn collection_limits(&self) -> Result<Vec<eth::CollectionLimit>> {287		let limits = &self.collection.limits;288289		Ok(vec![290			eth::CollectionLimit::new(291				eth::CollectionLimitField::AccountTokenOwnership,292				limits.account_token_ownership_limit,293			),294			eth::CollectionLimit::new(295				eth::CollectionLimitField::SponsoredDataSize,296				limits.sponsored_data_size,297			),298			limits299				.sponsored_data_rate_limit300				.and_then(|limit| {301					if let SponsoringRateLimit::Blocks(blocks) = limit {302						Some(eth::CollectionLimit::new(303							eth::CollectionLimitField::SponsoredDataRateLimit,304							Some(blocks),305						))306					} else {307						None308					}309				})310				.unwrap_or_else(|| {311					eth::CollectionLimit::new(312						eth::CollectionLimitField::SponsoredDataRateLimit,313						Default::default(),314					)315				}),316			eth::CollectionLimit::new(eth::CollectionLimitField::TokenLimit, limits.token_limit),317			eth::CollectionLimit::new(318				eth::CollectionLimitField::SponsorTransferTimeout,319				limits.sponsor_transfer_timeout,320			),321			eth::CollectionLimit::new(322				eth::CollectionLimitField::SponsorApproveTimeout,323				limits.sponsor_approve_timeout,324			),325			eth::CollectionLimit::new(326				eth::CollectionLimitField::OwnerCanTransfer,327				limits.owner_can_transfer.map(u32::from),328			),329			eth::CollectionLimit::new(330				eth::CollectionLimitField::OwnerCanDestroy,331				limits.owner_can_destroy.map(u32::from),332			),333			eth::CollectionLimit::new(334				eth::CollectionLimitField::TransferEnabled,335				limits.transfers_enabled.map(u32::from),336			),337		])338	}339340	/// Set limits for the collection.341	/// @dev Throws error if limit not found.342	/// @param limit Some limit.343	#[solidity(rename_selector = "setCollectionLimit")]344	fn set_collection_limit(&mut self, caller: Caller, limit: eth::CollectionLimit) -> Result<()> {345		self.consume_store_reads_and_writes(1, 1)?;346347		if !limit.has_value() {348			return Err(Error::Revert("user can't disable limits".into()));349		}350351		let caller = T::CrossAccountId::from_eth(caller);352		<Pallet<T>>::update_limits(&caller, self, limit.try_into()?).map_err(dispatch_to_evm::<T>)353	}354355	/// Get contract address.356	fn contract_address(&self) -> Result<Address> {357		Ok(crate::eth::collection_id_to_address(self.id))358	}359360	/// Add collection admin.361	/// @param newAdmin Cross account administrator address.362	fn add_collection_admin_cross(363		&mut self,364		caller: Caller,365		new_admin: eth::CrossAddress,366	) -> Result<()> {367		self.consume_store_reads_and_writes(2, 2)?;368369		let caller = T::CrossAccountId::from_eth(caller);370		let new_admin = new_admin.into_sub_cross_account::<T>()?;371		<Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;372		Ok(())373	}374375	/// Remove collection admin.376	/// @param admin Cross account administrator address.377	fn remove_collection_admin_cross(378		&mut self,379		caller: Caller,380		admin: eth::CrossAddress,381	) -> Result<()> {382		self.consume_store_reads_and_writes(2, 2)?;383384		let caller = T::CrossAccountId::from_eth(caller);385		let admin = admin.into_sub_cross_account::<T>()?;386		<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;387		Ok(())388	}389390	/// Add collection admin.391	/// @param newAdmin Address of the added administrator.392	#[solidity(hide)]393	fn add_collection_admin(&mut self, caller: Caller, new_admin: Address) -> Result<()> {394		self.consume_store_reads_and_writes(2, 2)?;395396		let caller = T::CrossAccountId::from_eth(caller);397		let new_admin = T::CrossAccountId::from_eth(new_admin);398		<Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;399		Ok(())400	}401402	/// Remove collection admin.403	///404	/// @param admin Address of the removed administrator.405	#[solidity(hide)]406	fn remove_collection_admin(&mut self, caller: Caller, admin: Address) -> Result<()> {407		self.consume_store_reads_and_writes(2, 2)?;408409		let caller = T::CrossAccountId::from_eth(caller);410		let admin = T::CrossAccountId::from_eth(admin);411		<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;412		Ok(())413	}414415	/// Toggle accessibility of collection nesting.416	///417	/// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'418	#[solidity(rename_selector = "setCollectionNesting")]419	fn set_nesting_bool(&mut self, caller: Caller, enable: bool) -> Result<()> {420		self.consume_store_reads_and_writes(1, 1)?;421422		let caller = T::CrossAccountId::from_eth(caller);423424		let mut permissions = self.collection.permissions.clone();425		let mut nesting = permissions.nesting().clone();426		nesting.token_owner = enable;427		nesting.restricted = None;428		permissions.nesting = Some(nesting);429430		<Pallet<T>>::update_permissions(&caller, self, permissions).map_err(dispatch_to_evm::<T>)431	}432433	/// Toggle accessibility of collection nesting.434	///435	/// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'436	/// @param collections Addresses of collections that will be available for nesting.437	#[solidity(rename_selector = "setCollectionNesting")]438	fn set_nesting(439		&mut self,440		caller: Caller,441		enable: bool,442		collections: Vec<Address>,443	) -> Result<()> {444		self.consume_store_reads_and_writes(1, 1)?;445446		if collections.is_empty() {447			return Err("no addresses provided".into());448		}449		let caller = T::CrossAccountId::from_eth(caller);450451		let mut permissions = self.collection.permissions.clone();452		match enable {453			false => {454				let mut nesting = permissions.nesting().clone();455				nesting.token_owner = false;456				nesting.restricted = None;457				permissions.nesting = Some(nesting);458			}459			true => {460				let mut bv = OwnerRestrictedSet::new();461				for i in collections {462					bv.try_insert(crate::eth::map_eth_to_id(&i).ok_or_else(|| {463						Error::Revert("Can't convert address into collection id".into())464					})?)465					.map_err(|_| "too many collections")?;466				}467				let mut nesting = permissions.nesting().clone();468				nesting.token_owner = true;469				nesting.restricted = Some(bv);470				permissions.nesting = Some(nesting);471			}472		};473474		<Pallet<T>>::update_permissions(&caller, self, permissions).map_err(dispatch_to_evm::<T>)475	}476477	/// Returns nesting for a collection478	#[solidity(rename_selector = "collectionNestingRestrictedCollectionIds")]479	fn collection_nesting_restricted_ids(&self) -> Result<eth::CollectionNesting> {480		let nesting = self.collection.permissions.nesting();481482		Ok(eth::CollectionNesting::new(483			nesting.token_owner,484			nesting485				.restricted486				.clone()487				.map(|b| b.0.into_inner().iter().map(|id| id.0.into()).collect())488				.unwrap_or_default(),489		))490	}491492	/// Returns permissions for a collection493	fn collection_nesting_permissions(&self) -> Result<Vec<eth::CollectionNestingPermission>> {494		let nesting = self.collection.permissions.nesting();495		Ok(vec![496			eth::CollectionNestingPermission::new(497				eth::CollectionPermissionField::CollectionAdmin,498				nesting.collection_admin,499			),500			eth::CollectionNestingPermission::new(501				eth::CollectionPermissionField::TokenOwner,502				nesting.token_owner,503			),504		])505	}506	/// Set the collection access method.507	/// @param mode Access mode508	fn set_collection_access(&mut self, caller: Caller, mode: eth::AccessMode) -> Result<()> {509		self.consume_store_reads_and_writes(1, 1)?;510511		let caller = T::CrossAccountId::from_eth(caller);512		let permissions = CollectionPermissions {513			access: Some(mode.into()),514			..Default::default()515		};516		<Pallet<T>>::update_permissions(&caller, self, permissions).map_err(dispatch_to_evm::<T>)517	}518519	/// Checks that user allowed to operate with collection.520	///521	/// @param user User address to check.522	fn allowlisted_cross(&self, user: eth::CrossAddress) -> Result<bool> {523		let user = user.into_sub_cross_account::<T>()?;524		Ok(Pallet::<T>::allowed(self.id, user))525	}526527	/// Add the user to the allowed list.528	///529	/// @param user Address of a trusted user.530	#[solidity(hide)]531	fn add_to_collection_allow_list(&mut self, caller: Caller, user: Address) -> Result<()> {532		self.consume_store_writes(1)?;533534		let caller = T::CrossAccountId::from_eth(caller);535		let user = T::CrossAccountId::from_eth(user);536		<Pallet<T>>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;537		Ok(())538	}539540	/// Add user to allowed list.541	///542	/// @param user User cross account address.543	fn add_to_collection_allow_list_cross(544		&mut self,545		caller: Caller,546		user: eth::CrossAddress,547	) -> Result<()> {548		self.consume_store_writes(1)?;549550		let caller = T::CrossAccountId::from_eth(caller);551		let user = user.into_sub_cross_account::<T>()?;552		Pallet::<T>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;553		Ok(())554	}555556	/// Remove the user from the allowed list.557	///558	/// @param user Address of a removed user.559	#[solidity(hide)]560	fn remove_from_collection_allow_list(&mut self, caller: Caller, user: Address) -> Result<()> {561		self.consume_store_writes(1)?;562563		let caller = T::CrossAccountId::from_eth(caller);564		let user = T::CrossAccountId::from_eth(user);565		<Pallet<T>>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;566		Ok(())567	}568569	/// Remove user from allowed list.570	///571	/// @param user User cross account address.572	fn remove_from_collection_allow_list_cross(573		&mut self,574		caller: Caller,575		user: eth::CrossAddress,576	) -> Result<()> {577		self.consume_store_writes(1)?;578579		let caller = T::CrossAccountId::from_eth(caller);580		let user = user.into_sub_cross_account::<T>()?;581		Pallet::<T>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;582		Ok(())583	}584585	/// Switch permission for minting.586	///587	/// @param mode Enable if "true".588	fn set_collection_mint_mode(&mut self, caller: Caller, mode: bool) -> Result<()> {589		self.consume_store_reads_and_writes(1, 1)?;590591		let caller = T::CrossAccountId::from_eth(caller);592		let permissions = CollectionPermissions {593			mint_mode: Some(mode),594			..Default::default()595		};596		<Pallet<T>>::update_permissions(&caller, self, permissions).map_err(dispatch_to_evm::<T>)597	}598599	/// Check that account is the owner or admin of the collection600	///601	/// @param user account to verify602	/// @return "true" if account is the owner or admin603	#[solidity(hide, rename_selector = "isOwnerOrAdmin")]604	fn is_owner_or_admin_eth(&self, user: Address) -> Result<bool> {605		let user = T::CrossAccountId::from_eth(user);606		Ok(self.is_owner_or_admin(&user))607	}608609	/// Check that account is the owner or admin of the collection610	///611	/// @param user User cross account to verify612	/// @return "true" if account is the owner or admin613	fn is_owner_or_admin_cross(&self, user: eth::CrossAddress) -> Result<bool> {614		let user = user.into_sub_cross_account::<T>()?;615		Ok(self.is_owner_or_admin(&user))616	}617618	/// Returns collection type619	///620	/// @return `Fungible` or `NFT` or `ReFungible`621	fn unique_collection_type(&self) -> Result<String> {622		let mode = match self.collection.mode {623			CollectionMode::Fungible(_) => "Fungible",624			CollectionMode::NFT => "NFT",625			CollectionMode::ReFungible => "ReFungible",626		};627		Ok(mode.into())628	}629630	/// Get collection owner.631	///632	/// @return Tuble with sponsor address and his substrate mirror.633	/// If address is canonical then substrate mirror is zero and vice versa.634	fn collection_owner(&self) -> Result<eth::CrossAddress> {635		Ok(eth::CrossAddress::from_sub_cross_account::<T>(636			&T::CrossAccountId::from_sub(self.owner.clone()),637		))638	}639640	/// Changes collection owner to another account641	///642	/// @dev Owner can be changed only by current owner643	/// @param newOwner new owner account644	#[solidity(hide, rename_selector = "changeCollectionOwner")]645	fn set_owner(&mut self, caller: Caller, new_owner: Address) -> Result<()> {646		self.consume_store_writes(1)?;647648		let caller = T::CrossAccountId::from_eth(caller);649		let new_owner = T::CrossAccountId::from_eth(new_owner);650		self.change_owner(caller, new_owner)651			.map_err(dispatch_to_evm::<T>)652	}653654	/// Get collection administrators655	///656	/// @return Vector of tuples with admins address and his substrate mirror.657	/// If address is canonical then substrate mirror is zero and vice versa.658	fn collection_admins(&self) -> Result<Vec<eth::CrossAddress>> {659		let result = crate::IsAdmin::<T>::iter_prefix((self.id,))660			.map(|(admin, _)| eth::CrossAddress::from_sub_cross_account::<T>(&admin))661			.collect();662		Ok(result)663	}664665	/// Changes collection owner to another account666	///667	/// @dev Owner can be changed only by current owner668	/// @param newOwner new owner cross account669	fn change_collection_owner_cross(670		&mut self,671		caller: Caller,672		new_owner: eth::CrossAddress,673	) -> Result<()> {674		self.consume_store_writes(1)?;675676		let caller = T::CrossAccountId::from_eth(caller);677		let new_owner = new_owner.into_sub_cross_account::<T>()?;678		self.change_owner(caller, new_owner)679			.map_err(dispatch_to_evm::<T>)680	}681}682683/// Contains static property keys and values.684pub mod static_property {685	use pallet_evm_coder_substrate::{686		execution::{Result, Error},687	};688	use alloc::format;689690	const EXPECT_CONVERT_ERROR: &str = "length < limit";691692	/// Keys.693	pub mod key {694		use super::*;695696		/// Key "baseURI".697		pub fn base_uri() -> up_data_structs::PropertyKey {698			property_key_from_bytes(b"baseURI").expect(EXPECT_CONVERT_ERROR)699		}700701		/// Key "url".702		pub fn url() -> up_data_structs::PropertyKey {703			property_key_from_bytes(b"URI").expect(EXPECT_CONVERT_ERROR)704		}705706		/// Key "suffix".707		pub fn suffix() -> up_data_structs::PropertyKey {708			property_key_from_bytes(b"URISuffix").expect(EXPECT_CONVERT_ERROR)709		}710711		/// Key "parentNft".712		pub fn parent_nft() -> up_data_structs::PropertyKey {713			property_key_from_bytes(b"parentNft").expect(EXPECT_CONVERT_ERROR)714		}715	}716717	/// Convert `byte` to [`PropertyKey`].718	pub fn property_key_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyKey> {719		bytes.to_vec().try_into().map_err(|_| {720			Error::Revert(format!(721				"Property key is too long. Max length is {}.",722				up_data_structs::PropertyKey::bound()723			))724		})725	}726727	/// Convert `bytes` to [`PropertyValue`].728	pub fn property_value_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyValue> {729		bytes.to_vec().try_into().map_err(|_| {730			Error::Revert(format!(731				"Property key is too long. Max length is {}.",732				up_data_structs::PropertyKey::bound()733			))734		})735	}736}
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -86,7 +86,6 @@
 use sp_core::H160;
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
 
-use crate::erc::CollectionHelpersEvents;
 #[cfg(feature = "runtime-benchmarks")]
 pub mod benchmarking;
 pub mod dispatch;
@@ -1250,6 +1249,7 @@
 		mut stored_properties: Properties,
 		is_token_owner: impl Fn() -> Result<bool, DispatchError>,
 		set_token_properties: impl FnOnce(Properties),
+		log: evm_coder::ethereum::Log,
 	) -> DispatchResult {
 		let is_collection_admin = collection.is_owner_or_admin(sender);
 		let permissions = Self::property_permissions(collection.id);
@@ -1304,13 +1304,7 @@
 				}
 			}
 
-			<PalletEvm<T>>::deposit_log(
-				CollectionHelpersEvents::TokenChanged {
-					collection_id: eth::collection_id_to_address(collection.id),
-					token_id: token_id.into(),
-				}
-				.to_log(T::ContractAddress::get()),
-			);
+			<PalletEvm<T>>::deposit_log(log.clone());
 		}
 
 		set_token_properties(stored_properties);
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -50,13 +50,24 @@
 	TokenProperties, SelfWeightOf, weights::WeightInfo,
 };
 
+/// Nft events.
+#[derive(ToLog)]
+pub enum ERC721TokenEvent {
+	/// The token has been changed.
+	TokenChanged {
+		/// Token ID.
+		#[indexed]
+		token_id: U256,
+	},
+}
+
 frontier_contract! {
 	macro_rules! NonfungibleHandle_result {...}
 	impl<T: Config> Contract for NonfungibleHandle<T> {...}
 }
 
 /// @title A contract that allows to set and delete token properties and change token property permissions.
-#[solidity_interface(name = TokenProperties, enum(derive(PreDispatch)), enum_attr(weight))]
+#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]
 impl<T: Config> NonfungibleHandle<T> {
 	/// @notice Set permissions for token property.
 	/// @dev Throws error if `msg.sender` is not admin or owner of the collection.
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -112,7 +112,7 @@
 };
 use pallet_structure::{Pallet as PalletStructure, Error as StructureError};
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
-use sp_core::H160;
+use sp_core::{Get, H160};
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
 use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};
 use core::ops::Deref;
@@ -622,6 +622,10 @@
 			stored_properties,
 			is_token_owner,
 			|properties| <TokenProperties<T>>::set((collection.id, token_id), properties),
+			erc::ERC721TokenEvent::TokenChanged {
+				token_id: token_id.into(),
+			}
+			.to_log(T::ContractAddress::get()),
 		)
 	}
 
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -17,9 +17,14 @@
 	}
 }
 
+/// @dev inlined interface
+contract ERC721TokenEvent {
+	event TokenChanged(uint256 indexed tokenId);
+}
+
 /// @title A contract that allows to set and delete token properties and change token property permissions.
 /// @dev the ERC-165 identifier for this interface is 0xde0695c2
-contract TokenProperties is Dummy, ERC165 {
+contract TokenProperties is Dummy, ERC165, ERC721TokenEvent {
 	// /// @notice Set permissions for token property.
 	// /// @dev Throws error if `msg.sender` is not admin or owner of the collection.
 	// /// @param key Property key.
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -59,8 +59,19 @@
 
 pub const ADDRESS_FOR_PARTIALLY_OWNED_TOKENS: H160 = H160::repeat_byte(0xff);
 
+/// Rft events.
+#[derive(ToLog)]
+pub enum ERC721TokenEvent {
+	/// The token has been changed.
+	TokenChanged {
+		/// Token ID.
+		#[indexed]
+		token_id: U256,
+	},
+}
+
 /// @title A contract that allows to set and delete token properties and change token property permissions.
-#[solidity_interface(name = TokenProperties, enum(derive(PreDispatch)), enum_attr(weight))]
+#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]
 impl<T: Config> RefungibleHandle<T> {
 	/// @notice Set permissions for token property.
 	/// @dev Throws error if `msg.sender` is not admin or owner of the collection.
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -100,7 +100,7 @@
 	Event as CommonEvent, Pallet as PalletCommon,
 };
 use pallet_structure::Pallet as PalletStructure;
-use sp_core::H160;
+use sp_core::{Get, H160};
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
 use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};
 use up_data_structs::{
@@ -571,6 +571,10 @@
 			stored_properties,
 			is_token_owner,
 			|properties| <TokenProperties<T>>::set((collection.id, token_id), properties),
+			erc::ERC721TokenEvent::TokenChanged {
+				token_id: token_id.into(),
+			}
+			.to_log(T::ContractAddress::get()),
 		)
 	}
 
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -17,9 +17,14 @@
 	}
 }
 
+/// @dev inlined interface
+contract ERC721TokenEvent {
+	event TokenChanged(uint256 indexed tokenId);
+}
+
 /// @title A contract that allows to set and delete token properties and change token property permissions.
 /// @dev the ERC-165 identifier for this interface is 0xde0695c2
-contract TokenProperties is Dummy, ERC165 {
+contract TokenProperties is Dummy, ERC165, ERC721TokenEvent {
 	// /// @notice Set permissions for token property.
 	// /// @dev Throws error if `msg.sender` is not admin or owner of the collection.
 	// /// @param key Property key.
modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth
--- a/pallets/unique/src/eth/stubs/CollectionHelpers.sol
+++ b/pallets/unique/src/eth/stubs/CollectionHelpers.sol
@@ -22,7 +22,6 @@
 	event CollectionCreated(address indexed owner, address indexed collectionId);
 	event CollectionDestroyed(address indexed collectionId);
 	event CollectionChanged(address indexed collectionId);
-	event TokenChanged(address indexed collectionId, uint256 tokenId);
 }
 
 /// @title Contract, which allows users to operate with collections
modifiedtests/src/eth/abi/collectionHelpers.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/collectionHelpers.json
+++ b/tests/src/eth/abi/collectionHelpers.json
@@ -45,25 +45,6 @@
     "type": "event"
   },
   {
-    "anonymous": false,
-    "inputs": [
-      {
-        "indexed": true,
-        "internalType": "address",
-        "name": "collectionId",
-        "type": "address"
-      },
-      {
-        "indexed": false,
-        "internalType": "uint256",
-        "name": "tokenId",
-        "type": "uint256"
-      }
-    ],
-    "name": "TokenChanged",
-    "type": "event"
-  },
-  {
     "inputs": [
       { "internalType": "uint32", "name": "collectionId", "type": "uint32" }
     ],
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -54,6 +54,19 @@
     "inputs": [
       {
         "indexed": true,
+        "internalType": "uint256",
+        "name": "tokenId",
+        "type": "uint256"
+      }
+    ],
+    "name": "TokenChanged",
+    "type": "event"
+  },
+  {
+    "anonymous": false,
+    "inputs": [
+      {
+        "indexed": true,
         "internalType": "address",
         "name": "from",
         "type": "address"
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -54,6 +54,19 @@
     "inputs": [
       {
         "indexed": true,
+        "internalType": "uint256",
+        "name": "tokenId",
+        "type": "uint256"
+      }
+    ],
+    "name": "TokenChanged",
+    "type": "event"
+  },
+  {
+    "anonymous": false,
+    "inputs": [
+      {
+        "indexed": true,
         "internalType": "address",
         "name": "from",
         "type": "address"
modifiedtests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/CollectionHelpers.sol
+++ b/tests/src/eth/api/CollectionHelpers.sol
@@ -17,7 +17,6 @@
 	event CollectionCreated(address indexed owner, address indexed collectionId);
 	event CollectionDestroyed(address indexed collectionId);
 	event CollectionChanged(address indexed collectionId);
-	event TokenChanged(address indexed collectionId, uint256 tokenId);
 }
 
 /// @title Contract, which allows users to operate with collections
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -12,9 +12,14 @@
 	function supportsInterface(bytes4 interfaceID) external view returns (bool);
 }
 
+/// @dev inlined interface
+interface ERC721TokenEvent {
+	event TokenChanged(uint256 indexed tokenId);
+}
+
 /// @title A contract that allows to set and delete token properties and change token property permissions.
 /// @dev the ERC-165 identifier for this interface is 0xde0695c2
-interface TokenProperties is Dummy, ERC165 {
+interface TokenProperties is Dummy, ERC165, ERC721TokenEvent {
 	// /// @notice Set permissions for token property.
 	// /// @dev Throws error if `msg.sender` is not admin or owner of the collection.
 	// /// @param key Property key.
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -12,9 +12,14 @@
 	function supportsInterface(bytes4 interfaceID) external view returns (bool);
 }
 
+/// @dev inlined interface
+interface ERC721TokenEvent {
+	event TokenChanged(uint256 indexed tokenId);
+}
+
 /// @title A contract that allows to set and delete token properties and change token property permissions.
 /// @dev the ERC-165 identifier for this interface is 0xde0695c2
-interface TokenProperties is Dummy, ERC165 {
+interface TokenProperties is Dummy, ERC165, ERC721TokenEvent {
 	// /// @notice Set permissions for token property.
 	// /// @dev Throws error if `msg.sender` is not admin or owner of the collection.
 	// /// @param key Property key.
modifiedtests/src/eth/events.test.tsdiffbeforeafterboth
--- a/tests/src/eth/events.test.ts
+++ b/tests/src/eth/events.test.ts
@@ -29,8 +29,10 @@
   });
 });
 
-function clearEvents(ethEvents: NormalizedEvent[], subEvents: IEvent[]) {
-  ethEvents.splice(0);
+function clearEvents(ethEvents: NormalizedEvent[] | null, subEvents: IEvent[]) {
+  if (ethEvents !== null) {
+    ethEvents.splice(0);
+  }
   subEvents.splice(0);
 }
 
@@ -374,7 +376,6 @@
   const owner = await helper.eth.createAccountWithBalance(donor);
   const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
   const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
-  const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);
   const result = await collection.methods.mint(owner).send({from: owner});
   const tokenId = result.events.Transfer.returnValues.tokenId;
   await collection.methods.setTokenPropertyPermissions([
@@ -384,38 +385,29 @@
       [TokenPermissionField.CollectionAdmin, true]],
     ],
   ]).send({from: owner});
-
 
-  const ethEvents: any = [];
-  collectionHelper.events.allEvents((_: any, event: any) => {
-    ethEvents.push(event);
-  });
   const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['TokenPropertySet', 'TokenPropertyDeleted']}]);
   {
-    await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});
+    const result = await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.containSubset([
-      {
-        event: 'TokenChanged',
-        returnValues: {
-          collectionId: collectionAddress,
-        },
+    expect(result.events.TokenChanged).to.be.like({
+      event: 'TokenChanged',
+      returnValues: {
+        tokenId: tokenId,
       },
-    ]);
+    });
     expect(subEvents).to.containSubset([{method: 'TokenPropertySet'}]);
-    clearEvents(ethEvents, subEvents);
+    clearEvents(null, subEvents);
   }
   {
-    await collection.methods.deleteProperties(tokenId, ['A']).send({from: owner});
+    const result = await collection.methods.deleteProperties(tokenId, ['A']).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.containSubset([
-      {
-        event: 'TokenChanged',
-        returnValues: {
-          collectionId: collectionAddress,
-        },
+    expect(result.events.TokenChanged).to.be.like({
+      event: 'TokenChanged',
+      returnValues: {
+        tokenId: tokenId,
       },
-    ]);
+    });
     expect(subEvents).to.containSubset([{method: 'TokenPropertyDeleted'}]);
   }
   unsubscribe();