Skip to content

Commit

Permalink
Merge pull request #741 from vultisig/fix/keysign
Browse files Browse the repository at this point in the history
Fix "join keysign for ERC20 swaps" by eliminating the dependency on the order of signatures.
  • Loading branch information
johnnyluo authored Jan 9, 2025
2 parents 71f562a + daf1a60 commit 6946755
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
12 changes: 12 additions & 0 deletions frontend/src/lib/utils/record/recordFromItems.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export function recordFromItems<T, K extends string | number>(
items: readonly T[],
getKey: (item: T) => K
): Record<K, T> {
const record = {} as Record<K, T>;

items.forEach(item => {
record[getKey(item)] = item;
});

return record;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Keysign } from '../../../../../wailsjs/go/tss/TssService';
import { getPreSigningHashes } from '../../../../chain/tx/utils/getPreSigningHashes';
import { getCoinType } from '../../../../chain/walletCore/getCoinType';
import { hexEncode } from '../../../../chain/walletCore/hexEncode';
import { arraysToRecord } from '../../../../lib/utils/array/arraysToRecord';
import { getLastItem } from '../../../../lib/utils/array/getLastItem';
import { chainPromises } from '../../../../lib/utils/promise/chainPromises';
import { pick } from '../../../../lib/utils/record/pick';
import { recordFromItems } from '../../../../lib/utils/record/recordFromItems';
import { Chain } from '../../../../model/chain';
import { useAssertWalletCore } from '../../../../providers/WalletCoreProvider';
import { BlockchainServiceFactory } from '../../../../services/Blockchain/BlockchainServiceFactory';
Expand Down Expand Up @@ -70,7 +70,9 @@ export const useKeysignMutation = () => {
tssType.toString().toLowerCase()
);

const signaturesRecord = arraysToRecord(msgs, signatures);
const signaturesRecord = recordFromItems(signatures, ({ msg }) =>
Buffer.from(msg, 'base64').toString('hex')
);

const publicKey = await getVaultPublicKey({
vault,
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/vault/qr/upload/ScanQrView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Button } from '../../../lib/ui/buttons/Button';
import { takeWholeSpaceAbsolutely } from '../../../lib/ui/css/takeWholeSpaceAbsolutely';
import { MatchQuery } from '../../../lib/ui/query/components/MatchQuery';
import { attempt } from '../../../lib/utils/attempt';
import { extractErrorMsg } from '../../../lib/utils/error/extractErrorMsg';
import { FlowErrorPageContent } from '../../../ui/flow/FlowErrorPageContent';
import { FlowPendingPageContent } from '../../../ui/flow/FlowPendingPageContent';
import { PageContent } from '../../../ui/page/PageContent';
Expand Down Expand Up @@ -114,9 +115,10 @@ export const ScanQrView = ({
pending={() => (
<FlowPendingPageContent title={t('getting_video_permission')} />
)}
error={() => (
error={error => (
<FlowErrorPageContent
title={t('failed_to_get_video_permission')}
message={extractErrorMsg(error)}
action={
<Button
onClick={() => {
Expand Down

0 comments on commit 6946755

Please sign in to comment.