@w3ux/utils 1.0.0 → 1.0.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.
package/index.cjs CHANGED
@@ -359,9 +359,9 @@ var unitToPlanck = (val, units) => {
359
359
  const [integerPart, fractionalPart = ""] = strVal.split(".");
360
360
  let bigIntValue = BigInt(integerPart) * BigInt(10) ** BigInt(units);
361
361
  if (fractionalPart) {
362
- const fractionalScale = BigInt(10) ** BigInt(units - fractionalPart.length);
363
- const fractionalValue = BigInt(fractionalPart.padEnd(units, "0"));
364
- bigIntValue += fractionalValue / fractionalScale;
362
+ const paddedFractional = fractionalPart.padEnd(units, "0");
363
+ const fractionalValue = BigInt(paddedFractional);
364
+ bigIntValue += fractionalValue;
365
365
  }
366
366
  return bigIntValue;
367
367
  } catch (e) {
package/index.js CHANGED
@@ -287,9 +287,9 @@ var unitToPlanck = (val, units) => {
287
287
  const [integerPart, fractionalPart = ""] = strVal.split(".");
288
288
  let bigIntValue = BigInt(integerPart) * BigInt(10) ** BigInt(units);
289
289
  if (fractionalPart) {
290
- const fractionalScale = BigInt(10) ** BigInt(units - fractionalPart.length);
291
- const fractionalValue = BigInt(fractionalPart.padEnd(units, "0"));
292
- bigIntValue += fractionalValue / fractionalScale;
290
+ const paddedFractional = fractionalPart.padEnd(units, "0");
291
+ const fractionalValue = BigInt(paddedFractional);
292
+ bigIntValue += fractionalValue;
293
293
  }
294
294
  return bigIntValue;
295
295
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w3ux/utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "license": "GPL-3.0-only",
5
5
  "dependencies": {
6
6
  "@polkadot-api/substrate-bindings": "^0.9.3"
package/unit.cjs CHANGED
@@ -251,9 +251,9 @@ var unitToPlanck = (val, units) => {
251
251
  const [integerPart, fractionalPart = ""] = strVal.split(".");
252
252
  let bigIntValue = BigInt(integerPart) * BigInt(10) ** BigInt(units);
253
253
  if (fractionalPart) {
254
- const fractionalScale = BigInt(10) ** BigInt(units - fractionalPart.length);
255
- const fractionalValue = BigInt(fractionalPart.padEnd(units, "0"));
256
- bigIntValue += fractionalValue / fractionalScale;
254
+ const paddedFractional = fractionalPart.padEnd(units, "0");
255
+ const fractionalValue = BigInt(paddedFractional);
256
+ bigIntValue += fractionalValue;
257
257
  }
258
258
  return bigIntValue;
259
259
  } catch (e) {
package/unit.js CHANGED
@@ -194,9 +194,9 @@ var unitToPlanck = (val, units) => {
194
194
  const [integerPart, fractionalPart = ""] = strVal.split(".");
195
195
  let bigIntValue = BigInt(integerPart) * BigInt(10) ** BigInt(units);
196
196
  if (fractionalPart) {
197
- const fractionalScale = BigInt(10) ** BigInt(units - fractionalPart.length);
198
- const fractionalValue = BigInt(fractionalPart.padEnd(units, "0"));
199
- bigIntValue += fractionalValue / fractionalScale;
197
+ const paddedFractional = fractionalPart.padEnd(units, "0");
198
+ const fractionalValue = BigInt(paddedFractional);
199
+ bigIntValue += fractionalValue;
200
200
  }
201
201
  return bigIntValue;
202
202
  } catch (e) {