@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.
- package/LICENSE.md +21 -0
- package/README.md +37 -0
- package/dist/index.cjs.js +3 -0
- package/dist/src/assets/erc20/index.d.ts +10 -0
- package/dist/src/assets/index.d.ts +19 -0
- package/dist/src/assets/native.d.ts +17 -0
- package/dist/src/assets/testnet.d.ts +3 -0
- package/dist/src/chains.d.ts +6 -0
- package/dist/src/common.d.ts +13 -0
- package/dist/src/dapps/index.d.ts +6 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/types.d.ts +43 -0
- package/package.json +84 -0
- package/src/assets/erc20/avalanche-tokens.json +29 -0
- package/src/assets/erc20/ethereum-tokens.json +2221 -0
- package/src/assets/erc20/index.ts +62 -0
- package/src/assets/erc20/polygon-tokens.json +359 -0
- package/src/assets/erc20/rsk-tokens.json +53 -0
- package/src/assets/erc20/terra-tokens.json +640 -0
- package/src/assets/index.ts +14 -0
- package/src/assets/native.ts +143 -0
- package/src/assets/testnet.ts +24 -0
- package/src/base58-js.d.ts +1 -0
- package/src/chains.ts +235 -0
- package/src/common.ts +105 -0
- package/src/dapps/dapps.json +2597 -0
- package/src/dapps/index.ts +10 -0
- package/src/index.ts +29 -0
- package/src/types.ts +47 -0
- package/src/typings/bitcoin-address-validation.d.ts +4 -0
- package/src/typings/cashaddrjs.d.ts +1 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
|
|
7
|
+
function unitToCurrency(asset: Asset, value: number | BigNumber): BigNumber {
|
|
8
|
+
const multiplier = new BigNumber(10).pow(asset.decimals)
|
|
9
|
+
return new BigNumber(value).dividedBy(multiplier)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function currencyToUnit(asset: Asset, value: number | BigNumber): BigNumber {
|
|
13
|
+
const multiplier = new BigNumber(10).pow(asset.decimals)
|
|
14
|
+
return new BigNumber(value).times(multiplier)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
assets,
|
|
19
|
+
chainToTokenAddressMap,
|
|
20
|
+
testnetAssets,
|
|
21
|
+
chainToTestnetTokenAddressMap,
|
|
22
|
+
chains,
|
|
23
|
+
dappChains,
|
|
24
|
+
isEthereumChain,
|
|
25
|
+
unitToCurrency,
|
|
26
|
+
currencyToUnit,
|
|
27
|
+
Asset,
|
|
28
|
+
ChainId
|
|
29
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
|
|
16
|
+
export type AssetType = 'native' | 'erc20'
|
|
17
|
+
|
|
18
|
+
export enum ChainId {
|
|
19
|
+
Bitcoin = 'bitcoin',
|
|
20
|
+
BitcoinCash = 'bitcoin_cash',
|
|
21
|
+
Ethereum = 'ethereum',
|
|
22
|
+
Rootstock = 'rsk',
|
|
23
|
+
BinanceSmartChain = 'bsc',
|
|
24
|
+
Near = 'near',
|
|
25
|
+
Polygon = 'polygon',
|
|
26
|
+
Arbitrum = 'arbitrum',
|
|
27
|
+
Solana = 'solana',
|
|
28
|
+
Fuse = 'fuse',
|
|
29
|
+
Terra = 'terra',
|
|
30
|
+
Avalanche = 'avalanche',
|
|
31
|
+
Yacoin = 'yacoin'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Asset {
|
|
35
|
+
name: string
|
|
36
|
+
chain: ChainId
|
|
37
|
+
type: AssetType
|
|
38
|
+
code: string
|
|
39
|
+
decimals: number
|
|
40
|
+
coinGeckoId?: string
|
|
41
|
+
color?: string
|
|
42
|
+
contractAddress?: string // ERC20 only
|
|
43
|
+
matchingAsset?: string
|
|
44
|
+
feeAsset?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type AssetMap = Record<string, Asset>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'cashaddrjs'
|