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

Method encodeEventLog

lib.esm/abi/interface.js:916–955  ·  view source on GitHub ↗
(fragment, values)

Source from the content-addressed store, hash-verified

914 return topics;
915 }
916 encodeEventLog(fragment, values) {
917 if (typeof (fragment) === "string") {
918 const f = this.getEvent(fragment);
919 assertArgument(f, "unknown event", "eventFragment", fragment);
920 fragment = f;
921 }
922 const topics = [];
923 const dataTypes = [];
924 const dataValues = [];
925 if (!fragment.anonymous) {
926 topics.push(fragment.topicHash);
927 }
928 assertArgument(values.length === fragment.inputs.length, "event arguments/values mismatch", "values", values);
929 fragment.inputs.forEach((param, index) => {
930 const value = values[index];
931 if (param.indexed) {
932 if (param.type === "string") {
933 topics.push(id(value));
934 }
935 else if (param.type === "bytes") {
936 topics.push(keccak256(value));
937 }
938 else if (param.baseType === "tuple" || param.baseType === "array") {
939 // @TODO
940 throw new Error("not implemented");
941 }
942 else {
943 topics.push(this.#abiCoder.encode([param.type], [value]));
944 }
945 }
946 else {
947 dataTypes.push(param);
948 dataValues.push(value);
949 }
950 });
951 return {
952 data: this.#abiCoder.encode(dataTypes, dataValues),
953 topics: topics
954 };
955 }
956 // Decode a filter for the event and the search criteria
957 decodeEventLog(fragment, data, topics) {
958 if (typeof (fragment) === "string") {

Callers 1

test-abi.jsFile · 0.45

Calls 5

getEventMethod · 0.95
assertArgumentFunction · 0.90
idFunction · 0.90
keccak256Function · 0.90
encodeMethod · 0.45

Tested by

no test coverage detected