@subwallet/extension-base 1.3.24-0 → 1.3.26-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 (62) hide show
  1. package/background/KoniTypes.d.ts +9 -1
  2. package/background/KoniTypes.js +1 -0
  3. package/background/errors/EvmProviderError.js +4 -0
  4. package/background/errors/ProviderError.d.ts +1 -1
  5. package/background/errors/ProviderError.js +2 -2
  6. package/cjs/background/KoniTypes.js +1 -0
  7. package/cjs/background/errors/EvmProviderError.js +4 -0
  8. package/cjs/background/errors/ProviderError.js +2 -2
  9. package/cjs/koni/background/handlers/Tabs.js +3 -2
  10. package/cjs/packageInfo.js +1 -1
  11. package/cjs/page/index.js +1 -1
  12. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +3 -3
  13. package/cjs/services/buy-service/constants/token.js +3 -0
  14. package/cjs/services/chain-service/constants.js +1 -1
  15. package/cjs/services/earning-service/constants/chains.js +1 -1
  16. package/cjs/services/earning-service/handlers/base.js +11 -5
  17. package/cjs/services/earning-service/handlers/native-staking/base-para.js +7 -6
  18. package/cjs/services/earning-service/handlers/native-staking/base.js +6 -3
  19. package/cjs/services/earning-service/handlers/native-staking/dtao.js +444 -0
  20. package/cjs/services/earning-service/handlers/native-staking/index.js +8 -1
  21. package/cjs/services/earning-service/handlers/native-staking/tao.js +138 -125
  22. package/cjs/services/earning-service/service.js +14 -4
  23. package/cjs/services/inapp-notification-service/index.js +3 -0
  24. package/cjs/services/transaction-service/index.js +6 -0
  25. package/cjs/services/transaction-service/utils.js +3 -3
  26. package/cjs/types/yield/info/base.js +1 -0
  27. package/cjs/utils/fetchEvmChainInfo.js +10 -5
  28. package/koni/background/handlers/Tabs.js +3 -2
  29. package/package.json +11 -6
  30. package/packageInfo.js +1 -1
  31. package/page/index.js +1 -1
  32. package/services/balance-service/helpers/subscribe/substrate/index.js +2 -2
  33. package/services/buy-service/constants/token.js +3 -0
  34. package/services/chain-service/constants.js +1 -1
  35. package/services/earning-service/constants/chains.js +1 -1
  36. package/services/earning-service/handlers/base.d.ts +7 -5
  37. package/services/earning-service/handlers/base.js +11 -7
  38. package/services/earning-service/handlers/native-staking/base-para.d.ts +1 -1
  39. package/services/earning-service/handlers/native-staking/base-para.js +7 -6
  40. package/services/earning-service/handlers/native-staking/base.d.ts +1 -1
  41. package/services/earning-service/handlers/native-staking/base.js +6 -3
  42. package/services/earning-service/handlers/native-staking/dtao.d.ts +64 -0
  43. package/services/earning-service/handlers/native-staking/dtao.js +434 -0
  44. package/services/earning-service/handlers/native-staking/index.d.ts +1 -0
  45. package/services/earning-service/handlers/native-staking/index.js +2 -1
  46. package/services/earning-service/handlers/native-staking/tao.d.ts +16 -4
  47. package/services/earning-service/handlers/native-staking/tao.js +136 -121
  48. package/services/earning-service/service.d.ts +1 -0
  49. package/services/earning-service/service.js +15 -5
  50. package/services/inapp-notification-service/index.js +3 -0
  51. package/services/transaction-service/index.js +6 -0
  52. package/services/transaction-service/utils.js +3 -3
  53. package/types/bridge/index.d.ts +1 -0
  54. package/types/buy.d.ts +1 -1
  55. package/types/yield/actions/join/step.d.ts +1 -0
  56. package/types/yield/actions/join/submit.d.ts +1 -0
  57. package/types/yield/info/account/info.d.ts +14 -1
  58. package/types/yield/info/base.d.ts +3 -1
  59. package/types/yield/info/base.js +1 -0
  60. package/types/yield/info/chain/info.d.ts +5 -1
  61. package/utils/fetchEvmChainInfo.d.ts +1 -1
  62. package/utils/fetchEvmChainInfo.js +10 -5
