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/lib/index.js

49 lines
1.4 KiB

require('@nomiclabs/hardhat-waffle');
const { extendEnvironment } = require('hardhat/config');
const HomeAbi = require('../artifacts/contracts/Home.sol/Home.json').abi;
const ReplicaAbi = require('../artifacts/contracts/Replica.sol/ProcessingReplica.json')
.abi;
extendEnvironment((hre) => {
const { ethers } = hre;
class Common extends ethers.Contract {
constructor(address, abi, providerOrSigner) {
super(address, abi, providerOrSigner);
}
}
class Home extends Common {
constructor(address, providerOrSigner) {
super(address, HomeAbi, providerOrSigner);
}
}
class Replica extends Common {
constructor(address, providerOrSigner) {
super(address, ReplicaAbi, providerOrSigner);
}
}
const getHomeFactory = async () => ethers.getContractFactory('Home');
const getReplicaFactory = async () =>
ethers.getContractFactory('ProcessingReplica');
hre.optics = {
Home,
Replica,
getHomeFactory,
getReplicaFactory,
deployHome: async (...args) => {
let contract = await (await getHomeFactory()).deploy(...args);
await contract.deployed();
return new Home(contract.address, contract.signer);
},
deployReplica: async (...args) => {
let contract = await (await getReplicaFactory()).deploy(...args);
await contract.deployed();
return new Replica(contract.address, contract.signer);
},
};
});