@subwallet/extension-base 1.1.64-0 → 1.1.65-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.
@@ -114,6 +114,7 @@ async function checkSupportTransfer(networkKey, tokenInfo, substrateApiMap, chai
114
114
  return result;
115
115
  }
116
116
  const createTransferExtrinsic = async _ref => {
117
+ var _tokenInfo$metadata;
117
118
  let {
118
119
  from,
119
120
  networkKey,
@@ -124,6 +125,10 @@ const createTransferExtrinsic = async _ref => {
124
125
  value
125
126
  } = _ref;
126
127
  const api = substrateApi.api;
128
+ const isDisableTransfer = (_tokenInfo$metadata = tokenInfo.metadata) === null || _tokenInfo$metadata === void 0 ? void 0 : _tokenInfo$metadata.isDisableTransfer;
129
+ if (isDisableTransfer) {
130
+ return [null, value];
131
+ }
127
132
 
128
133
  // @ts-ignore
129
134
  let transfer = null;
@@ -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.1.64-0'
16
+ version: '1.1.65-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -12,6 +13,7 @@ var _utils = require("@subwallet/extension-base/koni/api/tokens/wasm/utils");
12
13
  var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
13
14
  var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
14
15
  var _utils3 = require("@subwallet/extension-base/utils");
16
+ var _bignumber = _interopRequireDefault(require("bignumber.js"));
15
17
  var _rxjs = require("rxjs");
16
18
  var _util = require("@polkadot/util");
17
19
  var _evm = require("../evm");
@@ -233,6 +235,15 @@ const subscribeBridgedBalance = async _ref4 => {
233
235
  });
234
236
  };
235
237
  };
