(fragment: EventFragment | string, data: BytesLike, topics?: ReadonlyArray<string>)
| 1114 | |
| 1115 | // Decode a filter for the event and the search criteria |
| 1116 | decodeEventLog(fragment: EventFragment | string, data: BytesLike, topics?: ReadonlyArray<string>): Result { |
| 1117 | if (typeof(fragment) === "string") { |
| 1118 | const f = this.getEvent(fragment); |
| 1119 | assertArgument(f, "unknown event", "eventFragment", fragment); |
| 1120 | fragment = f; |
| 1121 | } |
| 1122 | |
| 1123 | if (topics != null && !fragment.anonymous) { |
| 1124 | const eventTopic = fragment.topicHash; |
| 1125 | assertArgument(isHexString(topics[0], 32) && topics[0].toLowerCase() === eventTopic, |
| 1126 | "fragment/topic mismatch", "topics[0]", topics[0]); |
| 1127 | topics = topics.slice(1); |
| 1128 | } |
| 1129 | |
| 1130 | const indexed: Array<ParamType> = []; |
| 1131 | const nonIndexed: Array<ParamType> = []; |
| 1132 | const dynamic: Array<boolean> = []; |
| 1133 | |
| 1134 | fragment.inputs.forEach((param, index) => { |
| 1135 | if (param.indexed) { |
| 1136 | if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { |
| 1137 | indexed.push(ParamType.from({ type: "bytes32", name: param.name })); |
| 1138 | dynamic.push(true); |
| 1139 | } else { |
| 1140 | indexed.push(param); |
| 1141 | dynamic.push(false); |
| 1142 | } |
| 1143 | } else { |
| 1144 | nonIndexed.push(param); |
| 1145 | dynamic.push(false); |
| 1146 | } |
| 1147 | }); |
| 1148 | |
| 1149 | const resultIndexed = (topics != null) ? this.#abiCoder.decode(indexed, concat(topics)): null; |
| 1150 | const resultNonIndexed = this.#abiCoder.decode(nonIndexed, data, true); |
| 1151 | |
| 1152 | //const result: (Array<any> & { [ key: string ]: any }) = [ ]; |
| 1153 | const values: Array<any> = [ ]; |
| 1154 | const keys: Array<null | string> = [ ]; |
| 1155 | let nonIndexedIndex = 0, indexedIndex = 0; |
| 1156 | fragment.inputs.forEach((param, index) => { |
| 1157 | let value: null | Indexed | Error = null; |
| 1158 | if (param.indexed) { |
| 1159 | if (resultIndexed == null) { |
| 1160 | value = new Indexed(null); |
| 1161 | |
| 1162 | } else if (dynamic[index]) { |
| 1163 | value = new Indexed(resultIndexed[indexedIndex++]); |
| 1164 | |
| 1165 | } else { |
| 1166 | try { |
| 1167 | value = resultIndexed[indexedIndex++]; |
| 1168 | } catch (error: any) { |
| 1169 | value = error; |
| 1170 | } |
| 1171 | } |
| 1172 | } else { |
| 1173 | try { |
no test coverage detected