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

Function toBeArray

lib.esm/utils/maths.js:182–197  ·  view source on GitHub ↗
(_value)

Source from the content-addressed store, hash-verified

180 * Converts %%value%% to a Big Endian Uint8Array.
181 */
182export function toBeArray(_value) {
183 const value = getUint(_value, "value");
184 if (value === BN_0) {
185 return new Uint8Array([]);
186 }
187 let hex = value.toString(16);
188 if (hex.length % 2) {
189 hex = "0" + hex;
190 }
191 const result = new Uint8Array(hex.length / 2);
192 for (let i = 0; i < result.length; i++) {
193 const offset = i * 2;
194 result[i] = parseInt(hex.substring(offset, offset + 2), 16);
195 }
196 return result;
197}
198/**
199 * Returns a [[HexString]] for %%value%% safe to use as a //Quantity//.
200 *

Callers 15

toUint256Function · 0.90
numPadFunction · 0.90
fromExtendedKeyMethod · 0.90
verifyFunction · 0.90
getValueFunction · 0.90
hashAuthorizationFunction · 0.90
_packFunction · 0.90
formatNumberFunction · 0.90
formatAuthorizationListFunction · 0.90
_serializeLegacyFunction · 0.90

Calls 2

getUintFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected