@ledgerhq/live-common 34.51.0-nightly.5 → 34.51.0-nightly.7
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/dada-client/state-manager/api.d.ts.map +1 -1
- package/lib/dada-client/state-manager/api.js +10 -5
- package/lib/dada-client/state-manager/api.js.map +1 -1
- package/lib/dada-client/state-manager/types.d.ts +1 -0
- package/lib/dada-client/state-manager/types.d.ts.map +1 -1
- package/lib/device/use-cases/getAppsCatalogForDevice.d.ts +1 -1
- package/lib/device/use-cases/getAppsCatalogForDevice.d.ts.map +1 -1
- package/lib/e2e/data/deviceLabelsData.d.ts.map +1 -1
- package/lib/e2e/data/deviceLabelsData.js +2 -4
- package/lib/e2e/data/deviceLabelsData.js.map +1 -1
- package/lib/e2e/enum/Device.d.ts +5 -4
- package/lib/e2e/enum/Device.d.ts.map +1 -1
- package/lib/e2e/enum/Device.js +6 -4
- package/lib/e2e/enum/Device.js.map +1 -1
- package/lib/e2e/families/bitcoin.d.ts.map +1 -1
- package/lib/e2e/families/bitcoin.js +4 -3
- package/lib/e2e/families/bitcoin.js.map +1 -1
- package/lib/e2e/families/cardano.js +2 -2
- package/lib/e2e/families/cardano.js.map +1 -1
- package/lib/e2e/families/evm.d.ts.map +1 -1
- package/lib/e2e/families/evm.js +3 -2
- package/lib/e2e/families/evm.js.map +1 -1
- package/lib/e2e/families/solana.d.ts.map +1 -1
- package/lib/e2e/families/solana.js +2 -5
- package/lib/e2e/families/solana.js.map +1 -1
- package/lib/e2e/families/tezos.d.ts.map +1 -1
- package/lib/e2e/families/tezos.js +2 -1
- package/lib/e2e/families/tezos.js.map +1 -1
- package/lib/e2e/index.d.ts +2 -0
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/speculos.d.ts +1 -1
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +53 -60
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/e2e/speculosAppVersion.d.ts +7 -0
- package/lib/e2e/speculosAppVersion.d.ts.map +1 -0
- package/lib/e2e/speculosAppVersion.js +104 -0
- package/lib/e2e/speculosAppVersion.js.map +1 -0
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/usePickDefaultAccount.js +1 -1
- package/lib/exchange/swap/hooks/usePickDefaultAccount.js.map +1 -1
- package/lib/exchange/swap/hooks/useSwapTransaction.d.ts +3 -2
- package/lib/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/useSwapTransaction.js +14 -9
- package/lib/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
- package/lib/exchange/swap/transactionStrategies.d.ts +2 -1
- package/lib/exchange/swap/transactionStrategies.d.ts.map +1 -1
- package/lib/exchange/swap/transactionStrategies.js +3 -1
- package/lib/exchange/swap/transactionStrategies.js.map +1 -1
- package/lib/exchange/swap/types.d.ts +1 -0
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/families/evm/walletApiAdapter.d.ts.map +1 -1
- package/lib/families/evm/walletApiAdapter.js +5 -0
- package/lib/families/evm/walletApiAdapter.js.map +1 -1
- package/lib/load/speculos.d.ts.map +1 -1
- package/lib/load/speculos.js +1 -0
- package/lib/load/speculos.js.map +1 -1
- package/lib/wallet-api/Exchange/server.d.ts +1 -0
- package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/server.js +5 -2
- package/lib/wallet-api/Exchange/server.js.map +1 -1
- package/lib/wallet-api/react.d.ts.map +1 -1
- package/lib/wallet-api/react.js +5 -1
- package/lib/wallet-api/react.js.map +1 -1
- package/lib-es/dada-client/state-manager/api.d.ts.map +1 -1
- package/lib-es/dada-client/state-manager/api.js +10 -5
- package/lib-es/dada-client/state-manager/api.js.map +1 -1
- package/lib-es/dada-client/state-manager/types.d.ts +1 -0
- package/lib-es/dada-client/state-manager/types.d.ts.map +1 -1
- package/lib-es/device/use-cases/getAppsCatalogForDevice.d.ts +1 -1
- package/lib-es/device/use-cases/getAppsCatalogForDevice.d.ts.map +1 -1
- package/lib-es/e2e/data/deviceLabelsData.d.ts.map +1 -1
- package/lib-es/e2e/data/deviceLabelsData.js +2 -4
- package/lib-es/e2e/data/deviceLabelsData.js.map +1 -1
- package/lib-es/e2e/enum/Device.d.ts +5 -4
- package/lib-es/e2e/enum/Device.d.ts.map +1 -1
- package/lib-es/e2e/enum/Device.js +6 -4
- package/lib-es/e2e/enum/Device.js.map +1 -1
- package/lib-es/e2e/families/bitcoin.d.ts.map +1 -1
- package/lib-es/e2e/families/bitcoin.js +4 -3
- package/lib-es/e2e/families/bitcoin.js.map +1 -1
- package/lib-es/e2e/families/cardano.js +2 -2
- package/lib-es/e2e/families/cardano.js.map +1 -1
- package/lib-es/e2e/families/evm.d.ts.map +1 -1
- package/lib-es/e2e/families/evm.js +3 -2
- package/lib-es/e2e/families/evm.js.map +1 -1
- package/lib-es/e2e/families/solana.d.ts.map +1 -1
- package/lib-es/e2e/families/solana.js +3 -6
- package/lib-es/e2e/families/solana.js.map +1 -1
- package/lib-es/e2e/families/tezos.d.ts.map +1 -1
- package/lib-es/e2e/families/tezos.js +2 -1
- package/lib-es/e2e/families/tezos.js.map +1 -1
- package/lib-es/e2e/index.d.ts +2 -0
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/speculos.d.ts +1 -1
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +19 -25
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/e2e/speculosAppVersion.d.ts +7 -0
- package/lib-es/e2e/speculosAppVersion.d.ts.map +1 -0
- package/lib-es/e2e/speculosAppVersion.js +74 -0
- package/lib-es/e2e/speculosAppVersion.js.map +1 -0
- package/lib-es/env.react.d.ts +1 -1
- package/lib-es/env.react.d.ts.map +1 -1
- package/lib-es/exchange/swap/hooks/usePickDefaultAccount.js +2 -2
- package/lib-es/exchange/swap/hooks/usePickDefaultAccount.js.map +1 -1
- package/lib-es/exchange/swap/hooks/useSwapTransaction.d.ts +3 -2
- package/lib-es/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
- package/lib-es/exchange/swap/hooks/useSwapTransaction.js +14 -9
- package/lib-es/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
- package/lib-es/exchange/swap/transactionStrategies.d.ts +2 -1
- package/lib-es/exchange/swap/transactionStrategies.d.ts.map +1 -1
- package/lib-es/exchange/swap/transactionStrategies.js +3 -1
- package/lib-es/exchange/swap/transactionStrategies.js.map +1 -1
- package/lib-es/exchange/swap/types.d.ts +1 -0
- package/lib-es/exchange/swap/types.d.ts.map +1 -1
- package/lib-es/families/evm/walletApiAdapter.d.ts.map +1 -1
- package/lib-es/families/evm/walletApiAdapter.js +5 -0
- package/lib-es/families/evm/walletApiAdapter.js.map +1 -1
- package/lib-es/load/speculos.d.ts.map +1 -1
- package/lib-es/load/speculos.js +1 -0
- package/lib-es/load/speculos.js.map +1 -1
- package/lib-es/wallet-api/Exchange/server.d.ts +1 -0
- package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/server.js +5 -2
- package/lib-es/wallet-api/Exchange/server.js.map +1 -1
- package/lib-es/wallet-api/react.d.ts.map +1 -1
- package/lib-es/wallet-api/react.js +5 -1
- package/lib-es/wallet-api/react.js.map +1 -1
- package/package.json +73 -73
- package/src/dada-client/state-manager/api.ts +10 -5
- package/src/dada-client/state-manager/types.ts +1 -0
- package/src/e2e/data/deviceLabelsData.ts +2 -4
- package/src/e2e/enum/Device.ts +7 -4
- package/src/e2e/families/bitcoin.ts +4 -9
- package/src/e2e/families/cardano.ts +2 -2
- package/src/e2e/families/evm.ts +3 -8
- package/src/e2e/families/solana.ts +2 -7
- package/src/e2e/families/tezos.ts +2 -7
- package/src/e2e/speculos.ts +22 -27
- package/src/e2e/speculosAppVersion.ts +86 -0
- package/src/exchange/swap/hooks/usePickDefaultAccount.ts +2 -2
- package/src/exchange/swap/hooks/useSwapTransaction.ts +20 -7
- package/src/exchange/swap/transactionStrategies.ts +4 -0
- package/src/exchange/swap/types.ts +1 -0
- package/src/families/evm/walletApiAdapter.ts +6 -0
- package/src/load/speculos.ts +1 -0
- package/src/wallet-api/Exchange/server.ts +12 -3
- package/src/wallet-api/react.ts +7 -1
|
@@ -36,6 +36,7 @@ export const useFromAmountStatusMessage = (
|
|
|
36
36
|
{ account, parentAccount, status, transaction }: Result<Transaction>,
|
|
37
37
|
// The order of errors/warnings here will determine the precedence
|
|
38
38
|
statusTypeToInclude: string[],
|
|
39
|
+
sponsored?: boolean,
|
|
39
40
|
): Error | undefined => {
|
|
40
41
|
const statusEntries = useMemo(
|
|
41
42
|
() => statusTypeToInclude.map(statusType => (status.errors || status.warnings)?.[statusType]),
|
|
@@ -65,7 +66,9 @@ export const useFromAmountStatusMessage = (
|
|
|
65
66
|
.filter(errorOrWarning => !(errorOrWarning instanceof AmountRequired));
|
|
66
67
|
const isRelevantStatus = (relevantStatus as Error) instanceof NotEnoughGas;
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
// Skip gas validation for sponsored transactions since gas fees are covered by sponsor
|
|
70
|
+
|
|
71
|
+
if (isRelevantStatus && currency && estimatedFees && !sponsored) {
|
|
69
72
|
const query = new URLSearchParams({
|
|
70
73
|
// get account id first and set it equal to account.
|
|
71
74
|
// if parent account exists then overwrite the former.
|
|
@@ -86,7 +89,15 @@ export const useFromAmountStatusMessage = (
|
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
return relevantStatus;
|
|
89
|
-
}, [
|
|
92
|
+
}, [
|
|
93
|
+
statusEntries,
|
|
94
|
+
currency,
|
|
95
|
+
estimatedFees,
|
|
96
|
+
transaction?.amount,
|
|
97
|
+
account?.id,
|
|
98
|
+
parentAccount?.id,
|
|
99
|
+
sponsored,
|
|
100
|
+
]);
|
|
90
101
|
};
|
|
91
102
|
|
|
92
103
|
type UseSwapTransactionProps = {
|
|
@@ -100,6 +111,7 @@ type UseSwapTransactionProps = {
|
|
|
100
111
|
refreshRate?: number;
|
|
101
112
|
allowRefresh?: boolean;
|
|
102
113
|
isEnabled?: boolean;
|
|
114
|
+
sponsored?: boolean;
|
|
103
115
|
};
|
|
104
116
|
|
|
105
117
|
export const useSwapTransaction = ({
|
|
@@ -113,6 +125,7 @@ export const useSwapTransaction = ({
|
|
|
113
125
|
refreshRate,
|
|
114
126
|
allowRefresh,
|
|
115
127
|
isEnabled,
|
|
128
|
+
sponsored,
|
|
116
129
|
}: UseSwapTransactionProps): SwapTransactionType => {
|
|
117
130
|
const bridgeTransaction = useBridgeTransaction(() => ({
|
|
118
131
|
account: defaultAccount,
|
|
@@ -140,11 +153,11 @@ export const useSwapTransaction = ({
|
|
|
140
153
|
|
|
141
154
|
const { account: toAccount } = toState;
|
|
142
155
|
|
|
143
|
-
const fromAmountError = useFromAmountStatusMessage(
|
|
144
|
-
|
|
145
|
-
"amount",
|
|
146
|
-
|
|
147
|
-
|
|
156
|
+
const fromAmountError = useFromAmountStatusMessage(
|
|
157
|
+
bridgeTransaction,
|
|
158
|
+
["gasPrice", "amount", "gasLimit"],
|
|
159
|
+
sponsored,
|
|
160
|
+
);
|
|
148
161
|
|
|
149
162
|
const { isSwapReversable, reverseSwap } = useReverseAccounts({
|
|
150
163
|
accounts,
|
|
@@ -130,6 +130,7 @@ export function evmTransaction({
|
|
|
130
130
|
recipient,
|
|
131
131
|
customFeeConfig,
|
|
132
132
|
extraTransactionParameters,
|
|
133
|
+
sponsored,
|
|
133
134
|
}: TransactionWithCustomFee): Partial<Extract<Transaction, { family: "evm" }>> {
|
|
134
135
|
if (customFeeConfig?.gasLimit) {
|
|
135
136
|
delete customFeeConfig.gasLimit;
|
|
@@ -142,6 +143,7 @@ export function evmTransaction({
|
|
|
142
143
|
recipient,
|
|
143
144
|
...customFeeConfig,
|
|
144
145
|
data: Buffer.from(extraTransactionParameters, "hex"),
|
|
146
|
+
sponsored,
|
|
145
147
|
};
|
|
146
148
|
}
|
|
147
149
|
return {
|
|
@@ -149,6 +151,7 @@ export function evmTransaction({
|
|
|
149
151
|
amount,
|
|
150
152
|
recipient,
|
|
151
153
|
...customFeeConfig,
|
|
154
|
+
sponsored,
|
|
152
155
|
};
|
|
153
156
|
}
|
|
154
157
|
|
|
@@ -242,6 +245,7 @@ export type TransactionWithCustomFee = TransactionCommon & {
|
|
|
242
245
|
customErrorType?: "swap";
|
|
243
246
|
extraTransactionParameters?: string;
|
|
244
247
|
family: string;
|
|
248
|
+
sponsored?: boolean;
|
|
245
249
|
};
|
|
246
250
|
|
|
247
251
|
// Define a specific type for the strategy functions, assuming they might need parameters
|
|
@@ -37,6 +37,12 @@ const convertToLiveTransaction: ConvertToLiveTransaction<
|
|
|
37
37
|
liveTx.data = walletApiTransaction.data;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
// Propagate sponsored flag if provided by the Wallet API transaction
|
|
41
|
+
// This enables fee validation logic to skip NotEnoughGas for sponsored txs
|
|
42
|
+
if ("sponsored" in walletApiTransaction) {
|
|
43
|
+
liveTx.sponsored = walletApiTransaction.sponsored;
|
|
44
|
+
}
|
|
45
|
+
|
|
40
46
|
if (walletApiTransaction.gasLimit) {
|
|
41
47
|
liveTx.gasLimit = walletApiTransaction.gasLimit;
|
|
42
48
|
liveTx.customGasLimit = walletApiTransaction.gasLimit;
|
package/src/load/speculos.ts
CHANGED
|
@@ -128,6 +128,7 @@ export const findLatestAppCandidate = (
|
|
|
128
128
|
appCandidates: AppCandidate[],
|
|
129
129
|
search: AppSearch,
|
|
130
130
|
): AppCandidate | null => {
|
|
131
|
+
search.firmware = process.env.SPECULOS_FIRMWARE_VERSION;
|
|
131
132
|
let apps = appCandidates.filter(c => appCandidatesMatches(c, search));
|
|
132
133
|
if (apps.length === 0) {
|
|
133
134
|
return null;
|
|
@@ -80,6 +80,7 @@ export type CompleteExchangeUiRequest = {
|
|
|
80
80
|
magnitudeAwareRate?: BigNumber;
|
|
81
81
|
refundAddress?: string;
|
|
82
82
|
payoutAddress?: string;
|
|
83
|
+
sponsored?: boolean;
|
|
83
84
|
};
|
|
84
85
|
type FundStartParamsUiRequest = {
|
|
85
86
|
exchangeType: "FUND";
|
|
@@ -386,6 +387,7 @@ export const handlers = ({
|
|
|
386
387
|
toNewTokenId,
|
|
387
388
|
customFeeConfig,
|
|
388
389
|
swapAppVersion,
|
|
390
|
+
sponsored,
|
|
389
391
|
} = params;
|
|
390
392
|
|
|
391
393
|
const trackingParams = {
|
|
@@ -478,11 +480,14 @@ export const handlers = ({
|
|
|
478
480
|
customFeeConfig: customFeeConfig ?? {},
|
|
479
481
|
payinExtraId,
|
|
480
482
|
extraTransactionParameters,
|
|
483
|
+
sponsored,
|
|
481
484
|
};
|
|
482
485
|
|
|
483
|
-
const transaction = await getStrategy(strategyData, "swap").catch(
|
|
484
|
-
|
|
485
|
-
|
|
486
|
+
const transaction: Transaction = await getStrategy(strategyData, "swap").catch(
|
|
487
|
+
async error => {
|
|
488
|
+
throw error;
|
|
489
|
+
},
|
|
490
|
+
);
|
|
486
491
|
|
|
487
492
|
const mainFromAccount = getMainAccount(fromAccount, fromParentAccount);
|
|
488
493
|
|
|
@@ -553,6 +558,7 @@ export const handlers = ({
|
|
|
553
558
|
magnitudeAwareRate,
|
|
554
559
|
refundAddress,
|
|
555
560
|
payoutAddress,
|
|
561
|
+
sponsored,
|
|
556
562
|
},
|
|
557
563
|
onSuccess: ({ operationHash, swapId }: { operationHash: string; swapId: string }) => {
|
|
558
564
|
tracking.completeExchangeSuccess({
|
|
@@ -775,6 +781,7 @@ interface StrategyParams {
|
|
|
775
781
|
customFeeConfig?: Record<string, unknown>;
|
|
776
782
|
payinExtraId?: string;
|
|
777
783
|
extraTransactionParameters?: string;
|
|
784
|
+
sponsored?: boolean;
|
|
778
785
|
}
|
|
779
786
|
|
|
780
787
|
async function getStrategy(
|
|
@@ -785,6 +792,7 @@ async function getStrategy(
|
|
|
785
792
|
customFeeConfig,
|
|
786
793
|
payinExtraId,
|
|
787
794
|
extraTransactionParameters,
|
|
795
|
+
sponsored,
|
|
788
796
|
}: StrategyParams,
|
|
789
797
|
customErrorType?: any,
|
|
790
798
|
): Promise<Transaction> {
|
|
@@ -823,6 +831,7 @@ async function getStrategy(
|
|
|
823
831
|
payinExtraId,
|
|
824
832
|
extraTransactionParameters,
|
|
825
833
|
customErrorType,
|
|
834
|
+
sponsored,
|
|
826
835
|
});
|
|
827
836
|
} catch (error) {
|
|
828
837
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
package/src/wallet-api/react.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "./converters";
|
|
18
18
|
import { isWalletAPISupportedCurrency } from "./helpers";
|
|
19
19
|
import { WalletAPICurrency, AppManifest, WalletAPIAccount, WalletAPICustomHandlers } from "./types";
|
|
20
|
+
|
|
20
21
|
import { getMainAccount, getParentAccount } from "../account";
|
|
21
22
|
import {
|
|
22
23
|
listCurrencies,
|
|
@@ -628,6 +629,8 @@ export function useWalletAPIServer({
|
|
|
628
629
|
server.setHandler(
|
|
629
630
|
"transaction.signAndBroadcast",
|
|
630
631
|
async ({ account, tokenCurrency, transaction, options }) => {
|
|
632
|
+
const sponsored = transaction.family === "ethereum" && transaction.sponsored;
|
|
633
|
+
|
|
631
634
|
const signedTransaction = await signTransactionLogic(
|
|
632
635
|
{ manifest, accounts, tracking },
|
|
633
636
|
account.id,
|
|
@@ -672,7 +675,10 @@ export function useWalletAPIServer({
|
|
|
672
675
|
optimisticOperation = await bridge.broadcast({
|
|
673
676
|
account: mainAccount,
|
|
674
677
|
signedOperation,
|
|
675
|
-
broadcastConfig: {
|
|
678
|
+
broadcastConfig: {
|
|
679
|
+
mevProtected: !!config.mevProtected,
|
|
680
|
+
sponsored,
|
|
681
|
+
},
|
|
676
682
|
});
|
|
677
683
|
tracking.broadcastSuccess(manifest);
|
|
678
684
|
} catch (error) {
|