|
| 1 | +/** |
| 2 | + * @vitest-environment node |
| 3 | + */ |
| 4 | +import { describe, expect, it } from 'vitest'; |
| 5 | + |
| 6 | +import { ChainId } from '../../types/ChainId'; |
| 7 | +import { CommonAddress } from '../CommonAddressUtils'; |
| 8 | +import { isWithdrawOnlyToken } from '../WithdrawOnlyUtils'; |
| 9 | + |
| 10 | +const networkTestTimeout = 10000; |
| 11 | + |
| 12 | +describe('isWithdrawOnlyToken', () => { |
| 13 | + const orbitChainId = 660279; // Xai |
| 14 | + |
| 15 | + it('should allow deposits for a standard token', async () => { |
| 16 | + const result = await isWithdrawOnlyToken({ |
| 17 | + parentChainErc20Address: '0x1234567890123456789012345678901234567890', |
| 18 | + parentChainId: ChainId.Ethereum, |
| 19 | + childChainId: ChainId.ArbitrumOne, |
| 20 | + }); |
| 21 | + expect(result).toBe(false); |
| 22 | + }); |
| 23 | + |
| 24 | + it('should block deposits for a token in the withdraw-only list', async () => { |
| 25 | + const result = await isWithdrawOnlyToken({ |
| 26 | + parentChainErc20Address: '0x99D8a9C45b2ecA8864373A26D1459e3Dff1e17F3', // MIM on Arbitrum One |
| 27 | + parentChainId: ChainId.Ethereum, |
| 28 | + childChainId: ChainId.ArbitrumOne, |
| 29 | + }); |
| 30 | + expect(result).toBe(true); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should block deposits for USDC.e on an Orbit chain', async () => { |
| 34 | + const result = await isWithdrawOnlyToken({ |
| 35 | + parentChainErc20Address: CommonAddress.ArbitrumOne['USDC.e'], |
| 36 | + parentChainId: ChainId.ArbitrumOne, |
| 37 | + childChainId: orbitChainId, |
| 38 | + }); |
| 39 | + expect(result).toBe(true); |
| 40 | + }); |
| 41 | + |
| 42 | + it('should allow deposits for USDC.e on a non-Orbit chain', async () => { |
| 43 | + const result = await isWithdrawOnlyToken({ |
| 44 | + parentChainErc20Address: CommonAddress.ArbitrumOne['USDC.e'], |
| 45 | + parentChainId: ChainId.Ethereum, |
| 46 | + childChainId: ChainId.ArbitrumOne, |
| 47 | + }); |
| 48 | + expect(result).toBe(false); |
| 49 | + }); |
| 50 | + |
| 51 | + it( |
| 52 | + 'should block deposits for a non-USDT LayerZero token', |
| 53 | + async () => { |
| 54 | + const result = await isWithdrawOnlyToken({ |
| 55 | + parentChainErc20Address: '0x57e114b691db790c35207b2e685d4a43181e6061', // ENA |
| 56 | + parentChainId: ChainId.Ethereum, |
| 57 | + childChainId: ChainId.ArbitrumOne, |
| 58 | + }); |
| 59 | + expect(result).toBe(true); |
| 60 | + }, |
| 61 | + { timeout: networkTestTimeout }, |
| 62 | + ); |
| 63 | + |
| 64 | + it( |
| 65 | + 'should allow deposits for USDT as a special case', |
| 66 | + async () => { |
| 67 | + const usdtAddress = CommonAddress.Ethereum.USDT; |
| 68 | + |
| 69 | + const result = await isWithdrawOnlyToken({ |
| 70 | + parentChainErc20Address: usdtAddress, |
| 71 | + parentChainId: ChainId.Ethereum, |
| 72 | + childChainId: ChainId.ArbitrumOne, |
| 73 | + }); |
| 74 | + expect(result).toBe(false); |
| 75 | + }, |
| 76 | + { timeout: networkTestTimeout }, |
| 77 | + ); |
| 78 | + |
| 79 | + it( |
| 80 | + 'should allow deposits for a token not in LayerZero metadata', |
| 81 | + async () => { |
| 82 | + const result = await isWithdrawOnlyToken({ |
| 83 | + parentChainErc20Address: '0x9876543210987654321098765432109876543210', |
| 84 | + parentChainId: ChainId.Ethereum, |
| 85 | + childChainId: ChainId.ArbitrumOne, |
| 86 | + }); |
| 87 | + expect(result).toBe(false); |
| 88 | + }, |
| 89 | + { timeout: networkTestTimeout }, |
| 90 | + ); |
| 91 | +}); |
0 commit comments