238
+ function extractOkResponse(response) {
239
+ if ('ok' in response) {
240
+ return response.ok;
241
+ }
242
+ if ('Ok' in response) {
243
+ return response.Ok;
244
+ }
245
+ return undefined;
246
+ }
236
247
  const subscribePSP22Balance = _ref5 => {
237
248
  let {
238
249
  addresses,
@@ -254,15 +265,17 @@ const subscribePSP22Balance = _ref5 => {
254
265
  const contract = psp22ContractMap[tokenInfo.slug];
255
266
  const balances = await Promise.all(addresses.map(async address => {
256
267
  try {
257
- var _balanceOf$output, _ref7;
268
+ var _balanceOf$output;
258
269
  const _balanceOf = await contract.query['psp22::balanceOf'](address, {
259
270
  gasLimit: (0, _utils.getDefaultWeightV2)(substrateApi)
260
271
  }, address);
261
272
  const balanceObj = _balanceOf === null || _balanceOf === void 0 ? void 0 : (_balanceOf$output = _balanceOf.output) === null || _balanceOf$output === void 0 ? void 0 : _balanceOf$output.toPrimitive();
273
+ const freeResponse = extractOkResponse(balanceObj);
274
+ const free = freeResponse ? new _bignumber.default(freeResponse).toString() : '0';
262
275
  return {
263
276
  address: address,
264
277
  tokenSlug: tokenInfo.slug,
265
- free: _balanceOf.output ? (_ref7 = balanceObj.ok) !== null && _ref7 !== void 0 ? _ref7 : balanceObj.Ok : '0',
278
+ free,
266
279
  locked: '0',
267
280
  state: _KoniTypes.APIItemState.READY
268
281
  };
@@ -290,7 +303,7 @@ const subscribePSP22Balance = _ref5 => {
290
303
  clearInterval(interval);
291
304
  };
292
305
  };
293
- const subscribeTokensAccountsPallet = async _ref8 => {
306
+ const subscribeTokensAccountsPallet = async _ref7 => {
294
307
  let {
295
308
  addresses,
296
309
  assetMap,
@@ -298,7 +311,7 @@ const subscribeTokensAccountsPallet = async _ref8 => {
298
311
  chainInfo,
299
312
  includeNativeToken,
300
313
  substrateApi
301
- } = _ref8;
314
+ } = _ref7;
302
315
  const chain = chainInfo.slug;
303
316
  const tokenTypes = includeNativeToken ? [_types._AssetType.NATIVE, _types._AssetType.LOCAL] : [_types._AssetType.LOCAL];
304
317
  const tokenMap = (0, _utils3.filterAssetsByChainAndType)(assetMap, chain, tokenTypes);
@@ -344,7 +357,7 @@ const subscribeTokensAccountsPallet = async _ref8 => {
344
357
  });
345
358
  };
346
359
  };
347
- const subscribeAssetsAccountPallet = async _ref9 => {
360
+ const subscribeAssetsAccountPallet = async _ref8 => {
348
361
  let {
349
362
  addresses,
350
363
  assetMap,
@@ -352,7 +365,7 @@ const subscribeAssetsAccountPallet = async _ref9 => {
352
365
  chainInfo,
353
366
  includeNativeToken,
354
367
  substrateApi
355
- } = _ref9;
368
+ } = _ref8;
356
369
  const chain = chainInfo.slug;
357
370
  const tokenMap = (0, _utils3.filterAssetsByChainAndType)(assetMap, chain, [_types._AssetType.LOCAL]);
358
371
  Object.values(tokenMap).forEach(token => {
@@ -409,14 +422,14 @@ const subscribeAssetsAccountPallet = async _ref9 => {
409
422
  };
410
423
 
411
424
  // eslint-disable-next-line @typescript-eslint/require-await
412
- const subscribeOrmlTokensPallet = async _ref10 => {
425
+ const subscribeOrmlTokensPallet = async _ref9 => {
413
426
  let {
414
427
  addresses,
415
428
  assetMap,
416
429
  callback,
417
430
  chainInfo,
418
431
  substrateApi
419
- } = _ref10;
432
+ } = _ref9;
420
433
  const chain = chainInfo.slug;
421
434
  const tokenTypes = [_types._AssetType.LOCAL];
422
435
  const tokenMap = (0, _utils3.filterAssetsByChainAndType)(assetMap, chain, tokenTypes);
@@ -114,7 +114,12 @@ export const createTransferExtrinsic = async ({
114
114
  transferAll,
115
115
  value
116
116
  }) => {
117
+ var _tokenInfo$metadata;
117
118
  const api = substrateApi.api;
119
+ const isDisableTransfer = (_tokenInfo$metadata = tokenInfo.metadata) === null || _tokenInfo$metadata === void 0 ? void 0 : _tokenInfo$metadata.isDisableTransfer;
120
+ if (isDisableTransfer) {
121
+ return [null, value];
122
+ }
118
123
 
119
124
  // @ts-ignore
120
125
  let transfer = null;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.64-0",
20
+ "version": "1.1.65-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1869,11 +1869,11 @@
1869
1869
  "@reduxjs/toolkit": "^1.9.1",
1870
1870
  "@sora-substrate/type-definitions": "^1.17.7",
1871
1871
  "@substrate/connect": "^0.8.9",
1872
- "@subwallet/chain-list": "0.2.60",
1873
- "@subwallet/extension-base": "^1.1.64-0",
1874
- "@subwallet/extension-chains": "^1.1.64-0",
1875
- "@subwallet/extension-dapp": "^1.1.64-0",
1876
- "@subwallet/extension-inject": "^1.1.64-0",
1872
+ "@subwallet/chain-list": "0.2.61",
1873
+ "@subwallet/extension-base": "^1.1.65-0",
1874
+ "@subwallet/extension-chains": "^1.1.65-0",
1875
+ "@subwallet/extension-dapp": "^1.1.65-0",
1876
+ "@subwallet/extension-inject": "^1.1.65-0",
1877
1877
  "@subwallet/keyring": "^0.1.5",
1878
1878
  "@subwallet/ui-keyring": "^0.1.5",
1879
1879
  "@walletconnect/sign-client": "^2.8.4",
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.1.64-0'
10
+ version: '1.1.65-0'
11
11
  };
@@ -9,6 +9,7 @@ import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/tokens/wa
9
9
  import { _BALANCE_CHAIN_GROUP, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
10
10
  import { _checkSmartContractSupportByChain, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _getTokenTypesSupportedByChain, _getXcmAssetMultilocation, _isBridgedToken, _isChainEvmCompatible, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
11
11
  import { filterAssetsByChainAndType } from '@subwallet/extension-base/utils';
12
+ import BigN from 'bignumber.js';
12
13
  import { combineLatest, Observable } from 'rxjs';
13
14
  import { BN, BN_ZERO } from '@polkadot/util';
14
15
  import { subscribeERC20Interval } from "../evm.js";
@@ -222,6 +223,15 @@ const subscribeBridgedBalance = async ({
222
223
  });
223
224
  };
224
225
  };
226
+ function extractOkResponse(response) {
227
+ if ('ok' in response) {
228
+ return response.ok;
229
+ }
230
+ if ('Ok' in response) {
231
+ return response.Ok;
232
+ }
233
+ return undefined;
234
+ }
225
235
  const subscribePSP22Balance = ({
226
236
  addresses,
227
237
  assetMap,
@@ -241,15 +251,17 @@ const subscribePSP22Balance = ({
241
251
  const contract = psp22ContractMap[tokenInfo.slug];
242
252
  const balances = await Promise.all(addresses.map(async address => {
243
253
  try {
244
- var _balanceOf$output, _ref;
254
+ var _balanceOf$output;
245
255
  const _balanceOf = await contract.query['psp22::balanceOf'](address, {
246
256
  gasLimit: getDefaultWeightV2(substrateApi)
247
257
  }, address);
248
258
  const balanceObj = _balanceOf === null || _balanceOf === void 0 ? void 0 : (_balanceOf$output = _balanceOf.output) === null || _balanceOf$output === void 0 ? void 0 : _balanceOf$output.toPrimitive();
259
+ const freeResponse = extractOkResponse(balanceObj);
260
+ const free = freeResponse ? new BigN(freeResponse).toString() : '0';
249
261
  return {
250
262
  address: address,
251
263
  tokenSlug: tokenInfo.slug,
252
- free: _balanceOf.output ? (_ref = balanceObj.ok) !== null && _ref !== void 0 ? _ref : balanceObj.Ok : '0',
264
+ free,
253
265
  locked: '0',
254
266
  state: APIItemState.READY
255
267
  };