@yaswap/cryptoassets 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ import { AssetMap } from '../../types';
2
+ declare const erc20Assets: AssetMap;
3
+ declare const testnetErc20Assets: AssetMap;
4
+ declare const chainToTokenAddressMap: {
5
+ [chain: string]: AssetMap;
6
+ };
7
+ declare const chainToTestnetTokenAddressMap: {
8
+ [chain: string]: AssetMap;
9
+ };
10
+ export { erc20Assets, testnetErc20Assets, chainToTokenAddressMap, chainToTestnetTokenAddressMap };
@@ -0,0 +1,19 @@
1
+ import { chainToTokenAddressMap, chainToTestnetTokenAddressMap } from './erc20';
2
+ declare const assets: {
3
+ [x: string]: import("..").Asset;
4
+ };
5
+ declare const testnetAssets: {
6
+ [x: string]: import("..").Asset | (import("..").Asset & {
7
+ name: string;
8
+ chain: import("..").ChainId;
9
+ type: import("../types").AssetType;
10
+ code: string;
11
+ decimals: number;
12
+ coinGeckoId?: string;
13
+ color?: string;
14
+ contractAddress?: string;
15
+ matchingAsset?: string;
16
+ feeAsset?: string;
17
+ });
18
+ };
19
+ export { assets, testnetAssets, chainToTokenAddressMap, chainToTestnetTokenAddressMap };
@@ -0,0 +1,17 @@
1
+ import { AssetMap, ChainId } from '../types';
2
+ declare const nativeAssets: AssetMap;
3
+ declare const testnetNativeAssets: AssetMap & {
4
+ [x: string]: {
5
+ name: string;
6
+ chain: ChainId;
7
+ type: import("../types").AssetType;
8
+ code: string;
9
+ decimals: number;
10
+ coinGeckoId?: string;
11
+ color?: string;
12
+ contractAddress?: string;
13
+ matchingAsset?: string;
14
+ feeAsset?: string;
15
+ };
16
+ };
17
+ export { nativeAssets, testnetNativeAssets };
@@ -0,0 +1,3 @@
1
+ export declare const TESTNET_CONTRACT_ADDRESSES: Record<string, string>;
2
+ export declare const TESTNET_TOKENS: string[];
3
+ export declare const TESTNET_NATIVE: string[];
@@ -0,0 +1,6 @@
1
+ import { Chain, ChainId } from './types';
2
+ declare const chains: {
3
+ [key in ChainId]: Chain;
4
+ };
5
+ declare function isEthereumChain(chain: ChainId): boolean;
6
+ export { chains, isEthereumChain };
@@ -0,0 +1,13 @@
1
+ export declare const isValidHex: (hash: string) => boolean;
2
+ export declare const toLowerCaseWithout0x: (hash: string) => string;
3
+ export declare const with0x: (hash: string) => string;
4
+ export declare const isValidNearAddress: (address: string) => boolean;
5
+ export declare const isValidNearTx: (hash: string) => boolean;
6
+ export declare const isValidBitcoinCashAddress: (address: string) => boolean;
7
+ export declare const formatBitcoinCashAddress: (address: string) => string;
8
+ export declare const isValidYacoinAddress: (address: string) => boolean;
9
+ export declare const isValidSolanaAddress: (address: string) => boolean;
10
+ export declare const isValidSolanaTx: (tx: string) => boolean;
11
+ export declare const isValidTerraAddress: (address: string) => boolean;
12
+ export declare const isValidTerraTx: (tx: string) => boolean;
13
+ export declare const getRSKChainID: (network: string) => 30 | 31;
@@ -0,0 +1,6 @@
1
+ import { ChainId } from '../types';
2
+ interface OriginChains {
3
+ [index: string]: ChainId[];
4
+ }
5
+ declare const dappChains: OriginChains;
6
+ export { dappChains };
@@ -0,0 +1,8 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { assets, testnetAssets, chainToTokenAddressMap, chainToTestnetTokenAddressMap } from './assets';
3
+ import { chains, isEthereumChain } from './chains';
4
+ import { dappChains } from './dapps';
5
+ import { Asset, ChainId } from './types';
6
+ declare function unitToCurrency(asset: Asset, value: number | BigNumber): BigNumber;
7
+ declare function currencyToUnit(asset: Asset, value: number | BigNumber): BigNumber;
8
+ export { assets, chainToTokenAddressMap, testnetAssets, chainToTestnetTokenAddressMap, chains, dappChains, isEthereumChain, unitToCurrency, currencyToUnit, Asset, ChainId };
@@ -0,0 +1,43 @@
1
+ export interface Chain {
2
+ name: string;
3
+ code: string;
4
+ nativeAsset: string;
5
+ fees: {
6
+ unit: string;
7
+ };
8
+ safeConfirmations: number;
9
+ txFailureTimeout: number;
10
+ isValidAddress: (address: string, network?: string) => boolean;
11
+ formatAddress: (address: string, network?: string) => string;
12
+ isValidTransactionHash: (hash: string) => boolean;
13
+ formatTransactionHash: (hash: string) => string;
14
+ }
15
+ export declare type AssetType = 'native' | 'erc20';
16
+ export declare enum ChainId {
17
+ Bitcoin = "bitcoin",
18
+ BitcoinCash = "bitcoin_cash",
19
+ Ethereum = "ethereum",
20
+ Rootstock = "rsk",
21
+ BinanceSmartChain = "bsc",
22
+ Near = "near",
23
+ Polygon = "polygon",
24
+ Arbitrum = "arbitrum",
25
+ Solana = "solana",
26
+ Fuse = "fuse",
27
+ Terra = "terra",
28
+ Avalanche = "avalanche",
29
+ Yacoin = "yacoin"
30
+ }
31
+ export interface Asset {
32
+ name: string;
33
+ chain: ChainId;
34
+ type: AssetType;
35
+ code: string;
36
+ decimals: number;
37
+ coinGeckoId?: string;
38
+ color?: string;
39
+ contractAddress?: string;
40
+ matchingAsset?: string;
41
+ feeAsset?: string;
42
+ }
43
+ export declare type AssetMap = Record<string, Asset>;
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@yaswap/cryptoassets",
3
+ "version": "1.0.0",
4
+ "keywords": [
5
+ "blockchain",
6
+ "crypto",
7
+ "cryptocurrency",
8
+ "cryptocurrencies",
9
+ "cryptoassets"
10
+ ],
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+ssh://git@github.com/yaswap/cryptoassets.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/yaswap/cryptoassets/issues"
18
+ },
19
+ "homepage": "https://github.com/yaswap/cryptoassets#readme",
20
+ "author": "Liquality <info@liquality.io>",
21
+ "module": "src/index.js",
22
+ "main": "dist/index.cjs.js",
23
+ "types": "dist/src/index.d.ts",
24
+ "files": [
25
+ "dist/index.umd.js",
26
+ "dist/src/**/*",
27
+ "src/**/*"
28
+ ],
29
+ "scripts": {
30
+ "prettier": "prettier --write --ignore .gitignore .",
31
+ "lint": "eslint . $npm_package_options_eslint",
32
+ "test": "cross-env NODE_ENV=test TS_NODE_FILES=true nyc mocha -r ts-node/register --recursive ./tests/**/*.test.ts",
33
+ "build": "cross-env NODE_ENV=production webpack --config webpack.config.js",
34
+ "updateErc20": "node scripts/updateERC20.js",
35
+ "prepublishOnly": "npm run build"
36
+ },
37
+ "options": {
38
+ "eslint": "--ext .jsx,.ts,.tsx"
39
+ },
40
+ "dependencies": {
41
+ "base58-js": "^1.0.0",
42
+ "bignumber.js": "^9.0.2",
43
+ "bitcoin-address-validation": "^2.2.1",
44
+ "bs58": "^4.0.1",
45
+ "cashaddrjs": "^0.4.4",
46
+ "ethereumjs-util": "^7.1.4",
47
+ "lodash": "^4.17.11",
48
+ "sha256-uint8array": "^0.10.3"
49
+ },
50
+ "devDependencies": {
51
+ "@types/bs58": "^4.0.1",
52
+ "@types/chai": "4.3.0",
53
+ "@types/lodash": "4.14.178",
54
+ "@types/mocha": "9.1.0",
55
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
56
+ "@typescript-eslint/parser": "^4.33.0",
57
+ "axios": "^0.25.0",
58
+ "chai": "^4.3.6",
59
+ "copy": "^0.3.2",
60
+ "cross-env": "^7.0.3",
61
+ "eslint": "^7.32.0",
62
+ "eslint-config-prettier": "^8.3.0",
63
+ "eslint-plugin-prettier": "^3.4.1",
64
+ "mocha": "^9.2.0",
65
+ "npm-run-all": "^4.1.3",
66
+ "nyc": "^15.1.0",
67
+ "pre-commit": "^1.2.2",
68
+ "prettier": "^2.5.1",
69
+ "should": "^13.2.1",
70
+ "ts-loader": "^9.0.0",
71
+ "ts-node": "^9.1.1",
72
+ "typescript": "^4.5.5",
73
+ "webpack": "^5.68.0",
74
+ "webpack-cli": "^4.9.2"
75
+ },
76
+ "pre-commit": [
77
+ "lint",
78
+ "build"
79
+ ],
80
+ "publishConfig": {
81
+ "access": "public"
82
+ },
83
+ "sideEffects": false
84
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "WBTC.e": {
3
+ "name": "Avax Wrapped Bitcoin",
4
+ "code": "WBTC",
5
+ "decimals": 8,
6
+ "contractAddress": "0x50b7545627a5162f82a992c33b87adc75187b218",
7
+ "color": "#5b3159",
8
+ "coinGeckoId": "wrapped-bitcoin",
9
+ "matchingAsset": "WBTC"
10
+ },
11
+ "USDC.e": {
12
+ "name": "Avax USD Coin",
13
+ "code": "USDC",
14
+ "decimals": 6,
15
+ "contractAddress": "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664",
16
+ "color": "#5b31b9",
17
+ "coinGeckoId": "usd-coin",
18
+ "matchingAsset": "USDC"
19
+ },
20
+ "USDT.e": {
21
+ "name": "Avax Tether USD",
22
+ "code": "USDT",
23
+ "decimals": 6,
24
+ "contractAddress": "0xc7198437980c041c805a1edcba50c1ce5db95118",
25
+ "color": "#5b31f9",
26
+ "coinGeckoId": "tether",
27
+ "matchingAsset": "USDT"
28
+ }
29
+ }