From a674ace960f1e4bcb90e9459957a753d90282503 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Thu, 7 Nov 2024 10:48:13 +0300 Subject: [PATCH] refactor --- examples/nft/contracts/Connected.sol | 17 ++++++----------- examples/nft/contracts/Universal.sol | 6 +++--- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/examples/nft/contracts/Connected.sol b/examples/nft/contracts/Connected.sol index a0c1dc13..34513668 100644 --- a/examples/nft/contracts/Connected.sol +++ b/examples/nft/contracts/Connected.sol @@ -52,37 +52,32 @@ contract Connected is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable { ) external payable { string memory uri = tokenURI(tokenId); _burn(tokenId); - bytes memory encodedData = abi.encode( - tokenId, - receiver, - uri, - destination - ); + bytes memory message = abi.encode(tokenId, receiver, uri, destination); RevertOptions memory revertOptions = RevertOptions( address(this), true, address(0), - encodedData, + message, 0 ); if (destination == address(0)) { - gateway.call(counterparty, encodedData, revertOptions); + gateway.call(counterparty, message, revertOptions); } else { gateway.depositAndCall{value: msg.value}( counterparty, - encodedData, + message, revertOptions ); } } function onCall( - MessageContext calldata messageContext, + MessageContext calldata context, bytes calldata message ) external payable onlyGateway returns (bytes4) { - if (messageContext.sender != counterparty) revert("Unauthorized"); + if (context.sender != counterparty) revert("Unauthorized"); (uint256 tokenId, address receiver, string memory uri) = abi.decode( message, diff --git a/examples/nft/contracts/Universal.sol b/examples/nft/contracts/Universal.sol index b5c5f6a0..83898337 100644 --- a/examples/nft/contracts/Universal.sol +++ b/examples/nft/contracts/Universal.sol @@ -70,7 +70,7 @@ contract Universal is !IZRC20(destination).transferFrom(msg.sender, address(this), gasFee) ) revert TransferFailed(); IZRC20(destination).approve(address(gateway), gasFee); - bytes memory encodedData = abi.encode(tokenId, receiver, uri); + bytes memory message = abi.encode(tokenId, receiver, uri); CallOptions memory callOptions = CallOptions(gasLimit, false); @@ -78,14 +78,14 @@ contract Universal is address(this), true, address(0), - encodedData, + message, gasLimit ); gateway.call( counterparty[destination], destination, - encodedData, + message, callOptions, revertOptions );