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

chore: release v1.728.0 #8483

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
125 changes: 125 additions & 0 deletions packages/utils/src/assetData/assetData.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import type { AssetsById } from '@shapeshiftoss/types'
import { describe, expect, it } from 'vitest'

import { decodeAssetData } from './decodeAssetData'
import { encodeAssetData } from './encodeAssetData'

const mockGeneratedAssetData: AssetsById = {
'bip122:000000000019d6689c085ae165831e93/slip44:0': {
assetId: 'bip122:000000000019d6689c085ae165831e93/slip44:0',
chainId: 'bip122:000000000019d6689c085ae165831e93',
symbol: 'BTC',
name: 'Bitcoin',
networkName: 'Bitcoin',
precision: 8,
color: '#FF9800',
icon: 'https://rawcdn.githack.com/trustwallet/assets/b7a5f12d893fcf58e0eb1dd64478f076857b720b/blockchains/bitcoin/info/logo.png',
explorer: 'https://live.blockcypher.com',
explorerAddressLink: 'https://live.blockcypher.com/btc/address/',
explorerTxLink: 'https://live.blockcypher.com/btc/tx/',
relatedAssetKey: null,
},
'eip155:1/erc20:0xf073bac22dab7faf4a3dd6c6189a70d54110525c': {
assetId: 'eip155:1/erc20:0xf073bac22dab7faf4a3dd6c6189a70d54110525c',
chainId: 'eip155:1',
name: 'Inception Restaked ETH on Ethereum',
precision: 18,
color: '#D6D1E4',
icon: 'https://assets.coingecko.com/coins/images/34127/large/inETH.png?1715036464',
symbol: 'INETH',
explorer: 'https://etherscan.io',
explorerAddressLink: 'https://etherscan.io/address/',
explorerTxLink: 'https://etherscan.io/tx/',
relatedAssetKey: 'eip155:1/erc20:0xf073bac22dab7faf4a3dd6c6189a70d54110525c',
},
'eip155:1/erc20:0xeed3ae7b0f8b5b9bb8c035a9941382b1822671cd': {
assetId: 'eip155:1/erc20:0xeed3ae7b0f8b5b9bb8c035a9941382b1822671cd',
chainId: 'eip155:1',
name: 'EveryCoin',
precision: 12,
color: '#0483CB',
icon: 'https://rawcdn.githack.com/trustwallet/assets/master/blockchains/ethereum/assets/0xEEd3aE7b0F8b5B9BB8C035A9941382B1822671CD/logo.png',
symbol: 'EVY',
explorer: 'https://etherscan.io',
explorerAddressLink: 'https://etherscan.io/address/',
explorerTxLink: 'https://etherscan.io/tx/',
relatedAssetKey: null,
},
'eip155:1/erc20:0xeeda34a377dd0ca676b9511ee1324974fa8d980d': {
explorer: 'https://etherscan.io',
explorerAddressLink: 'https://etherscan.io/address/',
explorerTxLink: 'https://etherscan.io/tx/',
color: '#FFFFFF',
icon: undefined,
icons: [
'https://rawcdn.githack.com/trustwallet/assets/master/blockchains/ethereum/assets/0xD9A442856C234a39a81a089C06451EBAa4306a72/logo.png',
'https://rawcdn.githack.com/trustwallet/assets/master/blockchains/ethereum/assets/0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0/logo.png',
],
name: 'Curve PUFETH/WSTETH Pool',
precision: 18,
symbol: 'pufETHwstE',
chainId: 'eip155:1',
assetId: 'eip155:1/erc20:0xeeda34a377dd0ca676b9511ee1324974fa8d980d',
relatedAssetKey: null,
isPool: true,
},
'eip155:1/erc20:0xeee0fe52299f2de8e2ed5111cd521ab67dcf0faf': {
assetId: 'eip155:1/erc20:0xeee0fe52299f2de8e2ed5111cd521ab67dcf0faf',
chainId: 'eip155:1',
name: 'The QWAN',
precision: 18,
color: '#18B6BE',
icon: 'https://assets.coingecko.com/coins/images/30613/large/qwan.jpg?1696529482',
symbol: 'QWAN',
explorer: 'https://etherscan.io',
explorerAddressLink: 'https://etherscan.io/address/',
explorerTxLink: 'https://etherscan.io/tx/',
relatedAssetKey: null,
},
'eip155:1/erc20:0xeeecd285f60e802ecb6d8d8d37790c887f9a4b33': {
assetId: 'eip155:1/erc20:0xeeecd285f60e802ecb6d8d8d37790c887f9a4b33',
chainId: 'eip155:1',
name: 'Big Tom',
precision: 9,
color: '#27DD08',
icon: 'https://assets.coingecko.com/coins/images/38555/large/huyah_%281%29.jpg?1717999187',
symbol: 'TOM',
explorer: 'https://etherscan.io',
explorerAddressLink: 'https://etherscan.io/address/',
explorerTxLink: 'https://etherscan.io/tx/',
relatedAssetKey: null,
},
'eip155:1/erc20:0xeeee2a2e650697d2a8e8bc990c2f3d04203be06f': {
assetId: 'eip155:1/erc20:0xeeee2a2e650697d2a8e8bc990c2f3d04203be06f',
chainId: 'eip155:1',
name: 'Forgotten Playland',
precision: 18,
color: '#35355D',
icon: 'https://assets.coingecko.com/coins/images/35339/large/200.png?1708515043',
symbol: 'FP',
explorer: 'https://etherscan.io',
explorerAddressLink: 'https://etherscan.io/address/',
explorerTxLink: 'https://etherscan.io/tx/',
relatedAssetKey: null,
},
}

