Skip to content

Commit

Permalink
Merge pull request #287 from G7DAO/feat/relay-bridge
Browse files Browse the repository at this point in the history
relay complete .. without analytics
  • Loading branch information
elclandestin0 authored Jan 17, 2025
2 parents 7501085 + 753e9d5 commit 14e6e4a
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 97 deletions.
18 changes: 3 additions & 15 deletions webapps/world-builder-dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import router from '@/router'

// relay stuff
import { RelayKitProvider } from '@reservoir0x/relay-kit-ui'
import { convertViemChainToRelayChain } from '@reservoir0x/relay-sdk'
import { http, createConfig, WagmiProvider } from 'wagmi'
import { mainnet, arbitrum, arbitrumSepolia, sepolia, } from 'viem/chains'
import { WagmiProvider } from 'wagmi'
import { MAINNET_RELAY_API } from '@reservoir0x/relay-sdk'
import { theme } from './utils/relayTheme'
import '@reservoir0x/relay-kit-ui/styles.css'
import { wagmiConfig, chains } from './utils/relayConfig'

dayjs.extend(utc)
dayjs.extend(timezone)
Expand All @@ -48,19 +47,8 @@ const queryClient = new QueryClient({
}
})

const chains = [
convertViemChainToRelayChain(mainnet),
convertViemChainToRelayChain(arbitrum),
convertViemChainToRelayChain(arbitrumSepolia),
convertViemChainToRelayChain(sepolia)
]

const wagmiConfig = createConfig({
chains: [mainnet],
transports: {
[mainnet.id]: http(),
}
})


const enMessages = { en }

Expand Down
87 changes: 5 additions & 82 deletions webapps/world-builder-dashboard/src/pages/RelayPage/RelayPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useNotifications, usePendingTransactions } from '@/hooks/useL2ToL1Messa
import { SwapWidget } from '@reservoir0x/relay-kit-ui'
import { Address } from "viem"
import { useNavigate } from 'react-router-dom'
import { ETH, USDC, TOKENS } from '@/utils/relayConfig'

export interface SwapWidgetToken {
chainId: number;
Expand All @@ -29,7 +30,7 @@ export interface SwapWidgetToken {


const RelayPage = () => {
const { connectedAccount } = useBlockchainContext()
const { connectedAccount, connectWallet } = useBlockchainContext()
const navigate = useNavigate()
const pendingTransacions = usePendingTransactions(connectedAccount)
const [notificationsOffset] = useState(0)
Expand Down Expand Up @@ -61,15 +62,11 @@ const RelayPage = () => {
<div className={styles.mainContainer}>
<SwapWidget
defaultFromToken={ETH}
defaultToToken={ETH}
defaultToToken={USDC}
defaultAmount={amount}
lockFromToken={true}
lockToToken={true}
tokens={[ETH, ETH_ARB, USDC, USDC_ARB, USDC_G7, G7, G7_ARB, G7_G7]}
lockChainId={ETH.chainId}
defaultToAddress={connectedAccount as Address}
supportedWalletVMs={['evm']}
onConnectWallet={open}
onConnectWallet={connectWallet}
onAnalyticEvent={(eventName, data) => {
console.log('Analytic Event', eventName, data)
}}
Expand All @@ -83,78 +80,4 @@ const RelayPage = () => {
)
}

export default RelayPage


export const ETH: SwapWidgetToken = {
chainId: 1,
address: '0x0000000000000000000000000000000000000000',
decimals: 18,
name: 'ETH',
symbol: 'ETH',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const ETH_ARB: SwapWidgetToken = {
chainId: 42161,
address: '0x0000000000000000000000000000000000000000',
decimals: 18,
name: 'ETH',
symbol: 'ETH',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const USDC: SwapWidgetToken = {
chainId: 1,
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const USDC_ARB: SwapWidgetToken = {
chainId: 42161,
address: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const USDC_G7: SwapWidgetToken = {
chainId: 2187,
address: '0x401eCb1D350407f13ba348573E5630B83638E30D',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

// G7
export const G7: SwapWidgetToken = {
chainId: 1,
address: '0x12c88a3C30A7AaBC1dd7f2c08a97145F5DCcD830',
decimals: 18,
name: 'G7',
symbol: 'G7',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const G7_ARB = {
chainId: 42161,
address: '0xF18e4466F26B4cA55bbAb890b314a54976E45B17',
decimals: 18,
name: 'G7',
symbol: 'G7',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const G7_G7 = {
chainId: 2187,
address: '0x0000000000000000000000000000000000000000',
decimals: 18,
name: 'G7',
symbol: 'G7',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}
export default RelayPage
99 changes: 99 additions & 0 deletions webapps/world-builder-dashboard/src/utils/relayConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

import { SwapWidgetToken } from '@/pages/RelayPage/RelayPage'
import { convertViemChainToRelayChain } from '@reservoir0x/relay-sdk'
import { http } from 'viem'
import { mainnet, arbitrum, base, optimism, polygon, zksync, xai } from 'viem/chains'
import { createConfig } from 'wagmi'

export const chains = [
convertViemChainToRelayChain(mainnet),
convertViemChainToRelayChain(arbitrum),
convertViemChainToRelayChain(base),
convertViemChainToRelayChain(optimism),
convertViemChainToRelayChain(polygon),
convertViemChainToRelayChain(zksync),
convertViemChainToRelayChain(xai),
]

export const wagmiConfig = createConfig({
chains: [mainnet],
transports: {
[mainnet.id]: http(),
}
})

export const ETH: SwapWidgetToken = {
chainId: 1,
address: '0x0000000000000000000000000000000000000000',
decimals: 18,
name: 'ETH',
symbol: 'ETH',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const ETH_ARB: SwapWidgetToken = {
chainId: 42161,
address: '0x0000000000000000000000000000000000000000',
decimals: 18,
name: 'ETH',
symbol: 'ETH',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const USDC: SwapWidgetToken = {
chainId: 1,
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const USDC_ARB: SwapWidgetToken = {
chainId: 42161,
address: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const USDC_G7: SwapWidgetToken = {
chainId: 2187,
address: '0x401eCb1D350407f13ba348573E5630B83638E30D',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

// G7
export const G7: SwapWidgetToken = {
chainId: 1,
address: '0x12c88a3C30A7AaBC1dd7f2c08a97145F5DCcD830',
decimals: 18,
name: 'G7',
symbol: 'G7',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const G7_ARB = {
chainId: 42161,
address: '0xF18e4466F26B4cA55bbAb890b314a54976E45B17',
decimals: 18,
name: 'G7',
symbol: 'G7',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}

export const G7_G7 = {
chainId: 2187,
address: '0x0000000000000000000000000000000000000000',
decimals: 18,
name: 'G7',
symbol: 'G7',
logoURI: 'https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Ficon%2FgJEa5WUcw0RjBfGqTNof%2Fxai%20symbol%20red%20svg.svg?alt=media&token=9131a0bf-a73d-4052-a957-fd69884aee62'
}


export const TOKENS = [ETH, ETH_ARB, USDC, USDC_ARB, USDC_G7, G7, G7_ARB, G7_G7]

0 comments on commit 14e6e4a

Please sign in to comment.