From 9f4fc065e116fe1a14d7eb882cead09faf2bf0b9 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Mon, 13 Feb 2023 09:15:55 +0000 Subject: [PATCH] Merge pull request #871 from UniqueNetwork/feature/move_TokenChanged_event --- --- 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", --- 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" --- a/pallets/common/src/erc.rs +++ b/pallets/common/src/erc.rs @@ -26,7 +26,6 @@ }; use pallet_evm_coder_substrate::dispatch_to_evm; use sp_std::{vec, vec::Vec}; -use sp_core::U256; use up_data_structs::{ CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property, SponsoringRateLimit, SponsorshipState, @@ -62,18 +61,9 @@ }, /// The collection has been changed. CollectionChanged { - /// Collection ID. - #[indexed] - collection_id: Address, - }, - - /// The token has been changed. - TokenChanged { /// Collection ID. #[indexed] collection_id: Address, - /// Token ID. - token_id: U256, }, } --- 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, 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 @@ } } - >::deposit_log( - CollectionHelpersEvents::TokenChanged { - collection_id: eth::collection_id_to_address(collection.id), - token_id: token_id.into(), - } - .to_log(T::ContractAddress::get()), - ); + >::deposit_log(log.clone()); } set_token_properties(stored_properties); --- 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 Contract for NonfungibleHandle {...} } /// @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 NonfungibleHandle { /// @notice Set permissions for token property. /// @dev Throws error if `msg.sender` is not admin or owner of the collection. --- 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| >::set((collection.id, token_id), properties), + erc::ERC721TokenEvent::TokenChanged { + token_id: token_id.into(), + } + .to_log(T::ContractAddress::get()), ) } --- 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. --- 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 RefungibleHandle { /// @notice Set permissions for token property. /// @dev Throws error if `msg.sender` is not admin or owner of the collection. --- 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| >::set((collection.id, token_id), properties), + erc::ERC721TokenEvent::TokenChanged { + token_id: token_id.into(), + } + .to_log(T::ContractAddress::get()), ) } --- 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. --- 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 --- 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" } ], --- 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" --- 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" --- 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 --- 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. --- 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. --- 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(); -- gitstuff