Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always use view overrides for statcCalls #866

Merged
merged 3 commits into from
Aug 20, 2023
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/moody-lamps-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@typechain/ethers-v6": patch
---

fix: always use view overrides for statcCalls
6 changes: 4 additions & 2 deletions examples/ethers-v6-nodenext/types/ethers-contracts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ export interface TypedContractMethod<
populateTransaction(
...args: ContractMethodArgs<A, S>
): Promise<ContractTransaction>;
staticCall(...args: ContractMethodArgs<A, S>): Promise<DefaultReturnType<R>>;
staticCall(
...args: ContractMethodArgs<A, "view">
): Promise<DefaultReturnType<R>>;
send(...args: ContractMethodArgs<A, S>): Promise<ContractTransactionResponse>;
estimateGas(...args: ContractMethodArgs<A, S>): Promise<bigint>;
staticCallResult(...args: ContractMethodArgs<A, S>): Promise<R>;
staticCallResult(...args: ContractMethodArgs<A, "view">): Promise<R>;
}
6 changes: 4 additions & 2 deletions examples/ethers-v6/types/ethers-contracts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ export interface TypedContractMethod<
populateTransaction(
...args: ContractMethodArgs<A, S>
): Promise<ContractTransaction>;
staticCall(...args: ContractMethodArgs<A, S>): Promise<DefaultReturnType<R>>;
staticCall(
...args: ContractMethodArgs<A, "view">
): Promise<DefaultReturnType<R>>;
send(...args: ContractMethodArgs<A, S>): Promise<ContractTransactionResponse>;
estimateGas(...args: ContractMethodArgs<A, S>): Promise<bigint>;
staticCallResult(...args: ContractMethodArgs<A, S>): Promise<R>;
staticCallResult(...args: ContractMethodArgs<A, "view">): Promise<R>;
}
6 changes: 4 additions & 2 deletions packages/hardhat-test/typechain-types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ export interface TypedContractMethod<
populateTransaction(
...args: ContractMethodArgs<A, S>
): Promise<ContractTransaction>;
staticCall(...args: ContractMethodArgs<A, S>): Promise<DefaultReturnType<R>>;
staticCall(
...args: ContractMethodArgs<A, "view">
): Promise<DefaultReturnType<R>>;
send(...args: ContractMethodArgs<A, S>): Promise<ContractTransactionResponse>;
estimateGas(...args: ContractMethodArgs<A, S>): Promise<bigint>;
staticCallResult(...args: ContractMethodArgs<A, S>): Promise<R>;
staticCallResult(...args: ContractMethodArgs<A, "view">): Promise<R>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ export interface TypedContractMethod<
populateTransaction(
...args: ContractMethodArgs<A, S>
): Promise<ContractTransaction>;
staticCall(...args: ContractMethodArgs<A, S>): Promise<DefaultReturnType<R>>;
staticCall(
...args: ContractMethodArgs<A, "view">
): Promise<DefaultReturnType<R>>;
send(...args: ContractMethodArgs<A, S>): Promise<ContractTransactionResponse>;
estimateGas(...args: ContractMethodArgs<A, S>): Promise<bigint>;
staticCallResult(...args: ContractMethodArgs<A, S>): Promise<R>;
staticCallResult(...args: ContractMethodArgs<A, "view">): Promise<R>;
}
21 changes: 21 additions & 0 deletions packages/target-ethers-v6-test/test/Payable.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { AssertTrue, IsExact } from 'test-utils'

import type { Payable } from '../types'
import type { PostfixOverrides } from '../types/common'
import { createNewBlockchain } from './common'

describe('Payable', () => {
const chain = createNewBlockchain<Payable>('Payable')

it('generate view override parameter types for staticCall', async () => {
type InputType = Parameters<typeof chain.contract.payable_func.staticCall>
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type _t1 = AssertTrue<IsExact<InputType, PostfixOverrides<[], 'view'>>>
})

it('generate view override parameter types for staticCallResult', async () => {
type InputType = Parameters<typeof chain.contract.payable_func.staticCallResult>
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type _t1 = AssertTrue<IsExact<InputType, PostfixOverrides<[], 'view'>>>
})
})
6 changes: 4 additions & 2 deletions packages/target-ethers-v6-test/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ export interface TypedContractMethod<
populateTransaction(
...args: ContractMethodArgs<A, S>
): Promise<ContractTransaction>;
staticCall(...args: ContractMethodArgs<A, S>): Promise<DefaultReturnType<R>>;
staticCall(
...args: ContractMethodArgs<A, "view">
): Promise<DefaultReturnType<R>>;
send(...args: ContractMethodArgs<A, S>): Promise<ContractTransactionResponse>;
estimateGas(...args: ContractMethodArgs<A, S>): Promise<bigint>;
staticCallResult(...args: ContractMethodArgs<A, S>): Promise<R>;
staticCallResult(...args: ContractMethodArgs<A, "view">): Promise<R>;
}
4 changes: 2 additions & 2 deletions packages/target-ethers-v6/static/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export interface TypedContractMethod<
getFragment(...args: ContractMethodArgs<A, S>): FunctionFragment

populateTransaction(...args: ContractMethodArgs<A, S>): Promise<ContractTransaction>
staticCall(...args: ContractMethodArgs<A, S>): Promise<DefaultReturnType<R>>
staticCall(...args: ContractMethodArgs<A, 'view'>): Promise<DefaultReturnType<R>>
send(...args: ContractMethodArgs<A, S>): Promise<ContractTransactionResponse>
estimateGas(...args: ContractMethodArgs<A, S>): Promise<bigint>
staticCallResult(...args: ContractMethodArgs<A, S>): Promise<R>
staticCallResult(...args: ContractMethodArgs<A, 'view'>): Promise<R>
}
Loading