Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat_phantom_wire_up
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Sep 20, 2024
2 parents b260f73 + 2b679a1 commit e117f2e
Show file tree
Hide file tree
Showing 71 changed files with 6,385 additions and 6,781 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,10 @@ jobs:
- name: Build Packages
run: yarn build:packages

- name: Generate CAIP adapters
run: yarn generate:caip-adapters

- name: Generate color map
run: yarn run generate:color-map

- name: Generate asset data
- name: Generate all assets
env:
ZERION_API_KEY: ${{ secrets.ZERION_API_KEY }}
run: yarn run generate:asset-data

- name: Generate THOR assets
run: yarn run generate:thor-asset-map

- name: Generate THOR long-tail assets
run: yarn run generate:thor-longtail-tokens
run: yarn run generate:all

- name: Create new feature branch
run: git checkout -B feat_regenerate_asset_data
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"dev:web:linked": "GENERATE_SOURCEMAP=false BROWSER=none yarn dev:web",
"dev:packages": "yarn tsc --build --watch --preserveWatchOutput tsconfig.packages.json",
"env": "yarn tsx ./scripts/bootstrap-env.ts",
"generate:all": "yarn generate:caip-adapters && yarn run generate:color-map && yarn run generate:asset-data && yarn run generate:thor-asset-map && yarn run generate:thor-longtail-tokens",
"generate:caip-adapters": "yarn workspace @shapeshiftoss/caip generate",
"generate:asset-data": "yarn tsx ./scripts/generateAssetData/generateAssetData.ts && yarn run codemod:clear-assets-migration",
"generate:related-asset-index": "yarn tsx ./scripts/generateAssetData/generateRelatedAssetIndex.ts && yarn run codemod:clear-assets-migration",
Expand Down Expand Up @@ -137,7 +138,7 @@
"chakra-ui-steps": "^1.7.3",
"crypto-browserify": "^3.12.0",
"dayjs": "^1.11.3",
"dompurify": "^2.5.4",
"dompurify": "^2.3.8",
"embla-carousel-auto-height": "^7.0.9",
"embla-carousel-autoplay": "^7.0.5",
"embla-carousel-react": "^7.0.5",
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.

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions packages/utils/src/evmChainIds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { EvmChainId } from '@shapeshiftoss/types'
import { KnownChainIds } from '@shapeshiftoss/types'

export const isEvmChainId = (
maybeEvmChainId: string | EvmChainId,
): maybeEvmChainId is EvmChainId => {
return evmChainIds.includes(maybeEvmChainId as EvmChainId)
}

export const evmChainIds = [
KnownChainIds.EthereumMainnet,
KnownChainIds.AvalancheMainnet,
KnownChainIds.OptimismMainnet,
KnownChainIds.BnbSmartChainMainnet,
KnownChainIds.PolygonMainnet,
KnownChainIds.GnosisMainnet,
KnownChainIds.ArbitrumMainnet,
KnownChainIds.ArbitrumNovaMainnet,
KnownChainIds.BaseMainnet,
] as const
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './promises'
export * from './treasury'
export * from './timeout'
export * from './createThrottle'
export * from './evmChainIds'

