@ledgerhq/live-common 21.27.0 → 21.30.1
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/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.js +1 -1
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.js.map +1 -1
- package/lib/__tests__/test-helpers/bridge.js +1 -1
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/apps/hw.d.ts.map +1 -1
- package/lib/apps/hw.js +8 -3
- package/lib/apps/hw.js.map +1 -1
- package/lib/apps/support.d.ts.map +1 -1
- package/lib/apps/support.js +2 -1
- package/lib/apps/support.js.map +1 -1
- package/lib/env.d.ts +10 -10
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +5 -5
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/usePickDefaultAccount.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/usePickDefaultAccount.js +4 -9
- package/lib/exchange/swap/hooks/usePickDefaultAccount.js.map +1 -1
- package/lib/exchange/swap/utils/index.d.ts +6 -1
- package/lib/exchange/swap/utils/index.d.ts.map +1 -1
- package/lib/exchange/swap/utils/index.js +8 -1
- package/lib/exchange/swap/utils/index.js.map +1 -1
- package/lib/exchange/swap/utils/index.test.js +27 -0
- package/lib/exchange/swap/utils/index.test.js.map +1 -1
- package/lib/families/algorand/api/algodv2.d.ts +2 -1
- package/lib/families/algorand/api/algodv2.d.ts.map +1 -1
- package/lib/families/algorand/api/algodv2.js +2 -2
- package/lib/families/algorand/api/algodv2.js.map +1 -1
- package/lib/families/algorand/js-broadcast.js +1 -1
- package/lib/families/algorand/js-broadcast.js.map +1 -1
- package/lib/families/algorand/js-signOperation.d.ts.map +1 -1
- package/lib/families/algorand/js-signOperation.js +1 -1
- package/lib/families/algorand/js-signOperation.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/base.js +19 -20
- package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js +4 -5
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +3 -4
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/decred.js +3 -4
- package/lib/families/bitcoin/wallet-btc/crypto/decred.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/litecoin.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/litecoin.js +3 -4
- package/lib/families/bitcoin/wallet-btc/crypto/litecoin.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js +3 -4
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js +3 -4
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.js +1 -3
- package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/xpub.js +1 -1
- package/lib/families/bitcoin/wallet-btc/xpub.js.map +1 -1
- package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js +1 -1
- package/lib/families/ethereum/datasets/ethereum.scanAccounts.1.js.map +1 -1
- package/lib/families/ethereum/nft.integration.test.js +1 -36
- package/lib/families/ethereum/nft.integration.test.js.map +1 -1
- package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
- package/lib/families/ethereum/synchronisation.js +2 -7
- package/lib/families/ethereum/synchronisation.js.map +1 -1
- package/lib/families/solana/api/chain/index.d.ts +2 -2
- package/lib/families/solana/api/chain/index.d.ts.map +1 -1
- package/lib/families/solana/api/chain/index.js +4 -4
- package/lib/families/solana/api/chain/index.js.map +1 -1
- package/lib/families/solana/bridge/bridge.js +5 -5
- package/lib/families/solana/bridge/bridge.js.map +1 -1
- package/lib/families/solana/bridge/js.js +3 -3
- package/lib/families/solana/bridge/js.js.map +1 -1
- package/lib/families/solana/bridge/mock.js +1 -1
- package/lib/families/solana/bridge/mock.js.map +1 -1
- package/lib/families/solana/test-dataset.d.ts.map +1 -1
- package/lib/families/solana/test-dataset.js +211 -209
- package/lib/families/solana/test-dataset.js.map +1 -1
- package/lib/families/solana/utils.d.ts +1 -2
- package/lib/families/solana/utils.d.ts.map +1 -1
- package/lib/families/solana/utils.js +11 -9
- package/lib/families/solana/utils.js.map +1 -1
- package/lib/families/tezos/datasets/tezos.scanAccounts.1.js +1 -1
- package/lib/families/tezos/datasets/tezos.scanAccounts.1.js.map +1 -1
- package/lib/hw/connectApp.d.ts.map +1 -1
- package/lib/hw/connectApp.js +32 -31
- package/lib/hw/connectApp.js.map +1 -1
- package/lib/market/utils/countervalueFormatter.js +1 -1
- package/lib/market/utils/countervalueFormatter.js.map +1 -1
- package/lib/nft/support.d.ts.map +1 -1
- package/lib/nft/support.js +1 -1
- package/lib/nft/support.js.map +1 -1
- package/lib/platform/PlatformAppProvider/api/api.mock.d.ts.map +1 -1
- package/lib/platform/PlatformAppProvider/api/api.mock.js +27 -0
- package/lib/platform/PlatformAppProvider/api/api.mock.js.map +1 -1
- package/lib/types/manager.d.ts +7 -0
- package/lib/types/manager.d.ts.map +1 -1
- package/lib/types/manager.js +7 -0
- package/lib/types/manager.js.map +1 -1
- package/package.json +13 -13
- package/src/.DS_Store +0 -0
- package/src/__tests__/__snapshots__/all.libcore.ts.snap +87 -226
- package/src/__tests__/families/bitcoin/wallet-btc/xpub.synced.unit.test.ts +1 -1
- package/src/__tests__/test-helpers/bridge.ts +1 -1
- package/src/apps/hw.ts +7 -0
- package/src/apps/support.ts +1 -0
- package/src/{currencies/__snapshots__ → data/flags}/.DS_Store +0 -0
- package/src/env.ts +5 -5
- package/src/exchange/swap/hooks/usePickDefaultAccount.ts +4 -9
- package/src/exchange/swap/utils/index.test.ts +44 -1
- package/src/exchange/swap/utils/index.ts +12 -1
- package/src/families/algorand/api/algodv2.ts +2 -2
- package/src/families/algorand/js-broadcast.ts +1 -1
- package/src/families/algorand/js-signOperation.ts +8 -3
- package/src/families/bitcoin/wallet-btc/crypto/base.ts +41 -20
- package/src/families/bitcoin/wallet-btc/crypto/bitcoin.ts +12 -5
- package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +11 -4
- package/src/families/bitcoin/wallet-btc/crypto/decred.ts +11 -4
- package/src/families/bitcoin/wallet-btc/crypto/litecoin.ts +11 -4
- package/src/families/bitcoin/wallet-btc/crypto/zec.ts +11 -4
- package/src/families/bitcoin/wallet-btc/crypto/zen.ts +11 -4
- package/src/families/bitcoin/wallet-btc/wallet.ts +1 -3
- package/src/families/bitcoin/wallet-btc/xpub.ts +1 -1
- package/src/families/ethereum/datasets/ethereum.scanAccounts.1.ts +43 -43
- package/src/families/ethereum/nft.integration.test.ts +1 -18
- package/src/families/ethereum/synchronisation.ts +1 -6
- package/src/families/solana/api/chain/index.ts +8 -7
- package/src/families/solana/bridge/bridge.ts +11 -11
- package/src/families/solana/bridge/js.ts +3 -3
- package/src/families/solana/bridge/mock.ts +1 -1
- package/src/families/solana/test-dataset.ts +340 -337
- package/src/families/solana/utils.ts +9 -8
- package/src/families/tezos/datasets/tezos.scanAccounts.1.ts +39 -39
- package/src/hw/connectApp.ts +39 -36
- package/src/market/utils/countervalueFormatter.ts +1 -1
- package/src/nft/support.ts +1 -3
- package/src/platform/PlatformAppProvider/api/api.mock.ts +27 -0
- package/src/types/manager.ts +7 -0
- package/lib/families/ethereum/versions.d.ts +0 -2
- package/lib/families/ethereum/versions.d.ts.map +0 -1
- package/lib/families/ethereum/versions.js +0 -5
- package/lib/families/ethereum/versions.js.map +0 -1
- package/src/__tests__/.DS_Store +0 -0
- package/src/families/ethereum/versions.ts +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/cryptoassets";
|
|
2
2
|
import { makeEmptyTokenAccount } from "../../../account";
|
|
3
|
-
import { Account, SubAccount } from "../../../types";
|
|
3
|
+
import { Account, SubAccount, TokenAccount } from "../../../types";
|
|
4
4
|
import type { ExchangeRate } from "../types";
|
|
5
|
+
import { getAccountCurrency } from "../../../account";
|
|
5
6
|
|
|
6
7
|
export const KYC_STATUS = {
|
|
7
8
|
pending: "pending",
|
|
@@ -65,3 +66,13 @@ export function getAccountTuplesForCurrency(
|
|
|
65
66
|
}))
|
|
66
67
|
.filter((a) => (hideEmpty ? a.account?.balance.gt(0) : true));
|
|
67
68
|
}
|
|
69
|
+
|
|
70
|
+
export const getAvailableAccountsById = (
|
|
71
|
+
id: string,
|
|
72
|
+
accounts: ((Account | TokenAccount) & { disabled?: boolean })[]
|
|
73
|
+
): ((Account | TokenAccount) & {
|
|
74
|
+
disabled?: boolean | undefined;
|
|
75
|
+
})[] =>
|
|
76
|
+
accounts
|
|
77
|
+
.filter((acc) => getAccountCurrency(acc)?.id === id && !acc.disabled)
|
|
78
|
+
.sort((a, b) => b.balance.minus(a.balance).toNumber());
|
|
@@ -37,7 +37,6 @@ export const getAccount = async (address: string): Promise<AlgoAccount> => {
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
// TODO Cache
|
|
41
40
|
export const getTransactionParams =
|
|
42
41
|
async (): Promise<AlgoTransactionParams> => {
|
|
43
42
|
const { data } = await network({
|
|
@@ -56,12 +55,13 @@ export const getTransactionParams =
|
|
|
56
55
|
};
|
|
57
56
|
|
|
58
57
|
export const broadcastTransaction = async (
|
|
59
|
-
payload:
|
|
58
|
+
payload: Buffer
|
|
60
59
|
): Promise<string> => {
|
|
61
60
|
const { data }: { data: AlgoTransactionBroadcastResponse } = await network({
|
|
62
61
|
method: "POST",
|
|
63
62
|
url: fullUrl(`/transactions`),
|
|
64
63
|
data: payload,
|
|
64
|
+
headers: { "Content-Type": "application/x-binary" },
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
return data.txId;
|
|
@@ -12,6 +12,6 @@ export const broadcast = async ({
|
|
|
12
12
|
signedOperation: SignedOperation;
|
|
13
13
|
}): Promise<Operation> => {
|
|
14
14
|
const { signature, operation } = signedOperation;
|
|
15
|
-
const hash = await apiBroadcast(signature);
|
|
15
|
+
const hash = await apiBroadcast(Buffer.from(signature, "hex"));
|
|
16
16
|
return patchOperationWithHash(operation, hash);
|
|
17
17
|
};
|
|
@@ -2,7 +2,12 @@ import { BigNumber } from "bignumber.js";
|
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
3
|
import { FeeNotLoaded } from "@ledgerhq/errors";
|
|
4
4
|
import Algorand from "@ledgerhq/hw-app-algorand";
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
Account,
|
|
7
|
+
Operation,
|
|
8
|
+
SignedOperation,
|
|
9
|
+
SignOperationEvent,
|
|
10
|
+
} from "../../types";
|
|
6
11
|
import { withDevice } from "../../hw/deviceAccess";
|
|
7
12
|
import type { Transaction } from "./types";
|
|
8
13
|
import {
|
|
@@ -56,9 +61,9 @@ export const signOperation = ({
|
|
|
56
61
|
type: "signed",
|
|
57
62
|
signedOperation: {
|
|
58
63
|
operation,
|
|
59
|
-
signature: toBroadcast,
|
|
64
|
+
signature: toBroadcast.toString("hex"),
|
|
60
65
|
expirationDate: null,
|
|
61
|
-
},
|
|
66
|
+
} as SignedOperation,
|
|
62
67
|
});
|
|
63
68
|
}
|
|
64
69
|
|
|
@@ -42,13 +42,13 @@ class Base implements ICrypto {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
protected getPubkeyAt(xpub: string, account: number, index: number): Buffer {
|
|
45
|
-
if (!Base.bech32Cache[xpub]) {
|
|
45
|
+
if (!Base.bech32Cache[`${this.network.name}-${xpub}`]) {
|
|
46
46
|
const buffer: Buffer = bs58.decode(xpub);
|
|
47
47
|
const depth: number = buffer[4];
|
|
48
48
|
const i: number = buffer.readUInt32BE(9);
|
|
49
49
|
const chainCode: Buffer = buffer.slice(13, 45);
|
|
50
50
|
const publicKey: Buffer = buffer.slice(45, 78);
|
|
51
|
-
Base.bech32Cache[xpub] = new BIP32(
|
|
51
|
+
Base.bech32Cache[`${this.network.name}-${xpub}`] = new BIP32(
|
|
52
52
|
publicKey,
|
|
53
53
|
chainCode,
|
|
54
54
|
this.network,
|
|
@@ -56,20 +56,30 @@ class Base implements ICrypto {
|
|
|
56
56
|
i
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
|
-
if (
|
|
60
|
-
|
|
59
|
+
if (
|
|
60
|
+
Base.publickeyCache[`${this.network.name}-${xpub}-${account}-${index}`]
|
|
61
|
+
) {
|
|
62
|
+
return Base.publickeyCache[
|
|
63
|
+
`${this.network.name}-${xpub}-${account}-${index}`
|
|
64
|
+
];
|
|
61
65
|
}
|
|
62
|
-
if (Base.publickeyCache[`${xpub}-${account}`]) {
|
|
66
|
+
if (Base.publickeyCache[`${this.network.name}-${xpub}-${account}`]) {
|
|
63
67
|
const publicKey =
|
|
64
|
-
Base.publickeyCache[`${xpub}-${account}`].derive(
|
|
65
|
-
|
|
68
|
+
Base.publickeyCache[`${this.network.name}-${xpub}-${account}`].derive(
|
|
69
|
+
index
|
|
70
|
+
).publicKey;
|
|
71
|
+
Base.publickeyCache[`${this.network.name}-${xpub}-${account}-${index}`] =
|
|
72
|
+
publicKey;
|
|
66
73
|
return publicKey;
|
|
67
74
|
}
|
|
68
|
-
Base.publickeyCache[`${xpub}-${account}`] =
|
|
69
|
-
Base.bech32Cache[xpub].derive(account);
|
|
75
|
+
Base.publickeyCache[`${this.network.name}-${xpub}-${account}`] =
|
|
76
|
+
Base.bech32Cache[`${this.network.name}-${xpub}`].derive(account);
|
|
70
77
|
const publicKey =
|
|
71
|
-
Base.publickeyCache[`${xpub}-${account}`].derive(
|
|
72
|
-
|
|
78
|
+
Base.publickeyCache[`${this.network.name}-${xpub}-${account}`].derive(
|
|
79
|
+
index
|
|
80
|
+
).publicKey;
|
|
81
|
+
Base.publickeyCache[`${this.network.name}-${xpub}-${account}-${index}`] =
|
|
82
|
+
publicKey;
|
|
73
83
|
return publicKey;
|
|
74
84
|
}
|
|
75
85
|
|
|
@@ -110,26 +120,37 @@ class Base implements ICrypto {
|
|
|
110
120
|
account: number,
|
|
111
121
|
index: number
|
|
112
122
|
): string {
|
|
113
|
-
if (
|
|
114
|
-
|
|
123
|
+
if (
|
|
124
|
+
Base.addressCache[
|
|
125
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
126
|
+
]
|
|
127
|
+
) {
|
|
128
|
+
return Base.addressCache[
|
|
129
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
130
|
+
];
|
|
115
131
|
}
|
|
116
132
|
switch (derivationMode) {
|
|
117
133
|
case DerivationModes.LEGACY:
|
|
118
|
-
Base.addressCache[
|
|
119
|
-
this.
|
|
134
|
+
Base.addressCache[
|
|
135
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
136
|
+
] = this.getLegacyAddress(xpub, account, index);
|
|
120
137
|
break;
|
|
121
138
|
case DerivationModes.SEGWIT:
|
|
122
|
-
Base.addressCache[
|
|
123
|
-
this.
|
|
139
|
+
Base.addressCache[
|
|
140
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
141
|
+
] = this.getSegWitAddress(xpub, account, index);
|
|
124
142
|
break;
|
|
125
143
|
case DerivationModes.NATIVE_SEGWIT:
|
|
126
|
-
Base.addressCache[
|
|
127
|
-
this.
|
|
144
|
+
Base.addressCache[
|
|
145
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
146
|
+
] = this.getNativeSegWitAddress(xpub, account, index);
|
|
128
147
|
break;
|
|
129
148
|
default:
|
|
130
149
|
throw new Error(`Invalid derivation Mode: ${derivationMode}`);
|
|
131
150
|
}
|
|
132
|
-
return Base.addressCache[
|
|
151
|
+
return Base.addressCache[
|
|
152
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
153
|
+
];
|
|
133
154
|
}
|
|
134
155
|
|
|
135
156
|
// infer address type from its syntax
|
|
@@ -125,15 +125,22 @@ class Bitcoin extends Base {
|
|
|
125
125
|
account: number,
|
|
126
126
|
index: number
|
|
127
127
|
): string {
|
|
128
|
-
if (
|
|
129
|
-
|
|
128
|
+
if (
|
|
129
|
+
Base.addressCache[
|
|
130
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
131
|
+
]
|
|
132
|
+
) {
|
|
133
|
+
return Base.addressCache[
|
|
134
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
135
|
+
];
|
|
130
136
|
}
|
|
131
137
|
switch (derivationMode) {
|
|
132
138
|
case DerivationModes.TAPROOT:
|
|
133
|
-
Base.addressCache[
|
|
134
|
-
this.
|
|
139
|
+
Base.addressCache[
|
|
140
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
141
|
+
] = this.getTaprootAddress(xpub, account, index);
|
|
135
142
|
return Base.addressCache[
|
|
136
|
-
`${derivationMode}-${xpub}-${account}-${index}`
|
|
143
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
137
144
|
];
|
|
138
145
|
default:
|
|
139
146
|
return super.getAddress(derivationMode, xpub, account, index);
|
|
@@ -47,12 +47,19 @@ class BitcoinCash implements ICrypto {
|
|
|
47
47
|
account: number,
|
|
48
48
|
index: number
|
|
49
49
|
): string {
|
|
50
|
-
if (
|
|
51
|
-
|
|
50
|
+
if (
|
|
51
|
+
Base.addressCache[
|
|
52
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
53
|
+
]
|
|
54
|
+
) {
|
|
55
|
+
return Base.addressCache[
|
|
56
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
57
|
+
];
|
|
52
58
|
}
|
|
53
59
|
const address = this.getLegacyBitcoinCashAddress(xpub, account, index);
|
|
54
|
-
Base.addressCache[
|
|
55
|
-
|
|
60
|
+
Base.addressCache[
|
|
61
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
62
|
+
] = address;
|
|
56
63
|
return address;
|
|
57
64
|
}
|
|
58
65
|
|
|
@@ -74,8 +74,14 @@ class Decred extends Base {
|
|
|
74
74
|
account: number,
|
|
75
75
|
index: number
|
|
76
76
|
): string {
|
|
77
|
-
if (
|
|
78
|
-
|
|
77
|
+
if (
|
|
78
|
+
Base.addressCache[
|
|
79
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
80
|
+
]
|
|
81
|
+
) {
|
|
82
|
+
return Base.addressCache[
|
|
83
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
84
|
+
];
|
|
79
85
|
}
|
|
80
86
|
let buffer: Buffer;
|
|
81
87
|
try {
|
|
@@ -90,8 +96,9 @@ class Decred extends Base {
|
|
|
90
96
|
const hd = new BIP32(X, chainCode, this.network, depth, i);
|
|
91
97
|
const publicKey = hd.derive(account).derive(index).publicKey;
|
|
92
98
|
const address = Decred.getAddressFromPk(publicKey);
|
|
93
|
-
Base.addressCache[
|
|
94
|
-
|
|
99
|
+
Base.addressCache[
|
|
100
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
101
|
+
] = address;
|
|
95
102
|
return address;
|
|
96
103
|
}
|
|
97
104
|
}
|
|
@@ -59,8 +59,14 @@ class Litecoin extends Base implements ICrypto {
|
|
|
59
59
|
account: number,
|
|
60
60
|
index: number
|
|
61
61
|
): string {
|
|
62
|
-
if (
|
|
63
|
-
|
|
62
|
+
if (
|
|
63
|
+
Base.addressCache[
|
|
64
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
65
|
+
]
|
|
66
|
+
) {
|
|
67
|
+
return Base.addressCache[
|
|
68
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
69
|
+
];
|
|
64
70
|
}
|
|
65
71
|
let address: string;
|
|
66
72
|
switch (derivationMode) {
|
|
@@ -76,8 +82,9 @@ class Litecoin extends Base implements ICrypto {
|
|
|
76
82
|
default:
|
|
77
83
|
throw new Error("Should not be reachable");
|
|
78
84
|
}
|
|
79
|
-
Base.addressCache[
|
|
80
|
-
|
|
85
|
+
Base.addressCache[
|
|
86
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
87
|
+
] = address;
|
|
81
88
|
return address;
|
|
82
89
|
}
|
|
83
90
|
|
|
@@ -53,12 +53,19 @@ class ZCash implements ICrypto {
|
|
|
53
53
|
account: number,
|
|
54
54
|
index: number
|
|
55
55
|
): string {
|
|
56
|
-
if (
|
|
57
|
-
|
|
56
|
+
if (
|
|
57
|
+
Base.addressCache[
|
|
58
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
59
|
+
]
|
|
60
|
+
) {
|
|
61
|
+
return Base.addressCache[
|
|
62
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
63
|
+
];
|
|
58
64
|
}
|
|
59
65
|
const address = this.getLegacyAddress(xpub, account, index);
|
|
60
|
-
Base.addressCache[
|
|
61
|
-
|
|
66
|
+
Base.addressCache[
|
|
67
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
68
|
+
] = address;
|
|
62
69
|
return address;
|
|
63
70
|
}
|
|
64
71
|
|
|
@@ -73,12 +73,19 @@ class Zen implements ICrypto {
|
|
|
73
73
|
account: number,
|
|
74
74
|
index: number
|
|
75
75
|
): string {
|
|
76
|
-
if (
|
|
77
|
-
|
|
76
|
+
if (
|
|
77
|
+
Base.addressCache[
|
|
78
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
79
|
+
]
|
|
80
|
+
) {
|
|
81
|
+
return Base.addressCache[
|
|
82
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
83
|
+
];
|
|
78
84
|
}
|
|
79
85
|
const address = this.getLegacyAddress(xpub, account, index);
|
|
80
|
-
Base.addressCache[
|
|
81
|
-
|
|
86
|
+
Base.addressCache[
|
|
87
|
+
`${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
|
|
88
|
+
] = address;
|
|
82
89
|
return address;
|
|
83
90
|
}
|
|
84
91
|
|
|
@@ -272,9 +272,7 @@ class BitcoinLikeWallet {
|
|
|
272
272
|
if (additionals && additionals.includes("peercoin")) {
|
|
273
273
|
// remove timestamp for new version of peercoin input, refer to https://github.com/peercoin/rfcs/issues/5 and https://github.com/LedgerHQ/ledgerjs/issues/701
|
|
274
274
|
const version = i.txHex.substring(0, 8);
|
|
275
|
-
|
|
276
|
-
hasTimestamp = false;
|
|
277
|
-
}
|
|
275
|
+
hasTimestamp = version === "01000000" || version === "02000000";
|
|
278
276
|
}
|
|
279
277
|
log("hw", `splitTransaction`, {
|
|
280
278
|
transactionHex: i.txHex,
|
|
@@ -67,7 +67,7 @@ class Xpub extends EventEmitter {
|
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
this.storage.addAddress(
|
|
70
|
-
`${this.derivationMode}-${this.xpub}-${account}-${index}`,
|
|
70
|
+
`${this.crypto.network.name}-${this.derivationMode}-${this.xpub}-${account}-${index}`,
|
|
71
71
|
address
|
|
72
72
|
);
|
|
73
73
|
await this.whenSynced("address", address);
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
name: "ethereum seed 1",
|
|
3
3
|
apdus: `
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
4
|
+
=> e00200000d038000002c8000003c80000000
|
|
5
|
+
<= 410469877df9567b58e6ef8f6cf1fb8a8e1bf28a327dee31b183a6b9cd1f3da063af0924506a9912793ef31e41df19f8653fa31bb1fecc32d2e41abdddb22ccb621028373561453661383832363036353137343345356546433033373937313136413335363539663638359000
|
|
6
|
+
=> e002000011048000002c8000003c8000000000000000
|
|
7
|
+
<= 4104b7577f404537d1e934a8d2a1fd2552a7f399928b5af0aad714acc17b36865b3f5d1843d6a580c737c051656ac35978283a388a759911d289e9994071247d167528356466304333363936343142384166336337653961653037364535343636654636373833313943649000
|
|
8
|
+
=> e002000011048000002c8000003c8000000000000001
|
|
9
|
+
<= 4104bee21a16156c645d0150e262c40648b9fd938c6462efe3adf9051efe077d30b356c86b8bc8a182e58cdc514e6d0c2670f6626d34f78220187e2d279d661d23f628446336313732383838343733383239324134373236353042624133653936433261344638383739369000
|
|
10
|
+
=> e002000011048000002c8000003c8000000000000002
|
|
11
|
+
<= 410467f77bf213f0de5fd7ae7ac2ca2b6f7ad6cacecbb8688acd0bcf0fcc5b7b58512fe786639619b9f4a513061dd0355590ec5b7d2c4d934c43a37778920bf07e1a28623262344230413836384543326530613162326533314131304142414130393365463032386544389000
|
|
12
|
+
=> e002000011048000002c8000003c8000000000000003
|
|
13
|
+
<= 4104dcce479cd733a7972cea67f0b5bf92d786a1e62a9afe5e50ddd2f7f7c8c1aaff89e28b236f5f1e75c702c3c0116de49dde6b32f06f66937f0b190bdd730bd84e28613563334139333430364465323733666639386244443343653935314232653431423137436443469000
|
|
14
|
+
=> e002000011048000002c8000003c8000000000000004
|
|
15
|
+
<= 4104b60582b8ea13540e5292396949f9d2ed23d9ec4344e2463e9fe7fa36c12372da03a0427c48d653dd59abfcbb7628b323076415f1fd53bc601b8071d82ddd635528393945363561463136626644393139303246623638394163373938343338633042464334373439359000
|
|
16
|
+
=> e002000011048000002c8000003c8000000000000005
|
|
17
|
+
<= 4104126bf90b475158cb8c947dbe47d9ecdff88c34c96c7b7f4fc17a05257dff1024c089fd51f657fa7f5b1041d23bc67d46cd0dd4df86c5318f653486199313e18f28663736394533463933663831313733653836333365354461653646433031426262443163634230389000
|
|
18
|
+
=> e002000011048000002c8000003c8000000000000006
|
|
19
|
+
<= 4104dc7934183510e92e07136e9192da7d5bbd4c3a757b4d9bdf8dcca9baabdf8efddfad24ef74e8a0db52d9e4171516665ff6e4cd152273f460627933df3ced177828463439386638653139323342653437633335343932376445334332313661633341453734666535619000
|
|
20
|
+
=> e002000011048000002c8000003c8000000000000007
|
|
21
|
+
<= 4104b7664a7012f69cee691362377df6d8558b0acfe1541dbf95af90e919d6867ac9d46b3b0b42e98fe8543c15ae501fed3d85869fd0310d9804faed0d07ae3b871628353932393338336336626631624439666533383462423665363162394232413230416637434361429000
|
|
22
|
+
=> e002000011048000002c8000003c8000000000000008
|
|
23
|
+
<= 41045cdb8bc99d890837444698a53d9c18d22c6159e0727e051fee54e7299318282d3fe882b4aa133e7e15529e90b824b4f83ea5242b3ad4651c7d9cca12c796e45428634339303838363541443934303634623733433739663235393861373966393843654544364446619000
|
|
24
|
+
=> e002000011048000002c8000003c8000000000000009
|
|
25
|
+
<= 4104720ec99d2297e627e239764e519be6900d06fc3d9145e306daeace60944c3c6dc14e74f24d27fc98278c0c07de821bae71ed5c95e9a7b95538637e817763609128373731663039424535353143386346393734426141426336373365324232323132643637383236469000
|
|
26
|
+
=> e002000011048000002c8000003c800000000000000a
|
|
27
|
+
<= 41043a98496a4115f61e264bd74ba1ea661729ccfa239e72318ecbd307fb747d2032be5e308e435b24417320a95b719d60b7740b0bf297f926b414b4d3b44d903a9f28384138383238373537353662333831336262613844644631376634304232363064423232466334379000
|
|
28
|
+
=> e002000011048000002c8000003c800000000000000b
|
|
29
|
+
<= 41040f3a6497cdef24c68b895a0d8a9f8b54e16ee84e4905a24236a242a82a900e068cb72ad71f52b57dfa41e00090cd035d1a4205dbe3982ac88189c743edb856a828646431344537456135384533384343316134653737386265663338323831664139413134353232419000
|
|
30
|
+
=> e002000015058000002c8000003c800000000000000000000001
|
|
31
|
+
<= 41040374fb34926a57e184cdd3438109021b3169a9c74ffe726d1abc7a187fa9440a11f071b96f72c8e9e0ea1f82dc2180166bd8c7bae9401cdd3d2466a40e1755ca28304536613732456439323243323338394466303365383666354537394261374336344535343933379000
|
|
32
|
+
=> e002000015058000002c8000003c800000000000000000000000
|
|
33
|
+
<= 410478f6d00bc3be349f69a8b88b3957d569d7ed44d27d0824988107ba1a6117cfcefc22b03b9be870ddadb643eeda4357761d44419cfbdccb19701be086780ff71128304533463062623935313646303166324333346332354530393537353138623861433934313463359000
|
|
34
|
+
=> e002000015058000002c8000003c800000010000000000000000
|
|
35
|
+
<= 4104c20d717f7652a279588b267457c051e387fbeb8648b730cd3daeaa8fa3774f37ab535ab9bd024b87776b77b3409546a0b64e1b14828ea43891b4200318fc90fd28363637463942453934613432343538636235334133413636353131446361313962333937373338649000
|
|
36
|
+
=> e002000015058000002c8000003c800000020000000000000000
|
|
37
|
+
<= 4104e788111a6c0254ec8184453383d2d8b18c8e0b86d1fea93c2691a9bc6240572f24129a634155d1291228a1721fc88737f75e51bb7575ccc69937d649c1422ea028386639353530323931314338316135454332626134623831356564326432433565316338383932359000
|
|
38
|
+
=> e002000015058000002c8000003c800000030000000000000000
|
|
39
|
+
<= 4104ffd79641446518c675ad32e6434a2aba9e7c426200bc336d78222cbec00d2c8aa7a8c685084f450870e2a801049795ba051f8b3a878a586158697d6bd4ce0b6d28386261343131303566464135343531306362394436376362334137323632344434303532634130389000
|
|
40
|
+
=> e002000015058000002c8000003c800000040000000000000000
|
|
41
|
+
<= 4104602f7c0f3f73a914b3dd83e8bb6f11f3dc8ea1d2c7308fa4f8d9d2000a4419eec324393f4cf191e83f3adc64de9388f5979664c6d6dac4c23c0566d7aabbddfa28366233343933464531383145413238336530333335653544384437363865323132326243366331389000
|
|
42
|
+
=> e002000015058000002c8000003c800000050000000000000000
|
|
43
|
+
<= 410484f94dfa2c52fee4f8b37b578b0087de88ee282cb788a56af1eabd7711ddd37e6da1c9eada59926b7828d7e12db21c443ed0a2ca4521561806d3175407a557c128323546456139343435344664334137413138443935383131463565346562353733633163434334329000
|
|
44
|
+
=> e002000015058000002c8000003c800000060000000000000000
|
|
45
|
+
<= 4104e7c7f373d0a568554b5372b68f6e697aee3947c053ee5d882afba2f2c9a44273768b2e61b01de519b0c1f365e23aea5e3d041a40a347a125e202a2d7d7ef596828624636373337664138373538463134443838376531646633323442423431363136334533366436319000
|
|
46
|
+
`,
|
|
47
47
|
};
|
|
@@ -5,7 +5,6 @@ import type { Account, AccountRaw } from "../../types";
|
|
|
5
5
|
import { getAccountBridge } from "../../bridge";
|
|
6
6
|
import { makeBridgeCacheSystem } from "../../bridge/cache";
|
|
7
7
|
import { patchAccount } from "../../reconciliation";
|
|
8
|
-
import { setEnv } from "../../env";
|
|
9
8
|
|
|
10
9
|
jest.setTimeout(200000);
|
|
11
10
|
|
|
@@ -68,10 +67,9 @@ const gaspardBscAccount: AccountRaw = {
|
|
|
68
67
|
xpub: "",
|
|
69
68
|
};
|
|
70
69
|
|
|
71
|
-
async function sync(account
|
|
70
|
+
async function sync(account) {
|
|
72
71
|
const bridge = getAccountBridge(account);
|
|
73
72
|
const blacklistedTokenIds = [];
|
|
74
|
-
setEnv("NFT", withNFT);
|
|
75
73
|
const r = await bridge
|
|
76
74
|
.sync(account, {
|
|
77
75
|
paginationConfig: {},
|
|
@@ -79,7 +77,6 @@ async function sync(account, withNFT = true) {
|
|
|
79
77
|
})
|
|
80
78
|
.pipe(reduce((a, f: (arg0: Account) => Account) => f(a), account))
|
|
81
79
|
.toPromise();
|
|
82
|
-
setEnv("NFT", false);
|
|
83
80
|
return r;
|
|
84
81
|
}
|
|
85
82
|
|
|
@@ -128,20 +125,6 @@ ethTestingAccounts.forEach((a) => {
|
|
|
128
125
|
const resync = await sync(copy);
|
|
129
126
|
expect(resync.nfts).toEqual(account.nfts);
|
|
130
127
|
});
|
|
131
|
-
|
|
132
|
-
test("start account with .nfts and disable the NFT flag should make it disappear", async () => {
|
|
133
|
-
expect(account.nfts).not.toBeFalsy();
|
|
134
|
-
const resync = await sync(account, false);
|
|
135
|
-
expect(resync.nfts).toBeFalsy();
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
test("start account without .nfts and enable the NFT flag should make it appear", async () => {
|
|
139
|
-
const first = await sync(account, false);
|
|
140
|
-
expect(first.nfts).toBeFalsy();
|
|
141
|
-
const second = await sync(first, true);
|
|
142
|
-
expect(second.nfts).not.toBeFalsy();
|
|
143
|
-
expect(second.nfts).toEqual(account.nfts);
|
|
144
|
-
});
|
|
145
128
|
});
|
|
146
129
|
});
|
|
147
130
|
|
|
@@ -20,7 +20,6 @@ import { API, apiForCurrency, Tx } from "../../api/Ethereum";
|
|
|
20
20
|
import { digestTokenAccounts, prepareTokenAccounts } from "./modules";
|
|
21
21
|
import { findTokenByAddressInCurrency } from "@ledgerhq/cryptoassets";
|
|
22
22
|
import { encodeNftId, isNFTActive, nftsFromOperations } from "../../nft";
|
|
23
|
-
import { NFT_VERSION } from "./versions";
|
|
24
23
|
|
|
25
24
|
export const getAccountShape: GetAccountShape = async (
|
|
26
25
|
infoInput,
|
|
@@ -40,15 +39,12 @@ export const getAccountShape: GetAccountShape = async (
|
|
|
40
39
|
const initialStableOperations = initialAccount
|
|
41
40
|
? stableOperations(initialAccount)
|
|
42
41
|
: [];
|
|
43
|
-
const shouldNFTBeActive = isNFTActive(currency);
|
|
44
42
|
// fetch transactions, incrementally if possible
|
|
45
43
|
const mostRecentStableOperation = initialStableOperations[0];
|
|
46
44
|
// when new tokens are added / blacklist changes, we need to sync again because we need to go through all operations again
|
|
47
45
|
const syncHash =
|
|
48
46
|
JSON.stringify(blacklistedTokenIds || []) +
|
|
49
47
|
"_" +
|
|
50
|
-
shouldNFTBeActive +
|
|
51
|
-
"_" +
|
|
52
48
|
listTokensForCryptoCurrency(currency, {
|
|
53
49
|
withDelisted: true,
|
|
54
50
|
}).length;
|
|
@@ -57,8 +53,7 @@ export const getAccountShape: GetAccountShape = async (
|
|
|
57
53
|
initialAccount &&
|
|
58
54
|
areAllOperationsLoaded(initialAccount) &&
|
|
59
55
|
mostRecentStableOperation &&
|
|
60
|
-
!outdatedSyncHash
|
|
61
|
-
NFT_VERSION
|
|
56
|
+
!outdatedSyncHash
|
|
62
57
|
? mostRecentStableOperation.blockHash
|
|
63
58
|
: undefined;
|
|
64
59
|
const txsP = fetchAllTransactions(api, address, pullFromBlockHash);
|
|
@@ -4,17 +4,16 @@ import {
|
|
|
4
4
|
TOKEN_PROGRAM_ID,
|
|
5
5
|
} from "@solana/spl-token";
|
|
6
6
|
import {
|
|
7
|
-
Cluster,
|
|
8
|
-
clusterApiUrl,
|
|
9
7
|
Connection,
|
|
10
8
|
FeeCalculator,
|
|
11
9
|
PublicKey,
|
|
10
|
+
sendAndConfirmRawTransaction,
|
|
12
11
|
SignaturesForAddressOptions,
|
|
13
12
|
} from "@solana/web3.js";
|
|
14
13
|
import { Awaited } from "../../logic";
|
|
15
14
|
|
|
16
15
|
export type Config = {
|
|
17
|
-
readonly
|
|
16
|
+
readonly endpoint: string;
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
export type ChainAPI = Readonly<{
|
|
@@ -59,8 +58,7 @@ export type ChainAPI = Readonly<{
|
|
|
59
58
|
}>;
|
|
60
59
|
|
|
61
60
|
export function getChainAPI(config: Config): ChainAPI {
|
|
62
|
-
const connection = () =>
|
|
63
|
-
new Connection(clusterApiUrl(config.cluster), "finalized");
|
|
61
|
+
const connection = () => new Connection(config.endpoint, "finalized");
|
|
64
62
|
|
|
65
63
|
return {
|
|
66
64
|
getBalance: (address: string) =>
|
|
@@ -96,8 +94,11 @@ export function getChainAPI(config: Config): ChainAPI {
|
|
|
96
94
|
.getParsedAccountInfo(new PublicKey(address))
|
|
97
95
|
.then((r) => r.value),
|
|
98
96
|
|
|
99
|
-
sendRawTransaction: (buffer: Buffer) =>
|
|
100
|
-
connection()
|
|
97
|
+
sendRawTransaction: (buffer: Buffer) => {
|
|
98
|
+
return sendAndConfirmRawTransaction(connection(), buffer, {
|
|
99
|
+
commitment: "confirmed",
|
|
100
|
+
});
|
|
101
|
+
},
|
|
101
102
|
|
|
102
103
|
findAssocTokenAccAddress: (owner: string, mint: string) =>
|
|
103
104
|
Token.getAssociatedTokenAddress(
|