@swapkit/helpers 1.0.0-rc.27 → 1.0.0-rc.29

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/package.json CHANGED
@@ -9,15 +9,15 @@
9
9
  "vite": "4.4.9",
10
10
  "vitest": "0.34.4",
11
11
  "@internal/config": "0.0.0-rc.1",
12
- "@swapkit/tokens": "1.0.0-rc.9",
13
- "@swapkit/types": "1.0.0-rc.9"
12
+ "@swapkit/tokens": "1.0.0-rc.11",
13
+ "@swapkit/types": "1.0.0-rc.11"
14
14
  },
15
15
  "eslintConfig": {
16
16
  "extends": "../../../internal/eslint-config"
17
17
  },
18
18
  "peerDependencies": {
19
- "@swapkit/tokens": "1.0.0-rc.9",
20
- "@swapkit/types": "1.0.0-rc.9"
19
+ "@swapkit/tokens": "1.0.0-rc.11",
20
+ "@swapkit/types": "1.0.0-rc.11"
21
21
  },
22
22
  "exports": {
23
23
  ".": {
@@ -42,7 +42,7 @@
42
42
  "repository": "https://github.com/thorswap/SwapKit.git",
43
43
  "type": "module",
44
44
  "types": "./dist/index.d.ts",
45
- "version": "1.0.0-rc.27",
45
+ "version": "1.0.0-rc.29",
46
46
  "scripts": {
47
47
  "build": "vite build",
48
48
  "clean": "rm -rf dist vite.config.ts.* .turbo node_modules",
@@ -230,6 +230,9 @@ describe('SwapKitNumber', () => {
230
230
  currencyPosition: 'end',
231
231
  }),
232
232
  ).toBe('0,000057€');
233
+
234
+ const skNumber4 = new SwapKitNumber(12345);
235
+ expect(skNumber4.toCurrency()).toBe('$12,345');
233
236
  });
234
237
  });
235
238
 
@@ -66,16 +66,11 @@ const createAssetValue = async (assetString: string, value: NumberPrimitives = 0
66
66
  return new AssetValue({ decimal, value: parsedValue, identifier: assetString });
67
67
  };
68
68
 
69
- const cacheAssetValue = new Map<string, AssetValue>();
70
-
71
69
  export class AssetValue extends BigIntArithmetics {
72
70
  constructor(params: AssetValueParams) {
73
71
  const identifier =
74
72
  'identifier' in params ? params.identifier : `${params.chain}.${params.symbol}`;
75
73
 
76
- const cachedAsset = cacheAssetValue.get(identifier);
77
- if (cachedAsset) return cachedAsset.set(params.value);
78
-
79
74
  super(
80
75
  params.value instanceof BigIntArithmetics
81
76
  ? params.value
@@ -90,20 +85,14 @@ export class AssetValue extends BigIntArithmetics {
90
85
  this.address = assetInfo.address;
91
86
  this.isSynthetic = assetInfo.isSynthetic;
92
87
  this.isGasAsset = assetInfo.isGasAsset;
93
-
94
- cacheAssetValue.set(identifier, this);
95
88
  }
96
89
 
97
90
  address?: string;
98
91
  isSynthetic = false;
99
92
  isGasAsset = false;
100
- // @ts-expect-error cache is false positive on that case
101
93
  chain: Chain;
102
- // @ts-expect-error cache is false positive on that case
103
94
  symbol: string;
104
- // @ts-expect-error cache is false positive on that case
105
95
  ticker: string;
106
- // @ts-expect-error cache is false positive on that case
107
96
  type: ReturnType<typeof getAssetType>;
108
97
 
109
98
  toString(short = false) {
@@ -283,7 +283,7 @@ export class BigIntArithmetics {
283
283
  ? '0.00'
284
284
  : int === '0'
285
285
  ? `${parseFloat(`0.${dec}`)}`.replace('.', decimalSeparator)
286
- : `${integer}${dec ? `${decimalSeparator}${dec.slice(0, decimal)}` : ''}`;
286
+ : `${integer}${parseInt(dec) ? `${decimalSeparator}${dec.slice(0, decimal)}` : ''}`;
287
287
 
288
288
  return `${currencyPosition === 'start' ? currency : ''}${parsedValue}${
289
289
  currencyPosition === 'end' ? currency : ''