( struct: AbiStruct, fields: ProcessedField[], context: FileContext, name: string, maskReference?: string )
| 148 | } |
| 149 | |
| 150 | const getEncoder = ( |
| 151 | struct: AbiStruct, |
| 152 | fields: ProcessedField[], |
| 153 | context: FileContext, |
| 154 | name: string, |
| 155 | maskReference?: string |
| 156 | ): CodeGenFunction => { |
| 157 | const orBlocks: { positioned: string; }[] = [...fields]; |
| 158 | const inputs = fields.map((field) => ({ definition:field.parameterDefinition, name: field.name, type: field.type })); |
| 159 | let outputName = 'encoded' |
| 160 | if (maskReference) { |
| 161 | orBlocks.unshift({ positioned: `and(old, ${maskReference})` }) |
| 162 | inputs.unshift({ definition:`${fields[0].structName} old`, name: 'old', type: struct }) |
| 163 | outputName = 'updated' |
| 164 | } |
| 165 | let encodeChunks = buildNestedAssemblyOr(orBlocks); |
| 166 | encodeChunks = prefixFirstString(encodeChunks, `${outputName} := `) |
| 167 | return { |
| 168 | name, |
| 169 | inputs, |
| 170 | outputs: [{ definition:`${fields[0].structName} ${outputName}`, name: outputName, type: struct }], |
| 171 | visibility: 'pure', |
| 172 | location: 'internal', |
| 173 | body: buildAssemblyBlock([ |
| 174 | ...getOverflowCheck(fields, context), |
| 175 | ...toArray(encodeChunks) |
| 176 | ]), |
| 177 | internalType: 'setter', |
| 178 | outputFields: [], |
| 179 | inputFields: fields |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | export const generateFieldSetter = ( |
| 184 | struct: AbiStruct, |
no test coverage detected