Use standard ABI encoding instead of the non-standard

packing mode.
This commit is contained in:
Mark Spanbroek 2021-11-24 11:43:31 +01:00
parent b9a9be350a
commit 0fedd8875f
2 changed files with 6 additions and 6 deletions

View File

@ -94,7 +94,7 @@ contract Contracts {
private pure
returns (bytes32)
{
return keccak256(abi.encodePacked(
return keccak256(abi.encode(
"[dagger.request.v1]",
duration,
size,
@ -110,7 +110,7 @@ contract Contracts {
private pure
returns (bytes32)
{
return keccak256(abi.encodePacked(
return keccak256(abi.encode(
"[dagger.bid.v1]",
requestHash,
expiry,

View File

@ -4,18 +4,18 @@ function hashRequest({
duration, size, contentHash, proofPeriod, proofTimeout, nonce
}) {
const type = "[dagger.request.v1]"
return ethers.utils.solidityKeccak256(
return ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode(
["string", "uint", "uint", "bytes32", "uint", "uint", "bytes32"],
[type, duration, size, contentHash, proofPeriod, proofTimeout, nonce]
)
))
}
function hashBid({requestHash, bidExpiry, price}) {
const type = "[dagger.bid.v1]"
return ethers.utils.solidityKeccak256(
return ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode(
["string", "bytes32", "uint", "uint"],
[type, requestHash, bidExpiry, price]
)
))
}
async function sign(signer, hash) {