@swapkit/core 1.0.0-rc.21 → 1.0.0-rc.23

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
@@ -2,7 +2,7 @@
2
2
  "author": "swapkit-oss-team",
3
3
  "dependencies": {
4
4
  "@swapkit/types": "1.0.0-rc.7",
5
- "@swapkit/helpers": "1.0.0-rc.16"
5
+ "@swapkit/helpers": "1.0.0-rc.17"
6
6
  },
7
7
  "description": "SwapKit Lib core",
8
8
  "devDependencies": {
@@ -15,16 +15,16 @@
15
15
  "@internal/config": "0.0.0-internal.0",
16
16
  "@swapkit/api": "1.0.0-rc.7",
17
17
  "@swapkit/tokens": "1.0.0-rc.7",
18
- "@swapkit/toolbox-cosmos": "1.0.0-rc.18",
19
- "@swapkit/toolbox-evm": "1.0.0-rc.17",
20
- "@swapkit/toolbox-utxo": "1.0.0-rc.17"
18
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.19",
19
+ "@swapkit/toolbox-evm": "1.0.0-rc.19",
20
+ "@swapkit/toolbox-utxo": "1.0.0-rc.18"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@swapkit/api": "1.0.0-rc.7",
24
24
  "@swapkit/tokens": "1.0.0-rc.7",
25
- "@swapkit/toolbox-cosmos": "1.0.0-rc.18",
26
- "@swapkit/toolbox-evm": "1.0.0-rc.17",
27
- "@swapkit/toolbox-utxo": "1.0.0-rc.17"
25
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.19",
26
+ "@swapkit/toolbox-evm": "1.0.0-rc.19",
27
+ "@swapkit/toolbox-utxo": "1.0.0-rc.18"
28
28
  },
29
29
  "eslintConfig": {
30
30
  "extends": "../../../internal/eslint-config"
@@ -52,7 +52,7 @@
52
52
  "repository": "https://github.com/thorswap/SwapKit.git",
53
53
  "type": "module",
54
54
  "types": "./dist/index.d.ts",
55
- "version": "1.0.0-rc.21",
55
+ "version": "1.0.0-rc.23",
56
56
  "scripts": {
57
57
  "build": "NODE_OPTIONS=--max_old_space_size=16384 vite build",
58
58
  "clean": "rm -rf dist vite.config.ts.* .turbo node_modules",
@@ -105,7 +105,7 @@ export class SwapKitCore<T = ''> {
105
105
  value: value
106
106
  ? new SwapKitNumber({
107
107
  value: !isHexString(value) ? parseUnits(value, 'wei').toString(16) : value,
108
- }).baseValueBigInt
108
+ }).getBaseValue('bigint')
109
109
  : 0n,
110
110
  };
111
111
 
@@ -177,18 +177,24 @@ export class SwapKitCore<T = ''> {
177
177
  getWalletByChain = async (chain: Chain, potentialScamFilter?: boolean) => {
178
178
  const address = this.getAddress(chain);
179
179
  if (!address) return null;
180
+ const defaultBalance = [AssetValue.fromChainOrSignature(chain)];
181
+ const walletType = this.connectedChains[chain]?.walletType as WalletOption;
180
182
 
181
- const balance = (await this.getWallet(chain)?.getBalance(address, potentialScamFilter)) ?? [
182
- AssetValue.fromChainOrSignature(chain),
183
- ];
183
+ try {
184
+ const balance = await this.getWallet(chain)?.getBalance(address, potentialScamFilter);
184
185
 
185
- this.connectedChains[chain] = {
186
- address,
187
- balance,
188
- walletType: this.connectedChains[chain]?.walletType as WalletOption,
189
- };
186
+ this.connectedChains[chain] = {
187
+ address,
188
+ balance: balance?.length ? balance : defaultBalance,
189
+ walletType,
190
+ };
190
191
 
191
- return { ...this.connectedChains[chain] };
192
+ return { ...this.connectedChains[chain] };
193
+ } catch (error) {
194
+ console.error(error);
195
+
196
+ return { address, balance: defaultBalance, walletType };
197
+ }
192
198
  };
193
199
 
194
200
  approveAssetValue = (assetValue: AssetValue, contractAddress?: string) =>
@@ -489,7 +495,7 @@ export class SwapKitCore<T = ''> {
489
495
  type === 'bond' ? MemoType.BOND : type === 'unbond' ? MemoType.UNBOND : MemoType.LEAVE;
490
496
  const memo = getMemoFor(memoType, {
491
497
  address,
492
- unbondAmount: type === 'unbond' ? assetValue.baseValueNumber : undefined,
498
+ unbondAmount: type === 'unbond' ? assetValue.getBaseValue('number') : undefined,
493
499
  });
494
500
 
495
501
  return this.#thorchainTransfer({
@@ -621,7 +627,7 @@ export class SwapKitCore<T = ''> {
621
627
  };
622
628
 
623
629
  #approve = async <T = string>({
624
- assetValue: { baseValueBigInt, address, chain, isGasAsset, isSynthetic },
630
+ assetValue: { getBaseValue, address, chain, isGasAsset, isSynthetic },
625
631
  type = 'checkOnly',
626
632
  contractAddress,
627
633
  }: {
@@ -647,7 +653,7 @@ export class SwapKitCore<T = ''> {
647
653
  contractAddress || ((await this.#getInboundDataByChain(chain)).router as string);
648
654
 
649
655
  return walletAction({
650
- amount: baseValueBigInt,
656
+ amount: getBaseValue('bigint'),
651
657
  assetAddress: address,
652
658
  from,
653
659
  spenderAddress,