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

Function decodeBytes32String

js/src/static_dependencies/ethers/bytes32.js:23–39  ·  view source on GitHub ↗
(_bytes)

Source from the content-addressed store, hash-verified

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

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…