git.delta.rocks / unique-network / refs/commits / 867eaa10a099

difftreelog

Merge pull request #993 from UniqueNetwork/fix/governance-with-batch

Yaroslav Bolyukin2023-09-13parents: #e089f01 #e0258a2.patch.diff
in: master
Fix/governance with batch

10 files changed

modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -119,6 +119,7 @@
 pallet-state-trie-migration = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
 pallet-sudo = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
 pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
+pallet-utility = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
 pallet-transaction-payment = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
 pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
 pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
modifiedruntime/common/config/governance/technical_committee.rsdiffbeforeafterboth
--- a/runtime/common/config/governance/technical_committee.rs
+++ b/runtime/common/config/governance/technical_committee.rs
@@ -38,7 +38,7 @@
 	type RemoveOrigin = RootOrMoreThanHalfCouncil;
 	type SwapOrigin = RootOrMoreThanHalfCouncil;
 	type ResetOrigin = EnsureRoot<AccountId>;
-	type PrimeOrigin = EnsureRoot<AccountId>;
+	type PrimeOrigin = RootOrMoreThanHalfCouncil;
 	type MembershipInitialized = TechnicalCommittee;
 	type MembershipChanged = TechnicalCommittee;
 	type MaxMembers = TechnicalMaxMembers;
modifiedruntime/common/config/substrate.rsdiffbeforeafterboth
--- a/runtime/common/config/substrate.rs
+++ b/runtime/common/config/substrate.rs
@@ -35,8 +35,8 @@
 };
 use pallet_transaction_payment::{Multiplier, ConstFeeMultiplier};
 use crate::{
-	runtime_common::DealWithFees, Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, PalletInfo,
-	System, Balances, SS58Prefix, Version,
+	runtime_common::DealWithFees, Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, OriginCaller,
+	PalletInfo, System, Balances, SS58Prefix, Version,
 };
 use up_common::{types::*, constants::*};
 use sp_std::vec;
@@ -248,3 +248,10 @@
 	type DisabledValidators = ();
 	type MaxAuthorities = MaxAuthorities;
 }
+
+impl pallet_utility::Config for Runtime {
+	type RuntimeEvent = RuntimeEvent;
+	type RuntimeCall = RuntimeCall;
+	type PalletsOrigin = OriginCaller;
+	type WeightInfo = pallet_utility::weights::SubstrateWeight<Self>;
+}
modifiedruntime/common/construct_runtime.rsdiffbeforeafterboth
--- a/runtime/common/construct_runtime.rs
+++ b/runtime/common/construct_runtime.rs
@@ -136,6 +136,8 @@
 
 				BalancesAdapter: pallet_balances_adapter = 155,
 
+				Utility: pallet_utility = 156,
+
 				#[cfg(feature = "pallet-test-utils")]
 				TestUtils: pallet_test_utils = 255,
 			}
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -58,6 +58,7 @@
 	'pallet-refungible/runtime-benchmarks',
 	'pallet-structure/runtime-benchmarks',
 	'pallet-timestamp/runtime-benchmarks',
+	'pallet-utility/runtime-benchmarks',
 	'pallet-unique-scheduler-v2/runtime-benchmarks',
 	'pallet-unique/runtime-benchmarks',
 	'pallet-xcm/runtime-benchmarks',
@@ -120,6 +121,7 @@
 	'pallet-structure/std',
 	'pallet-sudo/std',
 	'pallet-timestamp/std',
+	'pallet-utility/std',
 	'pallet-transaction-payment-rpc-runtime-api/std',
 	'pallet-transaction-payment/std',
 	'pallet-treasury/std',
@@ -213,6 +215,7 @@
 	'pallet-sudo/try-runtime',
 	'pallet-test-utils?/try-runtime',
 	'pallet-timestamp/try-runtime',
+	'pallet-utility/try-runtime',
 	'pallet-transaction-payment/try-runtime',
 	'pallet-treasury/try-runtime',
 	'pallet-unique-scheduler-v2/try-runtime',
@@ -263,6 +266,7 @@
 pallet-state-trie-migration = { workspace = true }
 pallet-sudo = { workspace = true }
 pallet-timestamp = { workspace = true }
+pallet-utility = { workspace = true }
 pallet-transaction-payment = { workspace = true }
 pallet-transaction-payment-rpc-runtime-api = { workspace = true }
 pallet-treasury = { workspace = true }
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -55,6 +55,7 @@
 	'pallet-scheduler/runtime-benchmarks',
 	'pallet-structure/runtime-benchmarks',
 	'pallet-timestamp/runtime-benchmarks',
+	'pallet-utility/runtime-benchmarks',
 	'pallet-unique/runtime-benchmarks',
 	'pallet-xcm/runtime-benchmarks',
 	'sp-runtime/runtime-benchmarks',
@@ -120,6 +121,7 @@
 	'pallet-structure/std',
 	'pallet-sudo/std',
 	'pallet-timestamp/std',
+	'pallet-utility/std',
 	'pallet-transaction-payment-rpc-runtime-api/std',
 	'pallet-transaction-payment/std',
 	'pallet-treasury/std',
@@ -203,6 +205,7 @@
 	'pallet-structure/try-runtime',
 	'pallet-sudo/try-runtime',
 	'pallet-timestamp/try-runtime',
+	'pallet-utility/try-runtime',
 	'pallet-transaction-payment/try-runtime',
 	'pallet-treasury/try-runtime',
 	'pallet-unique/try-runtime',
