@subwallet/extension-base 1.1.35-0 → 1.1.35-beta.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 +111 -69
- package/background/KoniTypes.js +19 -13
- package/background/errors/TransactionError.js +9 -0
- package/cjs/background/KoniTypes.js +20 -16
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/constants/index.js +19 -4
- package/cjs/koni/api/dotsama/balance.js +464 -0
- package/cjs/koni/api/nft/config.js +33 -23
- package/cjs/koni/api/nft/index.js +14 -0
- package/cjs/koni/api/nft/nft.js +1 -22
- package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
- package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
- package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +19 -16
- package/cjs/koni/api/staking/bonding/astar.js +11 -10
- package/cjs/koni/api/staking/bonding/index.js +4 -1
- package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
- package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
- package/cjs/koni/api/staking/bonding/utils.js +104 -86
- package/cjs/koni/api/staking/index.js +6 -5
- package/cjs/koni/api/staking/paraChain.js +6 -5
- package/cjs/koni/api/staking/relayChain.js +3 -2
- package/cjs/koni/api/yield/helper/utils.js +46 -0
- package/cjs/koni/background/cron.js +3 -21
- package/cjs/koni/background/handlers/Extension.js +368 -69
- package/cjs/koni/background/handlers/State.js +18 -12
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +7 -104
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +1 -16
- package/cjs/services/chain-service/index.js +6 -2
- package/cjs/services/chain-service/utils.js +7 -1
- package/cjs/services/earning-service/constants/chains.js +30 -0
- package/cjs/services/earning-service/constants/index.js +27 -0
- package/cjs/services/earning-service/constants/step.js +18 -0
- package/cjs/services/earning-service/handlers/base.js +262 -0
- package/cjs/services/earning-service/handlers/index.js +60 -0
- package/cjs/services/earning-service/handlers/lending/base.js +81 -0
- package/cjs/services/earning-service/handlers/lending/index.js +13 -0
- package/cjs/services/earning-service/handlers/lending/interlay.js +192 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +240 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +97 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +140 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +298 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +227 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +404 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +434 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +466 -0
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +161 -0
- package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +390 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +567 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +566 -0
- package/cjs/services/earning-service/handlers/special.js +493 -0
- package/cjs/services/earning-service/service.js +733 -0
- package/cjs/services/earning-service/utils/index.js +128 -0
- package/cjs/services/event-service/index.js +5 -0
- package/cjs/services/keyring-service/index.js +14 -2
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
- package/cjs/services/migration-service/scripts/index.js +6 -1
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
- package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
- package/cjs/services/mint-campaign-service/constants.js +11 -0
- package/cjs/services/mint-campaign-service/index.js +18 -0
- package/cjs/services/notification-service/NotificationService.js +3 -2
- package/cjs/services/request-service/handler/PopupHandler.js +2 -3
- package/cjs/services/storage-service/DatabaseService.js +63 -0
- package/cjs/services/storage-service/databases/index.js +4 -0
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +36 -0
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +71 -0
- package/cjs/services/storage-service/index.js +241 -0
- package/cjs/services/subscan-service/index.js +16 -0
- package/cjs/services/transaction-service/event-parser/index.js +58 -0
- package/cjs/services/transaction-service/helpers/index.js +3 -1
- package/cjs/services/transaction-service/index.js +249 -75
- package/cjs/services/transaction-service/utils.js +1 -0
- package/cjs/types/campaigns/index.js +16 -0
- package/cjs/types/campaigns/unlock-dot.js +1 -0
- package/cjs/types/index.js +44 -0
- package/cjs/types/ordinal.js +1 -0
- package/cjs/types/transaction.js +1 -0
- package/cjs/types/yield/actions/index.js +27 -0
- package/cjs/types/yield/actions/join/index.js +38 -0
- package/cjs/types/yield/actions/join/step.js +47 -0
- package/cjs/types/yield/actions/join/submit.js +1 -0
- package/cjs/types/yield/actions/join/validate.js +16 -0
- package/cjs/types/yield/actions/others.js +1 -0
- package/cjs/types/yield/index.js +27 -0
- package/cjs/types/yield/info/account/index.js +49 -0
- package/cjs/types/yield/info/account/info.js +1 -0
- package/cjs/types/yield/info/account/reward.js +1 -0
- package/cjs/types/yield/info/account/target.js +32 -0
- package/cjs/types/yield/info/account/unstake.js +27 -0
- package/cjs/types/yield/info/base.js +41 -0
- package/cjs/types/yield/info/chain/index.js +27 -0
- package/cjs/types/yield/info/chain/info.js +1 -0
- package/cjs/types/yield/info/chain/target.js +1 -0
- package/cjs/types/yield/info/index.js +49 -0
- package/cjs/types/yield/info/pallet.js +15 -0
- package/cjs/types.js +1 -0
- package/cjs/utils/address.js +34 -0
- package/cjs/utils/environment.js +23 -28
- package/cjs/utils/fetchStaticCache.js +22 -0
- package/cjs/utils/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +94 -10
- package/cjs/utils/keyring.js +57 -0
- package/cjs/utils/mv3.js +14 -0
- package/cjs/utils/number.js +6 -2
- package/cjs/utils/object.js +12 -0
- package/constants/index.d.ts +6 -1
- package/constants/index.js +6 -1
- package/koni/api/nft/config.js +33 -23
- package/koni/api/nft/index.js +15 -1
- package/koni/api/nft/nft.js +2 -23
- package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
- package/koni/api/nft/ordinal_nft/constants.js +12 -0
- package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
- package/koni/api/nft/ordinal_nft/index.js +114 -0
- package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
- package/koni/api/nft/ordinal_nft/utils.js +33 -0
- package/koni/api/staking/bonding/amplitude.js +13 -10
- package/koni/api/staking/bonding/astar.js +9 -8
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +5 -1
- package/koni/api/staking/bonding/paraChain.js +12 -10
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +33 -30
- package/koni/api/staking/bonding/utils.d.ts +15 -38
- package/koni/api/staking/bonding/utils.js +85 -69
- package/koni/api/staking/index.js +2 -1
- package/koni/api/staking/paraChain.js +7 -6
- package/koni/api/staking/relayChain.js +4 -3
- package/koni/api/yield/helper/utils.d.ts +10 -0
- package/koni/api/yield/helper/utils.js +32 -0
- package/koni/background/cron.d.ts +0 -4
- package/koni/background/cron.js +4 -22
- package/koni/background/handlers/Extension.d.ts +17 -1
- package/koni/background/handlers/Extension.js +327 -30
- package/koni/background/handlers/State.d.ts +6 -1
- package/koni/background/handlers/State.js +17 -12
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +1 -6
- package/koni/background/subscription.js +8 -104
- package/package.json +326 -3
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +0 -12
- package/services/chain-service/constants.js +0 -14
- package/services/chain-service/index.js +6 -2
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +5 -1
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +1235 -0
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +1355 -0
- package/services/earning-service/constants/chains.d.ts +15 -0
- package/services/earning-service/constants/chains.js +22 -0
- package/services/earning-service/constants/index.d.ts +2 -0
- package/services/earning-service/constants/index.js +5 -0
- package/services/earning-service/constants/step.d.ts +3 -0
- package/services/earning-service/constants/step.js +10 -0
- package/services/earning-service/handlers/base.d.ts +113 -0
- package/services/earning-service/handlers/base.js +256 -0
- package/services/earning-service/handlers/index.d.ts +5 -0
- package/services/earning-service/handlers/index.js +8 -0
- package/services/earning-service/handlers/lending/base.d.ts +8 -0
- package/services/earning-service/handlers/lending/base.js +73 -0
- package/services/earning-service/handlers/lending/index.d.ts +1 -0
- package/services/earning-service/handlers/lending/index.js +4 -0
- package/services/earning-service/handlers/lending/interlay.d.ts +24 -0
- package/services/earning-service/handlers/lending/interlay.js +184 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +232 -0
- package/services/earning-service/handlers/liquid-staking/base.d.ts +11 -0
- package/services/earning-service/handlers/liquid-staking/base.js +89 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +287 -0
- package/services/earning-service/handlers/liquid-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/liquid-staking/index.js +7 -0
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +26 -0
- package/services/earning-service/handlers/liquid-staking/parallel.js +219 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +394 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +425 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/astar.js +456 -0
- package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
- package/services/earning-service/handlers/native-staking/base-para.js +138 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/base.js +152 -0
- package/services/earning-service/handlers/native-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/index.js +7 -0
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +15 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +382 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
- package/services/earning-service/handlers/nomination-pool/index.js +556 -0
- package/services/earning-service/handlers/special.d.ts +64 -0
- package/services/earning-service/handlers/special.js +485 -0
- package/services/earning-service/service.d.ts +94 -0
- package/services/earning-service/service.js +722 -0
- package/services/earning-service/utils/index.d.ts +18 -0
- package/services/earning-service/utils/index.js +112 -0
- package/services/event-service/index.d.ts +2 -0
- package/services/event-service/index.js +5 -0
- package/services/event-service/types.d.ts +9 -0
- package/services/keyring-service/index.d.ts +2 -1
- package/services/keyring-service/index.js +14 -2
- package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
- package/services/migration-service/scripts/DeleteEarningData.js +13 -0
- package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
- package/services/migration-service/scripts/EnableEarningChains.js +13 -0
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
- package/services/migration-service/scripts/index.js +6 -1
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
- package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
- package/services/mint-campaign-service/campaigns/index.js +4 -0
- package/services/mint-campaign-service/constants.d.ts +1 -0
- package/services/mint-campaign-service/constants.js +4 -0
- package/services/mint-campaign-service/index.d.ts +7 -0
- package/services/mint-campaign-service/index.js +11 -0
- package/services/notification-service/NotificationService.js +3 -2
- package/services/request-service/handler/PopupHandler.js +3 -4
- package/services/storage-service/DatabaseService.d.ts +22 -1
- package/services/storage-service/DatabaseService.js +63 -0
- package/services/storage-service/databases/index.d.ts +3 -1
- package/services/storage-service/databases/index.js +4 -0
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +10 -0
- package/services/storage-service/db-stores/YieldPoolStore.js +28 -0
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +11 -0
- package/services/storage-service/db-stores/YieldPositionStore.js +63 -0
- package/services/subscan-service/index.d.ts +3 -2
- package/services/subscan-service/index.js +15 -0
- package/services/subscan-service/types.d.ts +20 -0
- package/services/transaction-service/event-parser/index.d.ts +3 -1
- package/services/transaction-service/event-parser/index.js +57 -1
- package/services/transaction-service/helpers/index.js +3 -1
- package/services/transaction-service/index.d.ts +6 -13
- package/services/transaction-service/index.js +247 -73
- package/services/transaction-service/types.d.ts +2 -0
- package/services/transaction-service/utils.js +1 -0
- package/types/campaigns/index.d.ts +1 -0
- package/types/campaigns/index.js +4 -0
- package/types/campaigns/unlock-dot.d.ts +71 -0
- package/types/campaigns/unlock-dot.js +1 -0
- package/types/index.d.ts +5 -0
- package/types/index.js +5 -1
- package/types/ordinal.d.ts +69 -0
- package/types/ordinal.js +1 -0
- package/types/transaction.d.ts +3 -0
- package/types/transaction.js +1 -0
- package/types/yield/actions/index.d.ts +2 -0
- package/types/yield/actions/index.js +5 -0
- package/types/yield/actions/join/index.d.ts +3 -0
- package/types/yield/actions/join/index.js +6 -0
- package/types/yield/actions/join/step.d.ts +95 -0
- package/types/yield/actions/join/step.js +46 -0
- package/types/yield/actions/join/submit.d.ts +58 -0
- package/types/yield/actions/join/submit.js +1 -0
- package/types/yield/actions/join/validate.d.ts +18 -0
- package/types/yield/actions/join/validate.js +10 -0
- package/types/yield/actions/others.d.ts +85 -0
- package/types/yield/actions/others.js +1 -0
- package/types/yield/index.d.ts +2 -0
- package/types/yield/index.js +5 -0
- package/types/yield/info/account/index.d.ts +4 -0
- package/types/yield/info/account/index.js +7 -0
- package/types/yield/info/account/info.d.ts +92 -0
- package/types/yield/info/account/info.js +1 -0
- package/types/yield/info/account/reward.d.ts +47 -0
- package/types/yield/info/account/reward.js +1 -0
- package/types/yield/info/account/target.d.ts +43 -0
- package/types/yield/info/account/target.js +27 -0
- package/types/yield/info/account/unstake.d.ts +31 -0
- package/types/yield/info/account/unstake.js +22 -0
- package/types/yield/info/base.d.ts +45 -0
- package/types/yield/info/base.js +36 -0
- package/types/yield/info/chain/index.d.ts +2 -0
- package/types/yield/info/chain/index.js +5 -0
- package/types/yield/info/chain/info.d.ts +252 -0
- package/types/yield/info/chain/info.js +1 -0
- package/types/yield/info/chain/target.d.ts +37 -0
- package/types/yield/info/chain/target.js +1 -0
- package/types/yield/info/index.d.ts +4 -0
- package/types/yield/info/index.js +7 -0
- package/types/yield/info/pallet.d.ts +143 -0
- package/types/yield/info/pallet.js +9 -0
- package/utils/environment.d.ts +9 -2
- package/utils/environment.js +14 -26
- package/utils/fetchStaticCache.d.ts +1 -0
- package/utils/fetchStaticCache.js +14 -0
- package/utils/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -1
- package/utils/index.js +53 -3
- package/utils/mv3.d.ts +2 -0
- package/utils/mv3.js +6 -0
- package/utils/number.d.ts +2 -1
- package/utils/number.js +2 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN } from '@polkadot/util';
|
|
3
|
+
export interface PalletNominationPoolsPoolMember {
|
|
4
|
+
poolId: number;
|
|
5
|
+
points: number;
|
|
6
|
+
lasRecordedRewardCounter: number;
|
|
7
|
+
unbondingEras: Record<string, number>;
|
|
8
|
+
}
|
|
9
|
+
export interface PalletStakingExposureItem {
|
|
10
|
+
who: string;
|
|
11
|
+
value: number;
|
|
12
|
+
}
|
|
13
|
+
export interface PalletStakingExposure {
|
|
14
|
+
total: number;
|
|
15
|
+
own: number;
|
|
16
|
+
others: PalletStakingExposureItem[];
|
|
17
|
+
}
|
|
18
|
+
export interface PalletDappsStakingDappInfo {
|
|
19
|
+
address: string;
|
|
20
|
+
name: string;
|
|
21
|
+
gitHubUrl: string;
|
|
22
|
+
tags: string[];
|
|
23
|
+
url: string;
|
|
24
|
+
imagesUrl: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface PalletDappsStakingUnlockingChunk {
|
|
27
|
+
amount: number;
|
|
28
|
+
unlockEra: number;
|
|
29
|
+
}
|
|
30
|
+
export interface PalletDappsStakingAccountLedger {
|
|
31
|
+
locked: number;
|
|
32
|
+
unbondingInfo: {
|
|
33
|
+
unlockingChunks: PalletDappsStakingUnlockingChunk[];
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface BlockHeader {
|
|
37
|
+
parentHash: string;
|
|
38
|
+
number: number;
|
|
39
|
+
stateRoot: string;
|
|
40
|
+
extrinsicsRoot: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ParachainStakingStakeOption {
|
|
43
|
+
owner: string;
|
|
44
|
+
amount: number;
|
|
45
|
+
}
|
|
46
|
+
export interface ParachainStakingCandidateMetadata {
|
|
47
|
+
bond: string;
|
|
48
|
+
delegationCount: number;
|
|
49
|
+
totalCounted: string;
|
|
50
|
+
lowestTopDelegationAmount: string;
|
|
51
|
+
status: any | 'Active';
|
|
52
|
+
}
|
|
53
|
+
export declare enum PalletParachainStakingRequestType {
|
|
54
|
+
REVOKE = "revoke",
|
|
55
|
+
DECREASE = "decrease",
|
|
56
|
+
BOND_LESS = "bondLess"
|
|
57
|
+
}
|
|
58
|
+
export interface PalletParachainStakingDelegationRequestsScheduledRequest {
|
|
59
|
+
delegator: string;
|
|
60
|
+
whenExecutable: number;
|
|
61
|
+
action: Record<PalletParachainStakingRequestType, number>;
|
|
62
|
+
}
|
|
63
|
+
export interface PalletParachainStakingDelegationInfo {
|
|
64
|
+
owner: string;
|
|
65
|
+
amount: number;
|
|
66
|
+
}
|
|
67
|
+
export interface PalletParachainStakingDelegator {
|
|
68
|
+
id: string;
|
|
69
|
+
delegations: PalletParachainStakingDelegationInfo[];
|
|
70
|
+
total: number;
|
|
71
|
+
lessTotal: number;
|
|
72
|
+
status: number;
|
|
73
|
+
}
|
|
74
|
+
export interface PalletIdentityRegistration {
|
|
75
|
+
judgements: any[];
|
|
76
|
+
deposit: number;
|
|
77
|
+
info: {
|
|
78
|
+
display: {
|
|
79
|
+
Raw: string;
|
|
80
|
+
};
|
|
81
|
+
web: {
|
|
82
|
+
Raw: string;
|
|
83
|
+
};
|
|
84
|
+
twitter: {
|
|
85
|
+
Raw: string;
|
|
86
|
+
};
|
|
87
|
+
riot: {
|
|
88
|
+
Raw: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export declare type PalletIdentitySuper = [string, {
|
|
93
|
+
Raw: string;
|
|
94
|
+
}];
|
|
95
|
+
export interface Unlocking {
|
|
96
|
+
remainingEras: BN;
|
|
97
|
+
value: BN;
|
|
98
|
+
}
|
|
99
|
+
export interface TernoaStakingRewardsStakingRewardsData {
|
|
100
|
+
sessionEraPayout: string;
|
|
101
|
+
sessionExtraRewardPayout: string;
|
|
102
|
+
}
|
|
103
|
+
export interface ValidatorExtraInfo {
|
|
104
|
+
commission: string;
|
|
105
|
+
blocked: false;
|
|
106
|
+
identity?: string;
|
|
107
|
+
isVerified: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface PalletNominationPoolsBondedPoolInner {
|
|
110
|
+
points: number;
|
|
111
|
+
state: 'Open' | 'Destroying' | 'Locked';
|
|
112
|
+
memberCounter: number;
|
|
113
|
+
roles: {
|
|
114
|
+
depositor: string;
|
|
115
|
+
root: string;
|
|
116
|
+
nominator: string;
|
|
117
|
+
bouncer: string;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export interface PalletStakingNominations {
|
|
121
|
+
targets: string[];
|
|
122
|
+
submittedIn: number;
|
|
123
|
+
suppressed: boolean;
|
|
124
|
+
}
|
|
125
|
+
export interface UnlockingChunk {
|
|
126
|
+
value: number;
|
|
127
|
+
era: number;
|
|
128
|
+
}
|
|
129
|
+
export interface PalletStakingStakingLedger {
|
|
130
|
+
stash: string;
|
|
131
|
+
total: number;
|
|
132
|
+
active: number;
|
|
133
|
+
unlocking: UnlockingChunk[];
|
|
134
|
+
claimedRewards: number[];
|
|
135
|
+
}
|
|
136
|
+
export interface RuntimeDispatchInfo {
|
|
137
|
+
weight: {
|
|
138
|
+
refTime: number;
|
|
139
|
+
proofSize: number;
|
|
140
|
+
};
|
|
141
|
+
class: string;
|
|
142
|
+
partialFee: number;
|
|
143
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export let PalletParachainStakingRequestType;
|
|
5
|
+
(function (PalletParachainStakingRequestType) {
|
|
6
|
+
PalletParachainStakingRequestType["REVOKE"] = "revoke";
|
|
7
|
+
PalletParachainStakingRequestType["DECREASE"] = "decrease";
|
|
8
|
+
PalletParachainStakingRequestType["BOND_LESS"] = "bondLess";
|
|
9
|
+
})(PalletParachainStakingRequestType || (PalletParachainStakingRequestType = {}));
|
package/utils/environment.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Bowser from 'bowser';
|
|
2
|
+
import { EnvironmentSupport, RuntimeEnvironmentInfo, TargetEnvironment } from '../background/KoniTypes';
|
|
2
3
|
export declare const RuntimeInfo: RuntimeEnvironmentInfo;
|
|
3
|
-
export declare const
|
|
4
|
+
export declare const BowserParser: Bowser.Parser.Parser;
|
|
5
|
+
export declare const isFirefox: boolean;
|
|
6
|
+
export declare const osName: string;
|
|
7
|
+
export declare const isMobile: boolean;
|
|
4
8
|
export declare const TARGET_ENV: TargetEnvironment;
|
|
9
|
+
export declare const targetIsExtension: boolean;
|
|
10
|
+
export declare const targetIsWeb: boolean;
|
|
11
|
+
export declare const targetIsMobile: boolean;
|
|
5
12
|
export declare const MODULE_SUPPORT: EnvironmentSupport;
|
package/utils/environment.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { isSupportWindow } from '@subwallet/extension-base/utils/mv3';
|
|
5
|
+
import Bowser from 'bowser';
|
|
4
6
|
import { RuntimeEnvironment } from "../background/KoniTypes.js";
|
|
5
7
|
function detectRuntimeEnvironment() {
|
|
6
|
-
if (
|
|
8
|
+
if (isSupportWindow) {
|
|
7
9
|
// Web environment
|
|
8
10
|
return {
|
|
9
11
|
environment: RuntimeEnvironment.Web,
|
|
@@ -17,7 +19,7 @@ function detectRuntimeEnvironment() {
|
|
|
17
19
|
environment: RuntimeEnvironment.ServiceWorker,
|
|
18
20
|
version: navigator.userAgent,
|
|
19
21
|
host: self.location.host,
|
|
20
|
-
protocol:
|
|
22
|
+
protocol: 'https'
|
|
21
23
|
};
|
|
22
24
|
} else if (typeof process !== 'undefined' && process.versions && process.versions.node) {
|
|
23
25
|
// Node.js environment
|
|
@@ -57,30 +59,16 @@ function detectRuntimeEnvironment() {
|
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
export const RuntimeInfo = detectRuntimeEnvironment();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K', 'macOS'];
|
|
67
|
-
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
|
|
68
|
-
const iosPlatforms = ['iPhone', 'iPad', 'iPod'];
|
|
69
|
-
let os = 'Unknown';
|
|
70
|
-
if (macosPlatforms.indexOf(platform) !== -1) {
|
|
71
|
-
os = 'Mac OS';
|
|
72
|
-
} else if (iosPlatforms.indexOf(platform) !== -1) {
|
|
73
|
-
os = 'iOS';
|
|
74
|
-
} else if (windowsPlatforms.indexOf(platform) !== -1) {
|
|
75
|
-
os = 'Windows';
|
|
76
|
-
} else if (/Android/.test(userAgent)) {
|
|
77
|
-
os = 'Android';
|
|
78
|
-
} else if (/Linux/.test(platform)) {
|
|
79
|
-
os = 'Linux';
|
|
80
|
-
}
|
|
81
|
-
return os;
|
|
82
|
-
};
|
|
62
|
+
|
|
63
|
+
// Todo: Support more in backend case
|
|
64
|
+
export const BowserParser = Bowser.getParser(typeof navigator !== 'undefined' ? navigator.userAgent : '');
|
|
65
|
+
export const isFirefox = BowserParser.getBrowserName(true) === 'firefox';
|
|
66
|
+
export const osName = BowserParser.getOSName();
|
|
67
|
+
export const isMobile = BowserParser.getPlatform().type === 'mobile';
|
|
83
68
|
export const TARGET_ENV = process.env.TARGET_ENV || 'extension';
|
|
69
|
+
export const targetIsExtension = TARGET_ENV === 'extension';
|
|
70
|
+
export const targetIsWeb = TARGET_ENV === 'webapp';
|
|
71
|
+
export const targetIsMobile = TARGET_ENV === 'mobile';
|
|
84
72
|
export const MODULE_SUPPORT = {
|
|
85
|
-
MANTA_ZK:
|
|
73
|
+
MANTA_ZK: targetIsExtension
|
|
86
74
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fetchStaticCache<T>(slug: string, defaultData: T, timeout?: number): Promise<T>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
export async function fetchStaticCache(slug, defaultData, timeout = 9000) {
|
|
6
|
+
try {
|
|
7
|
+
const rs = await axios.get(`https://static-cache.subwallet.app/${slug}`, {
|
|
8
|
+
timeout
|
|
9
|
+
});
|
|
10
|
+
return rs.data;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
return defaultData;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/utils/fetchStaticData.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
import { staticData } from '@subwallet/extension-base/utils/staticData';
|
|
5
5
|
import axios from 'axios';
|
|
6
|
+
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
6
7
|
const branchName = process.env.BRANCH_NAME || 'koni-dev';
|
|
7
|
-
const fetchTarget = branchName
|
|
8
|
+
const fetchTarget = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
8
9
|
export async function fetchStaticData(slug, targetFile) {
|
|
9
10
|
const fetchFile = targetFile || fetchTarget;
|
|
10
11
|
try {
|
package/utils/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare const isDef: (x: any) => boolean;
|
|
|
8
8
|
export declare const nonEmptyArr: (x: any) => boolean;
|
|
9
9
|
export declare const isEmptyArray: (x: any) => boolean;
|
|
10
10
|
export declare function isAccountAll(address?: string): boolean;
|
|
11
|
-
export declare const isMobile: boolean;
|
|
12
11
|
export declare function reformatAddress(address: string, networkPrefix?: number, isEthereum?: boolean): string;
|
|
13
12
|
export declare function filterAddressByNetworkKey(addresses: string[], networkKey: string, isEthereum?: boolean): string[];
|
|
14
13
|
export declare function categoryAddresses(addresses: string[]): string[][];
|
|
@@ -39,12 +38,17 @@ export declare function isSameAddress(address1: string, address2: string): boole
|
|
|
39
38
|
export declare function getDomainFromUrl(url: string): string;
|
|
40
39
|
export declare function waitTimeout(ms: number): Promise<void>;
|
|
41
40
|
export declare const stripUrl: (url: string) => string;
|
|
41
|
+
export declare const baseParseIPFSUrl: (input: string) => string | undefined;
|
|
42
|
+
export declare const swParseIPFSUrl: (input: string) => string | undefined;
|
|
42
43
|
export declare function wait(milliseconds: number): Promise<void>;
|
|
43
44
|
export * from './account';
|
|
44
45
|
export * from './array';
|
|
45
46
|
export * from './environment';
|
|
47
|
+
export * from './number';
|
|
46
48
|
export * from './lazy';
|
|
49
|
+
export * from './promise';
|
|
47
50
|
export * from './registry';
|
|
48
51
|
export * from './translate';
|
|
52
|
+
export * from './object';
|
|
49
53
|
export * from './fetchStaticData';
|
|
50
54
|
export * from './fetchEvmChainInfo';
|
package/utils/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { CrowdloanParaState
|
|
4
|
+
import { CrowdloanParaState } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
6
|
-
import {
|
|
6
|
+
import { getRandomIpfsGateway, SUBWALLET_IPFS } from '@subwallet/extension-base/koni/api/nft/config';
|
|
7
7
|
import { t } from 'i18next';
|
|
8
8
|
import { assert, BN, hexToU8a, isHex } from '@polkadot/util';
|
|
9
9
|
import { decodeAddress, encodeAddress, ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -15,7 +15,6 @@ export const isEmptyArray = x => !Array.isArray(x) || Array.isArray(x) && x.leng
|
|
|
15
15
|
export function isAccountAll(address) {
|
|
16
16
|
return address === ALL_ACCOUNT_KEY;
|
|
17
17
|
}
|
|
18
|
-
export const isMobile = MobileOS.includes(getOS());
|
|
19
18
|
export function reformatAddress(address, networkPrefix = 42, isEthereum = false) {
|
|
20
19
|
try {
|
|
21
20
|
if (!address || address === '') {
|
|
@@ -287,6 +286,54 @@ export const stripUrl = url => {
|
|
|
287
286
|
const parts = url.split('/');
|
|
288
287
|
return parts[2];
|
|
289
288
|
};
|
|
289
|
+
export const baseParseIPFSUrl = input => {
|
|
290
|
+
if (!input || input.length === 0) {
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
if (isUrl(input)) {
|
|
294
|
+
return input;
|
|
295
|
+
}
|
|
296
|
+
if (isUrl(input) || input.includes('https://') || input.includes('http')) {
|
|
297
|
+
return input;
|
|
298
|
+
}
|
|
299
|
+
if (input.startsWith('/ipfs/')) {
|
|
300
|
+
return getRandomIpfsGateway() + input.split('/ipfs/')[1];
|
|
301
|
+
}
|
|
302
|
+
if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
303
|
+
// just the IPFS hash
|
|
304
|
+
return getRandomIpfsGateway() + input;
|
|
305
|
+
}
|
|
306
|
+
if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
307
|
+
// starts with ipfs://
|
|
308
|
+
return getRandomIpfsGateway() + input.split('ipfs://')[1];
|
|
309
|
+
}
|
|
310
|
+
return getRandomIpfsGateway() + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export const swParseIPFSUrl = input => {
|
|
314
|
+
if (!input || input.length === 0) {
|
|
315
|
+
return undefined;
|
|
316
|
+
}
|
|
317
|
+
if (isUrl(input)) {
|
|
318
|
+
return input;
|
|
319
|
+
}
|
|
320
|
+
if (isUrl(input) || input.includes('https://') || input.includes('http')) {
|
|
321
|
+
return input;
|
|
322
|
+
}
|
|
323
|
+
if (input.startsWith('/ipfs/')) {
|
|
324
|
+
return SUBWALLET_IPFS + input.split('/ipfs/')[1];
|
|
325
|
+
}
|
|
326
|
+
if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
327
|
+
// just the IPFS hash
|
|
328
|
+
return SUBWALLET_IPFS + input;
|
|
329
|
+
}
|
|
330
|
+
if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
331
|
+
// starts with ipfs://
|
|
332
|
+
return SUBWALLET_IPFS + input.split('ipfs://')[1];
|
|
333
|
+
}
|
|
334
|
+
return SUBWALLET_IPFS + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
335
|
+
};
|
|
336
|
+
|
|
290
337
|
export function wait(milliseconds) {
|
|
291
338
|
return new Promise(resolve => {
|
|
292
339
|
setTimeout(() => {
|
|
@@ -297,8 +344,11 @@ export function wait(milliseconds) {
|
|
|
297
344
|
export * from "./account.js";
|
|
298
345
|
export * from "./array.js";
|
|
299
346
|
export * from "./environment.js";
|
|
347
|
+
export * from "./number.js";
|
|
300
348
|
export * from "./lazy.js";
|
|
349
|
+
export * from "./promise.js";
|
|
301
350
|
export * from "./registry.js";
|
|
302
351
|
export * from "./translate.js";
|
|
352
|
+
export * from "./object.js";
|
|
303
353
|
export * from "./fetchStaticData.js";
|
|
304
354
|
export * from "./fetchEvmChainInfo.js";
|
package/utils/mv3.d.ts
ADDED
package/utils/mv3.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var _chrome, _chrome$runtime, _chrome$runtime$getMa;
|
|
2
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
export const isManifestV3 = ((_chrome = chrome) === null || _chrome === void 0 ? void 0 : (_chrome$runtime = _chrome.runtime) === null || _chrome$runtime === void 0 ? void 0 : (_chrome$runtime$getMa = _chrome$runtime.getManifest()) === null || _chrome$runtime$getMa === void 0 ? void 0 : _chrome$runtime$getMa.manifest_version) === 3;
|
|
6
|
+
export const isSupportWindow = typeof window !== 'undefined';
|
package/utils/number.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
+
export declare const BN_ZERO: BigNumber;
|
|
2
3
|
export declare const BN_TEN: BigNumber;
|
|
3
4
|
export interface NumberFormatter {
|
|
4
5
|
(input: string, metadata?: Record<string, number>): string;
|
|
@@ -6,4 +7,4 @@ export interface NumberFormatter {
|
|
|
6
7
|
export declare const balanceFormatter: NumberFormatter;
|
|
7
8
|
export declare const PREDEFINED_FORMATTER: Record<string, NumberFormatter>;
|
|
8
9
|
export declare const toBNString: (input: string | number | BigNumber, decimal: number) => string;
|
|
9
|
-
export declare const formatNumber: (input: string | number | BigNumber, decimal: number, formatter
|
|
10
|
+
export declare const formatNumber: (input: string | number | BigNumber, decimal: number, formatter?: NumberFormatter, metadata?: Record<string, number>) => string;
|
package/utils/number.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import BigNumber from 'bignumber.js';
|
|
5
|
+
export const BN_ZERO = new BigNumber(0);
|
|
5
6
|
export const BN_TEN = new BigNumber(10);
|
|
6
7
|
// Clear zero from end, use with decimal only
|
|
7
8
|
const clearZero = result => {
|
|
@@ -94,7 +95,7 @@ export const toBNString = (input, decimal) => {
|
|
|
94
95
|
const raw = new BigNumber(input);
|
|
95
96
|
return raw.multipliedBy(BN_TEN.pow(decimal)).toFixed();
|
|
96
97
|
};
|
|
97
|
-
export const formatNumber = (input, decimal, formatter, metadata) => {
|
|
98
|
+
export const formatNumber = (input, decimal, formatter = balanceFormatter, metadata) => {
|
|
98
99
|
const raw = new BigNumber(input).dividedBy(BN_TEN.pow(decimal)).toFixed();
|
|
99
100
|
return formatter(raw, metadata);
|
|
100
101
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEmptyObject(input: Record<any, any>): boolean;
|