@subwallet/extension-base 1.1.65-0 → 1.1.67-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.
Files changed (65) hide show
  1. package/cjs/koni/api/dotsama/transfer.js +11 -0
  2. package/cjs/koni/api/staking/bonding/relayChain.js +6 -0
  3. package/cjs/koni/api/tokens/wasm/utils.js +5 -3
  4. package/cjs/koni/background/cron.js +13 -0
  5. package/cjs/koni/background/handlers/State.js +2 -0
  6. package/cjs/packageInfo.js +1 -1
  7. package/cjs/services/balance-service/helpers/subscribe/index.js +1 -1
  8. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +67 -0
  9. package/cjs/services/chain-service/constants.js +8 -1
  10. package/cjs/services/chain-service/handler/EvmChainHandler.js +1 -1
  11. package/cjs/services/chain-service/handler/SubstrateApi.js +15 -9
  12. package/cjs/services/chain-service/handler/SubstrateChainHandler.js +76 -57
  13. package/cjs/services/chain-service/index.js +45 -30
  14. package/cjs/services/chain-service/types.js +1 -1
  15. package/cjs/services/chain-service/utils/index.js +38 -15
  16. package/cjs/services/chain-service/utils/patch.js +1 -1
  17. package/cjs/services/earning-service/constants/chains.js +2 -2
  18. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +3 -0
  19. package/cjs/services/earning-service/handlers/nomination-pool/index.js +1 -0
  20. package/cjs/services/earning-service/service.js +2 -2
  21. package/cjs/services/price-service/index.js +31 -17
  22. package/cjs/stores/CurrentCurrencyStore.js +18 -0
  23. package/cjs/stores/index.js +8 -1
  24. package/cjs/utils/gear/grc20.js +141 -0
  25. package/cjs/utils/gear/index.js +16 -0
  26. package/cjs/utils/index.js +40 -28
  27. package/koni/api/dotsama/transfer.js +13 -2
  28. package/koni/api/staking/bonding/relayChain.d.ts +1 -2
  29. package/koni/api/staking/bonding/relayChain.js +6 -0
  30. package/koni/api/tokens/wasm/utils.js +5 -3
  31. package/koni/background/cron.d.ts +2 -0
  32. package/koni/background/cron.js +14 -1
  33. package/koni/background/handlers/State.js +2 -0
  34. package/package.json +32 -15
  35. package/packageInfo.js +1 -1
  36. package/services/balance-service/helpers/subscribe/index.js +1 -1
  37. package/services/balance-service/helpers/subscribe/substrate/index.js +67 -2
  38. package/services/chain-service/constants.d.ts +1 -0
  39. package/services/chain-service/constants.js +8 -1
  40. package/services/chain-service/handler/EvmChainHandler.d.ts +1 -1
  41. package/services/chain-service/handler/EvmChainHandler.js +1 -1
  42. package/services/chain-service/handler/SubstrateApi.js +6 -0
  43. package/services/chain-service/handler/SubstrateChainHandler.d.ts +4 -1
  44. package/services/chain-service/handler/SubstrateChainHandler.js +76 -57
  45. package/services/chain-service/index.js +17 -8
  46. package/services/chain-service/types.js +1 -1
  47. package/services/chain-service/utils/index.d.ts +4 -0
  48. package/services/chain-service/utils/index.js +30 -15
  49. package/services/chain-service/utils/patch.js +1 -1
  50. package/services/earning-service/constants/chains.js +2 -2
  51. package/services/earning-service/handlers/native-staking/relay-chain.js +3 -0
  52. package/services/earning-service/handlers/nomination-pool/index.js +1 -0
  53. package/services/earning-service/service.js +2 -2
  54. package/services/price-service/index.d.ts +4 -1
  55. package/services/price-service/index.js +31 -17
  56. package/stores/CurrentCurrencyStore.d.ts +5 -0
  57. package/stores/CurrentCurrencyStore.js +10 -0
  58. package/stores/index.d.ts +1 -0
  59. package/stores/index.js +2 -1
  60. package/utils/gear/grc20.d.ts +29 -0
  61. package/utils/gear/grc20.js +131 -0
  62. package/utils/gear/index.d.ts +1 -0
  63. package/utils/gear/index.js +4 -0
  64. package/utils/index.d.ts +6 -5
  65. package/utils/index.js +7 -6
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GRC20 = exports.DEFAULT_GEAR_ADDRESS = void 0;
7
+ exports.getGRC20ContractPromise = getGRC20ContractPromise;
8
+ var _api = require("@gear-js/api");
9
+ var _sailsJs = require("sails-js");
10
+ var _types = require("@polkadot/types");
11
+ // Copyright 2019-2022 @subwallet/extension-base
12
+ // SPDX-License-Identifier: Apache-2.0
13
+
14
+ // https://github.com/breathx/gear-erc20/blob/master/js/src/lib.ts
15
+
16
+ const DEFAULT_GEAR_ADDRESS = {
17
+ ALICE: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
18
+ BOB: '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty'
19
+ };
20
+ exports.DEFAULT_GEAR_ADDRESS = DEFAULT_GEAR_ADDRESS;
21
+ class GRC20 {
22
+ constructor(api) {
23
+ let programId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0x';
24
+ this.api = api;
25
+ this.programId = programId;
26
+ const types = {
27
+ ActorId: '([u8; 32])',
28
+ U256: '([u64; 4])'
29
+ };
30
+ this.registry = new _types.TypeRegistry();
31
+ this.registry.setKnownTypes({
32
+ types
33
+ });
34
+ this.registry.register(types);
35
+ }
36
+ newCtorFromCode(code, name, symbol, decimals) {
37
+ const builder = new _sailsJs.TransactionBuilder(this.api, this.registry, 'upload_program', ['New', name, symbol, decimals], '(String, String, String, u8)', 'String', code);
38
+ this.programId = builder.programId;
39
+ return builder;
40
+ }
41
+ newCtorFromCodeId(codeId, name, symbol, decimals) {
42
+ const builder = new _sailsJs.TransactionBuilder(this.api, this.registry, 'create_program', ['New', name, symbol, decimals], '(String, String, String, u8)', 'String', codeId);
43
+ this.programId = builder.programId;
44
+ return builder;
45
+ }
46
+ approve(spender, value) {
47
+ return new _sailsJs.TransactionBuilder(this.api, this.registry, 'send_message', ['Approve', spender, value], '(String, ActorId, U256)', 'bool', this.programId);
48
+ }
49
+ fromTransfer(from, to, value) {
50
+ return new _sailsJs.TransactionBuilder(this.api, this.registry, 'send_message', ['FromTransfer', from, to, value], '(String, ActorId, ActorId, U256)', 'bool', this.programId);
51
+ }
52
+ setBalance(newBalance) {
53
+ return new _sailsJs.TransactionBuilder(this.api, this.registry, 'send_message', ['SetBalance', newBalance], '(String, U256)', 'bool', this.programId);
54
+ }
55
+ transfer(to, value) {
56
+ return new _sailsJs.TransactionBuilder(this.api, this.registry, 'send_message', ['Transfer', to, value], '(String, ActorId, U256)', 'bool', this.programId);
57
+ }
58
+ async allowance(owner, spender, originAddress, value, atBlock) {
59
+ const payload = this.registry.createType('(String, ActorId, ActorId)', ['Allowance', owner, spender]).toU8a();
60
+ const reply = await this.api.message.calculateReply({
61
+ destination: this.programId,
62
+ origin: (0, _api.decodeAddress)(originAddress),
63
+ payload,
64
+ value: value || 0,
65
+ gasLimit: this.api.blockGasLimit.toBigInt(),
66
+ at: atBlock
67
+ });
68
+ const result = this.registry.createType('(String, U256)', reply.payload);
69
+ return result[1].toBigInt();
70
+ }
71
+ async balanceOf(owner, originAddress, value, atBlock) {
72
+ const payload = this.registry.createType('(String, ActorId)', ['BalanceOf', owner]).toU8a();
73
+ const reply = await this.api.message.calculateReply({
74
+ destination: this.programId,
75
+ origin: (0, _api.decodeAddress)(originAddress),
76
+ payload,
77
+ value: value || 0,
78
+ gasLimit: this.api.blockGasLimit.toBigInt(),
79
+ at: atBlock
80
+ });
81
+ const result = this.registry.createType('(String, U256)', reply.payload);
82
+ return result[1].toBigInt();
83
+ }
84
+ async decimals(originAddress, value, atBlock) {
85
+ const payload = this.registry.createType('String', 'Decimals').toU8a();
86
+ const reply = await this.api.message.calculateReply({
87
+ destination: this.programId,
88
+ origin: (0, _api.decodeAddress)(originAddress),
89
+ payload,
90
+ value: value || 0,
91
+ gasLimit: this.api.blockGasLimit.toBigInt(),
92
+ at: atBlock
93
+ });
94
+ const result = this.registry.createType('(String, u8)', reply.payload);
95
+ return result[1].toNumber();
96
+ }
97
+ async name(originAddress, value, atBlock) {
98
+ const payload = this.registry.createType('String', 'Name').toU8a();
99
+ const reply = await this.api.message.calculateReply({
100
+ destination: this.programId,
101
+ origin: (0, _api.decodeAddress)(originAddress),
102
+ payload,
103
+ value: value || 0,
104
+ gasLimit: this.api.blockGasLimit.toBigInt(),
105
+ at: atBlock
106
+ });
107
+ const result = this.registry.createType('(String, String)', reply.payload);
108
+ return result[1].toString();
109
+ }
110
+ async symbol(originAddress, value, atBlock) {
111
+ const payload = this.registry.createType('String', 'Symbol').toU8a();
112
+ const reply = await this.api.message.calculateReply({
113
+ destination: this.programId,
114
+ origin: (0, _api.decodeAddress)(originAddress),
115
+ payload,
116
+ value: value || 0,
117
+ gasLimit: this.api.blockGasLimit.toBigInt(),
118
+ at: atBlock
119
+ });
120
+ const result = this.registry.createType('(String, String)', reply.payload);
121
+ return result[1].toString();
122
+ }
123
+ async totalSupply(originAddress, value, atBlock) {
124
+ const payload = this.registry.createType('String', 'TotalSupply').toU8a();
125
+ const reply = await this.api.message.calculateReply({
126
+ destination: this.programId,
127
+ origin: (0, _api.decodeAddress)(originAddress),
128
+ payload,
129
+ value: value || 0,
130
+ gasLimit: this.api.blockGasLimit.toBigInt(),
131
+ at: atBlock
132
+ });
133
+ const result = this.registry.createType('(String, U256)', reply.payload);
134
+ return result[1].toBigInt();
135
+ }
136
+ }
137
+ exports.GRC20 = GRC20;
138
+ function getGRC20ContractPromise(apiPromise, contractAddress) {
139
+ const gearApi = apiPromise;
140
+ return new GRC20(gearApi, contractAddress);
141
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _grc = require("./grc20");
7
+ Object.keys(_grc).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _grc[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _grc[key];
14
+ }
15
+ });
16
+ });
@@ -140,63 +140,63 @@ Object.keys(_eth).forEach(function (key) {
140
140
  }
141
141
  });
