File tree 3 files changed +15
-10
lines changed
3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change
1
+ import type { AbiFunction } from "viem" ;
1
2
import { isAddress } from "viem" ;
2
3
3
4
import type { AbiBinding , ICommand } from "../../../types" ;
@@ -12,7 +13,6 @@ import {
12
13
checkArgsLength ,
13
14
encodeAction ,
14
15
fetchAbi ,
15
- getFunctionFragment ,
16
16
insideNodeLine ,
17
17
interpretNodeSync ,
18
18
tryAndCacheNotFound ,
@@ -85,16 +85,18 @@ export const act: ICommand<AragonOS> = {
85
85
if ( ! abi ) {
86
86
return [ ] ;
87
87
}
88
-
89
88
const functions = abi
90
89
// Only consider functions that change state
91
90
. filter (
92
- ( item ) =>
91
+ ( item ) : item is AbiFunction =>
93
92
item . type === "function" &&
94
93
( item . stateMutability === "nonpayable" ||
95
94
item . stateMutability === "payable" ) ,
96
95
)
97
- . map ( getFunctionFragment ) ;
96
+ . map (
97
+ ( func : AbiFunction ) =>
98
+ `${ func . name } (${ func . inputs . map ( ( input ) => input . type ) . join ( "," ) } )` ,
99
+ ) ;
98
100
return functions ;
99
101
}
100
102
default : {
Original file line number Diff line number Diff line change
1
+ import type { AbiFunction } from "viem" ;
1
2
import { getAbiItem , isAddress } from "viem" ;
2
3
3
4
import { BindingsSpace } from "../../../types" ;
@@ -145,7 +146,7 @@ export const exec: ICommand<Std> = {
145
146
nodeArgs [ 0 ] . type === "HelperFunctionExpression" &&
146
147
( nodeArgs [ 0 ] as HelperFunctionNode ) . name === "token"
147
148
? erc20ABI
148
- : ( function ( ) {
149
+ : ( ( ) => {
149
150
const targetAddress = interpretNodeSync (
150
151
nodeArgs [ 0 ] ,
151
152
bindingsManager ,
@@ -162,12 +163,15 @@ export const exec: ICommand<Std> = {
162
163
const functions = abi
163
164
// Only consider functions that change state
164
165
. filter (
165
- ( item ) =>
166
+ ( item ) : item is AbiFunction =>
166
167
item . type === "function" &&
167
168
( item . stateMutability === "nonpayable" ||
168
169
item . stateMutability === "payable" ) ,
169
170
)
170
- . map ( getFunctionFragment ) ;
171
+ . map (
172
+ ( func : AbiFunction ) =>
173
+ `${ func . name } (${ func . inputs . map ( ( input ) => input . type ) . join ( "," ) } )` ,
174
+ ) ;
171
175
return functions ;
172
176
}
173
177
default : {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export const SIGNATURE_REGEX =
10
10
export const toDecimals = ( amount : number | string , decimals = 18 ) : bigint => {
11
11
const [ integer , decimal ] = String ( amount ) . split ( "." ) ;
12
12
return BigInt (
13
- ( integer != "0" ? integer : "" ) + ( decimal || "" ) . padEnd ( decimals , "0" ) ||
13
+ ( integer !== "0" ? integer : "" ) + ( decimal || "" ) . padEnd ( decimals , "0" ) ||
14
14
"0" ,
15
15
) ;
16
16
} ;
@@ -22,7 +22,6 @@ export function addressesEqual(first: Address, second: Address): boolean {
22
22
export function getFunctionFragment ( func : AbiItem | undefined ) {
23
23
if ( func ?. type === "function" ) {
24
24
return `function ${ func . name } (${ func . inputs . map ( ( input ) => input . type ) . join ( ", " ) } )${ func . outputs . length > 0 ? ` returns (${ func . outputs . map ( ( output ) => output . type ) . join ( ", " ) } )` : "" } ` ;
25
- } else {
26
- throw new Error ( `invalid function` ) ;
27
25
}
26
+ throw new Error ( "invalid function" ) ;
28
27
}
You can’t perform that action at this time.
0 commit comments