// Order of these is deliberately shuffled to test sorting is preserved
const mockSortedAssetIds = [
'eip155:1/erc20:0xeeecd285f60e802ecb6d8d8d37790c887f9a4b33', // big tom
'eip155:1/erc20:0xeeee2a2e650697d2a8e8bc990c2f3d04203be06f', // forgotten playland
'eip155:1/erc20:0xeed3ae7b0f8b5b9bb8c035a9941382b1822671cd', // everycoin
'eip155:1/erc20:0xf073bac22dab7faf4a3dd6c6189a70d54110525c', // Inception Restaked ETH on Ethereum
'eip155:1/erc20:0xeee0fe52299f2de8e2ed5111cd521ab67dcf0faf', // the qwan
'eip155:1/erc20:0xeeda34a377dd0ca676b9511ee1324974fa8d980d', // Curve PUFETH/WSTETH Pool
'bip122:000000000019d6689c085ae165831e93/slip44:0', // BTC
]

describe('assetData', () => {
it('can encode and decode asset data as a complete round trip', () => {
const encodedAssetData = encodeAssetData(mockSortedAssetIds, mockGeneratedAssetData)
const { assetData, sortedAssetIds } = decodeAssetData(encodedAssetData)
expect(assetData).toEqual(mockGeneratedAssetData)
expect(sortedAssetIds).toEqual(mockSortedAssetIds)
})
})
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as caip from '@shapeshiftoss/caip'
import type { Asset } from '@shapeshiftoss/types'

type AssetWithNetworkName = Asset & { networkName: string }

export const ethereum: AssetWithNetworkName = {
export const ethereum: Readonly<Asset> = Object.freeze({
assetId: caip.ethAssetId,
chainId: caip.ethChainId,
symbol: 'ETH',
Expand All @@ -16,9 +14,9 @@ export const ethereum: AssetWithNetworkName = {
explorerAddressLink: 'https://etherscan.io/address/',
explorerTxLink: 'https://etherscan.io/tx/',
relatedAssetKey: 'eip155:1/slip44:60',
}
})

export const bitcoin: AssetWithNetworkName = {
export const bitcoin: Readonly<Asset> = Object.freeze({
assetId: caip.btcAssetId,
chainId: caip.btcChainId,
symbol: 'BTC',
Expand All @@ -31,9 +29,9 @@ export const bitcoin: AssetWithNetworkName = {
explorerAddressLink: 'https://live.blockcypher.com/btc/address/',
explorerTxLink: 'https://live.blockcypher.com/btc/tx/',
relatedAssetKey: null,
}
})

export const bitcoincash: AssetWithNetworkName = {
export const bitcoincash: Readonly<Asset> = Object.freeze({
assetId: caip.bchAssetId,
chainId: caip.bchChainId,
symbol: 'BCH',
Expand All @@ -46,9 +44,9 @@ export const bitcoincash: AssetWithNetworkName = {
explorerAddressLink: 'https://blockchair.com/bitcoin-cash/address/',
explorerTxLink: 'https://blockchair.com/bitcoin-cash/transaction/',
relatedAssetKey: null,
}
})

export const dogecoin: AssetWithNetworkName = {
export const dogecoin: Readonly<Asset> = Object.freeze({
assetId: caip.dogeAssetId,
chainId: caip.dogeChainId,
symbol: 'DOGE',
Expand All @@ -61,9 +59,9 @@ export const dogecoin: AssetWithNetworkName = {
explorerAddressLink: 'https://live.blockcypher.com/doge/address/',
explorerTxLink: 'https://live.blockcypher.com/doge/tx/',
relatedAssetKey: null,
}
})

export const litecoin: AssetWithNetworkName = {
export const litecoin: Readonly<Asset> = Object.freeze({
assetId: caip.ltcAssetId,
chainId: caip.ltcChainId,
symbol: 'LTC',
Expand All @@ -76,9 +74,9 @@ export const litecoin: AssetWithNetworkName = {
explorerAddressLink: 'https://live.blockcypher.com/ltc/address/',
explorerTxLink: 'https://live.blockcypher.com/ltc/tx/',
relatedAssetKey: null,
}
})

export const atom: AssetWithNetworkName = {
export const atom: Readonly<Asset> = Object.freeze({
assetId: caip.cosmosAssetId,
chainId: caip.cosmosChainId,
symbol: 'ATOM',
Expand All @@ -91,9 +89,9 @@ export const atom: AssetWithNetworkName = {
explorerAddressLink: 'https://www.mintscan.io/cosmos/account/',
explorerTxLink: 'https://www.mintscan.io/cosmos/txs/',
relatedAssetKey: null,
}
})

export const avax: AssetWithNetworkName = {
export const avax: Readonly<Asset> = Object.freeze({
assetId: caip.avalancheAssetId,
chainId: caip.avalancheChainId,
name: 'Avalanche',
Expand All @@ -106,9 +104,9 @@ export const avax: AssetWithNetworkName = {
explorerAddressLink: 'https://snowtrace.dev/address/',
explorerTxLink: 'https://snowtrace.dev/tx/',
relatedAssetKey: null,
}
})

export const thorchain: AssetWithNetworkName = {
export const thorchain: Readonly<Asset> = Object.freeze({
assetId: caip.thorchainAssetId,
chainId: caip.thorchainChainId,
name: 'THORChain',
Expand All @@ -121,9 +119,9 @@ export const thorchain: AssetWithNetworkName = {
explorerAddressLink: 'https://viewblock.io/thorchain/address/',
explorerTxLink: 'https://viewblock.io/thorchain/tx/',
relatedAssetKey: null,
}
})

export const optimism: AssetWithNetworkName = {
export const optimism: Readonly<Asset> = Object.freeze({
assetId: caip.optimismAssetId,
chainId: caip.optimismChainId,
name: 'Ethereum',
Expand All @@ -138,9 +136,9 @@ export const optimism: AssetWithNetworkName = {
explorerAddressLink: 'https://optimistic.etherscan.io/address/',
explorerTxLink: 'https://optimistic.etherscan.io/tx/',
relatedAssetKey: 'eip155:1/slip44:60',
}
})

export const bnbsmartchain: AssetWithNetworkName = {
export const bnbsmartchain: Readonly<Asset> = Object.freeze({
assetId: caip.bscAssetId,
chainId: caip.bscChainId,
name: 'BNB',
Expand All @@ -153,9 +151,9 @@ export const bnbsmartchain: AssetWithNetworkName = {
explorerAddressLink: 'https://bscscan.com/address/',
explorerTxLink: 'https://bscscan.com/tx/',
relatedAssetKey: null,
}
})

export const polygon: AssetWithNetworkName = {
export const polygon: Readonly<Asset> = Object.freeze({
assetId: caip.polygonAssetId,
chainId: caip.polygonChainId,
name: 'Polygon Ecosystem Token',
Expand All @@ -168,9 +166,9 @@ export const polygon: AssetWithNetworkName = {
explorerAddressLink: 'https://polygonscan.com/address/',
explorerTxLink: 'https://polygonscan.com/tx/',
relatedAssetKey: null,
}
})

export const gnosis: AssetWithNetworkName = {
export const gnosis: Readonly<Asset> = Object.freeze({
assetId: caip.gnosisAssetId,
chainId: caip.gnosisChainId,
name: 'xDAI',
Expand All @@ -185,9 +183,9 @@ export const gnosis: AssetWithNetworkName = {
explorerAddressLink: 'https://gnosis.blockscout.com/address/',
explorerTxLink: 'https://gnosis.blockscout.com/tx/',
relatedAssetKey: null,
}
})

export const arbitrum: AssetWithNetworkName = {
export const arbitrum: Readonly<Asset> = Object.freeze({
assetId: caip.arbitrumAssetId,
chainId: caip.arbitrumChainId,
name: 'Ethereum',
Expand All @@ -203,9 +201,9 @@ export const arbitrum: AssetWithNetworkName = {
explorerAddressLink: 'https://arbiscan.io/address/',
explorerTxLink: 'https://arbiscan.io/tx/',
relatedAssetKey: 'eip155:1/slip44:60',
}
})

export const arbitrumNova: AssetWithNetworkName = {
export const arbitrumNova: Readonly<Asset> = Object.freeze({
assetId: caip.arbitrumNovaAssetId,
chainId: caip.arbitrumNovaChainId,
name: 'Ethereum',
Expand All @@ -221,9 +219,9 @@ export const arbitrumNova: AssetWithNetworkName = {
explorerAddressLink: 'https://nova.arbiscan.io/address/',
explorerTxLink: 'https://nova.arbiscan.io/tx/',
relatedAssetKey: 'eip155:1/slip44:60',
}
})

export const base: AssetWithNetworkName = {
export const base: Readonly<Asset> = Object.freeze({
assetId: caip.baseAssetId,
chainId: caip.baseChainId,
name: 'Ethereum',
Expand All @@ -238,10 +236,10 @@ export const base: AssetWithNetworkName = {
explorer: 'https://basescan.org',
explorerAddressLink: 'https://basescan.org/address/',
explorerTxLink: 'https://basescan.org/tx/',
relatedAssetKey: null,
}
relatedAssetKey: 'eip155:1/slip44:60',
})

export const solana: AssetWithNetworkName = {
export const solana: Readonly<Asset> = Object.freeze({
assetId: caip.solAssetId,
chainId: caip.solanaChainId,
name: 'Solana',
Expand All @@ -255,4 +253,4 @@ export const solana: AssetWithNetworkName = {
explorerAddressLink: 'https://explorer.solana.com/address/',
explorerTxLink: 'https://explorer.solana.com/tx/',
relatedAssetKey: null,
}
})
10 changes: 10 additions & 0 deletions packages/utils/src/assetData/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const FIELDS = [
'assetIdx',
'name',
'precision',
'color',
'icon',
'symbol',
'relatedAssetKey',
'isPool',
] as const
Loading
Loading