@subwallet/extension-base 1.3.69-0 → 1.3.71-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 +11 -0
- package/background/KoniTypes.js +68 -8
- package/cjs/background/KoniTypes.js +68 -8
- package/cjs/constants/blocked-actions.js +3 -0
- package/cjs/core/logic-validation/swap.js +0 -3
- package/cjs/core/substrate/system-pallet.js +0 -2
- package/cjs/koni/api/nft/wasm_nft/index.js +0 -1
- package/cjs/koni/api/staking/bonding/astar.js +0 -2
- package/cjs/koni/api/staking/bonding/paraChain.js +0 -3
- package/cjs/koni/api/staking/bonding/relayChain.js +2 -4
- package/cjs/koni/api/staking/bonding/utils.js +0 -4
- package/cjs/koni/background/cron.js +0 -1
- package/cjs/koni/background/handlers/Extension.js +216 -158
- package/cjs/koni/background/handlers/State.js +59 -54
- package/cjs/koni/background/handlers/Tabs.js +39 -34
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/index.js +7 -0
- package/cjs/page/substrate/PostMessageProvider.js +3 -0
- package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +2 -3
- package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
- package/cjs/services/balance-service/index.js +103 -7
- package/cjs/services/balance-service/transfer/bitcoin-transfer.js +0 -1
- package/cjs/services/balance-service/transfer/cardano-transfer.js +1 -2
- package/cjs/services/balance-service/transfer/smart-contract.js +0 -1
- package/cjs/services/balance-service/transfer/token.js +0 -2
- package/cjs/services/balance-service/transfer/ton-transfer.js +0 -1
- package/cjs/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- package/cjs/services/chain-service/constants.js +15 -4
- package/cjs/services/chain-service/handler/CardanoApi.js +3 -1
- package/cjs/services/chain-service/handler/SubstrateApi.js +0 -2
- package/cjs/services/chain-service/handler/light-client/index.js +1 -2
- package/cjs/services/chain-service/health-check/index.js +0 -1
- package/cjs/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
- package/cjs/services/chain-service/index.js +18 -26
- package/cjs/services/chain-service/utils/index.js +34 -30
- package/cjs/services/earning-service/handlers/base.js +32 -0
- package/cjs/services/earning-service/handlers/lending/base.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -1
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +43 -2
- package/cjs/services/earning-service/handlers/native-staking/energy.js +0 -1
- package/cjs/services/earning-service/handlers/native-staking/mythos.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
- package/cjs/services/earning-service/handlers/special.js +7 -0
- package/cjs/services/event-service/index.js +1 -0
- package/cjs/services/history-service/subsquid-multi-chain-history.js +0 -1
- package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
- package/cjs/services/keyring-service/context/handlers/Migration.js +11 -9
- package/cjs/services/keyring-service/context/handlers/Mnemonic.js +18 -13
- package/cjs/services/keyring-service/context/state.js +21 -3
- package/cjs/services/keyring-service/utils.js +12 -2
- package/cjs/services/migration-service/index.js +1 -2
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
- package/cjs/services/nft-service/index.js +5 -0
- package/cjs/services/open-gov/handler.js +561 -0
- package/cjs/services/open-gov/index.js +273 -0
- package/cjs/services/open-gov/interface.js +31 -0
- package/cjs/services/open-gov/utils.js +66 -0
- package/cjs/services/request-service/handler/BitcoinRequestHandler.js +1 -2
- package/cjs/services/request-service/handler/CardanoRequestHandler.js +0 -1
- package/cjs/services/request-service/handler/EvmRequestHandler.js +0 -1
- package/cjs/services/request-service/handler/TonRequestHandler.js +0 -1
- package/cjs/services/request-service/helper/index.js +1 -2
- package/cjs/services/storage-service/DatabaseService.js +19 -3
- package/cjs/services/storage-service/databases/index.js +5 -0
- package/cjs/services/storage-service/db-stores/GovLockedInfoStore.js +35 -0
- package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -1
- package/cjs/services/swap-service/handler/asset-hub/router.js +0 -1
- package/cjs/services/swap-service/handler/chainflip-handler.js +1 -4
- package/cjs/services/swap-service/handler/hydradx-handler.js +0 -1
- package/cjs/services/swap-service/handler/kyber-handler.js +0 -1
- package/cjs/services/swap-service/handler/optimex-handler.js +1 -2
- package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -3
- package/cjs/services/swap-service/handler/uniswap-handler.js +0 -3
- package/cjs/services/transaction-service/event-parser/index.js +6 -6
- package/cjs/services/transaction-service/helpers/index.js +6 -0
- package/cjs/services/transaction-service/index.js +71 -28
- package/cjs/services/wallet-connect-service/index.js +21 -18
- package/cjs/services/wallet-connect-service/types.js +1 -1
- package/cjs/types/account/info/keyring.js +9 -1
- package/cjs/types/balance/index.js +5 -1
- package/cjs/types/swap/index.js +2 -1
- package/cjs/types/transaction/process.js +2 -0
- package/cjs/types/yield/actions/join/step.js +17 -1
- package/cjs/utils/account/common.js +0 -26
- package/cjs/utils/account/derive/info/solo.js +7 -4
- package/cjs/utils/account/derive/validate.js +1 -1
- package/cjs/utils/account/transform.js +10 -5
- package/cjs/utils/auth.js +1 -1
- package/cjs/utils/bitcoin/utxo-management.js +0 -1
- package/cjs/utils/environment.js +2 -1
- package/cjs/utils/fee/transfer.js +1 -2
- package/cjs/utils/index.js +1 -2
- package/constants/blocked-actions.js +3 -0
- package/core/logic-validation/swap.js +0 -3
- package/core/substrate/system-pallet.js +0 -2
- package/koni/api/nft/wasm_nft/index.js +0 -1
- package/koni/api/staking/bonding/astar.js +0 -2
- package/koni/api/staking/bonding/paraChain.js +0 -3
- package/koni/api/staking/bonding/relayChain.js +2 -4
- package/koni/api/staking/bonding/utils.js +0 -4
- package/koni/background/cron.js +0 -1
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +70 -11
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +46 -40
- package/koni/background/handlers/Tabs.js +9 -3
- package/package.json +44 -20
- package/packageInfo.js +1 -1
- package/page/substrate/PostMessageProvider.js +3 -0
- package/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
- package/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
- package/services/balance-service/helpers/subscribe/substrate/index.js +0 -1
- package/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
- package/services/balance-service/index.d.ts +8 -0
- package/services/balance-service/index.js +105 -9
- package/services/balance-service/transfer/bitcoin-transfer.js +0 -1
- package/services/balance-service/transfer/smart-contract.js +0 -1
- package/services/balance-service/transfer/token.js +0 -2
- package/services/balance-service/transfer/ton-transfer.js +0 -1
- package/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- package/services/chain-service/constants.d.ts +8 -0
- package/services/chain-service/constants.js +12 -2
- package/services/chain-service/handler/CardanoApi.js +3 -1
- package/services/chain-service/handler/SubstrateApi.js +0 -2
- package/services/chain-service/health-check/index.js +0 -1
- package/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
- package/services/chain-service/index.d.ts +0 -1
- package/services/chain-service/index.js +15 -23
- package/services/chain-service/utils/index.js +35 -31
- package/services/earning-service/handlers/base.js +32 -0
- package/services/earning-service/handlers/lending/base.js +0 -2
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -1
- package/services/earning-service/handlers/liquid-staking/base.js +0 -2
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
- package/services/earning-service/handlers/native-staking/astar.js +0 -2
- package/services/earning-service/handlers/native-staking/dtao.js +43 -0
- package/services/earning-service/handlers/native-staking/energy.js +0 -1
- package/services/earning-service/handlers/native-staking/mythos.js +0 -2
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -2
- package/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
- package/services/earning-service/handlers/special.js +7 -0
- 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/history-service/subsquid-multi-chain-history.js +0 -1
- package/services/keyring-service/context/handlers/Derive.js +2 -2
- package/services/keyring-service/context/handlers/Migration.js +3 -1
- package/services/keyring-service/context/handlers/Mnemonic.d.ts +1 -1
- package/services/keyring-service/context/handlers/Mnemonic.js +16 -10
- package/services/keyring-service/context/state.d.ts +3 -0
- package/services/keyring-service/context/state.js +21 -3
- package/services/keyring-service/utils.d.ts +1 -0
- package/services/keyring-service/utils.js +9 -0
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
- package/services/nft-service/index.js +6 -0
- package/services/open-gov/handler.d.ts +27 -0
- package/services/open-gov/handler.js +545 -0
- package/services/open-gov/index.d.ts +45 -0
- package/services/open-gov/index.js +265 -0
- package/services/open-gov/interface.d.ts +141 -0
- package/services/open-gov/interface.js +24 -0
- package/services/open-gov/utils.d.ts +14 -0
- package/services/open-gov/utils.js +52 -0
- package/services/request-service/handler/CardanoRequestHandler.js +0 -1
- package/services/request-service/handler/EvmRequestHandler.js +0 -1
- package/services/request-service/handler/TonRequestHandler.js +0 -1
- package/services/setting-service/constants.js +0 -1
- package/services/storage-service/DatabaseService.d.ts +7 -0
- package/services/storage-service/DatabaseService.js +19 -3
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +6 -0
- package/services/storage-service/db-stores/GovLockedInfoStore.d.ts +10 -0
- package/services/storage-service/db-stores/GovLockedInfoStore.js +27 -0
- package/services/swap-service/handler/asset-hub/handler.js +0 -1
- package/services/swap-service/handler/asset-hub/router.js +0 -1
- package/services/swap-service/handler/chainflip-handler.js +0 -2
- package/services/swap-service/handler/hydradx-handler.js +0 -1
- package/services/swap-service/handler/kyber-handler.js +0 -1
- package/services/swap-service/handler/simpleswap-handler.js +0 -1
- package/services/swap-service/handler/uniswap-handler.js +0 -3
- package/services/transaction-service/event-parser/index.js +6 -6
- package/services/transaction-service/helpers/index.js +6 -0
- package/services/transaction-service/index.js +43 -0
- package/services/wallet-connect-service/index.js +21 -18
- package/services/wallet-connect-service/types.js +1 -1
- package/types/account/action/add/mnemonic.d.ts +3 -2
- package/types/account/info/keyring.js +9 -1
- package/types/balance/index.js +5 -1
- package/types/swap/index.js +2 -1
- package/types/transaction/process.js +3 -1
- package/types/yield/actions/join/step.js +17 -1
- package/utils/account/common.d.ts +0 -3
- package/utils/account/common.js +0 -24
- package/utils/account/derive/info/solo.js +8 -5
- package/utils/account/derive/validate.d.ts +2 -2
- package/utils/account/derive/validate.js +1 -1
- package/utils/account/transform.js +10 -5
- package/utils/auth.js +2 -2
- package/utils/bitcoin/utxo-management.js +0 -1
- package/utils/index.js +2 -5
|
@@ -34,6 +34,7 @@ var _mintCampaignService = _interopRequireDefault(require("@subwallet/extension-
|
|
|
34
34
|
var _mktCampaignService = _interopRequireDefault(require("@subwallet/extension-base/services/mkt-campaign-service"));
|
|
35
35
|
var _nftService = _interopRequireDefault(require("@subwallet/extension-base/services/nft-service"));
|
|
36
36
|
var _NotificationService = _interopRequireDefault(require("@subwallet/extension-base/services/notification-service/NotificationService"));
|
|
37
|
+
var _openGov = _interopRequireDefault(require("@subwallet/extension-base/services/open-gov"));
|
|
37
38
|
var _priceService = require("@subwallet/extension-base/services/price-service");
|
|
38
39
|
var _requestService = _interopRequireDefault(require("@subwallet/extension-base/services/request-service"));
|
|
39
40
|
var _PopupHandler = require("@subwallet/extension-base/services/request-service/handler/PopupHandler");
|
|
@@ -59,8 +60,7 @@ var _util = require("@polkadot/util");
|
|
|
59
60
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
60
61
|
var _cron = require("../cron");
|
|
61
62
|
var _subscription = require("../subscription");
|
|
62
|
-
function
|
|
63
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
63
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
64
64
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
65
65
|
// SPDX-License-Identifier: Apache-2.0
|
|
66
66
|
|
|
@@ -94,6 +94,9 @@ class KoniState {
|
|
|
94
94
|
data: {}
|
|
95
95
|
};
|
|
96
96
|
lazyMap = {};
|
|
97
|
+
|
|
98
|
+
// TODO: consider making chainService public (or getter) and call function directly
|
|
99
|
+
|
|
97
100
|
// Handle the general status of the extension
|
|
98
101
|
generalStatus = _types.ServiceStatus.INITIALIZING;
|
|
99
102
|
waitSleeping = null;
|
|
@@ -128,6 +131,7 @@ class KoniState {
|
|
|
128
131
|
this.swapService = new _swapService.SwapService(this);
|
|
129
132
|
this.inappNotificationService = new _inappNotificationService.InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
|
|
130
133
|
this.chainOnlineService = new _chainOnlineService.ChainOnlineService(this.chainService, this.settingService, this.eventService, this.dbService);
|
|
134
|
+
this.openGovService = new _openGov.default(this);
|
|
131
135
|
this.subscription = new _subscription.KoniSubscription(this, this.dbService);
|
|
132
136
|
this.cron = new _cron.KoniCron(this, this.subscription, this.dbService);
|
|
133
137
|
this.logger = (0, _util.logger)('State');
|
|
@@ -232,6 +236,7 @@ class KoniState {
|
|
|
232
236
|
await this.earningService.init();
|
|
233
237
|
await this.swapService.init();
|
|
234
238
|
await this.inappNotificationService.init();
|
|
239
|
+
await this.openGovService.init();
|
|
235
240
|
|
|
236
241
|
// this.onReady();
|
|
237
242
|
this.onAccountAdd();
|
|
@@ -758,7 +763,7 @@ class KoniState {
|
|
|
758
763
|
async enableChainWithPriorityAssets(chainSlug) {
|
|
759
764
|
let enableTokens = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
760
765
|
if (enableTokens) {
|
|
761
|
-
await this.
|
|
766
|
+
await this.balanceService.updatePriorityAssetsByChain(chainSlug, true);
|
|
762
767
|
}
|
|
763
768
|
return this.chainService.enableChain(chainSlug);
|
|
764
769
|
}
|
|
@@ -1361,10 +1366,10 @@ class KoniState {
|
|
|
1361
1366
|
const psbtGenerate = bitcoin.Psbt.fromHex(psbt, {
|
|
1362
1367
|
network: network_
|
|
1363
1368
|
});
|
|
1364
|
-
const isExistedInput = (inputs, address) => inputs.findIndex(
|
|
1369
|
+
const isExistedInput = (inputs, address) => inputs.findIndex(_ref0 => {
|
|
1365
1370
|
let {
|
|
1366
1371
|
address: address_
|
|
1367
|
-
} =
|
|
1372
|
+
} = _ref0;
|
|
1368
1373
|
return (0, _utils3.isSameAddress)(address, address_ || '');
|
|
1369
1374
|
});
|
|
1370
1375
|
let to = '';
|
|
@@ -1372,11 +1377,11 @@ class KoniState {
|
|
|
1372
1377
|
let value = new _bignumber.default(0);
|
|
1373
1378
|
const totalBalance = await this.balanceService.getTotalBalance(address, result.networkKey, tokenInfo.slug);
|
|
1374
1379
|
let inputAmount = new _bignumber.default(0);
|
|
1375
|
-
const psbtInputData = psbtGenerate.data.inputs.reduce((inputs,
|
|
1380
|
+
const psbtInputData = psbtGenerate.data.inputs.reduce((inputs, _ref1, inputIndex) => {
|
|
1376
1381
|
let {
|
|
1377
1382
|
nonWitnessUtxo,
|
|
1378
1383
|
witnessUtxo
|
|
1379
|
-
} =
|
|
1384
|
+
} = _ref1;
|
|
1380
1385
|
let inputData = null;
|
|
1381
1386
|
if (witnessUtxo) {
|
|
1382
1387
|
inputData = {
|
|
@@ -1434,11 +1439,11 @@ class KoniState {
|
|
|
1434
1439
|
txInput: psbtInputData,
|
|
1435
1440
|
txOutput: psbtOutputData
|
|
1436
1441
|
};
|
|
1437
|
-
return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSignPsbtRequest', payloadAfterValidated, {}).then(
|
|
1442
|
+
return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSignPsbtRequest', payloadAfterValidated, {}).then(_ref10 => {
|
|
1438
1443
|
let {
|
|
1439
1444
|
isApproved,
|
|
1440
1445
|
payload
|
|
1441
|
-
} =
|
|
1446
|
+
} = _ref10;
|
|
1442
1447
|
if (isApproved) {
|
|
1443
1448
|
if (payload) {
|
|
1444
1449
|
return payload;
|
|
@@ -1470,11 +1475,11 @@ class KoniState {
|
|
|
1470
1475
|
};
|
|
1471
1476
|
|
|
1472
1477
|
// Custom handle this instead of general handler transaction
|
|
1473
|
-
return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSendTransactionRequestAfterConfirmation', requestPayload, {}).then(
|
|
1478
|
+
return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSendTransactionRequestAfterConfirmation', requestPayload, {}).then(_ref11 => {
|
|
1474
1479
|
let {
|
|
1475
1480
|
isApproved,
|
|
1476
1481
|
payload
|
|
1477
|
-
} =
|
|
1482
|
+
} = _ref11;
|
|
1478
1483
|
if (isApproved) {
|
|
1479
1484
|
if (payload) {
|
|
1480
1485
|
return payload;
|
|
@@ -1580,11 +1585,11 @@ class KoniState {
|
|
|
1580
1585
|
const subscription = this.keyringService.context.observable.currentAccount.subscribe(handleRemind);
|
|
1581
1586
|
}
|
|
1582
1587
|
}
|
|
1583
|
-
async setStorageFromWS(
|
|
1588
|
+
async setStorageFromWS(_ref12) {
|
|
1584
1589
|
let {
|
|
1585
1590
|
key,
|
|
1586
1591
|
value
|
|
1587
|
-
} =
|
|
1592
|
+
} = _ref12;
|
|
1588
1593
|
try {
|
|
1589
1594
|
const jsonData = JSON.stringify(value);
|
|
1590
1595
|
await _storage.SWStorage.instance.setItem(key, jsonData);
|
|
@@ -1687,7 +1692,7 @@ class KoniState {
|
|
|
1687
1692
|
this.campaignService.stop();
|
|
1688
1693
|
await Promise.all([this.cron.stop(), this.subscription.stop()]);
|
|
1689
1694
|
await this.pauseAllNetworks(undefined, 'IDLE mode');
|
|
1690
|
-
await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop()]);
|
|
1695
|
+
await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop(), this.openGovService.stop()]);
|
|
1691
1696
|
|
|
1692
1697
|
// Complete sleeping
|
|
1693
1698
|
sleeping.resolve();
|
|
@@ -1743,7 +1748,7 @@ class KoniState {
|
|
|
1743
1748
|
this.generalStatus = _types.ServiceStatus.STARTING_FULL;
|
|
1744
1749
|
const startingFull = (0, _promise.createPromiseHandler)();
|
|
1745
1750
|
this.waitStartingFull = startingFull.promise;
|
|
1746
|
-
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()]);
|
|
1751
|
+
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()]);
|
|
1747
1752
|
this.eventService.emit('general.start_full', true);
|
|
1748
1753
|
this.waitStartingFull = null;
|
|
1749
1754
|
this.generalStatus = _types.ServiceStatus.STARTED_FULL;
|
|
@@ -1875,7 +1880,7 @@ class KoniState {
|
|
|
1875
1880
|
});
|
|
1876
1881
|
}
|
|
1877
1882
|
async enableMantaPay(updateStore, address, password, seedPhrase) {
|
|
1878
|
-
var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$
|
|
1883
|
+
var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService1, _this$chainService1$m, _this$chainService1$m2;
|
|
1879
1884
|
if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
|
|
1880
1885
|
return;
|
|
1881
1886
|
}
|
|
@@ -1895,7 +1900,7 @@ class KoniState {
|
|
|
1895
1900
|
data: encryptedData
|
|
1896
1901
|
}));
|
|
1897
1902
|
} else {
|
|
1898
|
-
var _this$chainService9, _this$chainService9$m, _this$
|
|
1903
|
+
var _this$chainService9, _this$chainService9$m, _this$chainService0, _this$chainService0$m, _this$chainService0$m2;
|
|
1899
1904
|
const authContext = await ((_this$chainService9 = this.chainService) === null || _this$chainService9 === void 0 ? void 0 : (_this$chainService9$m = _this$chainService9.mantaPay) === null || _this$chainService9$m === void 0 ? void 0 : _this$chainService9$m.getMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
1900
1905
|
|
|
1901
1906
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
@@ -1903,18 +1908,18 @@ class KoniState {
|
|
|
1903
1908
|
|
|
1904
1909
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
|
|
1905
1910
|
const proofAuthKey = new Uint8Array(Object.values(decryptedData.proof_authorization_key));
|
|
1906
|
-
await ((_this$
|
|
1911
|
+
await ((_this$chainService0 = this.chainService) === null || _this$chainService0 === void 0 ? void 0 : (_this$chainService0$m = _this$chainService0.mantaPay) === null || _this$chainService0$m === void 0 ? void 0 : (_this$chainService0$m2 = _this$chainService0$m.privateWallet) === null || _this$chainService0$m2 === void 0 ? void 0 : _this$chainService0$m2.loadAuthorizationContext({
|
|
1907
1912
|
proof_authorization_key: proofAuthKey
|
|
1908
1913
|
}));
|
|
1909
1914
|
}
|
|
1910
|
-
const zkAddress = await ((_this$
|
|
1915
|
+
const zkAddress = await ((_this$chainService1 = this.chainService) === null || _this$chainService1 === void 0 ? void 0 : (_this$chainService1$m = _this$chainService1.mantaPay) === null || _this$chainService1$m === void 0 ? void 0 : (_this$chainService1$m2 = _this$chainService1$m.privateWallet) === null || _this$chainService1$m2 === void 0 ? void 0 : _this$chainService1$m2.getZkAddress());
|
|
1911
1916
|
if (updateStore) {
|
|
1912
|
-
var _this$
|
|
1913
|
-
await ((_this$
|
|
1917
|
+
var _this$chainService10, _this$chainService10$, _this$chainService11, _this$chainService11$, _this$chainService11$2, _this$chainService11$3;
|
|
1918
|
+
await ((_this$chainService10 = this.chainService) === null || _this$chainService10 === void 0 ? void 0 : (_this$chainService10$ = _this$chainService10.mantaPay) === null || _this$chainService10$ === void 0 ? void 0 : _this$chainService10$.saveMantaPayConfig({
|
|
1914
1919
|
address,
|
|
1915
1920
|
zkAddress: zkAddress,
|
|
1916
1921
|
enabled: true,
|
|
1917
|
-
chain: (_this$
|
|
1922
|
+
chain: (_this$chainService11 = this.chainService) === null || _this$chainService11 === void 0 ? void 0 : (_this$chainService11$ = _this$chainService11.mantaPay) === null || _this$chainService11$ === void 0 ? void 0 : (_this$chainService11$2 = _this$chainService11$.privateWallet) === null || _this$chainService11$2 === void 0 ? void 0 : (_this$chainService11$3 = _this$chainService11$2.network) === null || _this$chainService11$3 === void 0 ? void 0 : _this$chainService11$3.toLowerCase(),
|
|
1918
1923
|
isInitialSync: false
|
|
1919
1924
|
}));
|
|
1920
1925
|
}
|
|
@@ -1922,48 +1927,48 @@ class KoniState {
|
|
|
1922
1927
|
return zkAddress;
|
|
1923
1928
|
}
|
|
1924
1929
|
async disableMantaPay(address) {
|
|
1925
|
-
var _this$
|
|
1926
|
-
const config = await ((_this$
|
|
1930
|
+
var _this$chainService12, _this$chainService12$, _this$chainService13, _this$chainService13$, _this$chainService13$2, _this$chainService14, _this$chainService14$, _this$chainService14$2, _this$chainService15, _this$chainService15$, _this$chainService16, _this$chainService16$;
|
|
1931
|
+
const config = await ((_this$chainService12 = this.chainService) === null || _this$chainService12 === void 0 ? void 0 : (_this$chainService12$ = _this$chainService12.mantaPay) === null || _this$chainService12$ === void 0 ? void 0 : _this$chainService12$.getMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
1927
1932
|
if (!config) {
|
|
1928
1933
|
return false;
|
|
1929
1934
|
}
|
|
1930
|
-
await ((_this$
|
|
1931
|
-
await ((_this$
|
|
1935
|
+
await ((_this$chainService13 = this.chainService) === null || _this$chainService13 === void 0 ? void 0 : (_this$chainService13$ = _this$chainService13.mantaPay) === null || _this$chainService13$ === void 0 ? void 0 : (_this$chainService13$2 = _this$chainService13$.privateWallet) === null || _this$chainService13$2 === void 0 ? void 0 : _this$chainService13$2.dropAuthorizationContext());
|
|
1936
|
+
await ((_this$chainService14 = this.chainService) === null || _this$chainService14 === void 0 ? void 0 : (_this$chainService14$ = _this$chainService14.mantaPay) === null || _this$chainService14$ === void 0 ? void 0 : (_this$chainService14$2 = _this$chainService14$.privateWallet) === null || _this$chainService14$2 === void 0 ? void 0 : _this$chainService14$2.dropUserSeedPhrase());
|
|
1932
1937
|
// await this.chainService?.mantaPay?.privateWallet?.resetState();
|
|
1933
|
-
await ((_this$
|
|
1934
|
-
await ((_this$
|
|
1938
|
+
await ((_this$chainService15 = this.chainService) === null || _this$chainService15 === void 0 ? void 0 : (_this$chainService15$ = _this$chainService15.mantaPay) === null || _this$chainService15$ === void 0 ? void 0 : _this$chainService15$.deleteMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
1939
|
+
await ((_this$chainService16 = this.chainService) === null || _this$chainService16 === void 0 ? void 0 : (_this$chainService16$ = _this$chainService16.mantaPay) === null || _this$chainService16$ === void 0 ? void 0 : _this$chainService16$.deleteMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
1935
1940
|
this.chainService.setMantaZkAssetSettings(false);
|
|
1936
1941
|
this.isMantaPayEnabled = false;
|
|
1937
1942
|
return true;
|
|
1938
1943
|
}
|
|
1939
1944
|
async initialSyncMantaPay(address) {
|
|
1940
|
-
var _this$
|
|
1945
|
+
var _this$chainService17, _this$chainService17$, _this$chainService18, _this$chainService18$, _this$chainService18$2, _this$chainService18$3, _this$chainService19, _this$chainService19$, _this$chainService19$2, _this$chainService20, _this$chainService20$;
|
|
1941
1946
|
if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
|
|
1942
1947
|
return;
|
|
1943
1948
|
}
|
|
1944
|
-
(_this$
|
|
1945
|
-
await ((_this$
|
|
1946
|
-
const syncResult = await ((_this$
|
|
1947
|
-
await ((_this$
|
|
1949
|
+
(_this$chainService17 = this.chainService) === null || _this$chainService17 === void 0 ? void 0 : (_this$chainService17$ = _this$chainService17.mantaPay) === null || _this$chainService17$ === void 0 ? void 0 : _this$chainService17$.setCurrentAddress(address);
|
|
1950
|
+
await ((_this$chainService18 = this.chainService) === null || _this$chainService18 === void 0 ? void 0 : (_this$chainService18$ = _this$chainService18.mantaPay) === null || _this$chainService18$ === void 0 ? void 0 : (_this$chainService18$2 = _this$chainService18$.privateWallet) === null || _this$chainService18$2 === void 0 ? void 0 : (_this$chainService18$3 = _this$chainService18$2.baseWallet) === null || _this$chainService18$3 === void 0 ? void 0 : _this$chainService18$3.isApiReady());
|
|
1951
|
+
const syncResult = await ((_this$chainService19 = this.chainService) === null || _this$chainService19 === void 0 ? void 0 : (_this$chainService19$ = _this$chainService19.mantaPay) === null || _this$chainService19$ === void 0 ? void 0 : (_this$chainService19$2 = _this$chainService19$.privateWallet) === null || _this$chainService19$2 === void 0 ? void 0 : _this$chainService19$2.initialWalletSync());
|
|
1952
|
+
await ((_this$chainService20 = this.chainService) === null || _this$chainService20 === void 0 ? void 0 : (_this$chainService20$ = _this$chainService20.mantaPay) === null || _this$chainService20$ === void 0 ? void 0 : _this$chainService20$.updateMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN, {
|
|
1948
1953
|
isInitialSync: true
|
|
1949
1954
|
}));
|
|
1950
1955
|
this.eventService.emit('mantaPay.initSync', undefined);
|
|
1951
1956
|
return syncResult;
|
|
1952
1957
|
}
|
|
1953
1958
|
getMantaZkBalance() {
|
|
1954
|
-
var _this$
|
|
1955
|
-
if (!this.chainService || !((_this$
|
|
1959
|
+
var _this$chainService21, _this$chainService22, _this$chainService22$, _this$chainService22$2, _this$chainService23, _this$chainService23$, _this$chainService24, _this$chainService24$, _this$chainService24$2;
|
|
1960
|
+
if (!this.chainService || !((_this$chainService21 = this.chainService) !== null && _this$chainService21 !== void 0 && _this$chainService21.mantaPay)) {
|
|
1956
1961
|
return;
|
|
1957
1962
|
}
|
|
1958
|
-
if (!((_this$
|
|
1963
|
+
if (!((_this$chainService22 = this.chainService) !== null && _this$chainService22 !== void 0 && (_this$chainService22$ = _this$chainService22.mantaPay) !== null && _this$chainService22$ !== void 0 && (_this$chainService22$2 = _this$chainService22$.privateWallet) !== null && _this$chainService22$2 !== void 0 && _this$chainService22$2.initialSyncIsFinished)) {
|
|
1959
1964
|
return;
|
|
1960
1965
|
}
|
|
1961
|
-
const chain = (_this$
|
|
1966
|
+
const chain = (_this$chainService23 = this.chainService) === null || _this$chainService23 === void 0 ? void 0 : (_this$chainService23$ = _this$chainService23.mantaPay.privateWallet) === null || _this$chainService23$ === void 0 ? void 0 : _this$chainService23$.network;
|
|
1962
1967
|
if (!chain) {
|
|
1963
1968
|
return;
|
|
1964
1969
|
}
|
|
1965
1970
|
const assetMap = this.chainService.getMantaZkAssets(chain === null || chain === void 0 ? void 0 : chain.toLowerCase());
|
|
1966
|
-
(_this$
|
|
1971
|
+
(_this$chainService24 = this.chainService) === null || _this$chainService24 === void 0 ? void 0 : (_this$chainService24$ = _this$chainService24.mantaPay) === null || _this$chainService24$ === void 0 ? void 0 : (_this$chainService24$2 = _this$chainService24$.privateWallet) === null || _this$chainService24$2 === void 0 ? void 0 : _this$chainService24$2.getMultiZkBalance(Object.values(assetMap).map(tokenInfo => new _bn.default((0, _utils._getTokenOnChainAssetId)(tokenInfo)))).then(zkBalances => {
|
|
1967
1972
|
const assetList = Object.values(assetMap);
|
|
1968
1973
|
for (let i = 0; i < assetList.length; i++) {
|
|
1969
1974
|
var _zkBalances$i;
|
|
@@ -1980,9 +1985,9 @@ class KoniState {
|
|
|
1980
1985
|
}).catch(console.warn);
|
|
1981
1986
|
}
|
|
1982
1987
|
subscribeMantaPayBalance() {
|
|
1983
|
-
var _this$
|
|
1988
|
+
var _this$chainService25, _this$chainService25$;
|
|
1984
1989
|
let interval;
|
|
1985
|
-
(_this$
|
|
1990
|
+
(_this$chainService25 = this.chainService) === null || _this$chainService25 === void 0 ? void 0 : (_this$chainService25$ = _this$chainService25.mantaPay) === null || _this$chainService25$ === void 0 ? void 0 : _this$chainService25$.getMantaPayConfig(this.keyringService.context.currentAccount.proxyId, _constants2._DEFAULT_MANTA_ZK_CHAIN).then(config => {
|
|
1986
1991
|
if (config && config.enabled && config.isInitialSync) {
|
|
1987
1992
|
this.getMantaZkBalance();
|
|
1988
1993
|
interval = setInterval(this.getMantaZkBalance, _constants.MANTA_PAY_BALANCE_INTERVAL);
|
|
@@ -1993,23 +1998,23 @@ class KoniState {
|
|
|
1993
1998
|
};
|
|
1994
1999
|
}
|
|
1995
2000
|
async syncMantaPay() {
|
|
1996
|
-
var _this$
|
|
1997
|
-
const config = await ((_this$
|
|
2001
|
+
var _this$chainService26, _this$chainService26$, _this$chainService27, _this$chainService27$, _this$chainService27$2;
|
|
2002
|
+
const config = await ((_this$chainService26 = this.chainService) === null || _this$chainService26 === void 0 ? void 0 : (_this$chainService26$ = _this$chainService26.mantaPay) === null || _this$chainService26$ === void 0 ? void 0 : _this$chainService26$.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
1998
2003
|
if (!config.isInitialSync) {
|
|
1999
2004
|
return;
|
|
2000
2005
|
}
|
|
2001
|
-
if ((_this$
|
|
2002
|
-
var _this$
|
|
2003
|
-
await ((_this$
|
|
2006
|
+
if ((_this$chainService27 = this.chainService) !== null && _this$chainService27 !== void 0 && (_this$chainService27$ = _this$chainService27.mantaPay) !== null && _this$chainService27$ !== void 0 && (_this$chainService27$2 = _this$chainService27$.privateWallet) !== null && _this$chainService27$2 !== void 0 && _this$chainService27$2.initialSyncIsFinished) {
|
|
2007
|
+
var _this$chainService28, _this$chainService28$, _this$chainService28$2;
|
|
2008
|
+
await ((_this$chainService28 = this.chainService) === null || _this$chainService28 === void 0 ? void 0 : (_this$chainService28$ = _this$chainService28.mantaPay) === null || _this$chainService28$ === void 0 ? void 0 : (_this$chainService28$2 = _this$chainService28$.privateWallet) === null || _this$chainService28$2 === void 0 ? void 0 : _this$chainService28$2.walletSync());
|
|
2004
2009
|
} else {
|
|
2005
|
-
var _this$
|
|
2006
|
-
await ((_this$
|
|
2010
|
+
var _this$chainService29, _this$chainService29$, _this$chainService29$2;
|
|
2011
|
+
await ((_this$chainService29 = this.chainService) === null || _this$chainService29 === void 0 ? void 0 : (_this$chainService29$ = _this$chainService29.mantaPay) === null || _this$chainService29$ === void 0 ? void 0 : (_this$chainService29$2 = _this$chainService29$.privateWallet) === null || _this$chainService29$2 === void 0 ? void 0 : _this$chainService29$2.initialWalletSync());
|
|
2007
2012
|
}
|
|
2008
2013
|
}
|
|
2009
2014
|
async getMantaPayZkBalance(address, tokenInfo) {
|
|
2010
|
-
var _this$
|
|
2015
|
+
var _this$chainService30, _this$chainService30$, _this$chainService30$2;
|
|
2011
2016
|
const bnAssetId = new _bn.default((0, _utils._getTokenOnChainAssetId)(tokenInfo));
|
|
2012
|
-
const balance = await ((_this$
|
|
2017
|
+
const balance = await ((_this$chainService30 = this.chainService) === null || _this$chainService30 === void 0 ? void 0 : (_this$chainService30$ = _this$chainService30.mantaPay) === null || _this$chainService30$ === void 0 ? void 0 : (_this$chainService30$2 = _this$chainService30$.privateWallet) === null || _this$chainService30$2 === void 0 ? void 0 : _this$chainService30$2.getZkBalance(bnAssetId));
|
|
2013
2018
|
return {
|
|
2014
2019
|
decimals: tokenInfo.decimals || 0,
|
|
2015
2020
|
symbol: tokenInfo.symbol,
|
|
@@ -2017,11 +2022,11 @@ class KoniState {
|
|
|
2017
2022
|
};
|
|
2018
2023
|
}
|
|
2019
2024
|
subscribeMantaPaySyncState() {
|
|
2020
|
-
var _this$
|
|
2021
|
-
if (!((_this$
|
|
2025
|
+
var _this$chainService31, _this$chainService32, _this$chainService32$;
|
|
2026
|
+
if (!((_this$chainService31 = this.chainService) !== null && _this$chainService31 !== void 0 && _this$chainService31.mantaPay)) {
|
|
2022
2027
|
return new _rxjs.Subject();
|
|
2023
2028
|
}
|
|
2024
|
-
return (_this$
|
|
2029
|
+
return (_this$chainService32 = this.chainService) === null || _this$chainService32 === void 0 ? void 0 : (_this$chainService32$ = _this$chainService32.mantaPay) === null || _this$chainService32$ === void 0 ? void 0 : _this$chainService32$.subscribeSyncState();
|
|
2025
2030
|
}
|
|
2026
2031
|
|
|
2027
2032
|
/* Metadata */
|
|
@@ -2044,12 +2049,12 @@ class KoniState {
|
|
|
2044
2049
|
|
|
2045
2050
|
/* Metadata */
|
|
2046
2051
|
|
|
2047
|
-
getCrowdloanContributions(
|
|
2052
|
+
getCrowdloanContributions(_ref13) {
|
|
2048
2053
|
let {
|
|
2049
2054
|
address,
|
|
2050
2055
|
page,
|
|
2051
2056
|
relayChain
|
|
2052
|
-
} =
|
|
2057
|
+
} = _ref13;
|
|
2053
2058
|
return this.subscanService.getCrowdloanContributions(relayChain, address, page);
|
|
2054
2059
|
}
|
|
2055
2060
|
}
|
|
@@ -30,8 +30,7 @@ var _web = _interopRequireDefault(require("web3"));
|
|
|
30
30
|
var _phishing = require("@polkadot/phishing");
|
|
31
31
|
var _util = require("@polkadot/util");
|
|
32
32
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
33
|
-
function
|
|
34
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
35
34
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
36
35
|
// SPDX-License-Identifier: Apache-2.0
|
|
37
36
|
|
|
@@ -52,7 +51,7 @@ function transformAccountsV2(accounts) {
|
|
|
52
51
|
}
|
|
53
52
|
const validTypes = {
|
|
54
53
|
evm: _types3.EthereumKeypairTypes,
|
|
55
|
-
substrate: _types3.
|
|
54
|
+
substrate: _types3.AllSubstrateKeypairTypes,
|
|
56
55
|
ton: _types3.TonKeypairTypes,
|
|
57
56
|
cardano: _types3.CardanoKeypairTypes,
|
|
58
57
|
bitcoin: _types3.BitcoinKeypairTypes
|
|
@@ -80,7 +79,7 @@ function transformAccountsV2(accounts) {
|
|
|
80
79
|
return true;
|
|
81
80
|
}
|
|
82
81
|
};
|
|
83
|
-
|
|
82
|
+
const injectedAccounts = Object.values(accounts).filter(_ref2 => {
|
|
84
83
|
let {
|
|
85
84
|
json: {
|
|
86
85
|
meta: {
|
|
@@ -114,6 +113,12 @@ function transformAccountsV2(accounts) {
|
|
|
114
113
|
type
|
|
115
114
|
};
|
|
116
115
|
});
|
|
116
|
+
return injectedAccounts.map(acc => {
|
|
117
|
+
if (acc.type === 'ed25519-tw') {
|
|
118
|
+
acc.type = 'ed25519';
|
|
119
|
+
}
|
|
120
|
+
return acc;
|
|
121
|
+
});
|
|
117
122
|
}
|
|
118
123
|
// check if a URL is blocked
|
|
119
124
|
const chainPatrolCheckUrl = async url => {
|
|
@@ -503,10 +508,10 @@ class KoniTabs {
|
|
|
503
508
|
date: new Date().getTime()
|
|
504
509
|
}];
|
|
505
510
|
}
|
|
506
|
-
async revokePermissions(url, id,
|
|
511
|
+
async revokePermissions(url, id, _ref0) {
|
|
507
512
|
let {
|
|
508
513
|
params
|
|
509
|
-
} =
|
|
514
|
+
} = _ref0;
|
|
510
515
|
if (!params || !(0, _util.isArray)(params) || params.length === 0) {
|
|
511
516
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'No list of permissions found to revoke in the parameters.');
|
|
512
517
|
}
|
|
@@ -542,8 +547,8 @@ class KoniTabs {
|
|
|
542
547
|
if (accountAuthTypes.length === 1) {
|
|
543
548
|
delete value[urlStripped];
|
|
544
549
|
} else {
|
|
545
|
-
value[urlStripped].isAllowedMap = Object.entries(isAllowedMap).reduce((allowedMap,
|
|
546
|
-
let [address, value] =
|
|
550
|
+
value[urlStripped].isAllowedMap = Object.entries(isAllowedMap).reduce((allowedMap, _ref1) => {
|
|
551
|
+
let [address, value] = _ref1;
|
|
547
552
|
if ((0, _utilCrypto.isEthereumAddress)(address)) {
|
|
548
553
|
allowedMap[address] = false;
|
|
549
554
|
} else {
|
|
@@ -569,10 +574,10 @@ class KoniTabs {
|
|
|
569
574
|
await Promise.all(Array.from(permissions).map(permissionPromise));
|
|
570
575
|
return null;
|
|
571
576
|
}
|
|
572
|
-
async switchEvmChain(id, url,
|
|
577
|
+
async switchEvmChain(id, url, _ref10) {
|
|
573
578
|
let {
|
|
574
579
|
params
|
|
575
|
-
} =
|
|
580
|
+
} = _ref10;
|
|
576
581
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
577
582
|
const chainId = params[0].chainId;
|
|
578
583
|
const chainIdDec = parseInt(chainId, 16);
|
|
@@ -627,11 +632,11 @@ class KoniTabs {
|
|
|
627
632
|
}
|
|
628
633
|
return null;
|
|
629
634
|
}
|
|
630
|
-
async addEvmToken(id, url,
|
|
635
|
+
async addEvmToken(id, url, _ref11) {
|
|
631
636
|
var _input$type, _input$options, _input$options2, _input$options3, _input$options4, _input$options5;
|
|
632
637
|
let {
|
|
633
638
|
params
|
|
634
|
-
} =
|
|
639
|
+
} = _ref11;
|
|
635
640
|
const input = params;
|
|
636
641
|
const _tokenType = (input === null || input === void 0 ? void 0 : (_input$type = input.type) === null || _input$type === void 0 ? void 0 : _input$type.toLowerCase()) || '';
|
|
637
642
|
if (_tokenType !== 'erc20' && _tokenType !== 'erc721') {
|
|
@@ -684,10 +689,10 @@ class KoniTabs {
|
|
|
684
689
|
|
|
685
690
|
return await this.#koniState.addTokenConfirm(id, url, tokenInfo);
|
|
686
691
|
}
|
|
687
|
-
async addEvmChain(id, url,
|
|
692
|
+
async addEvmChain(id, url, _ref12) {
|
|
688
693
|
let {
|
|
689
694
|
params
|
|
690
|
-
} =
|
|
695
|
+
} = _ref12;
|
|
691
696
|
const input = params;
|
|
692
697
|
if (input && input.length > 0) {
|
|
693
698
|
const {
|
|
@@ -892,11 +897,11 @@ class KoniTabs {
|
|
|
892
897
|
const networkCheckInterval = setInterval(networkCheck, _constants.CRON_GET_API_MAP_STATUS);
|
|
893
898
|
const provider = await this.getEvmProvider(url);
|
|
894
899
|
const eventMap = {};
|
|
895
|
-
eventMap.data =
|
|
900
|
+
eventMap.data = _ref13 => {
|
|
896
901
|
let {
|
|
897
902
|
method,
|
|
898
903
|
params
|
|
899
|
-
} =
|
|
904
|
+
} = _ref13;
|
|
900
905
|
emitEvent('message', {
|
|
901
906
|
type: method,
|
|
902
907
|
data: params
|
|
@@ -905,8 +910,8 @@ class KoniTabs {
|
|
|
905
910
|
eventMap.error = rs => {
|
|
906
911
|
emitEvent('error', rs);
|
|
907
912
|
};
|
|
908
|
-
Object.entries(eventMap).forEach(
|
|
909
|
-
let [event, callback] =
|
|
913
|
+
Object.entries(eventMap).forEach(_ref14 => {
|
|
914
|
+
let [event, callback] = _ref14;
|
|
910
915
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
911
916
|
(provider === null || provider === void 0 ? void 0 : provider.on) && (provider === null || provider === void 0 ? void 0 : provider.on(event, callback));
|
|
912
917
|
});
|
|
@@ -920,8 +925,8 @@ class KoniTabs {
|
|
|
920
925
|
if (this.evmEventEmitterMap[url][id]) {
|
|
921
926
|
delete this.evmEventEmitterMap[url][id];
|
|
922
927
|
}
|
|
923
|
-
Object.entries(eventMap).forEach(
|
|
924
|
-
let [event, callback] =
|
|
928
|
+
Object.entries(eventMap).forEach(_ref15 => {
|
|
929
|
+
let [event, callback] = _ref15;
|
|
925
930
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
926
931
|
(provider === null || provider === void 0 ? void 0 : provider.removeListener) && (provider === null || provider === void 0 ? void 0 : provider.removeListener(event, callback));
|
|
927
932
|
});
|
|
@@ -956,11 +961,11 @@ class KoniTabs {
|
|
|
956
961
|
}
|
|
957
962
|
return provider;
|
|
958
963
|
}
|
|
959
|
-
async performWeb3Method(id, url,
|
|
964
|
+
async performWeb3Method(id, url, _ref16, callback) {
|
|
960
965
|
let {
|
|
961
966
|
method,
|
|
962
967
|
params
|
|
963
|
-
} =
|
|
968
|
+
} = _ref16;
|
|
964
969
|
const provider = await this.getEvmProvider(url);
|
|
965
970
|
this.checkAndHandleProviderStatus(provider);
|
|
966
971
|
return new Promise((resolve, reject) => {
|
|
@@ -992,11 +997,11 @@ class KoniTabs {
|
|
|
992
997
|
});
|
|
993
998
|
});
|
|
994
999
|
}
|
|
995
|
-
async evmSign(id, url,
|
|
1000
|
+
async evmSign(id, url, _ref17) {
|
|
996
1001
|
let {
|
|
997
1002
|
method,
|
|
998
1003
|
params
|
|
999
|
-
} =
|
|
1004
|
+
} = _ref17;
|
|
1000
1005
|
const signResult = await this.#koniState.evmSign(id, url, method, params);
|
|
1001
1006
|
if (signResult) {
|
|
1002
1007
|
return signResult;
|
|
@@ -1006,10 +1011,10 @@ class KoniTabs {
|
|
|
1006
1011
|
}
|
|
1007
1012
|
|
|
1008
1013
|
// TODO: Update logic
|
|
1009
|
-
async evmSendTransaction(id, url,
|
|
1014
|
+
async evmSendTransaction(id, url, _ref18) {
|
|
1010
1015
|
let {
|
|
1011
1016
|
params
|
|
1012
|
-
} =
|
|
1017
|
+
} = _ref18;
|
|
1013
1018
|
const transactionParams = params[0];
|
|
1014
1019
|
const transactionHash = await this.#koniState.evmSendTransaction(id, url, transactionParams);
|
|
1015
1020
|
if (!transactionHash) {
|
|
@@ -1095,11 +1100,11 @@ class KoniTabs {
|
|
|
1095
1100
|
isEvmPublicRequest(type, request) {
|
|
1096
1101
|
return type === 'evm(request)' && ['eth_chainId', 'net_version', 'wallet_requestPermissions', 'wallet_getPermissions'].includes(request === null || request === void 0 ? void 0 : request.method) || type === 'evm(events.subscribe)';
|
|
1097
1102
|
}
|
|
1098
|
-
async addPspToken(id, url,
|
|
1103
|
+
async addPspToken(id, url, _ref19) {
|
|
1099
1104
|
let {
|
|
1100
1105
|
genesisHash,
|
|
1101
1106
|
tokenInfo: input
|
|
1102
|
-
} =
|
|
1107
|
+
} = _ref19;
|
|
1103
1108
|
const _tokenType = input.type;
|
|
1104
1109
|
if (_tokenType !== 'psp22' && _tokenType !== 'psp34') {
|
|
1105
1110
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Assets type {{tokenType}} is not supported'.replace('{{tokenType}}', _tokenType));
|
|
@@ -1401,11 +1406,11 @@ class KoniTabs {
|
|
|
1401
1406
|
throw new _BitcoinProviderError.BitcoinProviderError(_KoniTypes.BitcoinProviderErrorType.USER_REJECTED_REQUEST);
|
|
1402
1407
|
}
|
|
1403
1408
|
}
|
|
1404
|
-
async bitcoinSign(id, url,
|
|
1409
|
+
async bitcoinSign(id, url, _ref20) {
|
|
1405
1410
|
let {
|
|
1406
1411
|
method,
|
|
1407
1412
|
params
|
|
1408
|
-
} =
|
|
1413
|
+
} = _ref20;
|
|
1409
1414
|
const signResult = await this.#koniState.bitcoinSign(id, url, method, params);
|
|
1410
1415
|
if (signResult) {
|
|
1411
1416
|
return signResult;
|
|
@@ -1413,11 +1418,11 @@ class KoniTabs {
|
|
|
1413
1418
|
throw new _BitcoinProviderError.BitcoinProviderError(_KoniTypes.BitcoinProviderErrorType.INVALID_PARAMS, 'Failed to sign message');
|
|
1414
1419
|
}
|
|
1415
1420
|
}
|
|
1416
|
-
async bitcoinSignPspt(id, url,
|
|
1421
|
+
async bitcoinSignPspt(id, url, _ref21) {
|
|
1417
1422
|
let {
|
|
1418
1423
|
method,
|
|
1419
1424
|
params
|
|
1420
|
-
} =
|
|
1425
|
+
} = _ref21;
|
|
1421
1426
|
const psbtParams = params;
|
|
1422
1427
|
const signResult = await this.#koniState.bitcoinSignPspt(id, url, psbtParams);
|
|
1423
1428
|
if (signResult) {
|
|
@@ -1426,10 +1431,10 @@ class KoniTabs {
|
|
|
1426
1431
|
throw new _BitcoinProviderError.BitcoinProviderError(_KoniTypes.BitcoinProviderErrorType.INVALID_PARAMS, 'Failed to sign message');
|
|
1427
1432
|
}
|
|
1428
1433
|
}
|
|
1429
|
-
async bitcoinSendTransfer(id, url,
|
|
1434
|
+
async bitcoinSendTransfer(id, url, _ref22) {
|
|
1430
1435
|
let {
|
|
1431
1436
|
params
|
|
1432
|
-
} =
|
|
1437
|
+
} = _ref22;
|
|
1433
1438
|
const transactionParams = params;
|
|
1434
1439
|
const transactionHash = await this.#koniState.bitcoinSendTransaction(id, url, transactionParams);
|
|
1435
1440
|
if (!transactionHash) {
|
package/cjs/packageInfo.js
CHANGED
package/cjs/page/index.js
CHANGED
|
@@ -21,6 +21,13 @@ var _getId = require("../utils/getId");
|
|
|
21
21
|
// Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
22
22
|
// SPDX-License-Identifier: Apache-2.0
|
|
23
23
|
|
|
24
|
+
// when sending a message from the injector to the extension, we
|
|
25
|
+
// - create an event - this we send to the loader
|
|
26
|
+
// - the loader takes this event and uses port.postMessage to background
|
|
27
|
+
// - on response, the loader creates a reponse event
|
|
28
|
+
// - this injector, listens on the events, maps it to the original
|
|
29
|
+
// - resolves/rejects the promise with the result (or sub data)
|
|
30
|
+
|
|
24
31
|
const handlers = {};
|
|
25
32
|
|
|
26
33
|
// a generic message sender that creates an event, returning a promise that will
|
|
@@ -11,6 +11,9 @@ var _util = require("@polkadot/util");
|
|
|
11
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
12
12
|
|
|
13
13
|
const l = (0, _util.logger)('PostMessageProvider');
|
|
14
|
+
|
|
15
|
+
// Same as https://github.com/polkadot-js/api/blob/57ca9a9c3204339e1e1f693fcacc33039868dc27/packages/rpc-provider/src/ws/Provider.ts#L17
|
|
16
|
+
|
|
14
17
|
// External to class, this.# is not private enough (yet)
|
|
15
18
|
let sendRequest;
|
|
16
19
|
|
|
@@ -49,7 +49,6 @@ async function retryCardanoTxStatus(fn, options) {
|
|
|
49
49
|
await new Promise(resolve => setTimeout(resolve, options.delay)); // wait for delay period, then recall the fn()
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
53
52
|
console.error('Cardano transaction timeout', lastError); // throw only last error, in case no successful result from fn()
|
|
54
53
|
|
|
55
54
|
return false;
|
|
@@ -67,7 +67,6 @@ const subscribeGRC20Balance = _ref => {
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
};
|
|
70
|
-
|
|
71
70
|
getTokenBalances();
|
|
72
71
|
const interval = setInterval(getTokenBalances, _constants.SUB_TOKEN_REFRESH_BALANCE_INTERVAL);
|
|
73
72
|
return () => {
|
|
@@ -127,7 +126,6 @@ const subscribeVftBalance = _ref3 => {
|
|
|
127
126
|
}
|
|
128
127
|
});
|
|
129
128
|
};
|
|
130
|
-
|
|
131
129
|
getTokenBalances();
|
|
132
130
|
const interval = setInterval(getTokenBalances, _constants.SUB_TOKEN_REFRESH_BALANCE_INTERVAL);
|
|
133
131
|
return () => {
|