Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add arbitrum #5337

Merged
merged 20 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.app
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ REACT_APP_UNCHAINED_POLYGON_HTTP_URL=https://api.polygon.shapeshift.com
REACT_APP_UNCHAINED_POLYGON_WS_URL=wss://api.polygon.shapeshift.com
REACT_APP_UNCHAINED_GNOSIS_HTTP_URL=https://api.gnosis.shapeshift.com
REACT_APP_UNCHAINED_GNOSIS_WS_URL=wss://api.gnosis.shapeshift.com
REACT_APP_UNCHAINED_ARBITRUM_HTTP_URL=https://api.arbitrum.shapeshift.com
REACT_APP_UNCHAINED_ARBITRUM_WS_URL=wss://api.arbitrum.shapeshift.com
REACT_APP_UNCHAINED_BITCOIN_HTTP_URL=https://api.bitcoin.shapeshift.com
REACT_APP_UNCHAINED_BITCOIN_WS_URL=wss://api.bitcoin.shapeshift.com
REACT_APP_UNCHAINED_DOGECOIN_WS_URL=wss://api.dogecoin.shapeshift.com
Expand All @@ -38,6 +40,7 @@ REACT_APP_OPTIMISM_NODE_URL=https://daemon.optimism.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://daemon.bnbsmartchain.shapeshift.com
REACT_APP_POLYGON_NODE_URL=https://daemon.polygon.shapeshift.com
REACT_APP_GNOSIS_NODE_URL=https://daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://daemon.arbitrum.shapeshift.com
REACT_APP_COSMOS_NODE_URL=https://daemon.cosmos.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://daemon.thorchain.shapeshift.com

Expand Down
2 changes: 2 additions & 0 deletions .env.base
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ REACT_APP_FEATURE_AXELAR=false
REACT_APP_FEATURE_BNBSMARTCHAIN=true
REACT_APP_FEATURE_POLYGON=true
REACT_APP_FEATURE_GNOSIS=true
REACT_APP_FEATURE_ARBITRUM=false
REACT_APP_FEATURE_JAYPEGZ=true
REACT_APP_FEATURE_DASHBOARD_TABS=true
REACT_APP_FEATURE_DEFI_DASHBOARD=true
Expand Down Expand Up @@ -83,6 +84,7 @@ REACT_APP_ALCHEMY_API_KEY=3DnVf4ZoxBk0W0TZcipqAhmATm7uc1vE
REACT_APP_ALCHEMY_POLYGON_JAYPEGS_API_KEY=OqVQS8M_NzYeV--9xHZjKEIscrZOADzp
REACT_APP_ALCHEMY_ETHEREUM_JAYPEGS_API_KEY=yh6GF21GaU8wlvEB4wYp7ssXhCU76gOx
REACT_APP_ALCHEMY_OPTIMISM_JAYPEGS_API_KEY=K03vX5rMZeGmF2V9U-SCsrCeeVnr8qmO

# Base URLs for NFTs - to be used with the REST endpoints above.
# SDK usage is usually preferred, but not all endoints have SDK wrappers around them.
REACT_APP_ALCHEMY_POLYGON_JAYPEGS_BASE_URL=https://polygon-mainnet.g.alchemy.com/nft/v2
Expand Down
4 changes: 4 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# feature flags
REACT_APP_FEATURE_NFT_METADATA=true
REACT_APP_FEATURE_ARBITRUM=true

