|
|
|
@ -245,7 +245,7 @@ describe('Swaps Util', () => { |
|
|
|
|
).toBe(true); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('returns false if "token_from" is ETH, "token_to" is WETH and "to" is mainnet contract address', () => { |
|
|
|
|
it('returns true if "token_from" is ETH, "token_to" is WETH and "to" is mainnet contract address', () => { |
|
|
|
|
usedTradeTxParams.to = |
|
|
|
|
SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[MAINNET_CHAIN_ID]; |
|
|
|
|
expect( |
|
|
|
@ -254,14 +254,38 @@ describe('Swaps Util', () => { |
|
|
|
|
swapMetaData, |
|
|
|
|
MAINNET_CHAIN_ID, |
|
|
|
|
), |
|
|
|
|
).toBe(false); |
|
|
|
|
).toBe(true); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('returns false if "token_from" is WETH, "token_to" is ETH and "to" is mainnet contract address', () => { |
|
|
|
|
it('returns true if "token_from" is WETH, "token_to" is ETH and "to" is mainnet contract address', () => { |
|
|
|
|
swapMetaData.token_from = WETH_SYMBOL; |
|
|
|
|
swapMetaData.token_to = ETH_SYMBOL; |
|
|
|
|
usedTradeTxParams.to = |
|
|
|
|
SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[MAINNET_CHAIN_ID]; |
|
|
|
|
expect( |
|
|
|
|
isContractAddressValid( |
|
|
|
|
usedTradeTxParams.to, |
|
|
|
|
swapMetaData, |
|
|
|
|
MAINNET_CHAIN_ID, |
|
|
|
|
), |
|
|
|
|
).toBe(true); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('returns false if "token_from" is ETH, "token_to" is WETH and "to" is BSC contract address', () => { |
|
|
|
|
usedTradeTxParams.to = SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[BSC_CHAIN_ID]; |
|
|
|
|
expect( |
|
|
|
|
isContractAddressValid( |
|
|
|
|
usedTradeTxParams.to, |
|
|
|
|
swapMetaData, |
|
|
|
|
MAINNET_CHAIN_ID, |
|
|
|
|
), |
|
|
|
|
).toBe(false); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('returns false if "token_from" is WETH, "token_to" is ETH and "to" is BSC contract address', () => { |
|
|
|
|
swapMetaData.token_from = WETH_SYMBOL; |
|
|
|
|
swapMetaData.token_to = ETH_SYMBOL; |
|
|
|
|
usedTradeTxParams.to = SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[BSC_CHAIN_ID]; |
|
|
|
|
expect( |
|
|
|
|
isContractAddressValid( |
|
|
|
|
usedTradeTxParams.to, |
|
|
|
@ -277,6 +301,16 @@ describe('Swaps Util', () => { |
|
|
|
|
).toBe(false); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('returns false if chainId is incorrect', () => { |
|
|
|
|
expect( |
|
|
|
|
isContractAddressValid( |
|
|
|
|
usedTradeTxParams.to, |
|
|
|
|
swapMetaData, |
|
|
|
|
'incorrectChainId', |
|
|
|
|
), |
|
|
|
|
).toBe(false); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('returns true if "token_from" is BAT and "to" is mainnet contract address', () => { |
|
|
|
|
swapMetaData.token_from = 'BAT'; |
|
|
|
|
usedTradeTxParams.to = |
|
|
|
|