@alchemy/common 0.0.0-alpha.4 → 0.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/bigint.d.ts +7 -0
- package/dist/esm/utils/bigint.js +12 -0
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/bigint.d.ts +7 -0
- package/dist/types/utils/bigint.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/utils/bigint.ts +14 -0
package/dist/esm/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { getAlchemyRpcUrl, isChainSupported, getSupportedChainIds, } from "./tra
|
|
|
7
7
|
export type * from "./utils/types.js";
|
|
8
8
|
export { assertNever } from "./utils/assertNever.js";
|
|
9
9
|
export { raise } from "./utils/raise.js";
|
|
10
|
-
export { bigIntMultiply } from "./utils/bigint.js";
|
|
10
|
+
export { bigIntMultiply, bigIntMax } from "./utils/bigint.js";
|
|
11
11
|
export { lowerAddress } from "./utils/lowerAddress.js";
|
|
12
12
|
export { createEip1193HandlerFactory } from "./utils/createEip1193HandlerFactory.js";
|
|
13
13
|
export type { AlchemyConnectionConfig } from "./transport/connectionSchema.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { alchemyTransport, isAlchemyTransport } from "./transport/alchemy.js";
|
|
|
4
4
|
export { getAlchemyRpcUrl, isChainSupported, getSupportedChainIds, } from "./transport/chainRegistry.js";
|
|
5
5
|
export { assertNever } from "./utils/assertNever.js";
|
|
6
6
|
export { raise } from "./utils/raise.js";
|
|
7
|
-
export { bigIntMultiply } from "./utils/bigint.js";
|
|
7
|
+
export { bigIntMultiply, bigIntMax } from "./utils/bigint.js";
|
|
8
8
|
export { lowerAddress } from "./utils/lowerAddress.js";
|
|
9
9
|
export { createEip1193HandlerFactory } from "./utils/createEip1193HandlerFactory.js";
|
|
10
10
|
export { AlchemyConnectionConfigSchema, validateAlchemyConnectionConfig, isAlchemyConnectionConfig, } from "./transport/connectionSchema.js";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIzD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,2BAA2B;AAC3B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIzD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,2BAA2B;AAC3B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAIrF,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AAEzC,SAAS;AACT,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAI5E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,4DAA4D;AAC5D,cAAc,aAAa,CAAC;AAE5B,sBAAsB;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,QAAQ,EACR,cAAc,EACd,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["// http\nexport type * from \"./rest/restClient.js\";\nexport type * from \"./rest/types.js\";\nexport { AlchemyRestClient } from \"./rest/restClient.js\";\n\n// transport\nexport type * from \"./transport/alchemy.js\";\nexport { alchemyTransport, isAlchemyTransport } from \"./transport/alchemy.js\";\n\n// chain registry utilities\nexport {\n getAlchemyRpcUrl,\n isChainSupported,\n getSupportedChainIds,\n} from \"./transport/chainRegistry.js\";\n\n// utils\nexport type * from \"./utils/types.js\";\nexport { assertNever } from \"./utils/assertNever.js\";\nexport { raise } from \"./utils/raise.js\";\nexport { bigIntMultiply, bigIntMax } from \"./utils/bigint.js\";\nexport { lowerAddress } from \"./utils/lowerAddress.js\";\nexport { createEip1193HandlerFactory } from \"./utils/createEip1193HandlerFactory.js\";\n\n// config\nexport type { AlchemyConnectionConfig } from \"./transport/connectionSchema.js\";\nexport {\n AlchemyConnectionConfigSchema,\n validateAlchemyConnectionConfig,\n isAlchemyConnectionConfig,\n} from \"./transport/connectionSchema.js\";\n\n// errors\nexport { BaseError } from \"./errors/BaseError.js\";\nexport { ChainNotFoundError } from \"./errors/ChainNotFoundError.js\";\nexport { AccountNotFoundError } from \"./errors/AccountNotFoundError.js\";\nexport { ConnectionConfigError } from \"./errors/ConnectionConfigError.js\";\nexport { FetchError } from \"./errors/FetchError.js\";\nexport { ServerError } from \"./errors/ServerError.js\";\nexport { InvalidRequestError } from \"./errors/InvalidRequestError.js\";\nexport { MethodUnsupportedError } from \"./errors/MethodUnsupportedError.js\";\n\n// actions\nexport type * from \"./actions/addBreadCrumb.js\";\nexport { addBreadCrumb } from \"./actions/addBreadCrumb.js\";\n\n// chains (convenience exports for Alchemy-supported chains)\nexport * from \"./chains.js\";\n\n// diagnostics logging\nexport { createLogger } from \"./logging/logger.js\";\nexport {\n setGlobalLoggerConfig,\n getGlobalLoggerConfig,\n LogLevel,\n isLevelEnabled,\n isNamespaceEnabled,\n} from \"./logging/config.js\";\nexport type { DiagnosticsLogger } from \"./logging/logger.js\";\nexport { InMemorySink } from \"./logging/sinks.js\";\n"]}
|
|
@@ -22,3 +22,10 @@ export declare enum RoundingMode {
|
|
|
22
22
|
* @returns {bigint} the bigint value of the multiplication with the number rounded by the rounding mode
|
|
23
23
|
*/
|
|
24
24
|
export declare const bigIntMultiply: (base: BigNumberish, multiplier: Multiplier["multiplier"], roundingMode?: RoundingMode) => bigint;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the max bigint in a list of bigints
|
|
27
|
+
*
|
|
28
|
+
* @param {bigint[]} args a list of bigints to get the max of
|
|
29
|
+
* @returns {bigint} the max bigint in the list
|
|
30
|
+
*/
|
|
31
|
+
export declare const bigIntMax: (...args: bigint[]) => bigint;
|
package/dist/esm/utils/bigint.js
CHANGED
|
@@ -34,4 +34,16 @@ export const bigIntMultiply = (base, multiplier, roundingMode = RoundingMode.ROU
|
|
|
34
34
|
? result / BigInt(10 ** decimalPlaces) + 1n
|
|
35
35
|
: result / BigInt(10 ** decimalPlaces);
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Returns the max bigint in a list of bigints
|
|
39
|
+
*
|
|
40
|
+
* @param {bigint[]} args a list of bigints to get the max of
|
|
41
|
+
* @returns {bigint} the max bigint in the list
|
|
42
|
+
*/
|
|
43
|
+
export const bigIntMax = (...args) => {
|
|
44
|
+
if (!args.length) {
|
|
45
|
+
throw new Error("bigIntMax requires at least one argument");
|
|
46
|
+
}
|
|
47
|
+
return args.reduce((m, c) => (m > c ? m : c));
|
|
48
|
+
};
|
|
37
49
|
//# sourceMappingURL=bigint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bigint.js","sourceRoot":"","sources":["../../../src/utils/bigint.ts"],"names":[],"mappings":"AAYA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2DAAc,CAAA;IACd,uDAAY,CAAA;AACd,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,UAAsB;IAC/C,MAAM,aAAa,GACjB,UAAU,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IAC9D,OAAO,aAAa,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAkB,EAClB,UAAoC,EACpC,eAA6B,YAAY,CAAC,QAAQ,EAClD,EAAE;IACF,IAAI,CAAC,iBAAiB,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAC;IACJ,CAAC;IAED,kFAAkF;IAClF,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IACvE,MAAM,MAAM,GACV,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,IAAI,aAAa,CAAC,CAAC,CAAC;IACtE,OAAO,YAAY,KAAK,YAAY,CAAC,QAAQ;QAC3C,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,aAAa,CAAC,GAAG,CAAC;QACxC,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,aAAa,CAAC,GAAG,EAAE;QAC3C,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,aAAa,CAAC,CAAC;AAC3C,CAAC,CAAC","sourcesContent":["/**\n * BigNumberish represents values that can be converted to BigInt\n */\nexport type BigNumberish = string | number | bigint;\n\n/**\n * Multiplier configuration for bigint multiplication\n */\nexport type Multiplier = {\n multiplier: number;\n};\n\nexport enum RoundingMode {\n ROUND_DOWN = 0,\n ROUND_UP = 1,\n}\n\n/**\n * Validates if a multiplier has acceptable precision (max 4 decimal places)\n *\n * @param {Multiplier} multiplier - the multiplier to validate\n * @returns {boolean} true if valid, false otherwise\n */\nfunction isValidMultiplier(multiplier: Multiplier): boolean {\n const decimalPlaces =\n multiplier.multiplier.toString().split(\".\")[1]?.length ?? 0;\n return decimalPlaces <= 4;\n}\n\n/**\n * Given a bigint and a number (which can be a float), returns the bigint value.\n * Note: this function has loss and will round down to the nearest integer.\n *\n * @param {BigNumberish} base - the number to be multiplied\n * @param {number} multiplier - the amount to multiply by\n * @param {RoundingMode} roundingMode - the rounding mode to use when calculating the percent. defaults to ROUND_UP\n * @returns {bigint} the bigint value of the multiplication with the number rounded by the rounding mode\n */\nexport const bigIntMultiply = (\n base: BigNumberish,\n multiplier: Multiplier[\"multiplier\"],\n roundingMode: RoundingMode = RoundingMode.ROUND_UP,\n) => {\n if (!isValidMultiplier({ multiplier })) {\n throw new Error(\n \"bigIntMultiply requires a multiplier validated number as the second argument (max 4 decimal places)\",\n );\n }\n\n // Get decimal places of b. Max decimal places is defined by the validation above.\n const decimalPlaces = multiplier.toString().split(\".\")[1]?.length ?? 0;\n const result =\n BigInt(base) * BigInt(Math.round(multiplier * 10 ** decimalPlaces));\n return roundingMode === RoundingMode.ROUND_UP &&\n result % BigInt(10 ** decimalPlaces) > 0\n ? result / BigInt(10 ** decimalPlaces) + 1n\n : result / BigInt(10 ** decimalPlaces);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"bigint.js","sourceRoot":"","sources":["../../../src/utils/bigint.ts"],"names":[],"mappings":"AAYA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2DAAc,CAAA;IACd,uDAAY,CAAA;AACd,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,UAAsB;IAC/C,MAAM,aAAa,GACjB,UAAU,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IAC9D,OAAO,aAAa,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAkB,EAClB,UAAoC,EACpC,eAA6B,YAAY,CAAC,QAAQ,EAClD,EAAE;IACF,IAAI,CAAC,iBAAiB,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAC;IACJ,CAAC;IAED,kFAAkF;IAClF,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IACvE,MAAM,MAAM,GACV,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,IAAI,aAAa,CAAC,CAAC,CAAC;IACtE,OAAO,YAAY,KAAK,YAAY,CAAC,QAAQ;QAC3C,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,aAAa,CAAC,GAAG,CAAC;QACxC,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,aAAa,CAAC,GAAG,EAAE;QAC3C,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,aAAa,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG,IAAc,EAAU,EAAE;IACrD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["/**\n * BigNumberish represents values that can be converted to BigInt\n */\nexport type BigNumberish = string | number | bigint;\n\n/**\n * Multiplier configuration for bigint multiplication\n */\nexport type Multiplier = {\n multiplier: number;\n};\n\nexport enum RoundingMode {\n ROUND_DOWN = 0,\n ROUND_UP = 1,\n}\n\n/**\n * Validates if a multiplier has acceptable precision (max 4 decimal places)\n *\n * @param {Multiplier} multiplier - the multiplier to validate\n * @returns {boolean} true if valid, false otherwise\n */\nfunction isValidMultiplier(multiplier: Multiplier): boolean {\n const decimalPlaces =\n multiplier.multiplier.toString().split(\".\")[1]?.length ?? 0;\n return decimalPlaces <= 4;\n}\n\n/**\n * Given a bigint and a number (which can be a float), returns the bigint value.\n * Note: this function has loss and will round down to the nearest integer.\n *\n * @param {BigNumberish} base - the number to be multiplied\n * @param {number} multiplier - the amount to multiply by\n * @param {RoundingMode} roundingMode - the rounding mode to use when calculating the percent. defaults to ROUND_UP\n * @returns {bigint} the bigint value of the multiplication with the number rounded by the rounding mode\n */\nexport const bigIntMultiply = (\n base: BigNumberish,\n multiplier: Multiplier[\"multiplier\"],\n roundingMode: RoundingMode = RoundingMode.ROUND_UP,\n) => {\n if (!isValidMultiplier({ multiplier })) {\n throw new Error(\n \"bigIntMultiply requires a multiplier validated number as the second argument (max 4 decimal places)\",\n );\n }\n\n // Get decimal places of b. Max decimal places is defined by the validation above.\n const decimalPlaces = multiplier.toString().split(\".\")[1]?.length ?? 0;\n const result =\n BigInt(base) * BigInt(Math.round(multiplier * 10 ** decimalPlaces));\n return roundingMode === RoundingMode.ROUND_UP &&\n result % BigInt(10 ** decimalPlaces) > 0\n ? result / BigInt(10 ** decimalPlaces) + 1n\n : result / BigInt(10 ** decimalPlaces);\n};\n\n/**\n * Returns the max bigint in a list of bigints\n *\n * @param {bigint[]} args a list of bigints to get the max of\n * @returns {bigint} the max bigint in the list\n */\nexport const bigIntMax = (...args: bigint[]): bigint => {\n if (!args.length) {\n throw new Error(\"bigIntMax requires at least one argument\");\n }\n\n return args.reduce((m, c) => (m > c ? m : c));\n};\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { getAlchemyRpcUrl, isChainSupported, getSupportedChainIds, } from "./tra
|
|
|
7
7
|
export type * from "./utils/types.js";
|
|
8
8
|
export { assertNever } from "./utils/assertNever.js";
|
|
9
9
|
export { raise } from "./utils/raise.js";
|
|
10
|
-
export { bigIntMultiply } from "./utils/bigint.js";
|
|
10
|
+
export { bigIntMultiply, bigIntMax } from "./utils/bigint.js";
|
|
11
11
|
export { lowerAddress } from "./utils/lowerAddress.js";
|
|
12
12
|
export { createEip1193HandlerFactory } from "./utils/createEip1193HandlerFactory.js";
|
|
13
13
|
export type { AlchemyConnectionConfig } from "./transport/connectionSchema.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,iBAAiB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,mBAAmB,wBAAwB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG9E,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AAGtC,mBAAmB,kBAAkB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,iBAAiB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,mBAAmB,wBAAwB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG9E,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AAGtC,mBAAmB,kBAAkB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAGrF,YAAY,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAG5E,mBAAmB,4BAA4B,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,cAAc,aAAa,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,QAAQ,EACR,cAAc,EACd,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -22,4 +22,11 @@ export declare enum RoundingMode {
|
|
|
22
22
|
* @returns {bigint} the bigint value of the multiplication with the number rounded by the rounding mode
|
|
23
23
|
*/
|
|
24
24
|
export declare const bigIntMultiply: (base: BigNumberish, multiplier: Multiplier["multiplier"], roundingMode?: RoundingMode) => bigint;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the max bigint in a list of bigints
|
|
27
|
+
*
|
|
28
|
+
* @param {bigint[]} args a list of bigints to get the max of
|
|
29
|
+
* @returns {bigint} the max bigint in the list
|
|
30
|
+
*/
|
|
31
|
+
export declare const bigIntMax: (...args: bigint[]) => bigint;
|
|
25
32
|
//# sourceMappingURL=bigint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bigint.d.ts","sourceRoot":"","sources":["../../../src/utils/bigint.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oBAAY,YAAY;IACtB,UAAU,IAAI;IACd,QAAQ,IAAI;CACb;AAcD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,YAAY,EAClB,YAAY,UAAU,CAAC,YAAY,CAAC,EACpC,eAAc,YAAoC,WAgBnD,CAAC"}
|
|
1
|
+
{"version":3,"file":"bigint.d.ts","sourceRoot":"","sources":["../../../src/utils/bigint.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oBAAY,YAAY;IACtB,UAAU,IAAI;IACd,QAAQ,IAAI;CACb;AAcD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,YAAY,EAClB,YAAY,UAAU,CAAC,YAAY,CAAC,EACpC,eAAc,YAAoC,WAgBnD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,MAAM,EAAE,KAAG,MAM7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alchemy/common",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.6",
|
|
4
4
|
"description": "A collection of interfaces and utilities to be used by other Alchemy packages",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
62
62
|
},
|
|
63
63
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "51d1115bb8a1507ba5fa56ad6b28ca03562106a6"
|
|
65
65
|
}
|
package/src/index.ts
CHANGED
|
@@ -18,7 +18,7 @@ export {
|
|
|
18
18
|
export type * from "./utils/types.js";
|
|
19
19
|
export { assertNever } from "./utils/assertNever.js";
|
|
20
20
|
export { raise } from "./utils/raise.js";
|
|
21
|
-
export { bigIntMultiply } from "./utils/bigint.js";
|
|
21
|
+
export { bigIntMultiply, bigIntMax } from "./utils/bigint.js";
|
|
22
22
|
export { lowerAddress } from "./utils/lowerAddress.js";
|
|
23
23
|
export { createEip1193HandlerFactory } from "./utils/createEip1193HandlerFactory.js";
|
|
24
24
|
|
package/src/utils/bigint.ts
CHANGED
|
@@ -56,3 +56,17 @@ export const bigIntMultiply = (
|
|
|
56
56
|
? result / BigInt(10 ** decimalPlaces) + 1n
|
|
57
57
|
: result / BigInt(10 ** decimalPlaces);
|
|
58
58
|
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns the max bigint in a list of bigints
|
|
62
|
+
*
|
|
63
|
+
* @param {bigint[]} args a list of bigints to get the max of
|
|
64
|
+
* @returns {bigint} the max bigint in the list
|
|
65
|
+
*/
|
|
66
|
+
export const bigIntMax = (...args: bigint[]): bigint => {
|
|
67
|
+
if (!args.length) {
|
|
68
|
+
throw new Error("bigIntMax requires at least one argument");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return args.reduce((m, c) => (m > c ? m : c));
|
|
72
|
+
};
|