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

Method encodeTopic

ts/src/static_dependencies/ethers/interface.ts:982–1001  ·  view source on GitHub ↗
(param: ParamType, value: any)

Source from the content-addressed store, hash-verified

980
981 // @TODO: Use the coders for this; to properly support tuples, etc.
982 const encodeTopic = (param: ParamType, value: any): string => {
983 if (param.type === "string") {
984 return id(value);
985 } else if (param.type === "bytes") {
986 return keccak256(value);
987 }
988
989 if (param.type === "bool" && typeof(value) === "boolean") {
990 value = (value ? "0x01": "0x00");
991 } else if (param.type.match(/^u?int/)) {
992 value = toBeHex(value); // @TODO: Should this toTwos??
993 } else if (param.type.match(/^bytes/)) {
994 value = zeroPadBytes(value, 32);
995 } else if (param.type === "address") {
996 // Check addresses are valid
997 this.#abiCoder.encode( [ "address" ], [ value ]);
998 }
999
1000 return zeroPadValue(hexlify(value), 32);
1001 };
1002
1003 values.forEach((value, index) => {
1004

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