-
Notifications
You must be signed in to change notification settings - Fork 192
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
feat: show Ether for custom gas token chains #1764
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -90,7 +90,7 @@ const ArbTokenBridgeStoreSyncWrapper = (): JSX.Element | null => { | |||
selectedTokenAddress === nativeCurrency.address || | |||
selectedTokenL2Address === nativeCurrency.address | |||
) { | |||
actions.app.setSelectedToken(null) | |||
actions.app.setSelectedToken({ token: null }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setSelectedToken
payload has changed to include an optional flag isSelectedTokenEther
.
When isSelectedTokenEther === true
and token === null
, everything will assume that the native currency is Ether.
When isSelectedTokenEther === false
and token === null
, everything will work as previously, which means it will default to the native currency on the child chain. Note this still could be ETH, isSelectedTokenEther
just serves as an override to cover custom gas token scenarios.
When isSelectedTokenEther
is not provided it will always set it to false
, so that we don't have to refactor the majority of the existing code. All we have to do is to pass a token
object instead.
See actions.ts
and state.ts
for more.
} = useAppState() | ||
const [networks] = useNetworks() | ||
const { childChainProvider } = useNetworksRelationship(networks) | ||
|
||
const nativeCurrency = useNativeCurrency({ provider: childChainProvider }) | ||
|
||
const tokenLogo = useMemo<string | undefined>(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used
function TokenListInfo({ | ||
token | ||
}: { | ||
token: ERC20BridgeToken | NativeCurrencyEther | null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, and in some of the following methods, we pass an additional NativeCurrencyEther
. This way we can check for it and return ETH details as needed.
const { isCustom: childChainNativeCurrencyIsCustom } = useNativeCurrency({ | ||
provider: childChainProvider | ||
}) | ||
|
||
const tokenListInfo = useMemo(() => { | ||
if (isNativeCurrencyEther(token)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isNativeCurrencyEther
is a type guard method that checks for NativeCurrencyEther
type. This way we can early check for ETH stuff and keep the rest of the code as-is.
See useNativeCurrency.ts
for more.
…e into detect-eth-custom-gas-fee
ETH transfers to custom gas token chains PR no. 1
This will be hidden behind a feature flag.
This is a prerequisite for https://linear.app/offchain-labs/issue/FS-139/enable-wrapping-eth-and-depositing-into-a-custom-gas-token-network.
It allows us to select ETH for custom gas token chains. For now only ETH detection and being able to select it has been implemented and can be merged on its own.
Testing