diff --git a/contracts/DIVAOwnershipSecondary.sol b/contracts/DIVAOwnershipSecondary.sol index 3e7ccdf..e1713ed 100644 --- a/contracts/DIVAOwnershipSecondary.sol +++ b/contracts/DIVAOwnershipSecondary.sol @@ -110,11 +110,14 @@ contract DIVAOwnershipSecondary is UsingTellor, IDIVAOwnershipSecondary { { // Construct Tellor queryData and queryId: // https://github.com/tellor-io/dataSpecs/blob/main/types/EVMCall.md - // 0xa18a186b = bytes4(keccak256(abi.encodePacked("getCurrentOwner()"))); queryData = abi.encode( "EVMCall", - abi.encode(_mainChainId, _ownershipContractMainChain, 0xa18a186b) + abi.encode( + _mainChainId, + _ownershipContractMainChain, + abi.encodeWithSignature("getCurrentOwner()") + ) ); queryId = keccak256(queryData); diff --git a/contracts/interfaces/IDIVAOwnershipSecondary.sol b/contracts/interfaces/IDIVAOwnershipSecondary.sol index 478f78e..a9cc262 100644 --- a/contracts/interfaces/IDIVAOwnershipSecondary.sol +++ b/contracts/interfaces/IDIVAOwnershipSecondary.sol @@ -48,7 +48,7 @@ interface IDIVAOwnershipSecondary is IDIVAOwnershipShared { * for reporting values to Tellor protocol. * @dev The query data is an encoded string consisting of the query type * string "EVMCall", the main chain Id (1 for Ethereum), the address of - * the ownership contract on main chain as well as the function signature of the main + * the ownership contract on main chain as well as the encoded function signature of the main * chain function `getCurrentOwner()` (`0xa18a186b`). The query Id is the `keccak256` * hash of the query Data. Refer to the Tellor specs * (https://github.com/tellor-io/dataSpecs/blob/main/types/EVMCall.md) diff --git a/package.json b/package.json index c95dbb6..856585c 100644 --- a/package.json +++ b/package.json @@ -103,8 +103,8 @@ "xdeployer": "^1.1.20" }, "dependencies": { - "@openzeppelin/contracts": "^4.7.3", - "@openzeppelin/contracts-upgradeable": "^4.8.0-rc.1", + "@openzeppelin/contracts": "^4.8.3", + "@openzeppelin/contracts-upgradeable": "^4.8.3", "eip-712": "^1.0.0", "trees": "^0.0.4" }, diff --git a/test/DIVAOwnershipSecondary.test.ts b/test/DIVAOwnershipSecondary.test.ts index a4c45d5..769af2e 100644 --- a/test/DIVAOwnershipSecondary.test.ts +++ b/test/DIVAOwnershipSecondary.test.ts @@ -22,17 +22,19 @@ const network = "goerli"; // for tellorPlayground address; should be the same as const mainChainId = 5; const getQueryDataAndId = (chainId: number, ownershipContractAddressMain: string): [string, string] => { - // 0xa18a186b = bytes4(keccak256(abi.encodePacked("getCurrentOwner"))); - // Encode bytes4 value according to the Ethereum ABI specification, i.e. pad it with leading zeros - // to fill an entire 32-byte (64 bits) slot. - const hexValue = 'a18a186b'; - const paddedHexValue = hexValue.padStart(64, '0'); - const prefixedHexValue = '0x' + paddedHexValue; // 00000000000000000000000000000000000000000000000000000000a18a186b + + // Perform equivalent of `abi.encodeWithSignature("getCurrentOwner()")` in Solidity using ethers + const ABI = [ + "function getCurrentOwner()" + ]; + const iface = new ethers.utils.Interface(ABI); + const encodedFunctionSignature = iface.encodeFunctionData("getCurrentOwner"); // 0xa18a186b + // Generate `queryData` and `queryId` const abiCoder = new ethers.utils.AbiCoder(); const queryDataArgs = abiCoder.encode( - ["uint256", "address", "bytes32"], - [chainId, ownershipContractAddressMain, prefixedHexValue] // 0xa18a186b = bytes4(keccak256(abi.encodePacked("getCurrentOwner"))); + ["uint256", "address", "bytes"], + [chainId, ownershipContractAddressMain, encodedFunctionSignature] ); const queryData = abiCoder.encode( ["string", "bytes"], diff --git a/test/EIP712.test.ts b/test/EIP712.test.ts index 41f56bb..10e8325 100644 --- a/test/EIP712.test.ts +++ b/test/EIP712.test.ts @@ -865,7 +865,7 @@ describe("EIP712", async function () { signature, offerCreateContingentPool.takerCollateralAmount ) - ).to.be.revertedWith("ECDSA: invalid signature 'v' value"); + ).to.be.revertedWith("ECDSA: invalid signature"); }); it("Reverts if offerExpiry has passed (offer status = EXPIRED)", async () => { @@ -3234,7 +3234,7 @@ describe("EIP712", async function () { signature, offerAddLiquidity.takerCollateralAmount ) - ).to.be.revertedWith("ECDSA: invalid signature 'v' value"); + ).to.be.revertedWith("ECDSA: invalid signature"); }); it("Reverts if offerExpiry has passed (offer status = EXPIRED)", async () => { @@ -5668,7 +5668,7 @@ describe("EIP712", async function () { signature, offerRemoveLiquidity.positionTokenAmount ) - ).to.be.revertedWith("ECDSA: invalid signature 'v' value"); + ).to.be.revertedWith("ECDSA: invalid signature"); }); it("Reverts if offerExpiry has passed (offer status = EXPIRED)", async () => {