Skip to content
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
2 changes: 1 addition & 1 deletion packages/caip/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/caip",
"version": "8.16.9",
"version": "8.16.10",
"description": "CAIP Implementation",
"repository": "https://github.com/shapeshift/web",
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion packages/caip/src/adapters/coinbase/generate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getData, parseData, writeFiles } from './utils'
import { getData, parseData } from './utils'
import { writeFiles } from './writeFiles'

const main = async () => {
const coinbaseCurrencies = await getData()
Expand Down
12 changes: 0 additions & 12 deletions packages/caip/src/adapters/coinbase/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from 'axios'
import fs from 'fs'
import toLower from 'lodash/toLower'

import type { AssetId } from '../../index'
Expand Down Expand Up @@ -46,14 +45,3 @@ export async function getData(): Promise<CoinbaseCurrency[]> {
return []
}
}

const writeFile = async (data: Record<AssetId, string>) => {
const path = './src/adapters/coinbase/generated/'
const file = 'adapter.json'
await fs.promises.writeFile(`${path}${file}`, JSON.stringify(data, null, 2))
}

export const writeFiles = async (data: Record<AssetId, string>) => {
await writeFile(data)
console.info('Generated Coinbase AssetId adapter data.')
}
17 changes: 17 additions & 0 deletions packages/caip/src/adapters/coinbase/writeFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Codegen-only, run by generate.ts. `fs` lives here rather than in `utils.ts` so
// that re-exporting from `utils.ts` can never pull a Node built-in into the graph
// browser bundlers reach from the package entry.
import fs from 'fs'

import type { AssetId } from '../../index'

const writeFile = async (data: Record<AssetId, string>): Promise<void> => {
const path = './src/adapters/coinbase/generated/'
const file = 'adapter.json'
await fs.promises.writeFile(`${path}${file}`, JSON.stringify(data, null, 2))
}

export const writeFiles = async (data: Record<AssetId, string>): Promise<void> => {
await writeFile(data)
console.info('Generated Coinbase AssetId adapter data.')
}
3 changes: 2 additions & 1 deletion packages/caip/src/adapters/coincap/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import dotenv from 'dotenv'
import path from 'path'

import { getCoincapAssetUrl } from './index'
import { fetchData, parseData, writeFiles } from './utils'
import { fetchData, parseData } from './utils'
import { writeFiles } from './writeFiles'

dotenv.config({ path: path.resolve(process.cwd(), '../../.env') })

Expand Down
3 changes: 2 additions & 1 deletion packages/caip/src/adapters/coincap/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import realFs from 'fs'
import { describe, expect, it, vi } from 'vitest'

import { bitcoinAssetMap, cosmosAssetMap } from '../../utils'
import { parseData, parseEthData, writeFiles } from './utils'
import { parseData, parseEthData } from './utils'
import { writeFiles } from './writeFiles'

const makeEthMockCoincapResponse = () => ({
id: 'ethereum',
Expand Down
10 changes: 0 additions & 10 deletions packages/caip/src/adapters/coincap/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from 'axios'
import fs from 'fs'

import type { AssetNamespace } from '../../assetId/assetId'
import { toAssetId } from '../../assetId/assetId'
Expand Down Expand Up @@ -89,15 +88,6 @@ const COINCAP_CHAIN_MAP: Record<string, { chainId: ChainId; assetNamespace: Asse
},
}

export const writeFiles = async (data: Record<string, Record<string, string>>) => {
const path = './src/adapters/coincap/generated/'
const file = '/adapter.json'
const writeFile = async ([k, v]: [string, unknown]) =>
await fs.promises.writeFile(`${path}${k}${file}`.replace(':', '_'), JSON.stringify(v))
await Promise.all(Object.entries(data).map(writeFile))
console.info('Generated CoinCap AssetId adapter data.')
}

export const fetchData = async (URL: string) =>
(await axios.get<{ data: CoinCapCoin[] }>(URL)).data.data

Expand Down
13 changes: 13 additions & 0 deletions packages/caip/src/adapters/coincap/writeFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Codegen-only, run by generate.ts. `fs` lives here rather than in `utils.ts` so
// that re-exporting from `utils.ts` can never pull a Node built-in into the graph
// browser bundlers reach from the package entry.
import fs from 'fs'

export const writeFiles = async (data: Record<string, Record<string, string>>): Promise<void> => {
const path = './src/adapters/coincap/generated/'
const file = '/adapter.json'
const writeFile = async ([k, v]: [string, unknown]): Promise<void> =>
await fs.promises.writeFile(`${path}${k}${file}`.replace(':', '_'), JSON.stringify(v))
await Promise.all(Object.entries(data).map(writeFile))
console.info('Generated CoinCap AssetId adapter data.')
}
3 changes: 2 additions & 1 deletion packages/caip/src/adapters/coingecko/generate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { coingeckoUrl } from './index'
import { fetchData, parseData, writeFiles } from './utils'
import { fetchData, parseData } from './utils'
import { writeFiles } from './writeFiles'

const main = async () => {
const data = await fetchData(coingeckoUrl)
Expand Down
3 changes: 2 additions & 1 deletion packages/caip/src/adapters/coingecko/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import realFs from 'fs'
import { describe, expect, it, vi } from 'vitest'

import { bitcoinAssetMap, cosmosAssetMap } from '../../utils'
import { parseData, writeFiles } from './utils'
import { parseData } from './utils'
import { writeFiles } from './writeFiles'

const makeEthMockCoingeckoResponse = () => ({
id: 'ethereum',
Expand Down
14 changes: 1 addition & 13 deletions packages/caip/src/adapters/coingecko/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from 'axios'
import fs from 'fs'

import type { AssetId } from '../../assetId/assetId'
import { toAssetId } from '../../assetId/assetId'
Expand Down Expand Up @@ -112,7 +111,7 @@ export type CoingeckoCoin = {
platforms: Record<string, string>
}

type AssetMap = Record<ChainId, Record<AssetId, string>>
export type AssetMap = Record<ChainId, Record<AssetId, string>>

export const fetchData = async (URL: string) => (await axios.get<CoingeckoCoin[]>(URL)).data

Expand Down Expand Up @@ -722,14 +721,3 @@ export const parseData = (coins: CoingeckoCoin[]): AssetMap => {
[mayachainChainId]: mayachainAssetMap,
}
}

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))
}),
)
console.info('Generated CoinGecko AssetId adapter data.')
}
17 changes: 17 additions & 0 deletions packages/caip/src/adapters/coingecko/writeFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Codegen-only, run by generate.ts. `index.ts` re-exports from `utils.ts`, so
// keeping `fs` here rather than there is what keeps Node built-ins out of the
// module graph browser bundlers reach from the package entry.
import fs from 'fs'

import type { AssetMap } from './utils'

export const writeFiles = async (data: AssetMap): Promise<void> => {
await Promise.all(
Object.entries(data).map(async ([chainId, assets]): Promise<void> => {
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))
}),
)
console.info('Generated CoinGecko AssetId adapter data.')
}
7 changes: 4 additions & 3 deletions packages/swap-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/swap-widget",
"version": "0.5.1",
"version": "0.5.2",
"description": "Embeddable swap widget using ShapeShift API",
"repository": "https://github.com/shapeshift/web",
"license": "MIT",
Expand All @@ -25,6 +25,7 @@
"scripts": {
"clean": "rm -rf dist node_modules",
"build": "rm -rf dist && tsc && tsup",
"prepublishOnly": "test -f dist/index.js && test -f dist/index.css || pnpm build",
"build:demo": "rm -rf dist && vite build",
"dev": "vite",
"preview": "vite preview",
Expand Down Expand Up @@ -53,7 +54,7 @@
"@tanstack/react-query": "^5.69.0",
"react": "^18.0.0 || ^19.0.0",
"react-dom": "^18.0.0 || ^19.0.0",
"viem": "^2.43.5",
"viem": "^2.45.0",
"wagmi": "^2.19.5"
},
"peerDependenciesMeta": {
Expand Down Expand Up @@ -96,7 +97,7 @@
"react-dom": "^19.0.0",
"tsup": "^8.5.1",
"typescript": "~5.2.2",
"viem": "2.43.5",
"viem": "2.46.3",
"vite": "^5.0.0",
"vite-plugin-node-polyfills": "0.23.0",
"wagmi": "2.19.5"
Expand Down
12 changes: 1 addition & 11 deletions packages/swap-widget/src/constants/viemChains.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Chain, WalletClient } from 'viem'
import { defineChain } from 'viem'
import {
arbitrum,
avalanche,
Expand All @@ -9,22 +8,13 @@ import {
hyperEvm,
katana,
mainnet,
megaeth,
monad,
optimism,
plasma,
polygon,
} from 'viem/chains'

const megaeth = defineChain({
id: 4326,
name: 'MegaETH',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: { default: { http: ['https://mainnet.megaeth.com/rpc'] } },
blockExplorers: {
default: { name: 'MegaETH Explorer', url: 'https://megaeth.blockscout.com' },
},
})

export const VIEM_CHAINS_BY_ID: Record<number, Chain> = {
[mainnet.id]: {
...mainnet,
Expand Down
Loading
Loading