8000 fix: multisig data disappears while signing multiple multisig tx's from same account by rajk93 · Pull Request #11552 · polkadot-js/apps · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: multisig data disappears while signing multiple multisig tx's from same account #11552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions packages/page-accounts/src/Accounts/useMultisigApprovals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { Option, StorageKey } from '@polkadot/types';
import type { H256, Multisig } from '@polkadot/types/interfaces';

import { useEffect, useState } from 'react';
import { useEffect, useRef, useState } from 'react';

import { createNamedHook, useApi, useBlockEvents, useIncrement, useIsMountedRef } from '@polkadot/react-hooks';

Expand All @@ -14,20 +14,29 @@ function useMultisigApprovalsImpl (address: string): [H256, Multisig][] | undefi
const [multiInfos, setMultiInfos] = useState<[H256, Multisig][] | undefined>();
const [trigger, incTrigger] = useIncrement(1);
const mountedRef = useIsMountedRef();
const prevEventsRef = useRef<string>('');

// increment the trigger by looking at all events
// - filter the by multisig module (old utility is not supported)
// - find anything data item where the type is AccountId
// - increment the trigger when at least one matches our address
// - increment the trigger when at least one matches our address and is different from previous multisig events
useEffect((): void => {
events
.some(({ record: { event: { data, section } } }) =>
section === 'multisig' &&
data.some((item) =>
item.toRawType() === 'AccountId' &&
item.eq(address)
)
) && incTrigger();
const multisigEvents = events.filter(({ record: { event: { data, section } } }) =>
section === 'multisig' &&
data.some((item) =>
item.toRawType() === 'AccountId' &&
item.eq(address)
)
);

if (multisigEvents.length) {
const eventsHash = JSON.stringify(multisigEvents.map((e) => e.key));

if (eventsHash !== prevEventsRef.current) {
prevEventsRef.current = eventsHash;
incTrigger();
}
}
}, [address, events, incTrigger]);

// query all the entries for the multisig, extracting approvals with their hash
Expand Down
0