From 0f79397d6ae28da58f88ebcca37f6b7ee97d2028 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan Date: Fri, 29 Sep 2023 20:49:39 +0100 Subject: [PATCH 1/4] works but errors out --- package.json | 4 +- .../ui/cypress/fixtures/knownMultisigs.ts | 9 + packages/ui/cypress/support/commands.ts | 21 ++ packages/ui/cypress/tests/transactions.cy.ts | 14 +- .../cypress/utils/rejectCurrentMultisigTxs.ts | 127 ++++++++++ .../ui/src/hooks/useGetEncodedAddress.tsx | 5 +- packages/ui/src/hooks/usePendingTx.tsx | 2 +- yarn.lock | 217 ++---------------- 8 files changed, 201 insertions(+), 198 deletions(-) create mode 100644 packages/ui/cypress/fixtures/knownMultisigs.ts create mode 100644 packages/ui/cypress/utils/rejectCurrentMultisigTxs.ts diff --git a/package.json b/package.json index bb846ec4..91d1996c 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,8 @@ "prettier": "^3.0.3" }, "resolutions": { - "graphql": "^16.0.0" + "graphql": "^16.0.0", + "@polkadot/util-crypto": "12.5.1", + "@polkadot/util": "12.5.1" } } diff --git a/packages/ui/cypress/fixtures/knownMultisigs.ts b/packages/ui/cypress/fixtures/knownMultisigs.ts new file mode 100644 index 00000000..740829d9 --- /dev/null +++ b/packages/ui/cypress/fixtures/knownMultisigs.ts @@ -0,0 +1,9 @@ +import { injectedAccounts } from './injectedAccounts' + +export const knownMultisigs = { + 'test-multisig-1': { + address: '5CmwqwwLEkEtsmB9gFaTJdCfurz33xyggHnvwHaGKtvmQNxq', + threshold: 2, + signatories: [injectedAccounts[0].address, injectedAccounts[1].address] + } +} diff --git a/packages/ui/cypress/support/commands.ts b/packages/ui/cypress/support/commands.ts index 6770cf30..a24acabf 100644 --- a/packages/ui/cypress/support/commands.ts +++ b/packages/ui/cypress/support/commands.ts @@ -1,6 +1,7 @@ /// import { AuthRequests, Extension, TxRequests } from './Extension' +import { MultisigInfo, rejectCurrentMultisigTxs } from '../utils/rejectCurrentMultisigTxs' import { InjectedAccountWitMnemonic } from '../fixtures/injectedAccounts' // *********************************************** @@ -77,6 +78,8 @@ Cypress.Commands.add('rejectTx', (id: number, reason: string) => { return extension.rejectTx(id, reason) }) +Cypress.Commands.add('rejectCurrentMultisigTx', rejectCurrentMultisigTxs) + declare global { namespace Cypress { interface Chainable { @@ -86,11 +89,13 @@ declare global { * @example cy.initExtension([{ address: '7NPoMQbiA6trJKkjB35uk96MeJD4PGWkLQLH7k7hXEkZpiba', name: 'Alice', type: 'sr25519'}]) */ initExtension: (accounts: InjectedAccountWitMnemonic[]) => Chainable + /** * Read the authentication request queue. * @example cy.getAuthRequests().then((authQueue) => { cy.wrap(Object.values(authQueue).length).should("eq", 1) }) */ getAuthRequests: () => Chainable + /** * Authorize a specific request * @param {number} id - the id of the request to authorize. This id is part of the getAuthRequests object response. @@ -98,6 +103,7 @@ declare global { * @example cy.enableAuth(1694443839903, ["7NPoMQbiA6trJKkjB35uk96MeJD4PGWkLQLH7k7hXEkZpiba"]) */ enableAuth: (id: number, accountAddresses: string[]) => void + /** * Reject a specific request * @param {number} id - the id of the request to reject. This id is part of the getAuthRequests object response. @@ -105,17 +111,20 @@ declare global { * @example cy.rejectAuth(1694443839903, "Cancelled") */ rejectAuth: (id: number, reason: string) => void + /** * Read the tx request queue. * @example cy.getTxRequests().then((txQueue) => { cy.wrap(Object.values(txQueue).length).should("eq", 1) }) */ getTxRequests: () => Chainable + /** * Authorize a specific request * @param {number} id - the id of the request to approve. This id is part of the getTxRequests object response. * @example cy.approveTx(1694443839903) */ approveTx: (id: number) => void + /** * Reject a specific request * @param {number} id - the id of the tx request to reject. This id is part of the getTxRequests object response. @@ -123,6 +132,18 @@ declare global { * @example cy.rejectAuth(1694443839903, "Cancelled") */ rejectTx: (id: number, reason: string) => void + + /** + * Reject all pending multisig requests with a specific account + * @param {number} id - + * @param {reason} reason - + * @example + */ + rejectCurrentMultisigTx: (opt: { + account: InjectedAccountWitMnemonic + multisigInfo: MultisigInfo + WSendpoint: string + }) => void } } } diff --git a/packages/ui/cypress/tests/transactions.cy.ts b/packages/ui/cypress/tests/transactions.cy.ts index 25d5a33b..a4aa55f7 100644 --- a/packages/ui/cypress/tests/transactions.cy.ts +++ b/packages/ui/cypress/tests/transactions.cy.ts @@ -1,4 +1,5 @@ import { injectedAccounts } from '../fixtures/injectedAccounts' +import { knownMultisigs } from '../fixtures/knownMultisigs' import { landingPageUrl } from '../fixtures/landingData' import { landingPage } from '../support/page-objects/landingPage' import { multisigPage } from '../support/page-objects/multisigPage' @@ -51,7 +52,18 @@ describe('Perform transactions', () => { }) }) - it.skip('Makes a balance transfer with Alice', () => { + it('Makes a balance transfer with Alice', () => { + cy.rejectCurrentMultisigTx({ + account: injectedAccounts[0], + multisigInfo: { + address: knownMultisigs['test-multisig-1'].address, + threshold: knownMultisigs['test-multisig-1'].threshold, + otherSignatories: knownMultisigs['test-multisig-1'].signatories.filter( + (address) => address !== injectedAccounts[0].address + ) + }, + WSendpoint: 'wss://rococo-rpc.polkadot.io' + }) multisigPage.newTransactionButton().click() sendTxModal.sendTxTitle().should('be.visible') fillAndSubmitTransactionForm() diff --git a/packages/ui/cypress/utils/rejectCurrentMultisigTxs.ts b/packages/ui/cypress/utils/rejectCurrentMultisigTxs.ts new file mode 100644 index 00000000..33830964 --- /dev/null +++ b/packages/ui/cypress/utils/rejectCurrentMultisigTxs.ts @@ -0,0 +1,127 @@ +import { cryptoWaitReady } from '@polkadot/util-crypto' +import { InjectedAccountWitMnemonic } from '../fixtures/injectedAccounts' +import { Keyring, WsProvider, ApiPromise } from '@polkadot/api' +import { MultisigStorageInfo } from '../../src/types' +import { PendingTx } from '../../src/hooks/usePendingTx' +import { SubmittableExtrinsic } from '@polkadot/api/types' +import { ISubmittableResult, AnyTuple, Codec } from '@polkadot/types/types' +import { StorageKey } from '@polkadot/types' + +export interface MultisigInfo { + address: string + otherSignatories: string[] + threshold: number +} +const callBack = + (resolve: (thenableOrResult?: unknown) => void) => + ({ status, txHash }: ISubmittableResult) => { + console.log('Transaction status:', status.type) + if (status.isBroadcast) { + console.log('Broadcasted', txHash.toHex()) + } + + if (status.isInBlock) { + console.log('In block') + } + + if (status.isFinalized) { + console.log('Finalized block hash', status.asFinalized.toHex()) + resolve() + } + } + +const getPendingMultisixTx = ( + multisigTxs: [StorageKey, Codec][], + multisigInfo: MultisigInfo +) => { + const curratedMultisigTxs: PendingTx[] = [] + + multisigTxs.forEach((storage) => { + // this is supposed to be the multisig address that we asked the storage for + const multisigFromChain = (storage[0].toHuman() as Array)[0] + const hash = (storage[0].toHuman() as Array)[1] + const info = storage[1].toJSON() as unknown as MultisigStorageInfo + + // Fix for ghost proposals for https://github.com/polkadot-js/apps/issues/9103 + // These 2 should be the same + if (multisigFromChain.toLowerCase() !== multisigInfo.address.toLowerCase()) { + console.error( + 'The onchain call and the one found in the block donot correspond', + multisigFromChain, + multisigInfo.address + ) + return + } + + curratedMultisigTxs.push({ + hash, + info, + from: multisigInfo.address + }) + }) + + return curratedMultisigTxs +} + +const getRejectionsTxs = ( + pendingMultisigTxs: PendingTx[], + account: InjectedAccountWitMnemonic, + multisigInfo: MultisigInfo, + api: ApiPromise +) => { + const allTxs: SubmittableExtrinsic<'promise', ISubmittableResult>[] = [] + pendingMultisigTxs.forEach((pendingMultisigTx) => { + const depositor = pendingMultisigTx.info.depositor + if (depositor !== account.address) { + console.log('multisig tx not proposed by the same account', depositor, account.address) + return + } + + const rejectCurrent = api.tx.multisig.cancelAsMulti( + multisigInfo.threshold, + multisigInfo.otherSignatories, + pendingMultisigTx.info.when, + pendingMultisigTx.hash + ) + allTxs.push(rejectCurrent) + }) + + return allTxs +} + +export const rejectCurrentMultisigTxs = ({ + account, + multisigInfo, + WSendpoint +}: { + account: InjectedAccountWitMnemonic + multisigInfo: MultisigInfo + WSendpoint: string +}) => { + return new Cypress.Promise(async (resolve) => { + await cryptoWaitReady() + + const keyring = new Keyring({ type: 'sr25519' }) + keyring.addFromMnemonic(account.mnemonic) + + const wsProvider = new WsProvider(WSendpoint) + const api = await ApiPromise.create({ provider: wsProvider }) + + const multisigTxs = await api.query.multisig.multisigs.entries(multisigInfo.address) + const pendingMultisigTxs = getPendingMultisixTx(multisigTxs, multisigInfo) + + if (!pendingMultisigTxs.length) { + console.log('no pending multisig tx for', multisigInfo.address) + resolve() + return + } + + console.log('pendingMultisigTxs', pendingMultisigTxs) + + const allTxs = getRejectionsTxs(pendingMultisigTxs, account, multisigInfo, api) + + console.log(`The multisig has ${allTxs.length} pending txs. Rejecting them now`) + + api.tx.utility.batchAll(allTxs).signAndSend(keyring.getPair(account.address), callBack(resolve)) + }) +} diff --git a/packages/ui/src/hooks/useGetEncodedAddress.tsx b/packages/ui/src/hooks/useGetEncodedAddress.tsx index 50547454..684d31b3 100644 --- a/packages/ui/src/hooks/useGetEncodedAddress.tsx +++ b/packages/ui/src/hooks/useGetEncodedAddress.tsx @@ -8,7 +8,10 @@ export const useGetEncodedAddress = () => { const getEncodedAddress = useCallback( (address: string | Uint8Array | undefined) => { - if (!chainInfo || !address) { + console.log('address', address) + + if (!chainInfo || !address || address === 'undefined') { + console.log('address return', address) return } diff --git a/packages/ui/src/hooks/usePendingTx.tsx b/packages/ui/src/hooks/usePendingTx.tsx index 92874123..674e1176 100644 --- a/packages/ui/src/hooks/usePendingTx.tsx +++ b/packages/ui/src/hooks/usePendingTx.tsx @@ -49,7 +49,7 @@ export const usePendingTx = (multiProxy?: MultiProxy) => { // These 2 should be the same if (multisigFromChain.toLowerCase() !== multisigs[index].toLowerCase()) { console.error( - 'The onchain call and the one found in the block donot correstpond', + 'The onchain call and the one found in the block donot correspond', multisigFromChain, multisigs[index] ) diff --git a/yarn.lock b/yarn.lock index 19f4cfbe..08032c4d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4485,15 +4485,6 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:1.1.0": - version: 1.1.0 - resolution: "@noble/curves@npm:1.1.0" - dependencies: - "@noble/hashes": 1.3.1 - checksum: 81115c3ebfa7e7da2d7e18d44d686f98dc6d35dbde3964412c05707c92d0994a01545bc265d5c0bc05c8c49333f75b99c9acef6750f5a79b3abcc8e0546acf88 - languageName: node - linkType: hard - "@noble/curves@npm:^1.2.0": version: 1.2.0 resolution: "@noble/curves@npm:1.2.0" @@ -4503,13 +4494,6 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.3.1": - version: 1.3.1 - resolution: "@noble/hashes@npm:1.3.1" - checksum: 86512713aaf338bced594bc2046ab249fea4e1ba1e7f2ecd02151ef1b8536315e788c11608fafe1b56f04fad1aa3c602da7e5f8e5fcd5f8b0aa94435fe65278e - languageName: node - linkType: hard - "@noble/hashes@npm:1.3.2, @noble/hashes@npm:^1.3.2": version: 1.3.2 resolution: "@noble/hashes@npm:1.3.2" @@ -4740,17 +4724,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/networks@npm:12.3.2, @polkadot/networks@npm:^12.3.1": - version: 12.3.2 - resolution: "@polkadot/networks@npm:12.3.2" - dependencies: - "@polkadot/util": 12.3.2 - "@substrate/ss58-registry": ^1.40.0 - tslib: ^2.5.3 - checksum: 580285fbeec56fe5a3a979f5393a379ecf0afe01a27d50029944b46fbbc6679edc084d6e346bdb171f6d68ad89830b85f3db1943d5fefa72c6cc4b98edaac685 - languageName: node - linkType: hard - "@polkadot/networks@npm:12.5.1, @polkadot/networks@npm:^12.5.1": version: 12.5.1 resolution: "@polkadot/networks@npm:12.5.1" @@ -4762,6 +4735,17 @@ __metadata: languageName: node linkType: hard +"@polkadot/networks@npm:^12.3.1": + version: 12.3.2 + resolution: "@polkadot/networks@npm:12.3.2" + dependencies: + "@polkadot/util": 12.3.2 + "@substrate/ss58-registry": ^1.40.0 + tslib: ^2.5.3 + checksum: 580285fbeec56fe5a3a979f5393a379ecf0afe01a27d50029944b46fbbc6679edc084d6e346bdb171f6d68ad89830b85f3db1943d5fefa72c6cc4b98edaac685 + languageName: node + linkType: hard + "@polkadot/react-identicon@npm:^3.6.3": version: 3.6.3 resolution: "@polkadot/react-identicon@npm:3.6.3" @@ -4970,27 +4954,7 @@ __metadata: languageName: node linkType: hard -"@polkadot/util-crypto@npm:12.3.2, @polkadot/util-crypto@npm:^12.3.1, @polkadot/util-crypto@npm:^12.3.2": - version: 12.3.2 - resolution: "@polkadot/util-crypto@npm:12.3.2" - dependencies: - "@noble/curves": 1.1.0 - "@noble/hashes": 1.3.1 - "@polkadot/networks": 12.3.2 - "@polkadot/util": 12.3.2 - "@polkadot/wasm-crypto": ^7.2.1 - "@polkadot/wasm-util": ^7.2.1 - "@polkadot/x-bigint": 12.3.2 - "@polkadot/x-randomvalues": 12.3.2 - "@scure/base": 1.1.1 - tslib: ^2.5.3 - peerDependencies: - "@polkadot/util": 12.3.2 - checksum: f594e84569cb86177b3ba40ba966a7197249f33590a48b925ff0b9cd17a43c3948a6200d955756f65ee97e231e5a9b3e5854021315655e010fb111d63d24c385 - languageName: node - linkType: hard - -"@polkadot/util-crypto@npm:12.5.1, @polkadot/util-crypto@npm:^12.5.1": +"@polkadot/util-crypto@npm:12.5.1": version: 12.5.1 resolution: "@polkadot/util-crypto@npm:12.5.1" dependencies: @@ -5010,22 +4974,7 @@ __metadata: languageName: node linkType: hard -"@polkadot/util@npm:12.3.2, @polkadot/util@npm:^12.3.1, @polkadot/util@npm:^12.3.2": - version: 12.3.2 - resolution: "@polkadot/util@npm:12.3.2" - dependencies: - "@polkadot/x-bigint": 12.3.2 - "@polkadot/x-global": 12.3.2 - "@polkadot/x-textdecoder": 12.3.2 - "@polkadot/x-textencoder": 12.3.2 - "@types/bn.js": ^5.1.1 - bn.js: ^5.2.1 - tslib: ^2.5.3 - checksum: 2772b0f373a50bdd7aaabb69c19006e757bf70559946a8bdecf44e01265a184fa4226ae901f87403f23fffd0eecc0203bdd16dd3fd8aa545b6abf1106942b5dc - languageName: node - linkType: hard - -"@polkadot/util@npm:12.5.1, @polkadot/util@npm:^12.5.1": +"@polkadot/util@npm:12.5.1": version: 12.5.1 resolution: "@polkadot/util@npm:12.5.1" dependencies: @@ -5040,19 +4989,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/wasm-bridge@npm:7.2.1": - version: 7.2.1 - resolution: "@polkadot/wasm-bridge@npm:7.2.1" - dependencies: - "@polkadot/wasm-util": 7.2.1 - tslib: ^2.5.0 - peerDependencies: - "@polkadot/util": "*" - "@polkadot/x-randomvalues": "*" - checksum: 836d0d03414ed4f4c57588cd0aae427e6a7ef6944e638e22d8d1505cde6cb3dca1bc7d8cf1bac0258f215d7d167aa882567db294989c8a9742e12008e35d463d - languageName: node - linkType: hard - "@polkadot/wasm-bridge@npm:7.2.2": version: 7.2.2 resolution: "@polkadot/wasm-bridge@npm:7.2.2" @@ -5066,17 +5002,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/wasm-crypto-asmjs@npm:7.2.1": - version: 7.2.1 - resolution: "@polkadot/wasm-crypto-asmjs@npm:7.2.1" - dependencies: - tslib: ^2.5.0 - peerDependencies: - "@polkadot/util": "*" - checksum: 99f170974785c04e5cad52f79fa830d66870fdcce6b4e06d8176b6cc8f9bf91b42be5dcf89669747d9db9ff5f9ced01febd1ce5f3d04fc9375707196715a3372 - languageName: node - linkType: hard - "@polkadot/wasm-crypto-asmjs@npm:7.2.2": version: 7.2.2 resolution: "@polkadot/wasm-crypto-asmjs@npm:7.2.2" @@ -5088,22 +5013,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/wasm-crypto-init@npm:7.2.1": - version: 7.2.1 - resolution: "@polkadot/wasm-crypto-init@npm:7.2.1" - dependencies: - "@polkadot/wasm-bridge": 7.2.1 - "@polkadot/wasm-crypto-asmjs": 7.2.1 - "@polkadot/wasm-crypto-wasm": 7.2.1 - "@polkadot/wasm-util": 7.2.1 - tslib: ^2.5.0 - peerDependencies: - "@polkadot/util": "*" - "@polkadot/x-randomvalues": "*" - checksum: 45a93e2ffd0bfb69d3e8c0b82d3856d69818ff9581d3012541ea9bf5dad56cfea33ecd2c9e7d02facad7fe519b62acb3aa1f8da1fba98039a853b40ae74b58c9 - languageName: node - linkType: hard - "@polkadot/wasm-crypto-init@npm:7.2.2": version: 7.2.2 resolution: "@polkadot/wasm-crypto-init@npm:7.2.2" @@ -5120,18 +5029,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/wasm-crypto-wasm@npm:7.2.1": - version: 7.2.1 - resolution: "@polkadot/wasm-crypto-wasm@npm:7.2.1" - dependencies: - "@polkadot/wasm-util": 7.2.1 - tslib: ^2.5.0 - peerDependencies: - "@polkadot/util": "*" - checksum: 08b34550a3a8aa25ecc7403e4e68fd1263aea883230bc79e2736c3079857fa6b45d129d2676e6304f46949249739b037a1277385f0d85336de95b92b41561463 - languageName: node - linkType: hard - "@polkadot/wasm-crypto-wasm@npm:7.2.2": version: 7.2.2 resolution: "@polkadot/wasm-crypto-wasm@npm:7.2.2" @@ -5144,23 +5041,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/wasm-crypto@npm:^7.2.1": - version: 7.2.1 - resolution: "@polkadot/wasm-crypto@npm:7.2.1" - dependencies: - "@polkadot/wasm-bridge": 7.2.1 - "@polkadot/wasm-crypto-asmjs": 7.2.1 - "@polkadot/wasm-crypto-init": 7.2.1 - "@polkadot/wasm-crypto-wasm": 7.2.1 - "@polkadot/wasm-util": 7.2.1 - tslib: ^2.5.0 - peerDependencies: - "@polkadot/util": "*" - "@polkadot/x-randomvalues": "*" - checksum: 70cc487fecbcb51be37a887907fbed695fefb2162200224462b87a2e75f758db8c6695a88f0fdd22c2cf308f30a887660b1184449dd8abc724ee6636c2d2c5d1 - languageName: node - linkType: hard - "@polkadot/wasm-crypto@npm:^7.2.2": version: 7.2.2 resolution: "@polkadot/wasm-crypto@npm:7.2.2" @@ -5178,17 +5058,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/wasm-util@npm:7.2.1, @polkadot/wasm-util@npm:^7.2.1": - version: 7.2.1 - resolution: "@polkadot/wasm-util@npm:7.2.1" - dependencies: - tslib: ^2.5.0 - peerDependencies: - "@polkadot/util": "*" - checksum: e8a352f1fcce0c6279d05feb79bc2844ff4e8757f8a5b8db91df8f0600cb6a4dd5cc818324d5fe035a050cf8663179285abe94f8c3b6c9fe5738c0efef51d558 - languageName: node - linkType: hard - "@polkadot/wasm-util@npm:7.2.2, @polkadot/wasm-util@npm:^7.2.2": version: 7.2.2 resolution: "@polkadot/wasm-util@npm:7.2.2" @@ -5200,16 +5069,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/x-bigint@npm:12.3.2, @polkadot/x-bigint@npm:^12.3.1": - version: 12.3.2 - resolution: "@polkadot/x-bigint@npm:12.3.2" - dependencies: - "@polkadot/x-global": 12.3.2 - tslib: ^2.5.3 - checksum: 38109d942378ec02bf73b904c6304a1f7c3e7769cb259284de0ffbf0e27056fe1f3a679aaed4e63ea2fd91eb1bc2c69371a87a93f621de2ddc3fcf9cdbc29298 - languageName: node - linkType: hard - "@polkadot/x-bigint@npm:12.5.1": version: 12.5.1 resolution: "@polkadot/x-bigint@npm:12.5.1" @@ -5220,6 +5079,16 @@ __metadata: languageName: node linkType: hard +"@polkadot/x-bigint@npm:^12.3.1": + version: 12.3.2 + resolution: "@polkadot/x-bigint@npm:12.3.2" + dependencies: + "@polkadot/x-global": 12.3.2 + tslib: ^2.5.3 + checksum: 38109d942378ec02bf73b904c6304a1f7c3e7769cb259284de0ffbf0e27056fe1f3a679aaed4e63ea2fd91eb1bc2c69371a87a93f621de2ddc3fcf9cdbc29298 + languageName: node + linkType: hard + "@polkadot/x-fetch@npm:^12.3.1": version: 12.3.2 resolution: "@polkadot/x-fetch@npm:12.3.2" @@ -5249,19 +5118,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/x-randomvalues@npm:12.3.2": - version: 12.3.2 - resolution: "@polkadot/x-randomvalues@npm:12.3.2" - dependencies: - "@polkadot/x-global": 12.3.2 - tslib: ^2.5.3 - peerDependencies: - "@polkadot/util": 12.3.2 - "@polkadot/wasm-util": "*" - checksum: d0a546c2be7b0a3fb41dd4e267bff93d4f35d06f59dff3273f8717a48d79c14a050ad2db36b764ee02e7e2a6ac659ee490d6f19e7fd310ba4d548114744237f4 - languageName: node - linkType: hard - "@polkadot/x-randomvalues@npm:12.5.1": version: 12.5.1 resolution: "@polkadot/x-randomvalues@npm:12.5.1" @@ -5275,16 +5131,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/x-textdecoder@npm:12.3.2": - version: 12.3.2 - resolution: "@polkadot/x-textdecoder@npm:12.3.2" - dependencies: - "@polkadot/x-global": 12.3.2 - tslib: ^2.5.3 - checksum: 57810a92f8eabd29fc91f06dd0f0701f12053765c257371a8a768ba06df06a9eb906692049562dc904bf9ce05a50abaaabe25cc1b66a5a2d8c6e81bf42fa9a67 - languageName: node - linkType: hard - "@polkadot/x-textdecoder@npm:12.5.1": version: 12.5.1 resolution: "@polkadot/x-textdecoder@npm:12.5.1" @@ -5295,16 +5141,6 @@ __metadata: languageName: node linkType: hard -"@polkadot/x-textencoder@npm:12.3.2": - version: 12.3.2 - resolution: "@polkadot/x-textencoder@npm:12.3.2" - dependencies: - "@polkadot/x-global": 12.3.2 - tslib: ^2.5.3 - checksum: 42893a49976d17e6ca57dcf6ab18f960b817c25f82a8a25630ee17855886acf47639b8168e72852a312e542d0ff7dc0a574db882c3aa5a0387d637da9cf1e8ed - languageName: node - linkType: hard - "@polkadot/x-textencoder@npm:12.5.1": version: 12.5.1 resolution: "@polkadot/x-textencoder@npm:12.5.1" @@ -5466,13 +5302,6 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:1.1.1": - version: 1.1.1 - resolution: "@scure/base@npm:1.1.1" - checksum: 97d200da8915ca18a4eceb73c23dda7fc3a4b8509f620c9b7756ee451d7c9ebbc828c6662f9ffa047806fbe41f37bf236c6ef75692690688b7659196cb2dc804 - languageName: node - linkType: hard - "@scure/base@npm:^1.1.3": version: 1.1.3 resolution: "@scure/base@npm:1.1.3" From 259966ca3b6241a900159f9e79d05a4442dca13b Mon Sep 17 00:00:00 2001 From: Thibaut Sardan Date: Fri, 29 Sep 2023 22:58:05 +0100 Subject: [PATCH 2/4] set max timout of 30s --- .../cypress/utils/rejectCurrentMultisigTxs.ts | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/packages/ui/cypress/utils/rejectCurrentMultisigTxs.ts b/packages/ui/cypress/utils/rejectCurrentMultisigTxs.ts index 33830964..e76e5eba 100644 --- a/packages/ui/cypress/utils/rejectCurrentMultisigTxs.ts +++ b/packages/ui/cypress/utils/rejectCurrentMultisigTxs.ts @@ -98,30 +98,38 @@ export const rejectCurrentMultisigTxs = ({ multisigInfo: MultisigInfo WSendpoint: string }) => { - return new Cypress.Promise(async (resolve) => { - await cryptoWaitReady() + // this function takes some time waiting for a finalized block + // with the removal of all pending tx. We set a max timout of 30s + return cy.then( + { timeout: 30000 }, + () => + new Cypress.Promise(async (resolve) => { + await cryptoWaitReady() - const keyring = new Keyring({ type: 'sr25519' }) - keyring.addFromMnemonic(account.mnemonic) + const keyring = new Keyring({ type: 'sr25519' }) + keyring.addFromMnemonic(account.mnemonic) - const wsProvider = new WsProvider(WSendpoint) - const api = await ApiPromise.create({ provider: wsProvider }) + const wsProvider = new WsProvider(WSendpoint) + const api = await ApiPromise.create({ provider: wsProvider }) - const multisigTxs = await api.query.multisig.multisigs.entries(multisigInfo.address) - const pendingMultisigTxs = getPendingMultisixTx(multisigTxs, multisigInfo) + const multisigTxs = await api.query.multisig.multisigs.entries(multisigInfo.address) + const pendingMultisigTxs = getPendingMultisixTx(multisigTxs, multisigInfo) - if (!pendingMultisigTxs.length) { - console.log('no pending multisig tx for', multisigInfo.address) - resolve() - return - } + if (!pendingMultisigTxs.length) { + console.log('no pending multisig tx for', multisigInfo.address) + resolve() + return + } - console.log('pendingMultisigTxs', pendingMultisigTxs) + console.log('pendingMultisigTxs', pendingMultisigTxs) - const allTxs = getRejectionsTxs(pendingMultisigTxs, account, multisigInfo, api) + const allTxs = getRejectionsTxs(pendingMultisigTxs, account, multisigInfo, api) - console.log(`The multisig has ${allTxs.length} pending txs. Rejecting them now`) + console.log(`The multisig has ${allTxs.length} pending txs. Rejecting them now`) - api.tx.utility.batchAll(allTxs).signAndSend(keyring.getPair(account.address), callBack(resolve)) - }) + api.tx.utility + .batchAll(allTxs) + .signAndSend(keyring.getPair(account.address), callBack(resolve)) + }) + ) } From 88a60f25ec0318dae699a82f22de39a758802c5b Mon Sep 17 00:00:00 2001 From: Thibaut Sardan Date: Fri, 29 Sep 2023 22:59:06 +0100 Subject: [PATCH 3/4] remove console.logs --- packages/ui/src/hooks/useGetEncodedAddress.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/ui/src/hooks/useGetEncodedAddress.tsx b/packages/ui/src/hooks/useGetEncodedAddress.tsx index 684d31b3..2c62fa60 100644 --- a/packages/ui/src/hooks/useGetEncodedAddress.tsx +++ b/packages/ui/src/hooks/useGetEncodedAddress.tsx @@ -8,10 +8,7 @@ export const useGetEncodedAddress = () => { const getEncodedAddress = useCallback( (address: string | Uint8Array | undefined) => { - console.log('address', address) - if (!chainInfo || !address || address === 'undefined') { - console.log('address return', address) return } From 0110c64d34ffd7ad161fb0b582ba358fa383b690 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan Date: Fri, 29 Sep 2023 23:04:29 +0100 Subject: [PATCH 4/4] doc --- packages/ui/cypress/support/commands.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ui/cypress/support/commands.ts b/packages/ui/cypress/support/commands.ts index a24acabf..01870eeb 100644 --- a/packages/ui/cypress/support/commands.ts +++ b/packages/ui/cypress/support/commands.ts @@ -135,9 +135,9 @@ declare global { /** * Reject all pending multisig requests with a specific account - * @param {number} id - - * @param {reason} reason - - * @example + * @param {InjectedAccountWitMnemonic} opt.account - The account to reject pending transactions with. It should be the proposer + * @param {multisigInfo} opt.multisigInfo - The information about the multisig to remove pending transactions from + * @param {WSendpoint} opt.WSendpoint - The RPC endpoint to connect to to submit the rejection batch transaction */ rejectCurrentMultisigTx: (opt: { account: InjectedAccountWitMnemonic