@subwallet/extension-base 1.3.3-0 → 1.3.5-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.
- package/background/KoniTypes.d.ts +14 -1
- package/background/KoniTypes.js +1 -0
- package/cjs/background/KoniTypes.js +1 -0
- package/cjs/constants/blocked-actions-list.js +1 -2
- package/cjs/constants/index.js +16 -1
- package/cjs/constants/remind-notification-time.js +14 -0
- package/cjs/core/logic-validation/transfer.js +12 -6
- package/cjs/core/substrate/xcm-parser.js +13 -1
- package/cjs/koni/api/contract-handler/utils/index.js +20 -1
- package/cjs/koni/api/nft/config.js +1 -1
- package/cjs/koni/api/nft/index.js +9 -0
- package/cjs/koni/api/nft/rari/index.js +87 -0
- package/cjs/koni/api/yield/helper/utils.js +1 -1
- package/cjs/koni/background/handlers/Extension.js +110 -23
- package/cjs/koni/background/handlers/State.js +5 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/process.js +2 -1
- package/cjs/services/balance-service/helpers/subscribe/index.js +5 -0
- package/cjs/services/balance-service/index.js +1 -1
- package/cjs/services/balance-service/transfer/xcm/availBridge.js +198 -0
- package/cjs/services/balance-service/transfer/xcm/index.js +50 -5
- package/cjs/services/chain-service/constants.js +2 -1
- package/cjs/services/chain-service/handler/EvmApi.js +12 -21
- package/cjs/services/chain-service/handler/EvmChainHandler.js +0 -2
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +73 -40
- package/cjs/services/chain-service/index.js +44 -13
- package/cjs/services/chain-service/utils/index.js +20 -0
- package/cjs/services/earning-service/handlers/base.js +12 -3
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +11 -3
- package/cjs/services/earning-service/handlers/native-staking/astar.js +1 -1
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +3 -1
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +3 -1
- package/cjs/services/earning-service/handlers/native-staking/tao.js +11 -3
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +14 -12
- package/cjs/services/earning-service/service.js +5 -0
- package/cjs/services/inapp-notification-service/consts.js +31 -0
- package/cjs/services/inapp-notification-service/index.js +260 -0
- package/cjs/services/inapp-notification-service/interfaces.js +32 -0
- package/cjs/services/inapp-notification-service/utils.js +197 -0
- package/cjs/services/keyring-service/context/account-context.js +9 -0
- package/cjs/services/keyring-service/context/state.js +4 -0
- package/cjs/services/setting-service/SettingService.js +9 -1
- package/cjs/services/setting-service/constants.js +16 -1
- package/cjs/services/storage-service/DatabaseService.js +42 -3
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/InappNotification.js +81 -0
- package/cjs/services/transaction-service/index.js +18 -4
- package/cjs/types/avail-bridge/index.js +1 -0
- package/cjs/types/notification/index.js +1 -0
- package/cjs/utils/account/transform.js +9 -5
- package/cjs/utils/staticData/index.js +7 -2
- package/constants/blocked-actions-list.js +1 -2
- package/constants/index.d.ts +2 -0
- package/constants/index.js +3 -1
- package/constants/remind-notification-time.d.ts +2 -0
- package/constants/remind-notification-time.js +7 -0
- package/core/logic-validation/transfer.js +12 -6
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +12 -1
- package/koni/api/contract-handler/utils/avail_bridge_abi.json +1659 -0
- package/koni/api/contract-handler/utils/avail_test_bridge_abi.json +1692 -0
- package/koni/api/contract-handler/utils/index.d.ts +7 -2
- package/koni/api/contract-handler/utils/index.js +15 -0
- package/koni/api/nft/config.js +1 -1
- package/koni/api/nft/index.js +9 -0
- package/koni/api/nft/rari/index.d.ts +7 -0
- package/koni/api/nft/rari/index.js +80 -0
- package/koni/api/yield/helper/utils.js +1 -1
- package/koni/background/handlers/Extension.d.ts +7 -0
- package/koni/background/handlers/Extension.js +112 -25
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +5 -2
- package/package.json +59 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/process.js +2 -1
- package/services/balance-service/helpers/subscribe/index.js +5 -0
- package/services/balance-service/index.js +2 -2
- package/services/balance-service/transfer/xcm/availBridge.d.ts +45 -0
- package/services/balance-service/transfer/xcm/availBridge.js +186 -0
- package/services/balance-service/transfer/xcm/index.d.ts +8 -8
- package/services/balance-service/transfer/xcm/index.js +46 -5
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +2 -1
- package/services/chain-service/handler/EvmApi.js +12 -21
- package/services/chain-service/handler/EvmChainHandler.js +0 -2
- package/services/chain-service/handler/SubstrateChainHandler.d.ts +3 -2
- package/services/chain-service/handler/SubstrateChainHandler.js +73 -40
- package/services/chain-service/index.d.ts +2 -0
- package/services/chain-service/index.js +45 -14
- package/services/chain-service/types.d.ts +2 -1
- package/services/chain-service/utils/index.d.ts +3 -0
- package/services/chain-service/utils/index.js +14 -0
- package/services/earning-service/handlers/base.d.ts +2 -0
- package/services/earning-service/handlers/base.js +9 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +11 -3
- package/services/earning-service/handlers/native-staking/astar.js +1 -1
- package/services/earning-service/handlers/native-staking/para-chain.js +3 -1
- package/services/earning-service/handlers/native-staking/relay-chain.js +3 -1
- package/services/earning-service/handlers/native-staking/tao.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/tao.js +6 -2
- package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -1
- package/services/earning-service/handlers/nomination-pool/index.js +14 -12
- package/services/earning-service/service.d.ts +2 -0
- package/services/earning-service/service.js +5 -0
- package/services/inapp-notification-service/consts.d.ts +18 -0
- package/services/inapp-notification-service/consts.js +22 -0
- package/services/inapp-notification-service/index.d.ts +37 -0
- package/services/inapp-notification-service/index.js +252 -0
- package/services/inapp-notification-service/interfaces.d.ts +77 -0
- package/services/inapp-notification-service/interfaces.js +24 -0
- package/services/inapp-notification-service/utils.d.ts +55 -0
- package/services/inapp-notification-service/utils.js +173 -0
- package/services/keyring-service/context/account-context.d.ts +3 -0
- package/services/keyring-service/context/account-context.js +9 -0
- package/services/keyring-service/context/state.d.ts +1 -0
- package/services/keyring-service/context/state.js +4 -0
- package/services/setting-service/SettingService.js +9 -1
- package/services/setting-service/constants.d.ts +2 -0
- package/services/setting-service/constants.js +15 -0
- package/services/storage-service/DatabaseService.d.ts +15 -0
- package/services/storage-service/DatabaseService.js +42 -3
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/InappNotification.d.ts +14 -0
- package/services/storage-service/db-stores/InappNotification.js +73 -0
- package/services/transaction-service/index.js +18 -4
- package/types/avail-bridge/index.d.ts +6 -0
- package/types/avail-bridge/index.js +1 -0
- package/types/notification/index.d.ts +9 -0
- package/types/notification/index.js +1 -0
- package/utils/account/transform.js +9 -5
- package/utils/staticData/index.d.ts +5 -1
- package/utils/staticData/index.js +5 -2
- package/utils/staticData/remindNotificationTime.json +1 -0
|
@@ -201,6 +201,15 @@ class ChainService {
|
|
|
201
201
|
});
|
|
202
202
|
return filteredAssetRegistry;
|
|
203
203
|
}
|
|
204
|
+
getAssetHubToken() {
|
|
205
|
+
const assetHubToken = {};
|
|
206
|
+
Object.values(this.getAssetRegistry()).forEach(asset => {
|
|
207
|
+
if (['statemint', 'statemine'].includes(asset.originChain)) {
|
|
208
|
+
assetHubToken[asset.slug] = asset;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return assetHubToken;
|
|
212
|
+
}
|
|
204
213
|
getChainInfoMap() {
|
|
205
214
|
return this.dataMap.chainInfoMap;
|
|
206
215
|
}
|
|
@@ -458,7 +467,7 @@ class ChainService {
|
|
|
458
467
|
upsertCustomToken(token) {
|
|
459
468
|
if (token.slug.length === 0) {
|
|
460
469
|
// new token
|
|
461
|
-
if (token.assetType === _types._AssetType.NATIVE) {
|
|
470
|
+
if (token.assetType === _types._AssetType.NATIVE || token.assetType === _types._AssetType.LOCAL) {
|
|
462
471
|
const defaultSlug = this.generateSlugForNativeToken(token.originChain, token.assetType, token.symbol);
|
|
463
472
|
token.slug = `${_types3._CUSTOM_PREFIX}${defaultSlug}`;
|
|
464
473
|
} else {
|
|
@@ -467,7 +476,7 @@ class ChainService {
|
|
|
467
476
|
token.slug = `${_types3._CUSTOM_PREFIX}${defaultSlug}`;
|
|
468
477
|
}
|
|
469
478
|
}
|
|
470
|
-
if (token.originChain && (0, _utils._isAssetFungibleToken)(token)) {
|
|
479
|
+
if (token.originChain && ((0, _utils._isAssetFungibleToken)(token) || (0, _utils._isLocalToken)(token))) {
|
|
471
480
|
var _this$getChainInfoByK;
|
|
472
481
|
token.hasValue = !((_this$getChainInfoByK = this.getChainInfoByKey(token.originChain)) !== null && _this$getChainInfoByK !== void 0 && _this$getChainInfoByK.isTestnet);
|
|
473
482
|
}
|
|
@@ -1540,13 +1549,35 @@ class ChainService {
|
|
|
1540
1549
|
contractError: false
|
|
1541
1550
|
};
|
|
1542
1551
|
}
|
|
1552
|
+
async getAssetIdTokenInfo(assetId, tokenType, chain) {
|
|
1553
|
+
if ([_types._AssetType.LOCAL].includes(tokenType) && assetId) {
|
|
1554
|
+
return await this.substrateChainHandler.getSubstrateAssetIdTokenInfo(assetId, chain);
|
|
1555
|
+
}
|
|
1556
|
+
return {
|
|
1557
|
+
decimals: -1,
|
|
1558
|
+
name: '',
|
|
1559
|
+
symbol: '',
|
|
1560
|
+
contractError: false
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1543
1563
|
async validateCustomToken(data) {
|
|
1544
1564
|
const assetRegistry = this.getSmartContractTokens();
|
|
1565
|
+
const asset = this.getAssetHubToken();
|
|
1545
1566
|
let existedToken;
|
|
1546
1567
|
for (const token of Object.values(assetRegistry)) {
|
|
1547
1568
|
var _token$metadata2;
|
|
1548
1569
|
const contractAddress = token === null || token === void 0 ? void 0 : (_token$metadata2 = token.metadata) === null || _token$metadata2 === void 0 ? void 0 : _token$metadata2.contractAddress;
|
|
1549
|
-
if (
|
|
1570
|
+
if (data.contractAddress) {
|
|
1571
|
+
if ((0, _utils._isEqualContractAddress)(contractAddress, data.contractAddress) && token.assetType === data.type && token.originChain === data.originChain) {
|
|
1572
|
+
existedToken = token;
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
for (const token of Object.values(asset)) {
|
|
1578
|
+
var _token$metadata3;
|
|
1579
|
+
const assetId = token === null || token === void 0 ? void 0 : (_token$metadata3 = token.metadata) === null || _token$metadata3 === void 0 ? void 0 : _token$metadata3.assetId;
|
|
1580
|
+
if (assetId === data.assetId && token.assetType === data.type && token.originChain === data.originChain) {
|
|
1550
1581
|
existedToken = token;
|
|
1551
1582
|
break;
|
|
1552
1583
|
}
|
|
@@ -1562,18 +1593,18 @@ class ChainService {
|
|
|
1562
1593
|
contractError: false
|
|
1563
1594
|
};
|
|
1564
1595
|
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
}
|
|
1596
|
+
let info;
|
|
1597
|
+
if (data.contractAddress) {
|
|
1598
|
+
info = await this.getSmartContractTokenInfo(data.contractAddress, data.type, data.originChain, data.contractCaller);
|
|
1599
|
+
} else {
|
|
1600
|
+
info = await this.getAssetIdTokenInfo(data.assetId, data.type, data.originChain);
|
|
1601
|
+
}
|
|
1571
1602
|
return {
|
|
1572
|
-
name,
|
|
1573
|
-
decimals,
|
|
1574
|
-
symbol,
|
|
1603
|
+
name: info.name,
|
|
1604
|
+
decimals: info.decimals,
|
|
1605
|
+
symbol: info.symbol,
|
|
1575
1606
|
isExist: !!existedToken,
|
|
1576
|
-
contractError
|
|
1607
|
+
contractError: info.contractError
|
|
1577
1608
|
};
|
|
1578
1609
|
}
|
|
1579
1610
|
generateSlugForSmartContractAsset(originChain, assetType, symbol, contractAddress) {
|
|
@@ -42,6 +42,8 @@ var _exportNames = {
|
|
|
42
42
|
_isChainSupportWasmNft: true,
|
|
43
43
|
_isChainSupportEvmERC20: true,
|
|
44
44
|
_isChainSupportWasmPSP22: true,
|
|
45
|
+
_isAssetHubChain: true,
|
|
46
|
+
_isAssetHubToken: true,
|
|
45
47
|
_isChainSupportGRC20: true,
|
|
46
48
|
_isChainSupportVFT: true,
|
|
47
49
|
_isSupportOrdinal: true,
|
|
@@ -77,6 +79,7 @@ var _exportNames = {
|
|
|
77
79
|
_getAssetDecimals: true,
|
|
78
80
|
_getBlockExplorerFromChain: true,
|
|
79
81
|
_parseMetadataForSmartContractAsset: true,
|
|
82
|
+
_parseMetadataForAssetId: true,
|
|
80
83
|
_isChainTestNet: true,
|
|
81
84
|
_isAssetFungibleToken: true,
|
|
82
85
|
_isAssetAutoEnable: true,
|
|
@@ -132,6 +135,8 @@ exports._getXcmTransferType = _getXcmTransferType;
|
|
|
132
135
|
exports._isAssetAutoEnable = void 0;
|
|
133
136
|
exports._isAssetCanPayTxFee = _isAssetCanPayTxFee;
|
|
134
137
|
exports._isAssetFungibleToken = _isAssetFungibleToken;
|
|
138
|
+
exports._isAssetHubChain = _isAssetHubChain;
|
|
139
|
+
exports._isAssetHubToken = _isAssetHubToken;
|
|
135
140
|
exports._isAssetSmartContractNft = _isAssetSmartContractNft;
|
|
136
141
|
exports._isAssetValuable = _isAssetValuable;
|
|
137
142
|
exports._isBridgedToken = _isBridgedToken;
|
|
@@ -176,6 +181,7 @@ exports._isTokenTransferredByTon = _isTokenTransferredByTon;
|
|
|
176
181
|
exports._isTokenWasmSmartContract = _isTokenWasmSmartContract;
|
|
177
182
|
exports._isXcmPathSupported = _isXcmPathSupported;
|
|
178
183
|
exports._parseAssetRefKey = _parseAssetRefKey;
|
|
184
|
+
exports._parseMetadataForAssetId = _parseMetadataForAssetId;
|
|
179
185
|
exports._parseMetadataForSmartContractAsset = _parseMetadataForSmartContractAsset;
|
|
180
186
|
exports.findChainInfoByHalfGenesisHash = exports.findChainInfoByChainId = void 0;
|
|
181
187
|
exports.randomizeProvider = randomizeProvider;
|
|
@@ -388,6 +394,12 @@ function _isChainSupportWasmPSP22(chainInfo) {
|
|
|
388
394
|
var _chainInfo$substrateI10, _chainInfo$substrateI11;
|
|
389
395
|
return ((_chainInfo$substrateI10 = chainInfo.substrateInfo) === null || _chainInfo$substrateI10 === void 0 ? void 0 : (_chainInfo$substrateI11 = _chainInfo$substrateI10.supportSmartContract) === null || _chainInfo$substrateI11 === void 0 ? void 0 : _chainInfo$substrateI11.includes(_types._AssetType.PSP22)) || false;
|
|
390
396
|
}
|
|
397
|
+
function _isAssetHubChain(chainInfo) {
|
|
398
|
+
return ['statemint', 'statemine'].includes(chainInfo.slug);
|
|
399
|
+
}
|
|
400
|
+
function _isAssetHubToken(token) {
|
|
401
|
+
return ['statemint', 'statemine'].includes(token.originChain);
|
|
402
|
+
}
|
|
391
403
|
function _isChainSupportGRC20(chainInfo) {
|
|
392
404
|
var _chainInfo$substrateI12, _chainInfo$substrateI13;
|
|
393
405
|
return ((_chainInfo$substrateI12 = chainInfo.substrateInfo) === null || _chainInfo$substrateI12 === void 0 ? void 0 : (_chainInfo$substrateI13 = _chainInfo$substrateI12.supportSmartContract) === null || _chainInfo$substrateI13 === void 0 ? void 0 : _chainInfo$substrateI13.includes(_types._AssetType.GRC20)) || false;
|
|
@@ -435,6 +447,9 @@ function _getTokenTypesSupportedByChain(chainInfo) {
|
|
|
435
447
|
}
|
|
436
448
|
});
|
|
437
449
|
}
|
|
450
|
+
if (['statemint', 'statemine'].includes(chainInfo.slug)) {
|
|
451
|
+
result.push(_types._AssetType.LOCAL);
|
|
452
|
+
}
|
|
438
453
|
return result;
|
|
439
454
|
}
|
|
440
455
|
function _getChainNativeTokenBasicInfo(chainInfo) {
|
|
@@ -588,6 +603,11 @@ function _parseMetadataForSmartContractAsset(contractAddress) {
|
|
|
588
603
|
contractAddress
|
|
589
604
|
};
|
|
590
605
|
}
|
|
606
|
+
function _parseMetadataForAssetId(assetId) {
|
|
607
|
+
return {
|
|
608
|
+
assetId
|
|
609
|
+
};
|
|
610
|
+
}
|
|
591
611
|
function _isChainTestNet(chainInfo) {
|
|
592
612
|
return chainInfo.isTestnet || false;
|
|
593
613
|
}
|
|
@@ -7,7 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
8
|
var _constants = require("@subwallet/extension-base/constants");
|
|
9
9
|
var _constants2 = require("@subwallet/extension-base/services/earning-service/constants");
|
|
10
|
-
var _utils = require("@subwallet/extension-base/utils");
|
|
10
|
+
var _utils = require("@subwallet/extension-base/services/inapp-notification-service/utils");
|
|
11
|
+
var _utils2 = require("@subwallet/extension-base/utils");
|
|
11
12
|
var _util = require("@polkadot/util");
|
|
12
13
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
13
14
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -98,6 +99,14 @@ class BasePoolHandler {
|
|
|
98
99
|
availableMethod: this.availableMethod
|
|
99
100
|
};
|
|
100
101
|
}
|
|
102
|
+
async createWithdrawNotifications(unstakingInfos, tokenInfo, address) {
|
|
103
|
+
const notifications = (0, _utils.createWithdrawNotifications)(unstakingInfos, tokenInfo, address, this.baseInfo.slug, this.type);
|
|
104
|
+
await this.state.inappNotificationService.validateAndWriteNotificationsToDB(notifications, address);
|
|
105
|
+
}
|
|
106
|
+
async createClaimNotification(claimItemInfo, tokenInfo) {
|
|
107
|
+
const notification = (0, _utils.createClaimNotification)(claimItemInfo, tokenInfo);
|
|
108
|
+
await this.state.inappNotificationService.validateAndWriteNotificationsToDB([notification], claimItemInfo.address);
|
|
109
|
+
}
|
|
101
110
|
|
|
102
111
|
/** Can mint when haven't enough native token (use input token for fee) */
|
|
103
112
|
get isPoolSupportAlternativeFee() {
|
|
@@ -107,7 +116,7 @@ class BasePoolHandler {
|
|
|
107
116
|
return await this.state.earningService.getYieldPool(this.slug);
|
|
108
117
|
}
|
|
109
118
|
async getPoolPosition(address) {
|
|
110
|
-
const originAddress = (0,
|
|
119
|
+
const originAddress = (0, _utils2.reformatAddress)(address);
|
|
111
120
|
return await this.state.earningService.getYieldPosition(originAddress, this.slug);
|
|
112
121
|
}
|
|
113
122
|
|
|
@@ -140,7 +149,7 @@ class BasePoolHandler {
|
|
|
140
149
|
const bnNativeTokenBalance = new _util.BN(nativeTokenBalance.value);
|
|
141
150
|
const bnMinBalanceToJoin = new _util.BN(((_poolInfo$statistic2 = poolInfo.statistic) === null || _poolInfo$statistic2 === void 0 ? void 0 : (_poolInfo$statistic2$ = _poolInfo$statistic2.earningThreshold) === null || _poolInfo$statistic2$ === void 0 ? void 0 : _poolInfo$statistic2$.join) || '0').add(new _util.BN(poolInfo.metadata.maintainBalance));
|
|
142
151
|
if (bnNativeTokenBalance.lte(bnMinBalanceToJoin)) {
|
|
143
|
-
const minJoin = (0,
|
|
152
|
+
const minJoin = (0, _utils2.formatNumber)(bnMinBalanceToJoin.toString(), this.nativeToken.decimals || 0);
|
|
144
153
|
const originChain = this.state.getChainInfo(nativeTokenInfo.originChain);
|
|
145
154
|
return {
|
|
146
155
|
passed: false,
|
|
@@ -166,6 +166,7 @@ class AmplitudeNativeStakingPoolHandler extends _basePara.default {
|
|
|
166
166
|
}
|
|
167
167
|
const totalBalance = new _util.BN(activeStake).add(new _util.BN(unstakingBalance));
|
|
168
168
|
const stakingStatus = (0, _utils.getEarningStatusByNominations)(new _util.BN(activeStake), nominationList);
|
|
169
|
+
await this.createWithdrawNotifications(unstakingList, this.nativeToken, address);
|
|
169
170
|
return {
|
|
170
171
|
status: stakingStatus,
|
|
171
172
|
balanceToken: this.nativeToken.slug,
|
|
@@ -251,13 +252,20 @@ class AmplitudeNativeStakingPoolHandler extends _basePara.default {
|
|
|
251
252
|
if (cancel) {
|
|
252
253
|
return;
|
|
253
254
|
}
|
|
254
|
-
|
|
255
|
+
const earningRewardItem = {
|
|
255
256
|
...this.baseInfo,
|
|
256
257
|
address: address,
|
|
257
258
|
type: this.type,
|
|
258
259
|
unclaimedReward: _unclaimedReward.toString(),
|
|
259
260
|
state: _KoniTypes.APIItemState.READY
|
|
260
|
-
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// TODO: Enable this when claim action is ready
|
|
264
|
+
// if (_unclaimedReward.toString() !== '0') {
|
|
265
|
+
// await this.createClaimNotification(earningRewardItem, this.nativeToken);
|
|
266
|
+
// }
|
|
267
|
+
|
|
268
|
+
callBack(earningRewardItem);
|
|
261
269
|
}));
|
|
262
270
|
}
|
|
263
271
|
return () => {
|
|
@@ -448,7 +456,7 @@ class AmplitudeNativeStakingPoolHandler extends _basePara.default {
|
|
|
448
456
|
} else {
|
|
449
457
|
extrinsic = chainApi.api.tx.parachainStaking.leaveDelegators();
|
|
450
458
|
}
|
|
451
|
-
return [_KoniTypes.ExtrinsicType.
|
|
459
|
+
return [_KoniTypes.ExtrinsicType.STAKING_UNBOND, extrinsic];
|
|
452
460
|
}
|
|
453
461
|
|
|
454
462
|
/* Leave pool action */
|
|
@@ -408,7 +408,7 @@ class AstarNativeStakingPoolHandler extends _basePara.default {
|
|
|
408
408
|
Wasm: selectedTarget
|
|
409
409
|
};
|
|
410
410
|
const extrinsic = chainApi.api.tx.dappsStaking.unbondAndUnstake(dappParam, binaryAmount);
|
|
411
|
-
return [_KoniTypes.ExtrinsicType.
|
|
411
|
+
return [_KoniTypes.ExtrinsicType.STAKING_UNBOND, extrinsic];
|
|
412
412
|
}
|
|
413
413
|
|
|
414
414
|
/* Leave pool action */
|
|
@@ -216,6 +216,8 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
216
216
|
const totalStake = bnTotalStake.toString();
|
|
217
217
|
const activeStake = bnTotalActiveStake.toString();
|
|
218
218
|
const unstakingBalance = bnTotalUnstaking.toString();
|
|
219
|
+
const tokenInfo = this.state.chainService.getAssetBySlug(this.nativeToken.slug);
|
|
220
|
+
await this.createWithdrawNotifications(Object.values(unstakingMap), tokenInfo, address);
|
|
219
221
|
return {
|
|
220
222
|
status: stakingStatus,
|
|
221
223
|
totalStake,
|
|
@@ -477,7 +479,7 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
477
479
|
} else {
|
|
478
480
|
extrinsic = apiPromise.api.tx.parachainStaking.scheduleRevokeDelegation(selectedTarget);
|
|
479
481
|
}
|
|
480
|
-
return [_KoniTypes.ExtrinsicType.
|
|
482
|
+
return [_KoniTypes.ExtrinsicType.STAKING_UNBOND, extrinsic];
|
|
481
483
|
}
|
|
482
484
|
|
|
483
485
|
/* Leave pool action */
|
|
@@ -178,6 +178,8 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
178
178
|
targetTimestampMs: targetTimestampMs
|
|
179
179
|
});
|
|
180
180
|
});
|
|
181
|
+
const tokenInfo = this.state.chainService.getAssetBySlug(this.nativeToken.slug);
|
|
182
|
+
await this.createWithdrawNotifications(unstakingList, tokenInfo, address);
|
|
181
183
|
return {
|
|
182
184
|
status: stakingStatus,
|
|
183
185
|
balanceToken: this.nativeToken.slug,
|
|
@@ -640,7 +642,7 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
640
642
|
} else {
|
|
641
643
|
extrinsic = chainApi.api.tx.staking.unbond(binaryAmount);
|
|
642
644
|
}
|
|
643
|
-
return [_KoniTypes.ExtrinsicType.
|
|
645
|
+
return [_KoniTypes.ExtrinsicType.STAKING_UNBOND, extrinsic];
|
|
644
646
|
}
|
|
645
647
|
|
|
646
648
|
/* Leave pool action */
|
|
@@ -4,7 +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_2 = exports.BITTENSOR_API_KEY_1 = void 0;
|
|
7
|
+
exports.default = exports.bittensorApiKey = 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_1 = void 0;
|
|
8
8
|
exports.fetchDelegates = fetchDelegates;
|
|
9
9
|
exports.fetchTaoDelegateState = fetchTaoDelegateState;
|
|
10
10
|
var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
|
|
@@ -24,6 +24,14 @@ const BITTENSOR_API_KEY_1 = process.env.BITTENSOR_API_KEY_1 || '';
|
|
|
24
24
|
exports.BITTENSOR_API_KEY_1 = BITTENSOR_API_KEY_1;
|
|
25
25
|
const BITTENSOR_API_KEY_2 = process.env.BITTENSOR_API_KEY_2 || '';
|
|
26
26
|
exports.BITTENSOR_API_KEY_2 = BITTENSOR_API_KEY_2;
|
|
27
|
+
const BITTENSOR_API_KEY_3 = process.env.BITTENSOR_API_KEY_3 || '';
|
|
28
|
+
exports.BITTENSOR_API_KEY_3 = BITTENSOR_API_KEY_3;
|
|
29
|
+
const BITTENSOR_API_KEY_4 = process.env.BITTENSOR_API_KEY_4 || '';
|
|
30
|
+
exports.BITTENSOR_API_KEY_4 = BITTENSOR_API_KEY_4;
|
|
31
|
+
const BITTENSOR_API_KEY_5 = process.env.BITTENSOR_API_KEY_5 || '';
|
|
32
|
+
exports.BITTENSOR_API_KEY_5 = BITTENSOR_API_KEY_5;
|
|
33
|
+
const BITTENSOR_API_KEY_6 = process.env.BITTENSOR_API_KEY_6 || '';
|
|
34
|
+
exports.BITTENSOR_API_KEY_6 = BITTENSOR_API_KEY_6;
|
|
27
35
|
function random() {
|
|
28
36
|
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
29
37
|
keys[_key] = arguments[_key];
|
|
@@ -33,7 +41,7 @@ function random() {
|
|
|
33
41
|
return validKeys[randomIndex];
|
|
34
42
|
}
|
|
35
43
|
const bittensorApiKey = () => {
|
|
36
|
-
return random(BITTENSOR_API_KEY_1, BITTENSOR_API_KEY_2);
|
|
44
|
+
return random(BITTENSOR_API_KEY_1, BITTENSOR_API_KEY_2, BITTENSOR_API_KEY_3, BITTENSOR_API_KEY_4, BITTENSOR_API_KEY_5, BITTENSOR_API_KEY_6);
|
|
37
45
|
};
|
|
38
46
|
|
|
39
47
|
/* Fetch data */
|
|
@@ -386,7 +394,7 @@ class TaoNativeStakingPoolHandler extends _basePara.default {
|
|
|
386
394
|
return Promise.reject(new _TransactionError.TransactionError(_types.BasicTxErrorType.INVALID_PARAMS));
|
|
387
395
|
}
|
|
388
396
|
const extrinsic = apiPromise.api.tx.subtensorModule.removeStake(selectedTarget, binaryAmount);
|
|
389
|
-
return [_KoniTypes.ExtrinsicType.
|
|
397
|
+
return [_KoniTypes.ExtrinsicType.STAKING_UNBOND, extrinsic];
|
|
390
398
|
}
|
|
391
399
|
|
|
392
400
|
/* Leave pool action */
|
|
@@ -153,7 +153,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
153
153
|
|
|
154
154
|
/* Subscribe pool position */
|
|
155
155
|
|
|
156
|
-
async parsePoolMemberMetadata(substrateApi, poolMemberInfo, currentEra, _deriveSessionProgress) {
|
|
156
|
+
async parsePoolMemberMetadata(substrateApi, poolMemberInfo, currentEra, _deriveSessionProgress, address) {
|
|
157
157
|
const chainInfo = this.chainInfo;
|
|
158
158
|
const unlimitedNominatorRewarded = substrateApi.api.consts.staking.maxExposurePageSize !== undefined;
|
|
159
159
|
const _maxNominatorRewardedPerValidator = (substrateApi.api.consts.staking.maxNominatorRewardedPerValidator || 0).toString();
|
|
@@ -224,6 +224,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
224
224
|
if (!bnActiveStake.gt(_util.BN_ZERO)) {
|
|
225
225
|
stakingStatus = _types.EarningStatus.NOT_EARNING;
|
|
226
226
|
}
|
|
227
|
+
await this.createWithdrawNotifications(unstakings, this.nativeToken, address);
|
|
227
228
|
return {
|
|
228
229
|
status: stakingStatus,
|
|
229
230
|
balanceToken: this.nativeToken.slug,
|
|
@@ -255,7 +256,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
255
256
|
const poolMemberInfo = _poolMemberInfo.toPrimitive();
|
|
256
257
|
const owner = (0, _utils3.reformatAddress)(useAddresses[i], 42);
|
|
257
258
|
if (poolMemberInfo) {
|
|
258
|
-
const nominatorMetadata = await this.parsePoolMemberMetadata(substrateApi, poolMemberInfo, currentEra, _deriveSessionProgress);
|
|
259
|
+
const nominatorMetadata = await this.parsePoolMemberMetadata(substrateApi, poolMemberInfo, currentEra, _deriveSessionProgress, owner);
|
|
259
260
|
resultCallback({
|
|
260
261
|
...defaultInfo,
|
|
261
262
|
...nominatorMetadata,
|
|
@@ -301,13 +302,17 @@ class NominationPoolHandler extends _base.default {
|
|
|
301
302
|
var _substrateApi$api$cal, _substrateApi$api$cal2;
|
|
302
303
|
const _unclaimedReward = await ((_substrateApi$api$cal = substrateApi.api.call) === null || _substrateApi$api$cal === void 0 ? void 0 : (_substrateApi$api$cal2 = _substrateApi$api$cal.nominationPoolsApi) === null || _substrateApi$api$cal2 === void 0 ? void 0 : _substrateApi$api$cal2.pendingRewards(address));
|
|
303
304
|
if (_unclaimedReward) {
|
|
304
|
-
|
|
305
|
+
const earningRewardItem = {
|
|
305
306
|
...this.baseInfo,
|
|
306
307
|
address: address,
|
|
307
308
|
type: this.type,
|
|
308
309
|
unclaimedReward: _unclaimedReward.toString(),
|
|
309
310
|
state: _KoniTypes.APIItemState.READY
|
|
310
|
-
}
|
|
311
|
+
};
|
|
312
|
+
if (_unclaimedReward.toString() !== '0') {
|
|
313
|
+
await this.createClaimNotification(earningRewardItem, this.nativeToken);
|
|
314
|
+
}
|
|
315
|
+
callBack(earningRewardItem);
|
|
311
316
|
}
|
|
312
317
|
}
|
|
313
318
|
}
|
|
@@ -476,21 +481,18 @@ class NominationPoolHandler extends _base.default {
|
|
|
476
481
|
const data = _data;
|
|
477
482
|
const {
|
|
478
483
|
address,
|
|
479
|
-
amount
|
|
480
|
-
selectedPool
|
|
484
|
+
amount
|
|
481
485
|
} = data;
|
|
482
486
|
const positionInfo = await this.getPoolPosition(address);
|
|
483
487
|
const [extrinsic] = await this.createJoinExtrinsic(data, positionInfo);
|
|
484
488
|
const joinPoolData = {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
amount,
|
|
489
|
-
address
|
|
489
|
+
path,
|
|
490
|
+
data: data,
|
|
491
|
+
currentStep
|
|
490
492
|
};
|
|
491
493
|
return {
|
|
492
494
|
txChain: this.chain,
|
|
493
|
-
extrinsicType: _KoniTypes.ExtrinsicType.
|
|
495
|
+
extrinsicType: _KoniTypes.ExtrinsicType.JOIN_YIELD_POOL,
|
|
494
496
|
extrinsic,
|
|
495
497
|
txData: joinPoolData,
|
|
496
498
|
transferNativeAmount: amount,
|
|
@@ -526,6 +526,7 @@ class EarningService {
|
|
|
526
526
|
stakingRewardState.ready = true;
|
|
527
527
|
this.earningRewardSubject.next(stakingRewardState);
|
|
528
528
|
this.earningsRewardQueue = [];
|
|
529
|
+
this.earningRewardReady.resolve();
|
|
529
530
|
});
|
|
530
531
|
}
|
|
531
532
|
async getPoolReward(addresses, callback) {
|
|
@@ -563,6 +564,10 @@ class EarningService {
|
|
|
563
564
|
getEarningRewards() {
|
|
564
565
|
return this.earningRewardSubject.getValue();
|
|
565
566
|
}
|
|
567
|
+
earningRewardReady = (0, _utils2.createPromiseHandler)();
|
|
568
|
+
waitEarningRewardReady() {
|
|
569
|
+
return this.earningRewardReady.promise;
|
|
570
|
+
}
|
|
566
571
|
runSubscribeStakingRewardInterval() {
|
|
567
572
|
const addresses = this.state.keyringService.context.getDecodedAddresses();
|
|
568
573
|
if (!addresses.length) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ONE_DAY_MILLISECOND = exports.NotificationTitleMap = exports.NotificationDescriptionMap = void 0;
|
|
7
|
+
var _interfaces = require("@subwallet/extension-base/services/inapp-notification-service/interfaces");
|
|
8
|
+
var _utils = require("@subwallet/extension-base/services/inapp-notification-service/utils");
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
const NotificationTitleMap = {
|
|
13
|
+
[_interfaces.NotificationActionType.WITHDRAW]: '[{{accountName}}] WITHDRAW {{tokenSymbol}}',
|
|
14
|
+
[_interfaces.NotificationActionType.CLAIM]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
15
|
+
[_interfaces.NotificationActionType.SEND]: '[{{accountName}}] SEND {{tokenSymbol}}',
|
|
16
|
+
[_interfaces.NotificationActionType.RECEIVE]: '[{{accountName}}] RECEIVE {{tokenSymbol}}',
|
|
17
|
+
[_interfaces.NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
18
|
+
[_interfaces.NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: '[{{accountName}}] CLAIM {{tokenSymbol}}'
|
|
19
|
+
};
|
|
20
|
+
exports.NotificationTitleMap = NotificationTitleMap;
|
|
21
|
+
const NotificationDescriptionMap = {
|
|
22
|
+
[_interfaces.NotificationActionType.WITHDRAW]: _utils.getWithdrawDescription,
|
|
23
|
+
[_interfaces.NotificationActionType.CLAIM]: _utils.getClaimDescription,
|
|
24
|
+
[_interfaces.NotificationActionType.SEND]: _utils.getSendDescription,
|
|
25
|
+
[_interfaces.NotificationActionType.RECEIVE]: _utils.getReceiveDescription,
|
|
26
|
+
[_interfaces.NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: _utils.getAvailBridgeClaimDescription,
|
|
27
|
+
[_interfaces.NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: _utils.getAvailBridgeClaimDescription
|
|
28
|
+
};
|
|
29
|
+
exports.NotificationDescriptionMap = NotificationDescriptionMap;
|
|
30
|
+
const ONE_DAY_MILLISECOND = 1000 * 24 * 60 * 60;
|
|
31
|
+
exports.ONE_DAY_MILLISECOND = ONE_DAY_MILLISECOND;
|