Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@ledgerhq/cryptoassets

Package Overview
Dependencies
Maintainers
15
Versions
357
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ledgerhq/cryptoassets - npm Package Compare versions

Comparing version 6.0.0-alpha.0 to 6.0.0-typescript.0

lib-es/abandonseed.d.ts

79

lib-es/abandonseed.js
import invariant from "invariant";
const abandonSeedAddresses = {
algorand: "PSHLIWQKDEETIIBQEOTLGCT5IF7BTTOKCUULONOGVGF2HYDT2IHW3H4CCI",
cosmos: "cosmos19rl4cm2hmr8afy4kldpxz3fka4jguq0auqdal4",
cosmos_testnet: "cosmos19rl4cm2hmr8afy4kldpxz3fka4jguq0auqdal4",
ripple: "rHsMGQEkVNJmpGWs8XUBoTBiAAbwxZN5v3",
stellar: "GDYPMQMYW2JTLPWAUAHIDY3E4VHP5SGTFC5SMA45L7ZPOTHWQ2PHEW3E",
tezos: "tz1VJitLYB31fEC82efFkLRU4AQUH9QgH3q6",
tron: "0x0000000000000000000000000000000000000000",
ethereum: "0x0000000000000000000000000000000000000000",
bitcoin: "1LqBGSKuX5yYUonjxT5qGfpUsXKYYWeabA",
bitcoin_cash: "1mW6fDEMjKrDHvLvoEsaeLxSCzZBf3Bfg",
bitcoin_gold: "GeTZ7bjfXtGsyEcerSSFJNUSZwLfjtCJX9",
bitcoin_private: "b1SGV7U5kGAMHtGbkAR3mjaZqVn57SHFbiR",
bitcoin_testnet: "mkpZhYtJu2r87Js3pDiWJDmPte2NRZ8bJV",
dash: "XoJA8qE3N2Y3jMLEtZ3vcN42qseZ8LvFf5",
decred: "",
// FIXME need to derivate decred abandon
digibyte: "DG1KhhBKpsyWXTakHNezaDQ34focsXjN1i",
dogecoin: "DBus3bamQjgJULBJtYXpEzDWQRwF5iwxgC",
game_credits: "GJgbzWpGhrZmSvc2V5Npqf57Kg9xfB79tj",
komodo: "RW8gfgpCUdgZbkPAs1uJQF2S9681JVkGRi",
litecoin: "LUWPbpM43E2p7ZSh8cyTBEkvpHmr3cB8Ez",
nix: "GRpn2DPiQxAczMrQFt2sK1CS8EYdnvSHxo",
peercoin: "PFinP8Tm5hFJKfVnSMFfiNibPNfHgXzTDZ",
pivx: "DDBxSas734KhMp1Btga3LdwWAc1igSER8o",
polkadot: "111111111111111111111111111111111HC1",
qtum: "QPvRe2C17qk24K6v5gTg7CPghZ8b4WMxZP",
stakenet: "XhPU3ZrghEh387nqgQ1Fi16JvtkSeYdP4g",
stealthcoin: "SKsLkKVeMtPNZQuNfUNXi3Bk1TwP1QPqJG",
stratis: "Sdo6x9k5AxWtfyJe5B9SZPteYTKgUoMMr1",
vertcoin: "Vce16eJifb7HpuoTFEBJyKNLsBJPo7fM83",
viacoin: "VfwB3jbDWELpfiFNzbEVgx73HsR9bAq35C",
zcash: "t1XVXWCvpMgBvUaed4XDqWtgQgJSu1Ghz7F",
zclassic: "t1Qmwyih5F7Mw6Vts4tSnXuA2o3NgJPYNgP",
zcoin: "a1bW3sVVUsLqgKuTMXtSaAHGvpxKwugxPH",
zencash: "zngWJRgpBa45KUeRuCmdMsqti4ohhe9sVwC"
var abandonSeedAddresses = {
algorand: "PSHLIWQKDEETIIBQEOTLGCT5IF7BTTOKCUULONOGVGF2HYDT2IHW3H4CCI",
cosmos: "cosmos19rl4cm2hmr8afy4kldpxz3fka4jguq0auqdal4",
cosmos_testnet: "cosmos19rl4cm2hmr8afy4kldpxz3fka4jguq0auqdal4",
ripple: "rHsMGQEkVNJmpGWs8XUBoTBiAAbwxZN5v3",
stellar: "GDYPMQMYW2JTLPWAUAHIDY3E4VHP5SGTFC5SMA45L7ZPOTHWQ2PHEW3E",
tezos: "tz1VJitLYB31fEC82efFkLRU4AQUH9QgH3q6",
tron: "0x0000000000000000000000000000000000000000",
ethereum: "0x0000000000000000000000000000000000000000",
bitcoin: "1LqBGSKuX5yYUonjxT5qGfpUsXKYYWeabA",
bitcoin_cash: "1mW6fDEMjKrDHvLvoEsaeLxSCzZBf3Bfg",
bitcoin_gold: "GeTZ7bjfXtGsyEcerSSFJNUSZwLfjtCJX9",
bitcoin_private: "b1SGV7U5kGAMHtGbkAR3mjaZqVn57SHFbiR",
bitcoin_testnet: "mkpZhYtJu2r87Js3pDiWJDmPte2NRZ8bJV",
dash: "XoJA8qE3N2Y3jMLEtZ3vcN42qseZ8LvFf5",
decred: "",
// FIXME need to derivate decred abandon
digibyte: "DG1KhhBKpsyWXTakHNezaDQ34focsXjN1i",
dogecoin: "DBus3bamQjgJULBJtYXpEzDWQRwF5iwxgC",
game_credits: "GJgbzWpGhrZmSvc2V5Npqf57Kg9xfB79tj",
komodo: "RW8gfgpCUdgZbkPAs1uJQF2S9681JVkGRi",
litecoin: "LUWPbpM43E2p7ZSh8cyTBEkvpHmr3cB8Ez",
nix: "GRpn2DPiQxAczMrQFt2sK1CS8EYdnvSHxo",
peercoin: "PFinP8Tm5hFJKfVnSMFfiNibPNfHgXzTDZ",
pivx: "DDBxSas734KhMp1Btga3LdwWAc1igSER8o",
polkadot: "111111111111111111111111111111111HC1",
qtum: "QPvRe2C17qk24K6v5gTg7CPghZ8b4WMxZP",
stakenet: "XhPU3ZrghEh387nqgQ1Fi16JvtkSeYdP4g",
stealthcoin: "SKsLkKVeMtPNZQuNfUNXi3Bk1TwP1QPqJG",
stratis: "Sdo6x9k5AxWtfyJe5B9SZPteYTKgUoMMr1",
vertcoin: "Vce16eJifb7HpuoTFEBJyKNLsBJPo7fM83",
viacoin: "VfwB3jbDWELpfiFNzbEVgx73HsR9bAq35C",
zcash: "t1XVXWCvpMgBvUaed4XDqWtgQgJSu1Ghz7F",
zclassic: "t1Qmwyih5F7Mw6Vts4tSnXuA2o3NgJPYNgP",
zcoin: "a1bW3sVVUsLqgKuTMXtSaAHGvpxKwugxPH",
zencash: "zngWJRgpBa45KUeRuCmdMsqti4ohhe9sVwC"
};

@@ -46,7 +46,6 @@ /**

*/
export const getAbandonSeedAddress = currencyId => {
invariant(abandonSeedAddresses[currencyId] !== undefined, `No abandonseed available for ${currencyId}`);
return abandonSeedAddresses[currencyId];
export var getAbandonSeedAddress = function (currencyId) {
invariant(abandonSeedAddresses[currencyId] !== undefined, "No abandonseed available for " + currencyId);
return abandonSeedAddresses[currencyId];
};
//# sourceMappingURL=abandonseed.js.map

@@ -1,175 +0,245 @@

import { listFiatCurrencies, getFiatCurrencyByTicker, hasFiatCurrencyTicker } from "./fiats";
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
import { listFiatCurrencies, getFiatCurrencyByTicker, hasFiatCurrencyTicker, } from "./fiats";
import { listTokens, findTokenById } from "./tokens";
import { listCryptoCurrencies, hasCryptoCurrencyId, getCryptoCurrencyById, findCryptoCurrency, findCryptoCurrencyById, findCryptoCurrencyByScheme, findCryptoCurrencyByTicker, findCryptoCurrencyByKeyword, registerCryptoCurrency } from "./currencies";
test("can get currency by coin type", () => {
expect(getCryptoCurrencyById("bitcoin")).toMatchObject({
id: "bitcoin",
name: "Bitcoin"
});
expect(getCryptoCurrencyById("litecoin")).toMatchObject({
id: "litecoin",
name: "Litecoin"
});
expect(hasCryptoCurrencyId("bitcoin")).toBe(true);
expect(hasCryptoCurrencyId("")).toBe(false);
expect(() => getCryptoCurrencyById("")).toThrow();
expect(hasCryptoCurrencyId("_")).toBe(false);
expect(() => getCryptoCurrencyById("_")).toThrow();
import { listCryptoCurrencies, hasCryptoCurrencyId, getCryptoCurrencyById, findCryptoCurrency, findCryptoCurrencyById, findCryptoCurrencyByScheme, findCryptoCurrencyByTicker, findCryptoCurrencyByKeyword, registerCryptoCurrency, } from "./currencies";
test("can get currency by coin type", function () {
expect(getCryptoCurrencyById("bitcoin")).toMatchObject({
id: "bitcoin",
name: "Bitcoin"
});
expect(getCryptoCurrencyById("litecoin")).toMatchObject({
id: "litecoin",
name: "Litecoin"
});
expect(hasCryptoCurrencyId("bitcoin")).toBe(true);
expect(hasCryptoCurrencyId("")).toBe(false);
expect(function () { return getCryptoCurrencyById(""); }).toThrow();
expect(hasCryptoCurrencyId("_")).toBe(false);
expect(function () { return getCryptoCurrencyById("_"); }).toThrow();
});
test("can find currency", () => {
const bitcoinMatch = {
id: "bitcoin",
name: "Bitcoin"
};
expect(findCryptoCurrency(c => c.name === "Bitcoin")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyById("bitcoin")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyByKeyword("btc")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyByKeyword("btc")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyByKeyword("btc")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyByTicker("BTC")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyByScheme("bitcoin")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyById("_")).toBe(undefined);
expect(findCryptoCurrencyByKeyword("_")).toBe(undefined);
expect(findCryptoCurrencyByKeyword("_")).toBe(undefined);
expect(findCryptoCurrencyByKeyword("_")).toBe(undefined);
expect(findCryptoCurrencyByTicker("_")).toBe(undefined);
expect(findCryptoCurrencyByScheme("_")).toBe(undefined);
test("can find currency", function () {
var bitcoinMatch = {
id: "bitcoin",
name: "Bitcoin"
};
expect(findCryptoCurrency(function (c) { return c.name === "Bitcoin"; })).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyById("bitcoin")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyByKeyword("btc")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyByKeyword("btc")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyByKeyword("btc")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyByTicker("BTC")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyByScheme("bitcoin")).toMatchObject(bitcoinMatch);
expect(findCryptoCurrencyById("_")).toBe(undefined);
expect(findCryptoCurrencyByKeyword("_")).toBe(undefined);
expect(findCryptoCurrencyByKeyword("_")).toBe(undefined);
expect(findCryptoCurrencyByKeyword("_")).toBe(undefined);
expect(findCryptoCurrencyByTicker("_")).toBe(undefined);
expect(findCryptoCurrencyByScheme("_")).toBe(undefined);
});
test("there are some dev cryptocurrencies", () => {
const all = listCryptoCurrencies(true);
const prod = listCryptoCurrencies();
expect(all).not.toBe(prod);
expect(all.filter(a => !a.isTestnetFor)).toMatchObject(prod);
expect(all.length).toBeGreaterThan(prod.length);
test("there are some dev cryptocurrencies", function () {
var all = listCryptoCurrencies(true);
var prod = listCryptoCurrencies();
expect(all).not.toBe(prod);
expect(all.filter(function (a) { return !a.isTestnetFor; })).toMatchObject(prod);
expect(all.length).toBeGreaterThan(prod.length);
});
test("there are some terminated cryptocurrencies", () => {
const all = listCryptoCurrencies(false, true);
const supported = listCryptoCurrencies();
expect(all).not.toBe(supported);
expect(all.filter(a => !a.terminated)).toMatchObject(supported);
expect(all.length).toBeGreaterThan(supported.length);
test("there are some terminated cryptocurrencies", function () {
var all = listCryptoCurrencies(false, true);
var supported = listCryptoCurrencies();
expect(all).not.toBe(supported);
expect(all.filter(function (a) { return !a.terminated; })).toMatchObject(supported);
expect(all.length).toBeGreaterThan(supported.length);
});
test("all cryptocurrencies match (by reference) the one you get by id", () => {
for (let c of listCryptoCurrencies()) {
expect(c).toBe(getCryptoCurrencyById(c.id));
}
test("all cryptocurrencies match (by reference) the one you get by id", function () {
var e_1, _a;
try {
for (var _b = __values(listCryptoCurrencies()), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
expect(c).toBe(getCryptoCurrencyById(c.id));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
});
test("there is no testnet or terminated coin by default", () => {
expect(listCryptoCurrencies(false, false)).toBe(listCryptoCurrencies());
expect(listCryptoCurrencies(true, true).length).toBeGreaterThan(listCryptoCurrencies().length);
for (let c of listCryptoCurrencies()) {
expect(!c.terminated).toBe(true);
expect(!c.isTestnetFor).toBe(true);
}
test("there is no testnet or terminated coin by default", function () {
var e_2, _a;
expect(listCryptoCurrencies(false, false)).toBe(listCryptoCurrencies());
expect(listCryptoCurrencies(true, true).length).toBeGreaterThan(listCryptoCurrencies().length);
try {
for (var _b = __values(listCryptoCurrencies()), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
expect(!c.terminated).toBe(true);
expect(!c.isTestnetFor).toBe(true);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
}
});
test("all cryptocurrencies have at least one unit", () => {
for (let c of listCryptoCurrencies()) {
expect(c.units.length).toBeGreaterThan(0);
}
test("all cryptocurrencies have at least one unit", function () {
var e_3, _a;
try {
for (var _b = __values(listCryptoCurrencies()), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
expect(c.units.length).toBeGreaterThan(0);
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_3) throw e_3.error; }
}
});
test("fiats list is always the same", () => {
expect(listFiatCurrencies()).toEqual(listFiatCurrencies());
test("fiats list is always the same", function () {
expect(listFiatCurrencies()).toEqual(listFiatCurrencies());
});
test("fiats list elements are correct", () => {
const tickers = {};
for (const fiat of listFiatCurrencies()) {
expect(fiat.ticker).toBeTruthy();
expect(typeof fiat.ticker).toBe("string");
expect(tickers[fiat.ticker]).toBeFalsy();
expect(fiat.units.length).toBeGreaterThan(0);
const unit = fiat.units[0];
expect(unit.code).toBeTruthy();
expect(typeof unit.code).toBe("string");
expect(unit.name).toBeTruthy();
expect(typeof unit.name).toBe("string");
expect(unit.magnitude).toBeGreaterThan(-1);
expect(typeof unit.magnitude).toBe("number");
tickers[fiat.ticker] = unit;
}
test("fiats list elements are correct", function () {
var e_4, _a;
var tickers = {};
try {
for (var _b = __values(listFiatCurrencies()), _c = _b.next(); !_c.done; _c = _b.next()) {
var fiat = _c.value;
expect(fiat.ticker).toBeTruthy();
expect(typeof fiat.ticker).toBe("string");
expect(tickers[fiat.ticker]).toBeFalsy();
expect(fiat.units.length).toBeGreaterThan(0);
var unit = fiat.units[0];
expect(unit.code).toBeTruthy();
expect(typeof unit.code).toBe("string");
expect(unit.name).toBeTruthy();
expect(typeof unit.name).toBe("string");
expect(unit.magnitude).toBeGreaterThan(-1);
expect(typeof unit.magnitude).toBe("number");
tickers[fiat.ticker] = unit;
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_4) throw e_4.error; }
}
});
test("tokens are correct", () => {
expect(listTokens().length).toBeGreaterThan(0);
for (const token of listTokens()) {
expect(token.ticker).toBeTruthy();
expect(typeof token.id).toBe("string");
expect(typeof token.name).toBe("string");
if (token.ledgerSignature) {
expect(typeof token.ledgerSignature).toBe("string");
test("tokens are correct", function () {
var e_5, _a;
expect(listTokens().length).toBeGreaterThan(0);
try {
for (var _b = __values(listTokens()), _c = _b.next(); !_c.done; _c = _b.next()) {
var token = _c.value;
expect(token.ticker).toBeTruthy();
expect(typeof token.id).toBe("string");
expect(typeof token.name).toBe("string");
if (token.ledgerSignature) {
expect(typeof token.ledgerSignature).toBe("string");
}
expect(typeof token.tokenType).toBe("string");
expect(typeof token.parentCurrency).toBe("object");
expect(hasCryptoCurrencyId(token.parentCurrency.id)).toBe(true);
expect(typeof token.ticker).toBe("string");
expect(token.units.length).toBeGreaterThan(0);
var unit = token.units[0];
expect(unit.code).toBeTruthy();
expect(typeof unit.code).toBe("string");
expect(unit.name).toBeTruthy();
expect(typeof unit.name).toBe("string");
expect(unit.magnitude).toBeGreaterThan(-1);
expect(typeof unit.magnitude).toBe("number");
if (token.compoundFor) {
var t = findTokenById(token.compoundFor);
expect(typeof t).toBe("object");
}
}
}
expect(typeof token.tokenType).toBe("string");
expect(typeof token.parentCurrency).toBe("object");
expect(hasCryptoCurrencyId(token.parentCurrency.id)).toBe(true);
expect(typeof token.ticker).toBe("string");
expect(token.units.length).toBeGreaterThan(0);
const unit = token.units[0];
expect(unit.code).toBeTruthy();
expect(typeof unit.code).toBe("string");
expect(unit.name).toBeTruthy();
expect(typeof unit.name).toBe("string");
expect(unit.magnitude).toBeGreaterThan(-1);
expect(typeof unit.magnitude).toBe("number");
if (token.compoundFor) {
const t = findTokenById(token.compoundFor);
expect(typeof t).toBe("object");
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_5) throw e_5.error; }
}
}
});
test("fiats list is sorted by ticker", () => {
expect(listFiatCurrencies().map(fiat => fiat.ticker).join(",")).toEqual(listFiatCurrencies().map(fiat => fiat.ticker).sort((a, b) => a > b ? 1 : -1).join(","));
test("fiats list is sorted by ticker", function () {
expect(listFiatCurrencies()
.map(function (fiat) { return fiat.ticker; })
.join(",")).toEqual(listFiatCurrencies()
.map(function (fiat) { return fiat.ticker; })
.sort(function (a, b) { return (a > b ? 1 : -1); })
.join(","));
});
test("can get fiat by coin type", () => {
expect(getFiatCurrencyByTicker("USD").units[0]).toMatchObject({
magnitude: 2
});
expect(getFiatCurrencyByTicker("EUR").units[0]).toMatchObject({
magnitude: 2
}); // this is not a fiat \o/
expect(() => getFiatCurrencyByTicker("USDT").units[0]).toThrow();
expect(hasFiatCurrencyTicker("USD")).toBe(true);
expect(hasFiatCurrencyTicker("USDT")).toBe(false);
test("can get fiat by coin type", function () {
expect(getFiatCurrencyByTicker("USD").units[0]).toMatchObject({
magnitude: 2
});
expect(getFiatCurrencyByTicker("EUR").units[0]).toMatchObject({
magnitude: 2
});
// this is not a fiat \o/
expect(function () { return getFiatCurrencyByTicker("USDT").units[0]; }).toThrow();
expect(hasFiatCurrencyTicker("USD")).toBe(true);
expect(hasFiatCurrencyTicker("USDT")).toBe(false);
});
test("all USDT are countervalue enabled", () => {
const tokens = listTokens().filter(t => t.ticker === "USDT" && !t.parentCurrency.isTestnetFor);
expect(tokens.map(t => t.id).sort()).toMatchSnapshot();
expect(tokens.every(t => t.disableCountervalue === false)).toBe(true);
test("all USDT are countervalue enabled", function () {
var tokens = listTokens().filter(function (t) { return t.ticker === "USDT" && !t.parentCurrency.isTestnetFor; });
expect(tokens.map(function (t) { return t.id; }).sort()).toMatchSnapshot();
expect(tokens.every(function (t) { return t.disableCountervalue === false; })).toBe(true);
});
test("can register a new coin externally", () => {
const coinId = "mycoin";
expect(() => getCryptoCurrencyById("mycoin")).toThrow(`currency with id "${coinId}" not found`);
const mycoin = {
type: "CryptoCurrency",
id: coinId,
coinType: 8008,
name: "MyCoin",
managerAppName: "MyCoin",
ticker: "MYC",
countervalueTicker: "MYC",
scheme: "mycoin",
color: "#ff0000",
family: "mycoin",
units: [{
name: "MYC",
code: "MYC",
magnitude: 8
}, {
name: "SmallestUnit",
code: "SMALLESTUNIT",
magnitude: 0
}],
explorerViews: [{
address: "https://mycoinexplorer.com/account/$address",
tx: "https://mycoinexplorer.com/transaction/$hash",
token: "https://mycoinexplorer.com/token/$contractAddress/?a=$address"
}]
};
registerCryptoCurrency(coinId, mycoin);
expect(getCryptoCurrencyById(coinId)).toEqual(mycoin);
test("can register a new coin externally", function () {
var coinId = "mycoin";
expect(function () { return getCryptoCurrencyById("mycoin"); }).toThrow("currency with id \"" + coinId + "\" not found");
var mycoin = {
type: "CryptoCurrency",
id: coinId,
coinType: 8008,
name: "MyCoin",
managerAppName: "MyCoin",
ticker: "MYC",
countervalueTicker: "MYC",
scheme: "mycoin",
color: "#ff0000",
family: "mycoin",
units: [
{
name: "MYC",
code: "MYC",
magnitude: 8
},
{
name: "SmallestUnit",
code: "SMALLESTUNIT",
magnitude: 0
},
],
explorerViews: [
{
address: "https://mycoinexplorer.com/account/$address",
tx: "https://mycoinexplorer.com/transaction/$hash",
token: "https://mycoinexplorer.com/token/$contractAddress/?a=$address"
},
]
};
registerCryptoCurrency(coinId, mycoin);
expect(getCryptoCurrencyById(coinId)).toEqual(mycoin);
});
//# sourceMappingURL=currencies.test.js.map

@@ -0,18 +1,58 @@

var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var e_1, _a;
import coins from "../data/exchange/erc20";
import erc20 from "../data/exchange/coins";
const all = [...coins, ...erc20];
const configs = {};
for (const [id, config, signature] of all) {
configs[id] = {
config,
signature
};
var all = __spreadArray(__spreadArray([], __read(coins)), __read(erc20));
var configs = {};
try {
for (var all_1 = __values(all), all_1_1 = all_1.next(); !all_1_1.done; all_1_1 = all_1.next()) {
var _b = __read(all_1_1.value, 3), id = _b[0], config = _b[1], signature = _b[2];
configs[id] = {
config: config,
signature: signature
};
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (all_1_1 && !all_1_1.done && (_a = all_1["return"])) _a.call(all_1);
}
finally { if (e_1) throw e_1.error; }
}
/**
*
*/
export const findExchangeCurrencyConfig = id => configs[id];
export var findExchangeCurrencyConfig = function (id) { return configs[id]; };
//# sourceMappingURL=exchange.js.map
// inspired by https://github.com/smirzaei/currency-formatter/blob/master/currencies.json
function fiat(name, ticker, defaultSymbol, defaultMagnitude) {
// for now, we only create one unit, in the future we will allow more
return {
type: "FiatCurrency",
ticker,
name,
symbol: defaultSymbol,
units: [{
code: defaultSymbol,
name,
magnitude: defaultMagnitude,
showAllDigits: true,
prefixCode: true
}]
};
// for now, we only create one unit, in the future we will allow more
return {
type: "FiatCurrency",
ticker: ticker,
name: name,
symbol: defaultSymbol,
units: [
{
code: defaultSymbol,
name: name,
magnitude: defaultMagnitude,
showAllDigits: true,
prefixCode: true
},
]
};
}
const byTicker = {
AED: fiat("Emirati Dirham", "AED", "د.إ.", 2),
AUD: fiat("Australian Dollar", "AUD", "AU$", 2),
BGN: fiat("Bulgarian Lev", "BGN", "лв.", 2),
BHD: fiat("Bahraini Dinar", "BHD", "د.ب.", 3),
BRL: fiat("Brazilian Real", "BRL", "R$", 2),
CAD: fiat("Canadian Dollar", "CAD", "CA$", 2),
CHF: fiat("Swiss Franc", "CHF", "CHF", 2),
CLP: fiat("Chilean Peso", "CLP", "CLP$", 2),
CNY: fiat("Yuan or Chinese Renminbi", "CNY", "¥", 2),
CRC: fiat("Costa Rican Colón", "CRC", "₡", 2),
CZK: fiat("Czech Koruna", "CZK", "Kč", 2),
DKK: fiat("Danish Krone", "DKK", "kr.", 2),
EUR: fiat("Euro", "EUR", "€", 2),
GBP: fiat("British Pound", "GBP", "£", 2),
GHS: fiat("Ghanaian Cedi", "GHS", "₵", 2),
HKD: fiat("Hong Kong Dollar", "HKD", "HK$", 2),
HRK: fiat("Croatian Kuna", "HRK", "kn", 2),
HUF: fiat("Hungarian Forint", "HUF", "Ft", 2),
IDR: fiat("Indonesian Rupiah", "IDR", "Rp", 0),
ILS: fiat("Israeli Shekel", "ILS", "₪", 2),
INR: fiat("Indian Rupee", "INR", "₹", 2),
IRR: fiat("Iranian Rial", "IRR", "﷼", 2),
JPY: fiat("Japanese Yen", "JPY", "¥", 0),
KES: fiat("Kenyan Shilling", "KES", "S", 2),
KHR: fiat("Cambodian Riel", "KHR", "៛", 0),
KRW: fiat("South Korean Won", "KRW", "₩", 0),
MUR: fiat("Mauritian Rupee", "MUR", "₨", 2),
MXN: fiat("Mexico Peso", "MXN", "Mex$", 2),
MYR: fiat("Malaysian Ringgit", "MYR", "RM", 2),
NGN: fiat("Nigerian Naira", "NGN", "₦", 2),
NOK: fiat("Norwegian Krone", "NOK", "kr", 2),
NZD: fiat("New Zealand Dollar", "NZD", "NZ$", 2),
PHP: fiat("Philippine Peso", "PHP", "₱", 2),
PKR: fiat("Pakistani Rupee", "PKR", "₨", 2),
PLN: fiat("Polish Złoty", "PLN", "zł", 2),
RON: fiat("Romanian Leu", "RON", "lei", 2),
RUB: fiat("Russian Rouble", "RUB", "₽", 2),
SEK: fiat("Swedish Krona", "SEK", "kr", 2),
SGD: fiat("Singapore Dollar", "SGD", "S$", 2),
THB: fiat("Thai Baht", "THB", "฿", 2),
TRY: fiat("Turkish Lira", "TRY", "TL", 2),
TZS: fiat("Tanzanian Shilling", "TZS", "TSh", 2),
UAH: fiat("Ukrainian Hryvnia", "UAH", "₴", 2),
UGX: fiat("Ugandan Shilling", "UGX", "USh", 2),
USD: fiat("US Dollar", "USD", "$", 2),
VES: fiat("Venezuelan Bolivar", "VES", "Bs. S.", 2),
VND: fiat("Vietnamese Dong", "VND", "₫", 1),
VUV: fiat("Ni-Vanuatu Vatu", "VUV", "VT", 0),
ZAR: fiat("South African Rand", "ZAR", "R", 2)
var byTicker = {
AED: fiat("Emirati Dirham", "AED", "د.إ.", 2),
AUD: fiat("Australian Dollar", "AUD", "AU$", 2),
BGN: fiat("Bulgarian Lev", "BGN", "лв.", 2),
BHD: fiat("Bahraini Dinar", "BHD", "د.ب.", 3),
BRL: fiat("Brazilian Real", "BRL", "R$", 2),
CAD: fiat("Canadian Dollar", "CAD", "CA$", 2),
CHF: fiat("Swiss Franc", "CHF", "CHF", 2),
CLP: fiat("Chilean Peso", "CLP", "CLP$", 2),
CNY: fiat("Yuan or Chinese Renminbi", "CNY", "¥", 2),
CRC: fiat("Costa Rican Colón", "CRC", "₡", 2),
CZK: fiat("Czech Koruna", "CZK", "Kč", 2),
DKK: fiat("Danish Krone", "DKK", "kr.", 2),
EUR: fiat("Euro", "EUR", "€", 2),
GBP: fiat("British Pound", "GBP", "£", 2),
GHS: fiat("Ghanaian Cedi", "GHS", "₵", 2),
HKD: fiat("Hong Kong Dollar", "HKD", "HK$", 2),
HRK: fiat("Croatian Kuna", "HRK", "kn", 2),
HUF: fiat("Hungarian Forint", "HUF", "Ft", 2),
IDR: fiat("Indonesian Rupiah", "IDR", "Rp", 0),
ILS: fiat("Israeli Shekel", "ILS", "₪", 2),
INR: fiat("Indian Rupee", "INR", "₹", 2),
IRR: fiat("Iranian Rial", "IRR", "﷼", 2),
JPY: fiat("Japanese Yen", "JPY", "¥", 0),
KES: fiat("Kenyan Shilling", "KES", "S", 2),
KHR: fiat("Cambodian Riel", "KHR", "៛", 0),
KRW: fiat("South Korean Won", "KRW", "₩", 0),
MUR: fiat("Mauritian Rupee", "MUR", "₨", 2),
MXN: fiat("Mexico Peso", "MXN", "Mex$", 2),
MYR: fiat("Malaysian Ringgit", "MYR", "RM", 2),
NGN: fiat("Nigerian Naira", "NGN", "₦", 2),
NOK: fiat("Norwegian Krone", "NOK", "kr", 2),
NZD: fiat("New Zealand Dollar", "NZD", "NZ$", 2),
PHP: fiat("Philippine Peso", "PHP", "₱", 2),
PKR: fiat("Pakistani Rupee", "PKR", "₨", 2),
PLN: fiat("Polish Złoty", "PLN", "zł", 2),
RON: fiat("Romanian Leu", "RON", "lei", 2),
RUB: fiat("Russian Rouble", "RUB", "₽", 2),
SEK: fiat("Swedish Krona", "SEK", "kr", 2),
SGD: fiat("Singapore Dollar", "SGD", "S$", 2),
THB: fiat("Thai Baht", "THB", "฿", 2),
TRY: fiat("Turkish Lira", "TRY", "TL", 2),
TZS: fiat("Tanzanian Shilling", "TZS", "TSh", 2),
UAH: fiat("Ukrainian Hryvnia", "UAH", "₴", 2),
UGX: fiat("Ugandan Shilling", "UGX", "USh", 2),
USD: fiat("US Dollar", "USD", "$", 2),
VES: fiat("Venezuelan Bolivar", "VES", "Bs. S.", 2),
VND: fiat("Vietnamese Dong", "VND", "₫", 1),
VUV: fiat("Ni-Vanuatu Vatu", "VUV", "VT", 0),
ZAR: fiat("South African Rand", "ZAR", "R", 2)
};
const list = Object.keys(byTicker).map(k => byTicker[k]);
var list = Object.keys(byTicker).map(function (k) { return byTicker[k]; });
/**

@@ -75,5 +76,4 @@ *

*/
export function hasFiatCurrencyTicker(ticker) {
return ticker in byTicker;
return ticker in byTicker;
}

@@ -84,5 +84,4 @@ /**

*/
export function findFiatCurrencyByTicker(ticker) {
return byTicker[ticker];
return byTicker[ticker];
}

@@ -93,11 +92,8 @@ /**

*/
export function getFiatCurrencyByTicker(ticker) {
const cur = findFiatCurrencyByTicker(ticker);
if (!cur) {
throw new Error(`fiat currency "${ticker}" not found`);
}
return cur;
var cur = findFiatCurrencyByTicker(ticker);
if (!cur) {
throw new Error("fiat currency \"" + ticker + "\" not found");
}
return cur;
}

@@ -107,6 +103,5 @@ /**

*/
export function listFiatCurrencies() {
return list;
return list;
}
//# sourceMappingURL=fiats.js.map

@@ -6,2 +6,3 @@ export * from "./fiats";

export * from "./abandonseed";
export * from "./types";
//# sourceMappingURL=index.js.map

@@ -0,1 +1,33 @@

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
import { getCryptoCurrencyById } from "./currencies";

@@ -6,10 +38,10 @@ import erc20tokens from "../data/erc20";

import asatokens from "../data/asa";
const emptyArray = [];
const tokensArray = [];
const tokensArrayWithDelisted = [];
const tokensByCryptoCurrency = {};
const tokensByCryptoCurrencyWithDelisted = {};
const tokensById = {};
const tokensByTicker = {};
const tokensByAddress = {};
var emptyArray = [];
var tokensArray = [];
var tokensArrayWithDelisted = [];
var tokensByCryptoCurrency = {};
var tokensByCryptoCurrencyWithDelisted = {};
var tokensById = {};
var tokensByTicker = {};
var tokensByAddress = {};
addTokens(erc20tokens.map(convertERC20));

@@ -19,4 +51,4 @@ addTokens(trc10tokens.map(convertTRONTokens("trc10")));

addTokens(asatokens.map(convertAlgorandASATokens));
const defaultTokenListOptions = {
withDelisted: false
var defaultTokenListOptions = {
withDelisted: false
};

@@ -26,10 +58,5 @@ /**

*/
export function listTokens(options) {
const {
withDelisted
} = { ...defaultTokenListOptions,
...options
};
return withDelisted ? tokensArrayWithDelisted : tokensArray;
var withDelisted = __assign(__assign({}, defaultTokenListOptions), options).withDelisted;
return withDelisted ? tokensArrayWithDelisted : tokensArray;
}

@@ -39,15 +66,8 @@ /**

*/
export function listTokensForCryptoCurrency(currency, options) {
const {
withDelisted
} = { ...defaultTokenListOptions,
...options
};
if (withDelisted) {
return tokensByCryptoCurrencyWithDelisted[currency.id] || emptyArray;
}
return tokensByCryptoCurrency[currency.id] || emptyArray;
var withDelisted = __assign(__assign({}, defaultTokenListOptions), options).withDelisted;
if (withDelisted) {
return tokensByCryptoCurrencyWithDelisted[currency.id] || emptyArray;
}
return tokensByCryptoCurrency[currency.id] || emptyArray;
}

@@ -57,13 +77,10 @@ /**

*/
export function listTokenTypesForCryptoCurrency(currency) {
return listTokensForCryptoCurrency(currency).reduce((acc, cur) => {
const tokenType = cur.tokenType;
if (acc.indexOf(tokenType) < 0) {
return [...acc, tokenType];
}
return acc;
}, []);
return listTokensForCryptoCurrency(currency).reduce(function (acc, cur) {
var tokenType = cur.tokenType;
if (acc.indexOf(tokenType) < 0) {
return __spreadArray(__spreadArray([], __read(acc)), [tokenType]);
}
return acc;
}, []);
}

@@ -73,5 +90,4 @@ /**

*/
export function findTokenByTicker(ticker) {
return tokensByTicker[ticker];
return tokensByTicker[ticker];
}

@@ -81,5 +97,4 @@ /**

*/
export function findTokenById(id) {
return tokensById[id];
return tokensById[id];
}

@@ -89,5 +104,4 @@ /**

*/
export function findTokenByAddress(address) {
return tokensByAddress[address.toLowerCase()];
return tokensByAddress[address.toLowerCase()];
}

@@ -97,16 +111,12 @@ /**

*/
export const hasTokenId = id => id in tokensById;
export var hasTokenId = function (id) { return id in tokensById; };
/**
*
*/
export function getTokenById(id) {
const currency = findTokenById(id);
if (!currency) {
throw new Error(`token with id "${id}" not found`);
}
return currency;
var currency = findTokenById(id);
if (!currency) {
throw new Error("token with id \"" + id + "\" not found");
}
return currency;
}

@@ -117,102 +127,105 @@ /**

*/
export function findCompoundToken(token) {
// TODO can be optimized by generating a direct map
return listTokensForCryptoCurrency(token.parentCurrency, {
withDelisted: true
}).find(t => t.compoundFor === token.id);
// TODO can be optimized by generating a direct map
return listTokensForCryptoCurrency(token.parentCurrency, {
withDelisted: true
}).find(function (t) { return t.compoundFor === token.id; });
}
function comparePriority(a, b) {
return Number(!!b.disableCountervalue) - Number(!!a.disableCountervalue);
return Number(!!b.disableCountervalue) - Number(!!a.disableCountervalue);
}
function addTokens(list) {
list.forEach(token => {
if (!token.delisted) tokensArray.push(token);
tokensArrayWithDelisted.push(token);
tokensById[token.id] = token;
if (!tokensByTicker[token.ticker] || comparePriority(token, tokensByTicker[token.ticker]) > 0) {
tokensByTicker[token.ticker] = token;
}
tokensByAddress[token.contractAddress.toLowerCase()] = token;
const {
parentCurrency
} = token;
if (!(parentCurrency.id in tokensByCryptoCurrency)) {
tokensByCryptoCurrency[parentCurrency.id] = [];
}
if (!(parentCurrency.id in tokensByCryptoCurrencyWithDelisted)) {
tokensByCryptoCurrencyWithDelisted[parentCurrency.id] = [];
}
if (!token.delisted) tokensByCryptoCurrency[parentCurrency.id].push(token);
tokensByCryptoCurrencyWithDelisted[parentCurrency.id].push(token);
});
list.forEach(function (token) {
if (!token.delisted)
tokensArray.push(token);
tokensArrayWithDelisted.push(token);
tokensById[token.id] = token;
if (!tokensByTicker[token.ticker] ||
comparePriority(token, tokensByTicker[token.ticker]) > 0) {
tokensByTicker[token.ticker] = token;
}
tokensByAddress[token.contractAddress.toLowerCase()] = token;
var parentCurrency = token.parentCurrency;
if (!(parentCurrency.id in tokensByCryptoCurrency)) {
tokensByCryptoCurrency[parentCurrency.id] = [];
}
if (!(parentCurrency.id in tokensByCryptoCurrencyWithDelisted)) {
tokensByCryptoCurrencyWithDelisted[parentCurrency.id] = [];
}
if (!token.delisted)
tokensByCryptoCurrency[parentCurrency.id].push(token);
tokensByCryptoCurrencyWithDelisted[parentCurrency.id].push(token);
});
}
function convertERC20([parentCurrencyId, token, ticker, magnitude, name, ledgerSignature, contractAddress, disableCountervalue, delisted, countervalueTicker, compoundFor]) {
const parentCurrency = getCryptoCurrencyById(parentCurrencyId);
return {
type: "TokenCurrency",
id: parentCurrencyId + "/erc20/" + token,
ledgerSignature,
contractAddress,
parentCurrency,
tokenType: "erc20",
name,
ticker,
delisted,
disableCountervalue: !!parentCurrency.isTestnetFor || !!disableCountervalue,
countervalueTicker,
compoundFor: compoundFor ? parentCurrencyId + "/erc20/" + compoundFor : undefined,
units: [{
name,
code: ticker,
magnitude
}]
};
function convertERC20(_a) {
var _b = __read(_a, 11), parentCurrencyId = _b[0], token = _b[1], ticker = _b[2], magnitude = _b[3], name = _b[4], ledgerSignature = _b[5], contractAddress = _b[6], disableCountervalue = _b[7], delisted = _b[8], countervalueTicker = _b[9], compoundFor = _b[10];
var parentCurrency = getCryptoCurrencyById(parentCurrencyId);
return {
type: "TokenCurrency",
id: parentCurrencyId + "/erc20/" + token,
ledgerSignature: ledgerSignature,
contractAddress: contractAddress,
parentCurrency: parentCurrency,
tokenType: "erc20",
name: name,
ticker: ticker,
delisted: delisted,
disableCountervalue: !!parentCurrency.isTestnetFor || !!disableCountervalue,
countervalueTicker: countervalueTicker,
compoundFor: compoundFor
? parentCurrencyId + "/erc20/" + compoundFor
: undefined,
units: [
{
name: name,
code: ticker,
magnitude: magnitude
},
]
};
}
function convertAlgorandASATokens([id, abbr, name, contractAddress, precision, enableCountervalues]) {
return {
type: "TokenCurrency",
id: `algorand/asa/${id}`,
contractAddress,
parentCurrency: getCryptoCurrencyById("algorand"),
tokenType: "asa",
name,
ticker: abbr,
disableCountervalue: !enableCountervalues,
units: [{
name,
code: abbr,
magnitude: precision
}]
};
function convertAlgorandASATokens(_a) {
var _b = __read(_a, 6), id = _b[0], abbr = _b[1], name = _b[2], contractAddress = _b[3], precision = _b[4], enableCountervalues = _b[5];
return {
type: "TokenCurrency",
id: "algorand/asa/" + id,
contractAddress: contractAddress,
parentCurrency: getCryptoCurrencyById("algorand"),
tokenType: "asa",
name: name,
ticker: abbr,
disableCountervalue: !enableCountervalues,
units: [
{
name: name,
code: abbr,
magnitude: precision
},
]
};
}
function convertTRONTokens(type) {
return ([id, abbr, name, contractAddress, precision, delisted, ledgerSignature, enableCountervalues]) => ({
type: "TokenCurrency",
id: `tron/${type}/${id}`,
contractAddress,
parentCurrency: getCryptoCurrencyById("tron"),
tokenType: type,
name,
ticker: abbr,
delisted,
disableCountervalue: !enableCountervalues,
ledgerSignature,
units: [{
name,
code: abbr,
magnitude: precision
}]
});
return function (_a) {
var _b = __read(_a, 8), id = _b[0], abbr = _b[1], name = _b[2], contractAddress = _b[3], precision = _b[4], delisted = _b[5], ledgerSignature = _b[6], enableCountervalues = _b[7];
return ({
type: "TokenCurrency",
id: "tron/" + type + "/" + id,
contractAddress: contractAddress,
parentCurrency: getCryptoCurrencyById("tron"),
tokenType: type,
name: name,
ticker: abbr,
delisted: delisted,
disableCountervalue: !enableCountervalues,
ledgerSignature: ledgerSignature,
units: [
{
name: name,
code: abbr,
magnitude: precision
},
]
});
};
}
//# sourceMappingURL=tokens.js.map

@@ -1,2 +0,2 @@

export {};
//# sourceMappingURL=types.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
exports.getAbandonSeedAddress = void 0;
var _invariant = _interopRequireDefault(require("invariant"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const abandonSeedAddresses = {
algorand: "PSHLIWQKDEETIIBQEOTLGCT5IF7BTTOKCUULONOGVGF2HYDT2IHW3H4CCI",
cosmos: "cosmos19rl4cm2hmr8afy4kldpxz3fka4jguq0auqdal4",
cosmos_testnet: "cosmos19rl4cm2hmr8afy4kldpxz3fka4jguq0auqdal4",
ripple: "rHsMGQEkVNJmpGWs8XUBoTBiAAbwxZN5v3",
stellar: "GDYPMQMYW2JTLPWAUAHIDY3E4VHP5SGTFC5SMA45L7ZPOTHWQ2PHEW3E",
tezos: "tz1VJitLYB31fEC82efFkLRU4AQUH9QgH3q6",
tron: "0x0000000000000000000000000000000000000000",
ethereum: "0x0000000000000000000000000000000000000000",
bitcoin: "1LqBGSKuX5yYUonjxT5qGfpUsXKYYWeabA",
bitcoin_cash: "1mW6fDEMjKrDHvLvoEsaeLxSCzZBf3Bfg",
bitcoin_gold: "GeTZ7bjfXtGsyEcerSSFJNUSZwLfjtCJX9",
bitcoin_private: "b1SGV7U5kGAMHtGbkAR3mjaZqVn57SHFbiR",
bitcoin_testnet: "mkpZhYtJu2r87Js3pDiWJDmPte2NRZ8bJV",
dash: "XoJA8qE3N2Y3jMLEtZ3vcN42qseZ8LvFf5",
decred: "",
// FIXME need to derivate decred abandon
digibyte: "DG1KhhBKpsyWXTakHNezaDQ34focsXjN1i",
dogecoin: "DBus3bamQjgJULBJtYXpEzDWQRwF5iwxgC",
game_credits: "GJgbzWpGhrZmSvc2V5Npqf57Kg9xfB79tj",
komodo: "RW8gfgpCUdgZbkPAs1uJQF2S9681JVkGRi",
litecoin: "LUWPbpM43E2p7ZSh8cyTBEkvpHmr3cB8Ez",
nix: "GRpn2DPiQxAczMrQFt2sK1CS8EYdnvSHxo",
peercoin: "PFinP8Tm5hFJKfVnSMFfiNibPNfHgXzTDZ",
pivx: "DDBxSas734KhMp1Btga3LdwWAc1igSER8o",
polkadot: "111111111111111111111111111111111HC1",
qtum: "QPvRe2C17qk24K6v5gTg7CPghZ8b4WMxZP",
stakenet: "XhPU3ZrghEh387nqgQ1Fi16JvtkSeYdP4g",
stealthcoin: "SKsLkKVeMtPNZQuNfUNXi3Bk1TwP1QPqJG",
stratis: "Sdo6x9k5AxWtfyJe5B9SZPteYTKgUoMMr1",
vertcoin: "Vce16eJifb7HpuoTFEBJyKNLsBJPo7fM83",
viacoin: "VfwB3jbDWELpfiFNzbEVgx73HsR9bAq35C",
zcash: "t1XVXWCvpMgBvUaed4XDqWtgQgJSu1Ghz7F",
zclassic: "t1Qmwyih5F7Mw6Vts4tSnXuA2o3NgJPYNgP",
zcoin: "a1bW3sVVUsLqgKuTMXtSaAHGvpxKwugxPH",
zencash: "zngWJRgpBa45KUeRuCmdMsqti4ohhe9sVwC"
var invariant_1 = __importDefault(require("invariant"));
var abandonSeedAddresses = {
algorand: "PSHLIWQKDEETIIBQEOTLGCT5IF7BTTOKCUULONOGVGF2HYDT2IHW3H4CCI",
cosmos: "cosmos19rl4cm2hmr8afy4kldpxz3fka4jguq0auqdal4",
cosmos_testnet: "cosmos19rl4cm2hmr8afy4kldpxz3fka4jguq0auqdal4",
ripple: "rHsMGQEkVNJmpGWs8XUBoTBiAAbwxZN5v3",
stellar: "GDYPMQMYW2JTLPWAUAHIDY3E4VHP5SGTFC5SMA45L7ZPOTHWQ2PHEW3E",
tezos: "tz1VJitLYB31fEC82efFkLRU4AQUH9QgH3q6",
tron: "0x0000000000000000000000000000000000000000",
ethereum: "0x0000000000000000000000000000000000000000",
bitcoin: "1LqBGSKuX5yYUonjxT5qGfpUsXKYYWeabA",
bitcoin_cash: "1mW6fDEMjKrDHvLvoEsaeLxSCzZBf3Bfg",
bitcoin_gold: "GeTZ7bjfXtGsyEcerSSFJNUSZwLfjtCJX9",
bitcoin_private: "b1SGV7U5kGAMHtGbkAR3mjaZqVn57SHFbiR",
bitcoin_testnet: "mkpZhYtJu2r87Js3pDiWJDmPte2NRZ8bJV",
dash: "XoJA8qE3N2Y3jMLEtZ3vcN42qseZ8LvFf5",
decred: "",
// FIXME need to derivate decred abandon
digibyte: "DG1KhhBKpsyWXTakHNezaDQ34focsXjN1i",
dogecoin: "DBus3bamQjgJULBJtYXpEzDWQRwF5iwxgC",
game_credits: "GJgbzWpGhrZmSvc2V5Npqf57Kg9xfB79tj",
komodo: "RW8gfgpCUdgZbkPAs1uJQF2S9681JVkGRi",
litecoin: "LUWPbpM43E2p7ZSh8cyTBEkvpHmr3cB8Ez",
nix: "GRpn2DPiQxAczMrQFt2sK1CS8EYdnvSHxo",
peercoin: "PFinP8Tm5hFJKfVnSMFfiNibPNfHgXzTDZ",
pivx: "DDBxSas734KhMp1Btga3LdwWAc1igSER8o",
polkadot: "111111111111111111111111111111111HC1",
qtum: "QPvRe2C17qk24K6v5gTg7CPghZ8b4WMxZP",
stakenet: "XhPU3ZrghEh387nqgQ1Fi16JvtkSeYdP4g",
stealthcoin: "SKsLkKVeMtPNZQuNfUNXi3Bk1TwP1QPqJG",
stratis: "Sdo6x9k5AxWtfyJe5B9SZPteYTKgUoMMr1",
vertcoin: "Vce16eJifb7HpuoTFEBJyKNLsBJPo7fM83",
viacoin: "VfwB3jbDWELpfiFNzbEVgx73HsR9bAq35C",
zcash: "t1XVXWCvpMgBvUaed4XDqWtgQgJSu1Ghz7F",
zclassic: "t1Qmwyih5F7Mw6Vts4tSnXuA2o3NgJPYNgP",
zcoin: "a1bW3sVVUsLqgKuTMXtSaAHGvpxKwugxPH",
zencash: "zngWJRgpBa45KUeRuCmdMsqti4ohhe9sVwC"
};

@@ -56,9 +52,7 @@ /**

*/
const getAbandonSeedAddress = currencyId => {
(0, _invariant.default)(abandonSeedAddresses[currencyId] !== undefined, `No abandonseed available for ${currencyId}`);
return abandonSeedAddresses[currencyId];
var getAbandonSeedAddress = function (currencyId) {
invariant_1["default"](abandonSeedAddresses[currencyId] !== undefined, "No abandonseed available for " + currencyId);
return abandonSeedAddresses[currencyId];
};
exports.getAbandonSeedAddress = getAbandonSeedAddress;
//# sourceMappingURL=abandonseed.js.map
"use strict";
var _fiats = require("./fiats");
var _tokens = require("./tokens");
var _currencies = require("./currencies");
test("can get currency by coin type", () => {
expect((0, _currencies.getCryptoCurrencyById)("bitcoin")).toMatchObject({
id: "bitcoin",
name: "Bitcoin"
});
expect((0, _currencies.getCryptoCurrencyById)("litecoin")).toMatchObject({
id: "litecoin",
name: "Litecoin"
});
expect((0, _currencies.hasCryptoCurrencyId)("bitcoin")).toBe(true);
expect((0, _currencies.hasCryptoCurrencyId)("")).toBe(false);
expect(() => (0, _currencies.getCryptoCurrencyById)("")).toThrow();
expect((0, _currencies.hasCryptoCurrencyId)("_")).toBe(false);
expect(() => (0, _currencies.getCryptoCurrencyById)("_")).toThrow();
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
exports.__esModule = true;
var fiats_1 = require("./fiats");
var tokens_1 = require("./tokens");
var currencies_1 = require("./currencies");
test("can get currency by coin type", function () {
expect(currencies_1.getCryptoCurrencyById("bitcoin")).toMatchObject({
id: "bitcoin",
name: "Bitcoin"
});
expect(currencies_1.getCryptoCurrencyById("litecoin")).toMatchObject({
id: "litecoin",
name: "Litecoin"
});
expect(currencies_1.hasCryptoCurrencyId("bitcoin")).toBe(true);
expect(currencies_1.hasCryptoCurrencyId("")).toBe(false);
expect(function () { return currencies_1.getCryptoCurrencyById(""); }).toThrow();
expect(currencies_1.hasCryptoCurrencyId("_")).toBe(false);
expect(function () { return currencies_1.getCryptoCurrencyById("_"); }).toThrow();
});
test("can find currency", () => {
const bitcoinMatch = {
id: "bitcoin",
name: "Bitcoin"
};
expect((0, _currencies.findCryptoCurrency)(c => c.name === "Bitcoin")).toMatchObject(bitcoinMatch);
expect((0, _currencies.findCryptoCurrencyById)("bitcoin")).toMatchObject(bitcoinMatch);
expect((0, _currencies.findCryptoCurrencyByKeyword)("btc")).toMatchObject(bitcoinMatch);
expect((0, _currencies.findCryptoCurrencyByKeyword)("btc")).toMatchObject(bitcoinMatch);
expect((0, _currencies.findCryptoCurrencyByKeyword)("btc")).toMatchObject(bitcoinMatch);
expect((0, _currencies.findCryptoCurrencyByTicker)("BTC")).toMatchObject(bitcoinMatch);
expect((0, _currencies.findCryptoCurrencyByScheme)("bitcoin")).toMatchObject(bitcoinMatch);
expect((0, _currencies.findCryptoCurrencyById)("_")).toBe(undefined);
expect((0, _currencies.findCryptoCurrencyByKeyword)("_")).toBe(undefined);
expect((0, _currencies.findCryptoCurrencyByKeyword)("_")).toBe(undefined);
expect((0, _currencies.findCryptoCurrencyByKeyword)("_")).toBe(undefined);
expect((0, _currencies.findCryptoCurrencyByTicker)("_")).toBe(undefined);
expect((0, _currencies.findCryptoCurrencyByScheme)("_")).toBe(undefined);
test("can find currency", function () {
var bitcoinMatch = {
id: "bitcoin",
name: "Bitcoin"
};
expect(currencies_1.findCryptoCurrency(function (c) { return c.name === "Bitcoin"; })).toMatchObject(bitcoinMatch);
expect(currencies_1.findCryptoCurrencyById("bitcoin")).toMatchObject(bitcoinMatch);
expect(currencies_1.findCryptoCurrencyByKeyword("btc")).toMatchObject(bitcoinMatch);
expect(currencies_1.findCryptoCurrencyByKeyword("btc")).toMatchObject(bitcoinMatch);
expect(currencies_1.findCryptoCurrencyByKeyword("btc")).toMatchObject(bitcoinMatch);
expect(currencies_1.findCryptoCurrencyByTicker("BTC")).toMatchObject(bitcoinMatch);
expect(currencies_1.findCryptoCurrencyByScheme("bitcoin")).toMatchObject(bitcoinMatch);
expect(currencies_1.findCryptoCurrencyById("_")).toBe(undefined);
expect(currencies_1.findCryptoCurrencyByKeyword("_")).toBe(undefined);
expect(currencies_1.findCryptoCurrencyByKeyword("_")).toBe(undefined);
expect(currencies_1.findCryptoCurrencyByKeyword("_")).toBe(undefined);
expect(currencies_1.findCryptoCurrencyByTicker("_")).toBe(undefined);
expect(currencies_1.findCryptoCurrencyByScheme("_")).toBe(undefined);
});
test("there are some dev cryptocurrencies", () => {
const all = (0, _currencies.listCryptoCurrencies)(true);
const prod = (0, _currencies.listCryptoCurrencies)();
expect(all).not.toBe(prod);
expect(all.filter(a => !a.isTestnetFor)).toMatchObject(prod);
expect(all.length).toBeGreaterThan(prod.length);
test("there are some dev cryptocurrencies", function () {
var all = currencies_1.listCryptoCurrencies(true);
var prod = currencies_1.listCryptoCurrencies();
expect(all).not.toBe(prod);
expect(all.filter(function (a) { return !a.isTestnetFor; })).toMatchObject(prod);
expect(all.length).toBeGreaterThan(prod.length);
});
test("there are some terminated cryptocurrencies", () => {
const all = (0, _currencies.listCryptoCurrencies)(false, true);
const supported = (0, _currencies.listCryptoCurrencies)();
expect(all).not.toBe(supported);
expect(all.filter(a => !a.terminated)).toMatchObject(supported);
expect(all.length).toBeGreaterThan(supported.length);
test("there are some terminated cryptocurrencies", function () {
var all = currencies_1.listCryptoCurrencies(false, true);
var supported = currencies_1.listCryptoCurrencies();
expect(all).not.toBe(supported);
expect(all.filter(function (a) { return !a.terminated; })).toMatchObject(supported);
expect(all.length).toBeGreaterThan(supported.length);
});
test("all cryptocurrencies match (by reference) the one you get by id", () => {
for (let c of (0, _currencies.listCryptoCurrencies)()) {
expect(c).toBe((0, _currencies.getCryptoCurrencyById)(c.id));
}
test("all cryptocurrencies match (by reference) the one you get by id", function () {
var e_1, _a;
try {
for (var _b = __values(currencies_1.listCryptoCurrencies()), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
expect(c).toBe(currencies_1.getCryptoCurrencyById(c.id));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
});
test("there is no testnet or terminated coin by default", () => {
expect((0, _currencies.listCryptoCurrencies)(false, false)).toBe((0, _currencies.listCryptoCurrencies)());
expect((0, _currencies.listCryptoCurrencies)(true, true).length).toBeGreaterThan((0, _currencies.listCryptoCurrencies)().length);
for (let c of (0, _currencies.listCryptoCurrencies)()) {
expect(!c.terminated).toBe(true);
expect(!c.isTestnetFor).toBe(true);
}
test("there is no testnet or terminated coin by default", function () {
var e_2, _a;
expect(currencies_1.listCryptoCurrencies(false, false)).toBe(currencies_1.listCryptoCurrencies());
expect(currencies_1.listCryptoCurrencies(true, true).length).toBeGreaterThan(currencies_1.listCryptoCurrencies().length);
try {
for (var _b = __values(currencies_1.listCryptoCurrencies()), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
expect(!c.terminated).toBe(true);
expect(!c.isTestnetFor).toBe(true);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
}
});
test("all cryptocurrencies have at least one unit", () => {
for (let c of (0, _currencies.listCryptoCurrencies)()) {
expect(c.units.length).toBeGreaterThan(0);
}
test("all cryptocurrencies have at least one unit", function () {
var e_3, _a;
try {
for (var _b = __values(currencies_1.listCryptoCurrencies()), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
expect(c.units.length).toBeGreaterThan(0);
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_3) throw e_3.error; }
}
});
test("fiats list is always the same", () => {
expect((0, _fiats.listFiatCurrencies)()).toEqual((0, _fiats.listFiatCurrencies)());
test("fiats list is always the same", function () {
expect(fiats_1.listFiatCurrencies()).toEqual(fiats_1.listFiatCurrencies());
});
test("fiats list elements are correct", () => {
const tickers = {};
for (const fiat of (0, _fiats.listFiatCurrencies)()) {
expect(fiat.ticker).toBeTruthy();
expect(typeof fiat.ticker).toBe("string");
expect(tickers[fiat.ticker]).toBeFalsy();
expect(fiat.units.length).toBeGreaterThan(0);
const unit = fiat.units[0];
expect(unit.code).toBeTruthy();
expect(typeof unit.code).toBe("string");
expect(unit.name).toBeTruthy();
expect(typeof unit.name).toBe("string");
expect(unit.magnitude).toBeGreaterThan(-1);
expect(typeof unit.magnitude).toBe("number");
tickers[fiat.ticker] = unit;
}
test("fiats list elements are correct", function () {
var e_4, _a;
var tickers = {};
try {
for (var _b = __values(fiats_1.listFiatCurrencies()), _c = _b.next(); !_c.done; _c = _b.next()) {
var fiat = _c.value;
expect(fiat.ticker).toBeTruthy();
expect(typeof fiat.ticker).toBe("string");
expect(tickers[fiat.ticker]).toBeFalsy();
expect(fiat.units.length).toBeGreaterThan(0);
var unit = fiat.units[0];
expect(unit.code).toBeTruthy();
expect(typeof unit.code).toBe("string");
expect(unit.name).toBeTruthy();
expect(typeof unit.name).toBe("string");
expect(unit.magnitude).toBeGreaterThan(-1);
expect(typeof unit.magnitude).toBe("number");
tickers[fiat.ticker] = unit;
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_4) throw e_4.error; }
}
});
test("tokens are correct", () => {
expect((0, _tokens.listTokens)().length).toBeGreaterThan(0);
for (const token of (0, _tokens.listTokens)()) {
expect(token.ticker).toBeTruthy();
expect(typeof token.id).toBe("string");
expect(typeof token.name).toBe("string");
if (token.ledgerSignature) {
expect(typeof token.ledgerSignature).toBe("string");
test("tokens are correct", function () {
var e_5, _a;
expect(tokens_1.listTokens().length).toBeGreaterThan(0);
try {
for (var _b = __values(tokens_1.listTokens()), _c = _b.next(); !_c.done; _c = _b.next()) {
var token = _c.value;
expect(token.ticker).toBeTruthy();
expect(typeof token.id).toBe("string");
expect(typeof token.name).toBe("string");
if (token.ledgerSignature) {
expect(typeof token.ledgerSignature).toBe("string");
}
expect(typeof token.tokenType).toBe("string");
expect(typeof token.parentCurrency).toBe("object");
expect(currencies_1.hasCryptoCurrencyId(token.parentCurrency.id)).toBe(true);
expect(typeof token.ticker).toBe("string");
expect(token.units.length).toBeGreaterThan(0);
var unit = token.units[0];
expect(unit.code).toBeTruthy();
expect(typeof unit.code).toBe("string");
expect(unit.name).toBeTruthy();
expect(typeof unit.name).toBe("string");
expect(unit.magnitude).toBeGreaterThan(-1);
expect(typeof unit.magnitude).toBe("number");
if (token.compoundFor) {
var t = tokens_1.findTokenById(token.compoundFor);
expect(typeof t).toBe("object");
}
}
}
expect(typeof token.tokenType).toBe("string");
expect(typeof token.parentCurrency).toBe("object");
expect((0, _currencies.hasCryptoCurrencyId)(token.parentCurrency.id)).toBe(true);
expect(typeof token.ticker).toBe("string");
expect(token.units.length).toBeGreaterThan(0);
const unit = token.units[0];
expect(unit.code).toBeTruthy();
expect(typeof unit.code).toBe("string");
expect(unit.name).toBeTruthy();
expect(typeof unit.name).toBe("string");
expect(unit.magnitude).toBeGreaterThan(-1);
expect(typeof unit.magnitude).toBe("number");
if (token.compoundFor) {
const t = (0, _tokens.findTokenById)(token.compoundFor);
expect(typeof t).toBe("object");
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_5) throw e_5.error; }
}
}
});
test("fiats list is sorted by ticker", () => {
expect((0, _fiats.listFiatCurrencies)().map(fiat => fiat.ticker).join(",")).toEqual((0, _fiats.listFiatCurrencies)().map(fiat => fiat.ticker).sort((a, b) => a > b ? 1 : -1).join(","));
test("fiats list is sorted by ticker", function () {
expect(fiats_1.listFiatCurrencies()
.map(function (fiat) { return fiat.ticker; })
.join(",")).toEqual(fiats_1.listFiatCurrencies()
.map(function (fiat) { return fiat.ticker; })
.sort(function (a, b) { return (a > b ? 1 : -1); })
.join(","));
});
test("can get fiat by coin type", () => {
expect((0, _fiats.getFiatCurrencyByTicker)("USD").units[0]).toMatchObject({
magnitude: 2
});
expect((0, _fiats.getFiatCurrencyByTicker)("EUR").units[0]).toMatchObject({
magnitude: 2
}); // this is not a fiat \o/
expect(() => (0, _fiats.getFiatCurrencyByTicker)("USDT").units[0]).toThrow();
expect((0, _fiats.hasFiatCurrencyTicker)("USD")).toBe(true);
expect((0, _fiats.hasFiatCurrencyTicker)("USDT")).toBe(false);
test("can get fiat by coin type", function () {
expect(fiats_1.getFiatCurrencyByTicker("USD").units[0]).toMatchObject({
magnitude: 2
});
expect(fiats_1.getFiatCurrencyByTicker("EUR").units[0]).toMatchObject({
magnitude: 2
});
// this is not a fiat \o/
expect(function () { return fiats_1.getFiatCurrencyByTicker("USDT").units[0]; }).toThrow();
expect(fiats_1.hasFiatCurrencyTicker("USD")).toBe(true);
expect(fiats_1.hasFiatCurrencyTicker("USDT")).toBe(false);
});
test("all USDT are countervalue enabled", () => {
const tokens = (0, _tokens.listTokens)().filter(t => t.ticker === "USDT" && !t.parentCurrency.isTestnetFor);
expect(tokens.map(t => t.id).sort()).toMatchSnapshot();
expect(tokens.every(t => t.disableCountervalue === false)).toBe(true);
test("all USDT are countervalue enabled", function () {
var tokens = tokens_1.listTokens().filter(function (t) { return t.ticker === "USDT" && !t.parentCurrency.isTestnetFor; });
expect(tokens.map(function (t) { return t.id; }).sort()).toMatchSnapshot();
expect(tokens.every(function (t) { return t.disableCountervalue === false; })).toBe(true);
});
test("can register a new coin externally", () => {
const coinId = "mycoin";
expect(() => (0, _currencies.getCryptoCurrencyById)("mycoin")).toThrow(`currency with id "${coinId}" not found`);
const mycoin = {
type: "CryptoCurrency",
id: coinId,
coinType: 8008,
name: "MyCoin",
managerAppName: "MyCoin",
ticker: "MYC",
countervalueTicker: "MYC",
scheme: "mycoin",
color: "#ff0000",
family: "mycoin",
units: [{
name: "MYC",
code: "MYC",
magnitude: 8
}, {
name: "SmallestUnit",
code: "SMALLESTUNIT",
magnitude: 0
}],
explorerViews: [{
address: "https://mycoinexplorer.com/account/$address",
tx: "https://mycoinexplorer.com/transaction/$hash",
token: "https://mycoinexplorer.com/token/$contractAddress/?a=$address"
}]
};
(0, _currencies.registerCryptoCurrency)(coinId, mycoin);
expect((0, _currencies.getCryptoCurrencyById)(coinId)).toEqual(mycoin);
test("can register a new coin externally", function () {
var coinId = "mycoin";
expect(function () { return currencies_1.getCryptoCurrencyById("mycoin"); }).toThrow("currency with id \"" + coinId + "\" not found");
var mycoin = {
type: "CryptoCurrency",
id: coinId,
coinType: 8008,
name: "MyCoin",
managerAppName: "MyCoin",
ticker: "MYC",
countervalueTicker: "MYC",
scheme: "mycoin",
color: "#ff0000",
family: "mycoin",
units: [
{
name: "MYC",
code: "MYC",
magnitude: 8
},
{
name: "SmallestUnit",
code: "SMALLESTUNIT",
magnitude: 0
},
],
explorerViews: [
{
address: "https://mycoinexplorer.com/account/$address",
tx: "https://mycoinexplorer.com/transaction/$hash",
token: "https://mycoinexplorer.com/token/$contractAddress/?a=$address"
},
]
};
currencies_1.registerCryptoCurrency(coinId, mycoin);
expect(currencies_1.getCryptoCurrencyById(coinId)).toEqual(mycoin);
});
//# sourceMappingURL=currencies.test.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var e_1, _a;
exports.__esModule = true;
exports.findExchangeCurrencyConfig = void 0;
var _erc = _interopRequireDefault(require("../data/exchange/erc20"));
var _coins = _interopRequireDefault(require("../data/exchange/coins"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const all = [..._erc.default, ..._coins.default];
const configs = {};
for (const [id, config, signature] of all) {
configs[id] = {
config,
signature
};
var erc20_1 = __importDefault(require("../data/exchange/erc20"));
var coins_1 = __importDefault(require("../data/exchange/coins"));
var all = __spreadArray(__spreadArray([], __read(erc20_1["default"])), __read(coins_1["default"]));
var configs = {};
try {
for (var all_1 = __values(all), all_1_1 = all_1.next(); !all_1_1.done; all_1_1 = all_1.next()) {
var _b = __read(all_1_1.value, 3), id = _b[0], config = _b[1], signature = _b[2];
configs[id] = {
config: config,
signature: signature
};
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (all_1_1 && !all_1_1.done && (_a = all_1["return"])) _a.call(all_1);
}
finally { if (e_1) throw e_1.error; }
}
/**
*
*/
const findExchangeCurrencyConfig = id => configs[id];
var findExchangeCurrencyConfig = function (id) { return configs[id]; };
exports.findExchangeCurrencyConfig = findExchangeCurrencyConfig;
//# sourceMappingURL=exchange.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hasFiatCurrencyTicker = hasFiatCurrencyTicker;
exports.findFiatCurrencyByTicker = findFiatCurrencyByTicker;
exports.getFiatCurrencyByTicker = getFiatCurrencyByTicker;
exports.listFiatCurrencies = listFiatCurrencies;
exports.__esModule = true;
exports.listFiatCurrencies = exports.getFiatCurrencyByTicker = exports.findFiatCurrencyByTicker = exports.hasFiatCurrencyTicker = void 0;
// inspired by https://github.com/smirzaei/currency-formatter/blob/master/currencies.json
function fiat(name, ticker, defaultSymbol, defaultMagnitude) {
// for now, we only create one unit, in the future we will allow more
return {
type: "FiatCurrency",
ticker,
name,
symbol: defaultSymbol,
units: [{
code: defaultSymbol,
name,
magnitude: defaultMagnitude,
showAllDigits: true,
prefixCode: true
}]
};
// for now, we only create one unit, in the future we will allow more
return {
type: "FiatCurrency",
ticker: ticker,
name: name,
symbol: defaultSymbol,
units: [
{
code: defaultSymbol,
name: name,
magnitude: defaultMagnitude,
showAllDigits: true,
prefixCode: true
},
]
};
}
const byTicker = {
AED: fiat("Emirati Dirham", "AED", "د.إ.", 2),
AUD: fiat("Australian Dollar", "AUD", "AU$", 2),
BGN: fiat("Bulgarian Lev", "BGN", "лв.", 2),
BHD: fiat("Bahraini Dinar", "BHD", "د.ب.", 3),
BRL: fiat("Brazilian Real", "BRL", "R$", 2),
CAD: fiat("Canadian Dollar", "CAD", "CA$", 2),
CHF: fiat("Swiss Franc", "CHF", "CHF", 2),
CLP: fiat("Chilean Peso", "CLP", "CLP$", 2),
CNY: fiat("Yuan or Chinese Renminbi", "CNY", "¥", 2),
CRC: fiat("Costa Rican Colón", "CRC", "₡", 2),
CZK: fiat("Czech Koruna", "CZK", "Kč", 2),
DKK: fiat("Danish Krone", "DKK", "kr.", 2),
EUR: fiat("Euro", "EUR", "€", 2),
GBP: fiat("British Pound", "GBP", "£", 2),
GHS: fiat("Ghanaian Cedi", "GHS", "₵", 2),
HKD: fiat("Hong Kong Dollar", "HKD", "HK$", 2),
HRK: fiat("Croatian Kuna", "HRK", "kn", 2),
HUF: fiat("Hungarian Forint", "HUF", "Ft", 2),
IDR: fiat("Indonesian Rupiah", "IDR", "Rp", 0),
ILS: fiat("Israeli Shekel", "ILS", "₪", 2),
INR: fiat("Indian Rupee", "INR", "₹", 2),
IRR: fiat("Iranian Rial", "IRR", "﷼", 2),
JPY: fiat("Japanese Yen", "JPY", "¥", 0),
KES: fiat("Kenyan Shilling", "KES", "S", 2),
KHR: fiat("Cambodian Riel", "KHR", "៛", 0),
KRW: fiat("South Korean Won", "KRW", "₩", 0),
MUR: fiat("Mauritian Rupee", "MUR", "₨", 2),
MXN: fiat("Mexico Peso", "MXN", "Mex$", 2),
MYR: fiat("Malaysian Ringgit", "MYR", "RM", 2),
NGN: fiat("Nigerian Naira", "NGN", "₦", 2),
NOK: fiat("Norwegian Krone", "NOK", "kr", 2),
NZD: fiat("New Zealand Dollar", "NZD", "NZ$", 2),
PHP: fiat("Philippine Peso", "PHP", "₱", 2),
PKR: fiat("Pakistani Rupee", "PKR", "₨", 2),
PLN: fiat("Polish Złoty", "PLN", "zł", 2),
RON: fiat("Romanian Leu", "RON", "lei", 2),
RUB: fiat("Russian Rouble", "RUB", "₽", 2),
SEK: fiat("Swedish Krona", "SEK", "kr", 2),
SGD: fiat("Singapore Dollar", "SGD", "S$", 2),
THB: fiat("Thai Baht", "THB", "฿", 2),
TRY: fiat("Turkish Lira", "TRY", "TL", 2),
TZS: fiat("Tanzanian Shilling", "TZS", "TSh", 2),
UAH: fiat("Ukrainian Hryvnia", "UAH", "₴", 2),
UGX: fiat("Ugandan Shilling", "UGX", "USh", 2),
USD: fiat("US Dollar", "USD", "$", 2),
VES: fiat("Venezuelan Bolivar", "VES", "Bs. S.", 2),
VND: fiat("Vietnamese Dong", "VND", "₫", 1),
VUV: fiat("Ni-Vanuatu Vatu", "VUV", "VT", 0),
ZAR: fiat("South African Rand", "ZAR", "R", 2)
var byTicker = {
AED: fiat("Emirati Dirham", "AED", "د.إ.", 2),
AUD: fiat("Australian Dollar", "AUD", "AU$", 2),
BGN: fiat("Bulgarian Lev", "BGN", "лв.", 2),
BHD: fiat("Bahraini Dinar", "BHD", "د.ب.", 3),
BRL: fiat("Brazilian Real", "BRL", "R$", 2),
CAD: fiat("Canadian Dollar", "CAD", "CA$", 2),
CHF: fiat("Swiss Franc", "CHF", "CHF", 2),
CLP: fiat("Chilean Peso", "CLP", "CLP$", 2),
CNY: fiat("Yuan or Chinese Renminbi", "CNY", "¥", 2),
CRC: fiat("Costa Rican Colón", "CRC", "₡", 2),
CZK: fiat("Czech Koruna", "CZK", "Kč", 2),
DKK: fiat("Danish Krone", "DKK", "kr.", 2),
EUR: fiat("Euro", "EUR", "€", 2),
GBP: fiat("British Pound", "GBP", "£", 2),
GHS: fiat("Ghanaian Cedi", "GHS", "₵", 2),
HKD: fiat("Hong Kong Dollar", "HKD", "HK$", 2),
HRK: fiat("Croatian Kuna", "HRK", "kn", 2),
HUF: fiat("Hungarian Forint", "HUF", "Ft", 2),
IDR: fiat("Indonesian Rupiah", "IDR", "Rp", 0),
ILS: fiat("Israeli Shekel", "ILS", "₪", 2),
INR: fiat("Indian Rupee", "INR", "₹", 2),
IRR: fiat("Iranian Rial", "IRR", "﷼", 2),
JPY: fiat("Japanese Yen", "JPY", "¥", 0),
KES: fiat("Kenyan Shilling", "KES", "S", 2),
KHR: fiat("Cambodian Riel", "KHR", "៛", 0),
KRW: fiat("South Korean Won", "KRW", "₩", 0),
MUR: fiat("Mauritian Rupee", "MUR", "₨", 2),
MXN: fiat("Mexico Peso", "MXN", "Mex$", 2),
MYR: fiat("Malaysian Ringgit", "MYR", "RM", 2),
NGN: fiat("Nigerian Naira", "NGN", "₦", 2),
NOK: fiat("Norwegian Krone", "NOK", "kr", 2),
NZD: fiat("New Zealand Dollar", "NZD", "NZ$", 2),
PHP: fiat("Philippine Peso", "PHP", "₱", 2),
PKR: fiat("Pakistani Rupee", "PKR", "₨", 2),
PLN: fiat("Polish Złoty", "PLN", "zł", 2),
RON: fiat("Romanian Leu", "RON", "lei", 2),
RUB: fiat("Russian Rouble", "RUB", "₽", 2),
SEK: fiat("Swedish Krona", "SEK", "kr", 2),
SGD: fiat("Singapore Dollar", "SGD", "S$", 2),
THB: fiat("Thai Baht", "THB", "฿", 2),
TRY: fiat("Turkish Lira", "TRY", "TL", 2),
TZS: fiat("Tanzanian Shilling", "TZS", "TSh", 2),
UAH: fiat("Ukrainian Hryvnia", "UAH", "₴", 2),
UGX: fiat("Ugandan Shilling", "UGX", "USh", 2),
USD: fiat("US Dollar", "USD", "$", 2),
VES: fiat("Venezuelan Bolivar", "VES", "Bs. S.", 2),
VND: fiat("Vietnamese Dong", "VND", "₫", 1),
VUV: fiat("Ni-Vanuatu Vatu", "VUV", "VT", 0),
ZAR: fiat("South African Rand", "ZAR", "R", 2)
};
const list = Object.keys(byTicker).map(k => byTicker[k]);
var list = Object.keys(byTicker).map(function (k) { return byTicker[k]; });
/**

@@ -85,6 +79,6 @@ *

*/
function hasFiatCurrencyTicker(ticker) {
return ticker in byTicker;
return ticker in byTicker;
}
exports.hasFiatCurrencyTicker = hasFiatCurrencyTicker;
/**

@@ -94,7 +88,6 @@ *

*/
function findFiatCurrencyByTicker(ticker) {
return byTicker[ticker];
return byTicker[ticker];
}
exports.findFiatCurrencyByTicker = findFiatCurrencyByTicker;
/**

@@ -104,21 +97,17 @@ *

*/
function getFiatCurrencyByTicker(ticker) {
const cur = findFiatCurrencyByTicker(ticker);
if (!cur) {
throw new Error(`fiat currency "${ticker}" not found`);
}
return cur;
var cur = findFiatCurrencyByTicker(ticker);
if (!cur) {
throw new Error("fiat currency \"" + ticker + "\" not found");
}
return cur;
}
exports.getFiatCurrencyByTicker = getFiatCurrencyByTicker;
/**
*
*/
function listFiatCurrencies() {
return list;
return list;
}
exports.listFiatCurrencies = listFiatCurrencies;
//# sourceMappingURL=fiats.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _fiats = require("./fiats");
Object.keys(_fiats).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _fiats[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _fiats[key];
}
});
});
var _currencies = require("./currencies");
Object.keys(_currencies).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _currencies[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _currencies[key];
}
});
});
var _tokens = require("./tokens");
Object.keys(_tokens).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _tokens[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _tokens[key];
}
});
});
var _exchange = require("./exchange");
Object.keys(_exchange).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _exchange[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _exchange[key];
}
});
});
var _abandonseed = require("./abandonseed");
Object.keys(_abandonseed).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _abandonseed[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _abandonseed[key];
}
});
});
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
exports.__esModule = true;
__exportStar(require("./fiats"), exports);
__exportStar(require("./currencies"), exports);
__exportStar(require("./tokens"), exports);
__exportStar(require("./exchange"), exports);
__exportStar(require("./abandonseed"), exports);
__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.listTokens = listTokens;
exports.listTokensForCryptoCurrency = listTokensForCryptoCurrency;
exports.listTokenTypesForCryptoCurrency = listTokenTypesForCryptoCurrency;
exports.findTokenByTicker = findTokenByTicker;
exports.findTokenById = findTokenById;
exports.findTokenByAddress = findTokenByAddress;
exports.getTokenById = getTokenById;
exports.findCompoundToken = findCompoundToken;
exports.hasTokenId = void 0;
var _currencies = require("./currencies");
var _erc = _interopRequireDefault(require("../data/erc20"));
var _trc = _interopRequireDefault(require("../data/trc10"));
var _trc2 = _interopRequireDefault(require("../data/trc20"));
var _asa = _interopRequireDefault(require("../data/asa"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
const emptyArray = [];
const tokensArray = [];
const tokensArrayWithDelisted = [];
const tokensByCryptoCurrency = {};
const tokensByCryptoCurrencyWithDelisted = {};
const tokensById = {};
const tokensByTicker = {};
const tokensByAddress = {};
addTokens(_erc.default.map(convertERC20));
addTokens(_trc.default.map(convertTRONTokens("trc10")));
addTokens(_trc2.default.map(convertTRONTokens("trc20")));
addTokens(_asa.default.map(convertAlgorandASATokens));
const defaultTokenListOptions = {
withDelisted: false
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
exports.findCompoundToken = exports.getTokenById = exports.hasTokenId = exports.findTokenByAddress = exports.findTokenById = exports.findTokenByTicker = exports.listTokenTypesForCryptoCurrency = exports.listTokensForCryptoCurrency = exports.listTokens = void 0;
var currencies_1 = require("./currencies");
var erc20_1 = __importDefault(require("../data/erc20"));
var trc10_1 = __importDefault(require("../data/trc10"));
var trc20_1 = __importDefault(require("../data/trc20"));
var asa_1 = __importDefault(require("../data/asa"));
var emptyArray = [];
var tokensArray = [];
var tokensArrayWithDelisted = [];
var tokensByCryptoCurrency = {};
var tokensByCryptoCurrencyWithDelisted = {};
var tokensById = {};
var tokensByTicker = {};
var tokensByAddress = {};
addTokens(erc20_1["default"].map(convertERC20));
addTokens(trc10_1["default"].map(convertTRONTokens("trc10")));
addTokens(trc20_1["default"].map(convertTRONTokens("trc20")));
addTokens(asa_1["default"].map(convertAlgorandASATokens));
var defaultTokenListOptions = {
withDelisted: false
};
/**
*
*/
function listTokens(options) {
const {
withDelisted
} = _objectSpread(_objectSpread({}, defaultTokenListOptions), options);
return withDelisted ? tokensArrayWithDelisted : tokensArray;
var withDelisted = __assign(__assign({}, defaultTokenListOptions), options).withDelisted;
return withDelisted ? tokensArrayWithDelisted : tokensArray;
}
exports.listTokens = listTokens;
/**
*
*/
function listTokensForCryptoCurrency(currency, options) {
const {
withDelisted
} = _objectSpread(_objectSpread({}, defaultTokenListOptions), options);
if (withDelisted) {
return tokensByCryptoCurrencyWithDelisted[currency.id] || emptyArray;
}
return tokensByCryptoCurrency[currency.id] || emptyArray;
var withDelisted = __assign(__assign({}, defaultTokenListOptions), options).withDelisted;
if (withDelisted) {
return tokensByCryptoCurrencyWithDelisted[currency.id] || emptyArray;
}
return tokensByCryptoCurrency[currency.id] || emptyArray;
}
exports.listTokensForCryptoCurrency = listTokensForCryptoCurrency;
/**
*
*/
function listTokenTypesForCryptoCurrency(currency) {
return listTokensForCryptoCurrency(currency).reduce((acc, cur) => {
const tokenType = cur.tokenType;
if (acc.indexOf(tokenType) < 0) {
return [...acc, tokenType];
}
return acc;
}, []);
return listTokensForCryptoCurrency(currency).reduce(function (acc, cur) {
var tokenType = cur.tokenType;
if (acc.indexOf(tokenType) < 0) {
return __spreadArray(__spreadArray([], __read(acc)), [tokenType]);
}
return acc;
}, []);
}
exports.listTokenTypesForCryptoCurrency = listTokenTypesForCryptoCurrency;
/**
*
*/
function findTokenByTicker(ticker) {
return tokensByTicker[ticker];
return tokensByTicker[ticker];
}
exports.findTokenByTicker = findTokenByTicker;
/**
*
*/
function findTokenById(id) {
return tokensById[id];
return tokensById[id];
}
exports.findTokenById = findTokenById;
/**
*
*/
function findTokenByAddress(address) {
return tokensByAddress[address.toLowerCase()];
return tokensByAddress[address.toLowerCase()];
}
exports.findTokenByAddress = findTokenByAddress;
/**
*
*/
const hasTokenId = id => id in tokensById;
var hasTokenId = function (id) { return id in tokensById; };
exports.hasTokenId = hasTokenId;
/**
*
*/
exports.hasTokenId = hasTokenId;
function getTokenById(id) {
const currency = findTokenById(id);
if (!currency) {
throw new Error(`token with id "${id}" not found`);
}
return currency;
var currency = findTokenById(id);
if (!currency) {
throw new Error("token with id \"" + id + "\" not found");
}
return currency;
}
exports.getTokenById = getTokenById;
/**

@@ -142,103 +132,106 @@ * if a given token account is a token that can be used in compound, give the associated compound token (cToken)

*/
function findCompoundToken(token) {
// TODO can be optimized by generating a direct map
return listTokensForCryptoCurrency(token.parentCurrency, {
withDelisted: true
}).find(t => t.compoundFor === token.id);
// TODO can be optimized by generating a direct map
return listTokensForCryptoCurrency(token.parentCurrency, {
withDelisted: true
}).find(function (t) { return t.compoundFor === token.id; });
}
exports.findCompoundToken = findCompoundToken;
function comparePriority(a, b) {
return Number(!!b.disableCountervalue) - Number(!!a.disableCountervalue);
return Number(!!b.disableCountervalue) - Number(!!a.disableCountervalue);
}
function addTokens(list) {
list.forEach(token => {
if (!token.delisted) tokensArray.push(token);
tokensArrayWithDelisted.push(token);
tokensById[token.id] = token;
if (!tokensByTicker[token.ticker] || comparePriority(token, tokensByTicker[token.ticker]) > 0) {
tokensByTicker[token.ticker] = token;
}
tokensByAddress[token.contractAddress.toLowerCase()] = token;
const {
parentCurrency
} = token;
if (!(parentCurrency.id in tokensByCryptoCurrency)) {
tokensByCryptoCurrency[parentCurrency.id] = [];
}
if (!(parentCurrency.id in tokensByCryptoCurrencyWithDelisted)) {
tokensByCryptoCurrencyWithDelisted[parentCurrency.id] = [];
}
if (!token.delisted) tokensByCryptoCurrency[parentCurrency.id].push(token);
tokensByCryptoCurrencyWithDelisted[parentCurrency.id].push(token);
});
list.forEach(function (token) {
if (!token.delisted)
tokensArray.push(token);
tokensArrayWithDelisted.push(token);
tokensById[token.id] = token;
if (!tokensByTicker[token.ticker] ||
comparePriority(token, tokensByTicker[token.ticker]) > 0) {
tokensByTicker[token.ticker] = token;
}
tokensByAddress[token.contractAddress.toLowerCase()] = token;
var parentCurrency = token.parentCurrency;
if (!(parentCurrency.id in tokensByCryptoCurrency)) {
tokensByCryptoCurrency[parentCurrency.id] = [];
}
if (!(parentCurrency.id in tokensByCryptoCurrencyWithDelisted)) {
tokensByCryptoCurrencyWithDelisted[parentCurrency.id] = [];
}
if (!token.delisted)
tokensByCryptoCurrency[parentCurrency.id].push(token);
tokensByCryptoCurrencyWithDelisted[parentCurrency.id].push(token);
});
}
function convertERC20([parentCurrencyId, token, ticker, magnitude, name, ledgerSignature, contractAddress, disableCountervalue, delisted, countervalueTicker, compoundFor]) {
const parentCurrency = (0, _currencies.getCryptoCurrencyById)(parentCurrencyId);
return {
type: "TokenCurrency",
id: parentCurrencyId + "/erc20/" + token,
ledgerSignature,
contractAddress,
parentCurrency,
tokenType: "erc20",
name,
ticker,
delisted,
disableCountervalue: !!parentCurrency.isTestnetFor || !!disableCountervalue,
countervalueTicker,
compoundFor: compoundFor ? parentCurrencyId + "/erc20/" + compoundFor : undefined,
units: [{
name,
code: ticker,
magnitude
}]
};
function convertERC20(_a) {
var _b = __read(_a, 11), parentCurrencyId = _b[0], token = _b[1], ticker = _b[2], magnitude = _b[3], name = _b[4], ledgerSignature = _b[5], contractAddress = _b[6], disableCountervalue = _b[7], delisted = _b[8], countervalueTicker = _b[9], compoundFor = _b[10];
var parentCurrency = currencies_1.getCryptoCurrencyById(parentCurrencyId);
return {
type: "TokenCurrency",
id: parentCurrencyId + "/erc20/" + token,
ledgerSignature: ledgerSignature,
contractAddress: contractAddress,
parentCurrency: parentCurrency,
tokenType: "erc20",
name: name,
ticker: ticker,
delisted: delisted,
disableCountervalue: !!parentCurrency.isTestnetFor || !!disableCountervalue,
countervalueTicker: countervalueTicker,
compoundFor: compoundFor
? parentCurrencyId + "/erc20/" + compoundFor
: undefined,
units: [
{
name: name,
code: ticker,
magnitude: magnitude
},
]
};
}
function convertAlgorandASATokens([id, abbr, name, contractAddress, precision, enableCountervalues]) {
return {
type: "TokenCurrency",
id: `algorand/asa/${id}`,
contractAddress,
parentCurrency: (0, _currencies.getCryptoCurrencyById)("algorand"),
tokenType: "asa",
name,
ticker: abbr,
disableCountervalue: !enableCountervalues,
units: [{
name,
code: abbr,
magnitude: precision
}]
};
function convertAlgorandASATokens(_a) {
var _b = __read(_a, 6), id = _b[0], abbr = _b[1], name = _b[2], contractAddress = _b[3], precision = _b[4], enableCountervalues = _b[5];
return {
type: "TokenCurrency",
id: "algorand/asa/" + id,
contractAddress: contractAddress,
parentCurrency: currencies_1.getCryptoCurrencyById("algorand"),
tokenType: "asa",
name: name,
ticker: abbr,
disableCountervalue: !enableCountervalues,
units: [
{
name: name,
code: abbr,
magnitude: precision
},
]
};
}
function convertTRONTokens(type) {
return ([id, abbr, name, contractAddress, precision, delisted, ledgerSignature, enableCountervalues]) => ({
type: "TokenCurrency",
id: `tron/${type}/${id}`,
contractAddress,
parentCurrency: (0, _currencies.getCryptoCurrencyById)("tron"),
tokenType: type,
name,
ticker: abbr,
delisted,
disableCountervalue: !enableCountervalues,
ledgerSignature,
units: [{
name,
code: abbr,
magnitude: precision
}]
});
return function (_a) {
var _b = __read(_a, 8), id = _b[0], abbr = _b[1], name = _b[2], contractAddress = _b[3], precision = _b[4], delisted = _b[5], ledgerSignature = _b[6], enableCountervalues = _b[7];
return ({
type: "TokenCurrency",
id: "tron/" + type + "/" + id,
contractAddress: contractAddress,
parentCurrency: currencies_1.getCryptoCurrencyById("tron"),
tokenType: type,
name: name,
ticker: abbr,
delisted: delisted,
disableCountervalue: !enableCountervalues,
ledgerSignature: ledgerSignature,
units: [
{
name: name,
code: abbr,
magnitude: precision
},
]
});
};
}
//# sourceMappingURL=tokens.js.map
"use strict";
exports.__esModule = true;
//# sourceMappingURL=types.js.map
{
"name": "@ledgerhq/cryptoassets",
"version": "6.0.0-alpha.0",
"version": "6.0.0-typescript.0",
"description": "Ledger crypto-assets list",

@@ -21,2 +21,3 @@ "keywords": [

"module": "lib-es/index.js",
"types": "lib/index.d.ts",
"license": "Apache-2.0",

@@ -26,13 +27,9 @@ "dependencies": {

},
"devDependencies": {
"flow-bin": "^0.149.0"
},
"scripts": {
"flow": "flow",
"clean": "bash ../../script/clean.sh",
"build": "bash ../../script/build.sh",
"watch": "bash ../../script/watch.sh",
"doc": "bash ../../script/doc.sh"
"doc": "bash ../../script/doc-ts.sh"
},
"gitHead": "5d7bee7188d759dc5bbce14213bad613f1d2aa08"
"gitHead": "3f8eef5e86a232eb16f4c018212e38f13799eeb2"
}

@@ -24,4 +24,2 @@ <img src="https://user-images.githubusercontent.com/211411/34776833-6f1ef4da-f618-11e7-8b13-f0697901d6a8.png" height="100" />

- [Parameters](#parameters)
- [CryptoCurrencyObjMap](#cryptocurrencyobjmap)
- [CryptoCurrencyConfig](#cryptocurrencyconfig)
- [CryptoCurrencyIds](#cryptocurrencyids)

@@ -97,13 +95,5 @@ - [registerCryptoCurrency](#registercryptocurrency)

### CryptoCurrencyObjMap
Type: $Exact&lt;$ObjMap&lt;any, F>>
### CryptoCurrencyConfig
Type: [CryptoCurrencyObjMap](#cryptocurrencyobjmap)&lt;function (any): C>
### CryptoCurrencyIds
Type: $Keys&lt;any>
Type: any

@@ -132,3 +122,3 @@ ### registerCryptoCurrency

Returns **[CryptoCurrency](#cryptocurrency)?**
Returns **([CryptoCurrency](#cryptocurrency) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**

@@ -141,3 +131,3 @@ ### findCryptoCurrencyByScheme

Returns **[CryptoCurrency](#cryptocurrency)?**
Returns **([CryptoCurrency](#cryptocurrency) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**

@@ -150,3 +140,3 @@ ### findCryptoCurrencyByTicker

Returns **[CryptoCurrency](#cryptocurrency)?**
Returns **([CryptoCurrency](#cryptocurrency) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**

@@ -159,3 +149,3 @@ ### findCryptoCurrencyById

Returns **[CryptoCurrency](#cryptocurrency)?**
Returns **([CryptoCurrency](#cryptocurrency) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**

@@ -168,3 +158,3 @@ ### findCryptoCurrencyByKeyword

Returns **[CryptoCurrency](#cryptocurrency)?**
Returns **([CryptoCurrency](#cryptocurrency) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**

@@ -193,3 +183,3 @@ ### hasCryptoCurrencyId

Returns **{config: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), signature: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}?**
Returns **({config: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), signature: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)} | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**

@@ -210,3 +200,3 @@ ### hasFiatCurrencyTicker

Returns **[FiatCurrency](#fiatcurrency)?**
Returns **([FiatCurrency](#fiatcurrency) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**

@@ -229,3 +219,3 @@ ### getFiatCurrencyByTicker

- `options` **$Shape&lt;TokensListOptions>?**
- `options` **Partial&lt;TokensListOptions>?**

@@ -239,3 +229,3 @@ Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[TokenCurrency](#tokencurrency)>**

- `currency` **[CryptoCurrency](#cryptocurrency)**
- `options` **$Shape&lt;TokensListOptions>?**
- `options` **Partial&lt;TokensListOptions>?**

@@ -258,3 +248,3 @@ Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[TokenCurrency](#tokencurrency)>**

Returns **[TokenCurrency](#tokencurrency)?**
Returns **([TokenCurrency](#tokencurrency) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**

@@ -267,3 +257,3 @@ ### findTokenById

Returns **[TokenCurrency](#tokencurrency)?**
Returns **([TokenCurrency](#tokencurrency) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**

@@ -276,3 +266,3 @@ ### findTokenByAddress

Returns **[TokenCurrency](#tokencurrency)?**
Returns **([TokenCurrency](#tokencurrency) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**

@@ -303,6 +293,8 @@ ### hasTokenId

Returns **[TokenCurrency](#tokencurrency)?**
Returns **([TokenCurrency](#tokencurrency) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
### Unit
Type: {name: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), code: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), magnitude: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), showAllDigits: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, prefixCode: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?}
#### Properties

@@ -318,2 +310,4 @@

Type: {name: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), ticker: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), units: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Unit](#unit)>, symbol: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, disableCountervalue: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, delisted: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, countervalueTicker: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?}
#### Properties

@@ -339,2 +333,4 @@

Type: {tx: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, address: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, token: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?}
#### Properties

@@ -341,0 +337,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc