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

fix: add custom node entry point #28

Merged
merged 1 commit into from
Feb 27, 2024
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
34 changes: 19 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,43 @@
},
"license": "MIT",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"main": "./dist/browser.cjs",
"module": "./dist/browser.js",
"exports": {
".": {
"node": {
"types": "./dist/node.d.cts",
"default": "./dist/node.cjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
"types": "./dist/browser.d.cts",
"default": "./dist/browser.cjs"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"types": "./dist/browser.d.ts",
"default": "./dist/browser.js"
},
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
"types": "./dist/browser.d.cts",
"default": "./dist/browser.cjs"
}
},
"engines": {
"node": ">=18.0.0"
},
"devDependencies": {
"@types/node": "^20.11.5",
"prettier": "^3.2.4",
"@types/node": "^20.11.20",
"prettier": "^3.2.5",
"ts-node": "^10.9.1",
"tsup": "^8.0.1",
"tsup": "^8.0.2",
"typescript": "^5.1.6",
"viem": "^2.1.1",
"vitest": "^1.2.1"
"viem": "^2.7.15",
"vitest": "^1.3.1"
},
"dependencies": {
"@supercharge/promise-pool": "^3.1.0",
"@supercharge/promise-pool": "^3.1.1",
"bs58": "^5.0.0",
"gray-matter": "^4.0.3",
"tsx": "^4.4.0"
"tsx": "^4.7.1"
},
"peerDependencies": {
"viem": "^2.0.3"
Expand Down
7 changes: 7 additions & 0 deletions src/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from './foundry/storage-diff';
export * from './rpc/chainIds';
export * from './rpc/helpers';
export * from './rpc/clients';
export * from './ipfs/hash';
export * from './ipfs/upload';
export * from './ipfs/parseIpfs';
2 changes: 2 additions & 0 deletions src/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './browser';
export * from './cache/json';
54 changes: 27 additions & 27 deletions src/rpc/clients.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PublicClient, createPublicClient, http } from 'viem';
import { createClient, http } from 'viem';
import {
mainnet,
arbitrum,
Expand All @@ -21,137 +21,137 @@ import {
harmonyOne,
arbitrumGoerli,
optimismGoerli,
scrollTestnet,
scrollSepolia,
fantomTestnet,
arbitrumSepolia,
} from 'viem/chains';
import { ChainId } from './chainIds';
import { Client } from 'viem';

const commonConfig = { timeout: 30_000 };

export const mainnetClient = createPublicClient({
export const mainnetClient = createClient({
chain: mainnet,
transport: http(process.env.RPC_MAINNET, commonConfig),
});

export const arbitrumClient = createPublicClient({
export const arbitrumClient = createClient({
chain: arbitrum,
transport: http(process.env.RPC_ARBITRUM, commonConfig),
});

export const polygonClient = createPublicClient({
export const polygonClient = createClient({
chain: polygon,
transport: http(process.env.RPC_POLYGON, commonConfig),
});

export const optimismClient = createPublicClient({
export const optimismClient = createClient({
chain: optimism,
transport: http(process.env.RPC_OPTIMISM, commonConfig),
});

export const metisClient = createPublicClient({
export const metisClient = createClient({
chain: metis,
transport: http(process.env.RPC_METIS, commonConfig),
});

export const baseClient = createPublicClient({
export const baseClient = createClient({
chain: base,
transport: http(process.env.RPC_BASE, commonConfig),
});

export const fantomClient = createPublicClient({
export const fantomClient = createClient({
chain: fantom,
transport: http(process.env.RPC_FANTOM, commonConfig),
});

export const bnbClient = createPublicClient({
export const bnbClient = createClient({
chain: bsc,
transport: http(process.env.RPC_BNB, commonConfig),
});

export const avalancheClient = createPublicClient({
export const avalancheClient = createClient({
chain: avalanche,
transport: http(process.env.RPC_AVALANCHE, commonConfig),
});

export const gnosisClient = createPublicClient({
export const gnosisClient = createClient({
chain: gnosis,
transport: http(process.env.RPC_GNOSIS, commonConfig),
});

export const scrollClient = createPublicClient({
export const scrollClient = createClient({
chain: scroll,
transport: http(process.env.RPC_SCROLL, commonConfig),
});

export const zkEVMClient = createPublicClient({
export const zkEVMClient = createClient({
chain: polygonZkEvm,
transport: http(process.env.RPC_ZKEVM, commonConfig),
});

export const celoClient = createPublicClient({
export const celoClient = createClient({
chain: celo,
transport: http(process.env.RPC_CELO, commonConfig),
});

export const zkSyncClient = createPublicClient({
export const zkSyncClient = createClient({
chain: zkSync,
transport: http(process.env.RPC_ZKSYNC, commonConfig),
});

export const harmonyClient = createPublicClient({
export const harmonyClient = createClient({
chain: harmonyOne,
transport: http(process.env.RPC_HARMONY, commonConfig),
});

// testnets
export const fujiClient = createPublicClient({
export const fujiClient = createClient({
chain: avalancheFuji,
transport: http(process.env.RPC_FUJI, commonConfig),
});

export const mumbaiClient = createPublicClient({
export const mumbaiClient = createClient({
chain: polygonMumbai,
transport: http(process.env.RPC_MUMBAI, commonConfig),
});

export const sepoliaClient = createPublicClient({
export const sepoliaClient = createClient({
chain: sepolia,
transport: http(process.env.RPC_SEPOLIA, commonConfig),
});

export const goerliClient = createPublicClient({
export const goerliClient = createClient({
chain: goerli,
transport: http(process.env.RPC_GOERLI, commonConfig),
});

export const arbitrumGoerliClient = createPublicClient({
export const arbitrumGoerliClient = createClient({
chain: arbitrumGoerli,
transport: http(process.env.RPC_ARBITRUM_GOERLI, commonConfig),
});

export const arbitrumSepoliaClient = createPublicClient({
export const arbitrumSepoliaClient = createClient({
chain: arbitrumSepolia,
transport: http(process.env.RPC_ARBITRUM_SEPOLIA, commonConfig),
});

export const optimismGoerliClient = createPublicClient({
export const optimismGoerliClient = createClient({
chain: optimismGoerli,
transport: http(process.env.RPC_OPTIMISM_GOERLI, commonConfig),
});

export const scrollSepoliaClient = createPublicClient({
export const scrollSepoliaClient = createClient({
chain: scrollSepolia,
transport: http(process.env.RPC_SCROLL_SEPOLIA, commonConfig),
});

export const fantomTestnetClient = createPublicClient({
export const fantomTestnetClient = createClient({
chain: fantomTestnet,
transport: http(process.env.RPC_FANTOM_TESTNET, commonConfig),
});

export const CHAIN_ID_CLIENT_MAP: Record<number, PublicClient> = {
export const CHAIN_ID_CLIENT_MAP: Record<number, Client> = {
[ChainId.mainnet]: mainnetClient,
[ChainId.arbitrum_one]: arbitrumClient,
[ChainId.arbitrum_goerli]: arbitrumGoerliClient,
Expand Down
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Options } from 'tsup';

const config: Options = {
entry: ['src/index.ts'],
entry: ['src/browser.ts', 'src/node.ts'],
sourcemap: true,
format: ['iife', 'cjs', 'esm'],
dts: {
Expand Down
Loading
Loading