@ledgerhq/cryptoassets 13.30.0 → 13.31.0-nightly.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +32 -0
- package/README.md +0 -257
- package/lib/abandonseed.d.ts.map +1 -1
- package/lib/abandonseed.js +4 -1
- package/lib/abandonseed.js.map +1 -1
- package/lib/api-token-converter.js +15 -15
- package/lib/api-token-converter.js.map +1 -1
- package/lib/crypto-assets-importer/importers/sui/index.d.ts.map +1 -1
- package/lib/crypto-assets-importer/importers/sui/index.js +4 -1
- package/lib/crypto-assets-importer/importers/sui/index.js.map +1 -1
- package/lib/crypto-assets-importer/importers/sui/sui.test.js +14 -3
- package/lib/crypto-assets-importer/importers/sui/sui.test.js.map +1 -1
- package/lib/currencies.d.ts.map +1 -1
- package/lib/currencies.js +92 -10
- package/lib/currencies.js.map +1 -1
- package/lib/data/sui.d.ts +2 -1
- package/lib/data/sui.d.ts.map +1 -1
- package/lib/data/sui.js.map +1 -1
- package/lib/legacy/legacy-data.d.ts +25 -0
- package/lib/legacy/legacy-data.d.ts.map +1 -0
- package/lib/legacy/legacy-data.js +102 -0
- package/lib/legacy/legacy-data.js.map +1 -0
- package/lib/legacy/legacy-state.d.ts +9 -0
- package/lib/legacy/legacy-state.d.ts.map +1 -0
- package/lib/legacy/legacy-state.js +12 -0
- package/lib/legacy/legacy-state.js.map +1 -0
- package/lib/legacy/legacy-utils.d.ts +89 -0
- package/lib/legacy/legacy-utils.d.ts.map +1 -0
- package/lib/legacy/legacy-utils.js +448 -0
- package/lib/legacy/legacy-utils.js.map +1 -0
- package/lib/legacy/legacy.test.d.ts +2 -0
- package/lib/legacy/legacy.test.d.ts.map +1 -0
- package/lib/legacy/legacy.test.js +466 -0
- package/lib/legacy/legacy.test.js.map +1 -0
- package/lib/tokens.d.ts +20 -50
- package/lib/tokens.d.ts.map +1 -1
- package/lib/tokens.js +49 -503
- package/lib/tokens.js.map +1 -1
- package/lib/tokens.test.js +4 -3
- package/lib/tokens.test.js.map +1 -1
- package/lib-es/abandonseed.d.ts.map +1 -1
- package/lib-es/abandonseed.js +4 -1
- package/lib-es/abandonseed.js.map +1 -1
- package/lib-es/api-token-converter.js +2 -2
- package/lib-es/api-token-converter.js.map +1 -1
- package/lib-es/crypto-assets-importer/importers/sui/index.d.ts.map +1 -1
- package/lib-es/crypto-assets-importer/importers/sui/index.js +4 -1
- package/lib-es/crypto-assets-importer/importers/sui/index.js.map +1 -1
- package/lib-es/crypto-assets-importer/importers/sui/sui.test.js +14 -3
- package/lib-es/crypto-assets-importer/importers/sui/sui.test.js.map +1 -1
- package/lib-es/currencies.d.ts.map +1 -1
- package/lib-es/currencies.js +92 -10
- package/lib-es/currencies.js.map +1 -1
- package/lib-es/data/sui.d.ts +2 -1
- package/lib-es/data/sui.d.ts.map +1 -1
- package/lib-es/data/sui.js.map +1 -1
- package/lib-es/legacy/legacy-data.d.ts +25 -0
- package/lib-es/legacy/legacy-data.d.ts.map +1 -0
- package/lib-es/legacy/legacy-data.js +76 -0
- package/lib-es/legacy/legacy-data.js.map +1 -0
- package/lib-es/legacy/legacy-state.d.ts +9 -0
- package/lib-es/legacy/legacy-state.d.ts.map +1 -0
- package/lib-es/legacy/legacy-state.js +9 -0
- package/lib-es/legacy/legacy-state.js.map +1 -0
- package/lib-es/legacy/legacy-utils.d.ts +89 -0
- package/lib-es/legacy/legacy-utils.d.ts.map +1 -0
- package/lib-es/legacy/legacy-utils.js +427 -0
- package/lib-es/legacy/legacy-utils.js.map +1 -0
- package/lib-es/legacy/legacy.test.d.ts +2 -0
- package/lib-es/legacy/legacy.test.d.ts.map +1 -0
- package/lib-es/legacy/legacy.test.js +464 -0
- package/lib-es/legacy/legacy.test.js.map +1 -0
- package/lib-es/tokens.d.ts +20 -50
- package/lib-es/tokens.d.ts.map +1 -1
- package/lib-es/tokens.js +27 -475
- package/lib-es/tokens.js.map +1 -1
- package/lib-es/tokens.test.js +2 -1
- package/lib-es/tokens.test.js.map +1 -1
- package/package.json +3 -5
- package/src/abandonseed.ts +4 -1
- package/src/api-token-converter.ts +2 -2
- package/src/crypto-assets-importer/importers/sui/index.ts +6 -2
- package/src/crypto-assets-importer/importers/sui/sui.test.ts +15 -3
- package/src/currencies.ts +92 -10
- package/src/data/sui.ts +2 -1
- package/src/legacy/legacy-data.ts +119 -0
- package/src/legacy/legacy-state.ts +10 -0
- package/src/legacy/legacy-utils.ts +571 -0
- package/src/legacy/legacy.test.ts +580 -0
- package/src/tokens.test.ts +1 -1
- package/src/tokens.ts +67 -588
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file contains the legacy token data imports and state management
|
|
3
|
+
// All convert functions have been moved to legacy-utils.ts to make it more modular
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.initializeLegacyTokens = exports.aptFATokens = exports.aptCoinTokens = exports.suitokens = exports.celoTokens = exports.coreTokens = exports.sonicTokens = exports.spltokens = exports.filecoinTokens = exports.jettonTokens = exports.vechainTokens = exports.stellarTokens = exports.cardanoNativeTokens = exports.esdttokens = exports.asatokens = exports.trc20tokens = exports.trc10tokens = exports.bnbTokens = exports.hederaTokens = exports.polygonTokens = exports.sepoliaTokens = exports.mainnetTokens = void 0;
|
|
9
|
+
const live_env_1 = require("@ledgerhq/live-env");
|
|
10
|
+
const cardanoNative_1 = __importDefault(require("../data/cardanoNative"));
|
|
11
|
+
exports.cardanoNativeTokens = cardanoNative_1.default;
|
|
12
|
+
const ton_jetton_1 = __importDefault(require("../data/ton-jetton"));
|
|
13
|
+
exports.jettonTokens = ton_jetton_1.default;
|
|
14
|
+
const _11155111_1 = require("../data/evm/11155111");
|
|
15
|
+
Object.defineProperty(exports, "sepoliaTokens", { enumerable: true, get: function () { return _11155111_1.tokens; } });
|
|
16
|
+
const stellar_1 = __importDefault(require("../data/stellar"));
|
|
17
|
+
exports.stellarTokens = stellar_1.default;
|
|
18
|
+
const hedera_1 = __importDefault(require("../data/hedera"));
|
|
19
|
+
exports.hederaTokens = hedera_1.default;
|
|
20
|
+
const vip180_1 = __importDefault(require("../data/vip180"));
|
|
21
|
+
exports.vechainTokens = vip180_1.default;
|
|
22
|
+
const esdt_1 = __importDefault(require("../data/esdt"));
|
|
23
|
+
exports.esdttokens = esdt_1.default;
|
|
24
|
+
const asa_1 = __importDefault(require("../data/asa"));
|
|
25
|
+
exports.asatokens = asa_1.default;
|
|
26
|
+
const _137_1 = require("../data/evm/137");
|
|
27
|
+
Object.defineProperty(exports, "polygonTokens", { enumerable: true, get: function () { return _137_1.tokens; } });
|
|
28
|
+
const _146_1 = require("../data/evm/146");
|
|
29
|
+
Object.defineProperty(exports, "sonicTokens", { enumerable: true, get: function () { return _146_1.tokens; } });
|
|
30
|
+
const _1116_1 = require("../data/evm/1116");
|
|
31
|
+
Object.defineProperty(exports, "coreTokens", { enumerable: true, get: function () { return _1116_1.tokens; } });
|
|
32
|
+
const trc10_1 = __importDefault(require("../data/trc10"));
|
|
33
|
+
exports.trc10tokens = trc10_1.default;
|
|
34
|
+
const trc20_1 = __importDefault(require("../data/trc20"));
|
|
35
|
+
exports.trc20tokens = trc20_1.default;
|
|
36
|
+
const _1_1 = require("../data/evm/1");
|
|
37
|
+
Object.defineProperty(exports, "mainnetTokens", { enumerable: true, get: function () { return _1_1.tokens; } });
|
|
38
|
+
const _56_1 = require("../data/evm/56");
|
|
39
|
+
Object.defineProperty(exports, "bnbTokens", { enumerable: true, get: function () { return _56_1.tokens; } });
|
|
40
|
+
const _42220_1 = require("../data/evm/42220");
|
|
41
|
+
Object.defineProperty(exports, "celoTokens", { enumerable: true, get: function () { return _42220_1.tokens; } });
|
|
42
|
+
const filecoin_erc20_1 = __importDefault(require("../data/filecoin-erc20"));
|
|
43
|
+
exports.filecoinTokens = filecoin_erc20_1.default;
|
|
44
|
+
const spl_1 = __importDefault(require("../data/spl"));
|
|
45
|
+
exports.spltokens = spl_1.default;
|
|
46
|
+
const apt_coin_1 = __importDefault(require("../data/apt_coin"));
|
|
47
|
+
exports.aptCoinTokens = apt_coin_1.default;
|
|
48
|
+
const apt_fungible_asset_1 = __importDefault(require("../data/apt_fungible_asset"));
|
|
49
|
+
exports.aptFATokens = apt_fungible_asset_1.default;
|
|
50
|
+
const sui_1 = __importDefault(require("../data/sui"));
|
|
51
|
+
exports.suitokens = sui_1.default;
|
|
52
|
+
const legacy_utils_1 = require("./legacy-utils");
|
|
53
|
+
// Function to initialize legacy tokens (using the actual data imports)
|
|
54
|
+
function initializeLegacyTokens(addTokens) {
|
|
55
|
+
// Ethereum mainnet tokens
|
|
56
|
+
addTokens(_1_1.tokens.map(legacy_utils_1.convertERC20));
|
|
57
|
+
// Ethereum Sepolia testnet tokens
|
|
58
|
+
addTokens(_11155111_1.tokens.map(legacy_utils_1.convertERC20));
|
|
59
|
+
// Polygon tokens
|
|
60
|
+
addTokens(_137_1.tokens.map(legacy_utils_1.convertERC20));
|
|
61
|
+
// Hedera tokens
|
|
62
|
+
addTokens(hedera_1.default.map(legacy_utils_1.convertHederaTokens));
|
|
63
|
+
// Binance Smart Chain tokens
|
|
64
|
+
addTokens(_56_1.tokens.map(legacy_utils_1.convertERC20));
|
|
65
|
+
// Tron tokens
|
|
66
|
+
addTokens(trc10_1.default.map((0, legacy_utils_1.convertTRONTokens)("trc10")));
|
|
67
|
+
addTokens(trc20_1.default.map((0, legacy_utils_1.convertTRONTokens)("trc20")));
|
|
68
|
+
// Algoland tokens
|
|
69
|
+
addTokens(asa_1.default.map(legacy_utils_1.convertAlgorandASATokens));
|
|
70
|
+
// MultiversX tokens
|
|
71
|
+
addTokens(esdt_1.default.map(legacy_utils_1.convertMultiversXESDTTokens));
|
|
72
|
+
// Cardano tokens
|
|
73
|
+
addTokens(cardanoNative_1.default.map(legacy_utils_1.convertCardanoNativeTokens));
|
|
74
|
+
// Stellar tokens
|
|
75
|
+
addTokens(stellar_1.default.map(legacy_utils_1.convertStellarTokens));
|
|
76
|
+
// VeChain tokens
|
|
77
|
+
addTokens(vip180_1.default.map(legacy_utils_1.convertVechainToken));
|
|
78
|
+
// Ton tokens
|
|
79
|
+
addTokens(ton_jetton_1.default.map(legacy_utils_1.convertJettonToken));
|
|
80
|
+
// Filecoin tokens
|
|
81
|
+
addTokens(filecoin_erc20_1.default.map(legacy_utils_1.convertERC20));
|
|
82
|
+
// Solana tokens
|
|
83
|
+
addTokens(spl_1.default.map(legacy_utils_1.convertSplTokens));
|
|
84
|
+
// Sonic
|
|
85
|
+
addTokens(_146_1.tokens.map(legacy_utils_1.convertERC20));
|
|
86
|
+
// Core
|
|
87
|
+
addTokens(_1116_1.tokens.map(legacy_utils_1.convertERC20));
|
|
88
|
+
// Celo
|
|
89
|
+
addTokens(_42220_1.tokens.map(legacy_utils_1.convertERC20));
|
|
90
|
+
if ((0, live_env_1.getEnv)("SUI_ENABLE_TOKENS")) {
|
|
91
|
+
// Sui tokens
|
|
92
|
+
addTokens(sui_1.default.map(legacy_utils_1.convertSuiTokens));
|
|
93
|
+
}
|
|
94
|
+
if ((0, live_env_1.getEnv)("APTOS_ENABLE_TOKENS")) {
|
|
95
|
+
// Aptos Legacy Coin tokens
|
|
96
|
+
// Aptos fungible assets tokens
|
|
97
|
+
addTokens(apt_coin_1.default.map(legacy_utils_1.convertAptCoinTokens));
|
|
98
|
+
addTokens(apt_fungible_asset_1.default.map(legacy_utils_1.convertAptFaTokens));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.initializeLegacyTokens = initializeLegacyTokens;
|
|
102
|
+
//# sourceMappingURL=legacy-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-data.js","sourceRoot":"","sources":["../../src/legacy/legacy-data.ts"],"names":[],"mappings":";AAAA,wEAA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OAAO;IACP,SAAS,CAAC,cAAU,CAAC,GAAG,CAAC,2BAAY,CAAC,CAAC,CAAC;IACxC,OAAO;IACP,SAAS,CAAC,eAAU,CAAC,GAAG,CAAC,2BAAY,CAAC,CAAC,CAAC;IAExC,IAAI,IAAA,iBAAM,EAAC,mBAAmB,CAAC,EAAE,CAAC;QAChC,aAAa;QACb,SAAS,CAAC,aAAS,CAAC,GAAG,CAAC,+BAAgB,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,IAAA,iBAAM,EAAC,qBAAqB,CAAC,EAAE,CAAC;QAClC,2BAA2B;QAC3B,+BAA+B;QAC/B,SAAS,CAAC,kBAAa,CAAC,GAAG,CAAC,mCAAoB,CAAC,CAAC,CAAC;QACnD,SAAS,CAAC,4BAAW,CAAC,GAAG,CAAC,iCAAkB,CAAC,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AAlDD,wDAkDC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
export declare const tokensArray: TokenCurrency[];
|
|
3
|
+
export declare const tokensArrayWithDelisted: TokenCurrency[];
|
|
4
|
+
export declare const tokensByCryptoCurrency: Record<string, TokenCurrency[]>;
|
|
5
|
+
export declare const tokensByCryptoCurrencyWithDelisted: Record<string, TokenCurrency[]>;
|
|
6
|
+
export declare const tokensById: Record<string, TokenCurrency>;
|
|
7
|
+
export declare const tokensByCurrencyAddress: Record<string, TokenCurrency>;
|
|
8
|
+
export declare const tokenListHashes: Set<unknown>;
|
|
9
|
+
//# sourceMappingURL=legacy-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-state.d.ts","sourceRoot":"","sources":["../../src/legacy/legacy-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,eAAO,MAAM,WAAW,EAAE,aAAa,EAAO,CAAC;AAC/C,eAAO,MAAM,uBAAuB,EAAE,aAAa,EAAO,CAAC;AAC3D,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAAM,CAAC;AAC1E,eAAO,MAAM,kCAAkC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAAM,CAAC;AACtF,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,CAAC;AAC5D,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,CAAC;AACzE,eAAO,MAAM,eAAe,cAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tokenListHashes = exports.tokensByCurrencyAddress = exports.tokensById = exports.tokensByCryptoCurrencyWithDelisted = exports.tokensByCryptoCurrency = exports.tokensArrayWithDelisted = exports.tokensArray = void 0;
|
|
4
|
+
// Legacy state variables that are used for the legacy implementation of CryptoAssetsStore contract
|
|
5
|
+
exports.tokensArray = [];
|
|
6
|
+
exports.tokensArrayWithDelisted = [];
|
|
7
|
+
exports.tokensByCryptoCurrency = {};
|
|
8
|
+
exports.tokensByCryptoCurrencyWithDelisted = {};
|
|
9
|
+
exports.tokensById = {};
|
|
10
|
+
exports.tokensByCurrencyAddress = {};
|
|
11
|
+
exports.tokenListHashes = new Set();
|
|
12
|
+
//# sourceMappingURL=legacy-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-state.js","sourceRoot":"","sources":["../../src/legacy/legacy-state.ts"],"names":[],"mappings":";;;AAEA,mGAAmG;AACtF,QAAA,WAAW,GAAoB,EAAE,CAAC;AAClC,QAAA,uBAAuB,GAAoB,EAAE,CAAC;AAC9C,QAAA,sBAAsB,GAAoC,EAAE,CAAC;AAC7D,QAAA,kCAAkC,GAAoC,EAAE,CAAC;AACzE,QAAA,UAAU,GAAkC,EAAE,CAAC;AAC/C,QAAA,uBAAuB,GAAkC,EAAE,CAAC;AAC5D,QAAA,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { TokenCurrency, CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
import { ERC20Token, AlgorandASAToken, MultiversXESDTToken, TRC10Token, TRC20Token } from "../types";
|
|
3
|
+
import type { CardanoNativeToken } from "../data/cardanoNative";
|
|
4
|
+
import type { TonJettonToken } from "../data/ton-jetton";
|
|
5
|
+
import type { StellarToken } from "../data/stellar";
|
|
6
|
+
import type { HederaToken } from "../data/hedera";
|
|
7
|
+
import type { Vip180Token } from "../data/vip180";
|
|
8
|
+
import type { SPLToken } from "../data/spl";
|
|
9
|
+
import type { AptosToken as AptosCoinToken } from "../data/apt_coin";
|
|
10
|
+
import type { AptosToken as AptosFAToken } from "../data/apt_fungible_asset";
|
|
11
|
+
import type { SuiToken } from "../data/sui";
|
|
12
|
+
export interface TokensListOptions {
|
|
13
|
+
withDelisted: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
18
|
+
export declare function convertERC20([parentCurrencyId, token, ticker, magnitude, name, ledgerSignature, contractAddress, disableCountervalue, delisted,]: ERC20Token): TokenCurrency | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated
|
|
21
|
+
*/
|
|
22
|
+
export declare function convertAlgorandASATokens([id, abbr, name, contractAddress, precision,]: AlgorandASAToken): TokenCurrency;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated
|
|
25
|
+
*/
|
|
26
|
+
export declare function convertVechainToken([tokenIdenfitier, ticker, name, contractAddress, precision,]: Vip180Token): TokenCurrency;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated
|
|
29
|
+
*/
|
|
30
|
+
export declare function convertTRONTokens(type: "trc10" | "trc20"): ([id, abbr, name, contractAddress, precision, delisted, ledgerSignature]: TRC10Token | TRC20Token) => TokenCurrency;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated
|
|
33
|
+
*/
|
|
34
|
+
export declare function convertMultiversXESDTTokens([ticker, identifier, decimals, signature, name,]: MultiversXESDTToken): TokenCurrency;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated
|
|
37
|
+
*/
|
|
38
|
+
export declare function convertSplTokens([id, network, name, symbol, address, decimals,]: SPLToken): TokenCurrency;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated
|
|
41
|
+
*/
|
|
42
|
+
export declare function convertAptCoinTokens(token: AptosCoinToken): TokenCurrency;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated
|
|
45
|
+
*/
|
|
46
|
+
export declare function convertAptFaTokens(token: AptosFAToken): TokenCurrency;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated
|
|
49
|
+
*/
|
|
50
|
+
export declare function convertSuiTokens([id, name, ticker, address, decimals, ledgerSignature,]: SuiToken): TokenCurrency;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated
|
|
53
|
+
*/
|
|
54
|
+
export declare function convertHederaTokens([id, tokenId, name, ticker, network, decimals, delisted,]: HederaToken): TokenCurrency;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated
|
|
57
|
+
*/
|
|
58
|
+
export declare function convertCardanoNativeTokens([parentCurrencyId, policyId, assetName, name, ticker, decimals, delisted,]: CardanoNativeToken): TokenCurrency | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated
|
|
61
|
+
*/
|
|
62
|
+
export declare function convertStellarTokens([assetCode, assetIssuer, assetType, name, precision,]: StellarToken): TokenCurrency;
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated
|
|
65
|
+
*/
|
|
66
|
+
export declare function convertJettonToken([address, name, ticker, magnitude, delisted]: TonJettonToken): TokenCurrency | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated
|
|
69
|
+
*/
|
|
70
|
+
export declare function createTokenHash(token: TokenCurrency): string;
|
|
71
|
+
/**
|
|
72
|
+
* Only for jest purpose, clear all the init list
|
|
73
|
+
*/
|
|
74
|
+
export declare function __clearAllLists(): void;
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated This function is deprecated since tokens will soon be loaded dynamically
|
|
77
|
+
*/
|
|
78
|
+
export declare function addTokens(list: (TokenCurrency | undefined)[]): void;
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated This function is deprecated since tokens will no longer be listable as we moved to DaDa API everywhere
|
|
81
|
+
* List all available tokens
|
|
82
|
+
*/
|
|
83
|
+
export declare function listTokensLegacy(options?: Partial<TokensListOptions>): TokenCurrency[];
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated This function is deprecated since tokens will no longer be listable as we moved to DaDa API everywhere
|
|
86
|
+
* List tokens for a specific cryptocurrency
|
|
87
|
+
*/
|
|
88
|
+
export declare function listTokensForCryptoCurrencyLegacy(currency: CryptoCurrency, options?: Partial<TokensListOptions>): TokenCurrency[];
|
|
89
|
+
//# sourceMappingURL=legacy-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-utils.d.ts","sourceRoot":"","sources":["../../src/legacy/legacy-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAWlF,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,UAAU,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB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;;GAGG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACnC,aAAa,EAAE,CAOjB"}
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listTokensForCryptoCurrencyLegacy = exports.listTokensLegacy = exports.addTokens = exports.__clearAllLists = exports.createTokenHash = exports.convertJettonToken = exports.convertStellarTokens = exports.convertCardanoNativeTokens = exports.convertHederaTokens = exports.convertSuiTokens = exports.convertAptFaTokens = exports.convertAptCoinTokens = exports.convertSplTokens = exports.convertMultiversXESDTTokens = exports.convertTRONTokens = exports.convertVechainToken = exports.convertAlgorandASATokens = exports.convertERC20 = void 0;
|
|
4
|
+
const currencies_1 = require("../currencies");
|
|
5
|
+
const legacy_state_1 = require("./legacy-state");
|
|
6
|
+
// Convert functions moved from legacy.ts
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
*/
|
|
10
|
+
function convertERC20([parentCurrencyId, token, ticker, magnitude, name, ledgerSignature, contractAddress, disableCountervalue, delisted,]) {
|
|
11
|
+
const parentCurrency = (0, currencies_1.findCryptoCurrencyById)(parentCurrencyId);
|
|
12
|
+
if (!parentCurrency) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const tokenType = parentCurrencyId === "bsc" ? "bep20" : "erc20";
|
|
16
|
+
return {
|
|
17
|
+
type: "TokenCurrency",
|
|
18
|
+
id: `${parentCurrencyId}/${tokenType}/${token}`,
|
|
19
|
+
ledgerSignature,
|
|
20
|
+
contractAddress,
|
|
21
|
+
parentCurrency,
|
|
22
|
+
tokenType,
|
|
23
|
+
name,
|
|
24
|
+
ticker,
|
|
25
|
+
delisted,
|
|
26
|
+
disableCountervalue: !!parentCurrency.isTestnetFor || !!disableCountervalue,
|
|
27
|
+
units: [
|
|
28
|
+
{
|
|
29
|
+
name,
|
|
30
|
+
code: ticker,
|
|
31
|
+
magnitude,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exports.convertERC20 = convertERC20;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated
|
|
39
|
+
*/
|
|
40
|
+
function convertAlgorandASATokens([id, abbr, name, contractAddress, precision,]) {
|
|
41
|
+
const parentCurrency = (0, currencies_1.getCryptoCurrencyById)("algorand");
|
|
42
|
+
return {
|
|
43
|
+
type: "TokenCurrency",
|
|
44
|
+
id: `algorand/asa/${id}`,
|
|
45
|
+
contractAddress,
|
|
46
|
+
parentCurrency,
|
|
47
|
+
tokenType: "asa",
|
|
48
|
+
name,
|
|
49
|
+
ticker: abbr,
|
|
50
|
+
disableCountervalue: false,
|
|
51
|
+
units: [
|
|
52
|
+
{
|
|
53
|
+
name,
|
|
54
|
+
code: abbr,
|
|
55
|
+
magnitude: precision,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
exports.convertAlgorandASATokens = convertAlgorandASATokens;
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated
|
|
63
|
+
*/
|
|
64
|
+
function convertVechainToken([tokenIdenfitier, ticker, name, contractAddress, precision,]) {
|
|
65
|
+
return {
|
|
66
|
+
type: "TokenCurrency",
|
|
67
|
+
id: `vechain/vip180/${tokenIdenfitier}`,
|
|
68
|
+
contractAddress: contractAddress,
|
|
69
|
+
parentCurrency: (0, currencies_1.getCryptoCurrencyById)("vechain"),
|
|
70
|
+
tokenType: "vip180",
|
|
71
|
+
name,
|
|
72
|
+
ticker,
|
|
73
|
+
disableCountervalue: false,
|
|
74
|
+
units: [
|
|
75
|
+
{
|
|
76
|
+
name,
|
|
77
|
+
code: ticker,
|
|
78
|
+
magnitude: precision,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
exports.convertVechainToken = convertVechainToken;
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated
|
|
86
|
+
*/
|
|
87
|
+
function convertTRONTokens(type) {
|
|
88
|
+
return ([id, abbr, name, contractAddress, precision, delisted, ledgerSignature]) => {
|
|
89
|
+
const parentCurrency = (0, currencies_1.getCryptoCurrencyById)("tron");
|
|
90
|
+
return {
|
|
91
|
+
type: "TokenCurrency",
|
|
92
|
+
id: `tron/${type}/${id}`,
|
|
93
|
+
contractAddress,
|
|
94
|
+
parentCurrency,
|
|
95
|
+
tokenType: type,
|
|
96
|
+
name,
|
|
97
|
+
ticker: abbr,
|
|
98
|
+
delisted,
|
|
99
|
+
disableCountervalue: false,
|
|
100
|
+
ledgerSignature,
|
|
101
|
+
units: [
|
|
102
|
+
{
|
|
103
|
+
name,
|
|
104
|
+
code: abbr,
|
|
105
|
+
magnitude: precision,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
exports.convertTRONTokens = convertTRONTokens;
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated
|
|
114
|
+
*/
|
|
115
|
+
function convertMultiversXESDTTokens([ticker, identifier, decimals, signature, name,]) {
|
|
116
|
+
const MULTIVERSX_ESDT_CONTRACT = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u";
|
|
117
|
+
const parentCurrency = (0, currencies_1.getCryptoCurrencyById)("elrond");
|
|
118
|
+
return {
|
|
119
|
+
type: "TokenCurrency",
|
|
120
|
+
id: `multiversx/esdt/${identifier}`,
|
|
121
|
+
contractAddress: MULTIVERSX_ESDT_CONTRACT,
|
|
122
|
+
ledgerSignature: signature,
|
|
123
|
+
parentCurrency,
|
|
124
|
+
tokenType: "esdt",
|
|
125
|
+
disableCountervalue: false,
|
|
126
|
+
name,
|
|
127
|
+
ticker,
|
|
128
|
+
units: [
|
|
129
|
+
{
|
|
130
|
+
name,
|
|
131
|
+
code: name,
|
|
132
|
+
magnitude: decimals,
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
exports.convertMultiversXESDTTokens = convertMultiversXESDTTokens;
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated
|
|
140
|
+
*/
|
|
141
|
+
function convertSplTokens([id, network, name, symbol, address, decimals,]) {
|
|
142
|
+
return {
|
|
143
|
+
type: "TokenCurrency",
|
|
144
|
+
id,
|
|
145
|
+
contractAddress: address,
|
|
146
|
+
parentCurrency: (0, currencies_1.getCryptoCurrencyById)(network),
|
|
147
|
+
name,
|
|
148
|
+
tokenType: "spl",
|
|
149
|
+
ticker: symbol,
|
|
150
|
+
disableCountervalue: false,
|
|
151
|
+
units: [
|
|
152
|
+
{
|
|
153
|
+
name,
|
|
154
|
+
code: symbol,
|
|
155
|
+
magnitude: decimals,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
exports.convertSplTokens = convertSplTokens;
|
|
161
|
+
/**
|
|
162
|
+
* @deprecated
|
|
163
|
+
*/
|
|
164
|
+
function convertAptosTokens(tokenType, [id, ticker, name, address, decimals, delisted]) {
|
|
165
|
+
return {
|
|
166
|
+
type: "TokenCurrency",
|
|
167
|
+
id,
|
|
168
|
+
contractAddress: address,
|
|
169
|
+
parentCurrency: (0, currencies_1.getCryptoCurrencyById)("aptos"),
|
|
170
|
+
name,
|
|
171
|
+
tokenType,
|
|
172
|
+
ticker,
|
|
173
|
+
disableCountervalue: false,
|
|
174
|
+
delisted,
|
|
175
|
+
units: [
|
|
176
|
+
{
|
|
177
|
+
name,
|
|
178
|
+
code: ticker,
|
|
179
|
+
magnitude: decimals,
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* @deprecated
|
|
186
|
+
*/
|
|
187
|
+
function convertAptCoinTokens(token) {
|
|
188
|
+
return convertAptosTokens("coin", token);
|
|
189
|
+
}
|
|
190
|
+
exports.convertAptCoinTokens = convertAptCoinTokens;
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated
|
|
193
|
+
*/
|
|
194
|
+
function convertAptFaTokens(token) {
|
|
195
|
+
return convertAptosTokens("fungible_asset", token);
|
|
196
|
+
}
|
|
197
|
+
exports.convertAptFaTokens = convertAptFaTokens;
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated
|
|
200
|
+
*/
|
|
201
|
+
function convertSuiTokens([id, name, ticker, address, decimals, ledgerSignature,]) {
|
|
202
|
+
return {
|
|
203
|
+
type: "TokenCurrency",
|
|
204
|
+
id,
|
|
205
|
+
contractAddress: address,
|
|
206
|
+
parentCurrency: (0, currencies_1.getCryptoCurrencyById)("sui"),
|
|
207
|
+
name,
|
|
208
|
+
ledgerSignature,
|
|
209
|
+
tokenType: "sui",
|
|
210
|
+
ticker,
|
|
211
|
+
disableCountervalue: false,
|
|
212
|
+
units: [
|
|
213
|
+
{
|
|
214
|
+
name,
|
|
215
|
+
code: ticker,
|
|
216
|
+
magnitude: decimals,
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
exports.convertSuiTokens = convertSuiTokens;
|
|
222
|
+
/**
|
|
223
|
+
* @deprecated
|
|
224
|
+
*/
|
|
225
|
+
function convertHederaTokens([id, tokenId, name, ticker, network, decimals, delisted,]) {
|
|
226
|
+
return {
|
|
227
|
+
type: "TokenCurrency",
|
|
228
|
+
id,
|
|
229
|
+
contractAddress: tokenId,
|
|
230
|
+
parentCurrency: (0, currencies_1.getCryptoCurrencyById)(network),
|
|
231
|
+
tokenType: "hts",
|
|
232
|
+
name,
|
|
233
|
+
ticker,
|
|
234
|
+
delisted,
|
|
235
|
+
disableCountervalue: false,
|
|
236
|
+
units: [
|
|
237
|
+
{
|
|
238
|
+
name,
|
|
239
|
+
code: ticker,
|
|
240
|
+
magnitude: decimals,
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
exports.convertHederaTokens = convertHederaTokens;
|
|
246
|
+
/**
|
|
247
|
+
* @deprecated
|
|
248
|
+
*/
|
|
249
|
+
function convertCardanoNativeTokens([parentCurrencyId, policyId, assetName, name, ticker, decimals, delisted,]) {
|
|
250
|
+
const assetId = policyId + assetName;
|
|
251
|
+
const parentCurrency = (0, currencies_1.getCryptoCurrencyById)(parentCurrencyId);
|
|
252
|
+
if (!parentCurrency) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
type: "TokenCurrency",
|
|
257
|
+
id: `${parentCurrencyId}/native/${assetId}`,
|
|
258
|
+
// Tracking and accounting of native tokens is natively supported by cardano ledger.
|
|
259
|
+
// As there's no contract for native tokens, using unique assetId in place of contractAddress
|
|
260
|
+
contractAddress: assetId,
|
|
261
|
+
parentCurrency,
|
|
262
|
+
tokenType: "native",
|
|
263
|
+
name,
|
|
264
|
+
ticker,
|
|
265
|
+
delisted,
|
|
266
|
+
disableCountervalue: false,
|
|
267
|
+
units: [
|
|
268
|
+
{
|
|
269
|
+
name,
|
|
270
|
+
code: ticker,
|
|
271
|
+
magnitude: decimals,
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
exports.convertCardanoNativeTokens = convertCardanoNativeTokens;
|
|
277
|
+
/**
|
|
278
|
+
* @deprecated
|
|
279
|
+
*/
|
|
280
|
+
function convertStellarTokens([assetCode, assetIssuer, assetType, name, precision,]) {
|
|
281
|
+
const parentCurrency = (0, currencies_1.getCryptoCurrencyById)("stellar");
|
|
282
|
+
return {
|
|
283
|
+
type: "TokenCurrency",
|
|
284
|
+
id: `stellar/asset/${assetCode.toUpperCase()}:${assetIssuer.toUpperCase()}`,
|
|
285
|
+
contractAddress: assetIssuer.toUpperCase(),
|
|
286
|
+
parentCurrency,
|
|
287
|
+
tokenType: assetType,
|
|
288
|
+
name,
|
|
289
|
+
ticker: assetCode,
|
|
290
|
+
disableCountervalue: false,
|
|
291
|
+
units: [
|
|
292
|
+
{
|
|
293
|
+
name,
|
|
294
|
+
code: assetCode,
|
|
295
|
+
magnitude: precision,
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
exports.convertStellarTokens = convertStellarTokens;
|
|
301
|
+
/**
|
|
302
|
+
* @deprecated
|
|
303
|
+
*/
|
|
304
|
+
function convertJettonToken([address, name, ticker, magnitude, delisted]) {
|
|
305
|
+
const parentCurrency = (0, currencies_1.findCryptoCurrencyById)("ton");
|
|
306
|
+
if (!parentCurrency) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
type: "TokenCurrency",
|
|
311
|
+
id: "ton/jetton/" + address.toLocaleLowerCase(),
|
|
312
|
+
contractAddress: address,
|
|
313
|
+
parentCurrency,
|
|
314
|
+
tokenType: "jetton",
|
|
315
|
+
name,
|
|
316
|
+
ticker,
|
|
317
|
+
delisted,
|
|
318
|
+
disableCountervalue: false,
|
|
319
|
+
units: [
|
|
320
|
+
{
|
|
321
|
+
name,
|
|
322
|
+
code: ticker,
|
|
323
|
+
magnitude,
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
exports.convertJettonToken = convertJettonToken;
|
|
329
|
+
/**
|
|
330
|
+
* @deprecated
|
|
331
|
+
*/
|
|
332
|
+
function createTokenHash(token) {
|
|
333
|
+
return token
|
|
334
|
+
? `${token.id}${token.contractAddress}${token.delisted}${token.ticker}${token.ledgerSignature}`
|
|
335
|
+
: "";
|
|
336
|
+
}
|
|
337
|
+
exports.createTokenHash = createTokenHash;
|
|
338
|
+
/**
|
|
339
|
+
* Only for jest purpose, clean object to be empty
|
|
340
|
+
* @param obj
|
|
341
|
+
*/
|
|
342
|
+
const __clearObject = (obj) => {
|
|
343
|
+
for (const key in obj) {
|
|
344
|
+
delete obj[key];
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* Only for jest purpose, clear all the init list
|
|
349
|
+
*/
|
|
350
|
+
function __clearAllLists() {
|
|
351
|
+
legacy_state_1.tokensArray.length = 0;
|
|
352
|
+
legacy_state_1.tokensArrayWithDelisted.length = 0;
|
|
353
|
+
__clearObject(legacy_state_1.tokensByCryptoCurrency);
|
|
354
|
+
__clearObject(legacy_state_1.tokensByCryptoCurrencyWithDelisted);
|
|
355
|
+
__clearObject(legacy_state_1.tokensById);
|
|
356
|
+
__clearObject(legacy_state_1.tokensByCurrencyAddress);
|
|
357
|
+
legacy_state_1.tokenListHashes.clear();
|
|
358
|
+
}
|
|
359
|
+
exports.__clearAllLists = __clearAllLists;
|
|
360
|
+
function removeTokenFromArray(array, tokenId) {
|
|
361
|
+
if (array && array.length > 0) {
|
|
362
|
+
const index = array.findIndex(currentToken => currentToken && currentToken.id === tokenId);
|
|
363
|
+
if (index === -1)
|
|
364
|
+
return array;
|
|
365
|
+
return array.splice(index, 1);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function removeTokenFromRecord(record, key) {
|
|
369
|
+
legacy_state_1.tokenListHashes.delete(record[key]);
|
|
370
|
+
delete record[key];
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Delete previous token entry to all array
|
|
374
|
+
* @param token
|
|
375
|
+
*/
|
|
376
|
+
function removeTokenFromAllLists(token) {
|
|
377
|
+
const { id, contractAddress, parentCurrency } = token;
|
|
378
|
+
const lowCaseContract = contractAddress.toLowerCase();
|
|
379
|
+
removeTokenFromRecord(legacy_state_1.tokensById, id);
|
|
380
|
+
removeTokenFromRecord(legacy_state_1.tokensByCurrencyAddress, parentCurrency.id + ":" + lowCaseContract);
|
|
381
|
+
removeTokenFromArray(legacy_state_1.tokensArray, id);
|
|
382
|
+
removeTokenFromArray(legacy_state_1.tokensArrayWithDelisted, id);
|
|
383
|
+
removeTokenFromArray(legacy_state_1.tokensByCryptoCurrency[parentCurrency.id], id);
|
|
384
|
+
removeTokenFromArray(legacy_state_1.tokensByCryptoCurrencyWithDelisted[parentCurrency.id], id);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* @deprecated This function is deprecated since tokens will soon be loaded dynamically
|
|
388
|
+
*/
|
|
389
|
+
function addTokens(list) {
|
|
390
|
+
list.forEach(token => {
|
|
391
|
+
if (!token)
|
|
392
|
+
return;
|
|
393
|
+
const tokenHash = createTokenHash(token);
|
|
394
|
+
if (legacy_state_1.tokenListHashes.has(tokenHash))
|
|
395
|
+
return;
|
|
396
|
+
/**
|
|
397
|
+
* We clean all the reference of an existing token, if an hash doesn't match.
|
|
398
|
+
* Like this we can update any change from a already added token coming from Dynamic CAL
|
|
399
|
+
* and maintain it up to date without having to release a new version of LLD or LLM
|
|
400
|
+
*/
|
|
401
|
+
const { id, contractAddress, parentCurrency, delisted } = token;
|
|
402
|
+
if (legacy_state_1.tokensById[id])
|
|
403
|
+
removeTokenFromAllLists(token);
|
|
404
|
+
const lowCaseContract = contractAddress.toLowerCase();
|
|
405
|
+
if (!delisted)
|
|
406
|
+
legacy_state_1.tokensArray.push(token);
|
|
407
|
+
legacy_state_1.tokensArrayWithDelisted.push(token);
|
|
408
|
+
legacy_state_1.tokensById[id] = token;
|
|
409
|
+
legacy_state_1.tokensByCurrencyAddress[parentCurrency.id + ":" + lowCaseContract] = token;
|
|
410
|
+
if (!(parentCurrency.id in legacy_state_1.tokensByCryptoCurrency)) {
|
|
411
|
+
legacy_state_1.tokensByCryptoCurrency[parentCurrency.id] = [];
|
|
412
|
+
}
|
|
413
|
+
if (!(parentCurrency.id in legacy_state_1.tokensByCryptoCurrencyWithDelisted)) {
|
|
414
|
+
legacy_state_1.tokensByCryptoCurrencyWithDelisted[parentCurrency.id] = [];
|
|
415
|
+
}
|
|
416
|
+
if (!delisted)
|
|
417
|
+
legacy_state_1.tokensByCryptoCurrency[parentCurrency.id].push(token);
|
|
418
|
+
legacy_state_1.tokensByCryptoCurrencyWithDelisted[parentCurrency.id].push(token);
|
|
419
|
+
legacy_state_1.tokenListHashes.add(tokenHash);
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
exports.addTokens = addTokens;
|
|
423
|
+
// Legacy list functions - deprecated since moving to DaDa API
|
|
424
|
+
const defaultTokenListOptions = {
|
|
425
|
+
withDelisted: false,
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* @deprecated This function is deprecated since tokens will no longer be listable as we moved to DaDa API everywhere
|
|
429
|
+
* List all available tokens
|
|
430
|
+
*/
|
|
431
|
+
function listTokensLegacy(options) {
|
|
432
|
+
const { withDelisted } = { ...defaultTokenListOptions, ...options };
|
|
433
|
+
return withDelisted ? legacy_state_1.tokensArrayWithDelisted : legacy_state_1.tokensArray;
|
|
434
|
+
}
|
|
435
|
+
exports.listTokensLegacy = listTokensLegacy;
|
|
436
|
+
/**
|
|
437
|
+
* @deprecated This function is deprecated since tokens will no longer be listable as we moved to DaDa API everywhere
|
|
438
|
+
* List tokens for a specific cryptocurrency
|
|
439
|
+
*/
|
|
440
|
+
function listTokensForCryptoCurrencyLegacy(currency, options) {
|
|
441
|
+
const { withDelisted } = { ...defaultTokenListOptions, ...options };
|
|
442
|
+
if (withDelisted) {
|
|
443
|
+
return legacy_state_1.tokensByCryptoCurrencyWithDelisted[currency.id] || [];
|
|
444
|
+
}
|
|
445
|
+
return legacy_state_1.tokensByCryptoCurrency[currency.id] || [];
|
|
446
|
+
}
|
|
447
|
+
exports.listTokensForCryptoCurrencyLegacy = listTokensForCryptoCurrencyLegacy;
|
|
448
|
+
//# sourceMappingURL=legacy-utils.js.map
|