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

Function encodeBytes32String

ts/src/static_dependencies/ethers/bytes32.ts:16–26  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

14 * Encodes %%text%% as a Bytes32 string.
15 */
16export function encodeBytes32String(text: string): string {
17
18 // Get the bytes
19 const bytes = toUtf8Bytes(text);
20
21 // Check we have room for null-termination
22 if (bytes.length > 31) { throw new Error("bytes32 string must be less than 32 bytes"); }
23
24 // Zero-pad (implicitly null-terminates)
25 return zeroPadBytes(bytes, 32);
26}
27
28/**
29 * Encodes the Bytes32-encoded %%bytes%% into a string.

Callers

nothing calls this directly

Calls 2

toUtf8BytesFunction · 0.90
zeroPadBytesFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…