@@ -6,7 +6,37 @@ export type Address = string;
66
77export type FunctionIO = FunctionInput & FunctionOutput ;
88
9- // TODO: replace with ethers js
9+ export namespace ABI {
10+ export type Func = {
11+ type : 'function' | 'constructor' | 'fallback' ;
12+ name : string ;
13+ inputs ?: Array < FunctionInput > ;
14+ outputs ?: Array < FunctionOutput > ;
15+ stateMutability : 'pure' | 'view' | 'nonpayable' | 'payable' ;
16+ payable ?: boolean ;
17+ constant ?: boolean ;
18+ } ;
19+
20+ export type Event = {
21+ type : 'event' ;
22+ name : string ;
23+ inputs : Array < EventInput > ;
24+ anonymous : boolean ;
25+ } ;
26+
27+ export type FunctionInput = {
28+ name : string ;
29+ type : string ;
30+ components ?: FunctionInput [ ] ;
31+ internalType ?: string ;
32+ } ;
33+
34+ export type FunctionOutput = FunctionInput ;
35+ export type EventInput = FunctionInput & { indexed ?: boolean } ;
36+
37+ export type FunctionIO = FunctionInput & FunctionOutput ;
38+ export type FunctionOrEvent = Func | Event ;
39+ }
1040
1141export function transformToFullName ( abi : SolidityFunction | Event ) : string {
1242 if ( abi . name . indexOf ( '(' ) !== - 1 ) {
@@ -15,18 +45,3 @@ export function transformToFullName(abi: SolidityFunction | Event): string {
1545 const typeName = ( abi . inputs as Array < EventInput | FunctionIO > ) . map ( ( i ) => i . type ) . join ( ',' ) ;
1646 return abi . name + '(' + typeName + ')' ;
1747}
18-
19- export function extractDisplayName ( name : string ) : string {
20- const length = name . indexOf ( '(' ) ;
21- return length !== - 1 ? name . substr ( 0 , length ) : name ;
22- }
23-
24- export function extractTypeName ( name : string ) : string {
25- /// TODO: make it invulnerable
26- const length = name . indexOf ( '(' ) ;
27- return length !== - 1 ? name . substr ( length + 1 , name . length - 1 - ( length + 1 ) ) . replace ( ' ' , '' ) : '' ;
28- }
29-
30- export function isFunction ( abi : SolidityFunction | Event ) : abi is SolidityFunction {
31- return abi . type === 'function' || abi . type === 'constructor' ;
32- }
0 commit comments