@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
|
@@ -32,6 +32,7 @@ var _keyringService = require("@subwallet/extension-base/services/keyring-servic
|
|
|
32
32
|
var _migrationService = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service"));
|
|
33
33
|
var _mintCampaignService = _interopRequireDefault(require("@subwallet/extension-base/services/mint-campaign-service"));
|
|
34
34
|
var _mktCampaignService = _interopRequireDefault(require("@subwallet/extension-base/services/mkt-campaign-service"));
|
|
35
|
+
var _multisigService = require("@subwallet/extension-base/services/multisig-service");
|
|
35
36
|
var _nftService = _interopRequireDefault(require("@subwallet/extension-base/services/nft-service"));
|
|
36
37
|
var _NotificationService = _interopRequireDefault(require("@subwallet/extension-base/services/notification-service/NotificationService"));
|
|
37
38
|
var _openGov = _interopRequireDefault(require("@subwallet/extension-base/services/open-gov"));
|
|
@@ -133,6 +134,7 @@ class KoniState {
|
|
|
133
134
|
this.inappNotificationService = new _inappNotificationService.InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
|
|
134
135
|
this.chainOnlineService = new _chainOnlineService.ChainOnlineService(this.chainService, this.settingService, this.eventService, this.dbService);
|
|
135
136
|
this.openGovService = new _openGov.default(this);
|
|
137
|
+
this.multisigService = new _multisigService.MultisigService(this.eventService, this.chainService, this.keyringService, this.inappNotificationService);
|
|
136
138
|
this.substrateProxyAccountService = new _substrateProxyService.default(this);
|
|
137
139
|
this.subscription = new _subscription.KoniSubscription(this, this.dbService);
|
|
138
140
|
this.cron = new _cron.KoniCron(this, this.subscription, this.dbService);
|
|
@@ -239,6 +241,7 @@ class KoniState {
|
|
|
239
241
|
await this.swapService.init();
|
|
240
242
|
await this.inappNotificationService.init();
|
|
241
243
|
await this.openGovService.init();
|
|
244
|
+
await this.multisigService.init();
|
|
242
245
|
|
|
243
246
|
// this.onReady();
|
|
244
247
|
this.onAccountAdd();
|
|
@@ -1694,7 +1697,7 @@ class KoniState {
|
|
|
1694
1697
|
this.campaignService.stop();
|
|
1695
1698
|
await Promise.all([this.cron.stop(), this.subscription.stop()]);
|
|
1696
1699
|
await this.pauseAllNetworks(undefined, 'IDLE mode');
|
|
1697
|
-
await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop(), this.openGovService.stop()]);
|
|
1700
|
+
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()]);
|
|
1698
1701
|
|
|
1699
1702
|
// Complete sleeping
|
|
1700
1703
|
sleeping.resolve();
|
|
@@ -1750,7 +1753,7 @@ class KoniState {
|
|
|
1750
1753
|
this.generalStatus = _types.ServiceStatus.STARTING_FULL;
|
|
1751
1754
|
const startingFull = (0, _promise.createPromiseHandler)();
|
|
1752
1755
|
this.waitStartingFull = startingFull.promise;
|
|
1753
|
-
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()]);
|
|
1756
|
+
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()]);
|
|
1754
1757
|
this.eventService.emit('general.start_full', true);
|
|
1755
1758
|
this.waitStartingFull = null;
|
|
1756
1759
|
this.generalStatus = _types.ServiceStatus.STARTED_FULL;
|
|
@@ -1824,10 +1827,6 @@ class KoniState {
|
|
|
1824
1827
|
await this.balanceService.reloadBalance();
|
|
1825
1828
|
return true;
|
|
1826
1829
|
}
|
|
1827
|
-
async reloadCrowdloan() {
|
|
1828
|
-
await this.subscription.reloadCrowdloan();
|
|
1829
|
-
return true;
|
|
1830
|
-
}
|
|
1831
1830
|
async approvePassPhishingPage(_url) {
|
|
1832
1831
|
return new Promise(resolve => {
|
|
1833
1832
|
this.settingService.getPassPhishingList(value => {
|
|
@@ -83,11 +83,12 @@ function transformAccountsV2(accounts) {
|
|
|
83
83
|
let {
|
|
84
84
|
json: {
|
|
85
85
|
meta: {
|
|
86
|
-
isHidden
|
|
86
|
+
isHidden,
|
|
87
|
+
isMultisig
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
} = _ref2;
|
|
90
|
-
return !isHidden;
|
|
91
|
+
return !isHidden && !isMultisig;
|
|
91
92
|
}).filter(authTypeFilter).filter(_ref3 => {
|
|
92
93
|
let {
|
|
93
94
|
json: {
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.KoniSubscription = void 0;
|
|
7
7
|
var _crowdloan = require("@subwallet/extension-base/koni/api/dotsama/crowdloan");
|
|
8
8
|
var _nft = require("@subwallet/extension-base/koni/api/nft");
|
|
9
|
-
var _types = require("@subwallet/extension-base/services/event-service/types");
|
|
10
9
|
var _utils = require("@subwallet/extension-base/utils");
|
|
11
10
|
var _util = require("@polkadot/util");
|
|
12
11
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -47,26 +46,7 @@ class KoniSubscription {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
async start() {
|
|
50
|
-
var _this$state$keyringSe;
|
|
51
49
|
await Promise.all([this.state.eventService.waitCryptoReady, this.state.eventService.waitKeyringReady, this.state.eventService.waitAssetReady]);
|
|
52
|
-
const currentAddress = (_this$state$keyringSe = this.state.keyringService.context.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.proxyId;
|
|
53
|
-
if (currentAddress) {
|
|
54
|
-
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
55
|
-
}
|
|
56
|
-
this.eventHandler = (events, eventTypes) => {
|
|
57
|
-
var _serviceInfo$currentA;
|
|
58
|
-
const serviceInfo = this.state.getServiceInfo();
|
|
59
|
-
const needReload = eventTypes.some(eventType => _types.COMMON_RELOAD_EVENTS.includes(eventType));
|
|
60
|
-
if (!needReload) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.proxyId;
|
|
64
|
-
if (!address) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
this.subscribeCrowdloans(address, serviceInfo.chainApiMap.substrate);
|
|
68
|
-
};
|
|
69
|
-
this.state.eventService.onLazy(this.eventHandler.bind(this));
|
|
70
50
|
}
|
|
71
51
|
async stop() {
|
|
72
52
|
if (this.eventHandler) {
|
|
@@ -117,8 +97,8 @@ class KoniSubscription {
|
|
|
117
97
|
}).catch(this.logger.log);
|
|
118
98
|
}
|
|
119
99
|
async reloadCrowdloan() {
|
|
120
|
-
var _this$state$
|
|
121
|
-
const currentAddress = (_this$state$
|
|
100
|
+
var _this$state$keyringSe;
|
|
101
|
+
const currentAddress = (_this$state$keyringSe = this.state.keyringService.context.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.proxyId;
|
|
122
102
|
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
123
103
|
await (0, _utils.waitTimeout)(1800);
|
|
124
104
|
}
|
package/cjs/packageInfo.js
CHANGED
|
@@ -144,8 +144,6 @@ const subscribeWithSystemAccountPallet = async _ref => {
|
|
|
144
144
|
args: addresses
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
149
147
|
const subscription = substrateApi.subscribeDataWithMulti(params, async rs => {
|
|
150
148
|
const balances = rs[systemAccountKey];
|
|
151
149
|
const poolMemberInfos = rs[poolMembersKey];
|
|
@@ -358,7 +358,12 @@ class SubstrateApi {
|
|
|
358
358
|
subscriber.next([]);
|
|
359
359
|
});
|
|
360
360
|
} else {
|
|
361
|
-
observables[key] = apiRx[section][module][method].multi(args).pipe(
|
|
361
|
+
observables[key] = apiRx[section][module][method].multi(args).pipe(
|
|
362
|
+
// tap((codecs) => console.log('raw data', key, codecs)), // this line is used to debug data before transformation
|
|
363
|
+
(0, _rxjs.map)(codecs => codecs.map(codec => codec.toPrimitive())), (0, _rxjs.catchError)((error, caught) => {
|
|
364
|
+
console.error(`RxJS pipe() error for key ${key}`, error);
|
|
365
|
+
return (0, _rxjs.of)([]);
|
|
366
|
+
}));
|
|
362
367
|
}
|
|
363
368
|
});
|
|
364
369
|
return (0, _rxjs.combineLatest)(observables).subscribe(callback);
|
|
@@ -1450,6 +1450,7 @@ class ChainService {
|
|
|
1450
1450
|
hasNativeNft: false,
|
|
1451
1451
|
supportStaking: params.chainSpec.paraId === null,
|
|
1452
1452
|
supportProxy: false,
|
|
1453
|
+
supportMultisig: false,
|
|
1453
1454
|
supportSmartContract: null
|
|
1454
1455
|
};
|
|
1455
1456
|
} else if (params.chainSpec.evmChainId !== null) {
|
|
@@ -876,6 +876,10 @@ const _isChainInfoCompatibleWithAccountInfo = (chainInfo, accountInfo) => {
|
|
|
876
876
|
type: accountType
|
|
877
877
|
} = accountInfo;
|
|
878
878
|
if (accountChainType === _types3.AccountChainType.SUBSTRATE) {
|
|
879
|
+
var _chainInfo$substrateI19;
|
|
880
|
+
if (accountSignMode === _types3.AccountSignMode.MULTISIG && !((_chainInfo$substrateI19 = chainInfo.substrateInfo) !== null && _chainInfo$substrateI19 !== void 0 && _chainInfo$substrateI19.supportMultisig)) {
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
879
883
|
return _isPureSubstrateChain(chainInfo) && _types4.AllSubstrateKeypairTypes.includes(accountType);
|
|
880
884
|
}
|
|
881
885
|
if (accountChainType === _types3.AccountChainType.ETHEREUM) {
|
|
@@ -19,6 +19,17 @@ var _basePara = _interopRequireDefault(require("./base-para"));
|
|
|
19
19
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
20
20
|
// SPDX-License-Identifier: Apache-2.0
|
|
21
21
|
|
|
22
|
+
async function queryDelegationScheduledRequestsFallback(api, delegator, collator) {
|
|
23
|
+
const query = api.query.parachainStaking.delegationScheduledRequests;
|
|
24
|
+
const key = await query.keys();
|
|
25
|
+
if (key[0].args.length === 1) {
|
|
26
|
+
return await query(collator);
|
|
27
|
+
} else if (key[0].args.length === 2) {
|
|
28
|
+
return await query(collator, delegator);
|
|
29
|
+
} else {
|
|
30
|
+
throw new _TransactionError.TransactionError(_types.BasicTxErrorType.INVALID_PARAMS, 'More args than 2 and 1');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
function calculateMantaNominatorReturn(decimal, commission, totalActiveCollators, bnAnnualInflation, blocksPreviousRound, bnCollatorExpectedBlocksPerRound, bnCollatorTotalStaked, isCountCommission) {
|
|
23
34
|
const MIN_DELEGATION = new _bignumber.default(_constants2.MANTA_MIN_DELEGATION);
|
|
24
35
|
const factor = new _bignumber.default(10).pow(decimal);
|
|
@@ -148,7 +159,10 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
148
159
|
const roundInfo = _roundInfo.toPrimitive();
|
|
149
160
|
const currentRound = roundInfo.current;
|
|
150
161
|
await Promise.all(delegatorState.delegations.map(async delegation => {
|
|
151
|
-
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([
|
|
162
|
+
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([queryDelegationScheduledRequestsFallback(substrateApi.api, address,
|
|
163
|
+
// delegator
|
|
164
|
+
delegation.owner // collator
|
|
165
|
+
), (0, _utils2.parseIdentity)(substrateIdentityApi, delegation.owner), substrateApi.api.query.parachainStaking.candidateInfo(delegation.owner), substrateApi.api.query.system.number(), substrateApi.api.query.timestamp.now()]);
|
|
152
166
|
const currentBlock = _currentBlock.toPrimitive();
|
|
153
167
|
const currentTimestamp = _currentTimestamp.toPrimitive();
|
|
154
168
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
@@ -160,7 +174,8 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
160
174
|
// parse unstaking info
|
|
161
175
|
if (delegationScheduledRequests) {
|
|
162
176
|
for (const scheduledRequest of delegationScheduledRequests) {
|
|
163
|
-
|
|
177
|
+
const requestDelegator = scheduledRequest.delegator ? scheduledRequest.delegator : address;
|
|
178
|
+
if ((0, _utils3.reformatAddress)(requestDelegator, 0) === (0, _utils3.reformatAddress)(address, 0)) {
|
|
164
179
|
// add network prefix
|
|
165
180
|
const isClaimable = scheduledRequest.whenExecutable - parseInt(currentRound) <= 0;
|
|
166
181
|
const remainingEra = scheduledRequest.whenExecutable - parseInt(currentRound);
|
|
@@ -41,6 +41,7 @@ class EventService extends _eventemitter.default {
|
|
|
41
41
|
this.waitEarningReady = this.generateWaitPromise('earning.ready');
|
|
42
42
|
this.waitLedgerReady = this.generateWaitPromise('ledger.ready');
|
|
43
43
|
this.waitOpenGovReady = this.generateWaitPromise('open-gov.ready');
|
|
44
|
+
this.waitMultisigReady = this.generateWaitPromise('multisig-service.ready');
|
|
44
45
|
}
|
|
45
46
|
generateWaitPromise(eventType) {
|
|
46
47
|
return new Promise(resolve => {
|
|
@@ -54,13 +54,13 @@ const parseInfuraFee = (info, threshold) => {
|
|
|
54
54
|
exports.parseInfuraFee = parseInfuraFee;
|
|
55
55
|
const fetchInfuraFeeData = async (chainId, infuraAuth) => {
|
|
56
56
|
const baseUrl = 'https://gas.api.infura.io/networks/{{chainId}}/suggestedGasFees';
|
|
57
|
-
const
|
|
57
|
+
const baseThresholdUrl = 'https://gas.api.infura.io/networks/{{chainId}}/busyThreshold';
|
|
58
58
|
// const baseFeeHistoryUrl = 'https://gas.api.infura.io/networks/{{chainId}}/baseFeeHistory';
|
|
59
59
|
// const baseFeePercentileUrl = 'https://gas.api.infura.io/networks/{{chainId}}/baseFeePercentile';
|
|
60
60
|
const feeUrl = baseUrl.replaceAll('{{chainId}}', chainId.toString());
|
|
61
|
-
const
|
|
61
|
+
const thresholdUrl = baseThresholdUrl.replaceAll('{{chainId}}', chainId.toString());
|
|
62
62
|
try {
|
|
63
|
-
const [feeResp,
|
|
63
|
+
const [feeResp, thresholdResp] = await Promise.all([feeUrl, thresholdUrl].map(url => {
|
|
64
64
|
return fetch(url, {
|
|
65
65
|
method: 'GET',
|
|
66
66
|
headers: {
|
|
@@ -70,7 +70,7 @@ const fetchInfuraFeeData = async (chainId, infuraAuth) => {
|
|
|
70
70
|
}));
|
|
71
71
|
|
|
72
72
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
73
|
-
const [feeInfo, thresholdInfo] = await Promise.all([feeResp.json(),
|
|
73
|
+
const [feeInfo, thresholdInfo] = await Promise.all([feeResp.json(), thresholdResp.json()]);
|
|
74
74
|
return parseInfuraFee(feeInfo, thresholdInfo);
|
|
75
75
|
} catch (e) {
|
|
76
76
|
console.warn(e);
|
|
@@ -16,7 +16,8 @@ const NotificationTitleMap = {
|
|
|
16
16
|
[_interfaces.NotificationActionType.RECEIVE]: '[{{accountName}}] RECEIVE {{tokenSymbol}}',
|
|
17
17
|
[_interfaces.NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
18
18
|
[_interfaces.NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
19
|
-
[_interfaces.NotificationActionType.CLAIM_POLYGON_BRIDGE]: '[{{accountName}}] CLAIM {{tokenSymbol}}'
|
|
19
|
+
[_interfaces.NotificationActionType.CLAIM_POLYGON_BRIDGE]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
20
|
+
[_interfaces.NotificationActionType.MULTISIG_APPROVAL]: '[{{accountName}}] APPROVAL REQUIRED'
|
|
20
21
|
};
|
|
21
22
|
exports.NotificationTitleMap = NotificationTitleMap;
|
|
22
23
|
const NotificationDescriptionMap = {
|
|
@@ -26,7 +27,8 @@ const NotificationDescriptionMap = {
|
|
|
26
27
|
[_interfaces.NotificationActionType.RECEIVE]: _utils.getReceiveDescription,
|
|
27
28
|
[_interfaces.NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: _utils.getAvailBridgeClaimDescription,
|
|
28
29
|
[_interfaces.NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: _utils.getAvailBridgeClaimDescription,
|
|
29
|
-
[_interfaces.NotificationActionType.CLAIM_POLYGON_BRIDGE]: _utils.getPolygonBridgeClaimDescription
|
|
30
|
+
[_interfaces.NotificationActionType.CLAIM_POLYGON_BRIDGE]: _utils.getPolygonBridgeClaimDescription,
|
|
31
|
+
[_interfaces.NotificationActionType.MULTISIG_APPROVAL]: _utils.getMultisigApprovalDescription
|
|
30
32
|
};
|
|
31
33
|
exports.NotificationDescriptionMap = NotificationDescriptionMap;
|
|
32
34
|
const ONE_DAY_MILLISECOND = 1000 * 24 * 60 * 60;
|
|
@@ -35,8 +35,8 @@ class InappNotificationService {
|
|
|
35
35
|
await this.start();
|
|
36
36
|
this.onAccountProxyRemove();
|
|
37
37
|
}
|
|
38
|
-
async markAllRead(
|
|
39
|
-
await this.dbService.markAllRead(
|
|
38
|
+
async markAllRead(params) {
|
|
39
|
+
await this.dbService.markAllRead(params);
|
|
40
40
|
}
|
|
41
41
|
async switchReadStatus(params) {
|
|
42
42
|
await this.dbService.switchReadStatus(params);
|
|
@@ -59,6 +59,9 @@ class InappNotificationService {
|
|
|
59
59
|
let overdueTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _consts.ONE_DAY_MILLISECOND * 60;
|
|
60
60
|
return this.dbService.cleanUpOldNotifications(overdueTime);
|
|
61
61
|
}
|
|
62
|
+
cleanUpNotificationByIds(ids) {
|
|
63
|
+
return this.dbService.cleanUpNotificationByIds(ids);
|
|
64
|
+
}
|
|
62
65
|
passValidateNotification(candidateNotification, comparedNotifications, remindTimeConfigInHrs) {
|
|
63
66
|
// todo: simplify condition !!
|
|
64
67
|
if ([_interfaces.NotificationActionType.WITHDRAW, _interfaces.NotificationActionType.CLAIM].includes(candidateNotification.actionType)) {
|
|
@@ -94,6 +97,7 @@ class InappNotificationService {
|
|
|
94
97
|
}
|
|
95
98
|
if ([_interfaces.NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM, _interfaces.NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL].includes(candidateNotification.actionType)) {
|
|
96
99
|
const {
|
|
100
|
+
actionType,
|
|
97
101
|
address,
|
|
98
102
|
metadata,
|
|
99
103
|
time
|
|
@@ -104,6 +108,9 @@ class InappNotificationService {
|
|
|
104
108
|
if (notification.address !== address) {
|
|
105
109
|
continue;
|
|
106
110
|
}
|
|
111
|
+
if (notification.actionType !== actionType) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
107
114
|
if (time - notification.time >= remindTime) {
|
|
108
115
|
continue;
|
|
109
116
|
}
|
|
@@ -116,6 +123,7 @@ class InappNotificationService {
|
|
|
116
123
|
}
|
|
117
124
|
if ([_interfaces.NotificationActionType.CLAIM_POLYGON_BRIDGE].includes(candidateNotification.actionType)) {
|
|
118
125
|
const {
|
|
126
|
+
actionType,
|
|
119
127
|
address,
|
|
120
128
|
metadata,
|
|
121
129
|
time
|
|
@@ -126,6 +134,9 @@ class InappNotificationService {
|
|
|
126
134
|
if (notification.address !== address) {
|
|
127
135
|
continue;
|
|
128
136
|
}
|
|
137
|
+
if (notification.actionType !== actionType) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
129
140
|
if (time - notification.time >= remindTime) {
|
|
130
141
|
continue;
|
|
131
142
|
}
|
|
@@ -137,9 +148,16 @@ class InappNotificationService {
|
|
|
137
148
|
}
|
|
138
149
|
}
|
|
139
150
|
if ([_interfaces.NotificationActionType.SWAP, _interfaces.NotificationActionType.EARNING].includes(candidateNotification.actionType)) {
|
|
140
|
-
const
|
|
151
|
+
const {
|
|
152
|
+
actionType,
|
|
153
|
+
metadata
|
|
154
|
+
} = candidateNotification;
|
|
155
|
+
const candidateMetadata = metadata;
|
|
141
156
|
const processId = candidateMetadata.processId;
|
|
142
157
|
for (const notification of comparedNotifications) {
|
|
158
|
+
if (notification.actionType !== actionType) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
143
161
|
const comparedMetadata = notification.metadata;
|
|
144
162
|
const _processId = comparedMetadata.processId;
|
|
145
163
|
if (processId === _processId) {
|
|
@@ -147,10 +165,33 @@ class InappNotificationService {
|
|
|
147
165
|
}
|
|
148
166
|
}
|
|
149
167
|
}
|
|
168
|
+
if ([_interfaces.NotificationActionType.MULTISIG_APPROVAL].includes(candidateNotification.actionType)) {
|
|
169
|
+
const {
|
|
170
|
+
actionType,
|
|
171
|
+
address,
|
|
172
|
+
metadata
|
|
173
|
+
} = candidateNotification;
|
|
174
|
+
const candidateMetadata = metadata;
|
|
175
|
+
|
|
176
|
+
// todo: experiment without notification reminder, remove this todo if no problems raised
|
|
177
|
+
for (const notification of comparedNotifications) {
|
|
178
|
+
if (notification.address !== address) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (notification.actionType !== actionType) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const comparedMetadata = notification.metadata;
|
|
185
|
+
const sameNotification = candidateMetadata.multisigTxType === comparedMetadata.multisigTxType && candidateMetadata.multisigKey === comparedMetadata.multisigKey;
|
|
186
|
+
if (sameNotification) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
150
191
|
return true;
|
|
151
192
|
}
|
|
152
193
|
async validateAndWriteNotificationsToDB(notifications, address) {
|
|
153
|
-
const proxyId = this.keyringService.context.belongUnifiedAccount(address) || address;
|
|
194
|
+
const proxyId = this.keyringService.context.belongUnifiedAccount(address) || (0, _utils3.reformatAddress)(address);
|
|
154
195
|
const accountName = this.keyringService.context.getCurrentAccountProxyName(proxyId);
|
|
155
196
|
const passNotifications = [];
|
|
156
197
|
const [comparedNotifications, remindTimeConfig] = await Promise.all([this.fetchNotificationsByParams({
|
|
@@ -429,7 +470,9 @@ class InappNotificationService {
|
|
|
429
470
|
this.status = _types.ServiceStatus.STARTING;
|
|
430
471
|
await this.startCron();
|
|
431
472
|
this.status = _types.ServiceStatus.STARTED;
|
|
432
|
-
} catch (e) {
|
|
473
|
+
} catch (e) {
|
|
474
|
+
console.error('Failed to start InappNotificationService', e);
|
|
475
|
+
}
|
|
433
476
|
}
|
|
434
477
|
async startCron() {
|
|
435
478
|
this.cleanUpOldNotifications().catch(console.error);
|
|
@@ -441,7 +484,9 @@ class InappNotificationService {
|
|
|
441
484
|
this.status = _types.ServiceStatus.STOPPING;
|
|
442
485
|
await this.stopCron();
|
|
443
486
|
this.status = _types.ServiceStatus.STOPPED;
|
|
444
|
-
} catch (e) {
|
|
487
|
+
} catch (e) {
|
|
488
|
+
console.error('Failed to stop InappNotificationService', e);
|
|
489
|
+
}
|
|
445
490
|
}
|
|
446
491
|
stopCron() {
|
|
447
492
|
return Promise.resolve(undefined);
|
|
@@ -32,6 +32,7 @@ exports.NotificationActionType = NotificationActionType;
|
|
|
32
32
|
NotificationActionType["CLAIM_POLYGON_BRIDGE"] = "CLAIM_POLYGON_BRIDGE";
|
|
33
33
|
NotificationActionType["SWAP"] = "SWAP";
|
|
34
34
|
NotificationActionType["EARNING"] = "EARNING";
|
|
35
|
+
NotificationActionType["MULTISIG_APPROVAL"] = "MULTISIG_APPROVAL";
|
|
35
36
|
})(NotificationActionType || (exports.NotificationActionType = NotificationActionType = {}));
|
|
36
37
|
let NotificationTab;
|
|
37
38
|
exports.NotificationTab = NotificationTab;
|
|
@@ -39,4 +40,5 @@ exports.NotificationTab = NotificationTab;
|
|
|
39
40
|
NotificationTab["ALL"] = "ALL";
|
|
40
41
|
NotificationTab["UNREAD"] = "UNREAD";
|
|
41
42
|
NotificationTab["READ"] = "READ";
|
|
43
|
+
NotificationTab["MULTISIG"] = "MULTISIG";
|
|
42
44
|
})(NotificationTab || (exports.NotificationTab = NotificationTab = {}));
|
|
@@ -7,6 +7,7 @@ exports.createClaimNotification = createClaimNotification;
|
|
|
7
7
|
exports.createWithdrawNotifications = createWithdrawNotifications;
|
|
8
8
|
exports.getClaimDescription = getClaimDescription;
|
|
9
9
|
exports.getIsTabRead = getIsTabRead;
|
|
10
|
+
exports.getMultisigApprovalDescription = getMultisigApprovalDescription;
|
|
10
11
|
exports.getReceiveDescription = getReceiveDescription;
|
|
11
12
|
exports.getSendDescription = getSendDescription;
|
|
12
13
|
exports.getWithdrawDescription = getWithdrawDescription;
|
|
@@ -36,6 +37,9 @@ function getSendDescription(amount, symbol) {
|
|
|
36
37
|
function getReceiveDescription(amount, symbol) {
|
|
37
38
|
return `You have just received ${amount} ${symbol}`;
|
|
38
39
|
}
|
|
40
|
+
function getMultisigApprovalDescription() {
|
|
41
|
+
return 'A multisig transaction is waiting for your approval. Click to view details';
|
|
42
|
+
}
|
|
39
43
|
|
|
40
44
|
/* Description */
|
|
41
45
|
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.AccountContext = void 0;
|
|
7
7
|
var _Migration = require("@subwallet/extension-base/services/keyring-service/context/handlers/Migration");
|
|
8
|
+
var _Multisig = require("@subwallet/extension-base/services/keyring-service/context/handlers/Multisig");
|
|
9
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
8
10
|
var _handlers = require("./handlers");
|
|
9
11
|
var _state = require("./state");
|
|
10
12
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
@@ -23,6 +25,7 @@ class AccountContext {
|
|
|
23
25
|
this.modifyHandler = new _handlers.AccountModifyHandler(this.parentService, this.state);
|
|
24
26
|
this.secretHandler = new _handlers.AccountSecretHandler(this.parentService, this.state);
|
|
25
27
|
this.migrationHandler = new _Migration.AccountMigrationHandler(this.parentService, this.state);
|
|
28
|
+
this.multisigHandler = new _Multisig.AccountMultisigHandler(this.parentService, this.state);
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
// TODO: Merge to value
|
|
@@ -147,6 +150,15 @@ class AccountContext {
|
|
|
147
150
|
return this.secretHandler.accountsCreateExternalV2(request);
|
|
148
151
|
}
|
|
149
152
|
|
|
153
|
+
/* Multisig */
|
|
154
|
+
async accountsCreateMultisig(request) {
|
|
155
|
+
return this.multisigHandler.accountsCreateMultisig(request);
|
|
156
|
+
}
|
|
157
|
+
getSignableAccountInfos(request) {
|
|
158
|
+
const chainInfo = this.koniState.chainService.getChainInfoByKey(request.chain);
|
|
159
|
+
return this.multisigHandler.getSignableAccountInfos(request, chainInfo);
|
|
160
|
+
}
|
|
161
|
+
|
|
150
162
|
/* Import ethereum account with the private key */
|
|
151
163
|
privateKeyValidateV2(request) {
|
|
152
164
|
return this.secretHandler.privateKeyValidateV2(request);
|
|
@@ -262,6 +274,38 @@ class AccountContext {
|
|
|
262
274
|
|
|
263
275
|
/* Migration */
|
|
264
276
|
|
|
277
|
+
/* Multisig */
|
|
278
|
+
|
|
279
|
+
getMultisigAccounts() {
|
|
280
|
+
return this.state.getMultisigAccounts();
|
|
281
|
+
}
|
|
282
|
+
getMultisigAccountByAddress(address) {
|
|
283
|
+
if (!address) {
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
const allMultisigAccounts = this.getMultisigAccounts();
|
|
287
|
+
return allMultisigAccounts.find(acc => acc.accounts[0].address === (0, _utils.reformatAddress)(address));
|
|
288
|
+
}
|
|
289
|
+
getMultisigAccountInfoByAddress(address) {
|
|
290
|
+
const accountProxy = this.getMultisigAccountByAddress(address);
|
|
291
|
+
if (!accountProxy) {
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
const threshold = accountProxy.accounts[0].threshold;
|
|
295
|
+
const signers = accountProxy.accounts[0].signers;
|
|
296
|
+
const multisigAddress = accountProxy.accounts[0].address;
|
|
297
|
+
return {
|
|
298
|
+
threshold,
|
|
299
|
+
signers,
|
|
300
|
+
multisigAddress
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
getMultisigAddresses() {
|
|
304
|
+
return this.state.getMultisigAddresses();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/* Multisig */
|
|
308
|
+
|
|
265
309
|
/* Others */
|
|
266
310
|
|
|
267
311
|
removeNoneHardwareGenesisHash() {
|