@@ -4,9 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = exports.bittensorApiKey = exports.BITTENSOR_API_KEY_9 = exports.BITTENSOR_API_KEY_8 = exports.BITTENSOR_API_KEY_7 = exports.BITTENSOR_API_KEY_6 = exports.BITTENSOR_API_KEY_5 = exports.BITTENSOR_API_KEY_4 = exports.BITTENSOR_API_KEY_3 = exports.BITTENSOR_API_KEY_2 = exports.BITTENSOR_API_KEY_10 = exports.BITTENSOR_API_KEY_1 = void 0;
8
- exports.fetchDelegates = fetchDelegates;
9
- exports.getTaoToAlphaMapping = void 0;
7
+ exports.default = exports.bittensorApiKey = exports.BittensorCache = exports.BITTENSOR_API_KEY_9 = exports.BITTENSOR_API_KEY_8 = exports.BITTENSOR_API_KEY_7 = exports.BITTENSOR_API_KEY_6 = exports.BITTENSOR_API_KEY_5 = exports.BITTENSOR_API_KEY_4 = exports.BITTENSOR_API_KEY_3 = exports.BITTENSOR_API_KEY_2 = exports.BITTENSOR_API_KEY_10 = exports.BITTENSOR_API_KEY_1 = void 0;
10
8
  var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
11
9
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
12
10
  var _constants = require("@subwallet/extension-base/constants");
@@ -20,26 +18,6 @@ var _utils3 = require("../../utils");
20
18
  // Copyright 2019-2022 @subwallet/extension-base
21
19
  // SPDX-License-Identifier: Apache-2.0
22
20
 
23
- const getTaoToAlphaMapping = async substrateApi => {
24
- const allSubnets = (await substrateApi.api.call.subnetInfoRuntimeApi.getAllDynamicInfo()).toJSON();
25
- if (!allSubnets) {
26
- return {};
27
- }
28
- return allSubnets.reduce((acc, subnet) => {
29
- const netuid = subnet === null || subnet === void 0 ? void 0 : subnet.netuid;
30
- const taoIn = subnet !== null && subnet !== void 0 && subnet.taoIn ? new _bignumber.default(subnet.taoIn) : new _bignumber.default(0);
31
- const alphaIn = subnet !== null && subnet !== void 0 && subnet.alphaIn ? new _bignumber.default(subnet.alphaIn) : new _bignumber.default(0);
32
- if (netuid === 0) {
33
- acc[netuid] = '1';
34
- } else if (alphaIn.gt(0)) {
35
- acc[netuid] = taoIn.dividedBy(alphaIn).toString();
36
- } else {
37
- acc[netuid] = '1';
38
- }
39
- return acc;
40
- }, {});
41
- };
42
- exports.getTaoToAlphaMapping = getTaoToAlphaMapping;
43
21
  const BITTENSOR_API_KEY_1 = process.env.BITTENSOR_API_KEY_1 || '';
44
22
  exports.BITTENSOR_API_KEY_1 = BITTENSOR_API_KEY_1;
45
23
  const BITTENSOR_API_KEY_2 = process.env.BITTENSOR_API_KEY_2 || '';
