|
1 |
| -import { |
2 |
| - ethers, |
3 |
| - type BrowserProvider, |
4 |
| - keccak256, |
5 |
| - BaseContractMethod, |
6 |
| -} from 'ethers' |
| 1 | +import { ethers, type BrowserProvider, keccak256 } from 'ethers' |
7 | 2 | import { TransactionResponse } from '@ethersproject/abstract-provider'
|
8 |
| -import { always, keys, mergeAll } from 'ramda' |
| 3 | +import { always, mergeAll } from 'ramda' |
9 | 4 |
|
10 | 5 | import { Positions } from '../../ethereum/s-tokens'
|
11 | 6 | import { Rewards } from '../../ethereum/s-tokens/rewards'
|
@@ -169,23 +164,14 @@ export const execute: ExecuteFunction = async <
|
169 | 164 | opts.mutation && opts.overrides?.overrides
|
170 | 165 | ? [...(args || []), opts.overrides.overrides]
|
171 | 166 | : 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] |
189 | 175 | const res = await (argsOverrided === undefined
|
190 | 176 | ? method()
|
191 | 177 | : method.apply(N, argsOverrided)
|
|
0 commit comments