@rosen-bridge/tokens
Advanced tools
Comparing version 0.1.4 to 0.1.5
export { TokenMap } from "./TokenMap/TokenMap"; | ||
export { RosenTokens } from "./TokenMap/types"; |
@@ -1,2 +0,2 @@ | ||
import { TokensMap } from "./types"; | ||
import { RosenTokens } from "./types"; | ||
/** | ||
@@ -12,3 +12,3 @@ * TokenMap class searches for different assets properties in different chains | ||
*/ | ||
constructor(tokens?: TokensMap); | ||
constructor(tokens: RosenTokens); | ||
/** | ||
@@ -28,2 +28,24 @@ * it returns specific token with respect to condition on the specific chain | ||
}[]; | ||
/** | ||
* returns tokenId in specific chain with respect to idKeys in the tokensConfig | ||
* @param token | ||
* example: { | ||
* "ergo": { | ||
* "tokenID": "tokenId", | ||
* "tokenName": "token1" | ||
* }, | ||
* "cardano": { | ||
* "fingerprint": "...", | ||
* "policyID": "policy", | ||
* "assetID": "id" | ||
* } | ||
* } | ||
* @param chain | ||
* example: "cardano" | ||
*/ | ||
getID: (token: { | ||
[key: string]: { | ||
[key: string]: string; | ||
}; | ||
}, chain: string) => string; | ||
} |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TokenMap = void 0; | ||
const tokensList_json_1 = __importDefault(require("../tokensList/tokensList.json")); | ||
/** | ||
@@ -18,3 +14,3 @@ * TokenMap class searches for different assets properties in different chains | ||
*/ | ||
constructor(tokens = tokensList_json_1.default) { | ||
constructor(tokens) { | ||
this.tokensConfig = tokens; | ||
@@ -45,3 +41,29 @@ } | ||
}; | ||
/** | ||
* returns tokenId in specific chain with respect to idKeys in the tokensConfig | ||
* @param token | ||
* example: { | ||
* "ergo": { | ||
* "tokenID": "tokenId", | ||
* "tokenName": "token1" | ||
* }, | ||
* "cardano": { | ||
* "fingerprint": "...", | ||
* "policyID": "policy", | ||
* "assetID": "id" | ||
* } | ||
* } | ||
* @param chain | ||
* example: "cardano" | ||
*/ | ||
getID = (token, chain) => { | ||
if (Object.hasOwnProperty.call(this.tokensConfig.idKeys, chain)) { | ||
const idKey = this.tokensConfig.idKeys[chain]; | ||
return token[chain][idKey]; | ||
} | ||
else { | ||
throw new Error(`idKey of the ${chain} chain is missed in the config file`); | ||
} | ||
}; | ||
} | ||
exports.TokenMap = TokenMap; |
@@ -1,2 +0,5 @@ | ||
export declare type TokensMap = { | ||
export declare type RosenTokens = { | ||
idKeys: { | ||
[key: string]: string; | ||
}; | ||
tokens: Array<{ | ||
@@ -3,0 +6,0 @@ [key: string]: { |
{ | ||
"idKeys": { | ||
"ergo": "tokenID", | ||
"cardano": "fingerprint" | ||
}, | ||
"tokens": [ | ||
@@ -3,0 +7,0 @@ { |
{ | ||
"name": "@rosen-bridge/tokens", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "this project manage supported tokens", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
16795
12
276
1