Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-fans-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@typechain/ethers-v5': minor
---

Added support for inputs wrapped in promise for ethers-v5 target.
6 changes: 6 additions & 0 deletions packages/hardhat-test/contracts/Directory/Hello.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

contract Hello {
constructor(uint) {}
}
17 changes: 9 additions & 8 deletions packages/hardhat-test/typechain-types/Counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "./common";

export interface CounterInterface extends utils.Interface {
Expand Down Expand Up @@ -86,22 +87,22 @@ export interface Counter extends BaseContract {

functions: {
countDown(
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;

countUp(
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;

getCount(overrides?: CallOverrides): Promise<[BigNumber]>;
};

countDown(
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;

countUp(
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;

getCount(overrides?: CallOverrides): Promise<BigNumber>;
Expand All @@ -121,23 +122,23 @@ export interface Counter extends BaseContract {

estimateGas: {
countDown(
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;

countUp(
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;

getCount(overrides?: CallOverrides): Promise<BigNumber>;
};

populateTransaction: {
countDown(
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;

countUp(
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;

getCount(overrides?: CallOverrides): Promise<PopulatedTransaction>;
Expand Down
11 changes: 9 additions & 2 deletions packages/hardhat-test/typechain-types/Demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "./common";

export declare namespace Demo {
export type Struct1Struct = { a: BigNumberish; b: BigNumberish };
export type Struct1Struct = {
a: PromiseOrValue<BigNumberish>;
b: PromiseOrValue<BigNumberish>;
};

export type Struct1StructOutput = [BigNumber, BigNumber] & {
a: BigNumber;
b: BigNumber;
};

export type Struct2Struct = { a: BigNumberish; b: BigNumberish };
export type Struct2Struct = {
a: PromiseOrValue<BigNumberish>;
b: PromiseOrValue<BigNumberish>;
};

export type Struct2StructOutput = [BigNumber, BigNumber] & {
a: BigNumber;
Expand Down
56 changes: 56 additions & 0 deletions packages/hardhat-test/typechain-types/Directory/Hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type { BaseContract, Signer, utils } from "ethers";

import type { Listener, Provider } from "@ethersproject/providers";
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../common";

export interface HelloInterface extends utils.Interface {
functions: {};

events: {};
}

export interface Hello extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;

interface: HelloInterface;

queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined
): Promise<Array<TEvent>>;

listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>
): Array<TypedListener<TEvent>>;
listeners(eventName?: string): Array<Listener>;
removeAllListeners<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>
): this;
removeAllListeners(eventName?: string): this;
off: OnEvent<this>;
on: OnEvent<this>;
once: OnEvent<this>;
removeListener: OnEvent<this>;

functions: {};

callStatic: {};

filters: {};

estimateGas: {};

populateTransaction: {};
}
4 changes: 4 additions & 0 deletions packages/hardhat-test/typechain-types/Directory/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { Hello } from "./Hello";
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "./common";

export type Vector2Struct = { x: BigNumberish; y: BigNumberish };
export type Vector2Struct = {
x: PromiseOrValue<BigNumberish>;
y: PromiseOrValue<BigNumberish>;
};

export type Vector2StructOutput = [BigNumber, BigNumber] & {
x: BigNumber;
Expand Down
2 changes: 2 additions & 0 deletions packages/hardhat-test/typechain-types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ export type GetContractTypeFromFactory<F> = F extends MinEthersFactory<
export type GetARGsTypeFromFactory<F> = F extends MinEthersFactory<any, any>
? Parameters<F["deploy"]>
: never;

export type PromiseOrValue<T> = T | Promise<T>;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable */
import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers";
import type { Provider, TransactionRequest } from "@ethersproject/providers";
import type { PromiseOrValue } from "../common";
import type { Counter, CounterInterface } from "../Counter";

const _abi = [
Expand Down Expand Up @@ -81,12 +82,12 @@ export class Counter__factory extends ContractFactory {
}

override deploy(
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<Counter> {
return super.deploy(overrides || {}) as Promise<Counter>;
}
override getDeployTransaction(
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): TransactionRequest {
return super.getDeployTransaction(overrides || {});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable */
import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers";
import type { Provider, TransactionRequest } from "@ethersproject/providers";
import type { PromiseOrValue } from "../common";
import type { Demo, DemoInterface } from "../Demo";

const _abi = [
Expand Down Expand Up @@ -71,14 +72,14 @@ export class Demo__factory extends ContractFactory {
override deploy(
input1: Demo.Struct1Struct,
input2: Demo.Struct2Struct[],
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<Demo> {
return super.deploy(input1, input2, overrides || {}) as Promise<Demo>;
}
override getDeployTransaction(
input1: Demo.Struct1Struct,
input2: Demo.Struct2Struct[],
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): TransactionRequest {
return super.getDeployTransaction(input1, input2, overrides || {});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import {
Signer,
utils,
Contract,
ContractFactory,
BigNumberish,
Overrides,
} from "ethers";
import type { Provider, TransactionRequest } from "@ethersproject/providers";
import type { PromiseOrValue } from "../../common";
import type { Hello, HelloInterface } from "../../Directory/Hello";

const _abi = [
{
inputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "nonpayable",
type: "constructor",
},
];

const _bytecode =
"0x6080604052348015600f57600080fd5b5060405160dc38038060dc8339818101604052810190602d91906045565b506090565b600081519050603f81607c565b92915050565b60006020828403121560585760576077565b5b60006064848285016032565b91505092915050565b6000819050919050565b600080fd5b608381606d565b8114608d57600080fd5b50565b603f80609d6000396000f3fe6080604052600080fdfea2646970667358221220133f91b0425ce510af8b75336b57852d3a7de1c90943e9b26ca086eabb5334d264736f6c63430008070033";

type HelloConstructorParams =
| [signer?: Signer]
| ConstructorParameters<typeof ContractFactory>;

const isSuperArgs = (
xs: HelloConstructorParams
): xs is ConstructorParameters<typeof ContractFactory> => xs.length > 1;

export class Hello__factory extends ContractFactory {
constructor(...args: HelloConstructorParams) {
if (isSuperArgs(args)) {
super(...args);
} else {
super(_abi, _bytecode, args[0]);
}
}

override deploy(
arg0: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<Hello> {
return super.deploy(arg0, overrides || {}) as Promise<Hello>;
}
override getDeployTransaction(
arg0: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): TransactionRequest {
return super.getDeployTransaction(arg0, overrides || {});
}
override attach(address: string): Hello {
return super.attach(address) as Hello;
}
override connect(signer: Signer): Hello__factory {
return super.connect(signer) as Hello__factory;
}

static readonly bytecode = _bytecode;
static readonly abi = _abi;
static createInterface(): HelloInterface {
return new utils.Interface(_abi) as HelloInterface;
}
static connect(address: string, signerOrProvider: Signer | Provider): Hello {
return new Contract(address, _abi, signerOrProvider) as Hello;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { Hello__factory } from "./Hello__factory";
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable */
import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers";
import type { Provider, TransactionRequest } from "@ethersproject/providers";
import type { PromiseOrValue } from "../common";
import type {
StructsInConstructor,
StructsInConstructorInterface,
Expand Down Expand Up @@ -57,7 +58,7 @@ export class StructsInConstructor__factory extends ContractFactory {

override deploy(
segment: [Vector2Struct, Vector2Struct],
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<StructsInConstructor> {
return super.deploy(
segment,
Expand All @@ -66,7 +67,7 @@ export class StructsInConstructor__factory extends ContractFactory {
}
override getDeployTransaction(
segment: [Vector2Struct, Vector2Struct],
overrides?: Overrides & { from?: string | Promise<string> }
overrides?: Overrides & { from?: PromiseOrValue<string> }
): TransactionRequest {
return super.getDeployTransaction(segment, overrides || {});
}
Expand Down
1 change: 1 addition & 0 deletions packages/hardhat-test/typechain-types/factories/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as directory from "./Directory";
export { Counter__factory } from "./Counter__factory";
export { Demo__factory } from "./Demo__factory";
export { StructsInConstructor__factory } from "./StructsInConstructor__factory";
9 changes: 9 additions & 0 deletions packages/hardhat-test/typechain-types/hardhat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ declare module "hardhat/types/runtime" {
name: "Demo",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.Demo__factory>;
getContractFactory(
name: "Hello",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.Hello__factory>;
getContractFactory(
name: "StructsInConstructor",
signerOrOptions?: ethers.Signer | FactoryOptions
Expand All @@ -35,6 +39,11 @@ declare module "hardhat/types/runtime" {
address: string,
signer?: ethers.Signer
): Promise<Contracts.Demo>;
getContractAt(
name: "Hello",
address: string,
signer?: ethers.Signer
): Promise<Contracts.Hello>;
getContractAt(
name: "StructsInConstructor",
address: string,
Expand Down
4 changes: 4 additions & 0 deletions packages/hardhat-test/typechain-types/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as directory from "./Directory";
export type { directory };
export type { Counter } from "./Counter";
export type { Demo } from "./Demo";
export type { StructsInConstructor } from "./StructsInConstructor";
export * as factories from "./factories";
export { Counter__factory } from "./factories/Counter__factory";
export { Demo__factory } from "./factories/Demo__factory";
export type { Hello } from "./Directory/Hello";
export { Hello__factory } from "./factories/Directory/Hello__factory";
export { StructsInConstructor__factory } from "./factories/StructsInConstructor__factory";
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../common";

export interface EdgeCasesInterface extends utils.Interface {
Expand Down
Loading