@subwallet/extension-base 0.8.1-wr2x → 0.8.1-wr3
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 +31 -1
- package/background/KoniTypes.js +15 -1
- package/background/errors/BalanceError.d.ts +6 -0
- package/background/errors/BalanceError.js +33 -0
- package/background/handlers/State.js +2 -1
- package/cjs/background/KoniTypes.js +18 -2
- package/cjs/background/errors/BalanceError.js +39 -0
- package/cjs/background/handlers/State.js +2 -1
- package/cjs/koni/api/dotsama/balance.js +1 -0
- package/cjs/koni/background/handlers/Extension.js +140 -94
- package/cjs/koni/background/handlers/State.js +15 -11
- package/cjs/services/balance-service/index.js +95 -2
- package/cjs/services/chain-service/utils.js +13 -3
- package/cjs/services/notification-service/NotificationService.js +23 -1
- package/cjs/services/request-service/handler/PopupHandler.js +10 -16
- package/cjs/services/request-service/index.js +2 -6
- package/cjs/services/setting-service/SettingService.js +2 -1
- package/cjs/services/storage-service/DatabaseService.js +3 -2
- package/cjs/services/storage-service/db-stores/Balance.js +0 -25
- package/cjs/services/transaction-service/index.js +22 -6
- package/koni/api/dotsama/balance.d.ts +1 -0
- package/koni/api/dotsama/balance.js +1 -1
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +58 -14
- package/koni/background/handlers/State.d.ts +3 -1
- package/koni/background/handlers/State.js +15 -11
- package/package.json +8 -3
- package/services/balance-service/index.d.ts +7 -5
- package/services/balance-service/index.js +95 -2
- package/services/chain-service/utils.d.ts +1 -1
- package/services/chain-service/utils.js +13 -3
- package/services/notification-service/NotificationService.d.ts +6 -1
- package/services/notification-service/NotificationService.js +23 -1
- package/services/request-service/handler/PopupHandler.d.ts +0 -1
- package/services/request-service/handler/PopupHandler.js +10 -15
- package/services/request-service/index.d.ts +3 -2
- package/services/request-service/index.js +2 -6
- package/services/setting-service/SettingService.js +2 -1
- package/services/storage-service/DatabaseService.d.ts +2 -1
- package/services/storage-service/DatabaseService.js +3 -2
- package/services/storage-service/db-stores/Balance.js +0 -25
- package/services/transaction-service/index.d.ts +3 -1
- package/services/transaction-service/index.js +23 -7
- package/cjs/background/errors/EvmRpcError.js +0 -21
- package/cjs/background/errors/SubWalletProviderError.js +0 -17
- package/cjs/constants/ethereum.js +0 -19
- package/cjs/utils/eth/parseTransactionData.js +0 -284
|
@@ -297,8 +297,12 @@ export interface UiSettings {
|
|
|
297
297
|
isShowBalance: boolean;
|
|
298
298
|
accountAllLogo: string;
|
|
299
299
|
theme: ThemeNames;
|
|
300
|
+
camera: boolean;
|
|
300
301
|
}
|
|
301
302
|
export declare type RequestSettingsType = UiSettings;
|
|
303
|
+
export declare type RequestCameraSettings = {
|
|
304
|
+
camera: boolean;
|
|
305
|
+
};
|
|
302
306
|
export interface RandomTestRequest {
|
|
303
307
|
start: number;
|
|
304
308
|
end: number;
|
|
@@ -476,6 +480,12 @@ export interface NftTransactionResponse extends SWTransactionResponse {
|
|
|
476
480
|
}
|
|
477
481
|
export declare type HandleBasicTx = (data: TransactionResponse) => void;
|
|
478
482
|
export declare type TxErrorCode = TransferTxErrorType | TransactionErrorType;
|
|
483
|
+
export declare enum BalanceErrorType {
|
|
484
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
485
|
+
TOKEN_ERROR = "TOKEN_ERROR",
|
|
486
|
+
TIMEOUT = "TIMEOUT",
|
|
487
|
+
GET_BALANCE_ERROR = "GET_BALANCE_ERROR"
|
|
488
|
+
}
|
|
479
489
|
export declare type TransactionWarningType = BasicTxWarningCode;
|
|
480
490
|
export declare enum ProviderErrorType {
|
|
481
491
|
CHAIN_DISCONNECTED = "CHAIN_DISCONNECTED",
|
|
@@ -1332,6 +1342,23 @@ export interface ActiveCronAndSubscriptionMap {
|
|
|
1332
1342
|
subscription: Record<SubscriptionServiceType, boolean>;
|
|
1333
1343
|
cron: Record<CronServiceType, boolean>;
|
|
1334
1344
|
}
|
|
1345
|
+
export declare enum NotificationType {
|
|
1346
|
+
INFO = "info",
|
|
1347
|
+
SUCCESS = "success",
|
|
1348
|
+
WARNING = "warning",
|
|
1349
|
+
ERROR = "error"
|
|
1350
|
+
}
|
|
1351
|
+
export interface Notification {
|
|
1352
|
+
id: number;
|
|
1353
|
+
type: NotificationType;
|
|
1354
|
+
title: string;
|
|
1355
|
+
message: string;
|
|
1356
|
+
notifyViaBrowser?: boolean;
|
|
1357
|
+
action?: {
|
|
1358
|
+
url?: string;
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
export declare type NotificationParams = Omit<Notification, 'id'>;
|
|
1335
1362
|
export interface KoniRequestSignatures {
|
|
1336
1363
|
'pri(staking.submitTuringCancelCompound)': [RequestTuringCancelStakeCompound, SWTransactionResponse];
|
|
1337
1364
|
'pri(staking.submitTuringCompound)': [RequestTuringStakeCompound, SWTransactionResponse];
|
|
@@ -1426,12 +1453,14 @@ export interface KoniRequestSignatures {
|
|
|
1426
1453
|
'pri(settings.saveAccountAllLogo)': [string, boolean, UiSettings];
|
|
1427
1454
|
'pri(settings.saveTheme)': [ThemeNames, boolean, UiSettings];
|
|
1428
1455
|
'pri(settings.saveBrowserConfirmationType)': [BrowserConfirmationType, boolean, UiSettings];
|
|
1456
|
+
'pri(settings.saveCamera)': [RequestCameraSettings, boolean];
|
|
1429
1457
|
'pri(transaction.history.getSubscription)': [null, TransactionHistoryItem[], TransactionHistoryItem[]];
|
|
1430
1458
|
'pri(transfer.checkReferenceCount)': [RequestTransferCheckReferenceCount, boolean];
|
|
1431
1459
|
'pri(transfer.checkSupporting)': [RequestTransferCheckSupporting, SupportTransferResponse];
|
|
1432
1460
|
'pri(transfer.getExistentialDeposit)': [RequestTransferExistentialDeposit, string];
|
|
1433
1461
|
'pri(subscription.cancel)': [string, boolean];
|
|
1434
|
-
'pri(freeBalance.
|
|
1462
|
+
'pri(freeBalance.get)': [RequestFreeBalance, AmountData];
|
|
1463
|
+
'pri(freeBalance.subscribe)': [RequestFreeBalance, AmountData, AmountData];
|
|
1435
1464
|
'pri(accounts.checkTransfer)': [RequestCheckTransfer, ValidateTransactionResponse];
|
|
1436
1465
|
'pri(accounts.transfer)': [RequestTransfer, SWTransactionResponse];
|
|
1437
1466
|
'pri(accounts.checkCrossChainTransfer)': [RequestCheckCrossChainTransfer, ValidateTransactionResponse];
|
|
@@ -1466,6 +1495,7 @@ export interface KoniRequestSignatures {
|
|
|
1466
1495
|
'pri(derivation.createV3)': [RequestDeriveCreateV3, boolean];
|
|
1467
1496
|
'pri(transactions.getOne)': [RequestGetTransaction, SWTransactionResult];
|
|
1468
1497
|
'pri(transactions.subscribe)': [null, Record<string, SWTransactionResult>, Record<string, SWTransactionResult>];
|
|
1498
|
+
'pri(notifications.subscribe)': [null, Notification[], Notification[]];
|
|
1469
1499
|
'mobile(ping)': [null, string];
|
|
1470
1500
|
'mobile(cronAndSubscription.init)': [RequestInitCronAndSubscription, ActiveCronAndSubscriptionMap];
|
|
1471
1501
|
'mobile(cronAndSubscription.activeService.subscribe)': [null, ActiveCronAndSubscriptionMap, ActiveCronAndSubscriptionMap];
|
package/background/KoniTypes.js
CHANGED
|
@@ -122,6 +122,13 @@ export let BasicTxWarningCode;
|
|
|
122
122
|
(function (BasicTxWarningCode) {
|
|
123
123
|
BasicTxWarningCode["NOT_ENOUGH_EXISTENTIAL_DEPOSIT"] = "notEnoughExistentialDeposit";
|
|
124
124
|
})(BasicTxWarningCode || (BasicTxWarningCode = {}));
|
|
125
|
+
export let BalanceErrorType;
|
|
126
|
+
(function (BalanceErrorType) {
|
|
127
|
+
BalanceErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
128
|
+
BalanceErrorType["TOKEN_ERROR"] = "TOKEN_ERROR";
|
|
129
|
+
BalanceErrorType["TIMEOUT"] = "TIMEOUT";
|
|
130
|
+
BalanceErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
131
|
+
})(BalanceErrorType || (BalanceErrorType = {}));
|
|
125
132
|
export let ProviderErrorType;
|
|
126
133
|
|
|
127
134
|
// Manage account
|
|
@@ -205,4 +212,11 @@ export let ChainEditStandard;
|
|
|
205
212
|
ChainEditStandard["SUBSTRATE"] = "SUBSTRATE";
|
|
206
213
|
ChainEditStandard["UNKNOWN"] = "UNKNOWN";
|
|
207
214
|
ChainEditStandard["MIXED"] = "MIXED";
|
|
208
|
-
})(ChainEditStandard || (ChainEditStandard = {}));
|
|
215
|
+
})(ChainEditStandard || (ChainEditStandard = {}));
|
|
216
|
+
export let NotificationType;
|
|
217
|
+
(function (NotificationType) {
|
|
218
|
+
NotificationType["INFO"] = "info";
|
|
219
|
+
NotificationType["SUCCESS"] = "success";
|
|
220
|
+
NotificationType["WARNING"] = "warning";
|
|
221
|
+
NotificationType["ERROR"] = "error";
|
|
222
|
+
})(NotificationType || (NotificationType = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SWError } from '@subwallet/extension-base/background/errors/SWError';
|
|
2
|
+
import { BalanceErrorType } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
+
export declare class BalanceError extends SWError {
|
|
4
|
+
errorType: BalanceErrorType;
|
|
5
|
+
constructor(errorType: BalanceErrorType, errMessage?: string, data?: unknown);
|
|
6
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { SWError } from '@subwallet/extension-base/background/errors/SWError';
|
|
5
|
+
import { BalanceErrorType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
|
+
|
|
7
|
+
// Todo: finish this map in the future
|
|
8
|
+
const defaultErrorMap = {
|
|
9
|
+
[BalanceErrorType.NETWORK_ERROR]: {
|
|
10
|
+
message: 'Chain is inactive or disconnected',
|
|
11
|
+
code: undefined
|
|
12
|
+
},
|
|
13
|
+
[BalanceErrorType.TOKEN_ERROR]: {
|
|
14
|
+
message: 'Token is not supported',
|
|
15
|
+
code: undefined
|
|
16
|
+
},
|
|
17
|
+
[BalanceErrorType.TIMEOUT]: {
|
|
18
|
+
message: 'Get balance timeout',
|
|
19
|
+
code: undefined
|
|
20
|
+
},
|
|
21
|
+
[BalanceErrorType.GET_BALANCE_ERROR]: {
|
|
22
|
+
message: 'Get balance error',
|
|
23
|
+
code: undefined
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export class BalanceError extends SWError {
|
|
27
|
+
constructor(errorType, errMessage, data) {
|
|
28
|
+
const defaultErr = defaultErrorMap[errorType];
|
|
29
|
+
const message = errMessage || (defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.message) || errorType;
|
|
30
|
+
super(errorType, message, defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.code, data);
|
|
31
|
+
this.errorType = errorType;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -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.RMRK_VER = exports.ProviderErrorType = 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.AccountExternalErrorCode = exports.APIItemState = void 0;
|
|
6
|
+
exports.UnstakingStatus = exports.TransferTxErrorType = exports.TransactionDirection = exports.ThemeNames = exports.StakingType = exports.StakingTxErrorType = 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;
|
|
7
7
|
// Copyright 2019-2022 @polkadot/extension-koni authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
/// Request Auth
|
|
@@ -130,6 +130,14 @@ exports.BasicTxWarningCode = BasicTxWarningCode;
|
|
|
130
130
|
(function (BasicTxWarningCode) {
|
|
131
131
|
BasicTxWarningCode["NOT_ENOUGH_EXISTENTIAL_DEPOSIT"] = "notEnoughExistentialDeposit";
|
|
132
132
|
})(BasicTxWarningCode || (exports.BasicTxWarningCode = BasicTxWarningCode = {}));
|
|
133
|
+
let BalanceErrorType;
|
|
134
|
+
exports.BalanceErrorType = BalanceErrorType;
|
|
135
|
+
(function (BalanceErrorType) {
|
|
136
|
+
BalanceErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
137
|
+
BalanceErrorType["TOKEN_ERROR"] = "TOKEN_ERROR";
|
|
138
|
+
BalanceErrorType["TIMEOUT"] = "TIMEOUT";
|
|
139
|
+
BalanceErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
140
|
+
})(BalanceErrorType || (exports.BalanceErrorType = BalanceErrorType = {}));
|
|
133
141
|
let ProviderErrorType; // Manage account
|
|
134
142
|
// Export private key
|
|
135
143
|
exports.ProviderErrorType = ProviderErrorType;
|
|
@@ -210,4 +218,12 @@ exports.ChainEditStandard = ChainEditStandard;
|
|
|
210
218
|
ChainEditStandard["SUBSTRATE"] = "SUBSTRATE";
|
|
211
219
|
ChainEditStandard["UNKNOWN"] = "UNKNOWN";
|
|
212
220
|
ChainEditStandard["MIXED"] = "MIXED";
|
|
213
|
-
})(ChainEditStandard || (exports.ChainEditStandard = ChainEditStandard = {}));
|
|
221
|
+
})(ChainEditStandard || (exports.ChainEditStandard = ChainEditStandard = {}));
|
|
222
|
+
let NotificationType;
|
|
223
|
+
exports.NotificationType = NotificationType;
|
|
224
|
+
(function (NotificationType) {
|
|
225
|
+
NotificationType["INFO"] = "info";
|
|
226
|
+
NotificationType["SUCCESS"] = "success";
|
|
227
|
+
NotificationType["WARNING"] = "warning";
|
|
228
|
+
NotificationType["ERROR"] = "error";
|
|
229
|
+
})(NotificationType || (exports.NotificationType = NotificationType = {}));
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BalanceError = void 0;
|
|
7
|
+
var _SWError = require("@subwallet/extension-base/background/errors/SWError");
|
|
8
|
+
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
// Todo: finish this map in the future
|
|
13
|
+
const defaultErrorMap = {
|
|
14
|
+
[_KoniTypes.BalanceErrorType.NETWORK_ERROR]: {
|
|
15
|
+
message: 'Chain is inactive or disconnected',
|
|
16
|
+
code: undefined
|
|
17
|
+
},
|
|
18
|
+
[_KoniTypes.BalanceErrorType.TOKEN_ERROR]: {
|
|
19
|
+
message: 'Token is not supported',
|
|
20
|
+
code: undefined
|
|
21
|
+
},
|
|
22
|
+
[_KoniTypes.BalanceErrorType.TIMEOUT]: {
|
|
23
|
+
message: 'Get balance timeout',
|
|
24
|
+
code: undefined
|
|
25
|
+
},
|
|
26
|
+
[_KoniTypes.BalanceErrorType.GET_BALANCE_ERROR]: {
|
|
27
|
+
message: 'Get balance error',
|
|
28
|
+
code: undefined
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
class BalanceError extends _SWError.SWError {
|
|
32
|
+
constructor(errorType, errMessage, data) {
|
|
33
|
+
const defaultErr = defaultErrorMap[errorType];
|
|
34
|
+
const message = errMessage || (defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.message) || errorType;
|
|
35
|
+
super(errorType, message, defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.code, data);
|
|
36
|
+
this.errorType = errorType;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.BalanceError = BalanceError;
|
|
@@ -7,6 +7,7 @@ exports.getFreeBalance = getFreeBalance;
|
|
|
7
7
|
exports.subscribeBalance = subscribeBalance;
|
|
8
8
|
exports.subscribeEVMBalance = subscribeEVMBalance;
|
|
9
9
|
exports.subscribeFreeBalance = subscribeFreeBalance;
|
|
10
|
+
exports.subscribeSubstrateBalance = subscribeSubstrateBalance;
|
|
10
11
|
var _types = require("@subwallet/chain-list/types");
|
|
11
12
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
12
13
|
var _constants = require("@subwallet/extension-base/constants");
|