@subwallet/extension-base 1.0.1 → 1.0.2-1b
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 +25 -36
- package/background/KoniTypes.js +12 -7
- package/background/errors/TransactionError.js +21 -1
- package/cjs/background/KoniTypes.js +14 -8
- package/cjs/background/errors/TransactionError.js +20 -0
- package/cjs/constants/index.js +13 -28
- package/cjs/koni/api/dotsama/balance.js +60 -224
- package/cjs/koni/api/dotsama/transfer.js +30 -29
- package/cjs/koni/api/nft/acala_nft/index.js +4 -1
- package/cjs/koni/api/nft/bit.country/index.js +4 -1
- package/cjs/koni/api/nft/evm_nft/index.js +7 -3
- package/cjs/koni/api/nft/index.js +3 -6
- package/cjs/koni/api/nft/karura_nft/index.js +4 -1
- package/cjs/koni/api/nft/rmrk_nft/index.js +8 -1
- package/cjs/koni/api/nft/statemine_nft/index.js +4 -1
- package/cjs/koni/api/nft/unique_nft/index.js +6 -1
- package/cjs/koni/api/nft/wasm_nft/index.js +169 -111
- package/cjs/koni/api/nft/wasm_nft/utils.js +11 -7
- package/cjs/koni/api/staking/bonding/amplitude.js +18 -10
- package/cjs/koni/api/staking/bonding/astar.js +37 -238
- package/cjs/koni/api/staking/bonding/index.js +26 -14
- package/cjs/koni/api/staking/bonding/paraChain.js +100 -11
- package/cjs/koni/api/staking/bonding/relayChain.js +174 -16
- package/cjs/koni/api/staking/bonding/utils.js +55 -10
- package/cjs/koni/api/tokens/wasm/index.js +5 -4
- package/cjs/koni/api/tokens/wasm/utils.js +63 -0
- package/cjs/koni/api/xcm/index.js +0 -111
- package/cjs/koni/api/xcm/polkadotXcm.js +2 -2
- package/cjs/koni/api/xcm/utils.js +18 -13
- package/cjs/koni/api/xcm/xTokens.js +3 -5
- package/cjs/koni/api/xcm/xcmPallet.js +9 -6
- package/cjs/koni/background/cron.js +179 -77
- package/cjs/koni/background/handlers/Extension.js +231 -195
- package/cjs/koni/background/handlers/State.js +147 -111
- package/cjs/koni/background/handlers/Tabs.js +48 -39
- package/cjs/koni/background/subscription.js +64 -56
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/index.js +5 -0
- package/cjs/services/chain-service/constants.js +1 -11
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +13 -8
- package/cjs/services/chain-service/handler/light-client/index.js +2 -0
- package/cjs/services/chain-service/index.js +39 -6
- package/cjs/services/chain-service/utils.js +4 -0
- package/cjs/services/event-service/index.js +75 -0
- package/cjs/services/event-service/types.js +11 -0
- package/cjs/services/history-service/index.js +46 -21
- package/cjs/services/history-service/subsquid-multi-chain-history.js +19 -11
- package/cjs/services/keyring-service/index.js +101 -0
- package/cjs/services/migration-service/index.js +13 -10
- package/cjs/{koni/migration/scripts/RemoveWrongCrowdloan.js → services/migration-service/scripts/AutoEnableChainsTokens.js} +11 -6
- package/cjs/services/migration-service/scripts/MigrateNetworkSettings.js +39 -19
- package/cjs/services/migration-service/scripts/MigrateSettings.js +31 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +72 -0
- package/cjs/services/migration-service/scripts/index.js +13 -4
- package/cjs/services/price-service/coingecko.js +15 -3
- package/cjs/services/price-service/index.js +15 -18
- package/cjs/services/request-service/constants.js +8 -2
- package/cjs/services/request-service/handler/AuthRequestHandler.js +43 -12
- package/cjs/services/request-service/index.js +3 -0
- package/cjs/services/storage-service/DatabaseService.js +53 -34
- package/cjs/services/storage-service/databases/index.js +1 -1
- package/cjs/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/cjs/services/storage-service/db-stores/Nft.js +8 -18
- package/cjs/services/storage-service/db-stores/Transaction.js +10 -7
- package/cjs/services/subscan-service/index.js +107 -0
- package/cjs/services/subscan-service/subscan-chain-map.js +74 -0
- package/cjs/services/subscan-service/types.js +1 -0
- package/cjs/services/transaction-service/event-parser/index.js +20 -48
- package/cjs/services/transaction-service/index.js +66 -22
- package/cjs/services/transaction-service/utils.js +4 -6
- package/cjs/utils/address.js +9 -1
- package/cjs/utils/index.js +30 -26
- package/constants/index.d.ts +8 -13
- package/constants/index.js +8 -13
- package/koni/api/dotsama/balance.d.ts +0 -1
- package/koni/api/dotsama/balance.js +33 -197
- package/koni/api/dotsama/transfer.js +5 -4
- package/koni/api/nft/acala_nft/index.js +3 -1
- package/koni/api/nft/bit.country/index.js +3 -1
- package/koni/api/nft/evm_nft/index.js +6 -3
- package/koni/api/nft/index.d.ts +1 -2
- package/koni/api/nft/index.js +3 -6
- package/koni/api/nft/karura_nft/index.js +3 -1
- package/koni/api/nft/nft.d.ts +1 -0
- package/koni/api/nft/rmrk_nft/index.js +8 -1
- package/koni/api/nft/statemine_nft/index.js +3 -1
- package/koni/api/nft/unique_nft/index.js +5 -1
- package/koni/api/nft/wasm_nft/index.d.ts +0 -2
- package/koni/api/nft/wasm_nft/index.js +167 -109
- package/koni/api/nft/wasm_nft/utils.d.ts +7 -5
- package/koni/api/nft/wasm_nft/utils.js +7 -5
- package/koni/api/staking/bonding/amplitude.d.ts +1 -2
- package/koni/api/staking/bonding/amplitude.js +22 -13
- package/koni/api/staking/bonding/astar.d.ts +2 -11
- package/koni/api/staking/bonding/astar.js +39 -231
- package/koni/api/staking/bonding/index.d.ts +5 -2
- package/koni/api/staking/bonding/index.js +27 -17
- package/koni/api/staking/bonding/paraChain.d.ts +4 -1
- package/koni/api/staking/bonding/paraChain.js +101 -14
- package/koni/api/staking/bonding/relayChain.d.ts +6 -2
- package/koni/api/staking/bonding/relayChain.js +172 -17
- package/koni/api/staking/bonding/utils.d.ts +15 -2
- package/koni/api/staking/bonding/utils.js +53 -11
- package/koni/api/tokens/wasm/index.js +5 -4
- package/koni/api/tokens/wasm/utils.d.ts +6 -0
- package/koni/api/tokens/wasm/utils.js +54 -0
- package/koni/api/xcm/index.js +1 -112
- package/koni/api/xcm/polkadotXcm.js +3 -3
- package/koni/api/xcm/utils.d.ts +5 -6
- package/koni/api/xcm/utils.js +15 -10
- package/koni/api/xcm/xTokens.js +5 -7
- package/koni/api/xcm/xcmPallet.js +10 -9
- package/koni/background/cron.d.ts +6 -1
- package/koni/background/cron.js +179 -76
- package/koni/background/handlers/Extension.d.ts +2 -2
- package/koni/background/handlers/Extension.js +161 -125
- package/koni/background/handlers/State.d.ts +21 -20
- package/koni/background/handlers/State.js +144 -111
- package/koni/background/handlers/Tabs.js +30 -20
- package/koni/background/subscription.d.ts +1 -1
- package/koni/background/subscription.js +64 -58
- package/package.json +63 -18
- package/packageInfo.js +1 -1
- package/page/index.d.ts +2 -0
- package/page/index.js +4 -0
- package/services/chain-service/constants.d.ts +0 -1
- package/services/chain-service/constants.js +0 -9
- package/services/chain-service/handler/SubstrateChainHandler.js +14 -9
- package/services/chain-service/handler/light-client/index.d.ts +17 -1
- package/services/chain-service/handler/light-client/index.js +1 -1
- package/services/chain-service/helper/psp22_abi.json +1041 -881
- package/services/chain-service/helper/psp34_abi.json +2963 -1807
- package/services/chain-service/index.d.ts +6 -4
- package/services/chain-service/index.js +40 -9
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +3 -0
- package/services/event-service/index.d.ts +22 -0
- package/services/event-service/index.js +63 -0
- package/services/event-service/types.d.ts +28 -0
- package/services/event-service/types.js +4 -0
- package/services/history-service/index.d.ts +5 -3
- package/services/history-service/index.js +46 -21
- package/services/history-service/subsquid-multi-chain-history.js +22 -13
- package/services/keyring-service/index.d.ts +19 -0
- package/services/keyring-service/index.js +93 -0
- package/services/migration-service/index.js +11 -9
- package/services/migration-service/scripts/AutoEnableChainsTokens.d.ts +4 -0
- package/services/migration-service/scripts/AutoEnableChainsTokens.js +13 -0
- package/services/migration-service/scripts/MigrateNetworkSettings.js +37 -18
- package/services/migration-service/scripts/MigrateSettings.d.ts +4 -0
- package/services/migration-service/scripts/MigrateSettings.js +23 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.js +64 -0
- package/services/migration-service/scripts/index.d.ts +1 -0
- package/services/migration-service/scripts/index.js +10 -3
- package/services/price-service/coingecko.js +15 -3
- package/services/price-service/index.d.ts +5 -3
- package/services/price-service/index.js +15 -18
- package/services/request-service/constants.d.ts +1 -0
- package/services/request-service/constants.js +6 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +8 -1
- package/services/request-service/handler/AuthRequestHandler.js +44 -13
- package/services/request-service/index.d.ts +7 -1
- package/services/request-service/index.js +3 -0
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +53 -34
- package/services/storage-service/databases/index.js +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.d.ts +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/services/storage-service/db-stores/Nft.d.ts +3 -3
- package/services/storage-service/db-stores/Nft.js +8 -17
- package/services/storage-service/db-stores/Transaction.js +10 -7
- package/services/subscan-service/index.d.ts +20 -0
- package/services/subscan-service/index.js +99 -0
- package/services/subscan-service/subscan-chain-map.d.ts +5 -0
- package/services/subscan-service/subscan-chain-map.js +63 -0
- package/services/subscan-service/types.d.ts +27 -0
- package/services/subscan-service/types.js +1 -0
- package/services/transaction-service/event-parser/index.d.ts +2 -2
- package/services/transaction-service/event-parser/index.js +21 -49
- package/services/transaction-service/index.d.ts +4 -2
- package/services/transaction-service/index.js +66 -22
- package/services/transaction-service/utils.js +5 -6
- package/utils/address.d.ts +1 -0
- package/utils/address.js +9 -2
- package/utils/index.d.ts +2 -1
- package/utils/index.js +26 -23
- 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/errors/SubWalletProviderError.js +0 -17
- package/cjs/koni/api/xcm/astar.js +0 -160
- package/cjs/koni/api/xcm/moonbeamXcm.js +0 -80
- package/cjs/koni/api/xcm/statemintXcm.js +0 -197
- package/cjs/koni/api/xcm/substrateXcm.js +0 -213
- package/cjs/koni/migration/Base.js +0 -20
- package/cjs/koni/migration/index.js +0 -45
- package/cjs/koni/migration/scripts/ChangeRouteToHome.js +0 -22
- package/cjs/koni/migration/scripts/ClearOldStorage.js +0 -24
- package/cjs/koni/migration/scripts/RemoveWrongTransactionHistoriesFromStore.js +0 -36
- package/cjs/koni/migration/scripts/ResetTransactionHistoryEventIdx.js +0 -21
- package/cjs/koni/migration/scripts/index.js +0 -22
- package/cjs/koni/page/index.js +0 -16
- package/cjs/services/asset-service/index.js +0 -91
- package/cjs/services/storage-service/db-stores/ExtraDelegationInfo.js +0 -17
- package/cjs/stores/Balance.js +0 -18
- package/cjs/stores/Crowdloan.js +0 -18
- package/cjs/stores/CustomEvmToken.js +0 -18
- package/cjs/stores/NetworkMap.js +0 -18
- package/cjs/stores/Nft.js +0 -18
- package/cjs/stores/NftCollection.js +0 -18
- package/cjs/stores/Price.js +0 -18
- package/cjs/stores/Staking.js +0 -18
- package/cjs/stores/StakingReward.js +0 -18
- package/cjs/utils/eth/parseTransactionData.js +0 -284
- package/koni/page/index.d.ts +0 -2
- package/koni/page/index.js +0 -9
- /package/cjs/{koni/page → page}/SubWalleEvmProvider.js +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.d.ts +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.js +0 -0
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.AssetService = void 0;
|
|
7
|
-
var _rxjs = require("rxjs");
|
|
8
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
9
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
-
|
|
11
|
-
class AssetService {
|
|
12
|
-
// Todo: Update to new store indexed DB
|
|
13
|
-
|
|
14
|
-
assetSettingSubject = new _rxjs.BehaviorSubject({});
|
|
15
|
-
constructor(store, chainService) {
|
|
16
|
-
this.chainService = chainService;
|
|
17
|
-
this.store = store;
|
|
18
|
-
this.initAssetSettings().catch(console.error);
|
|
19
|
-
}
|
|
20
|
-
async initAssetSettings() {
|
|
21
|
-
const assetSettings = await this.getAssetSettings();
|
|
22
|
-
const activeChainSlugs = this.chainService.getActiveChainSlugs();
|
|
23
|
-
const assetRegistry = this.chainService.getAssetRegistry();
|
|
24
|
-
if (Object.keys(assetSettings).length === 0) {
|
|
25
|
-
// only initiate the first time
|
|
26
|
-
Object.values(assetRegistry).forEach(assetInfo => {
|
|
27
|
-
const isSettingExisted = (assetInfo.slug in assetSettings);
|
|
28
|
-
|
|
29
|
-
// Set visible for every enabled chains
|
|
30
|
-
if (activeChainSlugs.includes(assetInfo.originChain) && !isSettingExisted) {
|
|
31
|
-
// Setting only exist when set either by chain settings or user
|
|
32
|
-
assetSettings[assetInfo.slug] = {
|
|
33
|
-
visible: true
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
this.setAssetSettings(assetSettings);
|
|
38
|
-
}
|
|
39
|
-
console.log('Done init asset settings');
|
|
40
|
-
}
|
|
41
|
-
setAssetSettings(assetSettings) {
|
|
42
|
-
this.assetSettingSubject.next(assetSettings);
|
|
43
|
-
this.store.set('AssetSetting', assetSettings);
|
|
44
|
-
}
|
|
45
|
-
async getStoreAssetSettings() {
|
|
46
|
-
return new Promise(resolve => {
|
|
47
|
-
this.store.get('AssetSetting', resolve);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
async getAssetSettings() {
|
|
51
|
-
if (Object.keys(this.assetSettingSubject.value).length === 0) {
|
|
52
|
-
const assetSettings = await this.getStoreAssetSettings();
|
|
53
|
-
this.assetSettingSubject.next(assetSettings);
|
|
54
|
-
}
|
|
55
|
-
return this.assetSettingSubject.value;
|
|
56
|
-
}
|
|
57
|
-
getAssetSettingSubject() {
|
|
58
|
-
return this.assetSettingSubject;
|
|
59
|
-
}
|
|
60
|
-
async updateAssetSetting(assetSlug, assetSetting) {
|
|
61
|
-
const currentAssetSettings = await this.getAssetSettings();
|
|
62
|
-
|
|
63
|
-
// Update settings
|
|
64
|
-
currentAssetSettings[assetSlug] = assetSetting;
|
|
65
|
-
this.setAssetSettings(currentAssetSettings);
|
|
66
|
-
if (assetSetting.visible) {
|
|
67
|
-
const assetInfo = this.chainService.getAssetBySlug(assetSlug);
|
|
68
|
-
const chainState = this.chainService.getChainStateByKey(assetInfo.originChain);
|
|
69
|
-
|
|
70
|
-
// if chain not enabled, then automatically enable
|
|
71
|
-
if (chainState && !chainState.active) {
|
|
72
|
-
this.chainService.enableChain(chainState.slug);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async updateAssetSettingByChain(chainSlug, visible) {
|
|
77
|
-
const storedAssetSettings = await this.getAssetSettings();
|
|
78
|
-
const assetsByChain = this.chainService.getFungibleTokensByChain(chainSlug);
|
|
79
|
-
const assetSettings = storedAssetSettings || {};
|
|
80
|
-
Object.values(assetsByChain).forEach(assetInfo => {
|
|
81
|
-
assetSettings[assetInfo.slug] = {
|
|
82
|
-
visible
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
this.setAssetSettings(assetSettings);
|
|
86
|
-
}
|
|
87
|
-
subscribeAssetSettings() {
|
|
88
|
-
return this.assetSettingSubject;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.AssetService = AssetService;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _BaseStoreWithAddressAndChain = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/BaseStoreWithAddressAndChain"));
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
class ExtraDelegationInfoStore extends _BaseStoreWithAddressAndChain.default {
|
|
13
|
-
getDelegationInfo(chain, address) {
|
|
14
|
-
return this.table.where('[chain+address]').equals([chain, address]).first();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.default = ExtraDelegationInfoStore;
|
package/cjs/stores/Balance.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defaults = require("@subwallet/extension-base/defaults");
|
|
9
|
-
var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class BalanceStore extends _SubscribableStore.default {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(`${_defaults.EXTENSION_PREFIX}balance`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = BalanceStore;
|
package/cjs/stores/Crowdloan.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defaults = require("@subwallet/extension-base/defaults");
|
|
9
|
-
var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class CrowdloanStore extends _SubscribableStore.default {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(`${_defaults.EXTENSION_PREFIX}crowdloan`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = CrowdloanStore;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defaults = require("@subwallet/extension-base/defaults");
|
|
9
|
-
var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class CustomTokenStore extends _SubscribableStore.default {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(_defaults.EXTENSION_PREFIX ? `${_defaults.EXTENSION_PREFIX}customToken` : null);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = CustomTokenStore;
|
package/cjs/stores/NetworkMap.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defaults = require("@subwallet/extension-base/defaults");
|
|
9
|
-
var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class NetworkMapStore extends _SubscribableStore.default {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(_defaults.EXTENSION_PREFIX ? `${_defaults.EXTENSION_PREFIX}networkMap` : null);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = NetworkMapStore;
|
package/cjs/stores/Nft.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defaults = require("@subwallet/extension-base/defaults");
|
|
9
|
-
var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class NftStore extends _SubscribableStore.default {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(`${_defaults.EXTENSION_PREFIX}nft`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = NftStore;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defaults = require("@subwallet/extension-base/defaults");
|
|
9
|
-
var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class NftCollectionStore extends _SubscribableStore.default {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(`${_defaults.EXTENSION_PREFIX}nft-collection`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = NftCollectionStore;
|
package/cjs/stores/Price.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defaults = require("@subwallet/extension-base/defaults");
|
|
9
|
-
var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class PriceStore extends _SubscribableStore.default {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(_defaults.EXTENSION_PREFIX ? `${_defaults.EXTENSION_PREFIX}price` : null);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = PriceStore;
|
package/cjs/stores/Staking.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defaults = require("@subwallet/extension-base/defaults");
|
|
9
|
-
var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class StakingStore extends _SubscribableStore.default {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(`${_defaults.EXTENSION_PREFIX}staking`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = StakingStore;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defaults = require("@subwallet/extension-base/defaults");
|
|
9
|
-
var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class StakingRewardStore extends _SubscribableStore.default {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(_defaults.EXTENSION_PREFIX ? `${_defaults.EXTENSION_PREFIX}stakingReward` : null);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = StakingRewardStore;
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.InputDataDecoder = void 0;
|
|
8
|
-
var _buffer = require("buffer");
|
|
9
|
-
var _ethers = require("ethers");
|
|
10
|
-
var _isBuffer = _interopRequireDefault(require("is-buffer"));
|
|
11
|
-
var _web3Utils = require("web3-utils");
|
|
12
|
-
// Copyright 2019-2022 @subwallet/extension-koni-base authors & contributors
|
|
13
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
14
|
-
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
|
|
17
|
-
const ABI_TYPES = ['function', 'constructor', 'event', 'fallback'];
|
|
18
|
-
const instanceOfAbiItem = object => {
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
|
|
20
|
-
return 'type' in object && ABI_TYPES.includes(object.type);
|
|
21
|
-
};
|
|
22
|
-
const checkArrayAbiItems = data => {
|
|
23
|
-
if (Array.isArray(data)) {
|
|
24
|
-
return data.length > 0 && data.every(value => instanceOfAbiItem(value));
|
|
25
|
-
} else {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const genType = type => {
|
|
30
|
-
if (typeof type === 'string') {
|
|
31
|
-
return type;
|
|
32
|
-
} else {
|
|
33
|
-
if (type.components) {
|
|
34
|
-
var _type$components;
|
|
35
|
-
const arr = (_type$components = type.components) === null || _type$components === void 0 ? void 0 : _type$components.map(genType);
|
|
36
|
-
const tupleStr = `(${arr.join(',')})`;
|
|
37
|
-
if (type.type === 'tuple[]') {
|
|
38
|
-
return tupleStr + '[]';
|
|
39
|
-
} else {
|
|
40
|
-
return tupleStr;
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
return type.type;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const getMethodId = abi => {
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call
|
|
49
|
-
return (0, _web3Utils.keccak256)((0, _web3Utils._jsonInterfaceMethodToString)(abi)).slice(2, 10);
|
|
50
|
-
};
|
|
51
|
-
const getMethodName = abi => {
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call
|
|
53
|
-
return (0, _web3Utils._jsonInterfaceMethodToString)(abi);
|
|
54
|
-
};
|
|
55
|
-
const deepRemoveUnwantedArrayProperties = arr => {
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-return
|
|
57
|
-
return [...arr.map(item => {
|
|
58
|
-
if (Array.isArray(item)) {
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
60
|
-
return deepRemoveUnwantedArrayProperties(item);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
64
|
-
return item;
|
|
65
|
-
})];
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// remove 0x from addresses
|
|
69
|
-
function deepStripTupleAddresses(input, tupleTypes) {
|
|
70
|
-
return input.map((item, i) => {
|
|
71
|
-
// We find tupleTypes to not be an array where internalType is present in the ABI indicating item is a structure
|
|
72
|
-
const type = tupleTypes[i] ? tupleTypes[i].type : null;
|
|
73
|
-
if (type === 'address' && typeof item === 'string') {
|
|
74
|
-
return item;
|
|
75
|
-
}
|
|
76
|
-
if (type === 'address[]' && Array.isArray(item)) {
|
|
77
|
-
return item.map(a => a);
|
|
78
|
-
}
|
|
79
|
-
if (Array.isArray(item)) {
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
81
|
-
return deepStripTupleAddresses(item, tupleTypes);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
85
|
-
return item;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
const toHexString = byteArray => {
|
|
89
|
-
return Array.from(byteArray, function (byte) {
|
|
90
|
-
return ('0' + (byte & 0xFF).toString(16)).slice(-2);
|
|
91
|
-
}).join('');
|
|
92
|
-
};
|
|
93
|
-
class InputDataDecoder {
|
|
94
|
-
constructor(prop) {
|
|
95
|
-
this.abi = [];
|
|
96
|
-
if (typeof prop === 'string') {
|
|
97
|
-
try {
|
|
98
|
-
this.abi = JSON.parse(prop);
|
|
99
|
-
} catch (err) {
|
|
100
|
-
throw new Error(`Invalid ABI: ${err.message}`);
|
|
101
|
-
}
|
|
102
|
-
} else if (checkArrayAbiItems(prop)) {
|
|
103
|
-
this.abi = prop;
|
|
104
|
-
} else {
|
|
105
|
-
throw new TypeError('Must pass ABI array object or file path to constructor');
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
decodeConstructor(data) {
|
|
109
|
-
if ((0, _isBuffer.default)(data)) {
|
|
110
|
-
data = data.toString('utf8');
|
|
111
|
-
}
|
|
112
|
-
if (typeof data !== 'string') {
|
|
113
|
-
data = '';
|
|
114
|
-
}
|
|
115
|
-
data = data.trim();
|
|
116
|
-
for (let i = 0; i < this.abi.length; i++) {
|
|
117
|
-
const obj = this.abi[i];
|
|
118
|
-
if (obj.type !== 'constructor') {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
const method = obj.name || null;
|
|
122
|
-
const methodName = getMethodName(obj);
|
|
123
|
-
const types = obj.inputs ? obj.inputs.map(x => x.type) : [];
|
|
124
|
-
const names = obj.inputs ? obj.inputs.map(x => x.name) : [];
|
|
125
|
-
|
|
126
|
-
// take last 32 bytes
|
|
127
|
-
data = data.slice(-256);
|
|
128
|
-
if (data.length !== 256) {
|
|
129
|
-
throw new Error('fail');
|
|
130
|
-
}
|
|
131
|
-
if (data.indexOf('0x') !== 0) {
|
|
132
|
-
data = `0x${data}`;
|
|
133
|
-
}
|
|
134
|
-
const _inputs = _ethers.ethers.utils.defaultAbiCoder.decode(types, data);
|
|
135
|
-
const inputs = deepRemoveUnwantedArrayProperties(_inputs);
|
|
136
|
-
return {
|
|
137
|
-
methodName,
|
|
138
|
-
method,
|
|
139
|
-
types,
|
|
140
|
-
inputs,
|
|
141
|
-
names
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
throw new Error('not found');
|
|
145
|
-
}
|
|
146
|
-
decodeData(data) {
|
|
147
|
-
if ((0, _isBuffer.default)(data)) {
|
|
148
|
-
data = data.toString('utf8');
|
|
149
|
-
}
|
|
150
|
-
if (typeof data !== 'string') {
|
|
151
|
-
data = '';
|
|
152
|
-
}
|
|
153
|
-
data = data.trim();
|
|
154
|
-
const dataBuf = _buffer.Buffer.from(data.replace(/^0x/, ''), 'hex');
|
|
155
|
-
const methodId = toHexString(dataBuf.subarray(0, 4));
|
|
156
|
-
const inputsBuf = dataBuf.subarray(4);
|
|
157
|
-
let result = {
|
|
158
|
-
method: null,
|
|
159
|
-
methodName: null,
|
|
160
|
-
types: [],
|
|
161
|
-
inputs: [],
|
|
162
|
-
names: []
|
|
163
|
-
};
|
|
164
|
-
for (const abi of this.abi) {
|
|
165
|
-
try {
|
|
166
|
-
if (abi.type === 'constructor') {
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
if (abi.type === 'event') {
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
const method = abi.name || null;
|
|
173
|
-
const methodName = getMethodName(abi);
|
|
174
|
-
const types = abi.inputs ? abi.inputs.map(x => {
|
|
175
|
-
if (x.type.includes('tuple')) {
|
|
176
|
-
return x;
|
|
177
|
-
} else {
|
|
178
|
-
return x.type;
|
|
179
|
-
}
|
|
180
|
-
}) : [];
|
|
181
|
-
const names = abi.inputs ? abi.inputs.map(x => {
|
|
182
|
-
if (x.type.includes('tuple') && x.components) {
|
|
183
|
-
return [x.name, x.components.map(a => a.name)];
|
|
184
|
-
} else {
|
|
185
|
-
return x.name;
|
|
186
|
-
}
|
|
187
|
-
}) : [];
|
|
188
|
-
const hash = getMethodId(abi);
|
|
189
|
-
if (hash === methodId) {
|
|
190
|
-
let inputs = [];
|
|
191
|
-
try {
|
|
192
|
-
// @ts-ignore
|
|
193
|
-
inputs = _ethers.ethers.utils.defaultAbiCoder.decode(types, inputsBuf);
|
|
194
|
-
} catch (err) {
|
|
195
|
-
try {
|
|
196
|
-
const ifc = new _ethers.ethers.utils.Interface([]);
|
|
197
|
-
inputs = ifc.decodeFunctionData(_ethers.ethers.utils.FunctionFragment.fromObject(abi), data);
|
|
198
|
-
} catch (err) {}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// TODO: do this normalization into normalizeAddresses
|
|
202
|
-
let _inputs = [];
|
|
203
|
-
_inputs = inputs.map((input, i) => {
|
|
204
|
-
if (types[i].components) {
|
|
205
|
-
const tupleTypes = types[i].components;
|
|
206
|
-
|
|
207
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-argument
|
|
208
|
-
return deepStripTupleAddresses(input, tupleTypes);
|
|
209
|
-
}
|
|
210
|
-
if (types[i] === 'address' && typeof input === 'string') {
|
|
211
|
-
return input;
|
|
212
|
-
}
|
|
213
|
-
if (types[i] === 'address[]' && Array.isArray(input)) {
|
|
214
|
-
return input.map(address => address);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
218
|
-
return input;
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
// Map any tuple types into arrays
|
|
222
|
-
const typesToReturn = types.map(genType);
|
|
223
|
-
|
|
224
|
-
// defaultAbiCoder attaches some unwanted properties to the list object
|
|
225
|
-
_inputs = deepRemoveUnwantedArrayProperties(_inputs);
|
|
226
|
-
result = {
|
|
227
|
-
methodName,
|
|
228
|
-
method,
|
|
229
|
-
types: typesToReturn,
|
|
230
|
-
inputs: _inputs,
|
|
231
|
-
names
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
} catch (err) {
|
|
235
|
-
console.log(err);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (!result.method) {
|
|
239
|
-
for (const obj of this.abi) {
|
|
240
|
-
if (obj.type === 'constructor') {
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
if (obj.type === 'event') {
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
const method = obj.name || null;
|
|
247
|
-
try {
|
|
248
|
-
const ifc = new _ethers.ethers.utils.Interface([]);
|
|
249
|
-
const _result = ifc.decodeFunctionData(_ethers.ethers.utils.FunctionFragment.fromObject(obj), data);
|
|
250
|
-
const inputs = deepRemoveUnwantedArrayProperties(_result);
|
|
251
|
-
result.method = method;
|
|
252
|
-
result.methodName = getMethodName(obj);
|
|
253
|
-
result.inputs = inputs;
|
|
254
|
-
result.names = obj.inputs ? obj.inputs.map(x => {
|
|
255
|
-
if (x.type.includes('tuple')) {
|
|
256
|
-
var _x$components;
|
|
257
|
-
return [x.name, ((_x$components = x.components) === null || _x$components === void 0 ? void 0 : _x$components.map(a => a.name)) || ''];
|
|
258
|
-
} else {
|
|
259
|
-
return x.name;
|
|
260
|
-
}
|
|
261
|
-
}) : [];
|
|
262
|
-
const types = obj.inputs ? obj.inputs.map(x => {
|
|
263
|
-
if (x.type.includes('tuple')) {
|
|
264
|
-
return x;
|
|
265
|
-
} else {
|
|
266
|
-
return x.type;
|
|
267
|
-
}
|
|
268
|
-
}) : [];
|
|
269
|
-
result.types = types.map(genType);
|
|
270
|
-
} catch (err) {}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (!result.method) {
|
|
274
|
-
try {
|
|
275
|
-
const decoded = this.decodeConstructor(data);
|
|
276
|
-
if (decoded) {
|
|
277
|
-
return decoded;
|
|
278
|
-
}
|
|
279
|
-
} catch (err) {}
|
|
280
|
-
}
|
|
281
|
-
return result;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
exports.InputDataDecoder = InputDataDecoder;
|
package/koni/page/index.d.ts
DELETED
package/koni/page/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
// the enable function, called by the dapp to allow access
|
|
5
|
-
import { SubWalletEvmProvider } from '@subwallet/extension-base/koni/page/SubWalleEvmProvider';
|
|
6
|
-
import { sendMessage } from '@subwallet/extension-base/page';
|
|
7
|
-
export function initEvmProvider(version) {
|
|
8
|
-
return new SubWalletEvmProvider(sendMessage, version);
|
|
9
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|