From 09213be4badc6ec51bd0c1570d9f1b10ca509f60 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 6 Dec 2024 18:23:53 +0300 Subject: [PATCH] bitcoin chain id --- examples/swap/contracts/Swap.sol | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/examples/swap/contracts/Swap.sol b/examples/swap/contracts/Swap.sol index 0904ed3..caf0ce8 100644 --- a/examples/swap/contracts/Swap.sol +++ b/examples/swap/contracts/Swap.sol @@ -24,7 +24,8 @@ contract Swap is { address public uniswapRouter; GatewayZEVM public gateway; - uint256 constant BITCOIN = 18332; + uint256 constant BITCOIN = 8332; + uint256 constant BITCOIN_TESTNET = 18332; uint256 public gasLimit; error InvalidAddress(); @@ -32,6 +33,15 @@ contract Swap is error ApprovalFailed(); error TransferFailed(); + event TokenSwap( + address sender, + bytes indexed recipient, + address indexed inputToken, + address indexed targetToken, + uint256 inputAmount, + uint256 outputAmount + ); + modifier onlyGateway() { if (msg.sender != address(gateway)) revert Unauthorized(); _; @@ -75,7 +85,7 @@ contract Swap is withdraw: true }); - if (context.chainID == BITCOIN) { + if (context.chainID == BITCOIN_TESTNET || context.chainID == BITCOIN) { params.target = BytesHelperLib.bytesToAddress(message, 0); params.to = abi.encodePacked( BytesHelperLib.bytesToAddress(message, 20) @@ -99,6 +109,14 @@ contract Swap is amount, params.target ); + emit TokenSwap( + context.sender, + params.to, + zrc20, + params.target, + amount, + out + ); withdraw(params, context.sender, gasFee, gasZRC20, out, zrc20); } @@ -123,7 +141,14 @@ contract Swap is amount, targetToken ); - + emit TokenSwap( + msg.sender, + recipient, + inputToken, + targetToken, + amount, + out + ); withdraw( Params({ target: targetToken,