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

Function getBigInt

lib.esm/utils/maths.js:69–91  ·  view source on GitHub ↗
(value, name)

Source from the content-addressed store, hash-verified

67 * a BigInt, then an ArgumentError will be thrown for %%name%%.
68 */
69export function getBigInt(value, name) {
70 switch (typeof (value)) {
71 case "bigint": return value;
72 case "number":
73 assertArgument(Number.isInteger(value), "underflow", name || "value", value);
74 assertArgument(value >= -maxValue && value <= maxValue, "overflow", name || "value", value);
75 return BigInt(value);
76 case "string":
77 try {
78 if (value === "") {
79 throw new Error("empty string");
80 }
81 if (value[0] === "-" && value[1] !== "-") {
82 return -BigInt(value.substring(1));
83 }
84 return BigInt(value);
85 }
86 catch (e) {
87 assertArgument(false, `invalid BigNumberish string: ${e.message}`, name || "value", value);
88 }
89 }
90 assertArgument(false, "invalid BigNumberish value", name || "value", value);
91}
92/**
93 * Returns %%value%% as a bigint, validating it is valid as a bigint
94 * value and that it is positive.

Callers 15

getChainIdMethod · 0.90
getChainIdVMethod · 0.90
getNormalizedVMethod · 0.90
fromMethod · 0.90
fromValueMethod · 0.90
constructorMethod · 0.90
chainIdMethod · 0.90
matchesMethod · 0.90
getFeeDataFuncMethod · 0.90
estimateGasMethod · 0.90
getBalanceMethod · 0.90
getStorageMethod · 0.90

Calls 1

assertArgumentFunction · 0.90

Tested by

no test coverage detected