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

Method encodeEventLog

js/src/static_dependencies/ethers/interface.js:794–833  ·  view source on GitHub ↗
(fragment, values)

Source from the content-addressed store, hash-verified

792 return topics;
793 }
794 encodeEventLog(fragment, values) {
795 if (typeof (fragment) === "string") {
796 const f = this.getEvent(fragment);
797 assertArgument(f, "unknown event", "eventFragment", fragment);
798 fragment = f;
799 }
800 const topics = [];
801 const dataTypes = [];
802 const dataValues = [];
803 if (!fragment.anonymous) {
804 topics.push(fragment.topicHash);
805 }
806 assertArgument(values.length === fragment.inputs.length, "event arguments/values mismatch", "values", values);
807 fragment.inputs.forEach((param, index) => {
808 const value = values[index];
809 if (param.indexed) {
810 if (param.type === "string") {
811 topics.push(id(value));
812 }
813 else if (param.type === "bytes") {
814 topics.push(keccak256(value));
815 }
816 else if (param.baseType === "tuple" || param.baseType === "array") {
817 // @TODO
818 throw new Error("not implemented");
819 }
820 else {
821 topics.push(this.#abiCoder.encode([param.type], [value]));
822 }
823 }
824 else {
825 dataTypes.push(param);
826 dataValues.push(value);
827 }
828 });
829 return {
830 data: this.#abiCoder.encode(dataTypes, dataValues),
831 topics: topics
832 };
833 }
834 // Decode a filter for the event and the search criteria
835 decodeEventLog(fragment, data, topics) {
836 if (typeof (fragment) === "string") {

Callers

nothing calls this directly

Calls 7

getEventMethod · 0.95
assertArgumentFunction · 0.90
idFunction · 0.90
keccak256Function · 0.90
pushMethod · 0.80
forEachMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected