Skip to content

Commit 170a090

Browse files
committed
tweak
1 parent 1259e39 commit 170a090

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

lib/common/utils/execute.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { ethers, type BrowserProvider, keccak256 } from 'ethers'
1+
import {
2+
ethers,
3+
type BrowserProvider,
4+
keccak256,
5+
BaseContractMethod,
6+
} from 'ethers'
27
import { TransactionResponse } from '@ethersproject/abstract-provider'
38
import { keys, mergeAll } from 'ramda'
49

@@ -135,18 +140,19 @@ export const execute: ExecuteFunction = async <
135140
? [...(args || []), opts.overrides.overrides]
136141
: args
137142
const singleMethod = opts.static
138-
? contract[opts.method].staticCall
139-
: contract[opts.method]
140-
const overloadedMethod = ((name) =>
141-
opts.static ? contract[name].staticCall : contract[name])(
142-
String(
143-
keys(contract).find(
144-
(fn: string | number | unknown) =>
145-
fn === `${opts.method}(${opts.interface})`
146-
)
147-
)
148-
)
149-
const method = singleMethod ?? overloadedMethod
143+
? (contract[opts.method] as undefined | BaseContractMethod)?.staticCall
144+
: (contract[opts.method] as undefined | BaseContractMethod)
145+
const overloadedMethod = singleMethod
146+
? undefined
147+
: ((name) => (opts.static ? contract[name].staticCall : contract[name]))(
148+
String(
149+
keys(contract).find(
150+
(fn: string | number | unknown) =>
151+
fn === `${opts.method}(${opts.interface})`
152+
)
153+
)
154+
)
155+
const method = singleMethod ?? (overloadedMethod as BaseContractMethod)
150156
const res = await (argsOverrided === undefined
151157
? method()
152158
: method.apply(N, argsOverrided)

0 commit comments

Comments
 (0)