feature: add optics Updater to global hre

buddies-main-deployment
James Prestwich 4 years ago committed by James Prestwich
parent fc7f2327f0
commit c40d6114a8
No known key found for this signature in database
GPG Key ID: 7CC174C250AD83AD
  1. 26
      solidity/lib/index.js

@ -25,6 +25,31 @@ extendEnvironment((hre) => {
}
}
class Updater {
constructor(signer, originSlip44) {
this.originSlip44 = originSlip44 ? originSlip44 : 0;
this.signer = signer;
}
domain() {
return ethers.utils.solidityKeccak256(
['uint32', 'string'],
[this.originSlip44, 'OPTICS'],
);
}
async signUpdate(oldRoot, newRoot) {
let message = ethers.utils.concat([this.domain(), oldRoot, newRoot]);
let signature = await this.signer.signMessage(message);
return {
origin: this.originSlip44,
newRoot,
oldRoot,
signature,
};
}
}
const getHomeFactory = async () => ethers.getContractFactory('Home');
const getReplicaFactory = async () =>
ethers.getContractFactory('ProcessingReplica');
@ -32,6 +57,7 @@ extendEnvironment((hre) => {
hre.optics = {
Home,
Replica,
Updater,
getHomeFactory,
getReplicaFactory,
deployHome: async (...args) => {

Loading…
Cancel
Save