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

Method handleType

src/parser/index.ts:96–167  ·  view source on GitHub ↗
(input: DefinedType)

Source from the content-addressed store, hash-verified

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 }

Callers 1

constructorMethod · 0.95

Calls 7

putEnumMethod · 0.95
handleFieldsMethod · 0.95
putStructMethod · 0.95
putErrorMethod · 0.95
putFunctionMethod · 0.95
putEventMethod · 0.95
bitsRequiredFunction · 0.90

Tested by

no test coverage detected