(param: ParamType, value: any)
| 980 | |
| 981 | // @TODO: Use the coders for this; to properly support tuples, etc. |
| 982 | const encodeTopic = (param: ParamType, value: any): string => { |
| 983 | if (param.type === "string") { |
| 984 | return id(value); |
| 985 | } else if (param.type === "bytes") { |
| 986 | return keccak256(value); |
| 987 | } |
| 988 | |
| 989 | if (param.type === "bool" && typeof(value) === "boolean") { |
| 990 | value = (value ? "0x01": "0x00"); |
| 991 | } else if (param.type.match(/^u?int/)) { |
| 992 | value = toBeHex(value); // @TODO: Should this toTwos?? |
| 993 | } else if (param.type.match(/^bytes/)) { |
| 994 | value = zeroPadBytes(value, 32); |
| 995 | } else if (param.type === "address") { |
| 996 | // Check addresses are valid |
| 997 | this.#abiCoder.encode( [ "address" ], [ value ]); |
| 998 | } |
| 999 | |
| 1000 | return zeroPadValue(hexlify(value), 32); |
| 1001 | }; |
| 1002 | |
| 1003 | values.forEach((value, index) => { |
| 1004 |
nothing calls this directly
no test coverage detected