@subwallet/extension-base 1.3.69-0 → 1.3.70-2
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 +3 -0
- package/cjs/background/KoniTypes.js +3 -0
- package/cjs/koni/background/handlers/Extension.js +62 -0
- package/cjs/koni/background/handlers/State.js +5 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +15 -4
- package/cjs/services/chain-service/utils/index.js +13 -5
- package/cjs/services/event-service/index.js +1 -0
- package/cjs/services/open-gov/handler.js +563 -0
- package/cjs/services/open-gov/index.js +273 -0
- package/cjs/services/open-gov/interface.js +28 -0
- package/cjs/services/open-gov/utils.js +66 -0
- package/cjs/services/storage-service/DatabaseService.js +19 -1
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/GovLockedInfoStore.js +35 -0
- package/cjs/services/transaction-service/helpers/index.js +6 -0
- package/cjs/services/transaction-service/index.js +43 -0
- package/cjs/utils/account/transform.js +5 -4
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +62 -0
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +5 -2
- package/package.json +30 -5
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +8 -0
- package/services/chain-service/constants.js +12 -2
- package/services/chain-service/utils/index.js +13 -5
- 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/open-gov/handler.d.ts +27 -0
- package/services/open-gov/handler.js +547 -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 +21 -0
- package/services/open-gov/utils.d.ts +14 -0
- package/services/open-gov/utils.js +52 -0
- package/services/storage-service/DatabaseService.d.ts +7 -0
- package/services/storage-service/DatabaseService.js +19 -1
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/GovLockedInfoStore.d.ts +10 -0
- package/services/storage-service/db-stores/GovLockedInfoStore.js +27 -0
- package/services/transaction-service/helpers/index.js +6 -0
- package/services/transaction-service/index.js +43 -0
- package/utils/account/transform.js +5 -4
|
@@ -30,6 +30,7 @@ import MintCampaignService from '@subwallet/extension-base/services/mint-campaig
|
|
|
30
30
|
import MktCampaignService from '@subwallet/extension-base/services/mkt-campaign-service';
|
|
31
31
|
import NftService from '@subwallet/extension-base/services/nft-service';
|
|
32
32
|
import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
|
|
33
|
+
import OpenGovService from '@subwallet/extension-base/services/open-gov';
|
|
33
34
|
import { PriceService } from '@subwallet/extension-base/services/price-service';
|
|
34
35
|
import RequestService from '@subwallet/extension-base/services/request-service';
|
|
35
36
|
import { openPopup } from '@subwallet/extension-base/services/request-service/handler/PopupHandler';
|
|
@@ -119,6 +120,7 @@ export default class KoniState {
|
|
|
119
120
|
this.swapService = new SwapService(this);
|
|
120
121
|
this.inappNotificationService = new InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
|
|
121
122
|
this.chainOnlineService = new ChainOnlineService(this.chainService, this.settingService, this.eventService, this.dbService);
|
|
123
|
+
this.openGovService = new OpenGovService(this);
|
|
122
124
|
this.subscription = new KoniSubscription(this, this.dbService);
|
|
123
125
|
this.cron = new KoniCron(this, this.subscription, this.dbService);
|
|
124
126
|
this.logger = createLogger('State');
|
|
@@ -222,6 +224,7 @@ export default class KoniState {
|
|
|
222
224
|
await this.earningService.init();
|
|
223
225
|
await this.swapService.init();
|
|
224
226
|
await this.inappNotificationService.init();
|
|
227
|
+
await this.openGovService.init();
|
|
225
228
|
|
|
226
229
|
// this.onReady();
|
|
227
230
|
this.onAccountAdd();
|
|
@@ -1655,7 +1658,7 @@ export default class KoniState {
|
|
|
1655
1658
|
this.campaignService.stop();
|
|
1656
1659
|
await Promise.all([this.cron.stop(), this.subscription.stop()]);
|
|
1657
1660
|
await this.pauseAllNetworks(undefined, 'IDLE mode');
|
|
1658
|
-
await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop()]);
|
|
1661
|
+
await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop(), this.openGovService.stop()]);
|
|
1659
1662
|
|
|
1660
1663
|
// Complete sleeping
|
|
1661
1664
|
sleeping.resolve();
|
|
@@ -1711,7 +1714,7 @@ export default class KoniState {
|
|
|
1711
1714
|
this.generalStatus = ServiceStatus.STARTING_FULL;
|
|
1712
1715
|
const startingFull = createPromiseHandler();
|
|
1713
1716
|
this.waitStartingFull = startingFull.promise;
|
|
1714
|
-
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()]);
|
|
1717
|
+
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()]);
|
|
1715
1718
|
this.eventService.emit('general.start_full', true);
|
|
1716
1719
|
this.waitStartingFull = null;
|
|
1717
1720
|
this.generalStatus = ServiceStatus.STARTED_FULL;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.3.
|
|
20
|
+
"version": "1.3.70-2",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1721,6 +1721,26 @@
|
|
|
1721
1721
|
"require": "./cjs/services/notification-service/NotificationService.js",
|
|
1722
1722
|
"default": "./services/notification-service/NotificationService.js"
|
|
1723
1723
|
},
|
|
1724
|
+
"./services/open-gov": {
|
|
1725
|
+
"types": "./services/open-gov/index.d.ts",
|
|
1726
|
+
"require": "./cjs/services/open-gov/index.js",
|
|
1727
|
+
"default": "./services/open-gov/index.js"
|
|
1728
|
+
},
|
|
1729
|
+
"./services/open-gov/handler": {
|
|
1730
|
+
"types": "./services/open-gov/handler.d.ts",
|
|
1731
|
+
"require": "./cjs/services/open-gov/handler.js",
|
|
1732
|
+
"default": "./services/open-gov/handler.js"
|
|
1733
|
+
},
|
|
1734
|
+
"./services/open-gov/interface": {
|
|
1735
|
+
"types": "./services/open-gov/interface.d.ts",
|
|
1736
|
+
"require": "./cjs/services/open-gov/interface.js",
|
|
1737
|
+
"default": "./services/open-gov/interface.js"
|
|
1738
|
+
},
|
|
1739
|
+
"./services/open-gov/utils": {
|
|
1740
|
+
"types": "./services/open-gov/utils.d.ts",
|
|
1741
|
+
"require": "./cjs/services/open-gov/utils.js",
|
|
1742
|
+
"default": "./services/open-gov/utils.js"
|
|
1743
|
+
},
|
|
1724
1744
|
"./services/price-service": {
|
|
1725
1745
|
"types": "./services/price-service/index.d.ts",
|
|
1726
1746
|
"require": "./cjs/services/price-service/index.js",
|
|
@@ -1911,6 +1931,11 @@
|
|
|
1911
1931
|
"require": "./cjs/services/storage-service/db-stores/Crowdloan.js",
|
|
1912
1932
|
"default": "./services/storage-service/db-stores/Crowdloan.js"
|
|
1913
1933
|
},
|
|
1934
|
+
"./services/storage-service/db-stores/GovLockedInfoStore": {
|
|
1935
|
+
"types": "./services/storage-service/db-stores/GovLockedInfoStore.d.ts",
|
|
1936
|
+
"require": "./cjs/services/storage-service/db-stores/GovLockedInfoStore.js",
|
|
1937
|
+
"default": "./services/storage-service/db-stores/GovLockedInfoStore.js"
|
|
1938
|
+
},
|
|
1914
1939
|
"./services/storage-service/db-stores/InappNotification": {
|
|
1915
1940
|
"types": "./services/storage-service/db-stores/InappNotification.d.ts",
|
|
1916
1941
|
"require": "./cjs/services/storage-service/db-stores/InappNotification.js",
|
|
@@ -2919,10 +2944,10 @@
|
|
|
2919
2944
|
"@substrate/connect": "^0.8.9",
|
|
2920
2945
|
"@subwallet-monorepos/subwallet-services-sdk": "0.1.14",
|
|
2921
2946
|
"@subwallet/chain-list": "0.2.122",
|
|
2922
|
-
"@subwallet/extension-base": "^1.3.
|
|
2923
|
-
"@subwallet/extension-chains": "^1.3.
|
|
2924
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
2925
|
-
"@subwallet/extension-inject": "^1.3.
|
|
2947
|
+
"@subwallet/extension-base": "^1.3.70-2",
|
|
2948
|
+
"@subwallet/extension-chains": "^1.3.70-2",
|
|
2949
|
+
"@subwallet/extension-dapp": "^1.3.70-2",
|
|
2950
|
+
"@subwallet/extension-inject": "^1.3.70-2",
|
|
2926
2951
|
"@subwallet/keyring": "^0.1.13",
|
|
2927
2952
|
"@subwallet/ui-keyring": "^0.1.13",
|
|
2928
2953
|
"@ton/core": "^0.56.3",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.3.
|
|
10
|
+
version: '1.3.70-2'
|
|
11
11
|
};
|
|
@@ -10,6 +10,14 @@ export declare const _API_OPTIONS_CHAIN_GROUP: {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const _PREDEFINED_SINGLE_MODES: Record<string, SingleModeJson>;
|
|
12
12
|
export declare const _PURE_EVM_CHAINS: string[];
|
|
13
|
+
export declare const _GOVERNANCE_CHAIN_GROUP: {
|
|
14
|
+
polkadot: string[];
|
|
15
|
+
kusama: string[];
|
|
16
|
+
westend_assethub: string[];
|
|
17
|
+
paseo: string[];
|
|
18
|
+
solo: string[];
|
|
19
|
+
testnet: string[];
|
|
20
|
+
};
|
|
13
21
|
export declare const _BALANCE_CHAIN_GROUP: {
|
|
14
22
|
kintsugi: string[];
|
|
15
23
|
genshiro: string[];
|
|
@@ -20,6 +20,14 @@ export const _PREDEFINED_SINGLE_MODES = {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
export const _PURE_EVM_CHAINS = ['binance', 'binance_test', 'ethereum', 'ethereum_goerli', 'astarEvm', 'shidenEvm', 'shibuyaEvm', 'crabEvm', 'pangolinEvm', 'cloverEvm', 'boba_rinkeby', 'boba', 'bobabase', 'bobabeam', 'watr_network_evm'];
|
|
23
|
+
export const _GOVERNANCE_CHAIN_GROUP = {
|
|
24
|
+
polkadot: ['statemint', 'bifrost_dot', 'hydradx_main', 'ajunaPolkadot', 'astar', 'phala', 'litentry', 'acala', 'centrifuge', 'interlay', 'laos_network'],
|
|
25
|
+
kusama: ['statemine', 'bifrost', 'basilisk', 'karura', 'kintsugi'],
|
|
26
|
+
westend_assethub: ['westend_assethub'],
|
|
27
|
+
paseo: ['paseo_assethub'],
|
|
28
|
+
solo: ['vara_network', 'zkverify'],
|
|
29
|
+
testnet: ['zkverify_testnet']
|
|
30
|
+
};
|
|
23
31
|
|
|
24
32
|
// Get balance----------------------------------------------------------------------------------------------------------
|
|
25
33
|
|
|
@@ -126,6 +134,8 @@ export const _EXPECTED_BLOCK_TIME = {
|
|
|
126
134
|
statemint: 6,
|
|
127
135
|
statemine: 6,
|
|
128
136
|
polkadex: 12,
|
|
137
|
+
westend_assethub: 6,
|
|
138
|
+
paseo_assethub: 6,
|
|
129
139
|
ternoa: 6,
|
|
130
140
|
ternoa_alphanet: 6,
|
|
131
141
|
westend: 6,
|
|
@@ -136,8 +146,8 @@ export const _EXPECTED_BLOCK_TIME = {
|
|
|
136
146
|
vara_testnet: 3,
|
|
137
147
|
goldberg_testnet: 20,
|
|
138
148
|
polimec: 12,
|
|
139
|
-
bifrost:
|
|
140
|
-
//
|
|
149
|
+
bifrost: 6,
|
|
150
|
+
// bifrost kusama
|
|
141
151
|
moonbeam: 12,
|
|
142
152
|
moonriver: 12,
|
|
143
153
|
moonbase: 6,
|
|
@@ -289,28 +289,36 @@ export function _getChainNativeTokenBasicInfo(chainInfo) {
|
|
|
289
289
|
return defaultTokenInfo;
|
|
290
290
|
}
|
|
291
291
|
if (chainInfo.substrateInfo) {
|
|
292
|
-
// substrate by default
|
|
293
292
|
return {
|
|
293
|
+
...defaultTokenInfo,
|
|
294
294
|
symbol: chainInfo.substrateInfo.symbol,
|
|
295
295
|
decimals: chainInfo.substrateInfo.decimals
|
|
296
296
|
};
|
|
297
|
-
}
|
|
297
|
+
}
|
|
298
|
+
if (chainInfo.evmInfo) {
|
|
298
299
|
return {
|
|
300
|
+
...defaultTokenInfo,
|
|
299
301
|
symbol: chainInfo.evmInfo.symbol,
|
|
300
302
|
decimals: chainInfo.evmInfo.decimals
|
|
301
303
|
};
|
|
302
|
-
}
|
|
304
|
+
}
|
|
305
|
+
if (chainInfo.tonInfo) {
|
|
303
306
|
return {
|
|
307
|
+
...defaultTokenInfo,
|
|
304
308
|
symbol: chainInfo.tonInfo.symbol,
|
|
305
309
|
decimals: chainInfo.tonInfo.decimals
|
|
306
310
|
};
|
|
307
|
-
}
|
|
311
|
+
}
|
|
312
|
+
if (chainInfo.cardanoInfo) {
|
|
308
313
|
return {
|
|
314
|
+
...defaultTokenInfo,
|
|
309
315
|
symbol: chainInfo.cardanoInfo.symbol,
|
|
310
316
|
decimals: chainInfo.cardanoInfo.decimals
|
|
311
317
|
};
|
|
312
|
-
}
|
|
318
|
+
}
|
|
319
|
+
if (chainInfo.bitcoinInfo) {
|
|
313
320
|
return {
|
|
321
|
+
...defaultTokenInfo,
|
|
314
322
|
symbol: chainInfo.bitcoinInfo.symbol,
|
|
315
323
|
decimals: chainInfo.bitcoinInfo.decimals
|
|
316
324
|
};
|
|
@@ -21,6 +21,7 @@ export declare class EventService extends EventEmitter<EventRegistry> {
|
|
|
21
21
|
readonly waitBuyServiceReady: Promise<boolean>;
|
|
22
22
|
readonly waitEarningReady: Promise<boolean>;
|
|
23
23
|
readonly waitLedgerReady: Promise<boolean>;
|
|
24
|
+
readonly waitOpenGovReady: Promise<boolean>;
|
|
24
25
|
constructor();
|
|
25
26
|
private generateWaitPromise;
|
|
26
27
|
private setLazyTimeout;
|
|
@@ -33,6 +33,7 @@ export class EventService extends EventEmitter {
|
|
|
33
33
|
this.waitBuyServiceReady = this.generateWaitPromise('buy.services.ready');
|
|
34
34
|
this.waitEarningReady = this.generateWaitPromise('earning.ready');
|
|
35
35
|
this.waitLedgerReady = this.generateWaitPromise('ledger.ready');
|
|
36
|
+
this.waitOpenGovReady = this.generateWaitPromise('open-gov.ready');
|
|
36
37
|
}
|
|
37
38
|
generateWaitPromise(eventType) {
|
|
38
39
|
return new Promise(resolve => {
|
|
@@ -45,6 +45,7 @@ export interface EventRegistry {
|
|
|
45
45
|
'earning.ready': [boolean];
|
|
46
46
|
'swap.ready': [boolean];
|
|
47
47
|
'ledger.ready': [boolean];
|
|
48
|
+
'open-gov.ready': [boolean];
|
|
48
49
|
}
|
|
49
50
|
export declare type EventType = keyof EventRegistry;
|
|
50
51
|
export declare const COMMON_RELOAD_EVENTS: EventType[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
+
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
3
|
+
import { TransactionData } from '@subwallet/extension-base/types';
|
|
4
|
+
import { _SubstrateApi } from '../chain-service/types';
|
|
5
|
+
import { GovVoteRequest, GovVotingInfo, RemoveVoteRequest, UnlockVoteRequest } from './interface';
|
|
6
|
+
export default abstract class BaseOpenGovHandler {
|
|
7
|
+
protected readonly state: KoniState;
|
|
8
|
+
readonly chain: string;
|
|
9
|
+
constructor(state: KoniState, chain: string);
|
|
10
|
+
protected get substrateApi(): _SubstrateApi;
|
|
11
|
+
get chainInfo(): _ChainInfo;
|
|
12
|
+
protected get nativeToken(): _ChainAsset;
|
|
13
|
+
private lockPeriod;
|
|
14
|
+
private refToTrackMap;
|
|
15
|
+
handleVote(request: GovVoteRequest): Promise<TransactionData>;
|
|
16
|
+
private handleStandardVote;
|
|
17
|
+
private handleSplitVote;
|
|
18
|
+
private handleSplitAbstainVote;
|
|
19
|
+
handleRemoveVote(request: RemoveVoteRequest): Promise<TransactionData>;
|
|
20
|
+
handleUnlockVote(request: UnlockVoteRequest): Promise<TransactionData>;
|
|
21
|
+
private earlyValidateVoting;
|
|
22
|
+
private validateConvictionAndBalance;
|
|
23
|
+
private validateSplitAbstainAmount;
|
|
24
|
+
subscribeGovLockedInfo(addresses: string[], cb: (info: GovVotingInfo) => void): Promise<() => void>;
|
|
25
|
+
private parseVotesAndCheckFinished;
|
|
26
|
+
private calculateUnlockAmounts;
|
|
27
|
+
}
|