diff --git a/contracts/crosschain/axelar/AxelarGatewayDestination.sol b/contracts/crosschain/axelar/AxelarGatewayDestination.sol index e8d3c1ae..27a68ae6 100644 --- a/contracts/crosschain/axelar/AxelarGatewayDestination.sol +++ b/contracts/crosschain/axelar/AxelarGatewayDestination.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.27; import {AxelarExecutable} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/executable/AxelarExecutable.sol"; -import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {StringsUnreleased} from "../../utils/Strings.sol"; import {CAIP2} from "../../utils/CAIP-2.sol"; import {CAIP10} from "../../utils/CAIP-10.sol"; @@ -12,8 +11,8 @@ import {IGatewayDestinationPassive} from "../interfaces/IGatewayDestinationPassi import {IGatewayReceiver} from "../interfaces/IGatewayReceiver.sol"; abstract contract AxelarGatewayDestination is IGatewayDestinationPassive, AxelarGatewayBase, AxelarExecutable { - using Strings for address; - using Strings for string; + using StringsUnreleased for address; + using StringsUnreleased for string; /// @dev Passive mode function validateReceivedMessage( @@ -29,7 +28,7 @@ abstract contract AxelarGatewayDestination is IGatewayDestinationPassive, Axelar // Rebuild expected package bytes memory adapterPayload = abi.encode( sender, - msg.sender.toHexString(), // receiver + msg.sender.toChecksumHexString(), // receiver payload, attributes ); @@ -71,7 +70,7 @@ abstract contract AxelarGatewayDestination is IGatewayDestinationPassive, Axelar require(getRemoteGateway(source).equal(remoteAccount), "Invalid origin gateway"); // Active mode - IGatewayReceiver(StringsUnreleased.parseAddress(receiver)).receiveMessage( + IGatewayReceiver(receiver.parseAddress()).receiveMessage( address(0), // not needed in active mode new bytes(0), // not needed in active mode source, diff --git a/contracts/crosschain/axelar/AxelarGatewaySource.sol b/contracts/crosschain/axelar/AxelarGatewaySource.sol index 7a722bdc..a4cfc125 100644 --- a/contracts/crosschain/axelar/AxelarGatewaySource.sol +++ b/contracts/crosschain/axelar/AxelarGatewaySource.sol @@ -4,12 +4,12 @@ pragma solidity ^0.8.27; import {AxelarGatewayBase} from "./AxelarGatewayBase.sol"; import {IGatewaySource} from "../interfaces/IGatewaySource.sol"; -import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; +import {StringsUnreleased} from "../../utils/Strings.sol"; import {CAIP2} from "../../utils/CAIP-2.sol"; import {CAIP10} from "../../utils/CAIP-10.sol"; abstract contract AxelarGatewaySource is IGatewaySource, AxelarGatewayBase { - using Strings for address; + using StringsUnreleased for address; function supportsAttribute(bytes4 /*selector*/) public view virtual returns (bool) { return false; @@ -29,7 +29,7 @@ abstract contract AxelarGatewaySource is IGatewaySource, AxelarGatewayBase { } // Create the package - string memory sender = msg.sender.toHexString(); + string memory sender = msg.sender.toChecksumHexString(); bytes memory adapterPayload = abi.encode(sender, receiver, payload, attributes); // Emit event diff --git a/contracts/crosschain/mocks/AxelarGatewayMock.sol b/contracts/crosschain/mocks/AxelarGatewayMock.sol index 6c2424f8..50ba7a96 100644 --- a/contracts/crosschain/mocks/AxelarGatewayMock.sol +++ b/contracts/crosschain/mocks/AxelarGatewayMock.sol @@ -5,11 +5,11 @@ pragma solidity ^0.8.27; import {IAxelarGateway} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol"; import {IAxelarExecutable} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarExecutable.sol"; import {BitMaps} from "@openzeppelin/contracts/utils/structs/BitMaps.sol"; -import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {StringsUnreleased} from "../../utils/Strings.sol"; contract AxelarGatewayMock { - using Strings for address; + using StringsUnreleased for address; + using StringsUnreleased for string; using BitMaps for BitMaps.BitMap; bool private activeMode; @@ -42,7 +42,12 @@ contract AxelarGatewayMock { ); bytes32 commandId = keccak256( - abi.encode(destinationChain, msg.sender.toHexString(), destinationContractAddress, keccak256(payload)) + abi.encode( + destinationChain, + msg.sender.toChecksumHexString(), + destinationContractAddress, + keccak256(payload) + ) ); require(!pendingCommandIds.get(uint256(commandId))); @@ -53,8 +58,8 @@ contract AxelarGatewayMock { if (activeMode) { // NOTE: // - source chain and destination chain are the same in this mock - address target = StringsUnreleased.parseAddress(destinationContractAddress); - IAxelarExecutable(target).execute(commandId, destinationChain, msg.sender.toHexString(), payload); + address target = destinationContractAddress.parseAddress(); + IAxelarExecutable(target).execute(commandId, destinationChain, msg.sender.toChecksumHexString(), payload); } } @@ -70,7 +75,8 @@ contract AxelarGatewayMock { emit IAxelarGateway.ContractCallExecuted(commandId); return - commandId == keccak256(abi.encode(sourceChain, sourceAddress, msg.sender.toHexString(), payloadHash)); + commandId == + keccak256(abi.encode(sourceChain, sourceAddress, msg.sender.toChecksumHexString(), payloadHash)); } else return false; } } diff --git a/contracts/utils/CAIP-10.sol b/contracts/utils/CAIP-10.sol index 70ced580..c41712fc 100644 --- a/contracts/utils/CAIP-10.sol +++ b/contracts/utils/CAIP-10.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; -import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; +import {StringsUnreleased} from "./Strings.sol"; import {Bytes} from "./Bytes.sol"; import {CAIP2} from "./CAIP-2.sol"; @@ -12,11 +12,11 @@ import {CAIP2} from "./CAIP-2.sol"; // account_address: [-.%a-zA-Z0-9]{1,128} library CAIP10 { using SafeCast for uint256; - using Strings for address; + using StringsUnreleased for address; using Bytes for bytes; function local(address account) internal view returns (string memory) { - return format(CAIP2.local(), account.toHexString()); + return format(CAIP2.local(), account.toChecksumHexString()); } function format(string memory caip2, string memory account) internal pure returns (string memory) { diff --git a/test/crosschain/axelar/AxelarGateway.test.js b/test/crosschain/axelar/AxelarGateway.test.js index d1ccda71..85c0561c 100644 --- a/test/crosschain/axelar/AxelarGateway.test.js +++ b/test/crosschain/axelar/AxelarGateway.test.js @@ -3,7 +3,7 @@ const { expect } = require('chai'); const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); const { anyValue } = require('@nomicfoundation/hardhat-chai-matchers/withArgs'); -const getAddress = account => (account.target ?? account.address ?? account).toLowerCase(); +const getAddress = account => ethers.getAddress(account.target ?? account.address ?? account); async function fixture() { const [owner, sender, ...accounts] = await ethers.getSigners(); diff --git a/test/crosschain/utils/CAIP.test.js b/test/crosschain/utils/CAIP.test.js index c649354f..b1da211d 100644 --- a/test/crosschain/utils/CAIP.test.js +++ b/test/crosschain/utils/CAIP.test.js @@ -37,7 +37,7 @@ describe('CAIP utilities', function () { it(`local(${account})`, async function () { // lowercase encoding for now - expect(await this.caip10.$local(ethers.Typed.address(account))).to.equal(format('eip155', this.chainId, account.toLowerCase())); + expect(await this.caip10.$local(ethers.Typed.address(account))).to.equal(format('eip155', this.chainId, account)); }); for (const { account, caip2, caip10 } of Object.values(CHAINS))