@swapkit/helpers 1.0.0-rc.26 → 1.0.0-rc.28
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/index.cjs +1 -1
- package/dist/index.es.js +302 -308
- package/package.json +5 -5
- package/src/modules/assetValue.ts +0 -11
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.
|
|
13
|
-
"@swapkit/types": "1.0.0-rc.
|
|
12
|
+
"@swapkit/tokens": "1.0.0-rc.10",
|
|
13
|
+
"@swapkit/types": "1.0.0-rc.10"
|
|
14
14
|
},
|
|
15
15
|
"eslintConfig": {
|
|
16
16
|
"extends": "../../../internal/eslint-config"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@swapkit/tokens": "1.0.0-rc.
|
|
20
|
-
"@swapkit/types": "1.0.0-rc.
|
|
19
|
+
"@swapkit/tokens": "1.0.0-rc.10",
|
|
20
|
+
"@swapkit/types": "1.0.0-rc.10"
|
|
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.
|
|
45
|
+
"version": "1.0.0-rc.28",
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "vite build",
|
|
48
48
|
"clean": "rm -rf dist vite.config.ts.* .turbo node_modules",
|
|
@@ -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) {
|