@@ -252,6 +255,7 @@
 pallet-state-trie-migration = { workspace = true }
 pallet-sudo = { workspace = true }
 pallet-timestamp = { workspace = true }
+pallet-utility = { workspace = true }
 pallet-transaction-payment = { workspace = true }
 pallet-transaction-payment-rpc-runtime-api = { workspace = true }
 pallet-treasury = { workspace = true }
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -52,6 +52,7 @@
 	'pallet-scheduler/runtime-benchmarks',
 	'pallet-structure/runtime-benchmarks',
 	'pallet-timestamp/runtime-benchmarks',
+	'pallet-utility/runtime-benchmarks',
 	'pallet-unique/runtime-benchmarks',
 	'pallet-xcm/runtime-benchmarks',
 	'sp-runtime/runtime-benchmarks',
@@ -118,6 +119,7 @@
 	'pallet-structure/std',
 	'pallet-sudo/std',
 	'pallet-timestamp/std',
+	'pallet-utility/std',
 	'pallet-transaction-payment-rpc-runtime-api/std',
 	'pallet-transaction-payment/std',
 	'pallet-treasury/std',
@@ -205,6 +207,7 @@
 	'pallet-structure/try-runtime',
 	'pallet-sudo/try-runtime',
 	'pallet-timestamp/try-runtime',
+	'pallet-utility/try-runtime',
 	'pallet-transaction-payment/try-runtime',
 	'pallet-treasury/try-runtime',
 	'pallet-unique/try-runtime',
@@ -255,6 +258,7 @@
 pallet-state-trie-migration = { workspace = true }
 pallet-sudo = { workspace = true }
 pallet-timestamp = { workspace = true }
+pallet-utility = { workspace = true }
 pallet-transaction-payment = { workspace = true }
 pallet-transaction-payment-rpc-runtime-api = { workspace = true }
 pallet-treasury = { workspace = true }
addedtests/src/governance/init.test.tsdiffbeforeafterboth

no changes

modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -27,6 +27,7 @@
   'statetriemigration',
   'structure',
   'system',
+  'utility',
   'vesting',
   'parachainsystem',
   'parachaininfo',
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -3255,8 +3255,8 @@
     return this.helper.executeExtrinsic(signer, `api.tx.${this.collective}.promoteMember`, [member]);
   }
 
-  promoteCall(newMember: string) {
-    return this.helper.constructApiCall(`api.tx.${this.collective}.promoteMember`, [newMember]);
+  promoteCall(member: string) {
+    return this.helper.constructApiCall(`api.tx.${this.collective}.promoteMember`, [member]);
   }
 
   demote(signer: TSigner, member: string) {
@@ -3275,6 +3275,10 @@
     return (await this.helper.getApi().query.fellowshipCollective.members.keys())
       .map((key) => key.args[0].toString());
   }
+
+  async getMemberRank(member: string) {
+    return (await this.helper.callRpc('api.query.fellowshipCollective.members', [member])).toJSON().rank;
+  }
 }
 
 class ReferendaGroup extends HelperGroup<UniqueHelper> {
@@ -3381,6 +3385,10 @@
     return this.helper.constructApiCall('api.tx.democracy.externalProposeDefault', [{Inline: proposalCall.method.toHex()}]);
   }
 
+  externalProposeDefaultWithPreimageCall(preimage: string) {
+    return this.helper.constructApiCall('api.tx.democracy.externalProposeDefault', [{Legacy: preimage}]);
+  }
+
   // ... and blacklist external proposal hash.
   vetoExternal(signer: TSigner, proposalHash: string) {
     return this.helper.executeExtrinsic(signer, 'api.tx.democracy.vetoExternal', [proposalHash]);
@@ -3733,6 +3741,20 @@
   }
 }
 
+class UtilityGroup<T extends ChainHelperBase> extends HelperGroup<T> {
+  async batch(signer: TSigner, txs: any[]) {
+    return await this.helper.executeExtrinsic(signer, 'api.tx.utility.batch', [txs]);
+  }
+
+  async batchAll(signer: TSigner, txs: any[]) {
+    return await this.helper.executeExtrinsic(signer, 'api.tx.utility.batchAll', [txs]);
+  }
+
+  batchAllCall(txs: any[]) {
+    return this.helper.constructApiCall('api.tx.utility.batchAll', [txs]);
+  }
+}
+
 class AcalaAssetRegistryGroup extends HelperGroup<AcalaHelper> {
   async registerForeignAsset(signer: TSigner, destination: any, metadata: AcalaAssetMetadata) {
     await this.helper.executeExtrinsic(signer, 'api.tx.assetRegistry.registerForeignAsset', [destination, metadata], true);
@@ -3835,6 +3857,7 @@
   xcm: XcmGroup<UniqueHelper>;
   xTokens: XTokensGroup<UniqueHelper>;
   tokens: TokensGroup<UniqueHelper>;
+  utility: UtilityGroup<UniqueHelper>;
 
   constructor(logger?: ILogger, options: { [key: string]: any } = {}) {
     super(logger, options.helperBase ?? UniqueHelper);
@@ -3865,6 +3888,7 @@
     this.xcm = new XcmGroup(this, 'polkadotXcm');
     this.xTokens = new XTokensGroup(this);
     this.tokens = new TokensGroup(this);
+    this.utility = new UtilityGroup(this);
   }
 
   getSudo<T extends UniqueHelper>() {