github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/js/src/contracts/abi.ts (about) 1 import { Event, EventInput, FunctionInput, FunctionOutput, SolidityFunction } from 'solc'; 2 3 export type ABI = Array<SolidityFunction | Event>; 4 5 export type Address = string; 6 7 export type FunctionIO = FunctionInput & FunctionOutput; 8 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 } 40 41 export function transformToFullName(abi: SolidityFunction | Event): string { 42 if (abi.name.indexOf('(') !== -1) { 43 return abi.name; 44 } 45 const typeName = (abi.inputs as Array<EventInput | FunctionIO>).map((i) => i.type).join(','); 46 return abi.name + '(' + typeName + ')'; 47 }