MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / decodeEventLog

Method decodeEventLog

lib.esm/abi/interface.js:957–1023  ·  view source on GitHub ↗
(fragment, data, topics)

Source from the content-addressed store, hash-verified

955 }
956 // Decode a filter for the event and the search criteria
957 decodeEventLog(fragment, data, topics) {
958 if (typeof (fragment) === "string") {
959 const f = this.getEvent(fragment);
960 assertArgument(f, "unknown event", "eventFragment", fragment);
961 fragment = f;
962 }
963 if (topics != null && !fragment.anonymous) {
964 const eventTopic = fragment.topicHash;
965 assertArgument(isHexString(topics[0], 32) && topics[0].toLowerCase() === eventTopic, "fragment/topic mismatch", "topics[0]", topics[0]);
966 topics = topics.slice(1);
967 }
968 const indexed = [];
969 const nonIndexed = [];
970 const dynamic = [];
971 fragment.inputs.forEach((param, index) => {
972 if (param.indexed) {
973 if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") {
974 indexed.push(ParamType.from({ type: "bytes32", name: param.name }));
975 dynamic.push(true);
976 }
977 else {
978 indexed.push(param);
979 dynamic.push(false);
980 }
981 }
982 else {
983 nonIndexed.push(param);
984 dynamic.push(false);
985 }
986 });
987 const resultIndexed = (topics != null) ? this.#abiCoder.decode(indexed, concat(topics)) : null;
988 const resultNonIndexed = this.#abiCoder.decode(nonIndexed, data, true);
989 //const result: (Array<any> & { [ key: string ]: any }) = [ ];
990 const values = [];
991 const keys = [];
992 let nonIndexedIndex = 0, indexedIndex = 0;
993 fragment.inputs.forEach((param, index) => {
994 let value = null;
995 if (param.indexed) {
996 if (resultIndexed == null) {
997 value = new Indexed(null);
998 }
999 else if (dynamic[index]) {
1000 value = new Indexed(resultIndexed[indexedIndex++]);
1001 }
1002 else {
1003 try {
1004 value = resultIndexed[indexedIndex++];
1005 }
1006 catch (error) {
1007 value = error;
1008 }
1009 }
1010 }
1011 else {
1012 try {
1013 value = resultNonIndexed[nonIndexedIndex++];
1014 }

Callers 5

parseLogMethod · 0.95
listenerFunction · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
test-abi.jsFile · 0.45

Calls 8

getEventMethod · 0.95
assertArgumentFunction · 0.90
isHexStringFunction · 0.90
concatFunction · 0.90
sliceMethod · 0.45
fromMethod · 0.45
decodeMethod · 0.45
fromItemsMethod · 0.45

Tested by

no test coverage detected