# logging
REACT_APP_REDUX_WINDOW=false
Expand All @@ -20,6 +21,8 @@ REACT_APP_UNCHAINED_POLYGON_HTTP_URL=https://dev-api.polygon.shapeshift.com
REACT_APP_UNCHAINED_POLYGON_WS_URL=wss://dev-api.polygon.shapeshift.com
REACT_APP_UNCHAINED_GNOSIS_HTTP_URL=https://dev-api.gnosis.shapeshift.com
REACT_APP_UNCHAINED_GNOSIS_WS_URL=wss://dev-api.gnosis.shapeshift.com
REACT_APP_UNCHAINED_ARBITRUM_HTTP_URL=https://dev-api.arbitrum.shapeshift.com
REACT_APP_UNCHAINED_ARBITRUM_WS_URL=wss://dev-api.arbitrum.shapeshift.com
REACT_APP_UNCHAINED_BITCOIN_HTTP_URL=https://dev-api.bitcoin.shapeshift.com
REACT_APP_UNCHAINED_BITCOIN_WS_URL=wss://dev-api.bitcoin.shapeshift.com
REACT_APP_UNCHAINED_DOGECOIN_WS_URL=wss://dev-api.dogecoin.shapeshift.com
Expand All @@ -41,6 +44,7 @@ REACT_APP_OPTIMISM_NODE_URL=https://dev-daemon.optimism.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://dev-daemon.bnbsmartchain.shapeshift.com
REACT_APP_POLYGON_NODE_URL=https://dev-daemon.polygon.shapeshift.com
REACT_APP_GNOSIS_NODE_URL=https://dev-daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://dev-daemon.arbitrum.shapeshift.com
REACT_APP_COSMOS_NODE_URL=https://dev-daemon.cosmos.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://dev-daemon.thorchain.shapeshift.com

Expand Down
4 changes: 4 additions & 0 deletions .env.develop
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# feature flags
REACT_APP_FEATURE_NFT_METADATA=true
REACT_APP_FEATURE_CHATWOOT=true
REACT_APP_FEATURE_ARBITRUM=true

# mixpanel
REACT_APP_MIXPANEL_TOKEN=1c1369f6ea23a6404bac41b42817cc4b
Expand All @@ -18,6 +19,8 @@ REACT_APP_UNCHAINED_POLYGON_HTTP_URL=https://dev-api.polygon.shapeshift.com
REACT_APP_UNCHAINED_POLYGON_WS_URL=wss://dev-api.polygon.shapeshift.com
REACT_APP_UNCHAINED_GNOSIS_HTTP_URL=https://dev-api.gnosis.shapeshift.com
REACT_APP_UNCHAINED_GNOSIS_WS_URL=wss://dev-api.gnosis.shapeshift.com
REACT_APP_UNCHAINED_ARBITRUM_HTTP_URL=https://dev-api.arbitrum.shapeshift.com
REACT_APP_UNCHAINED_ARBITRUM_WS_URL=wss://dev-api.arbitrum.shapeshift.com
REACT_APP_UNCHAINED_BITCOIN_HTTP_URL=https://dev-api.bitcoin.shapeshift.com
REACT_APP_UNCHAINED_BITCOIN_WS_URL=wss://dev-api.bitcoin.shapeshift.com
REACT_APP_UNCHAINED_DOGECOIN_WS_URL=wss://dev-api.dogecoin.shapeshift.com
Expand All @@ -39,6 +42,7 @@ REACT_APP_OPTIMISM_NODE_URL=https://dev-daemon.optimism.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://dev-daemon.bnbsmartchain.shapeshift.com
REACT_APP_POLYGON_NODE_URL=https://dev-daemon.polygon.shapeshift.com
REACT_APP_GNOSIS_NODE_URL=https://dev-daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://dev-daemon.arbitrum.shapeshift.com
REACT_APP_COSMOS_NODE_URL=https://dev-daemon.cosmos.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://dev-daemon.thorchain.shapeshift.com

Expand Down
3 changes: 3 additions & 0 deletions .env.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ REACT_APP_UNCHAINED_POLYGON_HTTP_URL=https://api.polygon.shapeshift.com
REACT_APP_UNCHAINED_POLYGON_WS_URL=wss://api.polygon.shapeshift.com
REACT_APP_UNCHAINED_GNOSIS_HTTP_URL=https://dev-api.gnosis.shapeshift.com
REACT_APP_UNCHAINED_GNOSIS_WS_URL=wss://dev-api.gnosis.shapeshift.com
REACT_APP_UNCHAINED_ARBITRUM_HTTP_URL=https://dev-api.arbitrum.shapeshift.com
REACT_APP_UNCHAINED_ARBITRUM_WS_URL=wss://dev-api.arbitrum.shapeshift.com
REACT_APP_UNCHAINED_BITCOIN_HTTP_URL=https://dev-api.bitcoin.shapeshift.com
REACT_APP_UNCHAINED_BITCOIN_WS_URL=wss://dev-api.bitcoin.shapeshift.com
REACT_APP_UNCHAINED_DOGECOIN_WS_URL=wss://dev-api.dogecoin.shapeshift.com
Expand All @@ -35,6 +37,7 @@ REACT_APP_OPTIMISM_NODE_URL=https://dev-daemon.optimism.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://dev-daemon.bnbsmartchain.shapeshift.com
REACT_APP_POLYGON_NODE_URL=https://dev-daemon.polygon.shapeshift.com
REACT_APP_GNOSIS_NODE_URL=https://dev-daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://dev-daemon.arbitrum.shapeshift.com
REACT_APP_COSMOS_NODE_URL=https://dev-daemon.cosmos.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://dev-daemon.thorchain.shapeshift.com

Expand Down
3 changes: 3 additions & 0 deletions .env.private
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ REACT_APP_UNCHAINED_POLYGON_HTTP_URL=https://api.polygon.shapeshift.com
REACT_APP_UNCHAINED_POLYGON_WS_URL=wss://api.polygon.shapeshift.com
REACT_APP_UNCHAINED_GNOSIS_HTTP_URL=https://api.gnosis.shapeshift.com
REACT_APP_UNCHAINED_GNOSIS_WS_URL=wss://api.gnosis.shapeshift.com
REACT_APP_UNCHAINED_ARBITRUM_HTTP_URL=https://api.arbitrum.shapeshift.com
REACT_APP_UNCHAINED_ARBITRUM_WS_URL=wss://api.arbitrum.shapeshift.com
REACT_APP_UNCHAINED_BITCOIN_HTTP_URL=https://api.bitcoin.shapeshift.com
REACT_APP_UNCHAINED_BITCOIN_WS_URL=wss://api.bitcoin.shapeshift.com
REACT_APP_UNCHAINED_DOGECOIN_WS_URL=wss://api.dogecoin.shapeshift.com
Expand All @@ -36,6 +38,7 @@ REACT_APP_OPTIMISM_NODE_URL=https://daemon.optimism.shapeshift.com
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://daemon.bnbsmartchain.shapeshift.com
REACT_APP_POLYGON_NODE_URL=https://daemon.polygon.shapeshift.com
REACT_APP_GNOSIS_NODE_URL=https://daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://daemon.arbitrum.shapeshift.com
REACT_APP_COSMOS_NODE_URL=https://daemon.cosmos.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://daemon.thorchain.shapeshift.com

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"eip155:42161/slip44:60":"ethereum"}
kaladinlight marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion packages/caip/src/adapters/coingecko/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export enum CoingeckoAssetPlatform {
Thorchain = 'thorchain',
Optimism = 'optimistic-ethereum',
BnbSmartChain = 'binance-smart-chain',
Arbitrum = 'arbitrum-one',
}

type CoinGeckoId = string

// markets.shapeshift.com is a coingecko proxy maintained by the fox foundation
export const coingeckoBaseUrl = 'https://markets.shapeshift.com/api/v3'
// export const coingeckoBaseUrl = 'http://localhost:1137/api/v3'
export const coingeckoProBaseUrl = coingeckoBaseUrl
export const coingeckoUrl = `${coingeckoBaseUrl}/coins/list?include_platform=true`

