@ledgerhq/live-common 34.51.0-nightly.0 → 34.51.0-nightly.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.js +2 -0
- package/lib/bridge/generic-alpaca/accountBridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +1 -0
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +3 -0
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.js +37 -45
- package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js +0 -20
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib/bridge/generic-alpaca/signRawOperation.d.ts +8 -0
- package/lib/bridge/generic-alpaca/signRawOperation.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/signRawOperation.js +55 -0
- package/lib/bridge/generic-alpaca/signRawOperation.js.map +1 -0
- package/lib/bridge/generic-alpaca/tests/getAccountShape.test.js +1 -0
- package/lib/bridge/generic-alpaca/tests/getAccountShape.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js +186 -88
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +1 -0
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/mockHelpers.d.ts +1 -0
- package/lib/bridge/mockHelpers.d.ts.map +1 -1
- package/lib/bridge/mockHelpers.js +53 -1
- package/lib/bridge/mockHelpers.js.map +1 -1
- package/lib/bridge/react/BridgeSync.d.ts +1 -0
- package/lib/bridge/react/BridgeSync.d.ts.map +1 -1
- package/lib/bridge/react/BridgeSync.js +19 -16
- package/lib/bridge/react/BridgeSync.js.map +1 -1
- package/lib/bridge/react/BridgeSync.test.js +403 -66
- package/lib/bridge/react/BridgeSync.test.js.map +1 -1
- package/lib/dada-client/entities/index.d.ts +1 -1
- package/lib/dada-client/entities/index.d.ts.map +1 -1
- package/lib/e2e/index.d.ts +8 -0
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/families/algorand/bridge/mock.d.ts.map +1 -1
- package/lib/families/algorand/bridge/mock.js +1 -0
- package/lib/families/algorand/bridge/mock.js.map +1 -1
- package/lib/families/bitcoin/bridge/mock.d.ts.map +1 -1
- package/lib/families/bitcoin/bridge/mock.js +1 -0
- package/lib/families/bitcoin/bridge/mock.js.map +1 -1
- package/lib/families/canton/bridge/mock.d.ts.map +1 -1
- package/lib/families/canton/bridge/mock.js +3 -0
- package/lib/families/canton/bridge/mock.js.map +1 -1
- package/lib/families/cardano/bridge/mock.d.ts.map +1 -1
- package/lib/families/cardano/bridge/mock.js +1 -0
- package/lib/families/cardano/bridge/mock.js.map +1 -1
- package/lib/families/casper/bridge/mock.d.ts.map +1 -1
- package/lib/families/casper/bridge/mock.js +1 -0
- package/lib/families/casper/bridge/mock.js.map +1 -1
- package/lib/families/cosmos/bridge/mock.d.ts.map +1 -1
- package/lib/families/cosmos/bridge/mock.js +1 -0
- package/lib/families/cosmos/bridge/mock.js.map +1 -1
- package/lib/families/evm/bridge/mock.d.ts.map +1 -1
- package/lib/families/evm/bridge/mock.js +1 -0
- package/lib/families/evm/bridge/mock.js.map +1 -1
- package/lib/families/icon/bridge/mock.d.ts.map +1 -1
- package/lib/families/icon/bridge/mock.js +1 -0
- package/lib/families/icon/bridge/mock.js.map +1 -1
- package/lib/families/multiversx/bridge/mock.d.ts.map +1 -1
- package/lib/families/multiversx/bridge/mock.js +1 -0
- package/lib/families/multiversx/bridge/mock.js.map +1 -1
- package/lib/families/polkadot/bridge/mock.d.ts.map +1 -1
- package/lib/families/polkadot/bridge/mock.js +1 -0
- package/lib/families/polkadot/bridge/mock.js.map +1 -1
- package/lib/families/polkadot/config.d.ts.map +1 -1
- package/lib/families/polkadot/config.js +84 -0
- package/lib/families/polkadot/config.js.map +1 -1
- package/lib/families/polkadot/setup.d.ts.map +1 -1
- package/lib/families/polkadot/setup.js +5 -4
- package/lib/families/polkadot/setup.js.map +1 -1
- package/lib/families/solana/bridge/mock.d.ts +1 -0
- package/lib/families/solana/bridge/mock.d.ts.map +1 -1
- package/lib/families/stellar/bridge/mock.d.ts.map +1 -1
- package/lib/families/stellar/bridge/mock.js +1 -0
- package/lib/families/stellar/bridge/mock.js.map +1 -1
- package/lib/families/tezos/bridge/mock.d.ts.map +1 -1
- package/lib/families/tezos/bridge/mock.js +1 -0
- package/lib/families/tezos/bridge/mock.js.map +1 -1
- package/lib/families/tron/bridge/mock.d.ts.map +1 -1
- package/lib/families/tron/bridge/mock.js +1 -0
- package/lib/families/tron/bridge/mock.js.map +1 -1
- package/lib/families/xrp/bridge/mock.d.ts.map +1 -1
- package/lib/families/xrp/bridge/mock.js +1 -0
- package/lib/families/xrp/bridge/mock.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts +3 -0
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +10 -1
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/generated/bridge/mock.d.ts +1 -0
- package/lib/generated/bridge/mock.d.ts.map +1 -1
- package/lib/hw/actions/rawTransaction.d.ts +37 -0
- package/lib/hw/actions/rawTransaction.d.ts.map +1 -0
- package/lib/hw/actions/rawTransaction.js +107 -0
- package/lib/hw/actions/rawTransaction.js.map +1 -0
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +9 -0
- package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
- package/lib/wallet-api/logic.d.ts +1 -0
- package/lib/wallet-api/logic.d.ts.map +1 -1
- package/lib/wallet-api/logic.js +21 -1
- package/lib/wallet-api/logic.js.map +1 -1
- package/lib/wallet-api/react.d.ts +9 -1
- package/lib/wallet-api/react.d.ts.map +1 -1
- package/lib/wallet-api/react.js +60 -2
- package/lib/wallet-api/react.js.map +1 -1
- package/lib/wallet-api/tracking.d.ts +3 -0
- package/lib/wallet-api/tracking.d.ts.map +1 -1
- package/lib/wallet-api/tracking.js +12 -0
- package/lib/wallet-api/tracking.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.js +2 -0
- package/lib-es/bridge/generic-alpaca/accountBridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +1 -0
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +3 -0
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js +37 -45
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js +0 -17
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signRawOperation.d.ts +8 -0
- package/lib-es/bridge/generic-alpaca/signRawOperation.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/signRawOperation.js +48 -0
- package/lib-es/bridge/generic-alpaca/signRawOperation.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/tests/getAccountShape.test.js +1 -0
- package/lib-es/bridge/generic-alpaca/tests/getAccountShape.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js +163 -88
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +1 -0
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/mockHelpers.d.ts +1 -0
- package/lib-es/bridge/mockHelpers.d.ts.map +1 -1
- package/lib-es/bridge/mockHelpers.js +51 -0
- package/lib-es/bridge/mockHelpers.js.map +1 -1
- package/lib-es/bridge/react/BridgeSync.d.ts +1 -0
- package/lib-es/bridge/react/BridgeSync.d.ts.map +1 -1
- package/lib-es/bridge/react/BridgeSync.js +17 -15
- package/lib-es/bridge/react/BridgeSync.js.map +1 -1
- package/lib-es/bridge/react/BridgeSync.test.js +382 -65
- package/lib-es/bridge/react/BridgeSync.test.js.map +1 -1
- package/lib-es/dada-client/entities/index.d.ts +1 -1
- package/lib-es/dada-client/entities/index.d.ts.map +1 -1
- package/lib-es/e2e/index.d.ts +8 -0
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/families/algorand/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/algorand/bridge/mock.js +2 -1
- package/lib-es/families/algorand/bridge/mock.js.map +1 -1
- package/lib-es/families/bitcoin/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/bitcoin/bridge/mock.js +2 -1
- package/lib-es/families/bitcoin/bridge/mock.js.map +1 -1
- package/lib-es/families/canton/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/canton/bridge/mock.js +3 -0
- package/lib-es/families/canton/bridge/mock.js.map +1 -1
- package/lib-es/families/cardano/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/cardano/bridge/mock.js +2 -1
- package/lib-es/families/cardano/bridge/mock.js.map +1 -1
- package/lib-es/families/casper/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/casper/bridge/mock.js +2 -1
- package/lib-es/families/casper/bridge/mock.js.map +1 -1
- package/lib-es/families/cosmos/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/cosmos/bridge/mock.js +2 -1
- package/lib-es/families/cosmos/bridge/mock.js.map +1 -1
- package/lib-es/families/evm/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/evm/bridge/mock.js +2 -1
- package/lib-es/families/evm/bridge/mock.js.map +1 -1
- package/lib-es/families/icon/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/icon/bridge/mock.js +2 -1
- package/lib-es/families/icon/bridge/mock.js.map +1 -1
- package/lib-es/families/multiversx/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/multiversx/bridge/mock.js +2 -1
- package/lib-es/families/multiversx/bridge/mock.js.map +1 -1
- package/lib-es/families/polkadot/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/polkadot/bridge/mock.js +2 -1
- package/lib-es/families/polkadot/bridge/mock.js.map +1 -1
- package/lib-es/families/polkadot/config.d.ts.map +1 -1
- package/lib-es/families/polkadot/config.js +84 -0
- package/lib-es/families/polkadot/config.js.map +1 -1
- package/lib-es/families/polkadot/setup.d.ts.map +1 -1
- package/lib-es/families/polkadot/setup.js +5 -4
- package/lib-es/families/polkadot/setup.js.map +1 -1
- package/lib-es/families/solana/bridge/mock.d.ts +1 -0
- package/lib-es/families/solana/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/stellar/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/stellar/bridge/mock.js +2 -1
- package/lib-es/families/stellar/bridge/mock.js.map +1 -1
- package/lib-es/families/tezos/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/tezos/bridge/mock.js +2 -1
- package/lib-es/families/tezos/bridge/mock.js.map +1 -1
- package/lib-es/families/tron/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/tron/bridge/mock.js +2 -1
- package/lib-es/families/tron/bridge/mock.js.map +1 -1
- package/lib-es/families/xrp/bridge/mock.d.ts.map +1 -1
- package/lib-es/families/xrp/bridge/mock.js +2 -1
- package/lib-es/families/xrp/bridge/mock.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts +3 -0
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +10 -1
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/generated/bridge/mock.d.ts +1 -0
- package/lib-es/generated/bridge/mock.d.ts.map +1 -1
- package/lib-es/hw/actions/rawTransaction.d.ts +37 -0
- package/lib-es/hw/actions/rawTransaction.d.ts.map +1 -0
- package/lib-es/hw/actions/rawTransaction.js +103 -0
- package/lib-es/hw/actions/rawTransaction.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +9 -0
- package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
- package/lib-es/wallet-api/logic.d.ts +1 -0
- package/lib-es/wallet-api/logic.d.ts.map +1 -1
- package/lib-es/wallet-api/logic.js +19 -0
- package/lib-es/wallet-api/logic.js.map +1 -1
- package/lib-es/wallet-api/react.d.ts +9 -1
- package/lib-es/wallet-api/react.d.ts.map +1 -1
- package/lib-es/wallet-api/react.js +61 -3
- package/lib-es/wallet-api/react.js.map +1 -1
- package/lib-es/wallet-api/tracking.d.ts +3 -0
- package/lib-es/wallet-api/tracking.d.ts.map +1 -1
- package/lib-es/wallet-api/tracking.js +12 -0
- package/lib-es/wallet-api/tracking.js.map +1 -1
- package/package.json +54 -54
- package/src/bridge/generic-alpaca/accountBridge.ts +2 -0
- package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +8 -0
- package/src/bridge/generic-alpaca/prepareTransaction.ts +46 -69
- package/src/bridge/generic-alpaca/signOperation.ts +0 -20
- package/src/bridge/generic-alpaca/signRawOperation.ts +86 -0
- package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +1 -0
- package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +191 -109
- package/src/bridge/generic-alpaca/utils.ts +1 -0
- package/src/bridge/mockHelpers.ts +57 -0
- package/src/bridge/react/BridgeSync.test.tsx +513 -82
- package/src/bridge/react/BridgeSync.tsx +18 -17
- package/src/dada-client/MIGRATION_GUIDE.md +215 -0
- package/src/dada-client/entities/index.ts +1 -1
- package/src/families/algorand/bridge/mock.ts +2 -0
- package/src/families/bitcoin/bridge/mock.ts +2 -0
- package/src/families/canton/bridge/mock.ts +3 -0
- package/src/families/cardano/bridge/mock.ts +2 -0
- package/src/families/casper/bridge/mock.ts +2 -0
- package/src/families/cosmos/bridge/mock.ts +2 -0
- package/src/families/evm/bridge/mock.ts +2 -0
- package/src/families/icon/bridge/mock.ts +2 -0
- package/src/families/multiversx/bridge/mock.ts +2 -0
- package/src/families/polkadot/bridge/mock.ts +2 -0
- package/src/families/polkadot/config.ts +84 -0
- package/src/families/polkadot/setup.ts +6 -4
- package/src/families/stellar/bridge/mock.ts +2 -0
- package/src/families/tezos/bridge/mock.ts +2 -0
- package/src/families/tron/bridge/mock.ts +2 -0
- package/src/families/xrp/bridge/mock.ts +2 -0
- package/src/featureFlags/defaultFeatures.ts +10 -1
- package/src/hw/actions/rawTransaction.ts +190 -0
- package/src/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.ts +9 -0
- package/src/wallet-api/logic.ts +35 -0
- package/src/wallet-api/react.ts +87 -1
- package/src/wallet-api/tracking.ts +15 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { of, Observable } from "rxjs";
|
|
2
|
+
import { scan, catchError, tap } from "rxjs/operators";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { log } from "@ledgerhq/logs";
|
|
5
|
+
import { TransportStatusError } from "@ledgerhq/errors";
|
|
6
|
+
import { TransactionRefusedOnDevice } from "../../errors";
|
|
7
|
+
import { getMainAccount } from "../../account";
|
|
8
|
+
import { getAccountBridge } from "../../bridge";
|
|
9
|
+
import type { ConnectAppEvent, Input as ConnectAppInput } from "../connectApp";
|
|
10
|
+
import type { Action, Device } from "./types";
|
|
11
|
+
import type { AppRequest, AppState } from "./app";
|
|
12
|
+
import { createAction as createAppAction } from "./app";
|
|
13
|
+
import type {
|
|
14
|
+
Account,
|
|
15
|
+
AccountLike,
|
|
16
|
+
SignedOperation,
|
|
17
|
+
SignOperationEvent,
|
|
18
|
+
} from "@ledgerhq/types-live";
|
|
19
|
+
|
|
20
|
+
type State = {
|
|
21
|
+
signedOperation: SignedOperation | null | undefined;
|
|
22
|
+
deviceSignatureRequested: boolean;
|
|
23
|
+
deviceStreamingProgress: number | null | undefined;
|
|
24
|
+
transactionSignError: Error | null | undefined;
|
|
25
|
+
transactionChecksOptInTriggered: boolean;
|
|
26
|
+
transactionChecksOptIn: boolean | null;
|
|
27
|
+
manifestId?: string;
|
|
28
|
+
manifestName?: string;
|
|
29
|
+
};
|
|
30
|
+
type RawTransactionState = AppState & State;
|
|
31
|
+
type RawTransactionRequest = {
|
|
32
|
+
parentAccount: Account | null | undefined;
|
|
33
|
+
account: AccountLike;
|
|
34
|
+
transaction: string;
|
|
35
|
+
appName?: string;
|
|
36
|
+
dependencies?: AppRequest[];
|
|
37
|
+
requireLatestFirmware?: boolean;
|
|
38
|
+
manifestId?: string;
|
|
39
|
+
manifestName?: string;
|
|
40
|
+
};
|
|
41
|
+
export type RawTransactionResult =
|
|
42
|
+
| {
|
|
43
|
+
signedOperation: SignedOperation;
|
|
44
|
+
device: Device;
|
|
45
|
+
swapId?: string;
|
|
46
|
+
}
|
|
47
|
+
| {
|
|
48
|
+
transactionSignError: Error;
|
|
49
|
+
};
|
|
50
|
+
type TransactionAction = Action<RawTransactionRequest, RawTransactionState, RawTransactionResult>;
|
|
51
|
+
|
|
52
|
+
const mapResult = ({
|
|
53
|
+
device,
|
|
54
|
+
signedOperation,
|
|
55
|
+
transactionSignError,
|
|
56
|
+
}: RawTransactionState): RawTransactionResult | null | undefined =>
|
|
57
|
+
signedOperation && device
|
|
58
|
+
? {
|
|
59
|
+
signedOperation,
|
|
60
|
+
device,
|
|
61
|
+
}
|
|
62
|
+
: transactionSignError
|
|
63
|
+
? {
|
|
64
|
+
transactionSignError,
|
|
65
|
+
}
|
|
66
|
+
: null;
|
|
67
|
+
|
|
68
|
+
type Event =
|
|
69
|
+
| SignOperationEvent
|
|
70
|
+
| {
|
|
71
|
+
type: "error";
|
|
72
|
+
error: Error;
|
|
73
|
+
};
|
|
74
|
+
const initialState = {
|
|
75
|
+
signedOperation: null,
|
|
76
|
+
deviceSignatureRequested: false,
|
|
77
|
+
deviceStreamingProgress: null,
|
|
78
|
+
transactionSignError: null,
|
|
79
|
+
transactionChecksOptInTriggered: false,
|
|
80
|
+
transactionChecksOptIn: null,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const reducer = (state: State, e: Event): State => {
|
|
84
|
+
switch (e.type) {
|
|
85
|
+
case "error": {
|
|
86
|
+
const { error } = e;
|
|
87
|
+
const transactionSignError =
|
|
88
|
+
error instanceof TransportStatusError && error.statusCode === 0x6985
|
|
89
|
+
? new TransactionRefusedOnDevice()
|
|
90
|
+
: error;
|
|
91
|
+
return { ...initialState, transactionSignError };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
case "signed":
|
|
95
|
+
return { ...state, signedOperation: e.signedOperation };
|
|
96
|
+
|
|
97
|
+
case "device-signature-requested":
|
|
98
|
+
return { ...state, deviceSignatureRequested: true };
|
|
99
|
+
|
|
100
|
+
case "device-signature-granted":
|
|
101
|
+
return { ...state, deviceSignatureRequested: false };
|
|
102
|
+
|
|
103
|
+
case "device-streaming":
|
|
104
|
+
return { ...state, deviceStreamingProgress: e.progress };
|
|
105
|
+
|
|
106
|
+
case "transaction-checks-opt-in-triggered":
|
|
107
|
+
return { ...state, transactionChecksOptInTriggered: true };
|
|
108
|
+
|
|
109
|
+
case "transaction-checks-opt-in":
|
|
110
|
+
return { ...state, transactionChecksOptIn: true };
|
|
111
|
+
|
|
112
|
+
case "transaction-checks-opt-out":
|
|
113
|
+
return { ...state, transactionChecksOptIn: false };
|
|
114
|
+
|
|
115
|
+
default:
|
|
116
|
+
return state;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const createAction = (
|
|
121
|
+
connectAppExec: (arg0: ConnectAppInput) => Observable<ConnectAppEvent>,
|
|
122
|
+
): TransactionAction => {
|
|
123
|
+
const useHook = (
|
|
124
|
+
reduxDevice: Device | null | undefined,
|
|
125
|
+
{
|
|
126
|
+
account,
|
|
127
|
+
parentAccount,
|
|
128
|
+
transaction,
|
|
129
|
+
appName,
|
|
130
|
+
dependencies,
|
|
131
|
+
requireLatestFirmware,
|
|
132
|
+
manifestId,
|
|
133
|
+
manifestName,
|
|
134
|
+
}: RawTransactionRequest,
|
|
135
|
+
): RawTransactionState => {
|
|
136
|
+
const mainAccount = getMainAccount(account, parentAccount);
|
|
137
|
+
const appState = createAppAction(connectAppExec).useHook(reduxDevice, {
|
|
138
|
+
account: mainAccount,
|
|
139
|
+
appName,
|
|
140
|
+
dependencies,
|
|
141
|
+
requireLatestFirmware,
|
|
142
|
+
});
|
|
143
|
+
const { device, opened, inWrongDeviceForAccount, error } = appState;
|
|
144
|
+
const [state, setState] = useState(initialState);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (!device || !opened || inWrongDeviceForAccount || error) {
|
|
147
|
+
setState(initialState);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const bridge = getAccountBridge(mainAccount);
|
|
152
|
+
const sub = bridge
|
|
153
|
+
.signRawOperation({
|
|
154
|
+
account: mainAccount,
|
|
155
|
+
transaction,
|
|
156
|
+
deviceId: device.deviceId,
|
|
157
|
+
deviceModelId: device.modelId,
|
|
158
|
+
})
|
|
159
|
+
.pipe(
|
|
160
|
+
catchError(error =>
|
|
161
|
+
of<{ type: "error"; error: Error }>({
|
|
162
|
+
type: "error",
|
|
163
|
+
error,
|
|
164
|
+
}),
|
|
165
|
+
),
|
|
166
|
+
tap((e: Event) => log("actions-transaction-event", e.type, e)),
|
|
167
|
+
scan(reducer, initialState),
|
|
168
|
+
)
|
|
169
|
+
.subscribe((x: any) => setState(x));
|
|
170
|
+
return () => {
|
|
171
|
+
sub.unsubscribe();
|
|
172
|
+
};
|
|
173
|
+
}, [device, mainAccount, transaction, opened, inWrongDeviceForAccount, error]);
|
|
174
|
+
return {
|
|
175
|
+
...appState,
|
|
176
|
+
...state,
|
|
177
|
+
manifestId,
|
|
178
|
+
manifestName,
|
|
179
|
+
deviceStreamingProgress:
|
|
180
|
+
state.signedOperation || state.transactionSignError
|
|
181
|
+
? null // when good app is opened, we start the progress so it doesn't "blink"
|
|
182
|
+
: state.deviceStreamingProgress || (appState.opened ? 0 : null),
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
useHook,
|
|
188
|
+
mapResult,
|
|
189
|
+
};
|
|
190
|
+
};
|
|
@@ -73,6 +73,9 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
73
73
|
const kaspa = useFeature("currencyKaspa");
|
|
74
74
|
const core = useFeature("currencyCore");
|
|
75
75
|
const ethereumHoodi = useFeature("currencyEthereumHoodi");
|
|
76
|
+
const westend = useFeature("currencyWestend");
|
|
77
|
+
const assetHubWestend = useFeature("currencyAssetHubWestend");
|
|
78
|
+
const assetHubPolkadot = useFeature("currencyAssetHubPolkadot");
|
|
76
79
|
|
|
77
80
|
const featureFlaggedCurrencies = useMemo(
|
|
78
81
|
(): Partial<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
|
|
@@ -142,6 +145,9 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
142
145
|
kaspa,
|
|
143
146
|
core,
|
|
144
147
|
ethereum_hoodi: ethereumHoodi,
|
|
148
|
+
westend,
|
|
149
|
+
assethub_westend: assetHubWestend,
|
|
150
|
+
assethub_polkadot: assetHubPolkadot,
|
|
145
151
|
}),
|
|
146
152
|
[
|
|
147
153
|
aptos,
|
|
@@ -210,6 +216,9 @@ export function useCurrenciesUnderFeatureFlag() {
|
|
|
210
216
|
kaspa,
|
|
211
217
|
core,
|
|
212
218
|
ethereumHoodi,
|
|
219
|
+
westend,
|
|
220
|
+
assetHubWestend,
|
|
221
|
+
assetHubPolkadot,
|
|
213
222
|
],
|
|
214
223
|
);
|
|
215
224
|
|
package/src/wallet-api/logic.ts
CHANGED
|
@@ -139,6 +139,41 @@ export function signTransactionLogic(
|
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
export function signRawTransactionLogic(
|
|
143
|
+
{ manifest, accounts, tracking }: WalletAPIContext,
|
|
144
|
+
walletAccountId: string,
|
|
145
|
+
transaction: string,
|
|
146
|
+
uiNavigation: (
|
|
147
|
+
account: AccountLike,
|
|
148
|
+
parentAccount: Account | undefined,
|
|
149
|
+
transaction: string,
|
|
150
|
+
) => Promise<SignedOperation>,
|
|
151
|
+
): Promise<SignedOperation> {
|
|
152
|
+
tracking.signRawTransactionRequested(manifest);
|
|
153
|
+
|
|
154
|
+
if (!transaction) {
|
|
155
|
+
tracking.signRawTransactionFail(manifest);
|
|
156
|
+
return Promise.reject(new Error("Transaction required"));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const accountId = getAccountIdFromWalletAccountId(walletAccountId);
|
|
160
|
+
if (!accountId) {
|
|
161
|
+
tracking.signRawTransactionFail(manifest);
|
|
162
|
+
return Promise.reject(new Error(`accountId ${walletAccountId} unknown`));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const account = accounts.find(account => account.id === accountId);
|
|
166
|
+
|
|
167
|
+
if (!account) {
|
|
168
|
+
tracking.signRawTransactionFail(manifest);
|
|
169
|
+
return Promise.reject(new Error("Account required"));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const parentAccount = getParentAccount(account, accounts);
|
|
173
|
+
|
|
174
|
+
return uiNavigation(account, parentAccount, transaction);
|
|
175
|
+
}
|
|
176
|
+
|
|
142
177
|
export function broadcastTransactionLogic(
|
|
143
178
|
{ manifest, accounts, tracking }: WalletAPIContext,
|
|
144
179
|
walletAccountId: string,
|
package/src/wallet-api/react.ts
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
signTransactionLogic,
|
|
38
38
|
bitcoinFamilyAccountGetAddressLogic,
|
|
39
39
|
bitcoinFamilyAccountGetPublicKeyLogic,
|
|
40
|
+
signRawTransactionLogic,
|
|
40
41
|
} from "./logic";
|
|
41
42
|
import { getAccountBridge } from "../bridge";
|
|
42
43
|
import { getEnv } from "@ledgerhq/live-env";
|
|
@@ -154,6 +155,14 @@ export interface UiHook {
|
|
|
154
155
|
}) => void;
|
|
155
156
|
"storage.get": WalletHandlers["storage.get"];
|
|
156
157
|
"storage.set": WalletHandlers["storage.set"];
|
|
158
|
+
"transaction.signRaw": (params: {
|
|
159
|
+
account: AccountLike;
|
|
160
|
+
parentAccount: Account | undefined;
|
|
161
|
+
transaction: string;
|
|
162
|
+
options: Parameters<WalletHandlers["transaction.sign"]>[0]["options"];
|
|
163
|
+
onSuccess: (signedOperation: SignedOperation) => void;
|
|
164
|
+
onError: (error: Error) => void;
|
|
165
|
+
}) => void;
|
|
157
166
|
"transaction.sign": (params: {
|
|
158
167
|
account: AccountLike;
|
|
159
168
|
parentAccount: Account | undefined;
|
|
@@ -320,6 +329,7 @@ export function useWalletAPIServer({
|
|
|
320
329
|
"storage.get": uiStorageGet,
|
|
321
330
|
"storage.set": uiStorageSet,
|
|
322
331
|
"transaction.sign": uiTxSign,
|
|
332
|
+
"transaction.signRaw": uiTxSignRaw,
|
|
323
333
|
"transaction.broadcast": uiTxBroadcast,
|
|
324
334
|
"device.transport": uiDeviceTransport,
|
|
325
335
|
"device.select": uiDeviceSelect,
|
|
@@ -536,6 +546,82 @@ export function useWalletAPIServer({
|
|
|
536
546
|
);
|
|
537
547
|
}, [accounts, manifest, server, tracking, uiTxSign]);
|
|
538
548
|
|
|
549
|
+
useEffect(() => {
|
|
550
|
+
if (!uiTxSignRaw) return;
|
|
551
|
+
|
|
552
|
+
server.setHandler(
|
|
553
|
+
"transaction.signRaw",
|
|
554
|
+
async ({ account, transaction, broadcast, options }) => {
|
|
555
|
+
const signedOperation = await signRawTransactionLogic(
|
|
556
|
+
{ manifest, accounts, tracking },
|
|
557
|
+
account.id,
|
|
558
|
+
transaction,
|
|
559
|
+
(account, parentAccount, tx) =>
|
|
560
|
+
new Promise((resolve, reject) => {
|
|
561
|
+
let done = false;
|
|
562
|
+
return uiTxSignRaw({
|
|
563
|
+
account,
|
|
564
|
+
parentAccount,
|
|
565
|
+
transaction: tx,
|
|
566
|
+
options,
|
|
567
|
+
onSuccess: signedOperation => {
|
|
568
|
+
if (done) return;
|
|
569
|
+
done = true;
|
|
570
|
+
tracking.signRawTransactionSuccess(manifest);
|
|
571
|
+
resolve(signedOperation);
|
|
572
|
+
},
|
|
573
|
+
onError: error => {
|
|
574
|
+
if (done) return;
|
|
575
|
+
done = true;
|
|
576
|
+
tracking.signRawTransactionFail(manifest);
|
|
577
|
+
reject(error);
|
|
578
|
+
},
|
|
579
|
+
});
|
|
580
|
+
}),
|
|
581
|
+
);
|
|
582
|
+
|
|
583
|
+
let hash: string | undefined;
|
|
584
|
+
if (broadcast) {
|
|
585
|
+
hash = await broadcastTransactionLogic(
|
|
586
|
+
{ manifest, accounts, tracking },
|
|
587
|
+
account.id,
|
|
588
|
+
signedOperation,
|
|
589
|
+
async (account, parentAccount, signedOperation) => {
|
|
590
|
+
const bridge = getAccountBridge(account, parentAccount);
|
|
591
|
+
const mainAccount = getMainAccount(account, parentAccount);
|
|
592
|
+
|
|
593
|
+
let optimisticOperation: Operation = signedOperation.operation;
|
|
594
|
+
|
|
595
|
+
if (!getEnv("DISABLE_TRANSACTION_BROADCAST")) {
|
|
596
|
+
try {
|
|
597
|
+
optimisticOperation = await bridge.broadcast({
|
|
598
|
+
account: mainAccount,
|
|
599
|
+
signedOperation,
|
|
600
|
+
broadcastConfig: { mevProtected: !!config.mevProtected },
|
|
601
|
+
});
|
|
602
|
+
tracking.broadcastSuccess(manifest);
|
|
603
|
+
} catch (error) {
|
|
604
|
+
tracking.broadcastFail(manifest);
|
|
605
|
+
throw error;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
uiTxBroadcast &&
|
|
610
|
+
uiTxBroadcast(account, parentAccount, mainAccount, optimisticOperation);
|
|
611
|
+
|
|
612
|
+
return optimisticOperation.hash;
|
|
613
|
+
},
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return {
|
|
618
|
+
signedTransactionHex: signedOperation.signature,
|
|
619
|
+
transactionHash: hash,
|
|
620
|
+
};
|
|
621
|
+
},
|
|
622
|
+
);
|
|
623
|
+
}, [accounts, config.mevProtected, manifest, server, tracking, uiTxBroadcast, uiTxSignRaw]);
|
|
624
|
+
|
|
539
625
|
useEffect(() => {
|
|
540
626
|
if (!uiTxSign) return;
|
|
541
627
|
|
|
@@ -604,7 +690,7 @@ export function useWalletAPIServer({
|
|
|
604
690
|
);
|
|
605
691
|
},
|
|
606
692
|
);
|
|
607
|
-
}, [accounts, manifest, server, tracking, uiTxBroadcast, uiTxSign]);
|
|
693
|
+
}, [accounts, config.mevProtected, manifest, server, tracking, uiTxBroadcast, uiTxSign]);
|
|
608
694
|
|
|
609
695
|
const onLoad = useCallback(() => {
|
|
610
696
|
tracking.loadSuccess(manifest);
|
|
@@ -70,6 +70,21 @@ export default function trackingWrapper(trackCall: TrackWalletAPI) {
|
|
|
70
70
|
track("WalletAPI SignTransaction Success", getEventData(manifest));
|
|
71
71
|
},
|
|
72
72
|
|
|
73
|
+
// Sign Raw transaction modal open
|
|
74
|
+
signRawTransactionRequested: (manifest: AppManifest) => {
|
|
75
|
+
track("WalletAPI SignRawTransaction", getEventData(manifest));
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// Failed to sign raw transaction (cancel or error)
|
|
79
|
+
signRawTransactionFail: (manifest: AppManifest) => {
|
|
80
|
+
track("WalletAPI SignRawTransaction Fail", getEventData(manifest));
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
// Successfully signed raw transaction
|
|
84
|
+
signRawTransactionSuccess: (manifest: AppManifest) => {
|
|
85
|
+
track("WalletAPI SignRawTransaction Success", getEventData(manifest));
|
|
86
|
+
},
|
|
87
|
+
|
|
73
88
|
// Select account modal open
|
|
74
89
|
requestAccountRequested: (manifest: AppManifest) => {
|
|
75
90
|
track("WalletAPI RequestAccount", getEventData(manifest));
|