export const isSome = <T>(option: T | null | undefined): option is T =>
!isUndefined(option) && !isNull(option)
4 changes: 2 additions & 2 deletions scripts/generateAssetData/arbitrum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { arbitrumChainId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import partition from 'lodash/partition'
import uniqBy from 'lodash/uniqBy'
import { getPortalTokens } from 'lib/portals/utils'

import { arbitrum } from '../baseAssets'
import * as coingecko from '../coingecko'
import { getPortalTokens } from '../utils/portals'

export const getAssets = async (): Promise<Asset[]> => {
const results = await Promise.allSettled([
coingecko.getAssets(arbitrumChainId),
getPortalTokens(arbitrum),
getPortalTokens(arbitrum, 'all'),
])
const [assets, _portalsAssets] = results.map(result => {
if (result.status === 'fulfilled') return result.value
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateAssetData/avalanche/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { avalancheChainId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import partition from 'lodash/partition'
import uniqBy from 'lodash/uniqBy'
import { getPortalTokens } from 'lib/portals/utils'

import { avax } from '../baseAssets'
import * as coingecko from '../coingecko'
import { getPortalTokens } from '../utils/portals'

export const getAssets = async (): Promise<Asset[]> => {
const results = await Promise.allSettled([
coingecko.getAssets(avalancheChainId),
getPortalTokens(avax),
getPortalTokens(avax, 'all'),
])

const [assets, _portalsAssets] = results.map(result => {
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateAssetData/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { baseChainId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import partition from 'lodash/partition'
import uniqBy from 'lodash/uniqBy'
import { getPortalTokens } from 'lib/portals/utils'

import { base } from '../baseAssets'
import * as coingecko from '../coingecko'
import { getPortalTokens } from '../utils/portals'

export const getAssets = async (): Promise<Asset[]> => {
const results = await Promise.allSettled([
coingecko.getAssets(baseChainId),
getPortalTokens(base),
getPortalTokens(base, 'all'),
])

const [assets, _portalsAssets] = results.map(result => {
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateAssetData/bnbsmartchain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { bscChainId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import { partition } from 'lodash'
import uniqBy from 'lodash/uniqBy'
import { getPortalTokens } from 'lib/portals/utils'

import { bnbsmartchain } from '../baseAssets'
import * as coingecko from '../coingecko'
import { getPortalTokens } from '../utils/portals'

export const getAssets = async (): Promise<Asset[]> => {
const results = await Promise.allSettled([
coingecko.getAssets(bscChainId),
getPortalTokens(bnbsmartchain),
getPortalTokens(bnbsmartchain, 'all'),
])

const [assets, _portalsAssets] = results.map(result => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateAssetData/coingecko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import type { Asset } from '@shapeshiftoss/types'
import axios from 'axios'

import { colorMap } from './../../src/lib/asset-service/service/colorMap'
import {
arbitrum,
arbitrumNova,
Expand All @@ -27,7 +28,6 @@ import {
optimism,
polygon,
} from './baseAssets'
import { colorMap } from './colorMap'

type Token = {
chainId: number
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateAssetData/cosmos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { cosmosChainId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import axios from 'axios'

import { colorMap } from '../../../src/lib/asset-service/service/colorMap'
import { atom } from '../baseAssets'
import { colorMap } from '../colorMap'

type CosmosAsset = {
denom: string
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateAssetData/ethTokens/uniswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ethChainId as chainId, toAssetId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import axios from 'axios'

import { colorMap } from '../colorMap'
import { colorMap } from '../../../src/lib/asset-service/service/colorMap'

type UniswapToken = {
chainId: number
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateAssetData/ethereum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import chunk from 'lodash/chunk'
import orderBy from 'lodash/orderBy'
import partition from 'lodash/partition'
import uniqBy from 'lodash/uniqBy'
import { getPortalTokens } from 'lib/portals/utils'

import { ethereum } from '../baseAssets'
import * as coingecko from '../coingecko'
import { generateTrustWalletUrl } from '../generateTrustWalletUrl/generateTrustWalletUrl'
import { getPortalTokens } from '../utils/portals'

const foxyToken: Asset = {
assetId: toAssetId({
Expand All @@ -32,7 +32,7 @@ const foxyToken: Asset = {
export const getAssets = async (): Promise<Asset[]> => {
const results = await Promise.allSettled([
coingecko.getAssets(ethChainId),
getPortalTokens(ethereum),
getPortalTokens(ethereum, 'all'),
])

const [coingeckoTokens, portalsTokens] = results.map(result => {
Expand Down
3 changes: 2 additions & 1 deletion scripts/generateAssetData/generateColorMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const generateColorMap = async () => {
}, initial)

await fs.promises.writeFile(
`./scripts/generateAssetData/colorMap/color-map.json`,
// note: cwd is the root of the monorepo, *not* the script directory
'src/lib/asset-service/service/color-map.json',
// beautify the file for github diff.
JSON.stringify(colorMap, null, 2),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
fromAssetId,
optimismAssetId,
} from '@shapeshiftoss/caip'
import { type Asset, type AssetsById, KnownChainIds } from '@shapeshiftoss/types'
import type { Asset, AssetsById } from '@shapeshiftoss/types'
import { isEvmChainId } from '@shapeshiftoss/utils'
import axios from 'axios'
import axiosRetry from 'axios-retry'
import fs from 'fs'
Expand All @@ -33,19 +34,6 @@ axiosRetry(axiosInstance, { retries: 5, retryDelay: axiosRetry.exponentialDelay
const ZERION_API_KEY = process.env.ZERION_API_KEY
if (!ZERION_API_KEY) throw new Error('Missing Zerion API key - see readme for instructions')

// Redeclared here due to ethers import issues
export const EVM_CHAIN_IDS = [
KnownChainIds.EthereumMainnet,
KnownChainIds.AvalancheMainnet,
KnownChainIds.OptimismMainnet,
KnownChainIds.BnbSmartChainMainnet,
KnownChainIds.PolygonMainnet,
KnownChainIds.GnosisMainnet,
KnownChainIds.ArbitrumMainnet,
KnownChainIds.ArbitrumNovaMainnet,
KnownChainIds.BaseMainnet,
] as const

const manualRelatedAssetIndex: Record<AssetId, AssetId[]> = {
[ethAssetId]: [
optimismAssetId,
Expand Down Expand Up @@ -126,11 +114,7 @@ const getRelatedAssetIds = async (

const { chainId, assetReference } = fromAssetId(assetId)

if (
!EVM_CHAIN_IDS.includes(chainId as (typeof EVM_CHAIN_IDS)[number]) ||
FEE_ASSET_IDS.includes(assetId)
)
return
if (!isEvmChainId(chainId) || FEE_ASSET_IDS.includes(assetId)) return

const filter = { params: { 'filter[implementation_address]': assetReference } }
const url = '/fungibles'
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateAssetData/gnosis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { gnosisChainId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import partition from 'lodash/partition'
import uniqBy from 'lodash/uniqBy'
import { getPortalTokens } from 'lib/portals/utils'

import { gnosis } from '../baseAssets'
import * as coingecko from '../coingecko'
import { getPortalTokens } from '../utils/portals'

export const getAssets = async (): Promise<Asset[]> => {
const [assets, _portalsAssets] = await Promise.all([
coingecko.getAssets(gnosisChainId),
getPortalTokens(gnosis),
getPortalTokens(gnosis, 'all'),
])

// Order matters here - We do a uniqBy and only keep the first of each asset using assetId as a criteria
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateAssetData/optimism/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { optimismChainId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import partition from 'lodash/partition'
import uniqBy from 'lodash/uniqBy'
import { getPortalTokens } from 'lib/portals/utils'

import { optimism } from '../baseAssets'
import * as coingecko from '../coingecko'
import { getPortalTokens } from '../utils/portals'

export const getAssets = async (): Promise<Asset[]> => {
const results = await Promise.allSettled([
coingecko.getAssets(optimismChainId),
getPortalTokens(optimism),
getPortalTokens(optimism, 'all'),
])

const [assets, _portalsAssets] = results.map(result => {
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateAssetData/polygon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { polygonChainId } from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'
import partition from 'lodash/partition'
import uniqBy from 'lodash/uniqBy'
import { getPortalTokens } from 'lib/portals/utils'

import { polygon } from '../baseAssets'
import * as coingecko from '../coingecko'
import { getPortalTokens } from '../utils/portals'

export const getAssets = async (): Promise<Asset[]> => {
const results = await Promise.allSettled([
coingecko.getAssets(polygonChainId),
getPortalTokens(polygon),
getPortalTokens(polygon, 'all'),
])

const [assets, _portalsAssets] = results.map(result => {
Expand Down
Loading

0 comments on commit e117f2e

Please sign in to comment.