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

Method encodeTopic

js/src/static_dependencies/ethers/interface.js:747–768  ·  view source on GitHub ↗
(param, value)

Source from the content-addressed store, hash-verified

745 }
746 // @TODO: Use the coders for this; to properly support tuples, etc.
747 const encodeTopic = (param, value) => {
748 if (param.type === "string") {
749 return id(value);
750 }
751 else if (param.type === "bytes") {
752 return keccak256(value);
753 }
754 if (param.type === "bool" && typeof (value) === "boolean") {
755 value = (value ? "0x01" : "0x00");
756 }
757 else if (param.type.match(/^u?int/)) {
758 value = toBeHex(value); // @TODO: Should this toTwos??
759 }
760 else if (param.type.match(/^bytes/)) {
761 value = zeroPadBytes(value, 32);
762 }
763 else if (param.type === "address") {
764 // Check addresses are valid
765 this.#abiCoder.encode(["address"], [value]);
766 }
767 return zeroPadValue(hexlify(value), 32);
768 };
769 values.forEach((value, index) => {
770 const param = fragment.inputs[index];
771 if (!param.indexed) {

Callers

nothing calls this directly

Calls 8

idFunction · 0.90
keccak256Function · 0.90
toBeHexFunction · 0.90
zeroPadBytesFunction · 0.90
zeroPadValueFunction · 0.90
hexlifyFunction · 0.90
matchMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected