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

Function decodeBytes32String

ts/src/static_dependencies/ethers/bytes32.ts:31–44  ·  view source on GitHub ↗
(_bytes: BytesLike)

Source from the content-addressed store, hash-verified

29 * Encodes the Bytes32-encoded %%bytes%% into a string.
30 */
31export function decodeBytes32String(_bytes: BytesLike): string {
32 const data = getBytes(_bytes, "bytes");
33
34 // Must be 32 bytes with a null-termination
35 if (data.length !== 32) { throw new Error("invalid bytes32 - not 32 bytes long"); }
36 if (data[31] !== 0) { throw new Error("invalid bytes32 string - no null terminator"); }
37
38 // Find the null termination
39 let length = 31;
40 while (data[length - 1] === 0) { length--; }
41
42 // Determine the string value
43 return toUtf8String(data.slice(0, length));
44}
45

Callers

nothing calls this directly

Calls 3

getBytesFunction · 0.90
toUtf8StringFunction · 0.90
sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…