@ledgerhq/coin-solana 0.31.1 → 0.32.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/.eslintrc.js +1 -0
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +31 -10
- package/lib/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +50 -0
- package/lib/bridge/js.d.ts +2 -1
- package/lib/bridge/js.d.ts.map +1 -1
- package/lib/bridge/js.js +3 -1
- package/lib/bridge/js.js.map +1 -1
- package/lib/bridge.integration.test.d.ts.map +1 -1
- package/lib/bridge.integration.test.js +2 -2
- package/lib/bridge.integration.test.js.map +1 -1
- package/lib/cli-transaction.d.ts.map +1 -1
- package/lib/cli-transaction.js +3 -2
- package/lib/cli-transaction.js.map +1 -1
- package/lib/cryptoAssetsStore.d.ts +5 -0
- package/lib/cryptoAssetsStore.d.ts.map +1 -0
- package/lib/cryptoAssetsStore.js +17 -0
- package/lib/cryptoAssetsStore.js.map +1 -0
- package/lib/cryptoAssetsStore.test.d.ts +2 -0
- package/lib/cryptoAssetsStore.test.d.ts.map +1 -0
- package/lib/cryptoAssetsStore.test.js +15 -0
- package/lib/cryptoAssetsStore.test.js.map +1 -0
- package/lib/helpers/token.d.ts.map +1 -1
- package/lib/helpers/token.js +2 -2
- package/lib/helpers/token.js.map +1 -1
- package/lib/network/chain/index.js +1 -1
- package/lib/network/chain/index.js.map +1 -1
- package/lib/preload.js +1 -1
- package/lib/preload.js.map +1 -1
- package/lib/prepareTransaction.d.ts.map +1 -1
- package/lib/prepareTransaction.js +3 -3
- package/lib/prepareTransaction.js.map +1 -1
- package/lib/synchronization.d.ts.map +1 -1
- package/lib/synchronization.js +3 -3
- package/lib/synchronization.js.map +1 -1
- package/lib/tests/tokens-bridge.unit.test.js +14 -2
- package/lib/tests/tokens-bridge.unit.test.js.map +1 -1
- package/lib/transaction.d.ts.map +1 -1
- package/lib/transaction.js +2 -2
- package/lib/transaction.js.map +1 -1
- package/lib-es/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +50 -0
- package/lib-es/bridge/js.d.ts +2 -1
- package/lib-es/bridge/js.d.ts.map +1 -1
- package/lib-es/bridge/js.js +3 -1
- package/lib-es/bridge/js.js.map +1 -1
- package/lib-es/bridge.integration.test.d.ts.map +1 -1
- package/lib-es/bridge.integration.test.js +2 -2
- package/lib-es/bridge.integration.test.js.map +1 -1
- package/lib-es/cli-transaction.d.ts.map +1 -1
- package/lib-es/cli-transaction.js +3 -2
- package/lib-es/cli-transaction.js.map +1 -1
- package/lib-es/cryptoAssetsStore.d.ts +5 -0
- package/lib-es/cryptoAssetsStore.d.ts.map +1 -0
- package/lib-es/cryptoAssetsStore.js +12 -0
- package/lib-es/cryptoAssetsStore.js.map +1 -0
- package/lib-es/cryptoAssetsStore.test.d.ts +2 -0
- package/lib-es/cryptoAssetsStore.test.d.ts.map +1 -0
- package/lib-es/cryptoAssetsStore.test.js +13 -0
- package/lib-es/cryptoAssetsStore.test.js.map +1 -0
- package/lib-es/helpers/token.d.ts.map +1 -1
- package/lib-es/helpers/token.js +2 -2
- package/lib-es/helpers/token.js.map +1 -1
- package/lib-es/network/chain/index.js +1 -1
- package/lib-es/network/chain/index.js.map +1 -1
- package/lib-es/preload.js +1 -1
- package/lib-es/preload.js.map +1 -1
- package/lib-es/prepareTransaction.d.ts.map +1 -1
- package/lib-es/prepareTransaction.js +3 -3
- package/lib-es/prepareTransaction.js.map +1 -1
- package/lib-es/synchronization.d.ts.map +1 -1
- package/lib-es/synchronization.js +3 -3
- package/lib-es/synchronization.js.map +1 -1
- package/lib-es/tests/tokens-bridge.unit.test.js +14 -2
- package/lib-es/tests/tokens-bridge.unit.test.js.map +1 -1
- package/lib-es/transaction.d.ts.map +1 -1
- package/lib-es/transaction.js +2 -2
- package/lib-es/transaction.js.map +1 -1
- package/package.json +10 -10
- package/src/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +50 -0
- package/src/bridge/js.ts +4 -0
- package/src/bridge.integration.test.ts +2 -2
- package/src/cli-transaction.ts +4 -2
- package/src/cryptoAssetsStore.test.ts +19 -0
- package/src/cryptoAssetsStore.ts +16 -0
- package/src/helpers/token.ts +4 -2
- package/src/network/chain/index.ts +1 -1
- package/src/preload.ts +1 -1
- package/src/prepareTransaction.ts +3 -3
- package/src/synchronization.ts +3 -3
- package/src/tests/tokens-bridge.unit.test.ts +22 -3
- package/src/transaction.ts +6 -2
|
@@ -10,9 +10,8 @@ import {
|
|
|
10
10
|
TransactionStatus,
|
|
11
11
|
} from "../types";
|
|
12
12
|
|
|
13
|
-
import { findTokenByAddressInCurrency } from "@ledgerhq/cryptoassets";
|
|
14
13
|
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
15
|
-
import type { Account } from "@ledgerhq/types-live";
|
|
14
|
+
import type { Account, CryptoAssetsStore } from "@ledgerhq/types-live";
|
|
16
15
|
import {
|
|
17
16
|
SolanaRecipientMemoIsRequired,
|
|
18
17
|
SolanaTokenAccountFrozen,
|
|
@@ -32,6 +31,10 @@ import {
|
|
|
32
31
|
} from "@solana/spl-token";
|
|
33
32
|
import { calculateToken2022TransferFees } from "../helpers/token";
|
|
34
33
|
import { PARSED_PROGRAMS } from "../network/chain/program/constants";
|
|
34
|
+
import { getCryptoAssetsStore, setCryptoAssetsStoreGetter } from "../cryptoAssetsStore";
|
|
35
|
+
import usdcTokenData from "../__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json";
|
|
36
|
+
|
|
37
|
+
const USDC_TOKEN = usdcTokenData as unknown as TokenCurrency;
|
|
35
38
|
|
|
36
39
|
// fake addresses
|
|
37
40
|
const testData = {
|
|
@@ -60,7 +63,23 @@ const mainAccId = encodeAccountId({
|
|
|
60
63
|
|
|
61
64
|
const wSolSubAccId = encodeAccountIdWithTokenAccountAddress(mainAccId, testData.ataAddress1);
|
|
62
65
|
|
|
63
|
-
|
|
66
|
+
setCryptoAssetsStoreGetter(
|
|
67
|
+
() =>
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
69
|
+
({
|
|
70
|
+
findTokenByAddressInCurrency: (address: string, _currencyId: string) => {
|
|
71
|
+
if (address === "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v") {
|
|
72
|
+
return USDC_TOKEN;
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
},
|
|
76
|
+
}) as CryptoAssetsStore,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const wSolToken = getCryptoAssetsStore().findTokenByAddressInCurrency(
|
|
80
|
+
testData.mintAddress,
|
|
81
|
+
"solana",
|
|
82
|
+
) as TokenCurrency;
|
|
64
83
|
|
|
65
84
|
const baseAccount = {
|
|
66
85
|
balance: new BigNumber(10000),
|
package/src/transaction.ts
CHANGED
|
@@ -22,10 +22,10 @@ import {
|
|
|
22
22
|
toTransactionStatusRawCommon as toTransactionStatusRaw,
|
|
23
23
|
} from "@ledgerhq/coin-framework/serialization";
|
|
24
24
|
import type { Account } from "@ledgerhq/types-live";
|
|
25
|
-
import { findTokenByAddressInCurrency } from "@ledgerhq/cryptoassets/index";
|
|
26
25
|
import { findSubAccountById, getAccountCurrency } from "@ledgerhq/coin-framework/account";
|
|
27
26
|
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies";
|
|
28
27
|
import { assertUnreachable } from "./utils";
|
|
28
|
+
import { getCryptoAssetsStore } from "./cryptoAssetsStore";
|
|
29
29
|
|
|
30
30
|
export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
|
|
31
31
|
const common = fromTransactionCommonRaw(tr);
|
|
@@ -153,7 +153,11 @@ function formatTokenTransfer(mainAccount: Account, tx: Transaction, command: Tok
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
function formatCreateATA(mainAccount: Account, command: TokenCreateATACommand) {
|
|
156
|
-
const token = findTokenByAddressInCurrency(
|
|
156
|
+
const token = getCryptoAssetsStore().findTokenByAddressInCurrency(
|
|
157
|
+
command.mint,
|
|
158
|
+
mainAccount.currency.id,
|
|
159
|
+
);
|
|
160
|
+
|
|
157
161
|
if (!token) {
|
|
158
162
|
throw new Error(`token for mint "${command.mint}" not found`);
|
|
159
163
|
}
|