Skip to content

Commit 7e00d56

Browse files
committed
fix an execution error
1 parent bf273b6 commit 7e00d56

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

lib/common/utils/execute.ts

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import {
2-
ethers,
3-
type BrowserProvider,
4-
keccak256,
5-
BaseContractMethod,
6-
} from 'ethers'
1+
import { ethers, type BrowserProvider, keccak256 } from 'ethers'
72
import { TransactionResponse } from '@ethersproject/abstract-provider'
8-
import { always, keys, mergeAll } from 'ramda'
3+
import { always, mergeAll } from 'ramda'
94

105
import { Positions } from '../../ethereum/s-tokens'
116
import { Rewards } from '../../ethereum/s-tokens/rewards'
@@ -169,23 +164,14 @@ export const execute: ExecuteFunction = async <
169164
opts.mutation && opts.overrides?.overrides
170165
? [...(args || []), opts.overrides.overrides]
171166
: args
172-
const singleMethod = opts.static
173-
? (contract[opts.method] as undefined | BaseContractMethod)?.staticCall
174-
: (contract[opts.method] as undefined | BaseContractMethod)
175-
const overloadedMethod = singleMethod
176-
? undefined
177-
: ((name) =>
178-
opts.static
179-
? (contract[name] as undefined | BaseContractMethod)?.staticCall
180-
: contract[name])(
181-
String(
182-
keys(contract).find(
183-
(fn: string | number | unknown) =>
184-
fn === `${opts.method}(${opts.interface})`,
185-
),
186-
),
187-
)
188-
const method = singleMethod ?? (overloadedMethod as BaseContractMethod)
167+
const typedMethod = `${opts.method}(${opts.interface})`
168+
const method = opts.static
169+
? opts.interface
170+
? contract[typedMethod].staticCall
171+
: contract[opts.method].staticCall
172+
: opts.interface
173+
? contract[typedMethod]
174+
: contract[opts.method]
189175
const res = await (argsOverrided === undefined
190176
? method()
191177
: method.apply(N, argsOverrided)

0 commit comments

Comments
 (0)