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

Function toQuantity

lib.commonjs/utils/maths.js:218–227  ·  view source on GitHub ↗

* Returns a [[HexString]] for %%value%% safe to use as a //Quantity//. * * A //Quantity// does not have and leading 0 values unless the value is * the literal value `0x0`. This is most commonly used for JSSON-RPC * numeric values.

(value)

Source from the content-addressed store, hash-verified

216 * numeric values.
217 */
218function toQuantity(value) {
219 let result = (0, data_js_1.hexlify)((0, data_js_1.isBytesLike)(value) ? value : toBeArray(value)).substring(2);
220 while (result.startsWith("0")) {
221 result = result.substring(1);
222 }
223 if (result === "") {
224 result = "0";
225 }
226 return "0x" + result;
227}
228exports.toQuantity = toQuantity;
229//# sourceMappingURL=maths.js.map

Callers

nothing calls this directly

Calls 1

toBeArrayFunction · 0.70

Tested by

no test coverage detected