@subwallet/extension-base 1.3.18-0 → 1.3.19-0

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.
@@ -1484,25 +1484,29 @@ class KoniExtension {
1484
1484
  return tokensCanPayFee;
1485
1485
  }
1486
1486
  await Promise.all(tokenInfos.map(async tokenInfo => {
1487
- const tokenSlug = tokenInfo.slug;
1488
- const reserve = await (0, _utils6.getReserveForPool)(substrateApi.api, nativeTokenInfo, tokenInfo);
1489
- if (!reserve || !reserve[0] || !reserve[1] || reserve[0] === '0' || reserve[1] === '0') {
1490
- return;
1491
- }
1492
- const rate = new _bignumber.default(reserve[1]).div(reserve[0]).toFixed();
1493
- const tokenCanPayFee = {
1494
- slug: tokenSlug,
1495
- free: tokensHasBalanceInfoMap[tokenSlug].free,
1496
- rate
1497
- };
1498
- if (feeAmount === undefined) {
1499
- tokensCanPayFee.push(tokenCanPayFee);
1500
- } else {
1501
- const amount = (0, _utils6.estimateTokensForPool)(feeAmount, reserve);
1502
- const liquidityError = (0, _utils6.checkLiquidityForPool)(amount, reserve[0], reserve[1]);
1503
- if (!liquidityError) {
1487
+ try {
1488
+ const tokenSlug = tokenInfo.slug;
1489
+ const reserve = await (0, _utils6.getReserveForPool)(substrateApi.api, nativeTokenInfo, tokenInfo);
1490
+ if (!reserve || !reserve[0] || !reserve[1] || reserve[0] === '0' || reserve[1] === '0') {
1491
+ return;
1492
+ }
1493
+ const rate = new _bignumber.default(reserve[1]).div(reserve[0]).toFixed();
1494
+ const tokenCanPayFee = {
1495
+ slug: tokenSlug,
1496
+ free: tokensHasBalanceInfoMap[tokenSlug].free,
1497
+ rate
1498
+ };
1499
+ if (feeAmount === undefined) {
1504
1500
  tokensCanPayFee.push(tokenCanPayFee);
1501
+ } else {
1502
+ const amount = (0, _utils6.estimateTokensForPool)(feeAmount, reserve);
1503
+ const liquidityError = (0, _utils6.checkLiquidityForPool)(amount, reserve[0], reserve[1]);
1504
+ if (!liquidityError) {
1505
+ tokensCanPayFee.push(tokenCanPayFee);
1506
+ }
1505
1507
  }
1508
+ } catch (e) {
1509
+ console.error('error when fetching pool with token', tokenInfo.slug, e);
1506
1510
  }
1507
1511
  }));
1508
1512
  return tokensCanPayFee;
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.3.18-0'
16
+ version: '1.3.19-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -107,7 +107,9 @@ class FeeService {
107
107
  clearInterval(interval);
108
108
  } else {
109
109
  const api = this.state.getEvmApi(chain);
110
- if (api) {
110
+
111
+ // TODO: Handle case type === evm and not have api
112
+ if (type === 'evm' && api) {
111
113
  (0, _utils2.calculateGasFeeParams)(api, chain).then(info => {
112
114
  observer.next(info);
113
115
  }).catch(e => {
@@ -121,6 +121,7 @@ class AssetHubSwapHandler {
121
121
  };
122
122
  return [step, fee];
123
123
  } catch (e) {
124
+ console.error('Error creating xcm step', e);
124
125
  return undefined;
125
126
  }
126
127
  }
@@ -135,7 +136,7 @@ class AssetHubSwapHandler {
135
136
  return Promise.resolve(undefined);
136
137
  }
137
138
  generateOptimalProcess(params) {
138
- return this.swapBaseHandler.generateOptimalProcess(params, [this.getXcmStep, this.getSubmitStep]);
139
+ return this.swapBaseHandler.generateOptimalProcess(params, [this.getXcmStep.bind(this), this.getSubmitStep.bind(this)]);
139
140
  }
140
141
  async getSwapQuote(request) {
141
142
  const fromAsset = this.chainService.getAssetBySlug(request.pair.from);
@@ -42,7 +42,7 @@ class SwapBaseHandler {
42
42
  };
43
43
  try {
44
44
  for (const genStepFunc of genStepFuncList) {
45
- const step = await genStepFunc.bind(this, params)();
45
+ const step = await genStepFunc(params);
46
46
  if (step) {
47
47
  result.steps.push({
48
48
  id: result.steps.length,
@@ -461,7 +461,7 @@ class ChainflipSwapHandler {
461
461
  return Promise.resolve(undefined);
462
462
  }
463
463
  generateOptimalProcess(params) {
464
- return this.swapBaseHandler.generateOptimalProcess(params, [this.getSubmitStep]);
464
+ return this.swapBaseHandler.generateOptimalProcess(params, [this.getSubmitStep.bind(this)]);
465
465
  }
466
466
  }
467
467
  exports.ChainflipSwapHandler = ChainflipSwapHandler;
@@ -136,6 +136,7 @@ class HydradxHandler {
136
136
  };
137
137
  return [step, fee];
138
138
  } catch (e) {
139
+ console.error('Error creating xcm step', e);
139
140
  return undefined;
140
141
  }
141
142
  }
@@ -190,9 +191,9 @@ class HydradxHandler {
190
191
  return Promise.resolve(undefined);
191
192
  }
192
193
  generateOptimalProcess(params) {
193
- return this.swapBaseHandler.generateOptimalProcess(params, [this.getXcmStep,
194
+ return this.swapBaseHandler.generateOptimalProcess(params, [this.getXcmStep.bind(this),
194
195
  // this.getFeeOptionStep.bind(this),
195
- this.getSubmitStep]);
196
+ this.getSubmitStep.bind(this)]);
196
197
  }
197
198
  getSwapPathErrors(swapList) {
198
199
  return swapList.reduce((prev, current) => {
@@ -243,7 +243,7 @@ class SimpleSwapHandler {
243
243
  }
244
244
  }
245
245
  generateOptimalProcess(params) {
246
- return this.swapBaseHandler.generateOptimalProcess(params, [this.getSubmitStep]);
246
+ return this.swapBaseHandler.generateOptimalProcess(params, [this.getSubmitStep.bind(this)]);
247
247
  }
248
248
  async getSubmitStep(params) {
249
249
  if (params.selectedQuote) {
@@ -1444,25 +1444,29 @@ export default class KoniExtension {
1444
1444
  return tokensCanPayFee;
1445
1445
  }
1446
1446
  await Promise.all(tokenInfos.map(async tokenInfo => {
1447
- const tokenSlug = tokenInfo.slug;
1448
- const reserve = await getReserveForPool(substrateApi.api, nativeTokenInfo, tokenInfo);
1449
- if (!reserve || !reserve[0] || !reserve[1] || reserve[0] === '0' || reserve[1] === '0') {
1450
- return;
1451
- }
1452
- const rate = new BigN(reserve[1]).div(reserve[0]).toFixed();
1453
- const tokenCanPayFee = {
1454
- slug: tokenSlug,
1455
- free: tokensHasBalanceInfoMap[tokenSlug].free,
1456
- rate
1457
- };
1458
- if (feeAmount === undefined) {
1459
- tokensCanPayFee.push(tokenCanPayFee);
1460
- } else {
1461
- const amount = estimateTokensForPool(feeAmount, reserve);
1462
- const liquidityError = checkLiquidityForPool(amount, reserve[0], reserve[1]);
1463
- if (!liquidityError) {
1447
+ try {
1448
+ const tokenSlug = tokenInfo.slug;
1449
+ const reserve = await getReserveForPool(substrateApi.api, nativeTokenInfo, tokenInfo);
1450
+ if (!reserve || !reserve[0] || !reserve[1] || reserve[0] === '0' || reserve[1] === '0') {
1451
+ return;
1452
+ }
1453
+ const rate = new BigN(reserve[1]).div(reserve[0]).toFixed();
1454
+ const tokenCanPayFee = {
1455
+ slug: tokenSlug,
1456
+ free: tokensHasBalanceInfoMap[tokenSlug].free,
1457
+ rate
1458
+ };
1459
+ if (feeAmount === undefined) {
1464
1460
  tokensCanPayFee.push(tokenCanPayFee);
1461
+ } else {
1462
+ const amount = estimateTokensForPool(feeAmount, reserve);
1463
+ const liquidityError = checkLiquidityForPool(amount, reserve[0], reserve[1]);
1464
+ if (!liquidityError) {
1465
+ tokensCanPayFee.push(tokenCanPayFee);
1466
+ }
1465
1467
  }
1468
+ } catch (e) {
1469
+ console.error('error when fetching pool with token', tokenInfo.slug, e);
1466
1470
  }
1467
1471
  }));
1468
1472
  return tokensCanPayFee;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.3.18-0",
20
+ "version": "1.3.19-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -2564,10 +2564,10 @@
2564
2564
  "@sora-substrate/type-definitions": "^1.17.7",
2565
2565
  "@substrate/connect": "^0.8.9",
2566
2566
  "@subwallet/chain-list": "0.2.99-beta.14",
2567
- "@subwallet/extension-base": "^1.3.18-0",
2568
- "@subwallet/extension-chains": "^1.3.18-0",
2569
- "@subwallet/extension-dapp": "^1.3.18-0",
2570
- "@subwallet/extension-inject": "^1.3.18-0",
2567
+ "@subwallet/extension-base": "^1.3.19-0",
2568
+ "@subwallet/extension-chains": "^1.3.19-0",
2569
+ "@subwallet/extension-dapp": "^1.3.19-0",
2570
+ "@subwallet/extension-inject": "^1.3.19-0",
2571
2571
  "@subwallet/keyring": "^0.1.8-beta.0",
2572
2572
  "@subwallet/ui-keyring": "^0.1.8-beta.0",
2573
2573
  "@ton/core": "^0.56.3",
package/packageInfo.js CHANGED
@@ -7,5 +7,5 @@ export const packageInfo = {
7
7
  name: '@subwallet/extension-base',
8
8
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
9
9
  type: 'esm',
10
- version: '1.3.18-0'
10
+ version: '1.3.19-0'
11
11
  };
@@ -101,7 +101,9 @@ export default class FeeService {
101
101
  clearInterval(interval);
102
102
  } else {
103
103
  const api = this.state.getEvmApi(chain);
104
- if (api) {
104
+
105
+ // TODO: Handle case type === evm and not have api
106
+ if (type === 'evm' && api) {
105
107
  calculateGasFeeParams(api, chain).then(info => {
106
108
  observer.next(info);
107
109
  }).catch(e => {
@@ -114,6 +114,7 @@ export class AssetHubSwapHandler {
114
114
  };
115
115
  return [step, fee];
116
116
  } catch (e) {
117
+ console.error('Error creating xcm step', e);
117
118
  return undefined;
118
119
  }
119
120
  }
@@ -128,7 +129,7 @@ export class AssetHubSwapHandler {
128
129
  return Promise.resolve(undefined);
129
130
  }
130
131
  generateOptimalProcess(params) {
131
- return this.swapBaseHandler.generateOptimalProcess(params, [this.getXcmStep, this.getSubmitStep]);
132
+ return this.swapBaseHandler.generateOptimalProcess(params, [this.getXcmStep.bind(this), this.getSubmitStep.bind(this)]);
132
133
  }
133
134
  async getSwapQuote(request) {
134
135
  const fromAsset = this.chainService.getAssetBySlug(request.pair.from);
@@ -34,7 +34,7 @@ export class SwapBaseHandler {
34
34
  };
35
35
  try {
36
36
  for (const genStepFunc of genStepFuncList) {
37
- const step = await genStepFunc.bind(this, params)();
37
+ const step = await genStepFunc(params);
38
38
  if (step) {
39
39
  result.steps.push({
40
40
  id: result.steps.length,
@@ -453,6 +453,6 @@ export class ChainflipSwapHandler {
453
453
  return Promise.resolve(undefined);
454
454
  }
455
455
  generateOptimalProcess(params) {
456
- return this.swapBaseHandler.generateOptimalProcess(params, [this.getSubmitStep]);
456
+ return this.swapBaseHandler.generateOptimalProcess(params, [this.getSubmitStep.bind(this)]);
457
457
  }
458
458
  }
@@ -128,6 +128,7 @@ export class HydradxHandler {
128
128
  };
129
129
  return [step, fee];
130
130
  } catch (e) {
131
+ console.error('Error creating xcm step', e);
131
132
  return undefined;
132
133
  }
133
134
  }
@@ -182,9 +183,9 @@ export class HydradxHandler {
182
183
  return Promise.resolve(undefined);
183
184
  }
184
185
  generateOptimalProcess(params) {
185
- return this.swapBaseHandler.generateOptimalProcess(params, [this.getXcmStep,
186
+ return this.swapBaseHandler.generateOptimalProcess(params, [this.getXcmStep.bind(this),
186
187
  // this.getFeeOptionStep.bind(this),
187
- this.getSubmitStep]);
188
+ this.getSubmitStep.bind(this)]);
188
189
  }
189
190
  getSwapPathErrors(swapList) {
190
191
  return swapList.reduce((prev, current) => {
@@ -234,7 +234,7 @@ export class SimpleSwapHandler {
234
234
  }
235
235
  }
236
236
  generateOptimalProcess(params) {
237
- return this.swapBaseHandler.generateOptimalProcess(params, [this.getSubmitStep]);
237
+ return this.swapBaseHandler.generateOptimalProcess(params, [this.getSubmitStep.bind(this)]);
238
238
  }
239
239
  async getSubmitStep(params) {
240
240
  if (params.selectedQuote) {