@@ -74,19 +52,71 @@ const bittensorApiKey = () => {
74
52
 
75
53
  /* Fetch data */
76
54
  exports.bittensorApiKey = bittensorApiKey;
77
- async function fetchDelegates() {
78
- const apiKey = bittensorApiKey();
79
- return new Promise(function (resolve) {
80
- fetch('https://api.taostats.io/api/validator/latest/v1', {
81
- method: 'GET',
82
- headers: {
83
- 'Content-Type': 'application/json',
84
- Authorization: `${apiKey}`
55
+ class BittensorCache {
56
+ static instance = null;
57
+ cache = null;
58
+ cacheTimeout = null;
59
+ promise = null;
60
+
61
+ // eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function
62
+ constructor() {}
63
+ static getInstance() {
64
+ if (!BittensorCache.instance) {
65
+ BittensorCache.instance = new BittensorCache();
66
+ }
67
+ return BittensorCache.instance;
68
+ }
69
+ async get() {
70
+ if (this.cache) {
71
+ return this.cache;
72
+ }
73
+ if (this.promise) {
74
+ return this.promise;
75
+ }
76
+ this.promise = this.fetchData();
77
+ return this.promise;
78
+ }
79
+ async fetchData() {
80
+ const apiKey = bittensorApiKey();
81
+ try {
82
+ const resp = await fetch('https://api.taostats.io/api/validator/latest/v1?limit=200', {
83
+ method: 'GET',
84
+ headers: {
85
+ 'Content-Type': 'application/json',
86
+ Authorization: `${apiKey}`
87
+ }
88
+ });
89
+ if (!resp.ok) {
90
+ console.error('Fetch bittensor delegates fail:', resp.status);
91
+ return this.cache || {
92
+ data: []
93
+ };
94
+ }
95
+ const rawData = await resp.json();
96
+ const data = {
97
+ data: rawData.data.filter(validator => parseFloat(validator.apr) > 0.0001)
98
+ };
99
+ this.cache = data;
100
+ this.promise = null;
101
+ if (this.cacheTimeout) {
102
+ clearTimeout(this.cacheTimeout);
85
103
  }
86
- }).then(resp => {
87
- resolve(resp.json());
88
- }).catch(console.error);
89
- });
104
+ this.cacheTimeout = setTimeout(() => {
105
+ this.fetchData().then(newData => {
106
+ if (newData.data.length > 0) {
107
+ this.cache = newData;
108
+ }
109
+ }).catch(console.error);
110
+ }, 60 * 2000);
111
+ return data;
112
+ } catch (error) {
113
+ console.error(error);
114
+ this.promise = null;
115
+ return this.cache || {
116
+ data: []
117
+ };
118
+ }
119
+ }
90
120
  }
91
121
 
92
122
  // export async function fetchTaoDelegateState (address: string): Promise<RawDelegateState> {
@@ -107,17 +137,31 @@ async function fetchDelegates() {
107
137
 
108
138
  /* Fetch data */
109
139
 
110
- const testnetDelegate = {
111
- '5G6wdAdS7hpBuH1tjuZDhpzrGw9Wf71WEVakDCxHDm1cxEQ2': {
112
- name: '0x436c6f776e4e616d65f09fa4a1',
113
- url: 'https://example.com ',
114
- image: 'https://example.com/image.png',
115
- discord: '0xe28094446973636f7264',
116
- description: 'This is an example identity.',
117
- additional: ''
118
- }
119
- };
140
+ // const testnetDelegate = {
141
+ // '5G6wdAdS7hpBuH1tjuZDhpzrGw9Wf71WEVakDCxHDm1cxEQ2': {
142
+ // name: '0x436c6f776e4e616d65f09fa4a1',
143
+ // url: 'https://example.com ',
144
+ // image: 'https://example.com/image.png',
145
+ // discord: '0xe28094446973636f7264',
146
+ // description: 'This is an example identity.',
147
+ // additional: ''
148
+ // }
149
+ // };
150
+ exports.BittensorCache = BittensorCache;
120
151
  class TaoNativeStakingPoolHandler extends _basePara.default {
152
+ availableMethod = {
153
+ join: true,
154
+ defaultUnstake: true,
155
+ fastUnstake: false,
156
+ cancelUnstake: false,
157
+ withdraw: false,
158
+ claimReward: false
159
+ };
160
+ constructor(state, chain) {
161
+ super(state, chain);
162
+ this.bittensorCache = BittensorCache.getInstance();
163
+ }
164
+
121
165
  /* Unimplemented function */
122
166
  handleYieldWithdraw(address, unstakingInfo) {
123
167
  return Promise.reject(new _TransactionError.TransactionError(_types.BasicTxErrorType.UNSUPPORTED));
@@ -144,29 +188,33 @@ class TaoNativeStakingPoolHandler extends _basePara.default {
144
188
  if (cancel) {
145
189
  return;
146
190
  }
147
- const minDelegatorStake = await substrateApi.api.query.subtensorModule.nominatorMinRequiredStake();
191
+ const minDelegatorStake = (await substrateApi.api.query.subtensorModule.nominatorMinRequiredStake()).toPrimitive() || 0;
192
+ const maxValidatorPerNominator = (await substrateApi.api.query.subtensorModule.maxAllowedValidators(0)).toPrimitive();
193
+ const taoIn = (await substrateApi.api.query.subtensorModule.subnetTAO(0)).toPrimitive();
194
+ const bnTaoIn = new _util.BN(taoIn);
148
195
  const BNminDelegatorStake = new _bignumber.default(minDelegatorStake.toString());
149
196
  const data = {
150
197
  ...this.baseInfo,
151
198
  type: this.type,
152
199
  metadata: {
153
200
  ...this.metadataInfo,
154
- description: this.getDescription('0')
201
+ description: this.getDescription()
155
202
  },
156
203
  statistic: {
157
204
  assetEarning: [{
158
205
  slug: this.nativeToken.slug
159
206
  }],
160
- maxCandidatePerFarmer: 16,
207
+ maxCandidatePerFarmer: Number(maxValidatorPerNominator),
161
208
  maxWithdrawalRequestPerFarmer: 1,
162
209
  earningThreshold: {
163
210
  join: BNminDelegatorStake.toString(),
164
211
  defaultUnstake: '0',
165
212
  fastUnstake: '0'
166
213
  },
167
- eraTime: 1.2,
214
+ eraTime: 24,
168
215
  era: 0,
169
- unstakingPeriod: 1.2
216
+ unstakingPeriod: 1.2,
217
+ tvl: bnTaoIn.toString()
170
218
  }
171
219
  };
172
220
  callback(data);
@@ -204,12 +252,11 @@ class TaoNativeStakingPoolHandler extends _basePara.default {
204
252
  chain: chainInfo.slug,
205
253
  validatorAddress: delegate.owner,
206
254
  activeStake: activeStake,
207
- validatorMinStake: minDelegatorStake
208
- // validatorIdentity: delegate.identity
255
+ validatorMinStake: minDelegatorStake,
256
+ validatorIdentity: delegate.identity
209
257
  });
210
258
  }
211
259
  }
212
-
213
260
  const stakingStatus = (0, _utils.getEarningStatusByNominations)(allActiveStake, nominationList);
214
261
  return {
215
262
  status: stakingStatus,
@@ -227,44 +274,9 @@ class TaoNativeStakingPoolHandler extends _basePara.default {
227
274
  const substrateApi = await this.substrateApi.isReady;
228
275
  const defaultInfo = this.baseInfo;
229
276
  const chainInfo = this.chainInfo;
230
- const getDevnetPoolPosition = async () => {
231
- const testnetAddress = Object.keys(testnetDelegate)[0];
232
- const delegatorState = [];
233
- let bnTotalBalance = _util.BN_ZERO;
234
- const stakePromises = useAddresses.map(async address => {
235
- const stakeAmount = (await substrateApi.api.query.subtensorModule.stake(testnetAddress, address)).toString();
236
- const bnStakeAmount = new _util.BN(stakeAmount);
237
- bnTotalBalance = bnTotalBalance.add(bnStakeAmount);
238
- delegatorState.push({
239
- owner: testnetAddress,
240
- amount: bnStakeAmount.toString()
241
- // identity: testnetAddress
242
- });
243
-
244
- rsCallback({
245
- ...defaultInfo,
246
- type: this.type,
247
- address: address,
248
- balanceToken: this.nativeToken.slug,
249
- totalStake: bnTotalBalance.toString(),
250
- activeStake: bnStakeAmount.toString(),
251
- unstakeBalance: '0',
252
- status: _types.EarningStatus.EARNING_REWARD,
253
- isBondedBefore: true,
254
- nominations: delegatorState.map(delegate => ({
255
- chain: this.chain,
256
- validatorAddress: delegate.owner,
257
- activeStake: delegate.amount,
258
- status: _types.EarningStatus.EARNING_REWARD
259
- })),
260
- unstakings: []
261
- });
262
- });
263
- await Promise.all(stakePromises);
264
- };
265
- const getMainnetPoolPosition = async () => {
277
+ const _delegateInfo = await this.bittensorCache.get();
278
+ const getPoolPosition = async () => {
266
279
  const rawDelegateStateInfos = await Promise.all(useAddresses.map(async address => (await substrateApi.api.call.stakeInfoRuntimeApi.getStakeInfoForColdkey(address)).toJSON()));
267
- const price = await getTaoToAlphaMapping(this.substrateApi);
268
280
  if (rawDelegateStateInfos && rawDelegateStateInfos.length > 0) {
269
281
  rawDelegateStateInfos.forEach((rawDelegateStateInfo, i) => {
270
282
  const owner = (0, _utils2.reformatAddress)(useAddresses[i], 42);
@@ -276,19 +288,26 @@ class TaoNativeStakingPoolHandler extends _basePara.default {
276
288
  const hotkey = delegate.hotkey;
277
289
  const netuid = delegate.netuid;
278
290
  const stake = new _bignumber.default(delegate.stake);
279
- const taoToAlphaPrice = price[netuid] ? new _bignumber.default(price[netuid]) : new _bignumber.default(1);
280
- const taoStake = stake.multipliedBy(taoToAlphaPrice).toFixed(0).toString();
281
- if (totalDelegate[hotkey]) {
282
- totalDelegate[hotkey] = new _bignumber.default(totalDelegate[hotkey]).plus(taoStake).toString();
283
- } else {
284
- totalDelegate[hotkey] = taoStake;
291
+ if (netuid === 0) {
292
+ const taoStake = stake.toFixed(0);
293
+ if (totalDelegate[hotkey]) {
294
+ totalDelegate[hotkey] = new _bignumber.default(totalDelegate[hotkey]).plus(taoStake).toFixed();
295
+ } else {
296
+ totalDelegate[hotkey] = taoStake;
297
+ }
285
298
  }
286
299
  }
287
300
  for (const hotkey in totalDelegate) {
288
301
  bnTotalBalance = bnTotalBalance.add(new _util.BN(totalDelegate[hotkey]));
302
+ let identity = '';
303
+ if (_delegateInfo) {
304
+ const delegateInfo = _delegateInfo.data.find(info => info.hotkey.ss58 === hotkey);
305
+ identity = delegateInfo ? delegateInfo.name : '';
306
+ }
289
307
  delegatorState.push({
290
308
  owner: hotkey,
291
- amount: totalDelegate[hotkey]
309
+ amount: totalDelegate[hotkey],
310
+ identity: identity
292
311
  });
293
312
  }
294
313
  if (delegateStateInfo && delegateStateInfo.length > 0) {
@@ -377,11 +396,7 @@ class TaoNativeStakingPoolHandler extends _basePara.default {
377
396
  if (cancel) {
378
397
  return;
379
398
  }
380
- if (this.chain === 'bittensor_devnet') {
381
- await getDevnetPoolPosition();
382
- } else {
383
- await getMainnetPoolPosition();
384
- }
399
+ await getPoolPosition();
385
400
  };
386
401
  getStakingPositionInterval().catch(console.error);
387
402
  const intervalId = setInterval(() => {
@@ -399,28 +414,26 @@ class TaoNativeStakingPoolHandler extends _basePara.default {
399
414
 
400
415
  // eslint-disable-next-line @typescript-eslint/require-await
401
416
  async getDevnetPoolTargets() {
402
- const _topValidator = testnetDelegate;
403
- const validatorAddresses = Object.keys(_topValidator);
404
- return validatorAddresses.map(address => {
405
- return {
406
- address: address,
407
- totalStake: '0',
408
- ownStake: '0',
409
- otherStake: '0',
410
- minBond: '0',
411
- nominatorCount: 0,
412
- commission: '0',
413
- expectedReturn: 0,
414
- blocked: false,
415
- isVerified: false,
416
- chain: this.chain,
417
- isCrowded: false,
418
- identity: address
419
- };
420
- });
417
+ const testnetDelegate = (await this.substrateApi.api.call.delegateInfoRuntimeApi.getDelegates()).toJSON();
418
+ const getNominatorMinRequiredStake = this.substrateApi.api.query.subtensorModule.nominatorMinRequiredStake();
419
+ const nominatorMinRequiredStake = (await getNominatorMinRequiredStake).toString();
420
+ const bnMinBond = new _util.BN(nominatorMinRequiredStake);
421
+ return testnetDelegate.map(delegate => ({
422
+ address: delegate.delegateSs58,
423
+ totalStake: '0',
424
+ ownStake: '0',
425
+ otherStake: '0',
426
+ minBond: bnMinBond.toString(),
427
+ nominatorCount: delegate.nominators.length,
428
+ commission: delegate.take / 1000,
429
+ blocked: false,
430
+ isVerified: false,
431
+ chain: this.chain,
432
+ isCrowded: false
433
+ }));
421
434
  }
422
435
  async getMainnetPoolTargets() {
423
- const _topValidator = await fetchDelegates();
436
+ const _topValidator = await this.bittensorCache.get();
424
437
  const topValidator = _topValidator;
425
438
  const getNominatorMinRequiredStake = this.substrateApi.api.query.subtensorModule.nominatorMinRequiredStake();
426
439
  const nominatorMinRequiredStake = (await getNominatorMinRequiredStake).toString();
@@ -457,10 +470,10 @@ class TaoNativeStakingPoolHandler extends _basePara.default {
457
470
  return results;
458
471
  }
459
472
  async getPoolTargets() {
460
- if (this.chain === 'bittensor_devnet') {
461
- return this.getDevnetPoolTargets();
462
- } else {
473
+ if (this.chain === 'bittensor') {
463
474
  return this.getMainnetPoolTargets();
475
+ } else {
476
+ return this.getDevnetPoolTargets();
464
477
  }
465
478
  }
466
479
 
@@ -29,6 +29,7 @@ const fetchPoolsData = async () => {
29
29
  };
30
30
  class EarningService {
31
31
  handlers = {};
32
+ handlerCache = new Map();
32
33
  earningRewardSubject = new _rxjs.BehaviorSubject({
33
34
  ready: false,
34
35
  data: {}
@@ -74,7 +75,10 @@ class EarningService {
74
75
  handlers.push(new _handlers.AmplitudeNativeStakingPoolHandler(this.state, chain));
75
76
  }
76
77
  if (_constants2._STAKING_CHAIN_GROUP.bittensor.includes(chain)) {
78
+ // todo: check support for testnet
79
+ // Mainnet only
77
80
  handlers.push(new _handlers.TaoNativeStakingPoolHandler(this.state, chain));
81
+ handlers.push(new _handlers.SubnetTaoStakingPoolHandler(this.state, chain));
78
82
  }
79
83
  if (_constants2._STAKING_CHAIN_GROUP.mythos.includes(chain)) {
80
84
  handlers.push(new _mythos.default(this.state, chain));
@@ -260,7 +264,12 @@ class EarningService {
260
264
  /* Pools' info methods */
261
265
 
262
266
  getPoolHandler(slug) {
263
- return this.handlers[slug];
267
+ if (this.handlerCache.has(slug)) {
268
+ return this.handlerCache.get(slug);
269
+ }
270
+ const handler = Object.values(this.handlers).find(h => h.canHandleSlug(slug));
271
+ this.handlerCache.set(slug, handler);
272
+ return handler;
264
273
  }
265
274
  isPoolSupportAlternativeFee(slug) {
266
275
  const handler = this.getPoolHandler(slug);
@@ -743,24 +752,25 @@ class EarningService {
743
752
  } = params;
744
753
  const handler = this.getPoolHandler(slug);
745
754
  if (handler) {
746
- return handler.validateYieldLeave(params.amount, params.address, params.fastLeave, params.selectedTarget);
755
+ return handler.validateYieldLeave(params.amount, params.address, params.fastLeave, params.selectedTarget, slug);
747
756
  } else {
748
757
  return Promise.reject(new _TransactionError.TransactionError(_types2.BasicTxErrorType.INTERNAL_ERROR));
749
758
  }
750
759
  }
751
760
  async handleYieldLeave(params) {
761
+ var _params$poolInfo$meta;
752
762
  await this.eventService.waitChainReady;
753
763
  const {
754
764
  slug
755
765
  } = params;
756
766
  const handler = this.getPoolHandler(slug);
767
+ const netuid = (_params$poolInfo$meta = params.poolInfo.metadata.subnetData) === null || _params$poolInfo$meta === void 0 ? void 0 : _params$poolInfo$meta.netuid;
757
768
  if (handler) {
758
- return handler.handleYieldLeave(params.fastLeave, params.amount, params.address, params.selectedTarget);
769
+ return handler.handleYieldLeave(params.fastLeave, params.amount, params.address, params.selectedTarget, netuid);
759
770
  } else {
760
771
  return Promise.reject(new _TransactionError.TransactionError(_types2.BasicTxErrorType.INTERNAL_ERROR));
761
772
  }
762
773
  }
763
-
764
774
  /* Leave */
765
775
 
766
776
  /* Other */
@@ -390,6 +390,9 @@ class InappNotificationService {
390
390
  case _types2.YieldPoolType.NATIVE_STAKING:
391
391
  method = _constants2._STAKING_CHAIN_GROUP.astar.includes(chain.slug) ? 'dApp staking' : 'Direct nomination';
392
392
  break;
393
+ case _types2.YieldPoolType.SUBNET_STAKING:
394
+ method = 'Subnet staking'; // todo: confirm with tester
395
+ break;
393
396
  }
394
397
  title = '[{{accountName}}] STAKED {{asset}}'.replace('{{asset}}', asset.symbol);
395
398
  description = '{{amount}} {{asset}} on {{chain}} staked via {{method}}. Click to view details'.replace('{{amount}}', (0, _utils2.formatNumber)(amount, asset.decimals || 0)).replace('{{asset}}', asset.symbol).replace('{{chain}}', chain.name).replace('{{method}}', method);
@@ -620,7 +620,13 @@ class TransactionService {
620
620
  break;
621
621
  case _KoniTypes.ExtrinsicType.STAKING_UNBOND:
622
622
  {
623
+ var _data$poolInfo;
623
624
  const data = (0, _utils3.parseTransactionData)(transaction.data);
625
+ if ((_data$poolInfo = data.poolInfo) !== null && _data$poolInfo !== void 0 && _data$poolInfo.metadata.subnetData) {
626
+ historyItem.additionalInfo = {
627
+ symbol: data.poolInfo.metadata.subnetData.subnetSymbol
628
+ };
629
+ }
624
630
  if (data.isLiquidStaking && data.derivativeTokenInfo && data.exchangeRate && data.inputTokenInfo) {
625
631
  historyItem.amount = {
626
632
  decimals: (0, _utils2._getAssetDecimals)(data.derivativeTokenInfo),
@@ -50,6 +50,9 @@ function getBlockExplorerAccountRoute(explorerLink) {
50
50
  if (explorerLink.includes('astral.autonomys')) {
51
51
  return 'accounts';
52
52
  }
53
+ if (explorerLink.includes('taostats.io')) {
54
+ return 'account';
55
+ }
53
56
  return 'address';
54
57
  }
55
58
  function getBlockExplorerTxRoute(chainInfo) {
@@ -74,9 +77,6 @@ function getExplorerLink(chainInfo, value, type) {
74
77
  return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${value}`;
75
78
  }
76
79
  if (explorerLink && (0, _util.isHex)((0, _util.hexAddPrefix)(value))) {
77
- if (chainInfo.slug === 'bittensor') {
78
- return undefined;
79
- }
80
80
  const route = getBlockExplorerTxRoute(chainInfo);
81
81
  if (chainInfo.slug === 'tangle') {
82
82
  return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}extrinsic/${value}${route}/${value}`;
@@ -23,6 +23,7 @@ exports.YieldPoolType = YieldPoolType;
23
23
  YieldPoolType["NOMINATION_POOL"] = "NOMINATION_POOL";
24
24
  YieldPoolType["NATIVE_STAKING"] = "NATIVE_STAKING";
25
25
  YieldPoolType["PARACHAIN_STAKING"] = "PARACHAIN_STAKING";
26
+ YieldPoolType["SUBNET_STAKING"] = "SUBNET_STAKING";
26
27
  })(YieldPoolType || (exports.YieldPoolType = YieldPoolType = {}));
27
28
  let YieldCompoundingPeriod;
28
29
  /**
@@ -10,11 +10,16 @@ exports.getEVMChainInfo = getEVMChainInfo;
10
10
  const onlineMap = {};
11
11
  async function getEVMChainInfo(chainId) {
12
12
  if (Object.keys(onlineMap).length === 0) {
13
- const rs = await fetch('https://chainid.network/chains.json');
14
- const data = await rs.json();
15
- data.forEach(item => {
16
- onlineMap[item.chainId] = item;
17
- });
13
+ try {
14
+ const rs = await fetch('https://chainid.network/chains.json');
15
+ const data = await rs.json();
16
+ data.forEach(item => {
17
+ onlineMap[item.chainId] = item;
18
+ });
19
+ } catch (e) {
20
+ console.error(e);
21
+ return null;
22
+ }
18
23
  }
19
24
  return onlineMap[chainId];
20
25
  }
@@ -505,11 +505,12 @@ export default class KoniTabs {
505
505
  } else {
506
506
  const onlineData = await getEVMChainInfo(chainIdDec);
507
507
  if (onlineData) {
508
+ var _onlineData$explorers;
508
509
  const chainData = {
509
510
  chainId: chainId,
510
511
  rpcUrls: onlineData.rpc.filter(url => url.startsWith('https://')),
511
512
  chainName: onlineData.name,
512
- blockExplorerUrls: onlineData.explorers.map(explorer => explorer.url),
513
+ blockExplorerUrls: (_onlineData$explorers = onlineData.explorers) === null || _onlineData$explorers === void 0 ? void 0 : _onlineData$explorers.map(explorer => explorer.url),
513
514
  nativeCurrency: onlineData.nativeCurrency,
514
515
  requestId: id
515
516
  };
@@ -518,7 +519,7 @@ export default class KoniTabs {
518
519
  params: [chainData]
519
520
  });
520
521
  } else {
521
- throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, 'This network is currently not supported');
522
+ throw new EvmProviderError(EvmProviderErrorType.NETWORK_NOT_SUPPORTED, 'This network is currently not supported');
522
523
  }
523
524
  }
524
525
  return null;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.3.24-0",
20
+ "version": "1.3.26-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1076,6 +1076,11 @@
1076
1076
  "require": "./cjs/services/earning-service/handlers/native-staking/base-para.js",
1077
1077
  "default": "./services/earning-service/handlers/native-staking/base-para.js"
1078
1078
  },
1079
+ "./services/earning-service/handlers/native-staking/dtao": {
1080
+ "types": "./services/earning-service/handlers/native-staking/dtao.d.ts",
1081
+ "require": "./cjs/services/earning-service/handlers/native-staking/dtao.js",
1082
+ "default": "./services/earning-service/handlers/native-staking/dtao.js"
1083
+ },
1079
1084
  "./services/earning-service/handlers/native-staking/mythos": {
1080
1085
  "types": "./services/earning-service/handlers/native-staking/mythos.d.ts",
1081
1086
  "require": "./cjs/services/earning-service/handlers/native-staking/mythos.js",
@@ -2660,12 +2665,12 @@
2660
2665
  "@sora-substrate/type-definitions": "^1.17.7",
2661
2666
  "@substrate/connect": "^0.8.9",
2662
2667
  "@subwallet/chain-list": "0.2.101",
2663
- "@subwallet/extension-base": "^1.3.24-0",
2664
- "@subwallet/extension-chains": "^1.3.24-0",
2665
- "@subwallet/extension-dapp": "^1.3.24-0",
2666
- "@subwallet/extension-inject": "^1.3.24-0",
2668
+ "@subwallet/extension-base": "^1.3.26-0",
2669
+ "@subwallet/extension-chains": "^1.3.26-0",
2670
+ "@subwallet/extension-dapp": "^1.3.26-0",
2671
+ "@subwallet/extension-inject": "^1.3.26-0",
2667
2672
  "@subwallet/keyring": "^0.1.9",
2668
- "@subwallet/subwallet-api-sdk": "^1.3.24-0",
2673
+ "@subwallet/subwallet-api-sdk": "^1.3.26-0",
2669
2674
  "@subwallet/ui-keyring": "^0.1.9",
2670
2675
  "@ton/core": "^0.56.3",
2671
2676
  "@ton/crypto": "^3.2.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.3.24-0'
10
+ version: '1.3.26-0'
11
11
  };
package/page/index.js CHANGED
@@ -61,7 +61,7 @@ export function handleResponse(data) {
61
61
  // eslint-disable-next-line @typescript-eslint/ban-types
62
62
  handler.subscriber(data.subscription);
63
63
  } else if (data.error) {
64
- handler.reject(new ProviderError(ProviderErrorType.INTERNAL_ERROR, data.error, data.errorCode));
64
+ handler.reject(new ProviderError(ProviderErrorType.INTERNAL_ERROR, data.error, data.errorCode, data.errorCode));
65
65
  } else {
66
66
  handler.resolve(data.response);
67
67
  }
@@ -15,7 +15,7 @@ import { getPSP22ContractPromise } from '@subwallet/extension-base/koni/api/cont
15
15
  import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/contract-handler/wasm/utils';
16
16
  import { _BALANCE_CHAIN_GROUP, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
17
17
  import { _checkSmartContractSupportByChain, _getAssetExistentialDeposit, _getChainExistentialDeposit, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _getTokenTypesSupportedByChain, _getXcmAssetMultilocation, _isBridgedToken, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
18
- import { getTaoToAlphaMapping } from '@subwallet/extension-base/services/earning-service/handlers/native-staking/tao';
18
+ import { getTaoToAlphaMapping } from '@subwallet/extension-base/services/earning-service/handlers/native-staking/dtao';
19
19
  import { filterAssetsByChainAndType } from '@subwallet/extension-base/utils';
20
20
  import BigN from 'bignumber.js';
21
21
  import { subscribeERC20Interval } from "../evm.js";
@@ -131,7 +131,7 @@ const subscribeWithSystemAccountPallet = async ({
131
131
  });
132
132
  }
133
133
  let bittensorStakingBalances = new Array(addresses.length).fill(new BigN(0));
134
- if (['bittensor'].includes(chainInfo.slug)) {
134
+ if (['bittensor', 'bittensor_testnet'].includes(chainInfo.slug)) {
135
135
  bittensorStakingBalances = await Promise.all(addresses.map(async address => {
136
136
  const stakeInfo = (await substrateApi.api.call.stakeInfoRuntimeApi.getStakeInfoForColdkey(address)).toJSON();
137
137
  const price = await getTaoToAlphaMapping(substrateApi);
@@ -20,5 +20,8 @@ export const DEFAULT_SERVICE_INFO = {
20
20
  },
21
21
  moonpay: {
22
22
  ...DEFAULT_BUY_SERVICE
23
+ },
24
+ meld: {
25
+ ...DEFAULT_BUY_SERVICE
23
26
  }
24
27
  };
@@ -34,7 +34,7 @@ export const _BALANCE_CHAIN_GROUP = {
34
34
  kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
35
35
  // perhaps there are some runtime updates
36
36
  centrifuge: ['centrifuge'],
37
- supportBridged: ['rococo_assethub', 'statemint', 'statemine']
37
+ supportBridged: ['rococo_assethub', 'statemint', 'statemine', 'polimec']
38
38
  };
39
39
  export const _BALANCE_TOKEN_GROUP = {
40
40
  crab: ['CKTON', 'PKTON'],
@@ -17,7 +17,7 @@ export const _STAKING_CHAIN_GROUP = {
17
17
  lending: ['interlay'],
18
18
  krest_network: ['krest_network'],
19
19
  manta: ['manta_network'],
20
- bittensor: ['bittensor', 'bittensor_devnet'],
20
+ bittensor: ['bittensor', 'bittensor_testnet'],
21
21
  mythos: ['mythos', 'muse_testnet']
22
22
  };
23
23
  export const TON_CHAINS = ['ton', 'ton_testnet'];