Skip to content

Commit

Permalink
New chain support
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayoakala committed May 24, 2024
1 parent 4923df2 commit 631e1de
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 7 deletions.
12 changes: 10 additions & 2 deletions web3-react/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,25 @@ interface ExampleConfig {
arbitrum: string
bsc: string
blast: string
base: string
avax: string
celo: string
zora: string
}
}

// Example Configuration
export const CurrentConfig: ExampleConfig = {
chain: Chain.MAINNET,
rpc: {
polygon: '',
mainnet: '',
polygon: 'https://polygon-mainnet.infura.io/v3/ddee64bef51f4b17b83aebdbff316876',
mainnet: 'https://mainnet.infura.io/v3/ddee64bef51f4b17b83aebdbff316876',
arbitrum: '',
bsc: '',
blast: '',
base: '',
avax: '',
celo: '',
zora: '',
},
}
32 changes: 27 additions & 5 deletions web3-react/src/example/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ const Example = () => {
token: tokenIn,
chainId,
includeGasInfo: true,
tokenOut,
tokenOutChainId: chainId,
},
{
headers,
Expand All @@ -218,7 +220,7 @@ const Example = () => {
}

let postOrderResponse
if (routing === 'CLASSIC') {
if (routing === 'CLASSIC' || routing === 'WRAP' || routing === 'UNWRAP') {
postOrderResponse = await axios.post(
`${API_URL}/swap`,
{
Expand Down Expand Up @@ -285,11 +287,15 @@ const Example = () => {
const mainnetBullet = '0x8ef32a03784c8Fd63bBf027251b9620865bD54B6'
const mainnetBtc = '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'

const baseWeth = '0x4200000000000000000000000000000000000006'

const zoraWeth = '0x4200000000000000000000000000000000000006'

const defaultNative = '0x0000000000000000000000000000000000000000'

const [tokenIn, setTokenIn] = useState(arbWeth)
const [tokenOut, setTokenOut] = useState(arbAxie)
const [amount, setAmount] = useState('500000000')
const [tokenIn, setTokenIn] = useState(defaultNative)
const [tokenOut, setTokenOut] = useState(zoraWeth)
const [amount, setAmount] = useState('10000')
const [routingPreference, setRoutingPreference] = useState(RoutingPreference.CLASSIC)

const exactIn = 'EXACT_INPUT'
Expand All @@ -300,7 +306,12 @@ const Example = () => {
const op = 10
const mainnet = 1
const blast = 81457
const [chainId, setChainId] = useState(arb)
const base = 8453
const AVAX_CHAIN = 43114
const CELO_CHAIN = 42220
const ZORA_CHAIN = 7777777
const [chainId, setChainId] = useState(CELO_CHAIN)
const [tokenOutChainId, setTokenOutChainId] = useState(CELO_CHAIN)

return (
<div className="App">
Expand All @@ -327,6 +338,17 @@ const Example = () => {
/>
</label>
<p />
<label>
Token Out Chain Id:
<p />
<input
style={{ width: 400 }}
type="text"
value={tokenOutChainId}
onChange={(event) => setTokenOutChainId(Number(event.target.value))}
/>
</label>
<p />
<label>
Token in:
<p />
Expand Down
28 changes: 28 additions & 0 deletions web3-react/src/libs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const POLYGON_CHAIN_ID = 137
const ARBITRUM_CHAIN_ID = 42161
const BNB_CHAIN_ID = 56
const BLAST_CHAIN = 81457
const BASE_CHAIN = 8453
const AVAX_CHAIN = 43114
const CELO_CHAIN = 42220
const ZORA_CHAIN = 7777777

export const INPUT_CHAIN_ID = CurrentConfig.chain === Chain.POLYGON ? POLYGON_CHAIN_ID : MAINNET_CHAIN_ID
export const INPUT_CHAIN_URL =
Expand Down Expand Up @@ -59,6 +63,30 @@ export const CHAIN_INFO: { [key: string]: ChainInfo } = {
nativeCurrency: { name: 'BLAST', symbol: 'BLAST', decimals: 18 },
rpcUrl: CurrentConfig.rpc.blast,
},
[BASE_CHAIN]: {
explorer: 'https://basescan.org/',
label: 'BASE Chain',
nativeCurrency: { name: 'BASE', symbol: 'BASE', decimals: 18 },
rpcUrl: CurrentConfig.rpc.base,
},
[AVAX_CHAIN]: {
explorer: 'https://basescan.org/',
label: 'AVAX Chain',
nativeCurrency: { name: 'AVAX', symbol: 'AVAX', decimals: 18 },
rpcUrl: CurrentConfig.rpc.base,
},
[CELO_CHAIN]: {
explorer: 'https://basescan.org/',
label: 'CELO Chain',
nativeCurrency: { name: 'CELO', symbol: 'BASE', decimals: 18 },
rpcUrl: CurrentConfig.rpc.base,
},
[ZORA_CHAIN]: {
explorer: 'https://basescan.org/',
label: 'ZORA Chain',
nativeCurrency: { name: 'Ether', symbol: 'Ether', decimals: 18 },
rpcUrl: CurrentConfig.rpc.base,
},
}

// URLs
Expand Down

0 comments on commit 631e1de

Please sign in to comment.