MCPcopy Create free account
hub / github.com/d1ll0n/stack-packer / abiStructToSol

Function abiStructToSol

src/code-gen/fields.ts:34–51  ·  view source on GitHub ↗
(struct: AbiStruct | AbiEnum)

Source from the content-addressed store, hash-verified

32};
33
34export 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
53export const resolveGroupMembers = (
54 struct: AbiStruct,

Callers 1

createLibraryMethod · 0.90

Calls 1

toTypeNameFunction · 0.85

Tested by

no test coverage detected