@aa-sdk/core 4.3.0 → 4.3.1

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.
@@ -68,9 +68,9 @@ export const bigIntMultiply = (base, multiplier, roundingMode = RoundingMode.ROU
68
68
  // Get decimal places of b. Max decimal places is defined by the MultiplerSchema.
69
69
  const decimalPlaces = multiplier.toString().split(".")[1]?.length ?? 0;
70
70
  const val = roundingMode === RoundingMode.ROUND_UP
71
- ? BigInt(base) * BigInt(multiplier * 10 ** decimalPlaces) +
71
+ ? BigInt(base) * BigInt(Math.round(multiplier * 10 ** decimalPlaces)) +
72
72
  BigInt(10 ** decimalPlaces - 1)
73
- : BigInt(base) * BigInt(multiplier * 10 ** decimalPlaces);
73
+ : BigInt(base) * BigInt(Math.round(multiplier * 10 ** decimalPlaces));
74
74
  return val / BigInt(10 ** decimalPlaces);
75
75
  };
76
76
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bigint.js","sourceRoot":"","sources":["../../../src/utils/bigint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;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;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG,IAAc,EAAU,EAAE;IAC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AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAkB,EAClB,UAAoC,EACpC,eAA6B,YAAY,CAAC,QAAQ,EAClD,EAAE;IACF,IAAI,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;IACJ,CAAC;IAED,iFAAiF;IACjF,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IACvE,MAAM,GAAG,GACP,YAAY,KAAK,YAAY,CAAC,QAAQ;QACpC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU,GAAG,EAAE,IAAI,aAAa,CAAC;YACvD,MAAM,CAAC,EAAE,IAAI,aAAa,GAAG,CAAC,CAAC;QACjC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU,GAAG,EAAE,IAAI,aAAa,CAAC,CAAC;IAE9D,OAAO,GAAG,GAAG,MAAM,CAAC,EAAE,IAAI,aAAa,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAU,EAAE,CACtD,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC","sourcesContent":["import { keccak256, toHex } from \"viem\";\nimport type { BigNumberish, Multiplier } from \"../types\";\nimport { isMultiplier } from \"./schema.js\";\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\n/**\n * Returns the min bigint in a list of bigints\n *\n * @param {bigint[]} args a list of bigints to get the max of\n * @returns {bigint} the min bigint in the list\n */\nexport const bigIntMin = (...args: bigint[]): bigint => {\n if (!args.length) {\n throw new Error(\"bigIntMin requires at least one argument\");\n }\n\n return args.reduce((m, c) => (m < c ? m : c));\n};\n\n/**\n * Given a bigint and a min-max range, returns the min-max clamped bigint value\n *\n * @param {BigNumberish} value a bigint value to clamp\n * @param {BigNumberish | undefined} lower lower bound min max tuple value\n * @param {BigNumberish | undefined} upper upper bound min max tuple value\n * @returns {bigint} the clamped bigint value per given range\n */\nexport const bigIntClamp = (\n value: BigNumberish,\n lower: BigNumberish | null | undefined,\n upper: BigNumberish | null | undefined\n): bigint => {\n lower = lower != null ? BigInt(lower) : null;\n upper = upper != null ? BigInt(upper) : null;\n\n if (upper != null && lower != null && upper < lower) {\n throw new Error(\n `invalid range: upper bound ${upper} is less than lower bound ${lower}`\n );\n }\n\n let ret = BigInt(value);\n if (lower != null && lower > ret) {\n ret = lower;\n }\n if (upper != null && upper < ret) {\n ret = upper;\n }\n return ret;\n};\n\nexport enum RoundingMode {\n ROUND_DOWN = 0,\n ROUND_UP = 1,\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 (!isMultiplier({ multiplier })) {\n throw new Error(\n \"bigIntMultiply requires a multiplier validated number as the second argument\"\n );\n }\n\n // Get decimal places of b. Max decimal places is defined by the MultiplerSchema.\n const decimalPlaces = multiplier.toString().split(\".\")[1]?.length ?? 0;\n const val =\n roundingMode === RoundingMode.ROUND_UP\n ? BigInt(base) * BigInt(multiplier * 10 ** decimalPlaces) +\n BigInt(10 ** decimalPlaces - 1)\n : BigInt(base) * BigInt(multiplier * 10 ** decimalPlaces);\n\n return val / BigInt(10 ** decimalPlaces);\n};\n\n/**\n * Useful if you want to use a string, such as a user's email address, as salt to generate a unique SmartAccount per user.\n *\n * example:\n * ```\n * const salt = stringToIndex(\"alice@example.com\");\n *\n * export const account = new SimpleSmartContractAccount({\n * index: salt,\n * // other args omitted...\n * });\n * ```\n *\n * @param {string} phrase -- any string value.\n * @returns {bigint} the bigint value of the hashed string\n */\nexport const stringToIndex = (phrase: string): bigint =>\n BigInt(keccak256(toHex(phrase)));\n"]}
1
+ {"version":3,"file":"bigint.js","sourceRoot":"","sources":["../../../src/utils/bigint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;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;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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CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;IACJ,CAAC;IAED,iFAAiF;IACjF,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IACvE,MAAM,GAAG,GACP,YAAY,KAAK,YAAY,CAAC,QAAQ;QACpC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,IAAI,aAAa,CAAC,CAAC;YACnE,MAAM,CAAC,EAAE,IAAI,aAAa,GAAG,CAAC,CAAC;QACjC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,IAAI,aAAa,CAAC,CAAC,CAAC;IAE1E,OAAO,GAAG,GAAG,MAAM,CAAC,EAAE,IAAI,aAAa,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAU,EAAE,CACtD,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC","sourcesContent":["import { keccak256, toHex } from \"viem\";\nimport type { BigNumberish, Multiplier } from \"../types\";\nimport { isMultiplier } from \"./schema.js\";\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\n/**\n * Returns the min bigint in a list of bigints\n *\n * @param {bigint[]} args a list of bigints to get the max of\n * @returns {bigint} the min bigint in the list\n */\nexport const bigIntMin = (...args: bigint[]): bigint => {\n if (!args.length) {\n throw new Error(\"bigIntMin requires at least one argument\");\n }\n\n return args.reduce((m, c) => (m < c ? m : c));\n};\n\n/**\n * Given a bigint and a min-max range, returns the min-max clamped bigint value\n *\n * @param {BigNumberish} value a bigint value to clamp\n * @param {BigNumberish | undefined} lower lower bound min max tuple value\n * @param {BigNumberish | undefined} upper upper bound min max tuple value\n * @returns {bigint} the clamped bigint value per given range\n */\nexport const bigIntClamp = (\n value: BigNumberish,\n lower: BigNumberish | null | undefined,\n upper: BigNumberish | null | undefined\n): bigint => {\n lower = lower != null ? BigInt(lower) : null;\n upper = upper != null ? BigInt(upper) : null;\n\n if (upper != null && lower != null && upper < lower) {\n throw new Error(\n `invalid range: upper bound ${upper} is less than lower bound ${lower}`\n );\n }\n\n let ret = BigInt(value);\n if (lower != null && lower > ret) {\n ret = lower;\n }\n if (upper != null && upper < ret) {\n ret = upper;\n }\n return ret;\n};\n\nexport enum RoundingMode {\n ROUND_DOWN = 0,\n ROUND_UP = 1,\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 (!isMultiplier({ multiplier })) {\n throw new Error(\n \"bigIntMultiply requires a multiplier validated number as the second argument\"\n );\n }\n\n // Get decimal places of b. Max decimal places is defined by the MultiplerSchema.\n const decimalPlaces = multiplier.toString().split(\".\")[1]?.length ?? 0;\n const val =\n roundingMode === RoundingMode.ROUND_UP\n ? BigInt(base) * BigInt(Math.round(multiplier * 10 ** decimalPlaces)) +\n BigInt(10 ** decimalPlaces - 1)\n : BigInt(base) * BigInt(Math.round(multiplier * 10 ** decimalPlaces));\n\n return val / BigInt(10 ** decimalPlaces);\n};\n\n/**\n * Useful if you want to use a string, such as a user's email address, as salt to generate a unique SmartAccount per user.\n *\n * example:\n * ```\n * const salt = stringToIndex(\"alice@example.com\");\n *\n * export const account = new SimpleSmartContractAccount({\n * index: salt,\n * // other args omitted...\n * });\n * ```\n *\n * @param {string} phrase -- any string value.\n * @returns {bigint} the bigint value of the hashed string\n */\nexport const stringToIndex = (phrase: string): bigint =>\n BigInt(keccak256(toHex(phrase)));\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.3.0";
1
+ export declare const VERSION = "4.3.1";
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.3.0";
3
+ export const VERSION = "4.3.1";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.3.0\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.3.1\";\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.3.0";
1
+ export declare const VERSION = "4.3.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aa-sdk/core",
3
3
  "license": "MIT",
4
- "version": "4.3.0",
4
+ "version": "4.3.1",
5
5
  "description": "viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts",
6
6
  "author": "Alchemy",
7
7
  "type": "module",
@@ -64,5 +64,5 @@
64
64
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
65
65
  },
66
66
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
67
- "gitHead": "78c86103afeee309748c9d604af58bc7707c8b16"
67
+ "gitHead": "68052c506336d4c7eee1d2ee78e9b07892488351"
68
68
  }
@@ -91,9 +91,9 @@ export const bigIntMultiply = (
91
91
  const decimalPlaces = multiplier.toString().split(".")[1]?.length ?? 0;
92
92
  const val =
93
93
  roundingMode === RoundingMode.ROUND_UP
94
- ? BigInt(base) * BigInt(multiplier * 10 ** decimalPlaces) +
94
+ ? BigInt(base) * BigInt(Math.round(multiplier * 10 ** decimalPlaces)) +
95
95
  BigInt(10 ** decimalPlaces - 1)
96
- : BigInt(base) * BigInt(multiplier * 10 ** decimalPlaces);
96
+ : BigInt(base) * BigInt(Math.round(multiplier * 10 ** decimalPlaces));
97
97
 
98
98
  return val / BigInt(10 ** decimalPlaces);
99
99
  };
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.3.0";
3
+ export const VERSION = "4.3.1";