MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / encodeBytes32String

Function encodeBytes32String

lib.esm/abi/bytes32.js:10–19  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

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

Callers 2

test-abi.tsFile · 0.90
test-abi.jsFile · 0.90

Calls 2

toUtf8BytesFunction · 0.90
zeroPadBytesFunction · 0.90

Tested by

no test coverage detected