@defi-wonderland/keep3r-v2
Version:
The Keep3r Network is a decentralized network for projects that need external devops, and for external teams to find keeper jobs
24 lines (21 loc) • 1.23 kB
text/typescript
import { TransactionResponse } from '@ethersproject/abstract-provider';
import { Contract, ContractFactory } from '@ethersproject/contracts';
import { BigNumber, ContractInterface, Signer } from 'ethers';
import { getStatic } from 'ethers/lib/utils';
import { network } from 'hardhat';
export const deploy = async (contract: ContractFactory, args: any[]): Promise<{ tx: TransactionResponse; contract: Contract }> => {
const deploymentTransactionRequest = await contract.getDeployTransaction(...args);
const deploymentTx = await contract.signer.sendTransaction(deploymentTransactionRequest);
const contractAddress = getStatic<(deploymentTx: TransactionResponse) => string>(contract.constructor, 'getContractAddress')(deploymentTx);
const deployedContract = getStatic<(contractAddress: string, contractInterface: ContractInterface, signer?: Signer) => Contract>(
contract.constructor,
'getContract'
)(contractAddress, contract.interface, contract.signer);
return {
tx: deploymentTx,
contract: deployedContract,
};
};
export const setBalance = async (address: string, amount: BigNumber): Promise<void> => {
await network.provider.send('hardhat_setBalance', [address, amount.toHexString()]);
};