(event: AbiEvent, context: FileContext)
| 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')}`; |
| 265 | const lines: string[] = []; |
| 266 | const topics: string[] = [] |
| 267 | const topic0Reference = context.addConstant(`${event.name}_topic0`, topic0); |
| 268 | topics.push(topic0Reference) |
| 269 | let offset = 0; |
| 270 | for (let field of event.fields) { |
| 271 | if (field.isIndexed) { |
| 272 | topics.push(field.name) |
| 273 | } else { |
| 274 | const offsetRef = context.addConstant(`${event.name}_${field.name}_ptr`, toHex(offset)); |
| 275 | lines.push(`mstore(${offsetRef}, ${field.name})`); |
| 276 | offset += 32; |
| 277 | } |
| 278 | } |
| 279 | const lengthReference = context.addConstant(`${event.name}_length`, toHex(offset)) |
| 280 | lines.push(`log${topics.length}(0, ${lengthReference}, ${topics.join(', ')})`) |
| 281 | const fnBlock = buildFunctionBlock( |
| 282 | `emit${event.name}`, |
| 283 | event.fields.map((field) => `${toTypeName(field.type)} ${field.name}`), |
| 284 | [], |
| 285 | buildAssemblyBlock(lines) |
| 286 | ); |
| 287 | return fnBlock |
| 288 | } |
| 289 | |
| 290 | export function getCallFunction(fn: AbiFunction, context: FileContext): ArrayJoinInput<string> { |
| 291 | const {input, output} = fn |
nothing calls this directly
no test coverage detected