@subwallet/extension-base 1.3.72-0 → 1.3.74-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 +42 -5
- package/background/KoniTypes.js +14 -1
- package/cjs/background/KoniTypes.js +16 -2
- package/cjs/core/logic-validation/transfer.js +35 -57
- package/cjs/koni/background/handlers/Extension.js +599 -146
- package/cjs/koni/background/handlers/State.js +5 -6
- package/cjs/koni/background/handlers/Tabs.js +3 -2
- package/cjs/koni/background/subscription.js +2 -22
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +0 -2
- package/cjs/services/chain-service/handler/SubstrateApi.js +6 -1
- package/cjs/services/chain-service/index.js +1 -0
- package/cjs/services/chain-service/utils/index.js +4 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +17 -2
- package/cjs/services/event-service/index.js +1 -0
- package/cjs/services/fee-service/utils/index.js +4 -4
- package/cjs/services/inapp-notification-service/consts.js +4 -2
- package/cjs/services/inapp-notification-service/index.js +51 -6
- package/cjs/services/inapp-notification-service/interfaces.js +2 -0
- package/cjs/services/inapp-notification-service/utils/common.js +4 -0
- package/cjs/services/keyring-service/context/account-context.js +44 -0
- package/cjs/services/keyring-service/context/handlers/Multisig.js +186 -0
- package/cjs/services/keyring-service/context/state.js +12 -0
- package/cjs/services/multisig-service/index.js +627 -0
- package/cjs/services/multisig-service/utils.js +242 -0
- package/cjs/services/request-service/handler/SubstrateRequestHandler.js +25 -0
- package/cjs/services/request-service/index.js +5 -1
- package/cjs/services/storage-service/DatabaseService.js +5 -2
- package/cjs/services/storage-service/db-stores/InappNotification.js +20 -2
- package/cjs/services/substrate-proxy-service/index.js +22 -7
- package/cjs/services/transaction-service/helpers/index.js +8 -0
- package/cjs/services/transaction-service/index.js +348 -147
- package/cjs/services/transaction-service/types.js +18 -1
- package/cjs/types/account/info/keyring.js +5 -0
- package/cjs/types/account/info/proxy.js +1 -0
- package/cjs/types/multisig/index.js +14 -0
- package/cjs/types/transaction/error.js +9 -2
- package/cjs/utils/account/transform.js +28 -4
- package/cjs/utils/logger/Logger.js +294 -0
- package/cjs/utils/logger/index.js +42 -0
- package/cjs/utils/logger/types.js +1 -0
- package/core/logic-validation/transfer.d.ts +2 -2
- package/core/logic-validation/transfer.js +10 -32
- package/koni/background/handlers/Extension.d.ts +7 -0
- package/koni/background/handlers/Extension.js +498 -45
- package/koni/background/handlers/State.d.ts +2 -1
- package/koni/background/handlers/State.js +5 -6
- package/koni/background/handlers/Tabs.js +3 -2
- package/koni/background/subscription.js +2 -22
- package/package.json +43 -7
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +0 -2
- package/services/chain-service/handler/SubstrateApi.js +7 -2
- package/services/chain-service/index.js +1 -0
- package/services/chain-service/types.d.ts +1 -1
- package/services/chain-service/utils/index.js +4 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +17 -2
- package/services/event-service/index.d.ts +1 -0
- package/services/event-service/index.js +1 -0
- package/services/event-service/types.d.ts +1 -0
- package/services/fee-service/utils/index.js +4 -4
- package/services/inapp-notification-service/consts.d.ts +3 -1
- package/services/inapp-notification-service/consts.js +5 -3
- package/services/inapp-notification-service/index.d.ts +3 -2
- package/services/inapp-notification-service/index.js +51 -6
- package/services/inapp-notification-service/interfaces.d.ts +18 -2
- package/services/inapp-notification-service/interfaces.js +2 -0
- package/services/inapp-notification-service/utils/common.d.ts +1 -0
- package/services/inapp-notification-service/utils/common.js +3 -0
- package/services/keyring-service/context/account-context.d.ts +9 -1
- package/services/keyring-service/context/account-context.js +44 -0
- package/services/keyring-service/context/handlers/Multisig.d.ts +18 -0
- package/services/keyring-service/context/handlers/Multisig.js +180 -0
- package/services/keyring-service/context/state.d.ts +2 -0
- package/services/keyring-service/context/state.js +12 -0
- package/services/multisig-service/index.d.ts +245 -0
- package/services/multisig-service/index.js +620 -0
- package/services/multisig-service/utils.d.ts +95 -0
- package/services/multisig-service/utils.js +227 -0
- package/services/request-service/handler/SubstrateRequestHandler.d.ts +1 -0
- package/services/request-service/handler/SubstrateRequestHandler.js +25 -0
- package/services/request-service/index.d.ts +2 -1
- package/services/request-service/index.js +5 -1
- package/services/storage-service/DatabaseService.d.ts +3 -2
- package/services/storage-service/DatabaseService.js +5 -2
- package/services/storage-service/db-stores/InappNotification.d.ts +3 -2
- package/services/storage-service/db-stores/InappNotification.js +20 -2
- package/services/substrate-proxy-service/index.d.ts +4 -1
- package/services/substrate-proxy-service/index.js +22 -8
- package/services/transaction-service/helpers/index.js +8 -0
- package/services/transaction-service/index.d.ts +31 -0
- package/services/transaction-service/index.js +270 -69
- package/services/transaction-service/types.d.ts +28 -3
- package/services/transaction-service/types.js +12 -1
- package/types/account/info/keyring.d.ts +14 -1
- package/types/account/info/keyring.js +6 -0
- package/types/account/info/proxy.d.ts +1 -0
- package/types/account/info/proxy.js +1 -0
- package/types/multisig/index.d.ts +76 -0
- package/types/multisig/index.js +8 -0
- package/types/notification/index.d.ts +8 -0
- package/types/substrateProxyAccount/index.d.ts +26 -1
- package/types/transaction/error.d.ts +6 -1
- package/types/transaction/error.js +7 -1
- package/types/transaction/request.d.ts +0 -1
- package/types/yield/info/pallet.d.ts +1 -1
- package/utils/account/transform.js +28 -4
- package/utils/logger/Logger.d.ts +31 -0
- package/utils/logger/Logger.js +267 -0
- package/utils/logger/index.d.ts +15 -0
- package/utils/logger/index.js +29 -0
- package/utils/logger/types.d.ts +23 -0
- package/utils/logger/types.js +1 -0
|
@@ -19,6 +19,7 @@ import { KeyringService } from '@subwallet/extension-base/services/keyring-servi
|
|
|
19
19
|
import MigrationService from '@subwallet/extension-base/services/migration-service';
|
|
20
20
|
import MintCampaignService from '@subwallet/extension-base/services/mint-campaign-service';
|
|
21
21
|
import MktCampaignService from '@subwallet/extension-base/services/mkt-campaign-service';
|
|
22
|
+
import { MultisigService } from '@subwallet/extension-base/services/multisig-service';
|
|
22
23
|
import NftService from '@subwallet/extension-base/services/nft-service';
|
|
23
24
|
import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
|
|
24
25
|
import OpenGovService from '@subwallet/extension-base/services/open-gov';
|
|
@@ -84,6 +85,7 @@ export default class KoniState {
|
|
|
84
85
|
readonly inappNotificationService: InappNotificationService;
|
|
85
86
|
readonly chainOnlineService: ChainOnlineService;
|
|
86
87
|
readonly openGovService: OpenGovService;
|
|
88
|
+
readonly multisigService: MultisigService;
|
|
87
89
|
readonly substrateProxyAccountService: SubstrateProxyAccountService;
|
|
88
90
|
private generalStatus;
|
|
89
91
|
private waitSleeping;
|
|
@@ -267,7 +269,6 @@ export default class KoniState {
|
|
|
267
269
|
reloadNft(): Promise<boolean>;
|
|
268
270
|
reloadStaking(): Promise<boolean>;
|
|
269
271
|
reloadBalance(): Promise<boolean>;
|
|
270
|
-
reloadCrowdloan(): Promise<boolean>;
|
|
271
272
|
approvePassPhishingPage(_url: string): Promise<boolean>;
|
|
272
273
|
saveEnvConfig<T extends keyof EnvConfig>(key: T, value: EnvConfig[T]): void;
|
|
273
274
|
initEnvConfig(envConfig: EnvConfig): void;
|
|
@@ -28,6 +28,7 @@ import { KeyringService } from '@subwallet/extension-base/services/keyring-servi
|
|
|
28
28
|
import MigrationService from '@subwallet/extension-base/services/migration-service';
|
|
29
29
|
import MintCampaignService from '@subwallet/extension-base/services/mint-campaign-service';
|
|
30
30
|
import MktCampaignService from '@subwallet/extension-base/services/mkt-campaign-service';
|
|
31
|
+
import { MultisigService } from '@subwallet/extension-base/services/multisig-service';
|
|
31
32
|
import NftService from '@subwallet/extension-base/services/nft-service';
|
|
32
33
|
import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
|
|
33
34
|
import OpenGovService from '@subwallet/extension-base/services/open-gov';
|
|
@@ -125,6 +126,7 @@ export default class KoniState {
|
|
|
125
126
|
this.inappNotificationService = new InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
|
|
126
127
|
this.chainOnlineService = new ChainOnlineService(this.chainService, this.settingService, this.eventService, this.dbService);
|
|
127
128
|
this.openGovService = new OpenGovService(this);
|
|
129
|
+
this.multisigService = new MultisigService(this.eventService, this.chainService, this.keyringService, this.inappNotificationService);
|
|
128
130
|
this.substrateProxyAccountService = new SubstrateProxyAccountService(this);
|
|
129
131
|
this.subscription = new KoniSubscription(this, this.dbService);
|
|
130
132
|
this.cron = new KoniCron(this, this.subscription, this.dbService);
|
|
@@ -230,6 +232,7 @@ export default class KoniState {
|
|
|
230
232
|
await this.swapService.init();
|
|
231
233
|
await this.inappNotificationService.init();
|
|
232
234
|
await this.openGovService.init();
|
|
235
|
+
await this.multisigService.init();
|
|
233
236
|
|
|
234
237
|
// this.onReady();
|
|
235
238
|
this.onAccountAdd();
|
|
@@ -1663,7 +1666,7 @@ export default class KoniState {
|
|
|
1663
1666
|
this.campaignService.stop();
|
|
1664
1667
|
await Promise.all([this.cron.stop(), this.subscription.stop()]);
|
|
1665
1668
|
await this.pauseAllNetworks(undefined, 'IDLE mode');
|
|
1666
|
-
await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop(), this.openGovService.stop()]);
|
|
1669
|
+
await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop(), this.openGovService.stop(), this.multisigService.stop()]);
|
|
1667
1670
|
|
|
1668
1671
|
// Complete sleeping
|
|
1669
1672
|
sleeping.resolve();
|
|
@@ -1719,7 +1722,7 @@ export default class KoniState {
|
|
|
1719
1722
|
this.generalStatus = ServiceStatus.STARTING_FULL;
|
|
1720
1723
|
const startingFull = createPromiseHandler();
|
|
1721
1724
|
this.waitStartingFull = startingFull.promise;
|
|
1722
|
-
await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start(), this.inappNotificationService.start(), this.openGovService.start()]);
|
|
1725
|
+
await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start(), this.inappNotificationService.start(), this.openGovService.start(), this.multisigService.start()]);
|
|
1723
1726
|
this.eventService.emit('general.start_full', true);
|
|
1724
1727
|
this.waitStartingFull = null;
|
|
1725
1728
|
this.generalStatus = ServiceStatus.STARTED_FULL;
|
|
@@ -1792,10 +1795,6 @@ export default class KoniState {
|
|
|
1792
1795
|
await this.balanceService.reloadBalance();
|
|
1793
1796
|
return true;
|
|
1794
1797
|
}
|
|
1795
|
-
async reloadCrowdloan() {
|
|
1796
|
-
await this.subscription.reloadCrowdloan();
|
|
1797
|
-
return true;
|
|
1798
|
-
}
|
|
1799
1798
|
async approvePassPhishingPage(_url) {
|
|
1800
1799
|
return new Promise(resolve => {
|
|
1801
1800
|
this.settingService.getPassPhishingList(value => {
|
|
@@ -69,10 +69,11 @@ function transformAccountsV2(accounts, anyType = false, authInfo, accountAuthTyp
|
|
|
69
69
|
const injectedAccounts = Object.values(accounts).filter(({
|
|
70
70
|
json: {
|
|
71
71
|
meta: {
|
|
72
|
-
isHidden
|
|
72
|
+
isHidden,
|
|
73
|
+
isMultisig
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
}) => !isHidden).filter(authTypeFilter).filter(({
|
|
76
|
+
}) => !isHidden && !isMultisig).filter(authTypeFilter).filter(({
|
|
76
77
|
json: {
|
|
77
78
|
address
|
|
78
79
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { subscribeCrowdloan } from '@subwallet/extension-base/koni/api/dotsama/crowdloan';
|
|
5
5
|
import { NftHandler } from '@subwallet/extension-base/koni/api/nft';
|
|
6
|
-
import { COMMON_RELOAD_EVENTS } from '@subwallet/extension-base/services/event-service/types';
|
|
7
6
|
import { waitTimeout } from '@subwallet/extension-base/utils';
|
|
8
7
|
import { logger as createLogger } from '@polkadot/util';
|
|
9
8
|
const nftHandler = new NftHandler();
|
|
@@ -41,26 +40,7 @@ export class KoniSubscription {
|
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
async start() {
|
|
44
|
-
var _this$state$keyringSe;
|
|
45
43
|
await Promise.all([this.state.eventService.waitCryptoReady, this.state.eventService.waitKeyringReady, this.state.eventService.waitAssetReady]);
|
|
46
|
-
const currentAddress = (_this$state$keyringSe = this.state.keyringService.context.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.proxyId;
|
|
47
|
-
if (currentAddress) {
|
|
48
|
-
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
49
|
-
}
|
|
50
|
-
this.eventHandler = (events, eventTypes) => {
|
|
51
|
-
var _serviceInfo$currentA;
|
|
52
|
-
const serviceInfo = this.state.getServiceInfo();
|
|
53
|
-
const needReload = eventTypes.some(eventType => COMMON_RELOAD_EVENTS.includes(eventType));
|
|
54
|
-
if (!needReload) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.proxyId;
|
|
58
|
-
if (!address) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.subscribeCrowdloans(address, serviceInfo.chainApiMap.substrate);
|
|
62
|
-
};
|
|
63
|
-
this.state.eventService.onLazy(this.eventHandler.bind(this));
|
|
64
44
|
}
|
|
65
45
|
async stop() {
|
|
66
46
|
if (this.eventHandler) {
|
|
@@ -106,8 +86,8 @@ export class KoniSubscription {
|
|
|
106
86
|
nftHandler.handleNfts(smartContractNfts, (...args) => this.state.updateNftData(...args), (...args) => this.state.setNftCollection(...args)).catch(this.logger.log);
|
|
107
87
|
}
|
|
108
88
|
async reloadCrowdloan() {
|
|
109
|
-
var _this$state$
|
|
110
|
-
const currentAddress = (_this$state$
|
|
89
|
+
var _this$state$keyringSe;
|
|
90
|
+
const currentAddress = (_this$state$keyringSe = this.state.keyringService.context.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.proxyId;
|
|
111
91
|
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
112
92
|
await waitTimeout(1800);
|
|
113
93
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.3.
|
|
20
|
+
"version": "1.3.74-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1386,6 +1386,11 @@
|
|
|
1386
1386
|
"require": "./cjs/services/keyring-service/context/handlers/Modify.js",
|
|
1387
1387
|
"default": "./services/keyring-service/context/handlers/Modify.js"
|
|
1388
1388
|
},
|
|
1389
|
+
"./services/keyring-service/context/handlers/Multisig": {
|
|
1390
|
+
"types": "./services/keyring-service/context/handlers/Multisig.d.ts",
|
|
1391
|
+
"require": "./cjs/services/keyring-service/context/handlers/Multisig.js",
|
|
1392
|
+
"default": "./services/keyring-service/context/handlers/Multisig.js"
|
|
1393
|
+
},
|
|
1389
1394
|
"./services/keyring-service/context/handlers/Secret": {
|
|
1390
1395
|
"types": "./services/keyring-service/context/handlers/Secret.d.ts",
|
|
1391
1396
|
"require": "./cjs/services/keyring-service/context/handlers/Secret.js",
|
|
@@ -1721,6 +1726,16 @@
|
|
|
1721
1726
|
"require": "./cjs/services/mkt-campaign-service/types.js",
|
|
1722
1727
|
"default": "./services/mkt-campaign-service/types.js"
|
|
1723
1728
|
},
|
|
1729
|
+
"./services/multisig-service": {
|
|
1730
|
+
"types": "./services/multisig-service/index.d.ts",
|
|
1731
|
+
"require": "./cjs/services/multisig-service/index.js",
|
|
1732
|
+
"default": "./services/multisig-service/index.js"
|
|
1733
|
+
},
|
|
1734
|
+
"./services/multisig-service/utils": {
|
|
1735
|
+
"types": "./services/multisig-service/utils.d.ts",
|
|
1736
|
+
"require": "./cjs/services/multisig-service/utils.js",
|
|
1737
|
+
"default": "./services/multisig-service/utils.js"
|
|
1738
|
+
},
|
|
1724
1739
|
"./services/nft-service": {
|
|
1725
1740
|
"types": "./services/nft-service/index.d.ts",
|
|
1726
1741
|
"require": "./cjs/services/nft-service/index.js",
|
|
@@ -2521,6 +2536,11 @@
|
|
|
2521
2536
|
"require": "./cjs/types/metadata.js",
|
|
2522
2537
|
"default": "./types/metadata.js"
|
|
2523
2538
|
},
|
|
2539
|
+
"./types/multisig": {
|
|
2540
|
+
"types": "./types/multisig/index.d.ts",
|
|
2541
|
+
"require": "./cjs/types/multisig/index.js",
|
|
2542
|
+
"default": "./types/multisig/index.js"
|
|
2543
|
+
},
|
|
2524
2544
|
"./types/notification": {
|
|
2525
2545
|
"types": "./types/notification/index.d.ts",
|
|
2526
2546
|
"require": "./cjs/types/notification/index.js",
|
|
@@ -2856,6 +2876,21 @@
|
|
|
2856
2876
|
"require": "./cjs/utils/lazy.js",
|
|
2857
2877
|
"default": "./utils/lazy.js"
|
|
2858
2878
|
},
|
|
2879
|
+
"./utils/logger": {
|
|
2880
|
+
"types": "./utils/logger/index.d.ts",
|
|
2881
|
+
"require": "./cjs/utils/logger/index.js",
|
|
2882
|
+
"default": "./utils/logger/index.js"
|
|
2883
|
+
},
|
|
2884
|
+
"./utils/logger/Logger": {
|
|
2885
|
+
"types": "./utils/logger/Logger.d.ts",
|
|
2886
|
+
"require": "./cjs/utils/logger/Logger.js",
|
|
2887
|
+
"default": "./utils/logger/Logger.js"
|
|
2888
|
+
},
|
|
2889
|
+
"./utils/logger/types": {
|
|
2890
|
+
"types": "./utils/logger/types.d.ts",
|
|
2891
|
+
"require": "./cjs/utils/logger/types.js",
|
|
2892
|
+
"default": "./utils/logger/types.js"
|
|
2893
|
+
},
|
|
2859
2894
|
"./utils/metadata": {
|
|
2860
2895
|
"types": "./utils/metadata.d.ts",
|
|
2861
2896
|
"require": "./cjs/utils/metadata.js",
|
|
@@ -2972,12 +3007,12 @@
|
|
|
2972
3007
|
"@snowbridge/registry": "^0.2.0",
|
|
2973
3008
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2974
3009
|
"@substrate/connect": "^0.8.9",
|
|
2975
|
-
"@subwallet-monorepos/subwallet-services-sdk": "0.1.
|
|
2976
|
-
"@subwallet/chain-list": "0.2.
|
|
2977
|
-
"@subwallet/extension-base": "^1.3.
|
|
2978
|
-
"@subwallet/extension-chains": "^1.3.
|
|
2979
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
2980
|
-
"@subwallet/extension-inject": "^1.3.
|
|
3010
|
+
"@subwallet-monorepos/subwallet-services-sdk": "0.1.16",
|
|
3011
|
+
"@subwallet/chain-list": "0.2.124-beta.1",
|
|
3012
|
+
"@subwallet/extension-base": "^1.3.74-0",
|
|
3013
|
+
"@subwallet/extension-chains": "^1.3.74-0",
|
|
3014
|
+
"@subwallet/extension-dapp": "^1.3.74-0",
|
|
3015
|
+
"@subwallet/extension-inject": "^1.3.74-0",
|
|
2981
3016
|
"@subwallet/keyring": "^0.1.14",
|
|
2982
3017
|
"@subwallet/ui-keyring": "^0.1.14",
|
|
2983
3018
|
"@ton/core": "^0.56.3",
|
|
@@ -3006,6 +3041,7 @@
|
|
|
3006
3041
|
"is-buffer": "^2.0.5",
|
|
3007
3042
|
"joi": "^17.13.3",
|
|
3008
3043
|
"json-rpc-engine": "^6.1.0",
|
|
3044
|
+
"loglevel": "^1.9.2",
|
|
3009
3045
|
"manta-extension-sdk": "^1.1.0",
|
|
3010
3046
|
"moment": "^2.29.4",
|
|
3011
3047
|
"protobufjs": "^7.5.4",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.3.
|
|
10
|
+
version: '1.3.74-0'
|
|
11
11
|
};
|
|
@@ -135,8 +135,6 @@ const subscribeWithSystemAccountPallet = async ({
|
|
|
135
135
|
args: addresses
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
140
138
|
const subscription = substrateApi.subscribeDataWithMulti(params, async rs => {
|
|
141
139
|
const balances = rs[systemAccountKey];
|
|
142
140
|
const poolMemberInfos = rs[poolMembersKey];
|
|
@@ -10,7 +10,7 @@ import { getSubstrateConnectProvider } from '@subwallet/extension-base/services/
|
|
|
10
10
|
import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
|
|
11
11
|
import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
|
|
12
12
|
import { goldbergRpc, goldbergTypes, spec as availSpec } from 'avail-js-sdk';
|
|
13
|
-
import { BehaviorSubject, combineLatest, map, Observable } from 'rxjs';
|
|
13
|
+
import { BehaviorSubject, catchError, combineLatest, map, Observable, of } from 'rxjs';
|
|
14
14
|
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
15
15
|
import { typesBundle as _typesBundle } from '@polkadot/apps-config/api';
|
|
16
16
|
import { TypeRegistry } from '@polkadot/types/create';
|
|
@@ -350,7 +350,12 @@ export class SubstrateApi {
|
|
|
350
350
|
subscriber.next([]);
|
|
351
351
|
});
|
|
352
352
|
} else {
|
|
353
|
-
observables[key] = apiRx[section][module][method].multi(args).pipe(
|
|
353
|
+
observables[key] = apiRx[section][module][method].multi(args).pipe(
|
|
354
|
+
// tap((codecs) => console.log('raw data', key, codecs)), // this line is used to debug data before transformation
|
|
355
|
+
map(codecs => codecs.map(codec => codec.toPrimitive())), catchError((error, caught) => {
|
|
356
|
+
console.error(`RxJS pipe() error for key ${key}`, error);
|
|
357
|
+
return of([]);
|
|
358
|
+
}));
|
|
354
359
|
}
|
|
355
360
|
});
|
|
356
361
|
return combineLatest(observables).subscribe(callback);
|
|
@@ -1422,6 +1422,7 @@ export class ChainService {
|
|
|
1422
1422
|
hasNativeNft: false,
|
|
1423
1423
|
supportStaking: params.chainSpec.paraId === null,
|
|
1424
1424
|
supportProxy: false,
|
|
1425
|
+
supportMultisig: false,
|
|
1425
1426
|
supportSmartContract: null
|
|
1426
1427
|
};
|
|
1427
1428
|
} else if (params.chainSpec.evmChainId !== null) {
|
|
@@ -100,7 +100,7 @@ export interface _SubstrateAdapterSubscriptionArgs extends Omit<Required<_Substr
|
|
|
100
100
|
}
|
|
101
101
|
export interface _SubstrateApiAdapter {
|
|
102
102
|
makeRpcQuery<T extends AnyJson | `0x${string}` | Registry | RuntimeVersion>(params: _SubstrateAdapterQueryArgs): Promise<T>;
|
|
103
|
-
subscribeDataWithMulti(params: _SubstrateAdapterSubscriptionArgs[], callback: (rs: Record<string, AnyJson[]>) => void): Subscription;
|
|
103
|
+
subscribeDataWithMulti(params: _SubstrateAdapterSubscriptionArgs[], callback: (rs: Record<string, AnyJson[]>) => void | Promise<void>): Subscription;
|
|
104
104
|
}
|
|
105
105
|
export interface _EvmApi extends _ChainBaseApi {
|
|
106
106
|
api: Web3;
|
|
@@ -644,6 +644,10 @@ export const _isChainInfoCompatibleWithAccountInfo = (chainInfo, accountInfo) =>
|
|
|
644
644
|
type: accountType
|
|
645
645
|
} = accountInfo;
|
|
646
646
|
if (accountChainType === AccountChainType.SUBSTRATE) {
|
|
647
|
+
var _chainInfo$substrateI19;
|
|
648
|
+
if (accountSignMode === AccountSignMode.MULTISIG && !((_chainInfo$substrateI19 = chainInfo.substrateInfo) !== null && _chainInfo$substrateI19 !== void 0 && _chainInfo$substrateI19.supportMultisig)) {
|
|
649
|
+
return false;
|
|
650
|
+
}
|
|
647
651
|
return _isPureSubstrateChain(chainInfo) && AllSubstrateKeypairTypes.includes(accountType);
|
|
648
652
|
}
|
|
649
653
|
if (accountChainType === AccountChainType.ETHEREUM) {
|
|
@@ -12,6 +12,17 @@ import { balanceFormatter, formatNumber, parseRawNumber, reformatAddress } from
|
|
|
12
12
|
import BigN from 'bignumber.js';
|
|
13
13
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
14
14
|
import BaseParaNativeStakingPoolHandler from "./base-para.js";
|
|
15
|
+
async function queryDelegationScheduledRequestsFallback(api, delegator, collator) {
|
|
16
|
+
const query = api.query.parachainStaking.delegationScheduledRequests;
|
|
17
|
+
const key = await query.keys();
|
|
18
|
+
if (key[0].args.length === 1) {
|
|
19
|
+
return await query(collator);
|
|
20
|
+
} else if (key[0].args.length === 2) {
|
|
21
|
+
return await query(collator, delegator);
|
|
22
|
+
} else {
|
|
23
|
+
throw new TransactionError(BasicTxErrorType.INVALID_PARAMS, 'More args than 2 and 1');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
15
26
|
function calculateMantaNominatorReturn(decimal, commission, totalActiveCollators, bnAnnualInflation, blocksPreviousRound, bnCollatorExpectedBlocksPerRound, bnCollatorTotalStaked, isCountCommission) {
|
|
16
27
|
const MIN_DELEGATION = new BigN(MANTA_MIN_DELEGATION);
|
|
17
28
|
const factor = new BigN(10).pow(decimal);
|
|
@@ -141,7 +152,10 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
141
152
|
const roundInfo = _roundInfo.toPrimitive();
|
|
142
153
|
const currentRound = roundInfo.current;
|
|
143
154
|
await Promise.all(delegatorState.delegations.map(async delegation => {
|
|
144
|
-
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([
|
|
155
|
+
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([queryDelegationScheduledRequestsFallback(substrateApi.api, address,
|
|
156
|
+
// delegator
|
|
157
|
+
delegation.owner // collator
|
|
158
|
+
), parseIdentity(substrateIdentityApi, delegation.owner), substrateApi.api.query.parachainStaking.candidateInfo(delegation.owner), substrateApi.api.query.system.number(), substrateApi.api.query.timestamp.now()]);
|
|
145
159
|
const currentBlock = _currentBlock.toPrimitive();
|
|
146
160
|
const currentTimestamp = _currentTimestamp.toPrimitive();
|
|
147
161
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
@@ -153,7 +167,8 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
153
167
|
// parse unstaking info
|
|
154
168
|
if (delegationScheduledRequests) {
|
|
155
169
|
for (const scheduledRequest of delegationScheduledRequests) {
|
|
156
|
-
|
|
170
|
+
const requestDelegator = scheduledRequest.delegator ? scheduledRequest.delegator : address;
|
|
171
|
+
if (reformatAddress(requestDelegator, 0) === reformatAddress(address, 0)) {
|
|
157
172
|
// add network prefix
|
|
158
173
|
const isClaimable = scheduledRequest.whenExecutable - parseInt(currentRound) <= 0;
|
|
159
174
|
const remainingEra = scheduledRequest.whenExecutable - parseInt(currentRound);
|
|
@@ -22,6 +22,7 @@ export declare class EventService extends EventEmitter<EventRegistry> {
|
|
|
22
22
|
readonly waitEarningReady: Promise<boolean>;
|
|
23
23
|
readonly waitLedgerReady: Promise<boolean>;
|
|
24
24
|
readonly waitOpenGovReady: Promise<boolean>;
|
|
25
|
+
readonly waitMultisigReady: Promise<boolean>;
|
|
25
26
|
constructor();
|
|
26
27
|
private generateWaitPromise;
|
|
27
28
|
private setLazyTimeout;
|
|
@@ -34,6 +34,7 @@ export class EventService extends EventEmitter {
|
|
|
34
34
|
this.waitEarningReady = this.generateWaitPromise('earning.ready');
|
|
35
35
|
this.waitLedgerReady = this.generateWaitPromise('ledger.ready');
|
|
36
36
|
this.waitOpenGovReady = this.generateWaitPromise('open-gov.ready');
|
|
37
|
+
this.waitMultisigReady = this.generateWaitPromise('multisig-service.ready');
|
|
37
38
|
}
|
|
38
39
|
generateWaitPromise(eventType) {
|
|
39
40
|
return new Promise(resolve => {
|
|
@@ -46,6 +46,7 @@ export interface EventRegistry {
|
|
|
46
46
|
'swap.ready': [boolean];
|
|
47
47
|
'ledger.ready': [boolean];
|
|
48
48
|
'open-gov.ready': [boolean];
|
|
49
|
+
'multisig-service.ready': [boolean];
|
|
49
50
|
}
|
|
50
51
|
export declare type EventType = keyof EventRegistry;
|
|
51
52
|
export declare const COMMON_RELOAD_EVENTS: EventType[];
|
|
@@ -45,13 +45,13 @@ export const parseInfuraFee = (info, threshold) => {
|
|
|
45
45
|
};
|
|
46
46
|
export const fetchInfuraFeeData = async (chainId, infuraAuth) => {
|
|
47
47
|
const baseUrl = 'https://gas.api.infura.io/networks/{{chainId}}/suggestedGasFees';
|
|
48
|
-
const
|
|
48
|
+
const baseThresholdUrl = 'https://gas.api.infura.io/networks/{{chainId}}/busyThreshold';
|
|
49
49
|
// const baseFeeHistoryUrl = 'https://gas.api.infura.io/networks/{{chainId}}/baseFeeHistory';
|
|
50
50
|
// const baseFeePercentileUrl = 'https://gas.api.infura.io/networks/{{chainId}}/baseFeePercentile';
|
|
51
51
|
const feeUrl = baseUrl.replaceAll('{{chainId}}', chainId.toString());
|
|
52
|
-
const
|
|
52
|
+
const thresholdUrl = baseThresholdUrl.replaceAll('{{chainId}}', chainId.toString());
|
|
53
53
|
try {
|
|
54
|
-
const [feeResp,
|
|
54
|
+
const [feeResp, thresholdResp] = await Promise.all([feeUrl, thresholdUrl].map(url => {
|
|
55
55
|
return fetch(url, {
|
|
56
56
|
method: 'GET',
|
|
57
57
|
headers: {
|
|
@@ -61,7 +61,7 @@ export const fetchInfuraFeeData = async (chainId, infuraAuth) => {
|
|
|
61
61
|
}));
|
|
62
62
|
|
|
63
63
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
64
|
-
const [feeInfo, thresholdInfo] = await Promise.all([feeResp.json(),
|
|
64
|
+
const [feeInfo, thresholdInfo] = await Promise.all([feeResp.json(), thresholdResp.json()]);
|
|
65
65
|
return parseInfuraFee(feeInfo, thresholdInfo);
|
|
66
66
|
} catch (e) {
|
|
67
67
|
console.warn(e);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAvailBridgeClaimDescription, getClaimDescription, getPolygonBridgeClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from './utils';
|
|
1
|
+
import { getAvailBridgeClaimDescription, getClaimDescription, getMultisigApprovalDescription, getPolygonBridgeClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from './utils';
|
|
2
2
|
export declare const NotificationTitleMap: {
|
|
3
3
|
WITHDRAW: string;
|
|
4
4
|
CLAIM: string;
|
|
@@ -7,6 +7,7 @@ export declare const NotificationTitleMap: {
|
|
|
7
7
|
CLAIM_AVAIL_BRIDGE_ON_AVAIL: string;
|
|
8
8
|
CLAIM_AVAIL_BRIDGE_ON_ETHEREUM: string;
|
|
9
9
|
CLAIM_POLYGON_BRIDGE: string;
|
|
10
|
+
MULTISIG_APPROVAL: string;
|
|
10
11
|
};
|
|
11
12
|
export declare const NotificationDescriptionMap: {
|
|
12
13
|
WITHDRAW: typeof getWithdrawDescription;
|
|
@@ -16,5 +17,6 @@ export declare const NotificationDescriptionMap: {
|
|
|
16
17
|
CLAIM_AVAIL_BRIDGE_ON_AVAIL: typeof getAvailBridgeClaimDescription;
|
|
17
18
|
CLAIM_AVAIL_BRIDGE_ON_ETHEREUM: typeof getAvailBridgeClaimDescription;
|
|
18
19
|
CLAIM_POLYGON_BRIDGE: typeof getPolygonBridgeClaimDescription;
|
|
20
|
+
MULTISIG_APPROVAL: typeof getMultisigApprovalDescription;
|
|
19
21
|
};
|
|
20
22
|
export declare const ONE_DAY_MILLISECOND: number;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { NotificationActionType } from "./interfaces.js";
|
|
5
|
-
import { getAvailBridgeClaimDescription, getClaimDescription, getPolygonBridgeClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from "./utils/index.js";
|
|
5
|
+
import { getAvailBridgeClaimDescription, getClaimDescription, getMultisigApprovalDescription, getPolygonBridgeClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from "./utils/index.js";
|
|
6
6
|
export const NotificationTitleMap = {
|
|
7
7
|
[NotificationActionType.WITHDRAW]: '[{{accountName}}] WITHDRAW {{tokenSymbol}}',
|
|
8
8
|
[NotificationActionType.CLAIM]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
@@ -10,7 +10,8 @@ export const NotificationTitleMap = {
|
|
|
10
10
|
[NotificationActionType.RECEIVE]: '[{{accountName}}] RECEIVE {{tokenSymbol}}',
|
|
11
11
|
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
12
12
|
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
13
|
-
[NotificationActionType.CLAIM_POLYGON_BRIDGE]: '[{{accountName}}] CLAIM {{tokenSymbol}}'
|
|
13
|
+
[NotificationActionType.CLAIM_POLYGON_BRIDGE]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
14
|
+
[NotificationActionType.MULTISIG_APPROVAL]: '[{{accountName}}] APPROVAL REQUIRED'
|
|
14
15
|
};
|
|
15
16
|
export const NotificationDescriptionMap = {
|
|
16
17
|
[NotificationActionType.WITHDRAW]: getWithdrawDescription,
|
|
@@ -19,6 +20,7 @@ export const NotificationDescriptionMap = {
|
|
|
19
20
|
[NotificationActionType.RECEIVE]: getReceiveDescription,
|
|
20
21
|
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: getAvailBridgeClaimDescription,
|
|
21
22
|
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: getAvailBridgeClaimDescription,
|
|
22
|
-
[NotificationActionType.CLAIM_POLYGON_BRIDGE]: getPolygonBridgeClaimDescription
|
|
23
|
+
[NotificationActionType.CLAIM_POLYGON_BRIDGE]: getPolygonBridgeClaimDescription,
|
|
24
|
+
[NotificationActionType.MULTISIG_APPROVAL]: getMultisigApprovalDescription
|
|
23
25
|
};
|
|
24
26
|
export const ONE_DAY_MILLISECOND = 1000 * 24 * 60 * 60;
|
|
@@ -7,7 +7,7 @@ import { AvailBridgeTransaction, PolygonTransaction } from '@subwallet/extension
|
|
|
7
7
|
import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
|
|
8
8
|
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
|
|
9
9
|
import { ProcessTransactionData } from '@subwallet/extension-base/types';
|
|
10
|
-
import { GetNotificationParams, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
|
|
10
|
+
import { GetNotificationParams, MarkAllReadParams, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
|
|
11
11
|
export declare class InappNotificationService implements CronServiceInterface {
|
|
12
12
|
private readonly dbService;
|
|
13
13
|
private readonly keyringService;
|
|
@@ -17,13 +17,14 @@ export declare class InappNotificationService implements CronServiceInterface {
|
|
|
17
17
|
private refeshAvailBridgeClaimTimeOut;
|
|
18
18
|
constructor(dbService: DatabaseService, keyringService: KeyringService, eventService: EventService, chainService: ChainService);
|
|
19
19
|
init(): Promise<void>;
|
|
20
|
-
markAllRead(
|
|
20
|
+
markAllRead(params: MarkAllReadParams): Promise<void>;
|
|
21
21
|
switchReadStatus(params: RequestSwitchStatusParams): Promise<void>;
|
|
22
22
|
subscribeUnreadNotificationsCountMap(callback: (data: Record<string, number>) => void): import("dexie").Subscription;
|
|
23
23
|
getUnreadNotificationsCountMap(): Promise<Record<string, number>>;
|
|
24
24
|
fetchNotificationsByParams(params: GetNotificationParams): Promise<_NotificationInfo[]>;
|
|
25
25
|
getNotificationById(id: string): Promise<_NotificationInfo | undefined>;
|
|
26
26
|
cleanUpOldNotifications(overdueTime?: number): Promise<number>;
|
|
27
|
+
cleanUpNotificationByIds(ids: string[]): Promise<number>;
|
|
27
28
|
passValidateNotification(candidateNotification: _BaseNotificationInfo, comparedNotifications: _NotificationInfo[], remindTimeConfigInHrs: Record<NotificationActionType, number>): boolean;
|
|
28
29
|
validateAndWriteNotificationsToDB(notifications: _BaseNotificationInfo[], address: string): Promise<void>;
|
|
29
30
|
cronCreateBridgeClaimNotification(): void;
|
|
@@ -29,8 +29,8 @@ export class InappNotificationService {
|
|
|
29
29
|
await this.start();
|
|
30
30
|
this.onAccountProxyRemove();
|
|
31
31
|
}
|
|
32
|
-
async markAllRead(
|
|
33
|
-
await this.dbService.markAllRead(
|
|
32
|
+
async markAllRead(params) {
|
|
33
|
+
await this.dbService.markAllRead(params);
|
|
34
34
|
}
|
|
35
35
|
async switchReadStatus(params) {
|
|
36
36
|
await this.dbService.switchReadStatus(params);
|
|
@@ -52,6 +52,9 @@ export class InappNotificationService {
|
|
|
52
52
|
cleanUpOldNotifications(overdueTime = ONE_DAY_MILLISECOND * 60) {
|
|
53
53
|
return this.dbService.cleanUpOldNotifications(overdueTime);
|
|
54
54
|
}
|
|
55
|
+
cleanUpNotificationByIds(ids) {
|
|
56
|
+
return this.dbService.cleanUpNotificationByIds(ids);
|
|
57
|
+
}
|
|
55
58
|
passValidateNotification(candidateNotification, comparedNotifications, remindTimeConfigInHrs) {
|
|
56
59
|
// todo: simplify condition !!
|
|
57
60
|
if ([NotificationActionType.WITHDRAW, NotificationActionType.CLAIM].includes(candidateNotification.actionType)) {
|
|
@@ -87,6 +90,7 @@ export class InappNotificationService {
|
|
|
87
90
|
}
|
|
88
91
|
if ([NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM, NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL].includes(candidateNotification.actionType)) {
|
|
89
92
|
const {
|
|
93
|
+
actionType,
|
|
90
94
|
address,
|
|
91
95
|
metadata,
|
|
92
96
|
time
|
|
@@ -97,6 +101,9 @@ export class InappNotificationService {
|
|
|
97
101
|
if (notification.address !== address) {
|
|
98
102
|
continue;
|
|
99
103
|
}
|
|
104
|
+
if (notification.actionType !== actionType) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
100
107
|
if (time - notification.time >= remindTime) {
|
|
101
108
|
continue;
|
|
102
109
|
}
|
|
@@ -109,6 +116,7 @@ export class InappNotificationService {
|
|
|
109
116
|
}
|
|
110
117
|
if ([NotificationActionType.CLAIM_POLYGON_BRIDGE].includes(candidateNotification.actionType)) {
|
|
111
118
|
const {
|
|
119
|
+
actionType,
|
|
112
120
|
address,
|
|
113
121
|
metadata,
|
|
114
122
|
time
|
|
@@ -119,6 +127,9 @@ export class InappNotificationService {
|
|
|
119
127
|
if (notification.address !== address) {
|
|
120
128
|
continue;
|
|
121
129
|
}
|
|
130
|
+
if (notification.actionType !== actionType) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
122
133
|
if (time - notification.time >= remindTime) {
|
|
123
134
|
continue;
|
|
124
135
|
}
|
|
@@ -130,9 +141,16 @@ export class InappNotificationService {
|
|
|
130
141
|
}
|
|
131
142
|
}
|
|
132
143
|
if ([NotificationActionType.SWAP, NotificationActionType.EARNING].includes(candidateNotification.actionType)) {
|
|
133
|
-
const
|
|
144
|
+
const {
|
|
145
|
+
actionType,
|
|
146
|
+
metadata
|
|
147
|
+
} = candidateNotification;
|
|
148
|
+
const candidateMetadata = metadata;
|
|
134
149
|
const processId = candidateMetadata.processId;
|
|
135
150
|
for (const notification of comparedNotifications) {
|
|
151
|
+
if (notification.actionType !== actionType) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
136
154
|
const comparedMetadata = notification.metadata;
|
|
137
155
|
const _processId = comparedMetadata.processId;
|
|
138
156
|
if (processId === _processId) {
|
|
@@ -140,10 +158,33 @@ export class InappNotificationService {
|
|
|
140
158
|
}
|
|
141
159
|
}
|
|
142
160
|
}
|
|
161
|
+
if ([NotificationActionType.MULTISIG_APPROVAL].includes(candidateNotification.actionType)) {
|
|
162
|
+
const {
|
|
163
|
+
actionType,
|
|
164
|
+
address,
|
|
165
|
+
metadata
|
|
166
|
+
} = candidateNotification;
|
|
167
|
+
const candidateMetadata = metadata;
|
|
168
|
+
|
|
169
|
+
// todo: experiment without notification reminder, remove this todo if no problems raised
|
|
170
|
+
for (const notification of comparedNotifications) {
|
|
171
|
+
if (notification.address !== address) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (notification.actionType !== actionType) {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const comparedMetadata = notification.metadata;
|
|
178
|
+
const sameNotification = candidateMetadata.multisigTxType === comparedMetadata.multisigTxType && candidateMetadata.multisigKey === comparedMetadata.multisigKey;
|
|
179
|
+
if (sameNotification) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
143
184
|
return true;
|
|
144
185
|
}
|
|
145
186
|
async validateAndWriteNotificationsToDB(notifications, address) {
|
|
146
|
-
const proxyId = this.keyringService.context.belongUnifiedAccount(address) || address;
|
|
187
|
+
const proxyId = this.keyringService.context.belongUnifiedAccount(address) || reformatAddress(address);
|
|
147
188
|
const accountName = this.keyringService.context.getCurrentAccountProxyName(proxyId);
|
|
148
189
|
const passNotifications = [];
|
|
149
190
|
const [comparedNotifications, remindTimeConfig] = await Promise.all([this.fetchNotificationsByParams({
|
|
@@ -422,7 +463,9 @@ export class InappNotificationService {
|
|
|
422
463
|
this.status = ServiceStatus.STARTING;
|
|
423
464
|
await this.startCron();
|
|
424
465
|
this.status = ServiceStatus.STARTED;
|
|
425
|
-
} catch (e) {
|
|
466
|
+
} catch (e) {
|
|
467
|
+
console.error('Failed to start InappNotificationService', e);
|
|
468
|
+
}
|
|
426
469
|
}
|
|
427
470
|
async startCron() {
|
|
428
471
|
this.cleanUpOldNotifications().catch(console.error);
|
|
@@ -434,7 +477,9 @@ export class InappNotificationService {
|
|
|
434
477
|
this.status = ServiceStatus.STOPPING;
|
|
435
478
|
await this.stopCron();
|
|
436
479
|
this.status = ServiceStatus.STOPPED;
|
|
437
|
-
} catch (e) {
|
|
480
|
+
} catch (e) {
|
|
481
|
+
console.error('Failed to stop InappNotificationService', e);
|
|
482
|
+
}
|
|
438
483
|
}
|
|
439
484
|
stopCron() {
|
|
440
485
|
return Promise.resolve(undefined);
|