(input: DefinedType)
| 94 | } |
| 95 | |
| 96 | handleType(input: DefinedType): AbiType<true, true> | AbiFunction { |
| 97 | if (input.type == 'EnumDefinition') { |
| 98 | const { type, name, fields, namePath } = <EnumType> input; |
| 99 | const out: AbiType = { |
| 100 | meta: 'enum', |
| 101 | name, |
| 102 | fields, |
| 103 | dynamic: false, |
| 104 | size: bitsRequired(fields.length) |
| 105 | }; |
| 106 | return this.putEnum(namePath, out); |
| 107 | } |
| 108 | if (input.type == 'StructDefinition') { |
| 109 | // console.log(input) |
| 110 | const { name, fields: _fields, namePath, coderType, accessors, groups } = <StructType> input; |
| 111 | const { fields, size, dynamic } = this.handleFields(_fields); |
| 112 | |
| 113 | const struct: AbiType = { |
| 114 | meta: 'struct', |
| 115 | size, |
| 116 | dynamic, |
| 117 | name, |
| 118 | fields, |
| 119 | coderType, |
| 120 | accessors, |
| 121 | groups |
| 122 | } |
| 123 | // struct.groups = groups.map(group => this.buildGroup(struct, group)); |
| 124 | |
| 125 | return this.putStruct(namePath, struct); |
| 126 | } |
| 127 | if (input.type == 'CustomErrorDefinition') { |
| 128 | const { name, fields: _fields, namePath } = <ErrorType> input; |
| 129 | const { fields, size, dynamic } = this.handleFields(_fields); |
| 130 | |
| 131 | const error: AbiError = { |
| 132 | meta: 'error', |
| 133 | size, |
| 134 | dynamic, |
| 135 | name, |
| 136 | fields |
| 137 | } |
| 138 | return this.putError(namePath, error as AbiError); |
| 139 | } |
| 140 | if (input.type == 'FunctionDefinition') { |
| 141 | const { stateMutability, visibility, name, namePath } = <FunctionType> input; |
| 142 | const inputs = this.handleFields(input.input) |
| 143 | const outputs = this.handleFields(input.output) |
| 144 | const fn: AbiFunction = { |
| 145 | meta: "function", |
| 146 | name, |
| 147 | stateMutability, |
| 148 | visibility, |
| 149 | input: inputs, |
| 150 | output: outputs |
| 151 | } |
| 152 | return this.putFunction(namePath, fn); |
| 153 | } |
no test coverage detected