@subwallet/extension-base 1.0.13-0 → 1.1.1-dev.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 +37 -0
- package/background/KoniTypes.js +8 -1
- package/background/handlers/Extension.js +17 -2
- package/background/types.d.ts +6 -1
- package/bundle-polkadot-extension-base.js +20 -0
- package/cjs/background/KoniTypes.js +10 -2
- package/cjs/background/handlers/Extension.js +22 -6
- package/cjs/constants/index.js +7 -1
- package/cjs/defaults.js +1 -1
- package/cjs/koni/api/dotsama/balance.js +5 -0
- package/cjs/koni/api/dotsama/transfer.js +6 -0
- package/cjs/koni/api/staking/bonding/astar.js +2 -2
- package/cjs/koni/api/staking/bonding/relayChain.js +12 -2
- package/cjs/koni/api/staking/bonding/utils.js +2 -2
- package/cjs/koni/background/cron.js +13 -37
- package/cjs/koni/background/handlers/Extension.js +324 -147
- package/cjs/koni/background/handlers/State.js +224 -51
- package/cjs/koni/background/subscription.js +9 -86
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +10 -4
- package/cjs/services/chain-service/handler/SubstrateApi.js +2 -1
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +3 -1
- package/cjs/services/chain-service/handler/manta/MantaPrivateHandler.js +147 -0
- package/cjs/services/chain-service/helper/erc20_abi.json +224 -0
- package/cjs/services/chain-service/helper/erc721_abi.json +384 -0
- package/cjs/services/chain-service/helper/psp22_abi.json +1127 -0
- package/cjs/services/chain-service/helper/psp34_abi.json +3144 -0
- package/cjs/services/chain-service/helper/test_erc721_abi.json +393 -0
- package/cjs/services/chain-service/index.js +54 -5
- package/cjs/services/chain-service/utils.js +6 -1
- package/cjs/services/event-service/types.js +3 -1
- package/cjs/services/storage-service/DatabaseService.js +31 -1
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/MantaPay.js +40 -0
- package/cjs/utils/index.js +12 -0
- package/cjs/utils/lazy.js +52 -0
- package/constants/index.d.ts +2 -0
- package/constants/index.js +2 -0
- package/defaults.d.ts +1 -1
- package/defaults.js +1 -1
- package/koni/api/dotsama/balance.js +6 -1
- package/koni/api/dotsama/transfer.js +7 -1
- package/koni/api/staking/bonding/astar.d.ts +1 -1
- package/koni/api/staking/bonding/astar.js +1 -1
- package/koni/api/staking/bonding/relayChain.js +12 -2
- package/koni/api/staking/bonding/utils.js +3 -3
- package/koni/background/cron.d.ts +1 -5
- package/koni/background/cron.js +15 -39
- package/koni/background/handlers/Extension.d.ts +5 -0
- package/koni/background/handlers/Extension.js +186 -11
- package/koni/background/handlers/State.d.ts +15 -3
- package/koni/background/handlers/State.js +226 -50
- package/koni/background/subscription.d.ts +1 -4
- package/koni/background/subscription.js +11 -87
- package/package.json +23 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +3 -0
- package/services/chain-service/constants.js +5 -2
- package/services/chain-service/handler/SubstrateApi.d.ts +1 -1
- package/services/chain-service/handler/SubstrateApi.js +2 -1
- package/services/chain-service/handler/SubstrateChainHandler.d.ts +1 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +3 -1
- package/services/chain-service/handler/manta/MantaPrivateHandler.d.ts +30 -0
- package/services/chain-service/handler/manta/MantaPrivateHandler.js +140 -0
- package/services/chain-service/handler/types.d.ts +2 -0
- package/services/chain-service/index.d.ts +7 -3
- package/services/chain-service/index.js +56 -7
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +5 -1
- package/services/event-service/types.d.ts +3 -0
- package/services/event-service/types.js +3 -1
- package/services/storage-service/DatabaseService.d.ts +10 -1
- package/services/storage-service/DatabaseService.js +31 -1
- 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/MantaPay.d.ts +9 -0
- package/services/storage-service/db-stores/MantaPay.js +32 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +2 -1
- package/utils/lazy.d.ts +2 -0
- package/utils/lazy.js +43 -0
|
@@ -1451,6 +1451,37 @@ export interface RequestReconnectConnectWalletSession {
|
|
|
1451
1451
|
export interface RequestDisconnectWalletConnectSession {
|
|
1452
1452
|
topic: string;
|
|
1453
1453
|
}
|
|
1454
|
+
export interface MantaPayConfig {
|
|
1455
|
+
address: string;
|
|
1456
|
+
zkAddress: string;
|
|
1457
|
+
enabled: boolean;
|
|
1458
|
+
chain: string;
|
|
1459
|
+
isInitialSync: boolean;
|
|
1460
|
+
}
|
|
1461
|
+
export interface MantaAuthorizationContext {
|
|
1462
|
+
address: string;
|
|
1463
|
+
chain: string;
|
|
1464
|
+
data: unknown;
|
|
1465
|
+
}
|
|
1466
|
+
export interface MantaPaySyncState {
|
|
1467
|
+
isSyncing: boolean;
|
|
1468
|
+
progress: number;
|
|
1469
|
+
needManualSync?: boolean;
|
|
1470
|
+
}
|
|
1471
|
+
export interface MantaPayEnableParams {
|
|
1472
|
+
password: string;
|
|
1473
|
+
address: string;
|
|
1474
|
+
}
|
|
1475
|
+
export declare enum MantaPayEnableMessage {
|
|
1476
|
+
WRONG_PASSWORD = "WRONG_PASSWORD",
|
|
1477
|
+
CHAIN_DISCONNECTED = "CHAIN_DISCONNECTED",
|
|
1478
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
|
1479
|
+
SUCCESS = "SUCCESS"
|
|
1480
|
+
}
|
|
1481
|
+
export interface MantaPayEnableResponse {
|
|
1482
|
+
success: boolean;
|
|
1483
|
+
message: MantaPayEnableMessage;
|
|
1484
|
+
}
|
|
1454
1485
|
export interface KoniRequestSignatures {
|
|
1455
1486
|
'pri(staking.submitTuringCancelCompound)': [RequestTuringCancelStakeCompound, SWTransactionResponse];
|
|
1456
1487
|
'pri(staking.submitTuringCompound)': [RequestTuringStakeCompound, SWTransactionResponse];
|
|
@@ -1505,6 +1536,12 @@ export interface KoniRequestSignatures {
|
|
|
1505
1536
|
'pri(crowdloan.getCrowdloan)': [RequestCrowdloan, CrowdloanJson];
|
|
1506
1537
|
'pri(crowdloan.getSubscription)': [RequestSubscribeCrowdloan, CrowdloanJson, CrowdloanJson];
|
|
1507
1538
|
'pri(phishing.pass)': [RequestPassPhishingPage, boolean];
|
|
1539
|
+
'pri(mantaPay.enable)': [MantaPayEnableParams, MantaPayEnableResponse];
|
|
1540
|
+
'pri(mantaPay.disable)': [string, boolean];
|
|
1541
|
+
'pri(mantaPay.getZkBalance)': [null, null];
|
|
1542
|
+
'pri(mantaPay.subscribeConfig)': [null, MantaPayConfig[], MantaPayConfig[]];
|
|
1543
|
+
'pri(mantaPay.subscribeSyncingState)': [null, MantaPaySyncState, MantaPaySyncState];
|
|
1544
|
+
'pri(mantaPay.initSyncMantaPay)': [string, null];
|
|
1508
1545
|
'pri(authorize.listV2)': [null, ResponseAuthorizeList];
|
|
1509
1546
|
'pri(authorize.requestsV2)': [RequestAuthorizeSubscribe, boolean, AuthorizeRequest[]];
|
|
1510
1547
|
'pri(authorize.approveV2)': [RequestAuthorizeApproveV2, boolean];
|
package/background/KoniTypes.js
CHANGED
|
@@ -223,4 +223,11 @@ export let NotificationType;
|
|
|
223
223
|
NotificationType["SUCCESS"] = "success";
|
|
224
224
|
NotificationType["WARNING"] = "warning";
|
|
225
225
|
NotificationType["ERROR"] = "error";
|
|
226
|
-
})(NotificationType || (NotificationType = {}));
|
|
226
|
+
})(NotificationType || (NotificationType = {}));
|
|
227
|
+
export let MantaPayEnableMessage;
|
|
228
|
+
(function (MantaPayEnableMessage) {
|
|
229
|
+
MantaPayEnableMessage["WRONG_PASSWORD"] = "WRONG_PASSWORD";
|
|
230
|
+
MantaPayEnableMessage["CHAIN_DISCONNECTED"] = "CHAIN_DISCONNECTED";
|
|
231
|
+
MantaPayEnableMessage["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
232
|
+
MantaPayEnableMessage["SUCCESS"] = "SUCCESS";
|
|
233
|
+
})(MantaPayEnableMessage || (MantaPayEnableMessage = {}));
|
|
@@ -446,8 +446,23 @@ export default class Extension {
|
|
|
446
446
|
});
|
|
447
447
|
return true;
|
|
448
448
|
}
|
|
449
|
-
windowOpen(
|
|
450
|
-
|
|
449
|
+
windowOpen({
|
|
450
|
+
allowedPath: path,
|
|
451
|
+
params,
|
|
452
|
+
subPath
|
|
453
|
+
}) {
|
|
454
|
+
let paramString = '';
|
|
455
|
+
if (params) {
|
|
456
|
+
paramString += '?';
|
|
457
|
+
for (let i = 0; i < Object.keys(params).length; i++) {
|
|
458
|
+
const [key, value] = Object.entries(params)[i];
|
|
459
|
+
paramString += `${key}=${value}`;
|
|
460
|
+
if (i !== Object.keys(params).length - 1) {
|
|
461
|
+
paramString += '&';
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const url = `${chrome.extension.getURL('index.html')}#${path}${subPath || ''}${paramString}`;
|
|
451
466
|
if (!ALLOWED_PATH.includes(path)) {
|
|
452
467
|
console.error('Not allowed to open the url:', url);
|
|
453
468
|
return false;
|
package/background/types.d.ts
CHANGED
|
@@ -124,7 +124,7 @@ export interface RequestSignatures extends KoniRequestSignatures {
|
|
|
124
124
|
'pri(signing.cancel)': [RequestSigningCancel, boolean];
|
|
125
125
|
'pri(signing.isLocked)': [RequestSigningIsLocked, ResponseSigningIsLocked];
|
|
126
126
|
'pri(signing.requests)': [RequestSigningSubscribe, boolean, SigningRequest[]];
|
|
127
|
-
'pri(window.open)': [
|
|
127
|
+
'pri(window.open)': [WindowOpenParams, boolean];
|
|
128
128
|
'pub(accounts.list)': [RequestAccountList, InjectedAccount[]];
|
|
129
129
|
'pub(accounts.subscribe)': [RequestAccountSubscribe, boolean, InjectedAccount[]];
|
|
130
130
|
'pub(authorize.tab)': [RequestAuthorizeTab, null];
|
|
@@ -361,6 +361,11 @@ export interface ResponseJsonRestore {
|
|
|
361
361
|
error: string | null;
|
|
362
362
|
}
|
|
363
363
|
export declare type AllowedPath = typeof ALLOWED_PATH[number];
|
|
364
|
+
export declare type WindowOpenParams = {
|
|
365
|
+
allowedPath: AllowedPath;
|
|
366
|
+
subPath?: string;
|
|
367
|
+
params?: Record<string, string>;
|
|
368
|
+
};
|
|
364
369
|
export interface ResponseJsonGetAccountInfo {
|
|
365
370
|
address: string;
|
|
366
371
|
name: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.polkadotExtensionBase = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
const global = window;
|
|
8
|
+
|
|
9
|
+
const packageInfo = {
|
|
10
|
+
name: '@subwallet/extension-base',
|
|
11
|
+
path: (({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('bundle-polkadot-extension-base.js', document.baseURI).href)) }) && (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('bundle-polkadot-extension-base.js', document.baseURI).href))) ? new URL((typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('bundle-polkadot-extension-base.js', document.baseURI).href))).pathname.substring(0, new URL((typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('bundle-polkadot-extension-base.js', document.baseURI).href))).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
12
|
+
type: 'esm',
|
|
13
|
+
version: '1.1.1'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.packageInfo = packageInfo;
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
19
|
+
|
|
20
|
+
}));
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UnstakingStatus = exports.TransferTxErrorType = exports.TransactionDirection = exports.ThemeNames = exports.StakingType = exports.StakingTxErrorType = exports.StakingStatus = exports.RuntimeEnvironment = exports.RMRK_VER = exports.ProviderErrorType = exports.NotificationType = exports.NETWORK_STATUS = exports.NETWORK_ERROR = exports.ExtrinsicType = exports.ExtrinsicStatus = exports.ExternalRequestPromiseStatus = exports.EvmProviderErrorType = exports.CrowdloanParaState = exports.ContractType = exports.ChainType = exports.ChainEditStandard = exports.BasicTxWarningCode = exports.BasicTxErrorType = exports.BalanceErrorType = exports.AccountExternalErrorCode = exports.APIItemState = void 0;
|
|
6
|
+
exports.UnstakingStatus = exports.TransferTxErrorType = exports.TransactionDirection = exports.ThemeNames = exports.StakingType = exports.StakingTxErrorType = exports.StakingStatus = exports.RuntimeEnvironment = exports.RMRK_VER = exports.ProviderErrorType = exports.NotificationType = exports.NETWORK_STATUS = exports.NETWORK_ERROR = exports.MantaPayEnableMessage = exports.ExtrinsicType = exports.ExtrinsicStatus = exports.ExternalRequestPromiseStatus = exports.EvmProviderErrorType = exports.CrowdloanParaState = exports.ContractType = exports.ChainType = exports.ChainEditStandard = exports.BasicTxWarningCode = exports.BasicTxErrorType = exports.BalanceErrorType = exports.AccountExternalErrorCode = exports.APIItemState = void 0;
|
|
7
7
|
// Copyright 2019-2022 @polkadot/extension-koni authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
let RuntimeEnvironment;
|
|
@@ -241,4 +241,12 @@ exports.NotificationType = NotificationType;
|
|
|
241
241
|
NotificationType["SUCCESS"] = "success";
|
|
242
242
|
NotificationType["WARNING"] = "warning";
|
|
243
243
|
NotificationType["ERROR"] = "error";
|
|
244
|
-
})(NotificationType || (exports.NotificationType = NotificationType = {}));
|
|
244
|
+
})(NotificationType || (exports.NotificationType = NotificationType = {}));
|
|
245
|
+
let MantaPayEnableMessage;
|
|
246
|
+
exports.MantaPayEnableMessage = MantaPayEnableMessage;
|
|
247
|
+
(function (MantaPayEnableMessage) {
|
|
248
|
+
MantaPayEnableMessage["WRONG_PASSWORD"] = "WRONG_PASSWORD";
|
|
249
|
+
MantaPayEnableMessage["CHAIN_DISCONNECTED"] = "CHAIN_DISCONNECTED";
|
|
250
|
+
MantaPayEnableMessage["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
251
|
+
MantaPayEnableMessage["SUCCESS"] = "SUCCESS";
|
|
252
|
+
})(MantaPayEnableMessage || (exports.MantaPayEnableMessage = MantaPayEnableMessage = {}));
|
|
@@ -483,8 +483,24 @@ class Extension {
|
|
|
483
483
|
});
|
|
484
484
|
return true;
|
|
485
485
|
}
|
|
486
|
-
windowOpen(
|
|
487
|
-
|
|
486
|
+
windowOpen(_ref24) {
|
|
487
|
+
let {
|
|
488
|
+
allowedPath: path,
|
|
489
|
+
params,
|
|
490
|
+
subPath
|
|
491
|
+
} = _ref24;
|
|
492
|
+
let paramString = '';
|
|
493
|
+
if (params) {
|
|
494
|
+
paramString += '?';
|
|
495
|
+
for (let i = 0; i < Object.keys(params).length; i++) {
|
|
496
|
+
const [key, value] = Object.entries(params)[i];
|
|
497
|
+
paramString += `${key}=${value}`;
|
|
498
|
+
if (i !== Object.keys(params).length - 1) {
|
|
499
|
+
paramString += '&';
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
const url = `${chrome.extension.getURL('index.html')}#${path}${subPath || ''}${paramString}`;
|
|
488
504
|
if (!_defaults.ALLOWED_PATH.includes(path)) {
|
|
489
505
|
console.error('Not allowed to open the url:', url);
|
|
490
506
|
return false;
|
|
@@ -507,26 +523,26 @@ class Extension {
|
|
|
507
523
|
throw new Error(`"${suri}" is not a valid derivation path`);
|
|
508
524
|
}
|
|
509
525
|
}
|
|
510
|
-
derivationValidate(
|
|
526
|
+
derivationValidate(_ref25) {
|
|
511
527
|
let {
|
|
512
528
|
parentAddress,
|
|
513
529
|
parentPassword,
|
|
514
530
|
suri
|
|
515
|
-
} =
|
|
531
|
+
} = _ref25;
|
|
516
532
|
const childPair = this.derive(parentAddress, suri, parentPassword, {});
|
|
517
533
|
return {
|
|
518
534
|
address: childPair.address,
|
|
519
535
|
suri
|
|
520
536
|
};
|
|
521
537
|
}
|
|
522
|
-
derivationCreate(
|
|
538
|
+
derivationCreate(_ref26) {
|
|
523
539
|
let {
|
|
524
540
|
genesisHash,
|
|
525
541
|
name,
|
|
526
542
|
parentAddress,
|
|
527
543
|
parentPassword,
|
|
528
544
|
suri
|
|
529
|
-
} =
|
|
545
|
+
} = _ref26;
|
|
530
546
|
const childPair = this.derive(parentAddress, suri, parentPassword, {
|
|
531
547
|
genesisHash,
|
|
532
548
|
name,
|
package/cjs/constants/index.js
CHANGED
|
@@ -18,6 +18,8 @@ var _exportNames = {
|
|
|
18
18
|
CRON_REFRESH_CHAIN_STAKING_METADATA: true,
|
|
19
19
|
CRON_REFRESH_CHAIN_NOMINATOR_METADATA: true,
|
|
20
20
|
CRON_RECOVER_HISTORY_INTERVAL: true,
|
|
21
|
+
CRON_SYNC_MANTA_PAY: true,
|
|
22
|
+
MANTA_PAY_BALANCE_INTERVAL: true,
|
|
21
23
|
ALL_ACCOUNT_KEY: true,
|
|
22
24
|
ALL_NETWORK_KEY: true,
|
|
23
25
|
ALL_GENESIS_HASH: true,
|
|
@@ -25,7 +27,7 @@ var _exportNames = {
|
|
|
25
27
|
IGNORE_QR_SIGNER: true,
|
|
26
28
|
XCM_MIN_AMOUNT_RATIO: true
|
|
27
29
|
};
|
|
28
|
-
exports.XCM_MIN_AMOUNT_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
|
|
30
|
+
exports.XCM_MIN_AMOUNT_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
|
|
29
31
|
var _staking = require("./staking");
|
|
30
32
|
Object.keys(_staking).forEach(function (key) {
|
|
31
33
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -69,6 +71,10 @@ const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
|
|
|
69
71
|
exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = CRON_REFRESH_CHAIN_NOMINATOR_METADATA;
|
|
70
72
|
const CRON_RECOVER_HISTORY_INTERVAL = 30000;
|
|
71
73
|
exports.CRON_RECOVER_HISTORY_INTERVAL = CRON_RECOVER_HISTORY_INTERVAL;
|
|
74
|
+
const CRON_SYNC_MANTA_PAY = 300000;
|
|
75
|
+
exports.CRON_SYNC_MANTA_PAY = CRON_SYNC_MANTA_PAY;
|
|
76
|
+
const MANTA_PAY_BALANCE_INTERVAL = 30000;
|
|
77
|
+
exports.MANTA_PAY_BALANCE_INTERVAL = MANTA_PAY_BALANCE_INTERVAL;
|
|
72
78
|
const ALL_ACCOUNT_KEY = 'ALL';
|
|
73
79
|
exports.ALL_ACCOUNT_KEY = ALL_ACCOUNT_KEY;
|
|
74
80
|
const ALL_NETWORK_KEY = 'all';
|
package/cjs/defaults.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.PORT_MOBILE = exports.PORT_EXTENSION = exports.PORT_CONTENT = exports.PH
|
|
|
7
7
|
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
|
|
10
|
-
const ALLOWED_PATH = ['/', '/settings/security', '/accounts/connect-ledger', '/accounts/restore-json', '/accounts/new-seed-phrase'];
|
|
10
|
+
const ALLOWED_PATH = ['/', '/settings/security', '/accounts/connect-ledger', '/accounts/restore-json', '/accounts/detail', '/accounts/new-seed-phrase'];
|
|
11
11
|
exports.ALLOWED_PATH = ALLOWED_PATH;
|
|
12
12
|
const PHISHING_PAGE_REDIRECT = '/phishing-page-detected';
|
|
13
13
|
exports.PHISHING_PAGE_REDIRECT = PHISHING_PAGE_REDIRECT;
|
|
@@ -337,6 +337,11 @@ async function subscribeTokensAccountsPallet(addresses, chain, api, callBack, in
|
|
|
337
337
|
}
|
|
338
338
|
async function subscribeAssetsAccountPallet(addresses, chain, api, callBack) {
|
|
339
339
|
const tokenMap = _handlers.state.getAssetByChainAndAsset(chain, [_types._AssetType.LOCAL]);
|
|
340
|
+
Object.values(tokenMap).forEach(token => {
|
|
341
|
+
if (_constants2._MANTA_ZK_CHAIN_GROUP.includes(token.originChain) && token.symbol.startsWith(_constants2._ZK_ASSET_PREFIX)) {
|
|
342
|
+
delete tokenMap[token.slug];
|
|
343
|
+
}
|
|
344
|
+
});
|
|
340
345
|
const unsubList = await Promise.all(Object.values(tokenMap).map(async tokenInfo => {
|
|
341
346
|
try {
|
|
342
347
|
const assetIndex = (0, _utils2._getTokenOnChainAssetId)(tokenInfo);
|
|
@@ -42,6 +42,12 @@ async function checkSupportTransfer(networkKey, tokenInfo, substrateApiMap, chai
|
|
|
42
42
|
supportTransferAll: true
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
+
if (tokenInfo.symbol.startsWith(_constants._ZK_ASSET_PREFIX) && _constants._MANTA_ZK_CHAIN_GROUP.includes(tokenInfo.originChain)) {
|
|
46
|
+
return {
|
|
47
|
+
supportTransfer: false,
|
|
48
|
+
supportTransferAll: false
|
|
49
|
+
};
|
|
50
|
+
}
|
|
45
51
|
if (_constants._TRANSFER_NOT_SUPPORTED_CHAINS.includes(networkKey)) {
|
|
46
52
|
return {
|
|
47
53
|
supportTransfer: false,
|
|
@@ -10,8 +10,8 @@ exports.getAstarDappsInfo = getAstarDappsInfo;
|
|
|
10
10
|
exports.getAstarNominatorMetadata = getAstarNominatorMetadata;
|
|
11
11
|
exports.getAstarStakingMetadata = getAstarStakingMetadata;
|
|
12
12
|
exports.getAstarUnbondingExtrinsic = getAstarUnbondingExtrinsic;
|
|
13
|
-
exports.getAstarWithdrawable = getAstarWithdrawable;
|
|
14
13
|
exports.getAstarWithdrawalExtrinsic = getAstarWithdrawalExtrinsic;
|
|
14
|
+
exports.getCompoundWithdrawable = getCompoundWithdrawable;
|
|
15
15
|
exports.subscribeAstarNominatorMetadata = subscribeAstarNominatorMetadata;
|
|
16
16
|
exports.subscribeAstarStakingMetadata = subscribeAstarStakingMetadata;
|
|
17
17
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
@@ -367,7 +367,7 @@ async function getAstarClaimRewardExtrinsic(substrateApi, address) {
|
|
|
367
367
|
}
|
|
368
368
|
return apiPromise.api.tx.utility.batch(transactions);
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function getCompoundWithdrawable(nominatorMetadata) {
|
|
371
371
|
const unstakingInfo = {
|
|
372
372
|
chain: nominatorMetadata.chain,
|
|
373
373
|
status: _KoniTypes.UnstakingStatus.CLAIMABLE,
|
|
@@ -615,17 +615,27 @@ async function getRelayBondingExtrinsic(substrateApi, amount, targetValidators,
|
|
|
615
615
|
const binaryAmount = new _util.BN(amount);
|
|
616
616
|
let bondTx;
|
|
617
617
|
let nominateTx;
|
|
618
|
+
const _params = chainApi.api.tx.staking.bond.toJSON();
|
|
619
|
+
const paramsCount = _params.args.length;
|
|
618
620
|
const validatorParamList = targetValidators.map(validator => {
|
|
619
621
|
return validator.address;
|
|
620
622
|
});
|
|
621
623
|
if (!nominatorMetadata) {
|
|
622
|
-
|
|
624
|
+
if (paramsCount === 2) {
|
|
625
|
+
bondTx = chainApi.api.tx.staking.bond(binaryAmount, bondDest);
|
|
626
|
+
} else {
|
|
627
|
+
bondTx = chainApi.api.tx.staking.bond(address, binaryAmount, bondDest);
|
|
628
|
+
}
|
|
623
629
|
nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
|
|
624
630
|
return chainApi.api.tx.utility.batchAll([bondTx, nominateTx]);
|
|
625
631
|
}
|
|
626
632
|
if (!nominatorMetadata.isBondedBefore) {
|
|
627
633
|
// first time
|
|
628
|
-
|
|
634
|
+
if (paramsCount === 2) {
|
|
635
|
+
bondTx = chainApi.api.tx.staking.bond(binaryAmount, bondDest);
|
|
636
|
+
} else {
|
|
637
|
+
bondTx = chainApi.api.tx.staking.bond(nominatorMetadata.address, binaryAmount, bondDest);
|
|
638
|
+
}
|
|
629
639
|
nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
|
|
630
640
|
return chainApi.api.tx.utility.batchAll([bondTx, nominateTx]);
|
|
631
641
|
} else {
|
|
@@ -247,8 +247,8 @@ function isActionFromValidator(stakingType, chain) {
|
|
|
247
247
|
function getWithdrawalInfo(nominatorMetadata) {
|
|
248
248
|
const unstakings = nominatorMetadata.unstakings;
|
|
249
249
|
let result;
|
|
250
|
-
if (_constants._STAKING_CHAIN_GROUP.astar.includes(nominatorMetadata.chain)) {
|
|
251
|
-
return (0, _astar.
|
|
250
|
+
if (_constants._STAKING_CHAIN_GROUP.astar.includes(nominatorMetadata.chain) || _constants._STAKING_CHAIN_GROUP.relay.includes(nominatorMetadata.chain)) {
|
|
251
|
+
return (0, _astar.getCompoundWithdrawable)(nominatorMetadata);
|
|
252
252
|
}
|
|
253
253
|
for (const unstaking of unstakings) {
|
|
254
254
|
if (unstaking.status === _KoniTypes.UnstakingStatus.CLAIMABLE) {
|
|
@@ -72,7 +72,7 @@ class KoniCron {
|
|
|
72
72
|
const serviceInfo = this.state.getServiceInfo();
|
|
73
73
|
const commonReload = eventTypes.some(eventType => commonReloadEvents.includes(eventType));
|
|
74
74
|
const chainUpdated = eventTypes.includes('chain.updateState');
|
|
75
|
-
const
|
|
75
|
+
const reloadMantaPay = eventTypes.includes('mantaPay.submitTransaction') || eventTypes.includes('mantaPay.enable');
|
|
76
76
|
const updatedChains = [];
|
|
77
77
|
if (chainUpdated) {
|
|
78
78
|
events.forEach(event => {
|
|
@@ -82,7 +82,7 @@ class KoniCron {
|
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
if (!commonReload && !chainUpdated && !
|
|
85
|
+
if (!commonReload && !chainUpdated && !reloadMantaPay) {
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
|
|
@@ -91,25 +91,19 @@ class KoniCron {
|
|
|
91
91
|
}
|
|
92
92
|
const chainInfoMap = serviceInfo.chainInfoMap;
|
|
93
93
|
const needUpdateNft = this.needUpdateNft(chainInfoMap, updatedChains);
|
|
94
|
-
|
|
94
|
+
|
|
95
|
+
// MantaPay
|
|
96
|
+
reloadMantaPay && this.removeCron('syncMantaPay');
|
|
95
97
|
|
|
96
98
|
// NFT
|
|
97
99
|
(commonReload || needUpdateNft) && this.resetNft(address);
|
|
98
100
|
(commonReload || needUpdateNft) && this.removeCron('refreshNft');
|
|
99
101
|
|
|
100
|
-
// Staking
|
|
101
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.resetStakingReward();
|
|
102
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.removeCron('refreshStakingReward');
|
|
103
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.removeCron('refreshPoolingStakingReward');
|
|
104
|
-
needUpdateStaking && this.removeCron('updateChainStakingMetadata');
|
|
105
|
-
|
|
106
102
|
// Chains
|
|
107
103
|
if (this.checkNetworkAvailable(serviceInfo)) {
|
|
108
104
|
// only add cron job if there's at least 1 active network
|
|
109
105
|
(commonReload || needUpdateNft) && this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
110
|
-
|
|
111
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
112
|
-
needUpdateStaking && this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate), _constants.CRON_REFRESH_CHAIN_STAKING_METADATA);
|
|
106
|
+
reloadMantaPay && this.addCron('syncMantaPay', this.syncMantaPay, _constants.CRON_SYNC_MANTA_PAY);
|
|
113
107
|
} else {
|
|
114
108
|
this.setStakingRewardReady();
|
|
115
109
|
}
|
|
@@ -123,7 +117,7 @@ class KoniCron {
|
|
|
123
117
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
124
118
|
this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
125
119
|
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
126
|
-
this.addCron('
|
|
120
|
+
this.addCron('syncMantaPay', this.syncMantaPay, _constants.CRON_SYNC_MANTA_PAY);
|
|
127
121
|
} else {
|
|
128
122
|
this.setStakingRewardReady();
|
|
129
123
|
}
|
|
@@ -147,6 +141,11 @@ class KoniCron {
|
|
|
147
141
|
this.status = 'stopped';
|
|
148
142
|
return Promise.resolve();
|
|
149
143
|
};
|
|
144
|
+
syncMantaPay = () => {
|
|
145
|
+
if (this.state.isMantaPayEnabled) {
|
|
146
|
+
this.state.syncMantaPay().catch(console.warn);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
150
149
|
refreshNft = (address, apiMap, smartContractNfts, chainInfoMap) => {
|
|
151
150
|
return () => {
|
|
152
151
|
this.subscriptions.subscribeNft(address, apiMap.substrate, apiMap.evm, smartContractNfts, chainInfoMap);
|
|
@@ -155,9 +154,6 @@ class KoniCron {
|
|
|
155
154
|
resetNft = newAddress => {
|
|
156
155
|
this.state.resetNft(newAddress);
|
|
157
156
|
};
|
|
158
|
-
resetStakingReward = () => {
|
|
159
|
-
this.state.resetStakingReward();
|
|
160
|
-
};
|
|
161
157
|
refreshStakingReward = address => {
|
|
162
158
|
return () => {
|
|
163
159
|
this.subscriptions.subscribeStakingReward(address).catch(this.logger.error);
|
|
@@ -174,16 +170,6 @@ class KoniCron {
|
|
|
174
170
|
checkNetworkAvailable = serviceInfo => {
|
|
175
171
|
return Object.keys(serviceInfo.chainApiMap.substrate).length > 0 || Object.keys(serviceInfo.chainApiMap.evm).length > 0;
|
|
176
172
|
};
|
|
177
|
-
updateChainStakingMetadata = (chainInfoMap, chainStateMap, substrateApiMap) => {
|
|
178
|
-
return () => {
|
|
179
|
-
this.subscriptions.fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap).catch(this.logger.error);
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
updateNominatorMetadata = (address, chainInfoMap, chainStateMap, substrateApiMap) => {
|
|
183
|
-
return () => {
|
|
184
|
-
this.subscriptions.fetchNominatorMetadata(address, chainInfoMap, chainStateMap, substrateApiMap).catch(this.logger.error);
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
173
|
async reloadNft() {
|
|
188
174
|
const address = this.state.keyringService.currentAccount.address;
|
|
189
175
|
const serviceInfo = this.state.getServiceInfo();
|
|
@@ -195,11 +181,7 @@ class KoniCron {
|
|
|
195
181
|
}
|
|
196
182
|
async reloadStaking() {
|
|
197
183
|
const address = this.state.keyringService.currentAccount.address;
|
|
198
|
-
|
|
199
|
-
this.removeCron('refreshStakingReward');
|
|
200
|
-
this.removeCron('refreshPoolingStakingReward');
|
|
201
|
-
this.addCron('refreshStakingReward', this.refreshStakingReward(address), _constants.CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
202
|
-
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
184
|
+
console.log('reload staking', address);
|
|
203
185
|
await (0, _utils2.waitTimeout)(1800);
|
|
204
186
|
return true;
|
|
205
187
|
}
|
|
@@ -212,11 +194,5 @@ class KoniCron {
|
|
|
212
194
|
}
|
|
213
195
|
return false;
|
|
214
196
|
}
|
|
215
|
-
needUpdateStaking(chainInfoMap, updatedChains) {
|
|
216
|
-
if (updatedChains && updatedChains.length > 0) {
|
|
217
|
-
return updatedChains.some(updatedChain => (0, _utils._isChainSupportSubstrateStaking)(chainInfoMap[updatedChain]));
|
|
218
|
-
}
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
197
|
}
|
|
222
198
|
exports.KoniCron = KoniCron;
|