diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d147e0..d268c97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +# [1.1.0](https://github.com/erdDEVcode/utils/compare/v1.0.2...v1.1.0) (2020-11-16) + ## [1.0.2](https://github.com/erdDEVcode/utils/compare/v1.0.1...v1.0.2) (2020-11-16) diff --git a/README.md b/README.md index b6c1791..fe6fbba 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ All predefined token and network metadata are in [`tokens.json`](https://github. This data gets loaded in and exposed via the `Data` export: ```js -import Data from 'elrond-utils' +import { data } 'elrond-utils' -const tokenData = Data.getToken('xegld') +const tokenData = data.getToken('xegld') console.log(JSON.stringify(tokenData, null, 2)) /* diff --git a/package-lock.json b/package-lock.json index b01853f..81a8183 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "elrond-utils", - "version": "1.0.2", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9c16139..87f8531 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "elrond-utils", - "version": "1.0.2", + "version": "1.1.0", "description": "Utilities and data for building with Elrond.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", @@ -36,7 +36,7 @@ "build-data": "mkdir -p ./dist/data && cp ./data/* ./dist/data", "build": "npm run build-data && tsc && tsc -p tsconfig-esm.json", "dev": "npm run build-data && tsc --watch", - "build-docs": "rm -rf ./docs && typedoc --out docs", + "build-docs": "rm -rf ./docs && typedoc", "publish-docs": "npm run build-docs && gh-pages -d docs", "prepublishOnly": "npm run build", "postpublish": "npm run publish-docs", diff --git a/src/index.ts b/src/index.ts index 040ed9b..4638cd6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,13 @@ import { NetworkMetadata, NetworkMetadataMap, Token, TokenMap } from './types' + +/** + * @internal + */ const networks = require('../data/networks.json') + +/** + * @internal + */ const tokens = require('../data/tokens.json') export * from './types' @@ -7,7 +15,7 @@ export * from './types' /** * Predefined data. */ -class Data { +export class Data { protected _tokens: TokenMap = {} protected _networks: NetworkMetadataMap = {} @@ -67,4 +75,4 @@ class Data { /** * Singleton instance. */ -export default new Data() \ No newline at end of file +export const data = new Data() \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 63fb59f..1310520 100644 --- a/src/types.ts +++ b/src/types.ts @@ -78,13 +78,40 @@ export interface PromiseResolver { * This reflects the data structures inside the `tokens.json` data file. */ export interface Token { + /** + * Token id. + */ id: string, + /** + * No. of digits to the right of the decimal point in the standard unit of this token. + * + * For example, for eGLD the value should be 18. This also means the smallest unit of + * denomination is 1 / 10^18. + */ decimals: number, + /** + * The display-friendly symbol. + */ symbol: string, - symbolFormatting?: string, + /** + * Display-friendly name. + */ name: string, + /** + * How the symbol should be formatted. + * + * This is specified as a string template utilising {value} and {symbol} + * + * Default is `{value} {symbol}`. + */ + symbolFormatting?: string, + /** + * The id to use for this token when fetching its exchange rate from Coingecko. + */ rateApiName?: string, - rateMultiplier?: number + /** + * Either path to or a Base64-encoded string for an image representing the token. + */ img?: string, } diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 0000000..23b88d3 --- /dev/null +++ b/typedoc.json @@ -0,0 +1,10 @@ +{ + "inputFiles": [ + "./src" + ], + "excludeProtected": true, + "stripInternal": true, + "theme": "minimal", + "mode": "file", + "out": "docs" +} \ No newline at end of file