(struct: AbiStruct | AbiEnum)
| 32 | }; |
| 33 | |
| 34 | export const abiStructToSol = (struct: AbiStruct | AbiEnum): ArrayJoinInput<string> => { |
| 35 | let arr: ArrayJoinInput = []; |
| 36 | if (struct.meta == 'enum') { |
| 37 | let size = 7 + struct.name.length + struct.fields.reduce((sum, f) => sum + f.length, 0); |
| 38 | if (size < 60) arr = [`enum ${struct.name} { ${struct.fields.join(', ')} }`]; |
| 39 | else |
| 40 | arr = [ |
| 41 | `enum ${struct.name} {`, |
| 42 | [ |
| 43 | ...struct.fields.slice(0, struct.fields.length - 1).map((f) => `${f},`), |
| 44 | struct.fields[struct.fields.length - 1], |
| 45 | ], |
| 46 | `}`, |
| 47 | ]; |
| 48 | } else |
| 49 | arr = [`struct ${struct.name} {`, struct.fields.map((field) => `${toTypeName(field.type)} ${field.name};`), `}`]; |
| 50 | return arr; |
| 51 | }; |
| 52 | |
| 53 | export const resolveGroupMembers = ( |
| 54 | struct: AbiStruct, |
no test coverage detected