-
Notifications
You must be signed in to change notification settings - Fork 0
feat: enhance OFT token detection to block deposits #147
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
Open
dewanshparashar
wants to merge
7
commits into
master
Choose a base branch
from
enhanced-oft-detection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+302
−20
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3b37d4e
feat: enhance OFT token detection to block deposits
dewanshparashar f6f1df4
dev: tests passing
dewanshparashar 6d05883
dev: enhance logic further
dewanshparashar 1ff3489
dev: add fallback
dewanshparashar 7967eb1
dev: fallback to orbit chain detection
dewanshparashar fc0313d
formatting
dewanshparashar 11a454f
dev: orbit chain reg
dewanshparashar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
packages/arb-token-bridge-ui/src/util/__tests__/WithdrawOnlyUtils.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { ChainId } from '../../types/ChainId'; | ||
| import { CommonAddress } from '../CommonAddressUtils'; | ||
| import { isWithdrawOnlyToken } from '../WithdrawOnlyUtils'; | ||
|
|
||
| const networkTestTimeout = 10000; | ||
|
|
||
| describe('isWithdrawOnlyToken', () => { | ||
| const orbitChainId = 660279; // Xai | ||
|
|
||
| it('should allow deposits for a standard token', async () => { | ||
| const result = await isWithdrawOnlyToken({ | ||
| parentChainErc20Address: '0x1234567890123456789012345678901234567890', | ||
| parentChainId: ChainId.Ethereum, | ||
| childChainId: ChainId.ArbitrumOne, | ||
| }); | ||
| expect(result).toBe(false); | ||
| }); | ||
|
|
||
| it('should block deposits for a token in the withdraw-only list', async () => { | ||
| const result = await isWithdrawOnlyToken({ | ||
| parentChainErc20Address: '0x99D8a9C45b2ecA8864373A26D1459e3Dff1e17F3', // MIM on Arbitrum One | ||
| parentChainId: ChainId.Ethereum, | ||
| childChainId: ChainId.ArbitrumOne, | ||
| }); | ||
| expect(result).toBe(true); | ||
| }); | ||
|
|
||
| it('should block deposits for USDC.e on an Orbit chain', async () => { | ||
| const result = await isWithdrawOnlyToken({ | ||
| parentChainErc20Address: CommonAddress.ArbitrumOne['USDC.e'], | ||
| parentChainId: ChainId.ArbitrumOne, | ||
| childChainId: orbitChainId, | ||
| }); | ||
| expect(result).toBe(true); | ||
| }); | ||
|
|
||
| it('should allow deposits for USDC.e on a non-Orbit chain', async () => { | ||
| const result = await isWithdrawOnlyToken({ | ||
| parentChainErc20Address: CommonAddress.ArbitrumOne['USDC.e'], | ||
| parentChainId: ChainId.Ethereum, | ||
|
Comment on lines
+54
to
+55
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't make any sense because the parent chain is Ethereum so the ERC20 address should be the one on Ethereum instead of Arbitrum One |
||
| childChainId: ChainId.ArbitrumOne, | ||
| }); | ||
| expect(result).toBe(false); | ||
| }); | ||
|
|
||
| it( | ||
| 'should block deposits for a non-USDT LayerZero token', | ||
| async () => { | ||
| const result = await isWithdrawOnlyToken({ | ||
| parentChainErc20Address: '0x57e114b691db790c35207b2e685d4a43181e6061', // ENA | ||
| parentChainId: ChainId.Ethereum, | ||
| childChainId: ChainId.ArbitrumOne, | ||
| }); | ||
| expect(result).toBe(true); | ||
| }, | ||
| { timeout: networkTestTimeout }, | ||
| ); | ||
|
|
||
| it( | ||
| 'should allow deposits for USDT as a special case', | ||
| async () => { | ||
| const usdtAddress = CommonAddress.Ethereum.USDT; | ||
|
|
||
| const result = await isWithdrawOnlyToken({ | ||
| parentChainErc20Address: usdtAddress, | ||
| parentChainId: ChainId.Ethereum, | ||
| childChainId: ChainId.ArbitrumOne, | ||
| }); | ||
| expect(result).toBe(false); | ||
| }, | ||
| { timeout: networkTestTimeout }, | ||
| ); | ||
|
|
||
| it( | ||
| 'should allow deposits for a token not in LayerZero metadata', | ||
| async () => { | ||
| const result = await isWithdrawOnlyToken({ | ||
| parentChainErc20Address: '0x9876543210987654321098765432109876543210', | ||
| parentChainId: ChainId.Ethereum, | ||
| childChainId: ChainId.ArbitrumOne, | ||
| }); | ||
| expect(result).toBe(false); | ||
| }, | ||
| { timeout: networkTestTimeout }, | ||
| ); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.