-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: implement getAssetNamespaceFromChainId helper (#8677)
- Loading branch information
1 parent
ea74117
commit c03e3b5
Showing
7 changed files
with
48 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { AssetNamespace } from '@shapeshiftoss/caip' | ||
import { ASSET_NAMESPACE } from '@shapeshiftoss/caip' | ||
import { KnownChainIds } from '@shapeshiftoss/types' | ||
|
||
import { assertUnreachable } from './assertUnreachable' | ||
|
||
export const getAssetNamespaceFromChainId = (chainId: KnownChainIds): AssetNamespace => { | ||
switch (chainId) { | ||
case KnownChainIds.BnbSmartChainMainnet: | ||
return ASSET_NAMESPACE.bep20 | ||
case KnownChainIds.SolanaMainnet: | ||
return ASSET_NAMESPACE.splToken | ||
case KnownChainIds.EthereumMainnet: | ||
case KnownChainIds.AvalancheMainnet: | ||
case KnownChainIds.OptimismMainnet: | ||
case KnownChainIds.PolygonMainnet: | ||
case KnownChainIds.GnosisMainnet: | ||
case KnownChainIds.ArbitrumMainnet: | ||
case KnownChainIds.ArbitrumNovaMainnet: | ||
case KnownChainIds.BaseMainnet: | ||
return ASSET_NAMESPACE.erc20 | ||
case KnownChainIds.CosmosMainnet: | ||
case KnownChainIds.ThorchainMainnet: | ||
return ASSET_NAMESPACE.ibc | ||
case KnownChainIds.BitcoinMainnet: | ||
case KnownChainIds.BitcoinCashMainnet: | ||
case KnownChainIds.DogecoinMainnet: | ||
case KnownChainIds.LitecoinMainnet: | ||
throw Error(`Unhandled case '${chainId}'`) | ||
default: | ||
return assertUnreachable(chainId) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters