From c52e7ce9d5637b2f08768894b57ce953846276c3 Mon Sep 17 00:00:00 2001 From: Smith Li Date: Mon, 25 Mar 2024 21:06:08 +0800 Subject: [PATCH 01/11] use utxo-monitor branch interbtc --- Cargo.toml | 64 +++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 079ced5f..c473d652 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -260,40 +260,40 @@ orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-li orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "28a2e6f0df9540d91db4018c7ecebb8bfc217a2a", default-features = false } # BTC bridge -annuity = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -bitcoin = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -btc-relay = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -clients-info = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -escrow = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -fee = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -interbtc-currency = { package = "currency", git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -issue = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -loans = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -nomination = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -oracle = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -primitives = { package = "interbtc-primitives", git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -redeem = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -replace = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -reward = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -security = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -staking = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -vault-registry = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } +annuity = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +bitcoin = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +btc-relay = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +clients-info = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +escrow = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +fee = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +interbtc-currency = { package = "currency", git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +issue = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +loans = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +nomination = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +oracle = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +primitives = { package = "interbtc-primitives", git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +redeem = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +replace = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +reward = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +security = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +staking = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +vault-registry = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -btc-relay-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -issue-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -oracle-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -redeem-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -replace-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -reward-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -vault-registry-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } +btc-relay-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +issue-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +oracle-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +redeem-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +replace-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +reward-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +vault-registry-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -btc-relay-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -issue-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -oracle-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -redeem-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -replace-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -reward-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } -vault-registry-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "polkadot-v0.9.43", default-features = false } +btc-relay-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +issue-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +oracle-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +redeem-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +replace-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +reward-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +vault-registry-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } # Supress warnings from the peerset in logs during syncing # The polkadot did the same in the next release. See: From 36c79bce507233a725b68af1e1d77bf7a7c035d1 Mon Sep 17 00:00:00 2001 From: Smith Li Date: Wed, 27 Mar 2024 20:34:35 +0800 Subject: [PATCH 02/11] add weight interface update_store_utxo/store_monitor_utxo --- Cargo.lock | 100 +++++++++--------- .../runtime-common/src/weights/btc_relay.rs | 20 ++++ 2 files changed, 70 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08696c92..59abae28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom 0.2.11", "once_cell", @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if 1.0.0", "getrandom 0.2.11", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "annuity" version = "1.0.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-benchmarking", "frame-support", @@ -1036,7 +1036,7 @@ dependencies = [ [[package]] name = "bitcoin" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "bitcoin 0.30.2", "bitcoin_hashes 0.7.6", @@ -1341,7 +1341,7 @@ checksum = "bd769563b4ea2953e2825c9e6b7470a5f55f67e0be00030bf3e390a2a6071f64" [[package]] name = "btc-relay" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "bitcoin 1.2.0", "frame-benchmarking", @@ -1361,7 +1361,7 @@ dependencies = [ [[package]] name = "btc-relay-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "btc-relay-rpc-runtime-api", "jsonrpsee", @@ -1374,7 +1374,7 @@ dependencies = [ [[package]] name = "btc-relay-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-support", "parity-scale-codec", @@ -1723,7 +1723,7 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "clients-info" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "fixed-hash 0.7.0", "frame-benchmarking", @@ -2217,7 +2217,7 @@ dependencies = [ [[package]] name = "currency" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-support", "frame-system", @@ -2984,7 +2984,7 @@ dependencies = [ [[package]] name = "escrow" version = "1.0.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-benchmarking", "frame-support", @@ -3848,7 +3848,7 @@ dependencies = [ [[package]] name = "fee" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "currency", "frame-benchmarking", @@ -5214,7 +5214,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.7", + "ahash 0.7.8", ] [[package]] @@ -5223,7 +5223,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.11", ] [[package]] @@ -5232,7 +5232,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.11", "allocator-api2", "serde", ] @@ -5965,7 +5965,7 @@ dependencies = [ [[package]] name = "interbtc-primitives" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "bitcoin 1.2.0", "bstringify", @@ -6042,7 +6042,7 @@ dependencies = [ [[package]] name = "issue" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -6074,7 +6074,7 @@ dependencies = [ [[package]] name = "issue-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "issue-rpc-runtime-api", "jsonrpsee", @@ -6087,7 +6087,7 @@ dependencies = [ [[package]] name = "issue-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-support", "parity-scale-codec", @@ -7042,7 +7042,7 @@ checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "loans" version = "1.9.3" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "currency", "frame-benchmarking", @@ -7866,7 +7866,7 @@ dependencies = [ [[package]] name = "nomination" version = "0.5.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "currency", "fee", @@ -8210,7 +8210,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "oracle" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "currency", "frame-benchmarking", @@ -8233,7 +8233,7 @@ dependencies = [ [[package]] name = "oracle-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -8246,7 +8246,7 @@ dependencies = [ [[package]] name = "oracle-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-support", "interbtc-primitives", @@ -10905,7 +10905,7 @@ dependencies = [ [[package]] name = "redeem" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -10935,7 +10935,7 @@ dependencies = [ [[package]] name = "redeem-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10948,7 +10948,7 @@ dependencies = [ [[package]] name = "redeem-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-support", "parity-scale-codec", @@ -11076,7 +11076,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "replace" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -11106,7 +11106,7 @@ dependencies = [ [[package]] name = "replace-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11119,7 +11119,7 @@ dependencies = [ [[package]] name = "replace-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-support", "parity-scale-codec", @@ -11183,7 +11183,7 @@ dependencies = [ [[package]] name = "reward" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-benchmarking", "frame-support", @@ -11203,7 +11203,7 @@ dependencies = [ [[package]] name = "reward-rpc" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -11217,7 +11217,7 @@ dependencies = [ [[package]] name = "reward-rpc-runtime-api" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-support", "oracle-rpc-runtime-api", @@ -12068,7 +12068,7 @@ name = "sc-consensus-grandpa" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.11", "array-bytes", "async-trait", "dyn-clone", @@ -12362,7 +12362,7 @@ name = "sc-network-gossip" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.11", "futures 0.3.29", "futures-timer", "libp2p", @@ -13079,7 +13079,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.11", "cfg-if 1.0.0", "hashbrown 0.13.2", ] @@ -13250,7 +13250,7 @@ dependencies = [ [[package]] name = "security" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-benchmarking", "frame-support", @@ -15092,7 +15092,7 @@ name = "sp-trie" version = "7.0.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.11", "hash-db 0.16.0", "hashbrown 0.13.2", "lazy_static", @@ -15116,7 +15116,7 @@ version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8efbe5b6d29a18fea7c2f52e0098135f2f864b31d335d5105b40a349866ba874" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.11", "hash-db 0.15.2", "hashbrown 0.12.3", "lazy_static", @@ -15140,7 +15140,7 @@ version = "22.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4eeb7ef23f79eba8609db79ef9cef242f994f1f87a3c0387b4b5f177fda74" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.11", "hash-db 0.16.0", "hashbrown 0.13.2", "lazy_static", @@ -15346,7 +15346,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staking" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-benchmarking", "frame-support", @@ -16861,7 +16861,7 @@ checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" [[package]] name = "traits" version = "1.9.3" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-support", "frame-system", @@ -17365,7 +17365,7 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vault-registry" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "bitcoin 1.2.0", "currency", @@ -17398,7 +17398,7 @@ dependencies = [ [[package]] name = "vault-registry-rpc" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -17412,7 +17412,7 @@ dependencies = [ [[package]] name = "vault-registry-rpc-runtime-api" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" dependencies = [ "frame-support", "oracle-rpc-runtime-api", @@ -18978,18 +18978,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.30" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306dca4455518f1f31635ec308b6b3e4eb1b11758cefafc782827d0aa7acb5c7" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.30" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be912bf68235a88fbefd1b73415cb218405958d1655b2ece9035a19920bdf6ba" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", diff --git a/runtime/runtime-common/src/weights/btc_relay.rs b/runtime/runtime-common/src/weights/btc_relay.rs index 0958e8c7..e3776c72 100644 --- a/runtime/runtime-common/src/weights/btc_relay.rs +++ b/runtime/runtime-common/src/weights/btc_relay.rs @@ -94,6 +94,26 @@ impl btc_relay::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } + + fn update_store_utxo () -> Weight { + // Proof Size summary in bytes: + // Measured: `874` + // Estimated: `6340` + // Minimum execution time: 88_808_000 picoseconds. + Weight::from_parts(90_482_000, 6340) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + + fn store_monitor_utxo () -> Weight { + // Proof Size summary in bytes: + // Measured: `874` + // Estimated: `6340` + // Minimum execution time: 88_808_000 picoseconds. + Weight::from_parts(90_482_000, 6340) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } /// Storage: BTCRelay ChainCounter (r:1 w:1) /// Proof: BTCRelay ChainCounter (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: BTCRelay BlockHeaders (r:2 w:1) From 21dd75e85780deacb7606d71a3c5181507092ebc Mon Sep 17 00:00:00 2001 From: Smith Li Date: Mon, 8 Apr 2024 17:26:04 +0800 Subject: [PATCH 03/11] use rev in Cargo.toml interbtc --- Cargo.lock | 66 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 64 ++++++++++++++++++++++++++-------------------------- 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59abae28..c6be81ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "annuity" version = "1.0.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-benchmarking", "frame-support", @@ -1036,7 +1036,7 @@ dependencies = [ [[package]] name = "bitcoin" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "bitcoin 0.30.2", "bitcoin_hashes 0.7.6", @@ -1341,7 +1341,7 @@ checksum = "bd769563b4ea2953e2825c9e6b7470a5f55f67e0be00030bf3e390a2a6071f64" [[package]] name = "btc-relay" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "bitcoin 1.2.0", "frame-benchmarking", @@ -1361,7 +1361,7 @@ dependencies = [ [[package]] name = "btc-relay-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "btc-relay-rpc-runtime-api", "jsonrpsee", @@ -1374,7 +1374,7 @@ dependencies = [ [[package]] name = "btc-relay-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-support", "parity-scale-codec", @@ -1723,7 +1723,7 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "clients-info" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "fixed-hash 0.7.0", "frame-benchmarking", @@ -2217,7 +2217,7 @@ dependencies = [ [[package]] name = "currency" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-support", "frame-system", @@ -2984,7 +2984,7 @@ dependencies = [ [[package]] name = "escrow" version = "1.0.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-benchmarking", "frame-support", @@ -3848,7 +3848,7 @@ dependencies = [ [[package]] name = "fee" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "currency", "frame-benchmarking", @@ -5965,7 +5965,7 @@ dependencies = [ [[package]] name = "interbtc-primitives" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "bitcoin 1.2.0", "bstringify", @@ -6042,7 +6042,7 @@ dependencies = [ [[package]] name = "issue" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -6074,7 +6074,7 @@ dependencies = [ [[package]] name = "issue-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "issue-rpc-runtime-api", "jsonrpsee", @@ -6087,7 +6087,7 @@ dependencies = [ [[package]] name = "issue-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-support", "parity-scale-codec", @@ -7042,7 +7042,7 @@ checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "loans" version = "1.9.3" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "currency", "frame-benchmarking", @@ -7866,7 +7866,7 @@ dependencies = [ [[package]] name = "nomination" version = "0.5.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "currency", "fee", @@ -8210,7 +8210,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "oracle" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "currency", "frame-benchmarking", @@ -8233,7 +8233,7 @@ dependencies = [ [[package]] name = "oracle-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -8246,7 +8246,7 @@ dependencies = [ [[package]] name = "oracle-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-support", "interbtc-primitives", @@ -10905,7 +10905,7 @@ dependencies = [ [[package]] name = "redeem" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -10935,7 +10935,7 @@ dependencies = [ [[package]] name = "redeem-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10948,7 +10948,7 @@ dependencies = [ [[package]] name = "redeem-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-support", "parity-scale-codec", @@ -11076,7 +11076,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "replace" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -11106,7 +11106,7 @@ dependencies = [ [[package]] name = "replace-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11119,7 +11119,7 @@ dependencies = [ [[package]] name = "replace-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-support", "parity-scale-codec", @@ -11183,7 +11183,7 @@ dependencies = [ [[package]] name = "reward" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-benchmarking", "frame-support", @@ -11203,7 +11203,7 @@ dependencies = [ [[package]] name = "reward-rpc" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -11217,7 +11217,7 @@ dependencies = [ [[package]] name = "reward-rpc-runtime-api" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-support", "oracle-rpc-runtime-api", @@ -13250,7 +13250,7 @@ dependencies = [ [[package]] name = "security" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-benchmarking", "frame-support", @@ -15346,7 +15346,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staking" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-benchmarking", "frame-support", @@ -16861,7 +16861,7 @@ checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" [[package]] name = "traits" version = "1.9.3" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-support", "frame-system", @@ -17365,7 +17365,7 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vault-registry" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "bitcoin 1.2.0", "currency", @@ -17398,7 +17398,7 @@ dependencies = [ [[package]] name = "vault-registry-rpc" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -17412,7 +17412,7 @@ dependencies = [ [[package]] name = "vault-registry-rpc-runtime-api" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=utxo-monitor#bb7ad26d8c65f692bca598f6399686eb69d63a85" +source = "git+https://github.com/ggxchain/interbtc.git?rev=8d931104#8d931104a7d559d7019b2c0b11f2404c2d8ecef3" dependencies = [ "frame-support", "oracle-rpc-runtime-api", diff --git a/Cargo.toml b/Cargo.toml index c473d652..ea4fc59f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -260,40 +260,40 @@ orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-li orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "28a2e6f0df9540d91db4018c7ecebb8bfc217a2a", default-features = false } # BTC bridge -annuity = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -bitcoin = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -btc-relay = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -clients-info = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -escrow = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -fee = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -interbtc-currency = { package = "currency", git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -issue = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -loans = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -nomination = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -oracle = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -primitives = { package = "interbtc-primitives", git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -redeem = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -replace = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -reward = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -security = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -staking = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -vault-registry = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +annuity = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +bitcoin = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +btc-relay = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +clients-info = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +escrow = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +fee = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +interbtc-currency = { package = "currency", git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +issue = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +loans = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +nomination = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +oracle = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +primitives = { package = "interbtc-primitives", git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +redeem = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +replace = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +reward = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +security = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +staking = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +vault-registry = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -btc-relay-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -issue-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -oracle-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -redeem-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -replace-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -reward-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -vault-registry-rpc = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +btc-relay-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +issue-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +oracle-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +redeem-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +replace-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +reward-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +vault-registry-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -btc-relay-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -issue-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -oracle-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -redeem-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -replace-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -reward-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } -vault-registry-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", branch = "utxo-monitor", default-features = false } +btc-relay-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +issue-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +oracle-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +redeem-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +replace-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +reward-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +vault-registry-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } # Supress warnings from the peerset in logs during syncing # The polkadot did the same in the next release. See: From a261673434538498c2c34d807c947e9879750e3a Mon Sep 17 00:00:00 2001 From: Smith Li Date: Tue, 16 Apr 2024 19:56:47 +0800 Subject: [PATCH 04/11] add nfts pallet --- Cargo.lock | 25 ++++++++++++++++++--- Cargo.toml | 1 + runtime/brooklyn/Cargo.toml | 2 ++ runtime/brooklyn/src/lib.rs | 45 +++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4696fa6..aabc4862 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4846,6 +4846,7 @@ dependencies = [ "pallet-insecure-randomness-collective-flip", "pallet-mmr", "pallet-multisig", + "pallet-nfts", "pallet-offences", "pallet-preimage", "pallet-proxy", @@ -9223,6 +9224,24 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", ] +[[package]] +name = "pallet-nfts" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "enumflags2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log 0.4.20", + "parity-scale-codec", + "scale-info", + "sp-core 7.0.0", + "sp-io 7.0.0", + "sp-runtime 7.0.0", + "sp-std 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", +] + [[package]] name = "pallet-offences" version = "4.0.0-dev" @@ -16837,7 +16856,7 @@ dependencies = [ "chrono", "lazy_static", "matchers", - "parking_lot 0.9.0", + "parking_lot 0.7.1", "regex", "serde", "serde_json", @@ -17065,9 +17084,9 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "digest 0.10.7", - "rand 0.5.6", + "rand 0.4.6", "static_assertions", ] diff --git a/Cargo.toml b/Cargo.toml index 485ac160..6f53a578 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,6 +134,7 @@ pallet-im-online = { version = "4.0.0-dev", git = "https://github.com/paritytech pallet-indices = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } pallet-mmr = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } pallet-multisig = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } +pallet-nfts = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } pallet-offences = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } pallet-preimage = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } pallet-proxy = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } diff --git a/runtime/brooklyn/Cargo.toml b/runtime/brooklyn/Cargo.toml index 886d0e88..a5ad2a78 100644 --- a/runtime/brooklyn/Cargo.toml +++ b/runtime/brooklyn/Cargo.toml @@ -58,6 +58,7 @@ pallet-im-online.workspace = true pallet-indices.workspace = true pallet-mmr.workspace = true pallet-multisig.workspace = true +pallet-nfts.workspace = true pallet-offences.workspace = true pallet-preimage.workspace = true pallet-proxy.workspace = true @@ -209,6 +210,7 @@ std = [ "pallet-indices/std", "pallet-mmr/std", "pallet-multisig/std", + "pallet-nfts/std", "pallet-offences/std", "pallet-preimage/std", "pallet-proxy/std", diff --git a/runtime/brooklyn/src/lib.rs b/runtime/brooklyn/src/lib.rs index edcd9705..409e872e 100644 --- a/runtime/brooklyn/src/lib.rs +++ b/runtime/brooklyn/src/lib.rs @@ -68,6 +68,7 @@ use frame_support::weights::constants::ParityDbWeight as RuntimeDbWeight; use frame_support::weights::constants::RocksDbWeight as RuntimeDbWeight; pub use pallet_grandpa::AuthorityId as GrandpaId; use pallet_grandpa::{fg_primitives, AuthorityList as GrandpaAuthorityList}; +use pallet_nfts::PalletFeatures; use pallet_session::historical::{self as pallet_session_historical}; use pallet_transaction_payment::CurrencyAdapter; use pos::{currency, session_payout}; @@ -569,6 +570,49 @@ impl pallet_utility::Config for Runtime { type WeightInfo = pallet_utility::weights::SubstrateWeight; } +parameter_types! { + pub const CollectionDeposit: Balance = 100 * GGX; + pub const ItemDeposit: Balance = 1 * GGX; + pub const KeyLimit: u32 = 32; + pub const ValueLimit: u32 = 256; + pub const ApprovalsLimit: u32 = 20; + pub const ItemAttributesApprovalsLimit: u32 = 20; + pub const MaxTips: u32 = 10; + pub storage MaxDeadlineDuration: BlockNumber = 12 * 30 * Days::get(); + + pub Features: PalletFeatures = PalletFeatures::all_enabled(); + pub const MaxAttributesPerCall: u32 = 10; +} + +impl pallet_nfts::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type CollectionId = u32; + type ItemId = u32; + type Currency = Balances; + type ForceOrigin = frame_system::EnsureRoot; + type CollectionDeposit = CollectionDeposit; + type ItemDeposit = ItemDeposit; + type MetadataDepositBase = MetadataDepositBase; + type AttributeDepositBase = MetadataDepositBase; + type DepositPerByte = MetadataDepositPerByte; + type StringLimit = StringLimit; + type KeyLimit = KeyLimit; + type ValueLimit = ValueLimit; + type ApprovalsLimit = ApprovalsLimit; + type ItemAttributesApprovalsLimit = ItemAttributesApprovalsLimit; + type MaxTips = MaxTips; + type MaxDeadlineDuration = MaxDeadlineDuration; + type MaxAttributesPerCall = MaxAttributesPerCall; + type Features = Features; + type OffchainSignature = Signature; + type OffchainPublic = ::Signer; + type WeightInfo = pallet_nfts::weights::SubstrateWeight; + #[cfg(feature = "runtime-benchmarks")] + type Helper = (); + type CreateOrigin = AsEnsureOriginWithArg>; + type Locker = (); +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -603,6 +647,7 @@ construct_runtime!( Historical: pallet_session_historical, RandomnessCollectiveFlip: pallet_randomness_collective_flip, ElectionProviderMultiPhase: pallet_election_provider_multi_phase, + Nfts: pallet_nfts, // Goverment pallets Treasury: pallet_treasury, From 27651d5cce8c4e3bf6221635150ed5316717d416 Mon Sep 17 00:00:00 2001 From: Smith Li Date: Tue, 16 Apr 2024 20:00:00 +0800 Subject: [PATCH 05/11] Update Cargo.lock --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index aabc4862..a819ce67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16856,7 +16856,7 @@ dependencies = [ "chrono", "lazy_static", "matchers", - "parking_lot 0.7.1", + "parking_lot 0.9.0", "regex", "serde", "serde_json", From 526a421badb2c006419055000b8d5de1ed7036dc Mon Sep 17 00:00:00 2001 From: Smith Li Date: Thu, 18 Apr 2024 21:30:32 +0800 Subject: [PATCH 06/11] init psp37 --- Cargo.lock | 17 +++ Cargo.toml | 1 + pallet/psp37/Cargo.toml | 40 +++++ pallet/psp37/src/lib.rs | 285 ++++++++++++++++++++++++++++++++++++ pallet/psp37/src/mock.rs | 214 +++++++++++++++++++++++++++ pallet/psp37/src/tests.rs | 9 ++ runtime/brooklyn/Cargo.toml | 4 + 7 files changed, 570 insertions(+) create mode 100644 pallet/psp37/Cargo.toml create mode 100644 pallet/psp37/src/lib.rs create mode 100644 pallet/psp37/src/mock.rs create mode 100644 pallet/psp37/src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index a819ce67..c18312e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4850,6 +4850,7 @@ dependencies = [ "pallet-offences", "pallet-preimage", "pallet-proxy", + "pallet-psp37", "pallet-ranked-collective", "pallet-receipt-registry", "pallet-referenda", @@ -9291,6 +9292,22 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43)", ] +[[package]] +name = "pallet-psp37" +version = "0.1.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-assets", + "pallet-balances", + "pallet-nfts", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core 7.0.0", + "sp-runtime 7.0.0", +] + [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index 6f53a578..c8de018c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -298,6 +298,7 @@ vault-registry-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.g # Dex pallet-dex = { path = "pallet/dex", default-features = false } +pallet-psp37 = { path = "pallet/psp37", default-features = false } # Supress warnings from the peerset in logs during syncing # The polkadot did the same in the next release. See: diff --git a/pallet/psp37/Cargo.toml b/pallet/psp37/Cargo.toml new file mode 100644 index 00000000..283e583f --- /dev/null +++ b/pallet/psp37/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "pallet-psp37" +version = "0.1.0" +edition.workspace = true +authors.workspace = true +repository.workspace = true + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +frame-support.workspace = true +frame-system.workspace = true +pallet-nfts.workspace = true +scale-codec = { package = "parity-scale-codec", workspace = true, features = ["max-encoded-len"] } +scale-info.workspace = true +sp-runtime.workspace = true + +[dev-dependencies] +pallet-assets.workspace = true +pallet-balances.workspace = true +pallet-timestamp.workspace = true +sp-core.workspace = true + +[features] +default = ["std"] +std = [ + "frame-support/std", + "frame-system/std", + "pallet-assets/std", + "pallet-balances/std", + "pallet-nfts/std", + "pallet-timestamp/std", + "scale-codec/std", + "scale-info/std", + "sp-core/std", + "sp-runtime/std", +] + +try-runtime = ["frame-support/try-runtime"] \ No newline at end of file diff --git a/pallet/psp37/src/lib.rs b/pallet/psp37/src/lib.rs new file mode 100644 index 00000000..12e3da62 --- /dev/null +++ b/pallet/psp37/src/lib.rs @@ -0,0 +1,285 @@ +#![cfg_attr(not(feature = "std"), no_std)] +#![feature(slice_pattern)] +#![allow(clippy::unused_unit)] + +use frame_support::{ + ensure, + pallet_prelude::DispatchResult, + sp_std::{convert::TryInto, prelude::*}, + traits::{Currency, ExistenceRequirement::AllowDeath, Get, ReservableCurrency}, + PalletId, RuntimeDebug, +}; + +use sp_runtime::traits::{CheckedAdd, CheckedSub, StaticLookup}; + +use frame_system::pallet_prelude::*; +use scale_codec::{Decode, Encode, MaxEncodedLen}; +use scale_info::TypeInfo; +use sp_runtime::{traits::One, DispatchError}; + +use frame_support::{ + sp_runtime::traits::AccountIdConversion, + traits::{ + fungibles::{Balanced, Mutate}, + tokens::Preservation, + }, +}; + +use pallet_nfts::{CollectionSetting, NextCollectionId}; + +// #[cfg(test)] +// mod mock; +// #[cfg(test)] +// mod tests; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::{ + dispatch::DispatchResultWithPostInfo, + pallet_prelude::{ValueQuery, *}, + Blake2_128Concat, + }; + + pub type BalanceOf = + <::Currency as Currency<::AccountId>>::Balance; + + /// The current storage version. + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + + #[pallet::pallet] + #[pallet::storage_version(STORAGE_VERSION)] + pub struct Pallet(PhantomData<(T, I)>); + + #[pallet::config] + /// The module configuration trait. + pub trait Config: frame_system::Config + pallet_nfts::Config { + /// The overarching event type. + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; + + /// The currency mechanism. + type Currency: ReservableCurrency; + } + + #[pallet::storage] + #[pallet::getter(fn native_asset_id)] + pub type NativeAssetId, I: 'static = ()> = StorageValue<_, u32, ValueQuery>; + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event, I: 'static = ()> { + NativeWithdrawed { amount: BalanceOf }, + } + + #[pallet::error] + pub enum Error { + OrderIndexOverflow, + } + + // #[pallet::hooks] + // impl, I: 'static> Hooks> for Pallet {} + + #[pallet::call] + impl, I: 'static> Pallet { + #[pallet::weight({0})] + #[pallet::call_index(0)] + pub fn approve( + origin: OriginFor, + operator: T::AccountId, + value: BalanceOf, + ) -> DispatchResultWithPostInfo { + let who = ensure_signed(origin)?; + + let maybe_check_origin = T::ForceOrigin::try_origin(origin) + .map(|_| None) + .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; + let delegate = T::Lookup::lookup(delegate)?; + Self::do_approve_transfer( + maybe_check_origin, + collection, + item, + delegate, + maybe_deadline, + ) + } + + #[pallet::weight({0})] + #[pallet::call_index(1)] + pub fn transfer( + origin: OriginFor, + to: T::AccountId, + id: u32, + value: BalanceOf, + data: Vec, + ) -> DispatchResultWithPostInfo { + let who = ensure_signed(origin)?; + + let origin = ensure_signed(origin)?; + + pallet_nfts::do_transfer(id, 0, to, |_, details| { + if details.owner != origin { + let deadline = details + .approvals + .get(&origin) + .ok_or(Error::::NoPermission)?; + if let Some(d) = deadline { + let block_number = frame_system::Pallet::::block_number(); + ensure!(block_number <= *d, Error::::ApprovalExpired); + } + } + Ok(()) + }) + } + + #[pallet::weight({0})] + #[pallet::call_index(2)] + pub fn transfer_from( + origin: OriginFor, + from: T::AccountId, + to: T::AccountId, + id: u32, + value: BalanceOf, + data: Vec, + ) -> DispatchResultWithPostInfo { + let who = ensure_signed(origin)?; + + Ok(().into()) + } + + #[pallet::weight({0})] + #[pallet::call_index(3)] + pub fn create(origin: OriginFor, id: u32) -> DispatchResult { + let who = ensure_signed(origin)?; + + let collection = + NextCollectionId::::get().unwrap_or(T::CollectionId::initial_value()); + + let owner = T::CreateOrigin::ensure_origin(origin, &collection)?; + let admin = T::Lookup::lookup(owner)?; + + // DepositRequired can be disabled by calling the force_create() only + ensure!( + !config.has_disabled_setting(CollectionSetting::DepositRequired), + Error::::WrongSetting + ); + + Self::do_create_collection( + collection, + owner.clone(), + admin.clone(), + config, + T::CollectionDeposit::get(), + Event::Created { + collection, + creator: owner, + owner: admin, + }, + ) + } + + #[pallet::weight({0})] + #[pallet::call_index(4)] + pub fn mint(origin: OriginFor, id: u32, mint_to: T::AccountId) -> DispatchResult { + let caller = ensure_signed(origin)?; + let mint_to = T::Lookup::lookup(mint_to)?; + let item_config = ItemConfig { + settings: Self::get_default_item_settings(&collection)?, + }; + + Self::do_mint( + collection, + item, + Some(caller.clone()), + mint_to.clone(), + item_config, + |collection_details, collection_config| { + let mint_settings = collection_config.mint_settings; + let now = frame_system::Pallet::::block_number(); + + if let Some(start_block) = mint_settings.start_block { + ensure!(start_block <= now, Error::::MintNotStarted); + } + if let Some(end_block) = mint_settings.end_block { + ensure!(end_block >= now, Error::::MintEnded); + } + + match mint_settings.mint_type { + MintType::Issuer => { + ensure!( + Self::has_role(&collection, &caller, CollectionRole::Issuer), + Error::::NoPermission + ); + } + MintType::HolderOf(collection_id) => { + let MintWitness { owned_item } = + witness_data.ok_or(Error::::BadWitness)?; + + let owns_item = Account::::contains_key(( + &caller, + &collection_id, + &owned_item, + )); + ensure!(owns_item, Error::::BadWitness); + + let pallet_attribute = + PalletAttributes::::UsedToClaim(collection); + + let key = ( + &collection_id, + Some(owned_item), + AttributeNamespace::Pallet, + &Self::construct_attribute_key(pallet_attribute.encode())?, + ); + let already_claimed = Attribute::::contains_key(key.clone()); + ensure!(!already_claimed, Error::::AlreadyClaimed); + + let attribute_value = Self::construct_attribute_value(vec![])?; + Attribute::::insert( + key, + ( + attribute_value.clone(), + AttributeDeposit { + account: None, + amount: Zero::zero(), + }, + ), + ); + Self::deposit_event(Event::PalletAttributeSet { + collection, + item: Some(item), + attribute: pallet_attribute, + value: attribute_value, + }); + } + _ => {} + } + + if let Some(price) = mint_settings.price { + T::Currency::transfer( + &caller, + &collection_details.owner, + price, + ExistenceRequirement::KeepAlive, + )?; + } + + Ok(()) + }, + ) + } + + #[pallet::weight({0})] + #[pallet::call_index(5)] + pub fn set_metadata(origin: OriginFor, id: u32, data: Vec) -> DispatchResult { + let maybe_check_origin = T::ForceOrigin::try_origin(origin) + .map(|_| None) + .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; + Self::do_set_item_metadata(maybe_check_origin, collection, item, data, None) + } + } +} + +// impl Pallet { + +// } diff --git a/pallet/psp37/src/mock.rs b/pallet/psp37/src/mock.rs new file mode 100644 index 00000000..596bc407 --- /dev/null +++ b/pallet/psp37/src/mock.rs @@ -0,0 +1,214 @@ +use crate as pallet_dex; + +use frame_support::{ + pallet_prelude::Weight, + parameter_types, sp_io, + traits::{AsEnsureOriginWithArg, GenesisBuild, Hooks}, + weights::constants::RocksDbWeight, + PalletId, +}; +use sp_core::{ConstU128, ConstU32, ConstU64, H256}; +use sp_runtime::{testing::Header, traits::IdentityLookup}; + +pub type AccountId = u128; +pub type Balance = u128; +pub type AssetId = u32; + +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; + +frame_support::construct_runtime!( + pub enum Test where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system, + Balances: pallet_balances, + Timestamp: pallet_timestamp, + Assets: pallet_assets, + Dex: pallet_dex, + } +); + +impl pallet_balances::Config for Test { + type Balance = Balance; + type DustRemoval = (); + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposit = ConstU128<1>; + type AccountStore = System; + type WeightInfo = pallet_balances::weights::SubstrateWeight; + type MaxLocks = ConstU32<50>; + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; + type HoldIdentifier = (); + type FreezeIdentifier = (); + type MaxHolds = ConstU32<0>; + type MaxFreezes = ConstU32<0>; +} + +// These parameters dont matter much as this will only be called by root with the forced arguments +// No deposit is substracted with those methods +parameter_types! { + pub const AssetDeposit: Balance = 0; + pub const AssetAccountDeposit: Balance = 0; + pub const ApprovalDeposit: Balance = 0; + pub const AssetsStringLimit: u32 = 50; + pub const MetadataDepositBase: Balance = 0; + pub const MetadataDepositPerByte: Balance = 0; +} + +impl pallet_assets::Config for Test { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type AssetId = AssetId; + type Currency = Balances; + type ForceOrigin = frame_system::EnsureRoot; + type AssetDeposit = AssetDeposit; + type AssetAccountDeposit = AssetAccountDeposit; + type MetadataDepositBase = MetadataDepositBase; + type MetadataDepositPerByte = MetadataDepositPerByte; + type ApprovalDeposit = ApprovalDeposit; + type StringLimit = AssetsStringLimit; + type Freezer = (); + type Extra = (); + type CreateOrigin = AsEnsureOriginWithArg>; + type WeightInfo = pallet_assets::weights::SubstrateWeight; + type RemoveItemsLimit = ConstU32<0>; + type AssetIdParameter = AssetId; + type CallbackHandle = (); + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); +} + +parameter_types! { + pub BlockWeights: frame_system::limits::BlockWeights = + frame_system::limits::BlockWeights::simple_max( + Weight::from_parts(2_000_000_000_000, u64::MAX), + ); +} + +impl frame_system::Config for Test { + type BaseCallFilter = frame_support::traits::Everything; + type BlockWeights = BlockWeights; + type BlockLength = (); + type DbWeight = RocksDbWeight; + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type BlockNumber = u64; + type RuntimeCall = RuntimeCall; + type Hash = H256; + type Version = (); + type Hashing = sp_runtime::traits::BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Header = Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = ConstU64<250>; + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +impl pallet_timestamp::Config for Test { + type Moment = u64; + type OnTimestampSet = (); + type MinimumPeriod = ConstU64<2>; + type WeightInfo = (); +} + +parameter_types! { + pub const DexPalletId: PalletId = PalletId(*b"py/sudex"); +} + +impl pallet_dex::Config for Test { + type RuntimeEvent = RuntimeEvent; + type PalletId = DexPalletId; + type Fungibles = Assets; + type PrivilegedOrigin = frame_system::EnsureRoot; + type Currency = Balances; +} + +pub struct ExtBuilder; + +impl Default for ExtBuilder { + fn default() -> Self { + ExtBuilder + } +} + +impl ExtBuilder { + pub fn build(self) -> sp_io::TestExternalities { + let mut storage = frame_system::GenesisConfig::default() + .build_storage::() + .unwrap(); + + // This will cause some initial issuance + pallet_balances::GenesisConfig:: { + balances: vec![(1, 9000), (2, 800)], + } + .assimilate_storage(&mut storage) + .ok(); + + pallet_assets::GenesisConfig:: { + assets: vec![ + // id, owner, is_sufficient, min_balance + (999, 0, true, 1), + (888, 0, true, 1), + (777, 0, true, 1), + ], + metadata: vec![ + // id, name, symbol, decimals + (999, "Bitcoin".into(), "BTC".into(), 10), + (888, "GGxchain".into(), "GGXT".into(), 18), + (777, "USDT".into(), "USDT".into(), 10), + ], + accounts: vec![ + // id, account_id, balance + (999, 1, 1000), + (888, 1, 1000), + (777, 1, 1000), + (999, 2, 1000), + (888, 2, 1000), + (777, 2, 1000), + ], + } + .assimilate_storage(&mut storage) + .ok(); + + >::assimilate_storage( + &pallet_dex::GenesisConfig { + asset_ids: vec![8888, 999, 888, 777], + native_asset_id: 8888, + }, + &mut storage, + ) + .unwrap(); + + let mut ext = sp_io::TestExternalities::new(storage); + ext.execute_with(|| System::set_block_number(1)); + ext + } +} + +pub fn new_test_ext() -> sp_io::TestExternalities { + ExtBuilder::default().build() +} + +pub fn run_to_block(n: u64) { + while System::block_number() < n { + if System::block_number() > 0 { + Dex::on_finalize(System::block_number()); + System::on_finalize(System::block_number()); + } + System::reset_events(); + System::set_block_number(System::block_number() + 1); + System::on_initialize(System::block_number()); + Dex::on_initialize(System::block_number()); + } +} diff --git a/pallet/psp37/src/tests.rs b/pallet/psp37/src/tests.rs new file mode 100644 index 00000000..e6a67edc --- /dev/null +++ b/pallet/psp37/src/tests.rs @@ -0,0 +1,9 @@ +use super::{pallet::Error, *}; +use frame_support::{assert_noop, assert_ok}; +use mock::*; + +#[test] +fn test_deposit() { + new_test_ext().execute_with(|| { + }) +} \ No newline at end of file diff --git a/runtime/brooklyn/Cargo.toml b/runtime/brooklyn/Cargo.toml index a5ad2a78..e08ceaf1 100644 --- a/runtime/brooklyn/Cargo.toml +++ b/runtime/brooklyn/Cargo.toml @@ -155,6 +155,8 @@ vault-registry-rpc-runtime-api.workspace = true # Dex pallet-dex.workspace = true +pallet-psp37.workspace = true + [build-dependencies] substrate-wasm-builder.workspace = true @@ -290,6 +292,8 @@ std = [ #Dex "pallet-dex/std", + + "pallet-psp37/std", ] aura = [] allowlist = [] From 47432f59270a03d33b04c4c8bee9601cf721286c Mon Sep 17 00:00:00 2001 From: Smith Li Date: Fri, 19 Apr 2024 20:23:59 +0800 Subject: [PATCH 07/11] use pallet-nfts call --- pallet/psp37/src/lib.rs | 168 +++------------------------------------- 1 file changed, 12 insertions(+), 156 deletions(-) diff --git a/pallet/psp37/src/lib.rs b/pallet/psp37/src/lib.rs index 12e3da62..e7b8150a 100644 --- a/pallet/psp37/src/lib.rs +++ b/pallet/psp37/src/lib.rs @@ -41,8 +41,9 @@ pub mod pallet { Blake2_128Concat, }; - pub type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; + pub type BalanceOf = <>::Currency as Currency< + ::AccountId, + >>::Balance; /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); @@ -57,9 +58,6 @@ pub mod pallet { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; - - /// The currency mechanism. - type Currency: ReservableCurrency; } #[pallet::storage] @@ -86,22 +84,11 @@ pub mod pallet { #[pallet::call_index(0)] pub fn approve( origin: OriginFor, + id: u32, operator: T::AccountId, value: BalanceOf, ) -> DispatchResultWithPostInfo { - let who = ensure_signed(origin)?; - - let maybe_check_origin = T::ForceOrigin::try_origin(origin) - .map(|_| None) - .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; - let delegate = T::Lookup::lookup(delegate)?; - Self::do_approve_transfer( - maybe_check_origin, - collection, - item, - delegate, - maybe_deadline, - ) + pallet_nfts::Pallet::::approve_transfer(origin.clone(), id, 0, operator, None) } #[pallet::weight({0})] @@ -113,23 +100,7 @@ pub mod pallet { value: BalanceOf, data: Vec, ) -> DispatchResultWithPostInfo { - let who = ensure_signed(origin)?; - - let origin = ensure_signed(origin)?; - - pallet_nfts::do_transfer(id, 0, to, |_, details| { - if details.owner != origin { - let deadline = details - .approvals - .get(&origin) - .ok_or(Error::::NoPermission)?; - if let Some(d) = deadline { - let block_number = frame_system::Pallet::::block_number(); - ensure!(block_number <= *d, Error::::ApprovalExpired); - } - } - Ok(()) - }) + pallet_nfts::Pallet::::transfer(origin.clone(), id, 0, to) } #[pallet::weight({0})] @@ -142,9 +113,7 @@ pub mod pallet { value: BalanceOf, data: Vec, ) -> DispatchResultWithPostInfo { - let who = ensure_signed(origin)?; - - Ok(().into()) + pallet_nfts::Pallet::::transfer(origin.clone(), id, 0, to) } #[pallet::weight({0})] @@ -152,134 +121,21 @@ pub mod pallet { pub fn create(origin: OriginFor, id: u32) -> DispatchResult { let who = ensure_signed(origin)?; - let collection = - NextCollectionId::::get().unwrap_or(T::CollectionId::initial_value()); - - let owner = T::CreateOrigin::ensure_origin(origin, &collection)?; - let admin = T::Lookup::lookup(owner)?; - - // DepositRequired can be disabled by calling the force_create() only - ensure!( - !config.has_disabled_setting(CollectionSetting::DepositRequired), - Error::::WrongSetting - ); - - Self::do_create_collection( - collection, - owner.clone(), - admin.clone(), - config, - T::CollectionDeposit::get(), - Event::Created { - collection, - creator: owner, - owner: admin, - }, - ) + pallet_nfts::Pallet::::create(origin.clone(), id, who, Default::default()) } #[pallet::weight({0})] #[pallet::call_index(4)] pub fn mint(origin: OriginFor, id: u32, mint_to: T::AccountId) -> DispatchResult { - let caller = ensure_signed(origin)?; - let mint_to = T::Lookup::lookup(mint_to)?; - let item_config = ItemConfig { - settings: Self::get_default_item_settings(&collection)?, - }; - - Self::do_mint( - collection, - item, - Some(caller.clone()), - mint_to.clone(), - item_config, - |collection_details, collection_config| { - let mint_settings = collection_config.mint_settings; - let now = frame_system::Pallet::::block_number(); - - if let Some(start_block) = mint_settings.start_block { - ensure!(start_block <= now, Error::::MintNotStarted); - } - if let Some(end_block) = mint_settings.end_block { - ensure!(end_block >= now, Error::::MintEnded); - } - - match mint_settings.mint_type { - MintType::Issuer => { - ensure!( - Self::has_role(&collection, &caller, CollectionRole::Issuer), - Error::::NoPermission - ); - } - MintType::HolderOf(collection_id) => { - let MintWitness { owned_item } = - witness_data.ok_or(Error::::BadWitness)?; - - let owns_item = Account::::contains_key(( - &caller, - &collection_id, - &owned_item, - )); - ensure!(owns_item, Error::::BadWitness); - - let pallet_attribute = - PalletAttributes::::UsedToClaim(collection); - - let key = ( - &collection_id, - Some(owned_item), - AttributeNamespace::Pallet, - &Self::construct_attribute_key(pallet_attribute.encode())?, - ); - let already_claimed = Attribute::::contains_key(key.clone()); - ensure!(!already_claimed, Error::::AlreadyClaimed); - - let attribute_value = Self::construct_attribute_value(vec![])?; - Attribute::::insert( - key, - ( - attribute_value.clone(), - AttributeDeposit { - account: None, - amount: Zero::zero(), - }, - ), - ); - Self::deposit_event(Event::PalletAttributeSet { - collection, - item: Some(item), - attribute: pallet_attribute, - value: attribute_value, - }); - } - _ => {} - } - - if let Some(price) = mint_settings.price { - T::Currency::transfer( - &caller, - &collection_details.owner, - price, - ExistenceRequirement::KeepAlive, - )?; - } - - Ok(()) - }, - ) + let who = ensure_signed(origin)?; + pallet_nfts::Pallet::::mint(origin.clone(), id, 0, who, None) } #[pallet::weight({0})] #[pallet::call_index(5)] pub fn set_metadata(origin: OriginFor, id: u32, data: Vec) -> DispatchResult { - let maybe_check_origin = T::ForceOrigin::try_origin(origin) - .map(|_| None) - .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; - Self::do_set_item_metadata(maybe_check_origin, collection, item, data, None) + let who = ensure_signed(origin)?; + pallet_nfts::Pallet::::set_metadata(origin.clone(), id, 0, None) } } } - -// impl Pallet { - -// } From c262e4f586f2ebd73362d782135e81cc204f489d Mon Sep 17 00:00:00 2001 From: Smith Li Date: Mon, 22 Apr 2024 23:00:13 +0800 Subject: [PATCH 08/11] add testcase --- pallet/psp37/src/lib.rs | 194 +++++++++++++++++++++------------- pallet/psp37/src/mock.rs | 121 ++++++++++----------- pallet/psp37/src/tests.rs | 104 +++++++++++++++++- runtime/brooklyn/src/lib.rs | 5 + runtime/brooklyn/src/psp37.rs | 5 + 5 files changed, 285 insertions(+), 144 deletions(-) create mode 100644 runtime/brooklyn/src/psp37.rs diff --git a/pallet/psp37/src/lib.rs b/pallet/psp37/src/lib.rs index e7b8150a..a3e5939d 100644 --- a/pallet/psp37/src/lib.rs +++ b/pallet/psp37/src/lib.rs @@ -1,106 +1,114 @@ #![cfg_attr(not(feature = "std"), no_std)] -#![feature(slice_pattern)] -#![allow(clippy::unused_unit)] - -use frame_support::{ - ensure, - pallet_prelude::DispatchResult, - sp_std::{convert::TryInto, prelude::*}, - traits::{Currency, ExistenceRequirement::AllowDeath, Get, ReservableCurrency}, - PalletId, RuntimeDebug, +#![recursion_limit = "256"] +#[cfg(test)] +pub mod mock; +#[cfg(test)] +pub mod tests; + +// use cumulus_pallet_xcm::Origin as CumulusOrigin; +pub use frame_support::traits::Currency; +use frame_system::{ + ensure_signed, + pallet_prelude::{BlockNumberFor, OriginFor}, }; - -use sp_runtime::traits::{CheckedAdd, CheckedSub, StaticLookup}; - -use frame_system::pallet_prelude::*; -use scale_codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; -use sp_runtime::{traits::One, DispatchError}; - -use frame_support::{ - sp_runtime::traits::AccountIdConversion, - traits::{ - fungibles::{Balanced, Mutate}, - tokens::Preservation, - }, -}; - -use pallet_nfts::{CollectionSetting, NextCollectionId}; - -// #[cfg(test)] -// mod mock; -// #[cfg(test)] -// mod tests; +pub use pallet::*; +use pallet_nfts::{CollectionConfig, CollectionSettings, MintSettings}; + +use scale_info::prelude::{vec, vec::Vec}; +pub use sp_runtime::traits::{StaticLookup, Zero}; +type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; +// pub use xcm::prelude::*; +pub type BalanceOf = <>::Currency as Currency< + ::AccountId, +>>::Balance; + +pub type CollectionConfigFor = pallet_nfts::CollectionConfig< + BalanceOf, + BlockNumberFor, + >::CollectionId, +>; #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::{ - dispatch::DispatchResultWithPostInfo, - pallet_prelude::{ValueQuery, *}, - Blake2_128Concat, - }; - - pub type BalanceOf = <>::Currency as Currency< - ::AccountId, - >>::Balance; - + use frame_support::pallet_prelude::*; + use sp_runtime::DispatchResult; /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); #[pallet::pallet] + #[pallet::without_storage_info] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData<(T, I)>); + /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] /// The module configuration trait. - pub trait Config: frame_system::Config + pallet_nfts::Config { - /// The overarching event type. + pub trait Config: frame_system::Config + pallet_nfts::Config { + /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::storage] #[pallet::getter(fn native_asset_id)] - pub type NativeAssetId, I: 'static = ()> = StorageValue<_, u32, ValueQuery>; + pub type DefaultItemId, I: 'static = ()> = StorageValue<_, T::ItemId, OptionQuery>; #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { - NativeWithdrawed { amount: BalanceOf }, + /// Approved + Approved, } + // Errors inform users that something went wrong. #[pallet::error] pub enum Error { - OrderIndexOverflow, + // Default item id not exist + DefaultItemIdNotExist, + // From account Id not equ origin + FromIdNotEquOrigin, } - // #[pallet::hooks] - // impl, I: 'static> Hooks> for Pallet {} - #[pallet::call] impl, I: 'static> Pallet { #[pallet::weight({0})] #[pallet::call_index(0)] pub fn approve( origin: OriginFor, - id: u32, - operator: T::AccountId, - value: BalanceOf, - ) -> DispatchResultWithPostInfo { - pallet_nfts::Pallet::::approve_transfer(origin.clone(), id, 0, operator, None) + operator: AccountIdLookupOf, + id: T::CollectionId, + _value: BalanceOf, + ) -> DispatchResult { + let _who = ensure_signed(origin.clone())?; + + let item_id = DefaultItemId::::get(); + ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); + + pallet_nfts::Pallet::::approve_transfer( + origin.clone(), + id, + item_id.unwrap(), + operator, + None, + ) } #[pallet::weight({0})] #[pallet::call_index(1)] pub fn transfer( origin: OriginFor, - to: T::AccountId, - id: u32, - value: BalanceOf, - data: Vec, - ) -> DispatchResultWithPostInfo { - pallet_nfts::Pallet::::transfer(origin.clone(), id, 0, to) + to: AccountIdLookupOf, + id: T::CollectionId, + _value: BalanceOf, + _data: Vec, + ) -> DispatchResult { + let _who = ensure_signed(origin.clone())?; + + let item_id = DefaultItemId::::get(); + ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); + + pallet_nfts::Pallet::::transfer(origin.clone(), id, item_id.unwrap(), to) } #[pallet::weight({0})] @@ -108,34 +116,68 @@ pub mod pallet { pub fn transfer_from( origin: OriginFor, from: T::AccountId, - to: T::AccountId, - id: u32, - value: BalanceOf, - data: Vec, - ) -> DispatchResultWithPostInfo { - pallet_nfts::Pallet::::transfer(origin.clone(), id, 0, to) + to: AccountIdLookupOf, + id: T::CollectionId, + _value: BalanceOf, + _data: Vec, + ) -> DispatchResult { + let who = ensure_signed(origin.clone())?; + + ensure!(who == from, Error::::FromIdNotEquOrigin); + + let item_id = DefaultItemId::::get(); + ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); + + pallet_nfts::Pallet::::transfer(origin.clone(), id, item_id.unwrap(), to) } #[pallet::weight({0})] #[pallet::call_index(3)] - pub fn create(origin: OriginFor, id: u32) -> DispatchResult { - let who = ensure_signed(origin)?; - - pallet_nfts::Pallet::::create(origin.clone(), id, who, Default::default()) + pub fn create_id(origin: OriginFor, owner: AccountIdLookupOf) -> DispatchResult { + let _who = ensure_signed(origin.clone())?; + + let item_id = DefaultItemId::::get(); + ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); + + pallet_nfts::Pallet::::create( + origin.clone(), + owner, + CollectionConfig { + settings: CollectionSettings::all_enabled(), + max_supply: None, + mint_settings: MintSettings::default(), + }, + ) } #[pallet::weight({0})] #[pallet::call_index(4)] - pub fn mint(origin: OriginFor, id: u32, mint_to: T::AccountId) -> DispatchResult { - let who = ensure_signed(origin)?; - pallet_nfts::Pallet::::mint(origin.clone(), id, 0, who, None) + pub fn mint( + origin: OriginFor, + id: T::CollectionId, + mint_to: AccountIdLookupOf, + ) -> DispatchResult { + let _who = ensure_signed(origin.clone())?; + + let item_id = DefaultItemId::::get(); + ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); + + pallet_nfts::Pallet::::mint(origin.clone(), id, item_id.unwrap(), mint_to, None) } #[pallet::weight({0})] #[pallet::call_index(5)] - pub fn set_metadata(origin: OriginFor, id: u32, data: Vec) -> DispatchResult { - let who = ensure_signed(origin)?; - pallet_nfts::Pallet::::set_metadata(origin.clone(), id, 0, None) + pub fn set_metadata( + origin: OriginFor, + id: T::CollectionId, + data: BoundedVec>::StringLimit>, + ) -> DispatchResult { + let _who = ensure_signed(origin.clone())?; + + let item_id = DefaultItemId::::get(); + ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); + + pallet_nfts::Pallet::::set_metadata(origin.clone(), id, item_id.unwrap(), data) } } } diff --git a/pallet/psp37/src/mock.rs b/pallet/psp37/src/mock.rs index 596bc407..16fbec30 100644 --- a/pallet/psp37/src/mock.rs +++ b/pallet/psp37/src/mock.rs @@ -1,19 +1,26 @@ -use crate as pallet_dex; +use crate as pallet_psp37; use frame_support::{ - pallet_prelude::Weight, - parameter_types, sp_io, - traits::{AsEnsureOriginWithArg, GenesisBuild, Hooks}, + pallet_prelude::Weight, parameter_types, sp_io, traits::AsEnsureOriginWithArg, weights::constants::RocksDbWeight, - PalletId, }; +use frame_system::EnsureSigned; +use pallet_nfts::PalletFeatures; use sp_core::{ConstU128, ConstU32, ConstU64, H256}; -use sp_runtime::{testing::Header, traits::IdentityLookup}; +use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32, MultiSignature}; -pub type AccountId = u128; +pub const ALICE: AccountId32 = AccountId32::new([0u8; 32]); +pub const BOB: AccountId32 = AccountId32::new([1u8; 32]); +pub const CHARLIE: AccountId32 = AccountId32::new([2u8; 32]); + +pub const INITIAL_BALANCE: u128 = 1_000_000_000; + +pub type AccountId = AccountId32; pub type Balance = u128; pub type AssetId = u32; +pub type Signature = MultiSignature; + type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -26,8 +33,9 @@ frame_support::construct_runtime!( System: frame_system, Balances: pallet_balances, Timestamp: pallet_timestamp, - Assets: pallet_assets, - Dex: pallet_dex, + Assets: pallet_assets, + Nfts: pallet_nfts, + Psp37: pallet_psp37, } ); @@ -123,15 +131,47 @@ impl pallet_timestamp::Config for Test { } parameter_types! { - pub const DexPalletId: PalletId = PalletId(*b"py/sudex"); + pub const CollectionDeposit: Balance = 100; + pub const ItemDeposit: Balance = 1 ; + pub const KeyLimit: u32 = 32; + pub const ValueLimit: u32 = 256; + pub const ApprovalsLimit: u32 = 20; + pub const ItemAttributesApprovalsLimit: u32 = 20; + pub const MaxTips: u32 = 10; + + pub Features: PalletFeatures = PalletFeatures::all_enabled(); + pub const MaxAttributesPerCall: u32 = 10; } -impl pallet_dex::Config for Test { +impl pallet_nfts::Config for Test { type RuntimeEvent = RuntimeEvent; - type PalletId = DexPalletId; - type Fungibles = Assets; - type PrivilegedOrigin = frame_system::EnsureRoot; + type CollectionId = u32; + type ItemId = u32; type Currency = Balances; + type ForceOrigin = frame_system::EnsureRoot; + type CollectionDeposit = CollectionDeposit; + type ItemDeposit = ItemDeposit; + type MetadataDepositBase = MetadataDepositBase; + type AttributeDepositBase = MetadataDepositBase; + type DepositPerByte = MetadataDepositPerByte; + type StringLimit = AssetsStringLimit; + type KeyLimit = KeyLimit; + type ValueLimit = ValueLimit; + type ApprovalsLimit = ApprovalsLimit; + type ItemAttributesApprovalsLimit = ItemAttributesApprovalsLimit; + type MaxTips = MaxTips; + type MaxDeadlineDuration = (); + type MaxAttributesPerCall = MaxAttributesPerCall; + type Features = Features; + type OffchainSignature = Signature; + type OffchainPublic = ::Signer; + type WeightInfo = (); + type CreateOrigin = AsEnsureOriginWithArg>; + type Locker = (); +} + +impl pallet_psp37::Config for Test { + type RuntimeEvent = RuntimeEvent; } pub struct ExtBuilder; @@ -148,47 +188,11 @@ impl ExtBuilder { .build_storage::() .unwrap(); - // This will cause some initial issuance pallet_balances::GenesisConfig:: { - balances: vec![(1, 9000), (2, 800)], - } - .assimilate_storage(&mut storage) - .ok(); - - pallet_assets::GenesisConfig:: { - assets: vec![ - // id, owner, is_sufficient, min_balance - (999, 0, true, 1), - (888, 0, true, 1), - (777, 0, true, 1), - ], - metadata: vec![ - // id, name, symbol, decimals - (999, "Bitcoin".into(), "BTC".into(), 10), - (888, "GGxchain".into(), "GGXT".into(), 18), - (777, "USDT".into(), "USDT".into(), 10), - ], - accounts: vec![ - // id, account_id, balance - (999, 1, 1000), - (888, 1, 1000), - (777, 1, 1000), - (999, 2, 1000), - (888, 2, 1000), - (777, 2, 1000), - ], + balances: vec![(ALICE, INITIAL_BALANCE)], } .assimilate_storage(&mut storage) - .ok(); - - >::assimilate_storage( - &pallet_dex::GenesisConfig { - asset_ids: vec![8888, 999, 888, 777], - native_asset_id: 8888, - }, - &mut storage, - ) - .unwrap(); + .unwrap(); let mut ext = sp_io::TestExternalities::new(storage); ext.execute_with(|| System::set_block_number(1)); @@ -199,16 +203,3 @@ impl ExtBuilder { pub fn new_test_ext() -> sp_io::TestExternalities { ExtBuilder::default().build() } - -pub fn run_to_block(n: u64) { - while System::block_number() < n { - if System::block_number() > 0 { - Dex::on_finalize(System::block_number()); - System::on_finalize(System::block_number()); - } - System::reset_events(); - System::set_block_number(System::block_number() + 1); - System::on_initialize(System::block_number()); - Dex::on_initialize(System::block_number()); - } -} diff --git a/pallet/psp37/src/tests.rs b/pallet/psp37/src/tests.rs index e6a67edc..90abba03 100644 --- a/pallet/psp37/src/tests.rs +++ b/pallet/psp37/src/tests.rs @@ -1,9 +1,107 @@ use super::{pallet::Error, *}; -use frame_support::{assert_noop, assert_ok}; +use frame_support::{assert_noop, assert_ok, BoundedVec}; use mock::*; #[test] -fn test_deposit() { +fn test_create_id() { new_test_ext().execute_with(|| { + assert_noop!( + Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE), + Error::::DefaultItemIdNotExist + ); + + DefaultItemId::::put(0); + + assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); + }) +} + +#[test] +fn test_mint() { + new_test_ext().execute_with(|| { + DefaultItemId::::put(0); + + assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); + assert_ok!(Psp37::mint(RuntimeOrigin::signed(ALICE), 0, ALICE)); + }) +} + +#[test] +fn test_approve() { + new_test_ext().execute_with(|| { + DefaultItemId::::put(0); + + assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); + assert_ok!(Psp37::mint(RuntimeOrigin::signed(ALICE), 0, ALICE)); + + assert_noop!( + Psp37::approve(RuntimeOrigin::signed(CHARLIE), BOB, 0, 1), + pallet_nfts::Error::::NoPermission + ); + + assert_ok!(Psp37::approve(RuntimeOrigin::signed(ALICE), BOB, 0, 1)); + }) +} + +#[test] +fn test_transfer() { + new_test_ext().execute_with(|| { + DefaultItemId::::put(0); + + assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); + assert_ok!(Psp37::mint(RuntimeOrigin::signed(ALICE), 0, ALICE)); + + assert_ok!(Psp37::transfer( + RuntimeOrigin::signed(ALICE), + BOB, + 0, + 0, + vec![] + )); + }) +} + +#[test] +fn test_transfer_from() { + new_test_ext().execute_with(|| { + DefaultItemId::::put(0); + + assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); + assert_ok!(Psp37::mint(RuntimeOrigin::signed(ALICE), 0, ALICE)); + + assert_ok!(Psp37::approve(RuntimeOrigin::signed(ALICE), BOB, 0, 1)); + + assert_noop!( + Psp37::transfer_from(RuntimeOrigin::signed(CHARLIE), ALICE, BOB, 0, 1, vec![]), + Error::::FromIdNotEquOrigin + ); + + assert_noop!( + Psp37::transfer_from(RuntimeOrigin::signed(CHARLIE), CHARLIE, BOB, 0, 1, vec![]), + pallet_nfts::Error::::NoPermission + ); + + assert_ok!(Psp37::transfer_from( + RuntimeOrigin::signed(BOB), + BOB, + CHARLIE, + 0, + 1, + vec![] + )); + }) +} + +#[test] +fn test_set_metadata() { + new_test_ext().execute_with(|| { + DefaultItemId::::put(0); + + assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); + assert_ok!(Psp37::mint(RuntimeOrigin::signed(ALICE), 0, ALICE)); + + let data: BoundedVec = vec![1, 2, 3].try_into().unwrap(); + + assert_ok!(Psp37::set_metadata(RuntimeOrigin::signed(ALICE), 0, data)); }) -} \ No newline at end of file +} diff --git a/runtime/brooklyn/src/lib.rs b/runtime/brooklyn/src/lib.rs index 409e872e..4d285754 100644 --- a/runtime/brooklyn/src/lib.rs +++ b/runtime/brooklyn/src/lib.rs @@ -25,6 +25,7 @@ mod ink; pub mod light_client; pub mod pos; mod prelude; +pub mod psp37; mod version; pub use version::VERSION; @@ -715,6 +716,10 @@ construct_runtime!( // Dex Dex: pallet_dex, + + // Psp37 + Psp37: pallet_psp37, + } ); diff --git a/runtime/brooklyn/src/psp37.rs b/runtime/brooklyn/src/psp37.rs new file mode 100644 index 00000000..89b2b147 --- /dev/null +++ b/runtime/brooklyn/src/psp37.rs @@ -0,0 +1,5 @@ +use crate::{prelude::*, Assets}; + +impl pallet_psp37::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} From 29dab579c5c5684f76155159b0f46cb0c32593f0 Mon Sep 17 00:00:00 2001 From: Smith Li Date: Tue, 23 Apr 2024 19:13:07 +0800 Subject: [PATCH 09/11] update nft string limit --- runtime/brooklyn/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/brooklyn/src/lib.rs b/runtime/brooklyn/src/lib.rs index 4d285754..7872d267 100644 --- a/runtime/brooklyn/src/lib.rs +++ b/runtime/brooklyn/src/lib.rs @@ -583,6 +583,8 @@ parameter_types! { pub Features: PalletFeatures = PalletFeatures::all_enabled(); pub const MaxAttributesPerCall: u32 = 10; + + pub const NftsStringLimit: u32 = 256; } impl pallet_nfts::Config for Runtime { @@ -596,7 +598,7 @@ impl pallet_nfts::Config for Runtime { type MetadataDepositBase = MetadataDepositBase; type AttributeDepositBase = MetadataDepositBase; type DepositPerByte = MetadataDepositPerByte; - type StringLimit = StringLimit; + type StringLimit = NftsStringLimit; type KeyLimit = KeyLimit; type ValueLimit = ValueLimit; type ApprovalsLimit = ApprovalsLimit; From 8b915d5bc6261b97dee91ba5cbe7dac6e09c87c5 Mon Sep 17 00:00:00 2001 From: Smith Li Date: Wed, 24 Apr 2024 18:54:25 +0800 Subject: [PATCH 10/11] 1 add deposit_event 2 add init_default_item_id --- Cargo.lock | 66 ++++++------- Cargo.toml | 64 ++++++------- pallet/psp37/src/lib.rs | 172 ++++++++++++++++++++++++++++++---- pallet/psp37/src/tests.rs | 27 ++++-- runtime/brooklyn/src/psp37.rs | 2 +- 5 files changed, 240 insertions(+), 91 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c18312e9..0f71027e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -174,7 +174,7 @@ dependencies = [ [[package]] name = "annuity" version = "1.0.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-benchmarking", "frame-support", @@ -1035,7 +1035,7 @@ dependencies = [ [[package]] name = "bitcoin" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "bitcoin 0.30.2", "bitcoin_hashes 0.7.6", @@ -1340,7 +1340,7 @@ checksum = "bd769563b4ea2953e2825c9e6b7470a5f55f67e0be00030bf3e390a2a6071f64" [[package]] name = "btc-relay" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "bitcoin 1.2.0", "frame-benchmarking", @@ -1360,7 +1360,7 @@ dependencies = [ [[package]] name = "btc-relay-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "btc-relay-rpc-runtime-api", "jsonrpsee", @@ -1373,7 +1373,7 @@ dependencies = [ [[package]] name = "btc-relay-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-support", "parity-scale-codec", @@ -1722,7 +1722,7 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "clients-info" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "fixed-hash 0.7.0", "frame-benchmarking", @@ -2207,7 +2207,7 @@ dependencies = [ [[package]] name = "currency" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-support", "frame-system", @@ -2974,7 +2974,7 @@ dependencies = [ [[package]] name = "escrow" version = "1.0.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-benchmarking", "frame-support", @@ -3838,7 +3838,7 @@ dependencies = [ [[package]] name = "fee" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "currency", "frame-benchmarking", @@ -5958,7 +5958,7 @@ dependencies = [ [[package]] name = "interbtc-primitives" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "bitcoin 1.2.0", "bstringify", @@ -6035,7 +6035,7 @@ dependencies = [ [[package]] name = "issue" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -6067,7 +6067,7 @@ dependencies = [ [[package]] name = "issue-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "issue-rpc-runtime-api", "jsonrpsee", @@ -6080,7 +6080,7 @@ dependencies = [ [[package]] name = "issue-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-support", "parity-scale-codec", @@ -7035,7 +7035,7 @@ checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "loans" version = "1.9.3" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "currency", "frame-benchmarking", @@ -7850,7 +7850,7 @@ dependencies = [ [[package]] name = "nomination" version = "0.5.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "currency", "fee", @@ -8194,7 +8194,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "oracle" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "currency", "frame-benchmarking", @@ -8217,7 +8217,7 @@ dependencies = [ [[package]] name = "oracle-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -8230,7 +8230,7 @@ dependencies = [ [[package]] name = "oracle-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-support", "interbtc-primitives", @@ -10948,7 +10948,7 @@ dependencies = [ [[package]] name = "redeem" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -10978,7 +10978,7 @@ dependencies = [ [[package]] name = "redeem-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10991,7 +10991,7 @@ dependencies = [ [[package]] name = "redeem-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-support", "parity-scale-codec", @@ -11119,7 +11119,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "replace" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -11149,7 +11149,7 @@ dependencies = [ [[package]] name = "replace-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11162,7 +11162,7 @@ dependencies = [ [[package]] name = "replace-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-support", "parity-scale-codec", @@ -11226,7 +11226,7 @@ dependencies = [ [[package]] name = "reward" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-benchmarking", "frame-support", @@ -11246,7 +11246,7 @@ dependencies = [ [[package]] name = "reward-rpc" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -11260,7 +11260,7 @@ dependencies = [ [[package]] name = "reward-rpc-runtime-api" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-support", "oracle-rpc-runtime-api", @@ -13293,7 +13293,7 @@ dependencies = [ [[package]] name = "security" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-benchmarking", "frame-support", @@ -15380,7 +15380,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staking" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-benchmarking", "frame-support", @@ -16895,7 +16895,7 @@ checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" [[package]] name = "traits" version = "1.9.3" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-support", "frame-system", @@ -17399,7 +17399,7 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vault-registry" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "bitcoin 1.2.0", "currency", @@ -17432,7 +17432,7 @@ dependencies = [ [[package]] name = "vault-registry-rpc" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -17446,7 +17446,7 @@ dependencies = [ [[package]] name = "vault-registry-rpc-runtime-api" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?branch=polkadot-v0.9.43#fb0433e19d3f560b248f133c28ee0c0635e30ac0" +source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" dependencies = [ "frame-support", "oracle-rpc-runtime-api", diff --git a/Cargo.toml b/Cargo.toml index a3f535d2..300fbf12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -261,40 +261,40 @@ orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-li orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "28a2e6f0df9540d91db4018c7ecebb8bfc217a2a", default-features = false } # BTC bridge -annuity = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -bitcoin = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -btc-relay = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -clients-info = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -escrow = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -fee = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -interbtc-currency = { package = "currency", git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -issue = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -loans = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -nomination = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -oracle = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -primitives = { package = "interbtc-primitives", git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -redeem = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -replace = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -reward = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -security = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -staking = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -vault-registry = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +annuity = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +bitcoin = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +btc-relay = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +clients-info = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +escrow = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +fee = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +interbtc-currency = { package = "currency", git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +issue = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +loans = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +nomination = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +oracle = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +primitives = { package = "interbtc-primitives", git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +redeem = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +replace = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +reward = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +security = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +staking = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +vault-registry = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -btc-relay-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -issue-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -oracle-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -redeem-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -replace-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -reward-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -vault-registry-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +btc-relay-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +issue-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +oracle-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +redeem-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +replace-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +reward-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +vault-registry-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -btc-relay-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -issue-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -oracle-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -redeem-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -replace-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -reward-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } -vault-registry-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "8d931104", default-features = false } +btc-relay-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +issue-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +oracle-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +redeem-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +replace-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +reward-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +vault-registry-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } # Dex pallet-dex = { path = "pallet/dex", default-features = false } diff --git a/pallet/psp37/src/lib.rs b/pallet/psp37/src/lib.rs index a3e5939d..81cd6266 100644 --- a/pallet/psp37/src/lib.rs +++ b/pallet/psp37/src/lib.rs @@ -12,9 +12,12 @@ use frame_system::{ pallet_prelude::{BlockNumberFor, OriginFor}, }; pub use pallet::*; -use pallet_nfts::{CollectionConfig, CollectionSettings, MintSettings}; +use pallet_nfts::{ + CollectionConfig, CollectionSettings, Incrementable, MintSettings, NextCollectionId, +}; use scale_info::prelude::{vec, vec::Vec}; +use sp_runtime::traits::One; pub use sp_runtime::traits::{StaticLookup, Zero}; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; // pub use xcm::prelude::*; @@ -57,8 +60,45 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { - /// Approved - Approved, + /// An `item` of a `id` has been approved by the `owner` for transfer by + /// a `operator`. + Approval { + owner: T::AccountId, + operator: AccountIdLookupOf, + id: T::CollectionId, + value: BalanceOf, + }, + + /// An `item` was transferred. + Transfer { + from: T::AccountId, + to: AccountIdLookupOf, + id: T::CollectionId, + value: BalanceOf, + }, + + /// A `token id` was created. + Created { + id: T::CollectionId, + creator: T::AccountId, + owner: AccountIdLookupOf, + }, + + /// `token value` was issued. + Issued { + id: T::CollectionId, + owner: AccountIdLookupOf, + value: BalanceOf, + }, + + /// New metadata has been set for an item. + MetadataSet { + id: T::CollectionId, + data: BoundedVec, + }, + + /// set default item id + DefaultItemIdSet { id: T::ItemId }, } // Errors inform users that something went wrong. @@ -68,6 +108,8 @@ pub mod pallet { DefaultItemIdNotExist, // From account Id not equ origin FromIdNotEquOrigin, + // Default item had init + DefaultItemIdHadInited, } #[pallet::call] @@ -78,20 +120,31 @@ pub mod pallet { origin: OriginFor, operator: AccountIdLookupOf, id: T::CollectionId, - _value: BalanceOf, + value: BalanceOf, ) -> DispatchResult { - let _who = ensure_signed(origin.clone())?; + let owner = ensure_signed(origin.clone())?; let item_id = DefaultItemId::::get(); ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); - pallet_nfts::Pallet::::approve_transfer( + let rt = pallet_nfts::Pallet::::approve_transfer( origin.clone(), id, item_id.unwrap(), - operator, + operator.clone(), None, - ) + )?; + + if rt == () { + Self::deposit_event(Event::Approval { + owner, + operator, + id, + value, + }); + } + + Ok(rt) } #[pallet::weight({0})] @@ -100,15 +153,31 @@ pub mod pallet { origin: OriginFor, to: AccountIdLookupOf, id: T::CollectionId, - _value: BalanceOf, + value: BalanceOf, _data: Vec, ) -> DispatchResult { - let _who = ensure_signed(origin.clone())?; + let from = ensure_signed(origin.clone())?; let item_id = DefaultItemId::::get(); ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); - pallet_nfts::Pallet::::transfer(origin.clone(), id, item_id.unwrap(), to) + let rt = pallet_nfts::Pallet::::transfer( + origin.clone(), + id, + item_id.unwrap(), + to.clone(), + )?; + + if rt == () { + Self::deposit_event(Event::Transfer { + from, + to, + id, + value, + }); + } + + Ok(rt) } #[pallet::weight({0})] @@ -118,7 +187,7 @@ pub mod pallet { from: T::AccountId, to: AccountIdLookupOf, id: T::CollectionId, - _value: BalanceOf, + value: BalanceOf, _data: Vec, ) -> DispatchResult { let who = ensure_signed(origin.clone())?; @@ -128,26 +197,49 @@ pub mod pallet { let item_id = DefaultItemId::::get(); ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); - pallet_nfts::Pallet::::transfer(origin.clone(), id, item_id.unwrap(), to) + let rt = pallet_nfts::Pallet::::transfer( + origin.clone(), + id, + item_id.unwrap(), + to.clone(), + )?; + + if rt == () { + Self::deposit_event(Event::Transfer { + from, + to, + id, + value, + }); + } + + Ok(rt) } #[pallet::weight({0})] #[pallet::call_index(3)] pub fn create_id(origin: OriginFor, owner: AccountIdLookupOf) -> DispatchResult { - let _who = ensure_signed(origin.clone())?; + let creator = ensure_signed(origin.clone())?; + let id = NextCollectionId::::get().unwrap_or(T::CollectionId::initial_value()); let item_id = DefaultItemId::::get(); ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); - pallet_nfts::Pallet::::create( + let rt = pallet_nfts::Pallet::::create( origin.clone(), - owner, + owner.clone(), CollectionConfig { settings: CollectionSettings::all_enabled(), max_supply: None, mint_settings: MintSettings::default(), }, - ) + )?; + + if rt == () { + Self::deposit_event(Event::Created { id, creator, owner }); + } + + Ok(rt) } #[pallet::weight({0})] @@ -162,7 +254,23 @@ pub mod pallet { let item_id = DefaultItemId::::get(); ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); - pallet_nfts::Pallet::::mint(origin.clone(), id, item_id.unwrap(), mint_to, None) + let rt = pallet_nfts::Pallet::::mint( + origin.clone(), + id, + item_id.unwrap(), + mint_to.clone(), + None, + )?; + + if rt == () { + Self::deposit_event(Event::Issued { + id, + owner: mint_to, + value: One::one(), + }); + } + + Ok(rt) } #[pallet::weight({0})] @@ -177,7 +285,33 @@ pub mod pallet { let item_id = DefaultItemId::::get(); ensure!(item_id.is_some(), Error::::DefaultItemIdNotExist); - pallet_nfts::Pallet::::set_metadata(origin.clone(), id, item_id.unwrap(), data) + let rt = pallet_nfts::Pallet::::set_metadata( + origin.clone(), + id, + item_id.unwrap(), + data.clone(), + )?; + + if rt == () { + Self::deposit_event(Event::MetadataSet { id, data }); + } + + Ok(rt) + } + + #[pallet::weight({0})] + #[pallet::call_index(6)] + pub fn init_default_item_id(origin: OriginFor, id: T::ItemId) -> DispatchResult { + let _who = ensure_signed(origin.clone())?; + + let item_id = DefaultItemId::::get(); + ensure!(item_id.is_none(), Error::::DefaultItemIdHadInited); + + DefaultItemId::::put(id); + + Self::deposit_event(Event::DefaultItemIdSet { id }); + + Ok(()) } } } diff --git a/pallet/psp37/src/tests.rs b/pallet/psp37/src/tests.rs index 90abba03..e380bb56 100644 --- a/pallet/psp37/src/tests.rs +++ b/pallet/psp37/src/tests.rs @@ -10,7 +10,7 @@ fn test_create_id() { Error::::DefaultItemIdNotExist ); - DefaultItemId::::put(0); + assert_ok!(Psp37::init_default_item_id(RuntimeOrigin::signed(ALICE), 0)); assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); }) @@ -19,7 +19,7 @@ fn test_create_id() { #[test] fn test_mint() { new_test_ext().execute_with(|| { - DefaultItemId::::put(0); + assert_ok!(Psp37::init_default_item_id(RuntimeOrigin::signed(ALICE), 0)); assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); assert_ok!(Psp37::mint(RuntimeOrigin::signed(ALICE), 0, ALICE)); @@ -29,7 +29,7 @@ fn test_mint() { #[test] fn test_approve() { new_test_ext().execute_with(|| { - DefaultItemId::::put(0); + assert_ok!(Psp37::init_default_item_id(RuntimeOrigin::signed(ALICE), 0)); assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); assert_ok!(Psp37::mint(RuntimeOrigin::signed(ALICE), 0, ALICE)); @@ -46,7 +46,7 @@ fn test_approve() { #[test] fn test_transfer() { new_test_ext().execute_with(|| { - DefaultItemId::::put(0); + assert_ok!(Psp37::init_default_item_id(RuntimeOrigin::signed(ALICE), 0)); assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); assert_ok!(Psp37::mint(RuntimeOrigin::signed(ALICE), 0, ALICE)); @@ -64,7 +64,7 @@ fn test_transfer() { #[test] fn test_transfer_from() { new_test_ext().execute_with(|| { - DefaultItemId::::put(0); + assert_ok!(Psp37::init_default_item_id(RuntimeOrigin::signed(ALICE), 0)); assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); assert_ok!(Psp37::mint(RuntimeOrigin::signed(ALICE), 0, ALICE)); @@ -95,7 +95,7 @@ fn test_transfer_from() { #[test] fn test_set_metadata() { new_test_ext().execute_with(|| { - DefaultItemId::::put(0); + assert_ok!(Psp37::init_default_item_id(RuntimeOrigin::signed(ALICE), 0)); assert_ok!(Psp37::create_id(RuntimeOrigin::signed(ALICE), ALICE)); assert_ok!(Psp37::mint(RuntimeOrigin::signed(ALICE), 0, ALICE)); @@ -105,3 +105,18 @@ fn test_set_metadata() { assert_ok!(Psp37::set_metadata(RuntimeOrigin::signed(ALICE), 0, data)); }) } + +#[test] +fn test_set_default_item_id() { + new_test_ext().execute_with(|| { + assert_ok!(Psp37::init_default_item_id(RuntimeOrigin::signed(ALICE), 0)); + + let item_id = DefaultItemId::::get(); + assert_eq!(item_id, Some(0)); + + assert_noop!( + Psp37::init_default_item_id(RuntimeOrigin::signed(ALICE), 0), + Error::::DefaultItemIdHadInited + ); + }) +} diff --git a/runtime/brooklyn/src/psp37.rs b/runtime/brooklyn/src/psp37.rs index 89b2b147..83e4ffed 100644 --- a/runtime/brooklyn/src/psp37.rs +++ b/runtime/brooklyn/src/psp37.rs @@ -1,4 +1,4 @@ -use crate::{prelude::*, Assets}; +use crate::prelude::*; impl pallet_psp37::Config for Runtime { type RuntimeEvent = RuntimeEvent; From 6057af667adce0ad3ac100165fc8a91d54c6f791 Mon Sep 17 00:00:00 2001 From: Li Smith Date: Mon, 6 May 2024 20:20:54 +0800 Subject: [PATCH 11/11] update interbtc rev --- Cargo.lock | 66 +++++++++---------- Cargo.toml | 64 +++++++++--------- .../runtime-common/src/weights/btc_relay.rs | 2 +- 3 files changed, 66 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f71027e..01b655b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -174,7 +174,7 @@ dependencies = [ [[package]] name = "annuity" version = "1.0.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-benchmarking", "frame-support", @@ -1035,7 +1035,7 @@ dependencies = [ [[package]] name = "bitcoin" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "bitcoin 0.30.2", "bitcoin_hashes 0.7.6", @@ -1340,7 +1340,7 @@ checksum = "bd769563b4ea2953e2825c9e6b7470a5f55f67e0be00030bf3e390a2a6071f64" [[package]] name = "btc-relay" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "bitcoin 1.2.0", "frame-benchmarking", @@ -1360,7 +1360,7 @@ dependencies = [ [[package]] name = "btc-relay-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "btc-relay-rpc-runtime-api", "jsonrpsee", @@ -1373,7 +1373,7 @@ dependencies = [ [[package]] name = "btc-relay-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-support", "parity-scale-codec", @@ -1722,7 +1722,7 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "clients-info" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "fixed-hash 0.7.0", "frame-benchmarking", @@ -2207,7 +2207,7 @@ dependencies = [ [[package]] name = "currency" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-support", "frame-system", @@ -2974,7 +2974,7 @@ dependencies = [ [[package]] name = "escrow" version = "1.0.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-benchmarking", "frame-support", @@ -3838,7 +3838,7 @@ dependencies = [ [[package]] name = "fee" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "currency", "frame-benchmarking", @@ -5958,7 +5958,7 @@ dependencies = [ [[package]] name = "interbtc-primitives" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "bitcoin 1.2.0", "bstringify", @@ -6035,7 +6035,7 @@ dependencies = [ [[package]] name = "issue" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -6067,7 +6067,7 @@ dependencies = [ [[package]] name = "issue-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "issue-rpc-runtime-api", "jsonrpsee", @@ -6080,7 +6080,7 @@ dependencies = [ [[package]] name = "issue-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-support", "parity-scale-codec", @@ -7035,7 +7035,7 @@ checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "loans" version = "1.9.3" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "currency", "frame-benchmarking", @@ -7850,7 +7850,7 @@ dependencies = [ [[package]] name = "nomination" version = "0.5.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "currency", "fee", @@ -8194,7 +8194,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "oracle" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "currency", "frame-benchmarking", @@ -8217,7 +8217,7 @@ dependencies = [ [[package]] name = "oracle-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -8230,7 +8230,7 @@ dependencies = [ [[package]] name = "oracle-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-support", "interbtc-primitives", @@ -10948,7 +10948,7 @@ dependencies = [ [[package]] name = "redeem" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -10978,7 +10978,7 @@ dependencies = [ [[package]] name = "redeem-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10991,7 +10991,7 @@ dependencies = [ [[package]] name = "redeem-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-support", "parity-scale-codec", @@ -11119,7 +11119,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "replace" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "bitcoin 1.2.0", "btc-relay", @@ -11149,7 +11149,7 @@ dependencies = [ [[package]] name = "replace-rpc" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11162,7 +11162,7 @@ dependencies = [ [[package]] name = "replace-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-support", "parity-scale-codec", @@ -11226,7 +11226,7 @@ dependencies = [ [[package]] name = "reward" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-benchmarking", "frame-support", @@ -11246,7 +11246,7 @@ dependencies = [ [[package]] name = "reward-rpc" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -11260,7 +11260,7 @@ dependencies = [ [[package]] name = "reward-rpc-runtime-api" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-support", "oracle-rpc-runtime-api", @@ -13293,7 +13293,7 @@ dependencies = [ [[package]] name = "security" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-benchmarking", "frame-support", @@ -15380,7 +15380,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staking" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-benchmarking", "frame-support", @@ -16895,7 +16895,7 @@ checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" [[package]] name = "traits" version = "1.9.3" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-support", "frame-system", @@ -17399,7 +17399,7 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vault-registry" version = "1.2.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "bitcoin 1.2.0", "currency", @@ -17432,7 +17432,7 @@ dependencies = [ [[package]] name = "vault-registry-rpc" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "jsonrpsee", "oracle-rpc-runtime-api", @@ -17446,7 +17446,7 @@ dependencies = [ [[package]] name = "vault-registry-rpc-runtime-api" version = "0.3.0" -source = "git+https://github.com/ggxchain/interbtc.git?rev=9f76825a#9f76825ae90084bd15d422e9176da8be97da8f93" +source = "git+https://github.com/ggxchain/interbtc.git?rev=1074d1b7#1074d1b70be897a0abb2fd0545064cfc6e96f9c7" dependencies = [ "frame-support", "oracle-rpc-runtime-api", diff --git a/Cargo.toml b/Cargo.toml index 300fbf12..d43cfa9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -261,40 +261,40 @@ orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-li orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "28a2e6f0df9540d91db4018c7ecebb8bfc217a2a", default-features = false } # BTC bridge -annuity = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -bitcoin = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -btc-relay = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -clients-info = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -escrow = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -fee = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -interbtc-currency = { package = "currency", git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -issue = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -loans = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -nomination = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -oracle = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -primitives = { package = "interbtc-primitives", git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -redeem = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -replace = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -reward = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -security = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -staking = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -vault-registry = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +annuity = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +bitcoin = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +btc-relay = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +clients-info = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +escrow = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +fee = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +interbtc-currency = { package = "currency", git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +issue = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +loans = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +nomination = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +oracle = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +primitives = { package = "interbtc-primitives", git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +redeem = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +replace = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +reward = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +security = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +staking = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +vault-registry = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } -btc-relay-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -issue-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -oracle-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -redeem-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -replace-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -reward-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -vault-registry-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +btc-relay-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +issue-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +oracle-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +redeem-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +replace-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +reward-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +vault-registry-rpc = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } -btc-relay-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -issue-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -oracle-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -redeem-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -replace-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -reward-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } -vault-registry-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "9f76825a", default-features = false } +btc-relay-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +issue-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +oracle-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +redeem-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +replace-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +reward-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } +vault-registry-rpc-runtime-api = { git = "https://github.com/ggxchain/interbtc.git", rev = "1074d1b7", default-features = false } # Dex pallet-dex = { path = "pallet/dex", default-features = false } diff --git a/runtime/runtime-common/src/weights/btc_relay.rs b/runtime/runtime-common/src/weights/btc_relay.rs index e3776c72..ad5bd501 100644 --- a/runtime/runtime-common/src/weights/btc_relay.rs +++ b/runtime/runtime-common/src/weights/btc_relay.rs @@ -95,7 +95,7 @@ impl btc_relay::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().writes(5_u64)) } - fn update_store_utxo () -> Weight { + fn update_store_utxo_to_spent () -> Weight { // Proof Size summary in bytes: // Measured: `874` // Estimated: `6340`