Skip to content

Commit

Permalink
Renames to customRpcs (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
abtestingalpha authored Jan 5, 2024
1 parent 59dc92b commit eb55b48
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 15 deletions.
8 changes: 4 additions & 4 deletions examples/with-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import {
USDT,
DAI,
ETH,
CustomFallbackRpcs,
CustomRpcs,
} from '@abtestingalpha/widget'
import { useEthereumWallet } from './hooks/useEthereumWallet'
import { BaseSyntheticEvent, SyntheticEvent, useState } from 'react'
import { useState } from 'react'
import Header from './Header'
import Footer from './Footer'
import { Install, Developer, Support } from './icons'

const tokens = [USDC, USDT, DAI, ETH]

const fallbackRpcs: CustomFallbackRpcs = {
const customRpcs: CustomRpcs = {
1: 'https://eth.llamarpc.com',
42161: 'https://arbitrum.llamarpc.com',
}
Expand Down Expand Up @@ -96,7 +96,7 @@ function App() {
>
<Bridge
web3Provider={web3Provider}
fallbackRpcs={fallbackRpcs}
customRpcs={customRpcs}
tokens={tokens}
customTheme={customTheme}
container={container}
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CHAINS_ARRAY } from './constants/chains'

export const Bridge = ({
web3Provider,
fallbackRpcs,
customRpcs,
theme,
customTheme,
container,
Expand All @@ -26,7 +26,7 @@ export const Bridge = ({
}: WidgetProps) => {
return (
<Web3Provider config={web3Provider}>
<SynapseProvider chains={CHAINS_ARRAY} fallbackRpcs={fallbackRpcs}>
<SynapseProvider chains={CHAINS_ARRAY} customRpcs={customRpcs}>
<Provider store={store}>
<TransactionsUpdater />
<Widget
Expand Down
10 changes: 5 additions & 5 deletions src/providers/SynapseProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
StaticJsonRpcProvider,
FallbackProvider,
} from '@ethersproject/providers'
import { Chain, CustomFallbackRpcs } from 'types'
import { Chain, CustomRpcs } from 'types'

export const SynapseContext = createContext(null)

Expand All @@ -14,11 +14,11 @@ export const SynapseProvider = memo(
({
children,
chains,
fallbackRpcs,
customRpcs,
}: {
children: React.ReactNode
chains: Chain[]
fallbackRpcs?: CustomFallbackRpcs
customRpcs?: CustomRpcs
}) => {
const synapseProviders = useMemo(() => {
return chains.map((chain) => {
Expand All @@ -27,9 +27,9 @@ export const SynapseProvider = memo(

/** Include Consumer custom rpc if provided */
/** Consumer provided rpc will have highest priority */
if (fallbackRpcs && fallbackRpcs[chain.id]) {
if (customRpcs && customRpcs[chain.id]) {
providers = [
new StaticJsonRpcProvider(fallbackRpcs[chain.id], chain.id),
new StaticJsonRpcProvider(customRpcs[chain.id], chain.id),
new StaticJsonRpcProvider(chain.rpcUrls.primary, chain.id),
new StaticJsonRpcProvider(chain.rpcUrls.fallback, chain.id),
]
Expand Down
63 changes: 59 additions & 4 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface CustomThemeVariables {
}

// TODO: Determine if this type if needed, or move to correct location
export type CustomFallbackRpcs = {
export type CustomRpcs = {
[chainId: number]: string
}

Expand All @@ -34,7 +34,7 @@ export interface WidgetProps {
web3Provider?: JsonRpcApiProvider | BrowserProvider

/** Consumer selected RPCs */
fallbackRpcs?: CustomFallbackRpcs
customRpcs?: CustomRpcs

/** Selected Day/Night Theme */
theme?: 'light' | 'dark'
Expand Down Expand Up @@ -66,8 +66,63 @@ export interface Chain {

export declare function Bridge(props: WidgetProps): JSX.Element

export declare const USDC: BridgeableToken
export declare const USDT: BridgeableToken
export declare const AGEUR: BridgeableToken
export declare const AVAX: BridgeableToken
export declare const BTCB: BridgeableToken
export declare const BUSD: BridgeableToken
export declare const CRVUSD: BridgeableToken
export declare const DAI: BridgeableToken
export declare const DAIe: BridgeableToken
export declare const DOG: BridgeableToken
export declare const ETH: BridgeableToken
export declare const FRAX: BridgeableToken
export declare const FTM: BridgeableToken
export declare const GMX: BridgeableToken
export declare const GOHM: BridgeableToken
export declare const H2O: BridgeableToken
export declare const HIGH: BridgeableToken
export declare const JEWEL: BridgeableToken
export declare const JUMP: BridgeableToken
export declare const KLAY: BridgeableToken
export declare const L2DAO: BridgeableToken
export declare const LINK: BridgeableToken
export declare const LUSD: BridgeableToken
export declare const MATIC: BridgeableToken
export declare const METISUSDC: BridgeableToken
export declare const MOVR: BridgeableToken
export declare const NETH: BridgeableToken
export declare const NEWO: BridgeableToken
export declare const NFD: BridgeableToken
export declare const NOTE: BridgeableToken
export declare const NUSD: BridgeableToken
export declare const ONEDAI: BridgeableToken
export declare const ONEETH: BridgeableToken
export declare const ONEUSDC: BridgeableToken
export declare const ONEUSDT: BridgeableToken
export declare const PEPE: BridgeableToken
export declare const PLS: BridgeableToken
export declare const SDT: BridgeableToken
export declare const SFI: BridgeableToken
export declare const SOLAR: BridgeableToken
export declare const SUSD: BridgeableToken
export declare const SYN: BridgeableToken
export declare const SYNFRAX: BridgeableToken
export declare const SYNJEWEL: BridgeableToken
export declare const UNIDX: BridgeableToken
export declare const USDBC: BridgeableToken
export declare const USDC: BridgeableToken
export declare const USDCe: BridgeableToken
export declare const USDT: BridgeableToken
export declare const USDTe: BridgeableToken
export declare const VSTA: BridgeableToken
export declare const WAVAX: BridgeableToken
export declare const WBTC: BridgeableToken
export declare const WETH: BridgeableToken
export declare const WETHE: BridgeableToken
export declare const WFTM: BridgeableToken
export declare const WJEWEL: BridgeableToken
export declare const WKLAY: BridgeableToken
export declare const WMATIC: BridgeableToken
export declare const WMOVR: BridgeableToken
export declare const WSOHM: BridgeableToken
export declare const XJEWEL: BridgeableToken

0 comments on commit eb55b48

Please sign in to comment.