Expand Down Expand Up @@ -63,6 +63,8 @@ export const chainIdToCoingeckoAssetPlatform = (chainId: ChainId): string => {
return CoingeckoAssetPlatform.Polygon
case CHAIN_REFERENCE.GnosisMainnet:
return CoingeckoAssetPlatform.Gnosis
case CHAIN_REFERENCE.ArbitrumMainnet:
return CoingeckoAssetPlatform.Arbitrum
default:
throw new Error(
`chainNamespace ${chainNamespace}, chainReference ${chainReference} not supported.`,
Expand Down
18 changes: 18 additions & 0 deletions packages/caip/src/adapters/coingecko/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { AssetId } from '../../assetId/assetId'
import { toAssetId } from '../../assetId/assetId'
import type { ChainId } from '../../chainId/chainId'
import {
arbitrumAssetId,
arbitrumChainId,
avalancheAssetId,
avalancheChainId,
bchChainId,
Expand Down Expand Up @@ -132,6 +134,20 @@ export const parseData = (coins: CoingeckoCoin[]): AssetMap => {
}
}

if (Object.keys(platforms).includes(CoingeckoAssetPlatform.Arbitrum)) {
try {
const assetId = toAssetId({
chainNamespace: CHAIN_NAMESPACE.Evm,
chainReference: CHAIN_REFERENCE.ArbitrumMainnet,
assetNamespace: 'erc20',
assetReference: platforms[CoingeckoAssetPlatform.Arbitrum],
})
prev[gnosisChainId][assetId] = id
} catch (err) {
// unable to create assetId, skip token
}
}

return prev
},
{
Expand All @@ -141,6 +157,7 @@ export const parseData = (coins: CoingeckoCoin[]): AssetMap => {
[bscChainId]: { [bscAssetId]: 'binancecoin' },
[polygonChainId]: { [polygonAssetId]: 'matic-network' },
[gnosisChainId]: { [gnosisAssetId]: 'xdai' },
[arbitrumChainId]: { [arbitrumAssetId]: 'ethereum' },
},
)

Expand All @@ -159,6 +176,7 @@ export const writeFiles = async (data: AssetMap) => {
await Promise.all(
Object.entries(data).map(async ([chainId, assets]) => {
const dirPath = `./src/adapters/coingecko/generated/${chainId}`.replace(':', '_')
await fs.promises.mkdir(dirPath, { recursive: true })
await fs.promises.writeFile(`${dirPath}/adapter.json`, JSON.stringify(assets))
}),
)
Expand Down
7 changes: 7 additions & 0 deletions packages/caip/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const optimismAssetId: AssetId = 'eip155:10/slip44:60'
export const bscAssetId: AssetId = 'eip155:56/slip44:60'
export const polygonAssetId: AssetId = 'eip155:137/slip44:60'
export const gnosisAssetId: AssetId = 'eip155:100/slip44:60'
export const arbitrumAssetId: AssetId = 'eip155:42161/slip44:60'

export const foxOnGnosisAssetId: AssetId =
'eip155:100/erc20:0x21a42669643f45bc0e086b8fc2ed70c23d67509d'
export const foxAssetId: AssetId = 'eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d'
Expand All @@ -37,6 +39,7 @@ export const optimismChainId: ChainId = 'eip155:10'
export const bscChainId: ChainId = 'eip155:56'
export const polygonChainId: ChainId = 'eip155:137'
export const gnosisChainId: ChainId = 'eip155:100'
export const arbitrumChainId: ChainId = 'eip155:42161'

export const cosmosChainId: ChainId = 'cosmos:cosmoshub-4'
export const thorchainChainId: ChainId = 'cosmos:thorchain-mainnet-v1'
Expand Down Expand Up @@ -83,6 +86,7 @@ export const CHAIN_REFERENCE = {
BnbSmartChainMainnet: '56', // https://docs.bnbchain.org/docs/wallet_api/#chain-ids
PolygonMainnet: '137', // https://wiki.polygon.technology/docs/develop/metamask/config-polygon-on-metamask/
GnosisMainnet: '100', // https://docs.gnosischain.com/tools/wallets/metamask/
ArbitrumMainnet: '42161', // https://chainlist.org/chain/42161
} as const

export const ASSET_NAMESPACE = {
Expand Down Expand Up @@ -116,6 +120,7 @@ export const ASSET_REFERENCE = {
BnbSmartChain: '60', // evm chain which uses ethereum derivation path as common practice
Polygon: '60', // evm chain which uses ethereum derivation path as common practice
Gnosis: '60', // evm chain which uses ethereum derivation path as common practice
Arbitrum: '60', // evm chain which uses ethereum derivation path as common practice
} as const

export const VALID_CHAIN_IDS: ValidChainMap = Object.freeze({
Expand All @@ -135,6 +140,7 @@ export const VALID_CHAIN_IDS: ValidChainMap = Object.freeze({
CHAIN_REFERENCE.BnbSmartChainMainnet,
CHAIN_REFERENCE.PolygonMainnet,
CHAIN_REFERENCE.GnosisMainnet,
CHAIN_REFERENCE.ArbitrumMainnet,
],
[CHAIN_NAMESPACE.CosmosSdk]: [
CHAIN_REFERENCE.CosmosHubMainnet,
Expand Down Expand Up @@ -185,4 +191,5 @@ export const FEE_ASSET_IDS = [
bscAssetId,
polygonAssetId,
gnosisAssetId,
arbitrumAssetId,
]
12 changes: 11 additions & 1 deletion packages/chain-adapters/src/evm/EvmBaseAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
HDWallet,
} from '@shapeshiftoss/hdwallet-core'
import {
supportsArbitrum,
supportsAvalanche,
supportsBSC,
supportsETH,
Expand Down Expand Up @@ -46,7 +47,7 @@ import type {
import { ValidAddressResultType } from '../types'
import { getAssetNamespace, toAddressNList, toRootDerivationPath } from '../utils'
import { bnOrZero } from '../utils/bignumber'
import type { avalanche, bnbsmartchain, ethereum, gnosis, optimism, polygon } from '.'
import type { arbitrum, avalanche, bnbsmartchain, ethereum, gnosis, optimism, polygon } from '.'
import type {
BuildCustomApiTxInput,
BuildCustomTxInput,
Expand All @@ -63,6 +64,7 @@ export const evmChainIds = [
KnownChainIds.BnbSmartChainMainnet,
KnownChainIds.PolygonMainnet,
KnownChainIds.GnosisMainnet,
KnownChainIds.ArbitrumMainnet,
] as const

export type EvmChainId = (typeof evmChainIds)[number]
Expand All @@ -74,6 +76,7 @@ export type EvmChainAdapter =
| bnbsmartchain.ChainAdapter
| polygon.ChainAdapter
| gnosis.ChainAdapter
| arbitrum.ChainAdapter

export const isEvmChainId = (
maybeEvmChainId: string | EvmChainId,
Expand Down Expand Up @@ -159,6 +162,8 @@ export abstract class EvmBaseAdapter<T extends EvmChainId> implements IChainAdap
return supportsPolygon(wallet)
case Number(fromChainId(KnownChainIds.GnosisMainnet).chainReference):
return supportsGnosis(wallet)
case Number(fromChainId(KnownChainIds.ArbitrumMainnet).chainReference):
return supportsArbitrum(wallet)
default:
return false
}
Expand Down Expand Up @@ -212,6 +217,11 @@ export abstract class EvmBaseAdapter<T extends EvmChainId> implements IChainAdap
symbol: 'ETH',
explorer: 'https://optimistic.etherscan.io',
},
[KnownChainIds.ArbitrumMainnet]: {
name: 'Ethereum',
symbol: 'ETH',
explorer: 'https://arbiscan.io',
},
}[this.chainId]

await wallet.ethSwitchChain({
Expand Down
Loading