2021-10-12 14:59:34 +00:00
|
|
|
const { ethers } = require("hardhat")
|
|
|
|
|
2021-10-14 12:49:29 +00:00
|
|
|
function hashRequest(duration, size, hash, proofPeriod, proofTimeout) {
|
2021-10-12 14:59:34 +00:00
|
|
|
return ethers.utils.solidityKeccak256(
|
2021-10-14 12:49:29 +00:00
|
|
|
["string", "uint", "uint", "bytes32", "uint", "uint"],
|
|
|
|
["[dagger.request.v1]", duration, size, hash, proofPeriod, proofTimeout]
|
2021-10-12 14:59:34 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-10-18 13:29:58 +00:00
|
|
|
function hashBid(requestHash, expiry, price) {
|
2021-10-12 14:59:34 +00:00
|
|
|
return ethers.utils.solidityKeccak256(
|
2021-10-18 13:29:58 +00:00
|
|
|
["string", "bytes32", "uint", "uint"],
|
|
|
|
["[dagger.bid.v1]", requestHash, expiry, price]
|
2021-10-12 14:59:34 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function sign(signer, hash) {
|
|
|
|
return await signer.signMessage(ethers.utils.arrayify(hash))
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { hashRequest, hashBid, sign }
|