Skip to content

Commit ffaa911

Browse files
committed
Implement mock interaction handling in HomeIndexRoute, adding mock data for contract address, chain ID, token address, and token amount to facilitate testing and development.
1 parent ac022b9 commit ffaa911

1 file changed

Lines changed: 41 additions & 8 deletions

File tree

extras/demo-anypay/src/routes/home/home-index-route.tsx

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,15 @@ const formatBalance = (balance: TokenBalance | NativeTokenBalance) => {
5353
}
5454

5555
// Mock Data
56-
// const MOCK_CONTRACT_ADDRESS = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'
57-
const MOCK_TRANSFER_DATA: Hex = `0xa9059cbb000000000000000000000000deadbeefdeadbeefdeadbeefdeadbeefdeadbeef00000000000000000000000000000000000000000000000000000000000f4240` // transfer(address,uint256) for 1 * 10^6
56+
const MOCK_CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000000'
57+
// Mock Calldata for interaction
58+
const MOCK_TRANSFER_DATA: Hex = `0xabcdef`
59+
// Mock Chain ID for interaction
60+
const MOCK_CHAIN_ID = chains.arbitrum.id
61+
// Mock Token Address for interaction on destination chain
62+
const MOCK_TOKEN_ADDRESS = '0x0000000000000000000000000000000000000000'
63+
// Mock Token Amount for interaction on destination chain
64+
const MOCK_TOKEN_AMOUNT = '300'
5865

5966
// Helper to get chain info
6067
const getChainInfo = (chainId: number) => {
@@ -171,18 +178,44 @@ export const HomeIndexRoute = () => {
171178
userAddress: account.address,
172179
originChainId: selectedToken.chainId || 8453,
173180
originTokenAddress: isOriginNative ? zeroAddress : selectedToken.contractAddress,
174-
destinationChainId: action === 'custom_call' ? parseInt(customCallData.chainId) : destinationCall.chainId,
175-
destinationToAddress: action === 'custom_call' ? customCallData.to : destinationCall.to,
176-
destinationTokenAddress: action === 'custom_call' ? customCallData.tokenAddress : USDC_ADDRESS,
181+
destinationChainId:
182+
action === 'custom_call'
183+
? parseInt(customCallData.chainId)
184+
: action === 'mock_interaction'
185+
? MOCK_CHAIN_ID
186+
: destinationCall.chainId,
187+
destinationToAddress:
188+
action === 'custom_call'
189+
? customCallData.to
190+
: action === 'mock_interaction'
191+
? MOCK_CONTRACT_ADDRESS
192+
: destinationCall.to,
193+
destinationTokenAddress:
194+
action === 'custom_call'
195+
? customCallData.tokenAddress
196+
: action === 'mock_interaction'
197+
? MOCK_TOKEN_ADDRESS
198+
: USDC_ADDRESS,
177199
destinationTokenAmount:
178-
action === 'custom_call' ? customCallData.tokenAmount : action === 'pay' ? AMOUNT.toString() : '0',
200+
action === 'custom_call'
201+
? customCallData.tokenAmount
202+
: action === 'mock_interaction'
203+
? MOCK_TOKEN_AMOUNT
204+
: AMOUNT.toString(),
179205
destinationCallData:
180206
action === 'custom_call'
181207
? customCallData.data.startsWith('0x')
182208
? customCallData.data
183209
: `0x${customCallData.data}`
184-
: destinationCall.transactionData,
185-
destinationCallValue: action === 'custom_call' ? customCallData.value : destinationCall.transactionValue,
210+
: action === 'mock_interaction'
211+
? MOCK_TRANSFER_DATA
212+
: destinationCall.transactionData,
213+
destinationCallValue:
214+
action === 'custom_call'
215+
? customCallData.value
216+
: action === 'mock_interaction'
217+
? MOCK_TOKEN_AMOUNT
218+
: destinationCall.transactionValue,
186219
}
187220

188221
console.log('Calling createIntentConfig with args:', args)

0 commit comments

Comments
 (0)