@ledgerhq/coin-solana 0.37.0 → 0.38.0-nightly.20251126160702
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/CHANGELOG.md +31 -0
- package/lib/bridge/bridge.d.ts +2 -4
- package/lib/bridge/bridge.d.ts.map +1 -1
- package/lib/bridge/bridge.js +16 -16
- package/lib/bridge/bridge.js.map +1 -1
- package/lib/bridge/js.d.ts +1 -2
- package/lib/bridge/js.d.ts.map +1 -1
- package/lib/bridge/js.js +9 -11
- package/lib/bridge/js.js.map +1 -1
- package/lib/cli-transaction.js +2 -2
- package/lib/cli-transaction.js.map +1 -1
- package/lib/config.d.ts +0 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/helpers/token.js +2 -2
- package/lib/helpers/token.js.map +1 -1
- package/lib/network/chain/index.d.ts.map +1 -1
- package/lib/network/chain/index.js +29 -38
- package/lib/network/chain/index.js.map +1 -1
- package/lib/network/chain/web3.d.ts.map +1 -1
- package/lib/network/chain/web3.js +9 -5
- package/lib/network/chain/web3.js.map +1 -1
- package/lib/network/index.d.ts +0 -2
- package/lib/network/index.d.ts.map +1 -1
- package/lib/network/index.js +1 -5
- package/lib/network/index.js.map +1 -1
- package/lib/network/nft/index.js +3 -3
- package/lib/network/nft/index.js.map +1 -1
- package/lib/preload-data.d.ts.map +1 -1
- package/lib/preload-data.js +0 -1
- package/lib/preload-data.js.map +1 -1
- package/lib/preload.d.ts +2 -6
- package/lib/preload.d.ts.map +1 -1
- package/lib/preload.js +2 -107
- package/lib/preload.js.map +1 -1
- package/lib/prepareTransaction.js +2 -2
- package/lib/prepareTransaction.js.map +1 -1
- package/lib/signOperation.d.ts +1 -1
- package/lib/signOperation.d.ts.map +1 -1
- package/lib/signOperation.js +1 -1
- package/lib/signOperation.js.map +1 -1
- package/lib/synchronization.d.ts.map +1 -1
- package/lib/synchronization.js +11 -7
- package/lib/synchronization.js.map +1 -1
- package/lib/transaction.js +2 -2
- package/lib/transaction.js.map +1 -1
- package/lib/types.d.ts +0 -2
- package/lib/types.d.ts.map +1 -1
- package/lib-es/bridge/bridge.d.ts +2 -4
- package/lib-es/bridge/bridge.d.ts.map +1 -1
- package/lib-es/bridge/bridge.js +17 -17
- package/lib-es/bridge/bridge.js.map +1 -1
- package/lib-es/bridge/js.d.ts +1 -2
- package/lib-es/bridge/js.d.ts.map +1 -1
- package/lib-es/bridge/js.js +10 -12
- package/lib-es/bridge/js.js.map +1 -1
- package/lib-es/cli-transaction.js +1 -1
- package/lib-es/cli-transaction.js.map +1 -1
- package/lib-es/config.d.ts +0 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/helpers/token.js +1 -1
- package/lib-es/helpers/token.js.map +1 -1
- package/lib-es/network/chain/index.d.ts.map +1 -1
- package/lib-es/network/chain/index.js +29 -38
- package/lib-es/network/chain/index.js.map +1 -1
- package/lib-es/network/chain/web3.d.ts.map +1 -1
- package/lib-es/network/chain/web3.js +9 -5
- package/lib-es/network/chain/web3.js.map +1 -1
- package/lib-es/network/index.d.ts +0 -2
- package/lib-es/network/index.d.ts.map +1 -1
- package/lib-es/network/index.js +0 -2
- package/lib-es/network/index.js.map +1 -1
- package/lib-es/network/nft/index.js +1 -1
- package/lib-es/network/nft/index.js.map +1 -1
- package/lib-es/preload-data.d.ts.map +1 -1
- package/lib-es/preload-data.js +0 -1
- package/lib-es/preload-data.js.map +1 -1
- package/lib-es/preload.d.ts +2 -6
- package/lib-es/preload.d.ts.map +1 -1
- package/lib-es/preload.js +2 -81
- package/lib-es/preload.js.map +1 -1
- package/lib-es/prepareTransaction.js +1 -1
- package/lib-es/prepareTransaction.js.map +1 -1
- package/lib-es/signOperation.d.ts +1 -1
- package/lib-es/signOperation.d.ts.map +1 -1
- package/lib-es/signOperation.js +1 -1
- package/lib-es/signOperation.js.map +1 -1
- package/lib-es/synchronization.d.ts.map +1 -1
- package/lib-es/synchronization.js +10 -6
- package/lib-es/synchronization.js.map +1 -1
- package/lib-es/transaction.js +1 -1
- package/lib-es/transaction.js.map +1 -1
- package/lib-es/types.d.ts +0 -2
- package/lib-es/types.d.ts.map +1 -1
- package/package.json +6 -8
- package/src/__tests__/getTransactions.test.ts +81 -0
- package/src/__tests__/unit/hw-signMessage.unit.test.ts +0 -1
- package/src/bridge/bridge.ts +27 -35
- package/src/bridge/js.ts +9 -29
- package/src/cli-transaction.ts +1 -1
- package/src/config.ts +0 -1
- package/src/helpers/token.ts +1 -1
- package/src/network/chain/index.ts +29 -38
- package/src/network/chain/web3.integration.test.ts +21 -1
- package/src/network/chain/web3.ts +11 -5
- package/src/network/index.ts +0 -2
- package/src/network/nft/index.ts +1 -1
- package/src/preload-data.ts +0 -1
- package/src/preload.test.ts +121 -12
- package/src/preload.ts +2 -111
- package/src/prepareTransaction.ts +1 -1
- package/src/signOperation.test.ts +2 -2
- package/src/signOperation.ts +2 -2
- package/src/synchronization.ts +10 -6
- package/src/tests/tokens-bridge.unit.test.ts +11 -16
- package/src/transaction.ts +1 -1
- package/src/types.ts +0 -2
- package/lib/cryptoAssetsStore.d.ts +0 -5
- package/lib/cryptoAssetsStore.d.ts.map +0 -1
- package/lib/cryptoAssetsStore.js +0 -17
- package/lib/cryptoAssetsStore.js.map +0 -1
- package/lib/network/cached.d.ts +0 -3
- package/lib/network/cached.d.ts.map +0 -1
- package/lib/network/cached.js +0 -56
- package/lib/network/cached.js.map +0 -1
- package/lib/network/queued.d.ts +0 -3
- package/lib/network/queued.d.ts.map +0 -1
- package/lib/network/queued.js +0 -27
- package/lib/network/queued.js.map +0 -1
- package/lib/network/traced.d.ts +0 -3
- package/lib/network/traced.d.ts.map +0 -1
- package/lib/network/traced.js +0 -80
- package/lib/network/traced.js.map +0 -1
- package/lib-es/cryptoAssetsStore.d.ts +0 -5
- package/lib-es/cryptoAssetsStore.d.ts.map +0 -1
- package/lib-es/cryptoAssetsStore.js +0 -12
- package/lib-es/cryptoAssetsStore.js.map +0 -1
- package/lib-es/network/cached.d.ts +0 -3
- package/lib-es/network/cached.d.ts.map +0 -1
- package/lib-es/network/cached.js +0 -49
- package/lib-es/network/cached.js.map +0 -1
- package/lib-es/network/queued.d.ts +0 -3
- package/lib-es/network/queued.d.ts.map +0 -1
- package/lib-es/network/queued.js +0 -23
- package/lib-es/network/queued.js.map +0 -1
- package/lib-es/network/traced.d.ts +0 -3
- package/lib-es/network/traced.d.ts.map +0 -1
- package/lib-es/network/traced.js +0 -76
- package/lib-es/network/traced.js.map +0 -1
- package/src/cryptoAssetsStore.test.ts +0 -19
- package/src/cryptoAssetsStore.ts +0 -16
- package/src/network/cached.ts +0 -111
- package/src/network/queued.ts +0 -25
- package/src/network/traced.ts +0 -89
- package/src/tests/preload.unit.test.ts +0 -182
package/src/preload.ts
CHANGED
|
@@ -1,99 +1,26 @@
|
|
|
1
1
|
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
2
|
import { flow } from "lodash/fp";
|
|
3
3
|
import { ChainAPI } from "./network";
|
|
4
|
-
import { log } from "@ledgerhq/logs";
|
|
5
4
|
import { setSolanaPreloadData as setPreloadData } from "./preload-data";
|
|
6
5
|
import { SolanaPreloadData, SolanaPreloadDataV1 } from "./types";
|
|
7
|
-
import {
|
|
8
|
-
assertUnreachable,
|
|
9
|
-
clusterByCurrencyId,
|
|
10
|
-
profitableValidators,
|
|
11
|
-
ledgerFirstValidators,
|
|
12
|
-
} from "./utils";
|
|
6
|
+
import { clusterByCurrencyId, profitableValidators, ledgerFirstValidators } from "./utils";
|
|
13
7
|
import { getValidators, ValidatorsAppValidator } from "./network/validator-app";
|
|
14
|
-
import spltokensList, { hash as embeddedHash, SPLToken } from "@ledgerhq/cryptoassets/data/spl";
|
|
15
|
-
import { fetchTokensFromCALService } from "@ledgerhq/cryptoassets/crypto-assets-importer/fetch/index";
|
|
16
|
-
import { getCALHash, setCALHash } from "./logic";
|
|
17
|
-
import { addTokens, convertSplTokens } from "@ledgerhq/cryptoassets/legacy/legacy-utils";
|
|
18
|
-
import { AxiosError } from "axios";
|
|
19
|
-
|
|
20
|
-
let shouldSkipTokenLoading = false;
|
|
21
|
-
|
|
22
|
-
export function setShouldSkipTokenLoading(skip: boolean): void {
|
|
23
|
-
shouldSkipTokenLoading = skip;
|
|
24
|
-
}
|
|
25
8
|
|
|
26
9
|
export const PRELOAD_MAX_AGE = 15 * 60 * 1000; // 15min
|
|
27
10
|
|
|
28
|
-
export const fetchSPLTokens: (
|
|
29
|
-
currency: CryptoCurrency,
|
|
30
|
-
) => Promise<SPLToken[] | null> = async currency => {
|
|
31
|
-
const latestCALHash = getCALHash(currency);
|
|
32
|
-
const calHash = latestCALHash || embeddedHash;
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const { tokens, hash } = await fetchTokensFromCALService(
|
|
36
|
-
{ blockchain_name: "solana" },
|
|
37
|
-
["id", "network", "name", "ticker", "contract_address", "decimals"],
|
|
38
|
-
calHash,
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const splTokens: SPLToken[] = tokens.map(token => [
|
|
42
|
-
token.id,
|
|
43
|
-
token.network,
|
|
44
|
-
token.name,
|
|
45
|
-
token.ticker,
|
|
46
|
-
token.contract_address,
|
|
47
|
-
token.decimals,
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
setCALHash(currency, hash || "");
|
|
51
|
-
log("solana/preload", "preload " + splTokens.length + " tokens");
|
|
52
|
-
|
|
53
|
-
if (!shouldSkipTokenLoading) {
|
|
54
|
-
addTokens(splTokens.map(convertSplTokens));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return splTokens;
|
|
58
|
-
} catch (e) {
|
|
59
|
-
if (e instanceof AxiosError && e.response?.status === 304) {
|
|
60
|
-
log(
|
|
61
|
-
"solana/preload",
|
|
62
|
-
`loading existing fallback tokens for solana with hash ${latestCALHash || embeddedHash}`,
|
|
63
|
-
);
|
|
64
|
-
if (!latestCALHash) {
|
|
65
|
-
setCALHash(currency, embeddedHash);
|
|
66
|
-
if (!shouldSkipTokenLoading) {
|
|
67
|
-
addTokens(spltokensList.map(convertSplTokens));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return spltokensList;
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
log("solana/preload", `failure to retrieve tokens for solana`, e);
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
11
|
export async function preloadWithAPI(
|
|
80
12
|
currency: CryptoCurrency,
|
|
81
|
-
|
|
13
|
+
api: ChainAPI,
|
|
82
14
|
): Promise<SolanaPreloadDataV1> {
|
|
83
|
-
const api = await getAPI();
|
|
84
|
-
|
|
85
15
|
const cluster = clusterByCurrencyId(currency.id);
|
|
86
16
|
|
|
87
17
|
const validators: ValidatorsAppValidator[] =
|
|
88
18
|
cluster === "devnet" ? await loadDevnetValidators(api) : await getValidators(cluster);
|
|
89
19
|
|
|
90
|
-
const splTokens = await fetchSPLTokens(currency);
|
|
91
|
-
|
|
92
20
|
const data: SolanaPreloadData = {
|
|
93
21
|
version: "1",
|
|
94
22
|
validatorsWithMeta: [],
|
|
95
23
|
validators: cluster === "mainnet-beta" ? preprocessMainnetValidators(validators) : validators,
|
|
96
|
-
splTokens,
|
|
97
24
|
};
|
|
98
25
|
|
|
99
26
|
setPreloadData(data, currency);
|
|
@@ -117,39 +44,3 @@ async function loadDevnetValidators(api: ChainAPI) {
|
|
|
117
44
|
}));
|
|
118
45
|
return validators;
|
|
119
46
|
}
|
|
120
|
-
|
|
121
|
-
export function hydrate(data: SolanaPreloadData | undefined, currency: CryptoCurrency): void {
|
|
122
|
-
// https://ledgerhq.atlassian.net/browse/LIVE-11568 covers unknown case where version is undefined
|
|
123
|
-
if (!data || !data.version) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
switch (data.version) {
|
|
128
|
-
case "1":
|
|
129
|
-
hydrateV1(data, currency);
|
|
130
|
-
return;
|
|
131
|
-
case "2":
|
|
132
|
-
throw new Error("version 2 for now exists only to support discriminated union");
|
|
133
|
-
default:
|
|
134
|
-
return assertUnreachable(data);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function hydrateV1(data: SolanaPreloadDataV1, currency: CryptoCurrency) {
|
|
139
|
-
if (Array.isArray(data.splTokens)) {
|
|
140
|
-
if (!shouldSkipTokenLoading) {
|
|
141
|
-
addTokens(data.splTokens.map(convertSplTokens));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
log("solana/preload", `hydrate ${data.splTokens.length} tokens`);
|
|
145
|
-
setPreloadData(data, currency);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (!shouldSkipTokenLoading) {
|
|
150
|
-
addTokens(spltokensList.map(convertSplTokens));
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
log("solana/preload", `hydrate fallback ${spltokensList.length} embedded tokens`);
|
|
154
|
-
setPreloadData(data, currency);
|
|
155
|
-
}
|
|
@@ -81,7 +81,7 @@ import { TokenAccountInfo } from "./network/chain/account/token";
|
|
|
81
81
|
import { deriveRawCommandDescriptor, toLiveTransaction } from "./rawTransaction";
|
|
82
82
|
import BigNumber from "bignumber.js";
|
|
83
83
|
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/formatCurrencyUnit";
|
|
84
|
-
import { getCryptoAssetsStore } from "
|
|
84
|
+
import { getCryptoAssetsStore } from "@ledgerhq/cryptoassets/state";
|
|
85
85
|
|
|
86
86
|
async function deriveCommandDescriptor(
|
|
87
87
|
mainAccount: SolanaAccount,
|
|
@@ -42,7 +42,7 @@ describe("Testing signOperation", () => {
|
|
|
42
42
|
|
|
43
43
|
const observable = buildSignOperation(
|
|
44
44
|
signContext(),
|
|
45
|
-
api,
|
|
45
|
+
api(),
|
|
46
46
|
)({
|
|
47
47
|
account: account(),
|
|
48
48
|
deviceId: "any random value",
|
|
@@ -118,7 +118,7 @@ function blockhashWithExpiryBlockHeight() {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
function api() {
|
|
121
|
-
return
|
|
121
|
+
return {} as ChainAPI;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
function account(): Account {
|
package/src/signOperation.ts
CHANGED
|
@@ -98,7 +98,7 @@ function getResolution(
|
|
|
98
98
|
export const buildSignOperation =
|
|
99
99
|
(
|
|
100
100
|
signerContext: SignerContext<SolanaSigner>,
|
|
101
|
-
api:
|
|
101
|
+
api: ChainAPI,
|
|
102
102
|
): AccountBridge<Transaction>["signOperation"] =>
|
|
103
103
|
({ account, deviceId, deviceModelId, transaction, certificateSignatureKind }) =>
|
|
104
104
|
new Observable(subscriber => {
|
|
@@ -106,7 +106,7 @@ export const buildSignOperation =
|
|
|
106
106
|
const [tx, recentBlockhash, signOnChainTransaction] = await buildTransactionWithAPI(
|
|
107
107
|
account.freshAddress,
|
|
108
108
|
transaction,
|
|
109
|
-
|
|
109
|
+
api,
|
|
110
110
|
);
|
|
111
111
|
|
|
112
112
|
subscriber.next({
|
package/src/synchronization.ts
CHANGED
|
@@ -50,7 +50,7 @@ import { getStakeAccounts } from "./network/chain/stake-activation/rpc";
|
|
|
50
50
|
import { tryParseAsMintAccount } from "./network/chain/account";
|
|
51
51
|
import ky from "ky";
|
|
52
52
|
import { isSignaturesForAddressResponse } from "./utils";
|
|
53
|
-
import { getCryptoAssetsStore } from "
|
|
53
|
+
import { getCryptoAssetsStore } from "@ledgerhq/cryptoassets/state";
|
|
54
54
|
|
|
55
55
|
export async function getAccount(
|
|
56
56
|
address: string,
|
|
@@ -132,12 +132,16 @@ export async function getTokenAccountsTransactions(
|
|
|
132
132
|
const txs = json.result.length
|
|
133
133
|
? await api.getParsedTransactions(json.result.map(({ signature }) => signature))
|
|
134
134
|
: [];
|
|
135
|
-
const
|
|
135
|
+
const sortedTxs = txs.sort((a, b) => (b?.slot ?? 0) - (a?.slot ?? 0));
|
|
136
|
+
const descriptors = sortedTxs.reduce((acc, tx) => {
|
|
136
137
|
if (tx && !tx.meta?.err && tx.blockTime) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
const info = json.result.find(s => tx.transaction.signatures.includes(s.signature))!;
|
|
139
|
+
if (info) {
|
|
140
|
+
acc.push({
|
|
141
|
+
info,
|
|
142
|
+
parsed: tx,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
141
145
|
}
|
|
142
146
|
return acc;
|
|
143
147
|
}, [] as TransactionDescriptor[]);
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "../types";
|
|
12
12
|
|
|
13
13
|
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
14
|
-
import type { Account
|
|
14
|
+
import type { Account } from "@ledgerhq/types-live";
|
|
15
15
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
16
16
|
import {
|
|
17
17
|
SolanaRecipientMemoIsRequired,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
} from "@solana/spl-token";
|
|
33
33
|
import { calculateToken2022TransferFees } from "../helpers/token";
|
|
34
34
|
import { PARSED_PROGRAMS } from "../network/chain/program/constants";
|
|
35
|
-
import {
|
|
35
|
+
import { setupMockCryptoAssetsStore } from "@ledgerhq/cryptoassets/cal-client/test-helpers";
|
|
36
36
|
import usdcTokenData from "../__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json";
|
|
37
37
|
|
|
38
38
|
const USDC_TOKEN = usdcTokenData as unknown as TokenCurrency;
|
|
@@ -64,20 +64,15 @@ const mainAccId = encodeAccountId({
|
|
|
64
64
|
|
|
65
65
|
const wSolSubAccId = encodeAccountIdWithTokenAccountAddress(mainAccId, testData.ataAddress1);
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
() =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
findTokenById: async () => undefined,
|
|
78
|
-
getTokensSyncHash: (_: string) => Promise.resolve("0"),
|
|
79
|
-
}) as CryptoAssetsStore,
|
|
80
|
-
);
|
|
67
|
+
setupMockCryptoAssetsStore({
|
|
68
|
+
findTokenByAddressInCurrency: async (address: string, _currencyId: string) => {
|
|
69
|
+
if (address === "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v") {
|
|
70
|
+
return USDC_TOKEN;
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
},
|
|
74
|
+
getTokensSyncHash: async () => "0",
|
|
75
|
+
});
|
|
81
76
|
|
|
82
77
|
// Create a mock token for testing
|
|
83
78
|
const wSolToken: TokenCurrency = {
|
package/src/transaction.ts
CHANGED
|
@@ -25,7 +25,7 @@ import type { Account } from "@ledgerhq/types-live";
|
|
|
25
25
|
import { findSubAccountById, getAccountCurrency } from "@ledgerhq/coin-framework/account";
|
|
26
26
|
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies";
|
|
27
27
|
import { assertUnreachable } from "./utils";
|
|
28
|
-
import { getCryptoAssetsStore } from "
|
|
28
|
+
import { getCryptoAssetsStore } from "@ledgerhq/cryptoassets/state";
|
|
29
29
|
|
|
30
30
|
export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
|
|
31
31
|
const common = fromTransactionCommonRaw(tr);
|
package/src/types.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import { ValidatorsAppValidator } from "./network/validator-app";
|
|
14
14
|
import { TokenAccountState } from "./network/chain/account/token";
|
|
15
15
|
import { PARSED_PROGRAMS } from "./network/chain/program/constants";
|
|
16
|
-
import type { SPLToken } from "@ledgerhq/cryptoassets/data/spl";
|
|
17
16
|
|
|
18
17
|
export type TransferCommand = {
|
|
19
18
|
kind: "transfer";
|
|
@@ -307,7 +306,6 @@ export type SolanaPreloadDataV1 = {
|
|
|
307
306
|
version: "1";
|
|
308
307
|
validatorsWithMeta: SolanaValidatorWithMeta[];
|
|
309
308
|
validators: ValidatorsAppValidator[];
|
|
310
|
-
splTokens: SPLToken[] | null;
|
|
311
309
|
};
|
|
312
310
|
|
|
313
311
|
// exists for discriminated union to work
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { CryptoAssetsStore, CryptoAssetsStoreGetter } from "@ledgerhq/types-live";
|
|
2
|
-
export declare const CRYPTO_ASSETS_STORE_NO_SET_ERROR_MESSAGE = "CryptoAssetsStore is not set. Please call setCryptoAssetsStore first on coin solana";
|
|
3
|
-
export declare function setCryptoAssetsStoreGetter(cryptoAssetsStoreGetter: CryptoAssetsStoreGetter): void;
|
|
4
|
-
export declare function getCryptoAssetsStore(): CryptoAssetsStore;
|
|
5
|
-
//# sourceMappingURL=cryptoAssetsStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoAssetsStore.d.ts","sourceRoot":"","sources":["../src/cryptoAssetsStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAElF,eAAO,MAAM,wCAAwC,wFACkC,CAAC;AAGxF,wBAAgB,0BAA0B,CAAC,uBAAuB,EAAE,uBAAuB,GAAG,IAAI,CAEjG;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CAKxD"}
|
package/lib/cryptoAssetsStore.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCryptoAssetsStore = exports.setCryptoAssetsStoreGetter = exports.CRYPTO_ASSETS_STORE_NO_SET_ERROR_MESSAGE = void 0;
|
|
4
|
-
exports.CRYPTO_ASSETS_STORE_NO_SET_ERROR_MESSAGE = "CryptoAssetsStore is not set. Please call setCryptoAssetsStore first on coin solana";
|
|
5
|
-
let getStore;
|
|
6
|
-
function setCryptoAssetsStoreGetter(cryptoAssetsStoreGetter) {
|
|
7
|
-
getStore = cryptoAssetsStoreGetter;
|
|
8
|
-
}
|
|
9
|
-
exports.setCryptoAssetsStoreGetter = setCryptoAssetsStoreGetter;
|
|
10
|
-
function getCryptoAssetsStore() {
|
|
11
|
-
if (!getStore) {
|
|
12
|
-
throw new Error(exports.CRYPTO_ASSETS_STORE_NO_SET_ERROR_MESSAGE);
|
|
13
|
-
}
|
|
14
|
-
return getStore();
|
|
15
|
-
}
|
|
16
|
-
exports.getCryptoAssetsStore = getCryptoAssetsStore;
|
|
17
|
-
//# sourceMappingURL=cryptoAssetsStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoAssetsStore.js","sourceRoot":"","sources":["../src/cryptoAssetsStore.ts"],"names":[],"mappings":";;;AAEa,QAAA,wCAAwC,GACnD,qFAAqF,CAAC;AAExF,IAAI,QAAiC,CAAC;AACtC,SAAgB,0BAA0B,CAAC,uBAAgD;IACzF,QAAQ,GAAG,uBAAuB,CAAC;AACrC,CAAC;AAFD,gEAEC;AAED,SAAgB,oBAAoB;IAClC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,gDAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,EAAE,CAAC;AACpB,CAAC;AALD,oDAKC"}
|
package/lib/network/cached.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cached.d.ts","sourceRoot":"","sources":["../../src/network/cached.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAuBnC,wBAAgB,MAAM,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAoF9C"}
|
package/lib/network/cached.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.cached = void 0;
|
|
7
|
-
const cache_1 = require("@ledgerhq/live-network/cache");
|
|
8
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
9
|
-
const object_hash_1 = __importDefault(require("object-hash"));
|
|
10
|
-
const cacheKeyAddress = (address) => address;
|
|
11
|
-
const cacheKeyEmpty = () => "";
|
|
12
|
-
const cacheKeyAssocTokenAccAddress = (owner, mint) => `${owner}:${mint}`;
|
|
13
|
-
const cacheKeyMinimumBalanceForRentExemption = (dataLengt) => dataLengt.toString();
|
|
14
|
-
const cacheKeyTransactions = (signatures) => (0, object_hash_1.default)([...signatures].sort());
|
|
15
|
-
const cacheKeyAddresses = (addresses) => (0, object_hash_1.default)([...addresses].sort());
|
|
16
|
-
const cacheKeyInstructions = (ixs, payer) => {
|
|
17
|
-
return (0, object_hash_1.default)(new web3_js_1.TransactionMessage({
|
|
18
|
-
instructions: ixs,
|
|
19
|
-
payerKey: payer,
|
|
20
|
-
recentBlockhash: payer.toString(),
|
|
21
|
-
})
|
|
22
|
-
.compileToLegacyMessage()
|
|
23
|
-
.serialize());
|
|
24
|
-
};
|
|
25
|
-
const cacheKeyByArgs = (...args) => (0, object_hash_1.default)(args);
|
|
26
|
-
function cached(api) {
|
|
27
|
-
return {
|
|
28
|
-
findAssocTokenAccAddress: (0, cache_1.makeLRUCache)(api.findAssocTokenAccAddress, cacheKeyAssocTokenAccAddress, (0, cache_1.minutes)(1000)),
|
|
29
|
-
getAccountInfo: (0, cache_1.makeLRUCache)(api.getAccountInfo, cacheKeyAddress, (0, cache_1.seconds)(30)),
|
|
30
|
-
getMultipleAccounts: (0, cache_1.makeLRUCache)(api.getMultipleAccounts, cacheKeyAddresses, (0, cache_1.seconds)(30)),
|
|
31
|
-
getAssocTokenAccMinNativeBalance: (0, cache_1.makeLRUCache)(api.getAssocTokenAccMinNativeBalance, cacheKeyEmpty, (0, cache_1.minutes)(5)),
|
|
32
|
-
getBalance: (0, cache_1.makeLRUCache)(api.getBalance, cacheKeyAddress, (0, cache_1.seconds)(30)),
|
|
33
|
-
getBalanceAndContext: (0, cache_1.makeLRUCache)(api.getBalanceAndContext, cacheKeyAddress, (0, cache_1.seconds)(30)),
|
|
34
|
-
getParsedTransactions: (0, cache_1.makeLRUCache)(api.getParsedTransactions, cacheKeyTransactions, (0, cache_1.seconds)(30)),
|
|
35
|
-
getParsedTokenAccountsByOwner: (0, cache_1.makeLRUCache)(api.getParsedTokenAccountsByOwner, cacheKeyAddress, (0, cache_1.minutes)(1)),
|
|
36
|
-
getParsedToken2022AccountsByOwner: (0, cache_1.makeLRUCache)(api.getParsedToken2022AccountsByOwner, cacheKeyAddress, (0, cache_1.minutes)(1)),
|
|
37
|
-
// cached by default in api
|
|
38
|
-
getStakeAccountsByStakeAuth: api.getStakeAccountsByStakeAuth,
|
|
39
|
-
getStakeAccountsByWithdrawAuth: api.getStakeAccountsByWithdrawAuth,
|
|
40
|
-
getInflationReward: (0, cache_1.makeLRUCache)(api.getInflationReward, cacheKeyByArgs, (0, cache_1.minutes)(5)),
|
|
41
|
-
getVoteAccounts: (0, cache_1.makeLRUCache)(api.getVoteAccounts, cacheKeyEmpty, (0, cache_1.minutes)(1)),
|
|
42
|
-
getLatestBlockhash: (0, cache_1.makeLRUCache)(api.getLatestBlockhash, cacheKeyEmpty, (0, cache_1.seconds)(15)),
|
|
43
|
-
getFeeForMessage: (0, cache_1.makeLRUCache)(api.getFeeForMessage, msg => msg.serialize().toString(), (0, cache_1.minutes)(1)),
|
|
44
|
-
getSignaturesForAddress: (0, cache_1.makeLRUCache)(api.getSignaturesForAddress, cacheKeyByArgs, (0, cache_1.seconds)(30)),
|
|
45
|
-
getMinimumBalanceForRentExemption: (0, cache_1.makeLRUCache)(api.getMinimumBalanceForRentExemption, cacheKeyMinimumBalanceForRentExemption, (0, cache_1.minutes)(5)),
|
|
46
|
-
// do not cache
|
|
47
|
-
sendRawTransaction: api.sendRawTransaction,
|
|
48
|
-
getEpochInfo: (0, cache_1.makeLRUCache)(api.getEpochInfo, cacheKeyEmpty, (0, cache_1.minutes)(1)),
|
|
49
|
-
getRecentPrioritizationFees: (0, cache_1.makeLRUCache)(api.getRecentPrioritizationFees, cacheKeyByArgs, (0, cache_1.seconds)(30)),
|
|
50
|
-
getSimulationComputeUnits: (0, cache_1.makeLRUCache)(api.getSimulationComputeUnits, cacheKeyInstructions, (0, cache_1.seconds)(30)),
|
|
51
|
-
config: api.config,
|
|
52
|
-
connection: api.connection,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
exports.cached = cached;
|
|
56
|
-
//# sourceMappingURL=cached.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cached.js","sourceRoot":"","sources":["../../src/network/cached.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA8E;AAC9E,6CAAwF;AACxF,8DAA+B;AAG/B,MAAM,eAAe,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC;AACrD,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,EAAW,CAAC;AACxC,MAAM,4BAA4B,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC;AACzF,MAAM,sCAAsC,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;AAE3F,MAAM,oBAAoB,GAAG,CAAC,UAAoB,EAAE,EAAE,CAAC,IAAA,qBAAI,EAAC,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACpF,MAAM,iBAAiB,GAAG,CAAC,SAAmB,EAAE,EAAE,CAAC,IAAA,qBAAI,EAAC,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC/E,MAAM,oBAAoB,GAAG,CAAC,GAA6B,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CAAC,2BAA2B,EAC/B,cAAc,EACd,IAAA,eAAO,EAAC,EAAE,CAAC,CACZ;QAED,yBAAyB,EAAE,IAAA,oBAAY,EACrC,GAAG,CAAC,yBAAyB,EAC7B,oBAAoB,EACpB,IAAA,eAAO,EAAC,EAAE,CAAC,CACZ;QAED,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,UAAU,EAAE,GAAG,CAAC,UAAU;KAC3B,CAAC;AACJ,CAAC;AApFD,wBAoFC"}
|
package/lib/network/queued.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queued.d.ts","sourceRoot":"","sources":["../../src/network/queued.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,gBAAgB,SAAM,GAAG,QAAQ,CAqBtE"}
|
package/lib/network/queued.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.queued = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
function queued(api, delayBetweenRuns = 100) {
|
|
6
|
-
const q = (0, utils_1.asyncQueue)({
|
|
7
|
-
delayBetweenRuns,
|
|
8
|
-
});
|
|
9
|
-
const proxy = new Proxy(api, {
|
|
10
|
-
get(target, propKey, receiver) {
|
|
11
|
-
const targetValue = Reflect.get(target, propKey, receiver);
|
|
12
|
-
if (typeof targetValue === "function") {
|
|
13
|
-
return function (...args) {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
|
-
// @ts-ignore: TS-2683
|
|
16
|
-
return q.submit(() => targetValue.apply(this, args));
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return targetValue;
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
return proxy;
|
|
25
|
-
}
|
|
26
|
-
exports.queued = queued;
|
|
27
|
-
//# sourceMappingURL=queued.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queued.js","sourceRoot":"","sources":["../../src/network/queued.ts"],"names":[],"mappings":";;;AAAA,oCAAsC;AAGtC,SAAgB,MAAM,CAAC,GAAa,EAAE,gBAAgB,GAAG,GAAG;IAC1D,MAAM,CAAC,GAAG,IAAA,kBAAU,EAAC;QACnB,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,KAAK,GAAa,IAAI,KAAK,CAAC,GAAG,EAAE;QACrC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ;YAC3B,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC3D,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;gBACtC,OAAO,UAAU,GAAG,IAAe;oBACjC,6DAA6D;oBAC7D,sBAAsB;oBACtB,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBACvD,CAAC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,WAAW,CAAC;YACrB,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AArBD,wBAqBC"}
|
package/lib/network/traced.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"traced.d.ts","sourceRoot":"","sources":["../../src/network/traced.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,MAAM,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,CA0E9C"}
|
package/lib/network/traced.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traced = void 0;
|
|
4
|
-
const logs_1 = require("@ledgerhq/logs");
|
|
5
|
-
const live_env_1 = require("@ledgerhq/live-env");
|
|
6
|
-
function traced(api) {
|
|
7
|
-
const state = {
|
|
8
|
-
reqId: 0,
|
|
9
|
-
reqStartTime: new Map(),
|
|
10
|
-
};
|
|
11
|
-
const startReqTrace = () => {
|
|
12
|
-
state.reqId += 1;
|
|
13
|
-
state.reqStartTime.set(state.reqId, Date.now());
|
|
14
|
-
return state.reqId;
|
|
15
|
-
};
|
|
16
|
-
const stopReqTrace = (reqId) => {
|
|
17
|
-
const reqStartTime = state.reqStartTime.get(reqId);
|
|
18
|
-
if (reqStartTime === undefined) {
|
|
19
|
-
(0, logs_1.log)("warn", `request start time not found for request id <${reqId}>`);
|
|
20
|
-
return {
|
|
21
|
-
duration: 0,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
state.reqStartTime.delete(reqId);
|
|
25
|
-
return {
|
|
26
|
-
duration: Date.now() - reqStartTime,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
const proxy = new Proxy(api, {
|
|
30
|
-
get(target, propKey, receiver) {
|
|
31
|
-
if (typeof propKey === "symbol") {
|
|
32
|
-
throw new Error("symbols not supported");
|
|
33
|
-
}
|
|
34
|
-
const targetValue = Reflect.get(target, propKey, receiver);
|
|
35
|
-
if (typeof targetValue === "function") {
|
|
36
|
-
return function (...args) {
|
|
37
|
-
const reqId = startReqTrace();
|
|
38
|
-
(0, logs_1.log)("network", formatMsg({ reqId, msg: `calling <${propKey}>` }), {
|
|
39
|
-
args,
|
|
40
|
-
});
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
|
-
// @ts-ignore: TS-2683
|
|
43
|
-
const result = targetValue.apply(this, args);
|
|
44
|
-
if (result instanceof Promise) {
|
|
45
|
-
return result
|
|
46
|
-
.then(answer => {
|
|
47
|
-
const { duration } = stopReqTrace(reqId);
|
|
48
|
-
(0, logs_1.log)("network-success", formatMsg({ reqId, msg: "success", duration }), (0, live_env_1.getEnv)("DEBUG_HTTP_RESPONSE") ? { answer } : undefined);
|
|
49
|
-
return answer;
|
|
50
|
-
})
|
|
51
|
-
.catch(error => {
|
|
52
|
-
const { duration } = stopReqTrace(reqId);
|
|
53
|
-
(0, logs_1.log)("network-error", formatMsg({ reqId, msg: "error", duration }), { error });
|
|
54
|
-
throw error;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
const { duration } = stopReqTrace(reqId);
|
|
59
|
-
(0, logs_1.log)("info", formatMsg({ reqId, msg: "sync result", duration }), (0, live_env_1.getEnv)("DEBUG_HTTP_RESPONSE") ? { result } : undefined);
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
return targetValue;
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
return proxy;
|
|
70
|
-
}
|
|
71
|
-
exports.traced = traced;
|
|
72
|
-
function formatMsg({ reqId, msg, duration }) {
|
|
73
|
-
const parts = [
|
|
74
|
-
`solana req id: ${reqId}`,
|
|
75
|
-
msg ?? "",
|
|
76
|
-
duration === undefined ? "" : `took ${duration.toFixed(0)}ms`,
|
|
77
|
-
];
|
|
78
|
-
return parts.join(", ");
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=traced.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"traced.js","sourceRoot":"","sources":["../../src/network/traced.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,iDAA4C;AAG5C,SAAgB,MAAM,CAAC,GAAa;IAClC,MAAM,KAAK,GAAG;QACZ,KAAK,EAAE,CAAC;QACR,YAAY,EAAE,IAAI,GAAG,EAAkB;KACxC,CAAC;IAEF,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,KAAK,CAAC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,OAAO,WAAW,CAAC;YACrB,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AA1ED,wBA0EC;AAED,SAAS,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAsD;IAC7F,MAAM,KAAK,GAAG;QACZ,kBAAkB,KAAK,EAAE;QACzB,GAAG,IAAI,EAAE;QACT,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;KAC9D,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { CryptoAssetsStore, CryptoAssetsStoreGetter } from "@ledgerhq/types-live";
|
|
2
|
-
export declare const CRYPTO_ASSETS_STORE_NO_SET_ERROR_MESSAGE = "CryptoAssetsStore is not set. Please call setCryptoAssetsStore first on coin solana";
|
|
3
|
-
export declare function setCryptoAssetsStoreGetter(cryptoAssetsStoreGetter: CryptoAssetsStoreGetter): void;
|
|
4
|
-
export declare function getCryptoAssetsStore(): CryptoAssetsStore;
|
|
5
|
-
//# sourceMappingURL=cryptoAssetsStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoAssetsStore.d.ts","sourceRoot":"","sources":["../src/cryptoAssetsStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAElF,eAAO,MAAM,wCAAwC,wFACkC,CAAC;AAGxF,wBAAgB,0BAA0B,CAAC,uBAAuB,EAAE,uBAAuB,GAAG,IAAI,CAEjG;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CAKxD"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const CRYPTO_ASSETS_STORE_NO_SET_ERROR_MESSAGE = "CryptoAssetsStore is not set. Please call setCryptoAssetsStore first on coin solana";
|
|
2
|
-
let getStore;
|
|
3
|
-
export function setCryptoAssetsStoreGetter(cryptoAssetsStoreGetter) {
|
|
4
|
-
getStore = cryptoAssetsStoreGetter;
|
|
5
|
-
}
|
|
6
|
-
export function getCryptoAssetsStore() {
|
|
7
|
-
if (!getStore) {
|
|
8
|
-
throw new Error(CRYPTO_ASSETS_STORE_NO_SET_ERROR_MESSAGE);
|
|
9
|
-
}
|
|
10
|
-
return getStore();
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=cryptoAssetsStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoAssetsStore.js","sourceRoot":"","sources":["../src/cryptoAssetsStore.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wCAAwC,GACnD,qFAAqF,CAAC;AAExF,IAAI,QAAiC,CAAC;AACtC,MAAM,UAAU,0BAA0B,CAAC,uBAAgD;IACzF,QAAQ,GAAG,uBAAuB,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,EAAE,CAAC;AACpB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cached.d.ts","sourceRoot":"","sources":["../../src/network/cached.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAuBnC,wBAAgB,MAAM,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAoF9C"}
|
package/lib-es/network/cached.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { makeLRUCache, minutes, seconds } from "@ledgerhq/live-network/cache";
|
|
2
|
-
import { TransactionMessage } from "@solana/web3.js";
|
|
3
|
-
import hash from "object-hash";
|
|
4
|
-
const cacheKeyAddress = (address) => address;
|
|
5
|
-
const cacheKeyEmpty = () => "";
|
|
6
|
-
const cacheKeyAssocTokenAccAddress = (owner, mint) => `${owner}:${mint}`;
|
|
7
|
-
const cacheKeyMinimumBalanceForRentExemption = (dataLengt) => dataLengt.toString();
|
|
8
|
-
const cacheKeyTransactions = (signatures) => hash([...signatures].sort());
|
|
9
|
-
const cacheKeyAddresses = (addresses) => hash([...addresses].sort());
|
|
10
|
-
const cacheKeyInstructions = (ixs, payer) => {
|
|
11
|
-
return hash(new TransactionMessage({
|
|
12
|
-
instructions: ixs,
|
|
13
|
-
payerKey: payer,
|
|
14
|
-
recentBlockhash: payer.toString(),
|
|
15
|
-
})
|
|
16
|
-
.compileToLegacyMessage()
|
|
17
|
-
.serialize());
|
|
18
|
-
};
|
|
19
|
-
const cacheKeyByArgs = (...args) => hash(args);
|
|
20
|
-
export function cached(api) {
|
|
21
|
-
return {
|
|
22
|
-
findAssocTokenAccAddress: makeLRUCache(api.findAssocTokenAccAddress, cacheKeyAssocTokenAccAddress, minutes(1000)),
|
|
23
|
-
getAccountInfo: makeLRUCache(api.getAccountInfo, cacheKeyAddress, seconds(30)),
|
|
24
|
-
getMultipleAccounts: makeLRUCache(api.getMultipleAccounts, cacheKeyAddresses, seconds(30)),
|
|
25
|
-
getAssocTokenAccMinNativeBalance: makeLRUCache(api.getAssocTokenAccMinNativeBalance, cacheKeyEmpty, minutes(5)),
|
|
26
|
-
getBalance: makeLRUCache(api.getBalance, cacheKeyAddress, seconds(30)),
|
|
27
|
-
getBalanceAndContext: makeLRUCache(api.getBalanceAndContext, cacheKeyAddress, seconds(30)),
|
|
28
|
-
getParsedTransactions: makeLRUCache(api.getParsedTransactions, cacheKeyTransactions, seconds(30)),
|
|
29
|
-
getParsedTokenAccountsByOwner: makeLRUCache(api.getParsedTokenAccountsByOwner, cacheKeyAddress, minutes(1)),
|
|
30
|
-
getParsedToken2022AccountsByOwner: makeLRUCache(api.getParsedToken2022AccountsByOwner, cacheKeyAddress, minutes(1)),
|
|
31
|
-
// cached by default in api
|
|
32
|
-
getStakeAccountsByStakeAuth: api.getStakeAccountsByStakeAuth,
|
|
33
|
-
getStakeAccountsByWithdrawAuth: api.getStakeAccountsByWithdrawAuth,
|
|
34
|
-
getInflationReward: makeLRUCache(api.getInflationReward, cacheKeyByArgs, minutes(5)),
|
|
35
|
-
getVoteAccounts: makeLRUCache(api.getVoteAccounts, cacheKeyEmpty, minutes(1)),
|
|
36
|
-
getLatestBlockhash: makeLRUCache(api.getLatestBlockhash, cacheKeyEmpty, seconds(15)),
|
|
37
|
-
getFeeForMessage: makeLRUCache(api.getFeeForMessage, msg => msg.serialize().toString(), minutes(1)),
|
|
38
|
-
getSignaturesForAddress: makeLRUCache(api.getSignaturesForAddress, cacheKeyByArgs, seconds(30)),
|
|
39
|
-
getMinimumBalanceForRentExemption: makeLRUCache(api.getMinimumBalanceForRentExemption, cacheKeyMinimumBalanceForRentExemption, minutes(5)),
|
|
40
|
-
// do not cache
|
|
41
|
-
sendRawTransaction: api.sendRawTransaction,
|
|
42
|
-
getEpochInfo: makeLRUCache(api.getEpochInfo, cacheKeyEmpty, minutes(1)),
|
|
43
|
-
getRecentPrioritizationFees: makeLRUCache(api.getRecentPrioritizationFees, cacheKeyByArgs, seconds(30)),
|
|
44
|
-
getSimulationComputeUnits: makeLRUCache(api.getSimulationComputeUnits, cacheKeyInstructions, seconds(30)),
|
|
45
|
-
config: api.config,
|
|
46
|
-
connection: api.connection,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=cached.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cached.js","sourceRoot":"","sources":["../../src/network/cached.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAqC,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,I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