forked from xchainjs/xchainjs-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.ts
36 lines (33 loc) · 1.22 KB
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { AssetAVAX } from '@xchainjs/xchain-avax'
import { AssetBNB } from '@xchainjs/xchain-binance'
import { AssetBSC } from '@xchainjs/xchain-bsc'
import { AssetATOM } from '@xchainjs/xchain-cosmos'
import { AssetETH } from '@xchainjs/xchain-ethereum'
import { Asset, Chain, eqAsset } from '@xchainjs/xchain-util'
/**
* Check if a chain is EVM and supported by the protocol
* @param {Chain} chain to check
* @returns true if chain is EVM, otherwise, false
*/
export const isProtocolEVMChain = (chain: Chain): boolean => {
return [AssetETH.chain, AssetBSC.chain, AssetAVAX.chain].includes(chain)
}
/**
* Check if asset is ERC20
* @param {Asset} asset to check
* @returns true if asset is ERC20, otherwise, false
*/
export const isProtocolERC20Asset = (asset: Asset): boolean => {
return isProtocolEVMChain(asset.chain)
? [AssetETH, AssetAVAX, AssetBSC].findIndex((nativeEVMAsset) => eqAsset(nativeEVMAsset, asset)) === -1 &&
!asset.synth
: false
}
/**
* Check if a chain is EVM and supported by the protocol
* @param {Chain} chain to check
* @returns true if chain is EVM, otherwise, false
*/
export const isProtocolBFTChain = (chain: Chain): boolean => {
return [AssetBNB.chain, AssetATOM.chain].includes(chain)
}