The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
hyperlane-monorepo/solidity/scripts/utils.js

40 lines
1012 B

async function reportTxOutcome(tx, confs) {
confs = confs ? confs : 1;
console.log(`\tSent tx with ID ${tx.hash} to ${tx.to}`);
console.log(`\tWaiting for ${confs} confs`);
return await tx.wait(confs);
}
// turn a tightly packed proof into an array
async function parseProof(rawProof) {
return ethers.utils.defaultAbiCoder.decode(['bytes32[32]'], rawProof);
}
async function validateUpdate(oldRoot, newRoot, signature, slip44) {
if (!ethers.utils.isHexString(oldRoot, 32)) {
throw new Error('oldRoot must be a 32-byte 0x prefixed hex string');
}
if (!ethers.utils.isHexString(newRoot, 32)) {
throw new Error('newRoot must be a 32-byte 0x prefixed hex string');
}
if (!ethers.utils.isHexString(signature, 65)) {
throw new Error('signature must be a 65-byte 0x prefixed hex string');
}
if (slip44) {
// TODO: validate the signature
}
return {
oldRoot,
newRoot,
signature,
};
}
module.exports = {
reportTxOutcome,
parseProof,
validateUpdate,
};