(error: AbiError, context: FileContext)
| 237 | } |
| 238 | |
| 239 | export function getThrowFunction(error: AbiError, context: FileContext): ArrayJoinInput<string> { |
| 240 | const signature = `${error.name}(${error.fields.map(f => toTypeName(f.type)).join(',')})`; |
| 241 | const selector = `0x${keccak256(signature).slice(0, 4).toString('hex')}`.padEnd(66, '0'); |
| 242 | let offset = 4; |
| 243 | const selectorReference = context.addConstant(`${error.name}_selector`, selector); |
| 244 | const lines: string[] = [ |
| 245 | `mstore(0, ${selectorReference})` |
| 246 | ]; |
| 247 | for (let field of error.fields) { |
| 248 | const offsetRef = context.addConstant(`${error.name}_${field.name}_ptr`, toHex(offset)); |
| 249 | lines.push(`mstore(${offsetRef}, ${field.name})`); |
| 250 | offset += 32; |
| 251 | } |
| 252 | const lengthReference = context.addConstant(`${error.name}_length`, toHex(offset)) |
| 253 | lines.push(`revert(0, ${lengthReference})`) |
| 254 | const fnBlock = buildFunctionBlock( |
| 255 | `throw${error.name}`, |
| 256 | error.fields.map((field) => `${toTypeName(field.type)} ${field.name}`), |
| 257 | [], |
| 258 | buildAssemblyBlock(lines) |
| 259 | ); |
| 260 | return fnBlock |
| 261 | } |
| 262 | |
| 263 | export function getEmitFunction(event: AbiEvent, context: FileContext): ArrayJoinInput<string> { |
| 264 | const topic0 = `0x${keccak256(`${event.name}(${event.fields.map(f => toTypeName(f.type)).join(',')})`).toString('hex')}`; |
nothing calls this directly
no test coverage detected