Skip to content

Commit 1704b5d

Browse files
Feat/lw 12399 sign multisig tx with hw (#1768)
* fix: [lw-12399] sign multisig tx with hw * fix: bump cardano-js-sdk --------- Co-authored-by: Angel Castillo <angel.castillo@iohk.io>
1 parent c63e64c commit 1704b5d

File tree

25 files changed

+211
-202
lines changed

25 files changed

+211
-202
lines changed

apps/browser-extension-wallet/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@
5656
},
5757
"dependencies": {
5858
"@ant-design/icons": "^4.7.0",
59-
"@cardano-sdk/cardano-services-client": "0.26.15",
59+
"@cardano-sdk/cardano-services-client": "0.26.16",
6060
"@cardano-sdk/core": "0.46.0",
6161
"@cardano-sdk/dapp-connector": "0.13.14",
62-
"@cardano-sdk/input-selection": "0.14.14",
63-
"@cardano-sdk/tx-construction": "0.27.1",
62+
"@cardano-sdk/input-selection": "0.14.15",
63+
"@cardano-sdk/tx-construction": "0.27.2",
6464
"@cardano-sdk/util": "0.17.0",
65-
"@cardano-sdk/util-rxjs": "0.9.16",
66-
"@cardano-sdk/wallet": "0.53.1",
67-
"@cardano-sdk/web-extension": "0.39.11",
65+
"@cardano-sdk/util-rxjs": "0.9.17",
66+
"@cardano-sdk/wallet": "0.53.2",
67+
"@cardano-sdk/web-extension": "0.39.12",
6868
"@emurgo/cip14-js": "~3.0.1",
6969
"@input-output-hk/lace-ui-toolkit": "3.5.0",
7070
"@lace/bitcoin": "0.1.0",
@@ -119,7 +119,7 @@
119119
"zustand": "3.5.14"
120120
},
121121
"devDependencies": {
122-
"@cardano-sdk/hardware-ledger": "0.16.1",
122+
"@cardano-sdk/hardware-ledger": "0.16.2",
123123
"@emurgo/cardano-message-signing-asmjs": "1.0.1",
124124
"@openpgp/web-stream-tools": "0.0.11-patch-0",
125125
"@pdfme/common": "^4.0.2",

apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/components/WalletAccounts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const WalletAccounts = ({ isPopup, onBack }: { isPopup: boolean; onBack:
6969
const disableUnlock = useMemo(
7070
() =>
7171
isPopup &&
72-
(wallet.type === WalletType.Ledger || wallet.type === WalletType.Trezor) && {
72+
Wallet.AVAILABLE_WALLETS.includes(wallet.type as Wallet.HardwareWallets) && {
7373
reason: (
7474
<Trans
7575
i18nKey="multiWallet.popupHwAccountEnable"

apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/__tests__/utils.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('Testing utils', () => {
8585
});
8686

8787
test('testing pubDRepKeyToHash', async () => {
88-
const pubDRepKeyHex = '_pubDRepKeyHex';
88+
const pubDRepKeyHex = '8293d319ef5b3ac72366dd28006bd315b715f7e7cfcbd3004129b80d';
8989
expect(await pubDRepKeyToHash(pubDRepKeyHex as Wallet.Crypto.Ed25519PublicKeyHex)).toEqual(pubDRepKeyHex);
9090
});
9191

apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable sonarjs/no-small-switch */
22
/* eslint-disable complexity */
33
import { Wallet } from '@lace/cardano';
4-
import { RemoteApiPropertyType, TransactionWitnessRequest, WalletType, exposeApi } from '@cardano-sdk/web-extension';
4+
import { exposeApi, RemoteApiPropertyType, TransactionWitnessRequest, WalletType } from '@cardano-sdk/web-extension';
55
import type { UserPromptService } from '@lib/scripts/background/services';
6-
import { DAPP_CHANNELS, cardanoCoin } from '@src/utils/constants';
6+
import { cardanoCoin, DAPP_CHANNELS } from '@src/utils/constants';
77
import { runtime } from 'webextension-polyfill';
88
import { of } from 'rxjs';
99
import { logger } from '@lace/common';
@@ -66,7 +66,7 @@ export const pubDRepKeyToHash = async (
6666
pubDRepKeyHex: Wallet.Crypto.Ed25519PublicKeyHex
6767
): Promise<Wallet.Crypto.Hash28ByteBase16> => {
6868
const pubDRepKey = await Wallet.Crypto.Ed25519PublicKey.fromHex(pubDRepKeyHex);
69-
return (await pubDRepKey.hash()).hex();
69+
return (await pubDRepKey.hash()).hex() as unknown as Wallet.Crypto.Hash28ByteBase16;
7070
};
7171

7272
export const depositPaidWithSymbol = (deposit: bigint, coinId: Wallet.CoinId): string => {

apps/browser-extension-wallet/src/features/delegation/components/MultiDelegationStakingPopup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { isMultidelegationSupportedByDevice } from '@views/browser/features/stak
3737
import { useSecrets, useSignPolicy } from '@lace/core';
3838
import { useRewardAccountsData } from '@src/views/browser-view/features/staking/hooks';
3939
import { parseError } from '@src/utils/parse-error';
40-
import { getParentWalletCIP1854Account } from '@lib/scripts/background/util';
40+
import { getParentWalletForCIP1854Account } from '@lib/scripts/background/util';
4141
import { useObservable } from '@lace/common';
4242
import { walletRoutePaths } from '@routes';
4343

@@ -86,7 +86,7 @@ export const MultiDelegationStakingPopup = (): JSX.Element => {
8686
const wallet = useCurrentWallet();
8787
const wallets = useObservable(walletRepository.wallets$);
8888

89-
const parentMultiSigAccount = getParentWalletCIP1854Account({ wallets, activeWallet: wallet });
89+
const parentMultiSigAccount = getParentWalletForCIP1854Account({ wallets, activeWallet: wallet })?.account;
9090
const signPolicy = useSignPolicy(wallet, 'staking');
9191

9292
const sendAnalytics = useCallback(() => {

apps/browser-extension-wallet/src/lib/scripts/background/storage/extension-blob-key-value-store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { toSerializableObject } from '@cardano-sdk/util';
99
* Stores entire key-value collection in a single document
1010
*/
1111
// eslint-disable-next-line @typescript-eslint/no-explicit-any
12-
export class ExtensionBlobKeyValueStore<K extends PropertyKey, V extends {}>
12+
export class ExtensionBlobKeyValueStore<K extends string, V extends {}>
1313
extends ExtensionDocumentStore<Record<K, V>>
1414
implements sdkStorage.KeyValueStore<K, V>
1515
{

apps/browser-extension-wallet/src/lib/scripts/background/util.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
WalletType
1313
} from '@cardano-sdk/web-extension';
1414
import * as KeyManagement from '@cardano-sdk/key-management';
15-
import { HexBlob } from '@cardano-sdk/util';
1615
import { getBackgroundStorage } from './storage';
1716
import { catchAndBrandExtensionApiError } from '@utils/catch-and-brand-extension-api-error';
1817

@@ -114,22 +113,30 @@ const waitForTabLoad = (tab: Tabs.Tab) =>
114113
* @param activeWallet
115114
* @returns {Bip32WalletAccount<Wallet.AccountMetadata>} | undefined
116115
*/
117-
export const getParentWalletCIP1854Account = ({
116+
export const getParentWalletForCIP1854Account = ({
118117
wallets,
119118
activeWallet
120119
}: {
121120
wallets: AnyWallet<Wallet.WalletMetadata, Wallet.AccountMetadata>[];
122121
activeWallet: AnyWallet<Wallet.WalletMetadata, Wallet.AccountMetadata>;
123-
}): Bip32WalletAccount<Wallet.AccountMetadata> | undefined => {
122+
}):
123+
| {
124+
wallet: AnyWallet<Wallet.WalletMetadata, Wallet.AccountMetadata>;
125+
account: Bip32WalletAccount<Wallet.AccountMetadata>;
126+
}
127+
| undefined => {
124128
if (activeWallet?.type !== WalletType.Script) return;
125129

126130
const parentWallet = wallets.find(({ walletId }) => walletId === activeWallet.ownSigners[0].walletId);
127131

128132
if (parentWallet.type !== WalletType.Script) {
129133
// eslint-disable-next-line consistent-return
130-
return parentWallet.accounts.find(
131-
({ accountIndex, purpose }) => accountIndex === 0 && purpose === KeyManagement.KeyPurpose.MULTI_SIG
132-
);
134+
return {
135+
wallet: parentWallet,
136+
account: parentWallet.accounts.find(
137+
({ accountIndex, purpose }) => accountIndex === 0 && purpose === KeyManagement.KeyPurpose.MULTI_SIG
138+
)
139+
};
133140
}
134141
};
135142

@@ -151,7 +158,7 @@ export const getActiveWallet = async ({
151158
if (!wallet) return;
152159
const account =
153160
wallet.type === WalletType.Script
154-
? getParentWalletCIP1854Account({ wallets, activeWallet: wallet })
161+
? getParentWalletForCIP1854Account({ wallets, activeWallet: wallet })?.account
155162
: wallet.accounts.find((acc) => activeWallet.accountIndex === acc.accountIndex);
156163
// eslint-disable-next-line consistent-return
157164
return { wallet, account };
@@ -192,8 +199,5 @@ export const getWalletName = (): string => {
192199
return `${process.env.WALLET_NAME}`;
193200
};
194201

195-
export const hashExtendedAccountPublicKey = (extendedAccountPublicKey: string): string => {
196-
const input = Buffer.from(extendedAccountPublicKey);
197-
198-
return blake2b.hash(HexBlob.fromBytes(input), 32);
199-
};
202+
export const hashExtendedAccountPublicKey = (extendedAccountPublicKey: string): string =>
203+
blake2b.hash(extendedAccountPublicKey, 16);

apps/browser-extension-wallet/src/lib/scripts/background/wallet.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,7 @@ const walletFactory: WalletFactory<Wallet.WalletMetadata, Wallet.AccountMetadata
177177
chainId,
178178
extendedAccountPublicKey: walletAccount.extendedAccountPublicKey
179179
},
180-
{
181-
bip32Ed25519: await Wallet.getBip32Ed25519(),
182-
blake2b: Wallet.Crypto.blake2b
183-
}
180+
await Wallet.KeyManagement.Bip32Account.createDefaultDependencies()
184181
);
185182

186183
const useWebSocket = isExperimentEnabled(featureFlags, ExperimentName.WEBSOCKET_API);

apps/browser-extension-wallet/src/views/browser-view/components/QRPublicKeyDrawer/QRPublicKeyDrawer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import { getQRCodeOptions } from '@src/utils/qrCodeHelpers';
88
import { PostHogAction } from '@providers/AnalyticsProvider/analyticsTracker';
99
import { useCurrentWallet, useWalletManager } from '@hooks';
1010
import { useObservable } from '@lace/common';
11-
import { getParentWalletCIP1854Account } from '@lib/scripts/background/util';
11+
import { getParentWalletForCIP1854Account } from '@lib/scripts/background/util';
1212

1313
const useWalletInformation = () => {
1414
const { walletRepository } = useWalletManager();
1515
const wallets = useObservable(walletRepository.wallets$);
1616
const wallet = useCurrentWallet();
1717

18-
const parentMultiSigAccount = getParentWalletCIP1854Account({ wallets, activeWallet: wallet });
18+
const parentMultiSigAccount = getParentWalletForCIP1854Account({ wallets, activeWallet: wallet })?.account;
1919

2020
return useWalletStore((state) => ({
2121
name: state?.walletInfo?.name,

apps/browser-extension-wallet/src/views/browser-view/features/activity/components/SharedWalletTransactionDetailsWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { AddressListType, getTransactionData } from '@views/browser/features/act
1414
import { useAddressBookContext, withAddressBookContext } from '@src/features/address-book/context';
1515
import { TransactionActivityDetail, TxDirection, TxDirections } from '@types';
1616
import { useObservable } from '@lace/common';
17-
import { getParentWalletCIP1854Account } from '@lib/scripts/background/util';
17+
import { getParentWalletForCIP1854Account } from '@lib/scripts/background/util';
1818

1919
interface SharedWalletTransactionDetailsProxyProps {
2020
amountTransformer: (amount: string) => string;
@@ -57,7 +57,7 @@ export const SharedWalletTransactionDetailsWrapper = withAddressBookContext(
5757
const wallets = useObservable(walletRepository.wallets$);
5858
const wallet = useCurrentWallet();
5959

60-
const parentMultiSigAccount = getParentWalletCIP1854Account({ wallets, activeWallet: wallet });
60+
const parentMultiSigAccount = getParentWalletForCIP1854Account({ wallets, activeWallet: wallet })?.account;
6161
const sharedWalletKey = parentMultiSigAccount?.extendedAccountPublicKey;
6262

6363
const coSigners = wallet?.metadata?.coSigners;

0 commit comments

Comments
 (0)