Skip to content

Commit

Permalink
build: fix tsc errors and disable eslint on some lines
Browse files Browse the repository at this point in the history
  • Loading branch information
antomor committed Oct 21, 2022
1 parent 2e46f9a commit 9661766
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const updateConfig = (

return {
...getExistingConfig(),
contractAddresses,
[`${network}.${chainId}`]: contractAddresses,
};
};

Expand Down
12 changes: 11 additions & 1 deletion utils/deployment/deployment.utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {
Contract as Contract,
ContractFactory as EthersContractFactory,
Signer,
} from 'ethers/lib/ethers';
import { ethers } from 'hardhat';
import { FactoryOptions } from 'hardhat/types';

export interface ContractFactory<C extends Contract>
extends EthersContractFactory {
Expand All @@ -11,20 +13,27 @@ export interface ContractFactory<C extends Contract>

export type DeployerParam<
C extends Contract,
// eslint-disable-next-line @typescript-eslint/ban-types
A extends {} = ContractFactory<C>['deploy']
> = {
contractName: string;
constructorArgs: A;
contractFactory?: ContractFactory<C>;
};

type ContractFactoryOpt = {
contractName: string,
signerOrOptions?: Signer | FactoryOptions
}


export const getContractFactory = async <
C extends Contract,
F extends ContractFactory<C>
>({
contractName,
signerOrOptions,
}: typeof ethers.getContractFactory.arguments) =>
}: ContractFactoryOpt) =>
ethers.getContractFactory(contractName, signerOrOptions) as Promise<F>;

export type DeployerReturnType<C extends Contract> = Promise<{
Expand All @@ -34,6 +43,7 @@ export type DeployerReturnType<C extends Contract> = Promise<{

export const deployContract = async <
C extends Contract,
// eslint-disable-next-line @typescript-eslint/ban-types
A extends {} = ContractFactory<C>['deploy']
>({
contractName,
Expand Down
2 changes: 1 addition & 1 deletion utils/scripts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const factoryList = {
} as const;

export type FactoryName = Exclude<Extract<keyof typeof factoryList, `${string}__factory`>,
'Migrations__factory'>;
'Migrations__factory' | 'Collector__factory' | 'Ownable__factory'>;

export type ContractName = FactoryName extends `${infer Prefix}__factory`
? Prefix
Expand Down

0 comments on commit 9661766

Please sign in to comment.