From 7ae20213cc2ca1efc674a7bc2e29e3938ccfb759 Mon Sep 17 00:00:00 2001 From: Rakan Al-Huneiti Date: Fri, 12 Jan 2024 17:38:03 +0300 Subject: [PATCH] Chainbridge constants fix (#231) ### Description Constant declarations were accidentally removed in #210 ### Types of Changes - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Dependency upgrade (A change in substrate or any 3rd party crate version) ### Migrations and Hooks - [ ] This change requires a runtime migration. - [ ] Modifies `on_initialize` - [ ] Modifies `on_finalize` ### Checklist - [x] Change has been tested locally. - [ ] Change adds / updates tests. - [ ] Changelog doc updated. --- pallets/chainbridge/src/lib.rs | 7 ++++++- pallets/chainbridge/src/mock.rs | 2 ++ pallets/erc20/src/lib.rs | 3 +++ runtime/cere-dev/src/lib.rs | 4 +++- runtime/cere/src/lib.rs | 2 ++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pallets/chainbridge/src/lib.rs b/pallets/chainbridge/src/lib.rs index a03bf2ee7..2b848939c 100644 --- a/pallets/chainbridge/src/lib.rs +++ b/pallets/chainbridge/src/lib.rs @@ -141,9 +141,14 @@ pub mod pallet { /// The identifier for this chain. /// This must be unique and must not collide with existing IDs within a set of bridged /// chains. + #[pallet::constant] type ChainId: Get; - type ProposalLifetime: Get; + #[pallet::constant] + type ProposalLifetime: Get<::BlockNumber>; + + #[pallet::constant] + type BridgeAccountId: Get; } /// All whitelisted chains and their respective transaction counts diff --git a/pallets/chainbridge/src/mock.rs b/pallets/chainbridge/src/mock.rs index c980befec..bb4f3c5b4 100644 --- a/pallets/chainbridge/src/mock.rs +++ b/pallets/chainbridge/src/mock.rs @@ -72,6 +72,7 @@ impl pallet_balances::Config for Test { parameter_types! { pub const TestChainId: u8 = 5; pub const ProposalLifetime: u64 = 50; + pub BridgeAccountId: u64 = AccountIdConversion::::into_account_truncating(&MODULE_ID); } impl crate::pallet::Config for Test { @@ -80,6 +81,7 @@ impl crate::pallet::Config for Test { type Proposal = RuntimeCall; type ChainId = TestChainId; type ProposalLifetime = ProposalLifetime; + type BridgeAccountId = BridgeAccountId; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/pallets/erc20/src/lib.rs b/pallets/erc20/src/lib.rs index 6d3b9f07f..5c2fee14a 100644 --- a/pallets/erc20/src/lib.rs +++ b/pallets/erc20/src/lib.rs @@ -41,8 +41,11 @@ pub mod pallet { type Currency: Currency; /// Ids can be defined by the runtime and passed in, perhaps from blake2b_128 hashes. + #[pallet::constant] type HashId: Get; + #[pallet::constant] type NativeTokenId: Get; + #[pallet::constant] type Erc721Id: Get; } diff --git a/runtime/cere-dev/src/lib.rs b/runtime/cere-dev/src/lib.rs index 402dc7f40..1733f3677 100644 --- a/runtime/cere-dev/src/lib.rs +++ b/runtime/cere-dev/src/lib.rs @@ -130,7 +130,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 48500, + spec_version: 48501, impl_version: 0, transaction_version: 10, apis: RUNTIME_API_VERSIONS, @@ -1226,6 +1226,7 @@ impl pallet_vesting::Config for Runtime { parameter_types! { pub const ChainId: u8 = 1; pub const ProposalLifetime: BlockNumber = 1000; + pub BridgeAccountId: AccountId = AccountIdConversion::::into_account_truncating(&pallet_chainbridge::MODULE_ID); } /// Configure the send data pallet @@ -1235,6 +1236,7 @@ impl pallet_chainbridge::Config for Runtime { type Proposal = RuntimeCall; type ChainId = ChainId; type ProposalLifetime = ProposalLifetime; + type BridgeAccountId = BridgeAccountId; } parameter_types! { diff --git a/runtime/cere/src/lib.rs b/runtime/cere/src/lib.rs index ce78fec8a..4e2be9717 100644 --- a/runtime/cere/src/lib.rs +++ b/runtime/cere/src/lib.rs @@ -1231,6 +1231,7 @@ impl pallet_vesting::Config for Runtime { parameter_types! { pub const ChainId: u8 = 1; pub const ProposalLifetime: BlockNumber = 1000; + pub BridgeAccountId: AccountId = AccountIdConversion::::into_account_truncating(&pallet_chainbridge::MODULE_ID); } /// Configure the send data pallet @@ -1240,6 +1241,7 @@ impl pallet_chainbridge::Config for Runtime { type Proposal = RuntimeCall; type ChainId = ChainId; type ProposalLifetime = ProposalLifetime; + type BridgeAccountId = BridgeAccountId; } parameter_types! {