@subwallet/extension-base 1.3.68-1 → 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/koni/background/handlers/Tabs.js +11 -4
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/transfer/token.js +34 -3
- package/cjs/services/chain-service/constants.js +17 -5
- package/cjs/services/chain-service/utils/index.js +13 -5
- package/cjs/services/chain-service/utils/patch.js +1 -1
- 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/services/transaction-service/utils.js +3 -3
- 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/koni/background/handlers/Tabs.js +11 -4
- package/package.json +31 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/transfer/token.d.ts +4 -0
- package/services/balance-service/transfer/token.js +31 -1
- package/services/chain-service/constants.d.ts +9 -0
- package/services/chain-service/constants.js +14 -3
- package/services/chain-service/utils/index.js +13 -5
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- 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/services/transaction-service/utils.js +3 -3
- package/utils/account/transform.js +5 -4
|
@@ -4744,6 +4744,58 @@ export default class KoniExtension {
|
|
|
4744
4744
|
}
|
|
4745
4745
|
/* Migrate Unified Account */
|
|
4746
4746
|
|
|
4747
|
+
/* Open Gov */
|
|
4748
|
+
|
|
4749
|
+
async handleVote(request) {
|
|
4750
|
+
const extrinsic = await this.#koniState.openGovService.handleVote(request);
|
|
4751
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
4752
|
+
address: request.address,
|
|
4753
|
+
chain: request.chain,
|
|
4754
|
+
transaction: extrinsic,
|
|
4755
|
+
data: request,
|
|
4756
|
+
extrinsicType: ExtrinsicType.GOV_VOTE,
|
|
4757
|
+
chainType: ChainType.SUBSTRATE
|
|
4758
|
+
});
|
|
4759
|
+
}
|
|
4760
|
+
async handleRemoveVote(request) {
|
|
4761
|
+
const extrinsic = await this.#koniState.openGovService.handleRemoveVote(request);
|
|
4762
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
4763
|
+
address: request.address,
|
|
4764
|
+
chain: request.chain,
|
|
4765
|
+
transaction: extrinsic,
|
|
4766
|
+
data: request,
|
|
4767
|
+
extrinsicType: ExtrinsicType.GOV_UNVOTE,
|
|
4768
|
+
chainType: ChainType.SUBSTRATE
|
|
4769
|
+
});
|
|
4770
|
+
}
|
|
4771
|
+
async handleUnlockVote(request) {
|
|
4772
|
+
const extrinsic = await this.#koniState.openGovService.handleUnlockVote(request);
|
|
4773
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
4774
|
+
address: request.address,
|
|
4775
|
+
chain: request.chain,
|
|
4776
|
+
transaction: extrinsic,
|
|
4777
|
+
data: request,
|
|
4778
|
+
extrinsicType: ExtrinsicType.GOV_UNLOCK_VOTE,
|
|
4779
|
+
chainType: ChainType.SUBSTRATE
|
|
4780
|
+
});
|
|
4781
|
+
}
|
|
4782
|
+
async subscribeGovLockedInfo(id, port) {
|
|
4783
|
+
const cb = createSubscription(id, port);
|
|
4784
|
+
await this.#koniState.openGovService.waitForStarted();
|
|
4785
|
+
const govLockedInfoSubscription = this.#koniState.openGovService.subscribeGovLockedInfoSubject().subscribe({
|
|
4786
|
+
next: rs => {
|
|
4787
|
+
cb(rs);
|
|
4788
|
+
}
|
|
4789
|
+
});
|
|
4790
|
+
this.createUnsubscriptionHandle(id, govLockedInfoSubscription.unsubscribe);
|
|
4791
|
+
port.onDisconnect.addListener(() => {
|
|
4792
|
+
this.cancelSubscription(id);
|
|
4793
|
+
});
|
|
4794
|
+
return await this.#koniState.openGovService.getGovLockedInfoInfo();
|
|
4795
|
+
}
|
|
4796
|
+
|
|
4797
|
+
/* Open Gov */
|
|
4798
|
+
|
|
4747
4799
|
// --------------------------------------------------------------
|
|
4748
4800
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
4749
4801
|
async handle(id, type, request, port) {
|
|
@@ -5402,6 +5454,16 @@ export default class KoniExtension {
|
|
|
5402
5454
|
return this.migrateSoloAccount(request);
|
|
5403
5455
|
case 'pri(migrate.pingSession)':
|
|
5404
5456
|
return this.pingSession(request);
|
|
5457
|
+
|
|
5458
|
+
/* Gov */
|
|
5459
|
+
case 'pri(openGov.vote)':
|
|
5460
|
+
return this.handleVote(request);
|
|
5461
|
+
case 'pri(openGov.unvote)':
|
|
5462
|
+
return this.handleRemoveVote(request);
|
|
5463
|
+
case 'pri(openGov.unlockVote)':
|
|
5464
|
+
return this.handleUnlockVote(request);
|
|
5465
|
+
case 'pri(openGov.subscribeGovLockedInfo)':
|
|
5466
|
+
return this.subscribeGovLockedInfo(id, port);
|
|
5405
5467
|
// Default
|
|
5406
5468
|
default:
|
|
5407
5469
|
throw new Error(`Unable to handle message of type ${type}`);
|
|
@@ -21,6 +21,7 @@ import MintCampaignService from '@subwallet/extension-base/services/mint-campaig
|
|
|
21
21
|
import MktCampaignService from '@subwallet/extension-base/services/mkt-campaign-service';
|
|
22
22
|
import NftService from '@subwallet/extension-base/services/nft-service';
|
|
23
23
|
import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
|
|
24
|
+
import OpenGovService from '@subwallet/extension-base/services/open-gov';
|
|
24
25
|
import { PriceService } from '@subwallet/extension-base/services/price-service';
|
|
25
26
|
import RequestService from '@subwallet/extension-base/services/request-service';
|
|
26
27
|
import { AuthUrls, MetaRequest, SignRequest } from '@subwallet/extension-base/services/request-service/types';
|
|
@@ -81,6 +82,7 @@ export default class KoniState {
|
|
|
81
82
|
readonly swapService: SwapService;
|
|
82
83
|
readonly inappNotificationService: InappNotificationService;
|
|
83
84
|
readonly chainOnlineService: ChainOnlineService;
|
|
85
|
+
readonly openGovService: OpenGovService;
|
|
84
86
|
private generalStatus;
|
|
85
87
|
private waitSleeping;
|
|
86
88
|
private waitStarting;
|
|
@@ -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;
|
|
@@ -242,11 +242,18 @@ export default class KoniTabs {
|
|
|
242
242
|
if (isInDenyList) {
|
|
243
243
|
return this.checkPassList(url);
|
|
244
244
|
}
|
|
245
|
+
|
|
246
|
+
// TODO: Temporarily disable the "Advanced phishing detection" feature
|
|
247
|
+
// because it produces incorrect results. It incorrectly flags
|
|
248
|
+
// YouTube, Facebook, and other social media platforms as phishing.
|
|
249
|
+
|
|
245
250
|
if (this.#chainPatrolService) {
|
|
246
|
-
const isInChainPatrolDenyList = await chainPatrolCheckUrl(url);
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
251
|
+
// const isInChainPatrolDenyList = await chainPatrolCheckUrl(url);
|
|
252
|
+
//
|
|
253
|
+
// if (isInChainPatrolDenyList) {
|
|
254
|
+
// return this.checkPassList(url);
|
|
255
|
+
// }
|
|
256
|
+
return false;
|
|
250
257
|
}
|
|
251
258
|
return false;
|
|
252
259
|
}
|
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",
|
|
@@ -2918,11 +2943,11 @@
|
|
|
2918
2943
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2919
2944
|
"@substrate/connect": "^0.8.9",
|
|
2920
2945
|
"@subwallet-monorepos/subwallet-services-sdk": "0.1.14",
|
|
2921
|
-
"@subwallet/chain-list": "0.2.
|
|
2922
|
-
"@subwallet/extension-base": "^1.3.
|
|
2923
|
-
"@subwallet/extension-chains": "^1.3.
|
|
2924
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
2925
|
-
"@subwallet/extension-inject": "^1.3.
|
|
2946
|
+
"@subwallet/chain-list": "0.2.122",
|
|
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
|
};
|
|
@@ -13,4 +13,8 @@ interface CreateTransferExtrinsicProps {
|
|
|
13
13
|
}
|
|
14
14
|
export declare const createSubstrateExtrinsic: ({ from, networkKey, substrateApi, to, tokenInfo, transferAll, value }: CreateTransferExtrinsicProps) => Promise<[SubmittableExtrinsic | null, string]>;
|
|
15
15
|
export declare const getTransferMockTxFee: (address: string, chainInfo: _ChainInfo, tokenInfo: _ChainAsset, api: _SubstrateApi | _EvmApi | _TonApi) => Promise<BigN>;
|
|
16
|
+
export declare const getAccountNetuidTokenInfo: (address: string, tokenInfo: _ChainAsset, substrateApi: _SubstrateApi) => Promise<{
|
|
17
|
+
isEnableTransferSubnet: boolean;
|
|
18
|
+
accountHotKey: string | undefined;
|
|
19
|
+
}>;
|
|
16
20
|
export {};
|
|
@@ -25,7 +25,7 @@ export const createSubstrateExtrinsic = async ({
|
|
|
25
25
|
transferAll,
|
|
26
26
|
value
|
|
27
27
|
}) => {
|
|
28
|
-
var _tokenInfo$metadata;
|
|
28
|
+
var _tokenInfo$metadata, _tokenInfo$metadata2;
|
|
29
29
|
const api = substrateApi.api;
|
|
30
30
|
const isDisableTransfer = (_tokenInfo$metadata = tokenInfo.metadata) === null || _tokenInfo$metadata === void 0 ? void 0 : _tokenInfo$metadata.isDisableTransfer;
|
|
31
31
|
if (isDisableTransfer) {
|
|
@@ -112,6 +112,18 @@ export const createSubstrateExtrinsic = async ({
|
|
|
112
112
|
}
|
|
113
113
|
} else if (_TRANSFER_CHAIN_GROUP.truth.includes(networkKey)) {
|
|
114
114
|
transfer = api.tx.assetManager.transfer(to, _getTokenOnChainInfo(tokenInfo), value);
|
|
115
|
+
} else if (_TRANSFER_CHAIN_GROUP.bittensor.includes(networkKey) && (_tokenInfo$metadata2 = tokenInfo.metadata) !== null && _tokenInfo$metadata2 !== void 0 && _tokenInfo$metadata2.netuid) {
|
|
116
|
+
var _tokenInfo$metadata3;
|
|
117
|
+
const {
|
|
118
|
+
accountHotKey,
|
|
119
|
+
isEnableTransferSubnet
|
|
120
|
+
} = await getAccountNetuidTokenInfo(from, tokenInfo, substrateApi);
|
|
121
|
+
const tokenNetuid = (_tokenInfo$metadata3 = tokenInfo.metadata) === null || _tokenInfo$metadata3 === void 0 ? void 0 : _tokenInfo$metadata3.netuid;
|
|
122
|
+
if (isEnableTransferSubnet && accountHotKey) {
|
|
123
|
+
transfer = api.tx.subtensorModule.transferStake(from, accountHotKey, tokenNetuid, tokenNetuid, value);
|
|
124
|
+
} else {
|
|
125
|
+
return [null, value];
|
|
126
|
+
}
|
|
115
127
|
}
|
|
116
128
|
return [transfer, transferAmount || value];
|
|
117
129
|
};
|
|
@@ -170,4 +182,22 @@ export const getTransferMockTxFee = async (address, chainInfo, tokenInfo, api) =
|
|
|
170
182
|
console.error('error mocking tx fee', e);
|
|
171
183
|
return new BigN(0);
|
|
172
184
|
}
|
|
185
|
+
};
|
|
186
|
+
export const getAccountNetuidTokenInfo = async (address, tokenInfo, substrateApi) => {
|
|
187
|
+
var _tokenInfo$metadata4;
|
|
188
|
+
const tokenNetuid = (_tokenInfo$metadata4 = tokenInfo.metadata) === null || _tokenInfo$metadata4 === void 0 ? void 0 : _tokenInfo$metadata4.netuid;
|
|
189
|
+
if (!tokenNetuid) {
|
|
190
|
+
return {
|
|
191
|
+
isEnableTransferSubnet: false,
|
|
192
|
+
accountHotKey: undefined
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const [isTransferToggle, rawStakeInfoForColdKey] = await Promise.all([substrateApi.api.query.subtensorModule.transferToggle(tokenNetuid), substrateApi.api.call.stakeInfoRuntimeApi.getStakeInfoForColdkey(address)]);
|
|
196
|
+
const isEnableTransferSubnet = isTransferToggle.toPrimitive();
|
|
197
|
+
const taoStakeInfos = rawStakeInfoForColdKey.toPrimitive();
|
|
198
|
+
const accountHotKey = taoStakeInfos.find(value => value.netuid === tokenNetuid);
|
|
199
|
+
return {
|
|
200
|
+
isEnableTransferSubnet,
|
|
201
|
+
accountHotKey: accountHotKey === null || accountHotKey === void 0 ? void 0 : accountHotKey.hotkey
|
|
202
|
+
};
|
|
173
203
|
};
|
|
@@ -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[];
|
|
@@ -73,6 +81,7 @@ export declare const _TRANSFER_CHAIN_GROUP: {
|
|
|
73
81
|
centrifuge: string[];
|
|
74
82
|
disable_transfer: string[];
|
|
75
83
|
truth: string[];
|
|
84
|
+
bittensor: string[];
|
|
76
85
|
};
|
|
77
86
|
export declare const _MANTA_ZK_CHAIN_GROUP: string[];
|
|
78
87
|
export declare const _ZK_ASSET_PREFIX = "zk";
|
|
@@ -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,
|
|
@@ -286,7 +296,8 @@ export const _TRANSFER_CHAIN_GROUP = {
|
|
|
286
296
|
pendulum: ['pendulum', 'amplitude', 'amplitude_test', 'hydradx_main', 'bifrost', 'bifrost_dot', 'jamton', 'hydradx_hollarnet'],
|
|
287
297
|
centrifuge: ['centrifuge'],
|
|
288
298
|
disable_transfer: ['crab', 'pangolin'],
|
|
289
|
-
truth: ['truth_network']
|
|
299
|
+
truth: ['truth_network'],
|
|
300
|
+
bittensor: ['bittensor']
|
|
290
301
|
};
|
|
291
302
|
export const _MANTA_ZK_CHAIN_GROUP = ['calamari'];
|
|
292
303
|
export const _ZK_ASSET_PREFIX = 'zk';
|
|
@@ -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
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
-
export declare const ChainListVersion = "0.2.
|
|
2
|
+
export declare const ChainListVersion = "0.2.122";
|
|
3
3
|
export interface PatchInfo {
|
|
4
4
|
patchVersion: string;
|
|
5
5
|
appliedVersion: string;
|
|
@@ -5,7 +5,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
|
5
5
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
6
6
|
const fetchDomain = process.env.PATCH_CHAIN_LIST_URL || (PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev');
|
|
7
7
|
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
8
|
-
export const ChainListVersion = '0.2.
|
|
8
|
+
export const ChainListVersion = '0.2.122'; // update this when build chain-list
|
|
9
9
|
|
|
10
10
|
// todo: move this interface to chainlist
|
|
11
11
|
|
|
@@ -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
|
+
}
|