@ledgerhq/cryptoassets
Advanced tools
Comparing version 5.44.1 to 5.45.0
@@ -2333,6 +2333,2 @@ /* | ||
}; | ||
/** | ||
* | ||
*/ | ||
const cryptocurrenciesByScheme = {}; | ||
@@ -2342,18 +2338,38 @@ const cryptocurrenciesByTicker = {}; | ||
const prodCryptoArray = []; | ||
const cryptocurrenciesArrayWithoutTerminated = []; | ||
const prodCryptoArrayWithoutTerminated = []; | ||
for (const id in cryptocurrenciesById) { | ||
const c = cryptocurrenciesById[id]; | ||
cryptocurrenciesById[c.id] = c; | ||
cryptocurrenciesByScheme[c.scheme] = c; | ||
const definition = cryptocurrenciesById[id]; | ||
registerCryptoCurrency(id, definition); | ||
} | ||
/** | ||
* | ||
*/ | ||
if (!c.isTestnetFor) { | ||
cryptocurrenciesByTicker[c.ticker] = c; | ||
prodCryptoArray.push(c); | ||
/** | ||
* | ||
* @param {string} id | ||
* @param {CryptoCurrency} currency | ||
*/ | ||
export function registerCryptoCurrency(id, currency) { | ||
cryptocurrenciesById[currency.id] = currency; | ||
cryptocurrenciesByScheme[currency.scheme] = currency; | ||
if (!currency.isTestnetFor) { | ||
cryptocurrenciesByTicker[currency.ticker] = currency; | ||
prodCryptoArray.push(currency); | ||
if (!currency.terminated) { | ||
prodCryptoArrayWithoutTerminated.push(currency); | ||
} | ||
} | ||
cryptocurrenciesArray.push(c); | ||
cryptocurrenciesArray.push(currency); | ||
if (!currency.terminated) { | ||
cryptocurrenciesArrayWithoutTerminated.push(currency); | ||
} | ||
} | ||
const cryptocurrenciesArrayWithoutTerminated = cryptocurrenciesArray.filter(c => !c.terminated); | ||
const prodCryptoArrayWithoutTerminated = prodCryptoArray.filter(c => !c.terminated); | ||
/** | ||
@@ -2360,0 +2376,0 @@ * |
import { listFiatCurrencies, getFiatCurrencyByTicker, hasFiatCurrencyTicker } from "./fiats"; | ||
import { listTokens, findTokenById } from "./tokens"; | ||
import { listCryptoCurrencies, hasCryptoCurrencyId, getCryptoCurrencyById } from "./currencies"; | ||
import { listCryptoCurrencies, hasCryptoCurrencyId, getCryptoCurrencyById, findCryptoCurrency, findCryptoCurrencyById, findCryptoCurrencyByScheme, findCryptoCurrencyByTicker, findCryptoCurrencyByKeyword, registerCryptoCurrency } from "./currencies"; | ||
test("can get currency by coin type", () => { | ||
@@ -19,6 +19,24 @@ expect(getCryptoCurrencyById("bitcoin")).toMatchObject({ | ||
}); | ||
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("there are some dev cryptocurrencies", () => { | ||
const all = listCryptoCurrencies(true); | ||
const prod = listCryptoCurrencies(); | ||
expect(listCryptoCurrencies(false)).toBe(listCryptoCurrencies()); | ||
expect(all).not.toBe(prod); | ||
@@ -28,2 +46,9 @@ expect(all.filter(a => !a.isTestnetFor)).toMatchObject(prod); | ||
}); | ||
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("all cryptocurrencies match (by reference) the one you get by id", () => { | ||
@@ -35,2 +60,5 @@ for (let c of listCryptoCurrencies()) { | ||
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()) { | ||
@@ -118,2 +146,34 @@ expect(!c.terminated).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); | ||
}); | ||
//# sourceMappingURL=currencies.test.js.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.registerCryptoCurrency = registerCryptoCurrency; | ||
exports.listCryptoCurrencies = listCryptoCurrencies; | ||
@@ -2353,6 +2354,2 @@ exports.findCryptoCurrency = findCryptoCurrency; | ||
}; | ||
/** | ||
* | ||
*/ | ||
const cryptocurrenciesByScheme = {}; | ||
@@ -2362,18 +2359,38 @@ const cryptocurrenciesByTicker = {}; | ||
const prodCryptoArray = []; | ||
const cryptocurrenciesArrayWithoutTerminated = []; | ||
const prodCryptoArrayWithoutTerminated = []; | ||
for (const id in cryptocurrenciesById) { | ||
const c = cryptocurrenciesById[id]; | ||
cryptocurrenciesById[c.id] = c; | ||
cryptocurrenciesByScheme[c.scheme] = c; | ||
const definition = cryptocurrenciesById[id]; | ||
registerCryptoCurrency(id, definition); | ||
} | ||
/** | ||
* | ||
*/ | ||
if (!c.isTestnetFor) { | ||
cryptocurrenciesByTicker[c.ticker] = c; | ||
prodCryptoArray.push(c); | ||
/** | ||
* | ||
* @param {string} id | ||
* @param {CryptoCurrency} currency | ||
*/ | ||
function registerCryptoCurrency(id, currency) { | ||
cryptocurrenciesById[currency.id] = currency; | ||
cryptocurrenciesByScheme[currency.scheme] = currency; | ||
if (!currency.isTestnetFor) { | ||
cryptocurrenciesByTicker[currency.ticker] = currency; | ||
prodCryptoArray.push(currency); | ||
if (!currency.terminated) { | ||
prodCryptoArrayWithoutTerminated.push(currency); | ||
} | ||
} | ||
cryptocurrenciesArray.push(c); | ||
cryptocurrenciesArray.push(currency); | ||
if (!currency.terminated) { | ||
cryptocurrenciesArrayWithoutTerminated.push(currency); | ||
} | ||
} | ||
const cryptocurrenciesArrayWithoutTerminated = cryptocurrenciesArray.filter(c => !c.terminated); | ||
const prodCryptoArrayWithoutTerminated = prodCryptoArray.filter(c => !c.terminated); | ||
/** | ||
@@ -2385,2 +2402,3 @@ * | ||
function listCryptoCurrencies(withDevCrypto = false, withTerminated = false) { | ||
@@ -2387,0 +2405,0 @@ return withTerminated ? withDevCrypto ? cryptocurrenciesArray : prodCryptoArray : withDevCrypto ? cryptocurrenciesArrayWithoutTerminated : prodCryptoArrayWithoutTerminated; |
@@ -24,6 +24,24 @@ "use strict"; | ||
}); | ||
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("there are some dev cryptocurrencies", () => { | ||
const all = (0, _currencies.listCryptoCurrencies)(true); | ||
const prod = (0, _currencies.listCryptoCurrencies)(); | ||
expect((0, _currencies.listCryptoCurrencies)(false)).toBe((0, _currencies.listCryptoCurrencies)()); | ||
expect(all).not.toBe(prod); | ||
@@ -33,2 +51,9 @@ expect(all.filter(a => !a.isTestnetFor)).toMatchObject(prod); | ||
}); | ||
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("all cryptocurrencies match (by reference) the one you get by id", () => { | ||
@@ -40,2 +65,5 @@ for (let c of (0, _currencies.listCryptoCurrencies)()) { | ||
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)()) { | ||
@@ -123,2 +151,34 @@ expect(!c.terminated).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); | ||
}); | ||
//# sourceMappingURL=currencies.test.js.map |
{ | ||
"name": "@ledgerhq/cryptoassets", | ||
"version": "5.44.1", | ||
"version": "5.45.0", | ||
"description": "Ledger crypto-assets list", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "2e0430956fd0a43e588e8cd490e3439d811eb139" | ||
"gitHead": "99a83259c1493e356f6060322960bba8f7af5c8a" | ||
} |
@@ -27,45 +27,47 @@ <img src="https://user-images.githubusercontent.com/211411/34776833-6f1ef4da-f618-11e7-8b13-f0697901d6a8.png" height="100" /> | ||
- [CryptoCurrencyIds](#cryptocurrencyids) | ||
- [registerCryptoCurrency](#registercryptocurrency) | ||
- [Parameters](#parameters-1) | ||
- [listCryptoCurrencies](#listcryptocurrencies) | ||
- [Parameters](#parameters-1) | ||
- [Parameters](#parameters-2) | ||
- [findCryptoCurrency](#findcryptocurrency) | ||
- [Parameters](#parameters-2) | ||
- [Parameters](#parameters-3) | ||
- [findCryptoCurrencyByScheme](#findcryptocurrencybyscheme) | ||
- [Parameters](#parameters-3) | ||
- [Parameters](#parameters-4) | ||
- [findCryptoCurrencyByTicker](#findcryptocurrencybyticker) | ||
- [Parameters](#parameters-4) | ||
- [Parameters](#parameters-5) | ||
- [findCryptoCurrencyById](#findcryptocurrencybyid) | ||
- [Parameters](#parameters-5) | ||
- [Parameters](#parameters-6) | ||
- [findCryptoCurrencyByKeyword](#findcryptocurrencybykeyword) | ||
- [Parameters](#parameters-6) | ||
- [Parameters](#parameters-7) | ||
- [hasCryptoCurrencyId](#hascryptocurrencyid) | ||
- [Parameters](#parameters-7) | ||
- [Parameters](#parameters-8) | ||
- [getCryptoCurrencyById](#getcryptocurrencybyid) | ||
- [Parameters](#parameters-8) | ||
- [Parameters](#parameters-9) | ||
- [findExchangeCurrencyConfig](#findexchangecurrencyconfig) | ||
- [Parameters](#parameters-9) | ||
- [Parameters](#parameters-10) | ||
- [hasFiatCurrencyTicker](#hasfiatcurrencyticker) | ||
- [Parameters](#parameters-10) | ||
- [Parameters](#parameters-11) | ||
- [findFiatCurrencyByTicker](#findfiatcurrencybyticker) | ||
- [Parameters](#parameters-11) | ||
- [Parameters](#parameters-12) | ||
- [getFiatCurrencyByTicker](#getfiatcurrencybyticker) | ||
- [Parameters](#parameters-12) | ||
- [Parameters](#parameters-13) | ||
- [listFiatCurrencies](#listfiatcurrencies) | ||
- [listTokens](#listtokens) | ||
- [Parameters](#parameters-13) | ||
- [Parameters](#parameters-14) | ||
- [listTokensForCryptoCurrency](#listtokensforcryptocurrency) | ||
- [Parameters](#parameters-14) | ||
- [Parameters](#parameters-15) | ||
- [listTokenTypesForCryptoCurrency](#listtokentypesforcryptocurrency) | ||
- [Parameters](#parameters-15) | ||
- [Parameters](#parameters-16) | ||
- [findTokenByTicker](#findtokenbyticker) | ||
- [Parameters](#parameters-16) | ||
- [Parameters](#parameters-17) | ||
- [findTokenById](#findtokenbyid) | ||
- [Parameters](#parameters-17) | ||
- [Parameters](#parameters-18) | ||
- [findTokenByAddress](#findtokenbyaddress) | ||
- [Parameters](#parameters-18) | ||
- [Parameters](#parameters-19) | ||
- [hasTokenId](#hastokenid) | ||
- [Parameters](#parameters-19) | ||
- [Parameters](#parameters-20) | ||
- [getTokenById](#gettokenbyid) | ||
- [Parameters](#parameters-20) | ||
- [Parameters](#parameters-21) | ||
- [findCompoundToken](#findcompoundtoken) | ||
- [Parameters](#parameters-21) | ||
- [Parameters](#parameters-22) | ||
- [Unit](#unit) | ||
@@ -107,2 +109,9 @@ - [Properties](#properties) | ||
### registerCryptoCurrency | ||
#### Parameters | ||
- `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `currency` **[CryptoCurrency](#cryptocurrency)** | ||
### listCryptoCurrencies | ||
@@ -109,0 +118,0 @@ |
@@ -2703,2 +2703,14 @@ // @flow | ||
const cryptocurrenciesByScheme: { [_: string]: CryptoCurrency } = {}; | ||
const cryptocurrenciesByTicker: { [_: string]: CryptoCurrency } = {}; | ||
const cryptocurrenciesArray = []; | ||
const prodCryptoArray = []; | ||
const cryptocurrenciesArrayWithoutTerminated = []; | ||
const prodCryptoArrayWithoutTerminated = []; | ||
for (const id in cryptocurrenciesById) { | ||
const definition = cryptocurrenciesById[id]; | ||
registerCryptoCurrency(id, definition); | ||
} | ||
/** | ||
@@ -2721,22 +2733,22 @@ * | ||
const cryptocurrenciesByScheme: { [_: string]: CryptoCurrency } = {}; | ||
const cryptocurrenciesByTicker: { [_: string]: CryptoCurrency } = {}; | ||
const cryptocurrenciesArray = []; | ||
const prodCryptoArray = []; | ||
for (const id in cryptocurrenciesById) { | ||
const c = cryptocurrenciesById[id]; | ||
cryptocurrenciesById[c.id] = c; | ||
cryptocurrenciesByScheme[c.scheme] = c; | ||
if (!c.isTestnetFor) { | ||
cryptocurrenciesByTicker[c.ticker] = c; | ||
prodCryptoArray.push(c); | ||
/** | ||
* | ||
* @param {string} id | ||
* @param {CryptoCurrency} currency | ||
*/ | ||
export function registerCryptoCurrency(id: string, currency: CryptoCurrency) { | ||
cryptocurrenciesById[currency.id] = currency; | ||
cryptocurrenciesByScheme[currency.scheme] = currency; | ||
if (!currency.isTestnetFor) { | ||
cryptocurrenciesByTicker[currency.ticker] = currency; | ||
prodCryptoArray.push(currency); | ||
if (!currency.terminated) { | ||
prodCryptoArrayWithoutTerminated.push(currency); | ||
} | ||
} | ||
cryptocurrenciesArray.push(c); | ||
cryptocurrenciesArray.push(currency); | ||
if (!currency.terminated) { | ||
cryptocurrenciesArrayWithoutTerminated.push(currency); | ||
} | ||
} | ||
const cryptocurrenciesArrayWithoutTerminated = cryptocurrenciesArray.filter( | ||
(c) => !c.terminated | ||
); | ||
const prodCryptoArrayWithoutTerminated = prodCryptoArray.filter( | ||
(c) => !c.terminated | ||
); | ||
@@ -2743,0 +2755,0 @@ /** |
@@ -11,2 +11,8 @@ import { | ||
getCryptoCurrencyById, | ||
findCryptoCurrency, | ||
findCryptoCurrencyById, | ||
findCryptoCurrencyByScheme, | ||
findCryptoCurrencyByTicker, | ||
findCryptoCurrencyByKeyword, | ||
registerCryptoCurrency, | ||
} from "./currencies"; | ||
@@ -30,6 +36,27 @@ | ||
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("there are some dev cryptocurrencies", () => { | ||
const all = listCryptoCurrencies(true); | ||
const prod = listCryptoCurrencies(); | ||
expect(listCryptoCurrencies(false)).toBe(listCryptoCurrencies()); | ||
expect(all).not.toBe(prod); | ||
@@ -40,2 +67,10 @@ expect(all.filter((a) => !a.isTestnetFor)).toMatchObject(prod); | ||
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("all cryptocurrencies match (by reference) the one you get by id", () => { | ||
@@ -48,2 +83,6 @@ for (let c of listCryptoCurrencies()) { | ||
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()) { | ||
@@ -142,1 +181,41 @@ expect(!c.terminated).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); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2561553
16957
345