dagger-contracts/test/marketplace.js

24 lines
700 B
JavaScript
Raw Normal View History

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