142
142
  });
143
- var _number = require("./number");
144
- Object.keys(_number).forEach(function (key) {
143
+ var _fetchEvmChainInfo = require("./fetchEvmChainInfo");
144
+ Object.keys(_fetchEvmChainInfo).forEach(function (key) {
145
145
  if (key === "default" || key === "__esModule") return;
146
146
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
147
- if (key in exports && exports[key] === _number[key]) return;
147
+ if (key in exports && exports[key] === _fetchEvmChainInfo[key]) return;
148
148
  Object.defineProperty(exports, key, {
149
149
  enumerable: true,
150
150
  get: function () {
151
- return _number[key];
151
+ return _fetchEvmChainInfo[key];
152
152
  }
153
153
  });
154
154
  });
155
- var _lazy = require("./lazy");
156
- Object.keys(_lazy).forEach(function (key) {
155
+ var _fetchStaticData = require("./fetchStaticData");
156
+ Object.keys(_fetchStaticData).forEach(function (key) {
157
157
  if (key === "default" || key === "__esModule") return;
158
158
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
159
- if (key in exports && exports[key] === _lazy[key]) return;
159
+ if (key in exports && exports[key] === _fetchStaticData[key]) return;
160
160
  Object.defineProperty(exports, key, {
161
161
  enumerable: true,
162
162
  get: function () {
163
- return _lazy[key];
163
+ return _fetchStaticData[key];
164
164
  }
165
165
  });
166
166
  });
167
- var _promise = require("./promise");
168
- Object.keys(_promise).forEach(function (key) {
167
+ var _gear = require("./gear");
168
+ Object.keys(_gear).forEach(function (key) {
169
169
  if (key === "default" || key === "__esModule") return;
170
170
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
171
- if (key in exports && exports[key] === _promise[key]) return;
171
+ if (key in exports && exports[key] === _gear[key]) return;
172
172
  Object.defineProperty(exports, key, {
173
173
  enumerable: true,
174
174
  get: function () {
175
- return _promise[key];
175
+ return _gear[key];
176
176
  }
177
177
  });
178
178
  });
179
- var _registry = require("./registry");
180
- Object.keys(_registry).forEach(function (key) {
179
+ var _lazy = require("./lazy");
180
+ Object.keys(_lazy).forEach(function (key) {
181
181
  if (key === "default" || key === "__esModule") return;
182
182
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
183
- if (key in exports && exports[key] === _registry[key]) return;
183
+ if (key in exports && exports[key] === _lazy[key]) return;
184
184
  Object.defineProperty(exports, key, {
185
185
  enumerable: true,
186
186
  get: function () {
187
- return _registry[key];
187
+ return _lazy[key];
188
188
  }
189
189
  });
190
190
  });
191
- var _translate = require("./translate");
192
- Object.keys(_translate).forEach(function (key) {
191
+ var _number = require("./number");
192
+ Object.keys(_number).forEach(function (key) {
193
193
  if (key === "default" || key === "__esModule") return;
194
194
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
195
- if (key in exports && exports[key] === _translate[key]) return;
195
+ if (key in exports && exports[key] === _number[key]) return;
196
196
  Object.defineProperty(exports, key, {
197
197
  enumerable: true,
198
198
  get: function () {
199
- return _translate[key];
199
+ return _number[key];
200
200
  }
201
201
  });
202
202
  });
@@ -212,27 +212,27 @@ Object.keys(_object).forEach(function (key) {
212
212
  }
213
213
  });
214
214
  });
215
- var _fetchStaticData = require("./fetchStaticData");
216
- Object.keys(_fetchStaticData).forEach(function (key) {
215
+ var _promise = require("./promise");
216
+ Object.keys(_promise).forEach(function (key) {
217
217
  if (key === "default" || key === "__esModule") return;
218
218
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
219
- if (key in exports && exports[key] === _fetchStaticData[key]) return;
219
+ if (key in exports && exports[key] === _promise[key]) return;
220
220
  Object.defineProperty(exports, key, {
221
221
  enumerable: true,
222
222
  get: function () {
223
- return _fetchStaticData[key];
223
+ return _promise[key];
224
224
  }
225
225
  });
226
226
  });
227
- var _fetchEvmChainInfo = require("./fetchEvmChainInfo");
228
- Object.keys(_fetchEvmChainInfo).forEach(function (key) {
227
+ var _registry = require("./registry");
228
+ Object.keys(_registry).forEach(function (key) {
229
229
  if (key === "default" || key === "__esModule") return;
230
230
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
231
- if (key in exports && exports[key] === _fetchEvmChainInfo[key]) return;
231
+ if (key in exports && exports[key] === _registry[key]) return;
232
232
  Object.defineProperty(exports, key, {
233
233
  enumerable: true,
234
234
  get: function () {
235
- return _fetchEvmChainInfo[key];
235
+ return _registry[key];
236
236
  }
237
237
  });
238
238
  });
@@ -248,6 +248,18 @@ Object.keys(_swap).forEach(function (key) {
248
248
  }
249
249
  });
250
250
  });
251
+ var _translate = require("./translate");
252
+ Object.keys(_translate).forEach(function (key) {
253
+ if (key === "default" || key === "__esModule") return;
254
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
255
+ if (key in exports && exports[key] === _translate[key]) return;
256
+ Object.defineProperty(exports, key, {
257
+ enumerable: true,
258
+ get: function () {
259
+ return _translate[key];
260
+ }
261
+ });
262
+ });
251
263
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
252
264
  // SPDX-License-Identifier: Apache-2.0
253
265
 
@@ -1,11 +1,14 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-base
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { GearApi } from '@gear-js/api';
4
5
  import { getPSP22ContractPromise } from '@subwallet/extension-base/koni/api/tokens/wasm';
5
6
  import { getWasmContractGasLimit } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
6
7
  import { _BALANCE_TOKEN_GROUP, _MANTA_ZK_CHAIN_GROUP, _TRANSFER_CHAIN_GROUP, _TRANSFER_NOT_SUPPORTED_CHAINS, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
7
- import { _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _isChainEvmCompatible, _isNativeToken, _isTokenWasmSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
8
- import { BN } from '@polkadot/util';
8
+ import { _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _isChainEvmCompatible, _isNativeToken, _isTokenGearSmartContract, _isTokenWasmSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
9
+ import { getGRC20ContractPromise } from '@subwallet/extension-base/utils';
10
+ import { BN, u8aToHex } from '@polkadot/util';
11
+ import { decodeAddress } from '@polkadot/util-crypto';
9
12
  function isRefCount(accountInfo) {
10
13
  return !!accountInfo.refcount;
11
14
  }
@@ -140,6 +143,14 @@ export const createTransferExtrinsic = async ({
140
143
  gasLimit
141
144
  }, to, value, {});
142
145
  transferAmount = value;
146
+ } else if (_isTokenGearSmartContract(tokenInfo) && api instanceof GearApi) {
147
+ const contractPromise = getGRC20ContractPromise(api, _getContractAddressOfToken(tokenInfo));
148
+ const transaction = await contractPromise.transfer(u8aToHex(decodeAddress(to)), BigInt(value)) // Create transfer transaction
149
+ .withAccount(from) // Set sender account
150
+ .calculateGas(); // Add account arg to extrinsic
151
+
152
+ transfer = transaction.tx;
153
+ transferAmount = value;
143
154
  } else if (_TRANSFER_CHAIN_GROUP.acala.includes(networkKey)) {
144
155
  if (!_isNativeToken(tokenInfo)) {
145
156
  if (isTxCurrenciesSupported) {
@@ -3,7 +3,6 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
3
3
  import { ChainStakingMetadata, NominatorMetadata, UnstakingInfo, ValidatorInfo } from '@subwallet/extension-base/background/KoniTypes';
4
4
  import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
5
5
  import { NominationPoolInfo, PalletNominationPoolsPoolMember } from '@subwallet/extension-base/types';
6
- import { Codec } from '@polkadot/types/types';
7
6
  export interface PalletStakingNominations {
8
7
  targets: string[];
9
8
  submittedIn: number;
@@ -23,7 +22,7 @@ export interface PalletStakingStakingLedger {
23
22
  export declare function validateRelayUnbondingCondition(amount: string, chainStakingMetadata: ChainStakingMetadata, nominatorMetadata: NominatorMetadata): TransactionError[];
24
23
  export declare function validatePoolBondingCondition(chainInfo: _ChainInfo, amount: string, selectedPool: NominationPoolInfo, address: string, chainStakingMetadata: ChainStakingMetadata, nominatorMetadata?: NominatorMetadata): TransactionError[];
25
24
  export declare function validateRelayBondingCondition(chainInfo: _ChainInfo, amount: string, selectedValidators: ValidatorInfo[], address: string, chainStakingMetadata: ChainStakingMetadata, nominatorMetadata?: NominatorMetadata): TransactionError[];
26
- export declare function subscribeRelayChainStakingMetadata(chainInfo: _ChainInfo, substrateApi: _SubstrateApi, callback: (chain: string, rs: ChainStakingMetadata) => void): Promise<Codec>;
25
+ export declare function subscribeRelayChainStakingMetadata(chainInfo: _ChainInfo, substrateApi: _SubstrateApi, callback: (chain: string, rs: ChainStakingMetadata) => void): import("@polkadot/api-base/types").UnsubscribePromise;
27
26
  export declare function getRelayChainStakingMetadata(chainInfo: _ChainInfo, substrateApi: _SubstrateApi): Promise<ChainStakingMetadata>;
28
27
  export declare function subscribeRelayChainNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi, ledger: PalletStakingStakingLedger): Promise<NominatorMetadata>;
29
28
  /**
@@ -680,6 +680,7 @@ export async function getRelayBondingExtrinsic(substrateApi, amount, targetValid
680
680
  if (paramsCount === 2) {
681
681
  bondTx = chainApi.api.tx.staking.bond(binaryAmount, bondDest);
682
682
  } else {
683
+ // @ts-ignore
683
684
  bondTx = chainApi.api.tx.staking.bond(address, binaryAmount, bondDest);
684
685
  }
685
686
  nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
@@ -690,6 +691,7 @@ export async function getRelayBondingExtrinsic(substrateApi, amount, targetValid
690
691
  if (paramsCount === 2) {
691
692
  bondTx = chainApi.api.tx.staking.bond(binaryAmount, bondDest);
692
693
  } else {
694
+ // @ts-ignore
693
695
  bondTx = chainApi.api.tx.staking.bond(nominatorMetadata.address, binaryAmount, bondDest);
694
696
  }
695
697
  nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
@@ -707,6 +709,8 @@ export async function getRelayBondingExtrinsic(substrateApi, amount, targetValid
707
709
  } else if (nominateTx && !bondTx) {
708
710
  return nominateTx;
709
711
  }
712
+
713
+ // @ts-ignore
710
714
  return chainApi.api.tx.utility.batchAll([bondTx, nominateTx]);
711
715
  }
712
716
  export async function getRelayUnbondingExtrinsic(substrateApi, amount, nominatorMetadata) {
@@ -727,6 +731,7 @@ export async function getRelayWithdrawalExtrinsic(substrateApi, address) {
727
731
  const slashingSpanCount = _slashingSpans !== null ? _slashingSpans.spanIndex : '0';
728
732
  return chainApi.api.tx.staking.withdrawUnbonded(slashingSpanCount);
729
733
  } else {
734
+ // @ts-ignore
730
735
  return chainApi.api.tx.staking.withdrawUnbonded();
731
736
  }
732
737
  }
@@ -770,6 +775,7 @@ export async function getPoolingWithdrawalExtrinsic(substrateApi, nominatorMetad
770
775
  Id: nominatorMetadata.address
771
776
  }, slashingSpanCount);
772
777
  } else {
778
+ // @ts-ignore
773
779
  return chainApi.api.tx.nominationPools.withdrawUnbonded({
774
780
  Id: nominatorMetadata.address
775
781
  });
@@ -33,11 +33,13 @@ export async function getWasmContractGasLimit(api, callerAddress, message, contr
33
33
  storageDepositLimit,
34
34
  value
35
35
  } = options;
36
-
37
- // @ts-ignore
38
36
  const {
39
37
  gasRequired
40
- } = await api.call.contractsApi.call(callerAddress, contract.address, value !== null && value !== void 0 ? value : new BN(0), gasLimit !== null && gasLimit !== void 0 ? gasLimit : null, storageDepositLimit !== null && storageDepositLimit !== void 0 ? storageDepositLimit : null, abiMessage === null || abiMessage === void 0 ? void 0 : (_abiMessage$value = abiMessage.value) === null || _abiMessage$value === void 0 ? void 0 : _abiMessage$value.toU8a(args));
38
+ } = await api.call.contractsApi.call(callerAddress, contract.address, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
39
+ value !== null && value !== void 0 ? value : new BN(0), // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
40
+ gasLimit !== null && gasLimit !== void 0 ? gasLimit : null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
41
+ storageDepositLimit !== null && storageDepositLimit !== void 0 ? storageDepositLimit : null, // @ts-ignore
42
+ abiMessage === null || abiMessage === void 0 ? void 0 : (_abiMessage$value = abiMessage.value) === null || _abiMessage$value === void 0 ? void 0 : _abiMessage$value.toU8a(args));
41
43
  return gasRequired;
42
44
  } catch {
43
45
  return getDefaultWeightV2(api, true);
@@ -23,6 +23,8 @@ export declare class KoniCron {
23
23
  start: () => Promise<void>;
24
24
  stop: () => Promise<void>;
25
25
  syncMantaPay: () => void;
26
+ fetchPoolInfo: () => void;
27
+ stopPoolInfo: () => void;
26
28
  refreshNft: (address: string, apiMap: ApiMap, smartContractNfts: _ChainAsset[], chainInfoMap: Record<string, _ChainInfo>) => () => void;
27
29
  resetNft: (newAddress: string) => void;
28
30
  checkNetworkAvailable: (serviceInfo: ServiceInfo) => boolean;
@@ -1,7 +1,7 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { CRON_REFRESH_NFT_INTERVAL, CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants';
4
+ import { CRON_REFRESH_CHAIN_STAKING_METADATA, CRON_REFRESH_NFT_INTERVAL, CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants';
5
5
  import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils';
6
6
  import { waitTimeout } from '@subwallet/extension-base/utils';
7
7
  import { Subject } from 'rxjs';
@@ -87,6 +87,11 @@ export class KoniCron {
87
87
  (commonReload || needUpdateNft) && this.resetNft(address);
88
88
  (commonReload || needUpdateNft) && this.removeCron('refreshNft');
89
89
  commonReload && this.removeCron('refreshPoolingStakingReward');
90
+ if (chainUpdated) {
91
+ this.stopPoolInfo();
92
+ this.removeCron('fetchPoolInfo');
93
+ this.addCron('fetchPoolInfo', this.fetchPoolInfo, CRON_REFRESH_CHAIN_STAKING_METADATA);
94
+ }
90
95
 
91
96
  // Chains
92
97
  if (this.checkNetworkAvailable(serviceInfo)) {
@@ -96,6 +101,7 @@ export class KoniCron {
96
101
  }
97
102
  };
98
103
  this.state.eventService.onLazy(this.eventHandler);
104
+ this.addCron('fetchPoolInfo', this.fetchPoolInfo, CRON_REFRESH_CHAIN_STAKING_METADATA);
99
105
  if (!(currentAccountInfo !== null && currentAccountInfo !== void 0 && currentAccountInfo.address)) {
100
106
  return;
101
107
  }
@@ -122,6 +128,7 @@ export class KoniCron {
122
128
  this.serviceSubscription = undefined;
123
129
  }
124
130
  this.removeAllCrons();
131
+ this.stopPoolInfo();
125
132
  this.status = 'stopped';
126
133
  return Promise.resolve();
127
134
  };
@@ -130,6 +137,12 @@ export class KoniCron {
130
137
  this.state.syncMantaPay().catch(console.warn);
131
138
  }
132
139
  };
140
+ fetchPoolInfo = () => {
141
+ this.state.earningService.runSubscribePoolsInfo().catch(console.error);
142
+ };
143
+ stopPoolInfo = () => {
144
+ this.state.earningService.runUnsubscribePoolsInfo();
145
+ };
133
146
  refreshNft = (address, apiMap, smartContractNfts, chainInfoMap) => {
134
147
  return () => {
135
148
  this.subscriptions.subscribeNft(address, apiMap.substrate, apiMap.evm, smartContractNfts, chainInfoMap);
@@ -61,6 +61,7 @@ const generateDefaultCrowdloanMap = () => {
61
61
  const crowdloanMap = {};
62
62
  return crowdloanMap;
63
63
  };
64
+ const DEFAULT_CURRENCY = 'USD';
64
65
  export default class KoniState {
65
66
  injectedProviders = new Map();
66
67
  unsubscriptionMap = {};
@@ -1546,6 +1547,7 @@ export default class KoniState {
1546
1547
  this.accountRefStore.set('refList', []);
1547
1548
  if (resetAll) {
1548
1549
  this.settingService.resetWallet();
1550
+ await this.priceService.setPriceCurrency(DEFAULT_CURRENCY);
1549
1551
  }
1550
1552
  this.chainService.resetWallet(resetAll);
1551
1553
  await this.walletConnectService.resetWallet(resetAll);
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.65-0",
20
+ "version": "1.1.67-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1510,6 +1510,11 @@
1510
1510
  "require": "./cjs/stores/CurrentAccountStore.js",
1511
1511
  "default": "./stores/CurrentAccountStore.js"
1512
1512
  },
1513
+ "./stores/CurrentCurrencyStore": {
1514
+ "types": "./stores/CurrentCurrencyStore.d.ts",
1515
+ "require": "./cjs/stores/CurrentCurrencyStore.js",
1516
+ "default": "./stores/CurrentCurrencyStore.js"
1517
+ },
1513
1518
  "./stores/DetectAccountBalance": {
1514
1519
  "types": "./stores/DetectAccountBalance.d.ts",
1515
1520
  "require": "./cjs/stores/DetectAccountBalance.js",
@@ -1770,6 +1775,16 @@
1770
1775
  "require": "./cjs/utils/fetchStaticData.js",
1771
1776
  "default": "./utils/fetchStaticData.js"
1772
1777
  },
1778
+ "./utils/gear": {
1779
+ "types": "./utils/gear/index.d.ts",
1780
+ "require": "./cjs/utils/gear/index.js",
1781
+ "default": "./utils/gear/index.js"
1782
+ },
1783
+ "./utils/gear/grc20": {
1784
+ "types": "./utils/gear/grc20.d.ts",
1785
+ "require": "./cjs/utils/gear/grc20.js",
1786
+ "default": "./utils/gear/grc20.js"
1787
+ },
1773
1788
  "./utils/getId": {
1774
1789
  "types": "./utils/getId.d.ts",
1775
1790
  "require": "./cjs/utils/getId.js",
@@ -1848,32 +1863,33 @@
1848
1863
  "@ethereumjs/tx": "^5.1.0",
1849
1864
  "@ethersproject/abi": "^5.7.0",
1850
1865
  "@galacticcouncil/sdk": "^2.1.0",
1866
+ "@gear-js/api": "^0.37.2",
1851
1867
  "@json-rpc-tools/utils": "^1.7.6",
1852
1868
  "@metamask/safe-event-emitter": "^2.0.0",
1853
1869
  "@metaverse-network-sdk/type-definitions": "^0.0.1-13",
1854
1870
  "@oak-foundation/types": "^0.0.23",
1855
- "@polkadot/api": "^10.12.4",
1871
+ "@polkadot/api": "^11.0.3",
1856
1872
  "@polkadot/api-base": "^10.11.2",
1857
- "@polkadot/api-contract": "^10.12.4",
1858
- "@polkadot/api-derive": "^10.12.4",
1859
- "@polkadot/apps-config": "^0.135.1",
1873
+ "@polkadot/api-contract": "^11.0.3",
1874
+ "@polkadot/api-derive": "^11.0.3",
1875
+ "@polkadot/apps-config": "^0.137.1",
1860
1876
  "@polkadot/hw-ledger": "^12.6.2",
1861
1877
  "@polkadot/networks": "^12.6.2",
1862
- "@polkadot/phishing": "^0.22.4",
1863
- "@polkadot/rpc-provider": "^10.12.4",
1864
- "@polkadot/types": "^10.12.4",
1865
- "@polkadot/types-augment": "^10.12.4",
1866
- "@polkadot/ui-settings": "^3.6.5",
1878
+ "@polkadot/phishing": "^0.22.7",
1879
+ "@polkadot/rpc-provider": "^11.0.3",
1880
+ "@polkadot/types": "^11.0.3",
1881
+ "@polkadot/types-augment": "^11.0.3",
1882
+ "@polkadot/ui-settings": "^3.6.6",
1867
1883
  "@polkadot/util": "^12.6.2",
1868
1884
  "@polkadot/util-crypto": "^12.6.2",
1869
1885
  "@reduxjs/toolkit": "^1.9.1",
1870
1886
  "@sora-substrate/type-definitions": "^1.17.7",
1871
1887
  "@substrate/connect": "^0.8.9",
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",
1888
+ "@subwallet/chain-list": "0.2.63",
1889
+ "@subwallet/extension-base": "^1.1.67-0",
1890
+ "@subwallet/extension-chains": "^1.1.67-0",
1891
+ "@subwallet/extension-dapp": "^1.1.67-0",
1892
+ "@subwallet/extension-inject": "^1.1.67-0",
1877
1893
  "@subwallet/keyring": "^0.1.5",
1878
1894
  "@subwallet/ui-keyring": "^0.1.5",
1879
1895
  "@walletconnect/sign-client": "^2.8.4",
@@ -1901,6 +1917,7 @@
1901
1917
  "moment": "^2.29.4",
1902
1918
  "protobufjs": "^7.2.4",
1903
1919
  "rxjs": "^7.8.1",
1920
+ "sails-js": "^0.1.3",
1904
1921
  "uuid": "^9.0.0",
1905
1922
  "web3": "^1.10.0",
1906
1923
  "web3-core": "^1.10.0",
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.65-0'
10
+ version: '1.1.67-0'
11
11
  };
@@ -88,7 +88,7 @@ export function subscribeBalance(addresses, chains, tokens, _chainAssetMap, _cha
88
88
  const chainSlug = chainInfo.slug;
89
89
  const [useAddresses, notSupportAddresses] = filterAddress(addresses, chainInfo);
90
90
  if (notSupportAddresses.length) {
91
- const tokens = filterAssetsByChainAndType(chainAssetMap, chainSlug, [_AssetType.NATIVE, _AssetType.ERC20, _AssetType.PSP22, _AssetType.LOCAL]);
91
+ const tokens = filterAssetsByChainAndType(chainAssetMap, chainSlug, [_AssetType.NATIVE, _AssetType.ERC20, _AssetType.PSP22, _AssetType.LOCAL, _AssetType.GRC20]);
92
92
  const now = new Date().getTime();
93
93
  Object.values(tokens).forEach(token => {
94
94
  const items = notSupportAddresses.map(address => ({