MCPcopy Create free account
hub / github.com/ccxt/ccxt / decodeEventLog

Method decodeEventLog

js/src/static_dependencies/ethers/interface.js:835–901  ·  view source on GitHub ↗
(fragment, data, topics)

Source from the content-addressed store, hash-verified

833 }
834 // Decode a filter for the event and the search criteria
835 decodeEventLog(fragment, data, topics) {
836 if (typeof (fragment) === "string") {
837 const f = this.getEvent(fragment);
838 assertArgument(f, "unknown event", "eventFragment", fragment);
839 fragment = f;
840 }
841 if (topics != null && !fragment.anonymous) {
842 const eventTopic = fragment.topicHash;
843 assertArgument(isHexString(topics[0], 32) && topics[0].toLowerCase() === eventTopic, "fragment/topic mismatch", "topics[0]", topics[0]);
844 topics = topics.slice(1);
845 }
846 const indexed = [];
847 const nonIndexed = [];
848 const dynamic = [];
849 fragment.inputs.forEach((param, index) => {
850 if (param.indexed) {
851 if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") {
852 indexed.push(ParamType.from({ type: "bytes32", name: param.name }));
853 dynamic.push(true);
854 }
855 else {
856 indexed.push(param);
857 dynamic.push(false);
858 }
859 }
860 else {
861 nonIndexed.push(param);
862 dynamic.push(false);
863 }
864 });
865 const resultIndexed = (topics != null) ? this.#abiCoder.decode(indexed, concat(topics)) : null;
866 const resultNonIndexed = this.#abiCoder.decode(nonIndexed, data, true);
867 //const result: (Array<any> & { [ key: string ]: any }) = [ ];
868 const values = [];
869 const keys = [];
870 let nonIndexedIndex = 0, indexedIndex = 0;
871 fragment.inputs.forEach((param, index) => {
872 let value = null;
873 if (param.indexed) {
874 if (resultIndexed == null) {
875 value = new Indexed(null);
876 }
877 else if (dynamic[index]) {
878 value = new Indexed(resultIndexed[indexedIndex++]);
879 }
880 else {
881 try {
882 value = resultIndexed[indexedIndex++];
883 }
884 catch (error) {
885 value = error;
886 }
887 }
888 }
889 else {
890 try {
891 value = resultNonIndexed[nonIndexedIndex++];
892 }

Callers 1

parseLogMethod · 0.95

Calls 10

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

Tested by

no test coverage detected