difftreelog
feat add propose-fast-track (#1022)
in: master
* feat: add propose-fast-track * fix: propose-upgrade * fix: fasttrack preimage
3 files changed
tests/package.jsondiffbeforeafterboth1{2 "name": "unique-tests",3 "version": "1.0.0",4 "description": "Unique Chain Tests",5 "main": "",6 "devDependencies": {7 "@polkadot/typegen": "10.10.1",8 "@types/chai": "^4.3.3",9 "@types/chai-as-promised": "^7.1.5",10 "@types/chai-like": "^1.1.1",11 "@types/chai-subset": "^1.3.3",12 "@types/mocha": "^10.0.0",13 "@types/node": "^20.4.2",14 "@typescript-eslint/eslint-plugin": "^6.0.0",15 "@typescript-eslint/parser": "^6.0.0",16 "chai": "^4.3.6",17 "chai-subset": "^1.6.0",18 "eslint": "^8.45.0",19 "eslint-plugin-mocha": "^10.1.0",20 "mocha": "^10.1.0",21 "mochawesome": "^7.1.3",22 "ts-node": "^10.9.1",23 "typescript": "^5.1.6"24 },25 "mocha": {26 "timeout": 9999999,27 "require": [28 "ts-node/register"29 ]30 },31 "scripts": {32 "lint": "eslint --ext .ts,.js src/",33 "fix": "yarn lint --fix",34 "setup": "ts-node --esm ./src/util/globalSetup.ts",35 "setIdentities": "ts-node --esm ./src/util/identitySetter.ts",36 "checkRelayIdentities": "ts-node --esm ./src/util/relayIdentitiesChecker.ts",37 "frankenstein": "ts-node --esm ./src/util/frankenstein.ts",38 "_test": "yarn setup && mocha --timeout 9999999 --loader=ts-node/esm.mjs",39 "_testParallel": "yarn setup && mocha --timeout 9999999 --parallel --loader=ts-node/esm.mjs",40 "test": "yarn _test './src/**/*.*test.ts'",41 "testParallelFull": "yarn testParallel && yarn testSequential",42 "testParallel": "yarn _testParallel './src/**/*.test.ts'",43 "testSequential": "yarn _test './src/**/*.seqtest.ts'",44 "testStructure": "yarn _test ./**/nesting/*.*test.ts",45 "testGovernance": "RUN_GOV_TESTS=1 yarn _test ./**/governance/*.*test.ts",46 "testEth": "yarn _test './**/eth/**/*.*test.ts'",47 "testEthNesting": "yarn _test './**/eth/nesting/**/*.*test.ts'",48 "testEthFractionalizer": "yarn _test './**/eth/fractionalizer/**/*.*test.ts'",49 "testEthMarketplace": "yarn _test './**/eth/marketplace/**/*.*test.ts'",50 "testEthMarket": "yarn _test './**/eth/marketplace-v2/**/*.*test.ts'",51 "testPerformance": "yarn _test ./**/performance.*test.ts",52 "testSub": "yarn _test './**/sub/**/*.*test.ts'",53 "testSubNesting": "yarn _test './**/sub/nesting/**/*.*test.ts'",54 "testEvent": "yarn _test ./src/check-event/*.*test.ts",55 "testEthPayable": "yarn _test './**/eth/payable.test.ts'",56 "testEvmCoder": "yarn _test './**/eth/evmCoder.test.ts'",57 "testNesting": "yarn _test ./**/nest.test.ts",58 "testUnnesting": "yarn _test ./**/unnest.test.ts",59 "testProperties": "yarn _test ./**/collectionProperties.*test.ts ./**/tokenProperties.*test.ts ./**/getPropertiesRpc.test.ts",60 "testCollectionProperties": "yarn _test ./**/collectionProperties.*test.ts",61 "testTokenProperties": "yarn _test ./**/tokenProperties.*test.ts",62 "testMigration": "yarn _test ./**/nesting/migration-check.test.ts",63 "testAddCollectionAdmin": "yarn _test ./**/addCollectionAdmin.test.ts",64 "testSetCollectionLimits": "yarn _test ./**/setCollectionLimits.test.ts",65 "testChangeCollectionOwner": "yarn _test ./**/change-collection-owner.test.ts",66 "testSetCollectionSponsor": "yarn _test ./**/setCollectionSponsor.test.ts",67 "testConfirmSponsorship": "yarn _test ./**/confirmSponsorship.test.ts",68 "testRemoveCollectionAdmin": "yarn _test ./**/removeCollectionAdmin.test.ts",69 "testRemoveCollectionSponsor": "yarn _test ./**/removeCollectionSponsor.test.ts",70 "testAllowLists": "yarn _test ./**/allowLists.test.ts",71 "testConnection": "yarn _test ./**/connection.test.ts",72 "testContracts": "yarn _test ./**/contracts.test.ts",73 "testCreateItem": "yarn _test ./**/createItem.test.ts",74 "testCreateMultipleItems": "yarn _test ./**/createMultipleItems.test.ts",75 "testCreateMultipleItemsEx": "yarn _test ./**/createMultipleItemsEx.test.ts",76 "testApprove": "yarn _test ./**/approve.test.ts",77 "testTransferFrom": "yarn _test ./**/transferFrom.test.ts",78 "testCreateCollection": "yarn _test ./**/createCollection.test.ts",79 "testDestroyCollection": "yarn _test ./**/destroyCollection.test.ts",80 "testToggleContractAllowList": "yarn _test ./**/toggleContractAllowList.test.ts",81 "testAddToContractAllowList": "yarn _test ./**/addToContractAllowList.test.ts",82 "testTransfer": "yarn _test ./**/transfer.test.ts",83 "testBurnItem": "yarn _test ./**/burnItem.test.ts",84 "testAdminTransferAndBurn": "yarn _test ./**/adminTransferAndBurn.test.ts",85 "testSetPermissions": "yarn _test ./**/setPermissions.test.ts",86 "testCreditFeesToTreasury": "yarn _test ./**/creditFeesToTreasury.seqtest.ts",87 "testContractSponsoring": "yarn _test ./**/eth/contractSponsoring.test.ts",88 "testEnableContractSponsoring": "yarn _test ./**/enableContractSponsoring.test.ts",89 "testRemoveFromContractAllowList": "yarn _test ./**/removeFromContractAllowList.test.ts",90 "testSetContractSponsoringRateLimit": "yarn _test ./**/setContractSponsoringRateLimit.test.ts",91 "testSetOffchainSchema": "yarn _test ./**/setOffchainSchema.test.ts",92 "testNextSponsoring": "yarn _test ./**/nextSponsoring.test.ts",93 "testOverflow": "yarn _test ./**/overflow.test.ts",94 "testMaintenance": "yarn _test ./**/maintenance.seqtest.ts",95 "testInflation": "yarn _test ./**/inflation.seqtest.ts",96 "testScheduler": "yarn _test ./**/scheduler.seqtest.ts",97 "testSchedulingEVM": "yarn _test ./**/eth/scheduling.test.ts",98 "testPalletPresence": "yarn _test ./**/pallet-presence.test.ts",99 "testEnableDisableTransfers": "yarn _test ./**/enableDisableTransfer.test.ts",100 "testLimits": "yarn _test ./**/limits.test.ts",101 "testEthCreateNFTCollection": "yarn _test ./**/eth/createNFTCollection.test.ts",102 "testEthCreateRFTCollection": "yarn _test ./**/eth/createRFTCollection.test.ts",103 "testEthNFT": "yarn _test ./**/eth/nonFungible.test.ts",104 "testRFT": "yarn _test ./**/refungible.test.ts",105 "testEthRFT": "yarn _test ./**/eth/reFungible.test.ts ./**/eth/reFungibleToken.test.ts",106 "testFT": "yarn _test ./**/fungible.test.ts",107 "testEthFT": "yarn _test ./**/eth/fungible.test.ts",108 "testRPC": "yarn _test ./**/rpc.test.ts",109 "testPromotion": "yarn _test ./**/appPromotion/*test.ts",110 "testApiConsts": "yarn _test ./**/apiConsts.test.ts",111 "testCouncil": "yarn _test ./**/council.*test.ts",112 "testDemocracy": "yarn _test ./**/democracy.*test.ts",113 "testCollators": "RUN_COLLATOR_TESTS=1 yarn _test ./**/collator-selection/**.*test.ts --timeout 49999999",114 "testCollatorSelection": "RUN_COLLATOR_TESTS=1 yarn _test ./**/collatorSelection.*test.ts --timeout 49999999",115 "testIdentity": "RUN_COLLATOR_TESTS=1 yarn _test ./**/identity.*test.ts --timeout 49999999",116 "testLowLevelXcmUnique": "RUN_XCM_TESTS=1 yarn _test ./**/xcm/lowLevelXcmUnique.test.ts",117 "testXcmUnique": "RUN_XCM_TESTS=1 yarn _test ./**/xcm/xcmUnique.test.ts",118 "testFullXcmUnique": "RUN_XCM_TESTS=1 yarn _test ./**/xcm/*Unique.test.ts",119 "testXcmQuartz": "RUN_XCM_TESTS=1 yarn _test ./**/xcm/xcmQuartz.test.ts",120 "testLowLevelXcmQuartz": "RUN_XCM_TESTS=1 yarn _test ./**/xcm/lowLevelXcmQuartz.test.ts",121 "testFullXcmQuartz": "RUN_XCM_TESTS=1 yarn _test ./**/xcm/*Quartz.test.ts",122 "testXcmOpal": "RUN_XCM_TESTS=1 yarn _test ./**/xcm/xcmOpal.test.ts",123 "testXcmTransferAcala": "yarn _test ./**/xcm/xcmTransferAcala.test.ts acalaId=2000 uniqueId=5000",124 "testXcmTransferStatemine": "yarn _test ./**/xcm/xcmTransferStatemine.test.ts statemineId=1000 uniqueId=5000",125 "testXcmTransferMoonbeam": "yarn _test ./**/xcm/xcmTransferMoonbeam.test.ts",126 "benchMintingFee": "ts-node src/benchmarks/mintFee/benchmark.ts",127 "load": "yarn _test './**/*.load.ts'",128 "loadTransfer": "ts-node src/transfer.nload.ts",129 "polkadot-types-fetch-metadata": "yarn ts-node --esm src/fetchMetadata.ts",130 "polkadot-types-from-defs": "ts-node --esm ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .",131 "polkadot-types-from-chain": "ts-node --esm ./node_modules/.bin/polkadot-types-from-chain --endpoint src/interfaces/metadata.json --output src/interfaces/ --package .",132 "polkadot-types": "echo \"export default {}\" > src/interfaces/lookup.ts && yarn polkadot-types-fetch-metadata && yarn polkadot-types-from-defs && yarn polkadot-types-from-defs && yarn polkadot-types-from-chain",133 "generateEnv": "ts-node --esm ./src/generateEnv.ts",134 "propose-upgrade": "ts-node --esm ./src/proposeupgrade.ts",135 "propose-fast-track": "ts-node --esm ./src/proposefasttrack.ts"136 },137 "author": "",138 "license": "SEE LICENSE IN ../LICENSE",139 "homepage": "",140 "dependencies": {141 "@openzeppelin/contracts": "^4.9.2",142 "@polkadot/api": "10.10.1",143 "@polkadot/rpc-core": "^10.10.1",144 "@polkadot/util": "12.5.1",145 "@polkadot/util-crypto": "12.5.1",146 "@polkadot/wasm-crypto-asmjs": "^7.2.2",147 "@polkadot/wasm-crypto-wasm": "^7.2.2",148 "@rmrk-team/evm-contracts": "^1.2.1",149 "@typechain/web3-v1": "^6.0.3",150 "chai-as-promised": "^7.1.1",151 "chai-like": "^1.1.1",152 "csv-writer": "^1.6.0",153 "find-process": "^1.4.7",154 "lossless-json": "^2.0.9",155 "solc": "0.8.20",156 "typechain": "^8.2.0",157 "web3": "1.10.0"158 },159 "resolutions": {160 "decode-uri-component": "^0.2.1"161 },162 "type": "module",163 "packageManager": "yarn@3.6.1"164}tests/src/proposefasttrack.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/proposefasttrack.ts
@@ -0,0 +1,42 @@
+import {ApiPromise, WsProvider} from '@polkadot/api';
+import {blake2AsHex} from '@polkadot/util-crypto';
+
+async function main() {
+ const networkUrl = process.argv[2];
+
+ const wsProvider = new WsProvider(networkUrl);
+ const api = await ApiPromise.create({provider: wsProvider});
+
+ const externalDemocracyProposal = (await api.query.democracy.nextExternal() as any).unwrap()[0];
+
+ let proposalHash;
+ if(externalDemocracyProposal.isInline) {
+ proposalHash = blake2AsHex(externalDemocracyProposal.asInline, 256);
+ } else if(externalDemocracyProposal.isLegacy) {
+ proposalHash = externalDemocracyProposal.asLegacy.toJSON().hash;
+ } else {
+ proposalHash = externalDemocracyProposal.asLookup.toJSON().hash;
+ }
+
+ const voringPeriod = 7200;
+ const delay = 10;
+
+ const democracyFastTrack = api.tx.democracy.fastTrack(proposalHash, voringPeriod, delay);
+
+ const techCommThreshold = ((await api.query.technicalCommittee.members()).toJSON() as any[]).length;
+ const techCommProposal = api.tx.technicalCommittee.propose(
+ techCommThreshold,
+ democracyFastTrack.method.toHex(),
+ democracyFastTrack.encodedLength,
+ );
+
+ const encodedCall = techCommProposal.method.toHex();
+
+ console.log('-----------------');
+ console.log('Fast Track Proposal: ', `https://polkadot.js.org/apps/?rpc=${networkUrl}#/extrinsics/decode/${encodedCall}`);
+ console.log('-----------------');
+
+ await api.disconnect();
+}
+
+await main();
tests/src/proposeupgrade.tsdiffbeforeafterboth--- a/tests/src/proposeupgrade.ts
+++ b/tests/src/proposeupgrade.ts
@@ -18,20 +18,30 @@
const councilMembers = (await api.query.council.members()).toJSON() as any[];
const councilProposalThreshold = Math.floor(councilMembers.length / 2) + 1;
+ const democracyProposalContent = api.tx.utility.batchAll([
+ authorizeUpgrade.method.toHex(),
+ enableMaintenance.method.toHex(),
+ ]).method.toHex();
+
+ const democracyProposalHash = blake2AsHex(democracyProposalContent, 256);
+ const democracyProposalPreimage = api.tx.preimage.notePreimage(democracyProposalContent).method.toHex();
+
const democracyProposal = api.tx.democracy.externalProposeDefault({
- Inline: api.tx.utility.batchAll([
- authorizeUpgrade.method.toHex(),
- enableMaintenance.method.toHex(),
- ]).method.toHex(),
+ Legacy: democracyProposalHash,
});
const councilProposal = api.tx.council.propose(
councilProposalThreshold,
democracyProposal,
democracyProposal.method.encodedLength,
- );
+ ).method.toHex();
- const encodedCall = councilProposal.method.toHex();
+ const proposeUpgradeBatch = api.tx.utility.batchAll([
+ democracyProposalPreimage,
+ councilProposal,
+ ]);
+
+ const encodedCall = proposeUpgradeBatch.method.toHex();
console.log('-----------------');
console.log('Upgrade Proposal: ', `https://polkadot.js.org/apps/?rpc=${networkUrl}#/extrinsics/decode/${encodedCall}`);