@subwallet/extension-base 1.1.17-0 → 1.1.18-1
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 +67 -1
- package/background/KoniTypes.js +5 -0
- package/cjs/background/KoniTypes.js +7 -1
- package/cjs/constants/index.js +6 -3
- package/cjs/koni/api/dotsama/crowdloan.js +106 -60
- package/cjs/koni/api/nft/acala_nft/index.js +1 -1
- package/cjs/koni/api/nft/config.js +21 -1
- package/cjs/koni/api/nft/karura_nft/index.js +1 -1
- package/cjs/koni/api/nft/vara_nft/index.js +19 -17
- package/cjs/koni/background/handlers/Extension.js +49 -1
- package/cjs/koni/background/handlers/State.js +25 -33
- package/cjs/koni/background/subscription.js +6 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/helpers.js +61 -0
- package/cjs/services/campaign-service/index.js +142 -0
- package/cjs/services/campaign-service/types.js +1 -0
- package/cjs/services/event-service/index.js +2 -0
- package/cjs/services/migration-service/index.js +4 -1
- package/cjs/services/notification-service/NotificationService.js +20 -6
- package/cjs/services/storage-service/DatabaseService.js +18 -1
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/Campaign.js +35 -0
- package/constants/index.d.ts +1 -0
- package/constants/index.js +1 -0
- package/koni/api/dotsama/crowdloan.d.ts +7 -6
- package/koni/api/dotsama/crowdloan.js +103 -51
- package/koni/api/nft/acala_nft/index.js +1 -1
- package/koni/api/nft/config.d.ts +4 -0
- package/koni/api/nft/config.js +16 -0
- package/koni/api/nft/karura_nft/index.js +1 -1
- package/koni/api/nft/vara_nft/index.js +19 -17
- package/koni/background/handlers/Extension.d.ts +2 -0
- package/koni/background/handlers/Extension.js +49 -2
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +4 -11
- package/koni/background/subscription.js +6 -2
- package/package.json +27 -6
- package/packageInfo.js +1 -1
- package/services/campaign-service/helpers.d.ts +3 -0
- package/services/campaign-service/helpers.js +54 -0
- package/services/campaign-service/index.d.ts +11 -0
- package/services/campaign-service/index.js +134 -0
- package/services/campaign-service/types.d.ts +34 -0
- package/services/campaign-service/types.js +1 -0
- package/services/event-service/index.d.ts +2 -0
- package/services/event-service/index.js +2 -0
- package/services/event-service/types.d.ts +2 -0
- package/services/migration-service/index.d.ts +3 -1
- package/services/migration-service/index.js +4 -1
- package/services/notification-service/NotificationService.d.ts +2 -2
- package/services/notification-service/NotificationService.js +20 -6
- package/services/storage-service/DatabaseService.d.ts +7 -1
- package/services/storage-service/DatabaseService.js +18 -1
- package/services/storage-service/databases/index.d.ts +3 -1
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/Campaign.d.ts +9 -0
- package/services/storage-service/db-stores/Campaign.js +27 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
|
-
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
+
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _FundStatus, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
3
3
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
4
4
|
import { AuthUrls, Resolver } from '@subwallet/extension-base/background/handlers/State';
|
|
5
5
|
import { AccountAuthType, AccountJson, AddressJson, AuthorizeRequest, ConfirmationRequestBase, RequestAccountList, RequestAccountSubscribe, RequestAccountUnsubscribe, RequestAuthorizeCancel, RequestAuthorizeReject, RequestAuthorizeSubscribe, RequestAuthorizeTab, RequestCurrentAccountAddress, ResponseAuthorizeList, ResponseJsonGetAccountInfo, SeedLengths } from '@subwallet/extension-base/background/types';
|
|
@@ -220,6 +220,14 @@ export interface CrowdloanItem {
|
|
|
220
220
|
state: APIItemState;
|
|
221
221
|
paraState?: CrowdloanParaState;
|
|
222
222
|
contribute: string;
|
|
223
|
+
fundId: string;
|
|
224
|
+
paraId: number;
|
|
225
|
+
status: _FundStatus;
|
|
226
|
+
startTime: Date;
|
|
227
|
+
endTime: Date;
|
|
228
|
+
auctionIndex: number;
|
|
229
|
+
firstPeriod: number;
|
|
230
|
+
lastPeriod: number;
|
|
223
231
|
}
|
|
224
232
|
export interface CrowdloanJson {
|
|
225
233
|
reset?: boolean;
|
|
@@ -1435,6 +1443,9 @@ export declare enum NotificationType {
|
|
|
1435
1443
|
WARNING = "warning",
|
|
1436
1444
|
ERROR = "error"
|
|
1437
1445
|
}
|
|
1446
|
+
export interface NotificationButton {
|
|
1447
|
+
title: string;
|
|
1448
|
+
}
|
|
1438
1449
|
export interface Notification {
|
|
1439
1450
|
id: number;
|
|
1440
1451
|
type: NotificationType;
|
|
@@ -1443,7 +1454,10 @@ export interface Notification {
|
|
|
1443
1454
|
notifyViaBrowser?: boolean;
|
|
1444
1455
|
action?: {
|
|
1445
1456
|
url?: string;
|
|
1457
|
+
buttonClick?: (btnIndex: number) => void;
|
|
1458
|
+
click?: () => void;
|
|
1446
1459
|
};
|
|
1460
|
+
buttons?: NotificationButton[];
|
|
1447
1461
|
}
|
|
1448
1462
|
export declare type NotificationParams = Omit<Notification, 'id'>;
|
|
1449
1463
|
export interface CronReloadRequest {
|
|
@@ -1538,6 +1552,56 @@ export interface ResolveAddressToDomainRequest {
|
|
|
1538
1552
|
chain: string;
|
|
1539
1553
|
address: string;
|
|
1540
1554
|
}
|
|
1555
|
+
export declare type CampaignAction = 'open_view' | 'open_url' | null;
|
|
1556
|
+
export interface CampaignButton {
|
|
1557
|
+
id: number;
|
|
1558
|
+
color: string;
|
|
1559
|
+
icon: string | null;
|
|
1560
|
+
name: string;
|
|
1561
|
+
type: CampaignAction;
|
|
1562
|
+
metadata: Record<string, any> | null;
|
|
1563
|
+
}
|
|
1564
|
+
export declare enum CampaignDataType {
|
|
1565
|
+
NOTIFICATION = "notification",
|
|
1566
|
+
BANNER = "banner"
|
|
1567
|
+
}
|
|
1568
|
+
export interface BaseCampaignData {
|
|
1569
|
+
slug: string;
|
|
1570
|
+
campaignId: number;
|
|
1571
|
+
isDone: boolean;
|
|
1572
|
+
type: CampaignDataType;
|
|
1573
|
+
data: Record<string, any>;
|
|
1574
|
+
buttons: CampaignButton[];
|
|
1575
|
+
startTime: number;
|
|
1576
|
+
endTime: number;
|
|
1577
|
+
condition: Record<string, any> | null;
|
|
1578
|
+
}
|
|
1579
|
+
export interface CampaignBanner extends BaseCampaignData {
|
|
1580
|
+
type: CampaignDataType.BANNER;
|
|
1581
|
+
data: {
|
|
1582
|
+
media: string;
|
|
1583
|
+
alt: string;
|
|
1584
|
+
action: CampaignAction;
|
|
1585
|
+
metadata: Record<string, any> | null;
|
|
1586
|
+
environments: string[];
|
|
1587
|
+
position: string[];
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
export interface CampaignNotification extends BaseCampaignData {
|
|
1591
|
+
type: CampaignDataType.NOTIFICATION;
|
|
1592
|
+
data: {
|
|
1593
|
+
title: string;
|
|
1594
|
+
message: string;
|
|
1595
|
+
repeat: number;
|
|
1596
|
+
repeatAfter: number;
|
|
1597
|
+
action: CampaignAction;
|
|
1598
|
+
metadata: Record<string, any> | null;
|
|
1599
|
+
};
|
|
1600
|
+
}
|
|
1601
|
+
export declare type CampaignData = CampaignBanner | CampaignNotification;
|
|
1602
|
+
export interface RequestCampaignBannerComplete {
|
|
1603
|
+
slug: string;
|
|
1604
|
+
}
|
|
1541
1605
|
export interface KoniRequestSignatures {
|
|
1542
1606
|
'pri(staking.submitTuringCancelCompound)': [RequestTuringCancelStakeCompound, SWTransactionResponse];
|
|
1543
1607
|
'pri(staking.submitTuringCompound)': [RequestTuringStakeCompound, SWTransactionResponse];
|
|
@@ -1720,6 +1784,8 @@ export interface KoniRequestSignatures {
|
|
|
1720
1784
|
'pri(walletConnect.notSupport.approve)': [RequestApproveWalletConnectNotSupport, boolean];
|
|
1721
1785
|
'pri(walletConnect.notSupport.reject)': [RequestRejectWalletConnectNotSupport, boolean];
|
|
1722
1786
|
'pri(metadata.find)': [RequestFindRawMetadata, ResponseFindRawMetadata];
|
|
1787
|
+
'pri(campaign.banner.subscribe)': [null, CampaignBanner[], CampaignBanner[]];
|
|
1788
|
+
'pri(campaign.banner.complete)': [RequestCampaignBannerComplete, boolean];
|
|
1723
1789
|
}
|
|
1724
1790
|
export interface ApplicationMetadataType {
|
|
1725
1791
|
version: string;
|
package/background/KoniTypes.js
CHANGED
|
@@ -236,4 +236,9 @@ export let MantaPayEnableMessage;
|
|
|
236
236
|
MantaPayEnableMessage["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
237
237
|
MantaPayEnableMessage["SUCCESS"] = "SUCCESS";
|
|
238
238
|
})(MantaPayEnableMessage || (MantaPayEnableMessage = {}));
|
|
239
|
+
export let CampaignDataType;
|
|
240
|
+
(function (CampaignDataType) {
|
|
241
|
+
CampaignDataType["NOTIFICATION"] = "notification";
|
|
242
|
+
CampaignDataType["BANNER"] = "banner";
|
|
243
|
+
})(CampaignDataType || (CampaignDataType = {}));
|
|
239
244
|
export const MobileOS = ['iOS', 'Android'];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WalletUnlockType = exports.UnstakingStatus = exports.TransferTxErrorType = exports.TransactionDirection = exports.ThemeNames = exports.StakingType = exports.StakingTxErrorType = exports.StakingStatus = exports.RuntimeEnvironment = exports.RMRK_VER = exports.ProviderErrorType = exports.NotificationType = exports.NETWORK_STATUS = exports.NETWORK_ERROR = exports.MobileOS = exports.MantaPayEnableMessage = exports.ExtrinsicType = exports.ExtrinsicStatus = exports.ExternalRequestPromiseStatus = exports.EvmProviderErrorType = exports.CrowdloanParaState = exports.ContractType = exports.ChainType = exports.ChainEditStandard = exports.BasicTxWarningCode = exports.BasicTxErrorType = exports.BalanceErrorType = exports.AccountExternalErrorCode = exports.APIItemState = void 0;
|
|
6
|
+
exports.WalletUnlockType = exports.UnstakingStatus = exports.TransferTxErrorType = exports.TransactionDirection = exports.ThemeNames = exports.StakingType = exports.StakingTxErrorType = exports.StakingStatus = exports.RuntimeEnvironment = exports.RMRK_VER = exports.ProviderErrorType = exports.NotificationType = exports.NETWORK_STATUS = exports.NETWORK_ERROR = exports.MobileOS = exports.MantaPayEnableMessage = exports.ExtrinsicType = exports.ExtrinsicStatus = exports.ExternalRequestPromiseStatus = exports.EvmProviderErrorType = exports.CrowdloanParaState = exports.ContractType = exports.ChainType = exports.ChainEditStandard = exports.CampaignDataType = exports.BasicTxWarningCode = exports.BasicTxErrorType = exports.BalanceErrorType = exports.AccountExternalErrorCode = exports.APIItemState = void 0;
|
|
7
7
|
// Copyright 2019-2022 @polkadot/extension-koni authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
let RuntimeEnvironment;
|
|
@@ -256,5 +256,11 @@ exports.MantaPayEnableMessage = MantaPayEnableMessage;
|
|
|
256
256
|
MantaPayEnableMessage["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
257
257
|
MantaPayEnableMessage["SUCCESS"] = "SUCCESS";
|
|
258
258
|
})(MantaPayEnableMessage || (exports.MantaPayEnableMessage = MantaPayEnableMessage = {}));
|
|
259
|
+
let CampaignDataType;
|
|
260
|
+
exports.CampaignDataType = CampaignDataType;
|
|
261
|
+
(function (CampaignDataType) {
|
|
262
|
+
CampaignDataType["NOTIFICATION"] = "notification";
|
|
263
|
+
CampaignDataType["BANNER"] = "banner";
|
|
264
|
+
})(CampaignDataType || (exports.CampaignDataType = CampaignDataType = {}));
|
|
259
265
|
const MobileOS = ['iOS', 'Android'];
|
|
260
266
|
exports.MobileOS = MobileOS;
|
package/cjs/constants/index.js
CHANGED
|
@@ -25,9 +25,10 @@ var _exportNames = {
|
|
|
25
25
|
ALL_GENESIS_HASH: true,
|
|
26
26
|
IGNORE_GET_SUBSTRATE_FEATURES_LIST: true,
|
|
27
27
|
IGNORE_QR_SIGNER: true,
|
|
28
|
-
XCM_MIN_AMOUNT_RATIO: true
|
|
28
|
+
XCM_MIN_AMOUNT_RATIO: true,
|
|
29
|
+
MARKETING_CAMPAIGN_URL: true
|
|
29
30
|
};
|
|
30
|
-
exports.XCM_MIN_AMOUNT_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
|
|
31
|
+
exports.XCM_MIN_AMOUNT_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.MARKETING_CAMPAIGN_URL = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
|
|
31
32
|
var _staking = require("./staking");
|
|
32
33
|
Object.keys(_staking).forEach(function (key) {
|
|
33
34
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -98,4 +99,6 @@ exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = IGNORE_GET_SUBSTRATE_FEATURES_LIST;
|
|
|
98
99
|
const IGNORE_QR_SIGNER = [];
|
|
99
100
|
exports.IGNORE_QR_SIGNER = IGNORE_QR_SIGNER;
|
|
100
101
|
const XCM_MIN_AMOUNT_RATIO = 1.2;
|
|
101
|
-
exports.XCM_MIN_AMOUNT_RATIO = XCM_MIN_AMOUNT_RATIO;
|
|
102
|
+
exports.XCM_MIN_AMOUNT_RATIO = XCM_MIN_AMOUNT_RATIO;
|
|
103
|
+
const MARKETING_CAMPAIGN_URL = process.env.MARKETING_CAMPAIGN_URL || '';
|
|
104
|
+
exports.MARKETING_CAMPAIGN_URL = MARKETING_CAMPAIGN_URL;
|
|
@@ -4,21 +4,40 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getCrowdloanFundsStatus = getCrowdloanFundsStatus;
|
|
8
7
|
exports.subscribeAcalaContributeInterval = void 0;
|
|
9
8
|
exports.subscribeCrowdloan = subscribeCrowdloan;
|
|
10
9
|
var _chainList = require("@subwallet/chain-list");
|
|
10
|
+
var _types = require("@subwallet/chain-list/types");
|
|
11
11
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
12
12
|
var _constants = require("@subwallet/extension-base/constants");
|
|
13
13
|
var _typeRegistry = _interopRequireDefault(require("@subwallet/extension-base/koni/api/dotsama/typeRegistry"));
|
|
14
|
-
var _utils = require("@subwallet/extension-base/
|
|
15
|
-
var _utils2 = require("@subwallet/extension-base/utils");
|
|
14
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
16
15
|
var _axios = _interopRequireDefault(require("axios"));
|
|
17
16
|
var _util = require("@polkadot/util");
|
|
18
17
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
19
18
|
// SPDX-License-Identifier: Apache-2.0
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
const STATUS_MAP = {
|
|
21
|
+
[_types._FundStatus.IN_AUCTION]: _KoniTypes.CrowdloanParaState.ONGOING,
|
|
22
|
+
[_types._FundStatus.WITHDRAW]: _KoniTypes.CrowdloanParaState.FAILED,
|
|
23
|
+
[_types._FundStatus.FAILED]: _KoniTypes.CrowdloanParaState.FAILED,
|
|
24
|
+
[_types._FundStatus.WON]: _KoniTypes.CrowdloanParaState.COMPLETED
|
|
25
|
+
};
|
|
26
|
+
const getOnlineFundList = (async () => {
|
|
27
|
+
const request = await _axios.default.get('https://static-data.subwallet.app/crowdloan-funds/list.json');
|
|
28
|
+
return request.data;
|
|
29
|
+
})();
|
|
30
|
+
function getRPCCrowdloan(parentAPI, fundInfo, hexAddresses, callback) {
|
|
31
|
+
const {
|
|
32
|
+
auctionIndex,
|
|
33
|
+
endTime,
|
|
34
|
+
firstPeriod,
|
|
35
|
+
fundId,
|
|
36
|
+
lastPeriod,
|
|
37
|
+
paraId,
|
|
38
|
+
startTime,
|
|
39
|
+
status
|
|
40
|
+
} = fundInfo;
|
|
22
41
|
const unsubPromise = parentAPI.api.derive.crowdloan.ownContributions(paraId, hexAddresses, result => {
|
|
23
42
|
let contribute = new _util.BN(0);
|
|
24
43
|
Object.values(result).forEach(item => {
|
|
@@ -26,8 +45,16 @@ function getRPCCrowdloan(parentAPI, paraId, hexAddresses, paraState, callback) {
|
|
|
26
45
|
});
|
|
27
46
|
const rs = {
|
|
28
47
|
state: _KoniTypes.APIItemState.READY,
|
|
29
|
-
paraState,
|
|
30
|
-
contribute: contribute.toString()
|
|
48
|
+
paraState: STATUS_MAP[fundInfo.status],
|
|
49
|
+
contribute: contribute.toString(),
|
|
50
|
+
fundId,
|
|
51
|
+
paraId,
|
|
52
|
+
status,
|
|
53
|
+
startTime,
|
|
54
|
+
endTime,
|
|
55
|
+
auctionIndex,
|
|
56
|
+
firstPeriod,
|
|
57
|
+
lastPeriod
|
|
31
58
|
};
|
|
32
59
|
callback(rs);
|
|
33
60
|
});
|
|
@@ -37,7 +64,18 @@ function getRPCCrowdloan(parentAPI, paraId, hexAddresses, paraState, callback) {
|
|
|
37
64
|
}).catch(console.error);
|
|
38
65
|
};
|
|
39
66
|
}
|
|
40
|
-
const subscribeAcalaContributeInterval = (polkadotAddresses,
|
|
67
|
+
const subscribeAcalaContributeInterval = (polkadotAddresses, fundInfo, callback) => {
|
|
68
|
+
const {
|
|
69
|
+
auctionIndex,
|
|
70
|
+
endTime,
|
|
71
|
+
firstPeriod,
|
|
72
|
+
fundId,
|
|
73
|
+
lastPeriod,
|
|
74
|
+
paraId,
|
|
75
|
+
startTime,
|
|
76
|
+
status
|
|
77
|
+
} = fundInfo;
|
|
78
|
+
const paraState = STATUS_MAP[fundInfo.status];
|
|
41
79
|
const acalaContributionApi = 'https://api.polkawallet.io/acala-distribution-v2/crowdloan?account=';
|
|
42
80
|
const getContributeInfo = () => {
|
|
43
81
|
Promise.all(polkadotAddresses.map(polkadotAddress => {
|
|
@@ -46,14 +84,21 @@ const subscribeAcalaContributeInterval = (polkadotAddresses, paraState, callback
|
|
|
46
84
|
let contribute = new _util.BN(0);
|
|
47
85
|
resList.forEach(res => {
|
|
48
86
|
var _res$data$data, _res$data$data$acala, _res$data$data$acala$;
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
|
|
50
88
|
contribute = contribute.add(new _util.BN(((_res$data$data = res.data.data) === null || _res$data$data === void 0 ? void 0 : (_res$data$data$acala = _res$data$data.acala) === null || _res$data$data$acala === void 0 ? void 0 : (_res$data$data$acala$ = _res$data$data$acala[0]) === null || _res$data$data$acala$ === void 0 ? void 0 : _res$data$data$acala$.totalDOTLocked) || '0'));
|
|
51
89
|
});
|
|
52
90
|
const rs = {
|
|
53
91
|
state: _KoniTypes.APIItemState.READY,
|
|
54
92
|
paraState,
|
|
55
|
-
|
|
56
|
-
|
|
93
|
+
contribute: contribute.toString(),
|
|
94
|
+
fundId,
|
|
95
|
+
paraId,
|
|
96
|
+
status,
|
|
97
|
+
startTime,
|
|
98
|
+
endTime,
|
|
99
|
+
auctionIndex,
|
|
100
|
+
firstPeriod,
|
|
101
|
+
lastPeriod
|
|
57
102
|
};
|
|
58
103
|
callback(rs);
|
|
59
104
|
}).catch(console.error);
|
|
@@ -64,70 +109,71 @@ const subscribeAcalaContributeInterval = (polkadotAddresses, paraState, callback
|
|
|
64
109
|
clearInterval(interval);
|
|
65
110
|
};
|
|
66
111
|
};
|
|
67
|
-
exports.subscribeAcalaContributeInterval = subscribeAcalaContributeInterval;
|
|
68
|
-
async function getCrowdloanFundsStatus(api) {
|
|
69
|
-
const leases = await api.query.slots.leases.keys();
|
|
70
|
-
const leasesParaIds = leases.map(_ref => {
|
|
71
|
-
let {
|
|
72
|
-
args: [paraId]
|
|
73
|
-
} = _ref;
|
|
74
|
-
return paraId.toString();
|
|
75
|
-
});
|
|
76
|
-
const rs = await api.query.crowdloan.funds.entries();
|
|
77
|
-
const newRaise = await api.query.crowdloan.newRaise();
|
|
78
|
-
const newRaiseParaIds = newRaise.toJSON().map(p => p.toString());
|
|
79
|
-
return rs.reduce((stateMap, _ref2) => {
|
|
80
|
-
let [{
|
|
81
|
-
args: [paraId]
|
|
82
|
-
}, fundData] = _ref2;
|
|
83
|
-
const paraStr = paraId.toString();
|
|
84
112
|
|
|
85
|
-
|
|
86
|
-
|
|
113
|
+
// export async function getCrowdloanFundsStatus (api: ApiPromise) {
|
|
114
|
+
// const leases = await api.query.slots.leases.keys<ParaId[]>();
|
|
115
|
+
// const leasesParaIds = leases.map(({ args: [paraId] }) => paraId.toString());
|
|
87
116
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
117
|
+
// const rs = await api.query.crowdloan.funds.entries<Option<any>, ParaId[]>();
|
|
118
|
+
// const newRaise = await api.query.crowdloan.newRaise<Vec<u32>>();
|
|
119
|
+
|
|
120
|
+
// const newRaiseParaIds = (newRaise.toJSON() as number[]).map((p) => p.toString());
|
|
121
|
+
|
|
122
|
+
// return rs.reduce((stateMap, [{ args: [paraId] }, fundData]) => {
|
|
123
|
+
// const paraStr = paraId.toString();
|
|
124
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
125
|
+
// // const item = fundData.unwrap() as PolkadotRuntimeCommonCrowdloanFundInfo;
|
|
126
|
+
// if (leasesParaIds.indexOf(paraStr) > -1) {
|
|
127
|
+
// stateMap[paraStr] = CrowdloanParaState.COMPLETED;
|
|
128
|
+
// }
|
|
129
|
+
// if (newRaiseParaIds.indexOf(paraStr) > -1) {
|
|
130
|
+
// stateMap[paraStr] = CrowdloanParaState.ONGOING;
|
|
131
|
+
// }
|
|
132
|
+
// return stateMap;
|
|
133
|
+
// }, {} as Record<string, CrowdloanParaState>);
|
|
134
|
+
// }
|
|
97
135
|
|
|
98
136
|
// Get All crowdloan
|
|
137
|
+
exports.subscribeAcalaContributeInterval = subscribeAcalaContributeInterval;
|
|
99
138
|
async function subscribeCrowdloan(addresses, substrateApiMap, callback, chainInfoMap) {
|
|
100
139
|
const unsubMap = {};
|
|
140
|
+
const latestMap = {};
|
|
141
|
+
const rawFundList = await getOnlineFundList;
|
|
142
|
+
rawFundList.forEach(fundInfo => {
|
|
143
|
+
const chainSlug = fundInfo.chain;
|
|
144
|
+
if (!latestMap[chainSlug] || fundInfo.auctionIndex > latestMap[chainSlug].auctionIndex) {
|
|
145
|
+
latestMap[chainSlug] = fundInfo;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
101
148
|
if (Object.keys(substrateApiMap).includes(_chainList.COMMON_CHAIN_SLUGS.KUSAMA) && Object.keys(substrateApiMap).includes(_chainList.COMMON_CHAIN_SLUGS.POLKADOT)) {
|
|
149
|
+
const now = Date.now();
|
|
102
150
|
const polkadotAPI = await substrateApiMap[_chainList.COMMON_CHAIN_SLUGS.POLKADOT].isReady;
|
|
103
|
-
const polkadotFundsStatusMap = await getCrowdloanFundsStatus(polkadotAPI.api);
|
|
104
151
|
const kusamaAPI = await substrateApiMap[_chainList.COMMON_CHAIN_SLUGS.KUSAMA].isReady;
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
// TODO: find all crowdloan valid networks: parachains, in-crowdloan, crowdloan but failed
|
|
108
|
-
|
|
109
|
-
const substrateAddresses = (0, _utils2.categoryAddresses)(addresses)[0];
|
|
152
|
+
const substrateAddresses = (0, _utils.categoryAddresses)(addresses)[0];
|
|
110
153
|
const hexAddresses = substrateAddresses.map(address => {
|
|
111
154
|
return _typeRegistry.default.createType('AccountId', address).toHex();
|
|
112
155
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
156
|
+
if (addresses.length === 0) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
Object.values(latestMap).forEach(fundInfo => {
|
|
160
|
+
var _chainInfoMap$chainSl;
|
|
161
|
+
const chainSlug = fundInfo.chain;
|
|
162
|
+
const endTime = new Date(fundInfo.endTime).getTime();
|
|
163
|
+
const parentChain = fundInfo.relayChain;
|
|
164
|
+
const substrateInfo = (_chainInfoMap$chainSl = chainInfoMap[chainSlug]) === null || _chainInfoMap$chainSl === void 0 ? void 0 : _chainInfoMap$chainSl.substrateInfo;
|
|
165
|
+
if (chainSlug && parentChain && STATUS_MAP[fundInfo.status] && fundInfo.paraId && endTime > now && substrateInfo) {
|
|
117
166
|
const crowdloanCb = rs => {
|
|
118
|
-
callback(
|
|
167
|
+
callback(chainSlug, rs);
|
|
119
168
|
};
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
unsubMap[networkKey] = getRPCCrowdloan(polkadotAPI, paraId, hexAddresses, polkadotFundsStatusMap[paraId], crowdloanCb);
|
|
129
|
-
} else if (parentChain === _chainList.COMMON_CHAIN_SLUGS.KUSAMA && kusamaFundsStatusMap[paraId]) {
|
|
130
|
-
unsubMap[networkKey] = getRPCCrowdloan(kusamaAPI, paraId, hexAddresses, kusamaFundsStatusMap[paraId], crowdloanCb);
|
|
169
|
+
fundInfo.paraId = substrateInfo.crowdloanParaId || substrateInfo.paraId || fundInfo.paraId;
|
|
170
|
+
if (chainSlug === _chainList.COMMON_CHAIN_SLUGS.ACALA) {
|
|
171
|
+
const acalaAddresses = substrateAddresses.map(address => (0, _utils.reformatAddress)(address, 10, false));
|
|
172
|
+
unsubMap.acala = subscribeAcalaContributeInterval(acalaAddresses, fundInfo, crowdloanCb);
|
|
173
|
+
} else if (parentChain === _chainList.COMMON_CHAIN_SLUGS.POLKADOT) {
|
|
174
|
+
unsubMap[chainSlug] = getRPCCrowdloan(polkadotAPI, fundInfo, hexAddresses, crowdloanCb);
|
|
175
|
+
} else if (parentChain === _chainList.COMMON_CHAIN_SLUGS.KUSAMA) {
|
|
176
|
+
unsubMap[chainSlug] = getRPCCrowdloan(kusamaAPI, fundInfo, hexAddresses, crowdloanCb);
|
|
131
177
|
}
|
|
132
178
|
}
|
|
133
179
|
});
|
|
@@ -143,7 +143,7 @@ const getMetadata = metadataUrl => {
|
|
|
143
143
|
if (!metadataUrl) {
|
|
144
144
|
return null;
|
|
145
145
|
}
|
|
146
|
-
url = (0, _config.getRandomIpfsGateway)() + metadataUrl + '/
|
|
146
|
+
url = (0, _config.getRandomIpfsGateway)() + metadataUrl + '/metadata.json';
|
|
147
147
|
return (0, _crossFetch.default)(url, {
|
|
148
148
|
method: 'GET',
|
|
149
149
|
headers
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.VARA_SCAN_ENDPOINT = exports.UNIQUE_SCAN_ENDPOINT = exports.UNIQUE_IPFS_GATEWAY = exports.TRANSFER_CHAIN_ID = exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN = exports.SUPPORTED_NFT_NETWORKS = exports.SINGULAR_V2_ENDPOINT = exports.SINGULAR_V2_COLLECTION_ENDPOINT = exports.SINGULAR_V1_ENDPOINT = exports.SINGULAR_V1_COLLECTION_ENDPOINT = exports.RMRK_PINATA_SERVER = exports.QUARTZ_SCAN_ENDPOINT = exports.PINATA_IPFS_GATEWAY = exports.NFT_STORAGE_GATEWAY = exports.KANARIA_EXTERNAL_SERVER = exports.KANARIA_ENDPOINT = exports.IPFS_W3S_LINK = exports.IPFS_IO = exports.IPFS_GATEWAY_4EVERLAND = exports.IPFS_FLEEK = exports.GATEWAY_IPFS_IO = exports.DWEB_LINK = exports.CLOUDFLARE_PINATA_SERVER = exports.CF_IPFS_GATEWAY = exports.BIT_COUNTRY_THUMBNAIL_RESOLVER = exports.BIT_COUNTRY_LAND_ESTATE_METADATA_API = exports.BIT_COUNTRY_IPFS_SERVER = void 0;
|
|
7
|
+
exports.W3S_IPFS = exports.VARA_SCAN_ENDPOINT = exports.UNIQUE_SCAN_ENDPOINT = exports.UNIQUE_IPFS_GATEWAY = exports.TRANSFER_CHAIN_ID = exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN = exports.SUPPORTED_NFT_NETWORKS = exports.SUBWALLET_IPFS = exports.SINGULAR_V2_ENDPOINT = exports.SINGULAR_V2_COLLECTION_ENDPOINT = exports.SINGULAR_V1_ENDPOINT = exports.SINGULAR_V1_COLLECTION_ENDPOINT = exports.RMRK_PINATA_SERVER = exports.QUARTZ_SCAN_ENDPOINT = exports.PINATA_IPFS_GATEWAY = exports.NFT_STORAGE_GATEWAY = exports.KANARIA_EXTERNAL_SERVER = exports.KANARIA_ENDPOINT = exports.IPFS_W3S_LINK = exports.IPFS_IO = exports.IPFS_GATEWAY_4EVERLAND = exports.IPFS_FLEEK = exports.IPFS_ETH_ARAGON = exports.IPFS2_RMRK = exports.GATEWAY_IPFS_IO = exports.DWEB_LINK = exports.CLOUDFLARE_PINATA_SERVER = exports.CF_IPFS_GATEWAY = exports.BIT_COUNTRY_THUMBNAIL_RESOLVER = exports.BIT_COUNTRY_LAND_ESTATE_METADATA_API = exports.BIT_COUNTRY_IPFS_SERVER = void 0;
|
|
7
8
|
exports.getRandomIpfsGateway = getRandomIpfsGateway;
|
|
8
9
|
var _utils = require("@subwallet/extension-base/utils");
|
|
10
|
+
var _bowser = _interopRequireDefault(require("bowser"));
|
|
9
11
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
12
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
13
|
|
|
@@ -59,6 +61,18 @@ const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
|
|
|
59
61
|
exports.IPFS_GATEWAY_4EVERLAND = IPFS_GATEWAY_4EVERLAND;
|
|
60
62
|
const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
|
|
61
63
|
exports.IPFS_FLEEK = IPFS_FLEEK;
|
|
64
|
+
const W3S_IPFS = 'https://w3s.link/ipfs/'; // 400
|
|
65
|
+
exports.W3S_IPFS = W3S_IPFS;
|
|
66
|
+
const IPFS2_RMRK = 'https://ipfs2.rmrk.link/ipfs/'; // ????
|
|
67
|
+
exports.IPFS2_RMRK = IPFS2_RMRK;
|
|
68
|
+
const IPFS_ETH_ARAGON = 'https://ipfs.eth.aragon.network/ipfs/'; // 400
|
|
69
|
+
exports.IPFS_ETH_ARAGON = IPFS_ETH_ARAGON;
|
|
70
|
+
const SUBWALLET_IPFS = 'https://ipfs.subwallet.app/ipfs/'; // ???
|
|
71
|
+
exports.SUBWALLET_IPFS = SUBWALLET_IPFS;
|
|
72
|
+
const detectFirefox = () => {
|
|
73
|
+
return (localStorage.getItem('browserInfo') || _bowser.default.getParser(window.navigator.userAgent).getBrowserName()).toLowerCase() === 'firefox';
|
|
74
|
+
};
|
|
75
|
+
const isFirefox = detectFirefox();
|
|
62
76
|
let SUPPORTED_NFT_NETWORKS;
|
|
63
77
|
exports.SUPPORTED_NFT_NETWORKS = SUPPORTED_NFT_NETWORKS;
|
|
64
78
|
(function (SUPPORTED_NFT_NETWORKS) {
|
|
@@ -128,6 +142,12 @@ const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
|
128
142
|
provider: NFT_STORAGE_GATEWAY,
|
|
129
143
|
weight: 50
|
|
130
144
|
}];
|
|
145
|
+
if (isFirefox) {
|
|
146
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
147
|
+
provider: SUBWALLET_IPFS,
|
|
148
|
+
weight: 5000
|
|
149
|
+
});
|
|
150
|
+
}
|
|
131
151
|
if (!_utils.RuntimeInfo.protocol || _utils.RuntimeInfo.protocol && !_utils.RuntimeInfo.protocol.startsWith('http')) {
|
|
132
152
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
133
153
|
provider: IPFS_FLEEK,
|
|
@@ -146,7 +146,7 @@ const getKaruraMetadata = metadataUrl => {
|
|
|
146
146
|
if (!metadataUrl) {
|
|
147
147
|
return null;
|
|
148
148
|
}
|
|
149
|
-
url = (0, _config.getRandomIpfsGateway)() + metadataUrl + '/
|
|
149
|
+
url = (0, _config.getRandomIpfsGateway)() + metadataUrl + '/metadata.json';
|
|
150
150
|
return (0, _crossFetch.default)(url, {
|
|
151
151
|
method: 'GET',
|
|
152
152
|
headers: {
|
|
@@ -72,23 +72,25 @@ class VaraNftApi extends _nft.BaseNftApi {
|
|
|
72
72
|
try {
|
|
73
73
|
await Promise.all(this.addresses.map(async address => {
|
|
74
74
|
const nfts = await this.getNftByAccount(address);
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
75
|
+
if (nfts) {
|
|
76
|
+
for (const nft of nfts) {
|
|
77
|
+
const parsedNft = {
|
|
78
|
+
id: nft.tokenId,
|
|
79
|
+
chain: this.chain,
|
|
80
|
+
owner: address,
|
|
81
|
+
name: nft.name,
|
|
82
|
+
image: this.parseUrl(nft.mediaUrl),
|
|
83
|
+
description: nft.description,
|
|
84
|
+
collectionId: nft.collection.id
|
|
85
|
+
};
|
|
86
|
+
const parsedCollection = {
|
|
87
|
+
collectionId: nft.collection.id,
|
|
88
|
+
chain: this.chain,
|
|
89
|
+
collectionName: nft.collection.name
|
|
90
|
+
};
|
|
91
|
+
params.updateItem(this.chain, parsedNft, address);
|
|
92
|
+
params.updateCollection(this.chain, parsedCollection);
|
|
93
|
+
}
|
|
92
94
|
}
|
|
93
95
|
}));
|
|
94
96
|
} catch (e) {
|
|
@@ -2777,7 +2777,7 @@ class KoniExtension {
|
|
|
2777
2777
|
} = _ref65;
|
|
2778
2778
|
try {
|
|
2779
2779
|
// Remove isMasterPassword meta if createNew
|
|
2780
|
-
if (createNew) {
|
|
2780
|
+
if (createNew && !_uiKeyring.keyring.keyring.hasMasterPassword) {
|
|
2781
2781
|
const pairs = _uiKeyring.keyring.getPairs();
|
|
2782
2782
|
for (const pair of pairs) {
|
|
2783
2783
|
if (pair.meta.isInjected) {
|
|
@@ -3612,6 +3612,47 @@ class KoniExtension {
|
|
|
3612
3612
|
return true;
|
|
3613
3613
|
}
|
|
3614
3614
|
|
|
3615
|
+
/* Campaign */
|
|
3616
|
+
|
|
3617
|
+
async subscribeProcessingBanner(id, port) {
|
|
3618
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3619
|
+
const filterBanner = data => {
|
|
3620
|
+
const result = [];
|
|
3621
|
+
for (const item of data) {
|
|
3622
|
+
if (item.type === _KoniTypes.CampaignDataType.BANNER) {
|
|
3623
|
+
result.push(item);
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
return result;
|
|
3627
|
+
};
|
|
3628
|
+
const callback = data => {
|
|
3629
|
+
cb(filterBanner(data));
|
|
3630
|
+
};
|
|
3631
|
+
const subscription = this.#koniState.campaignService.subscribeProcessingCampaign().subscribe({
|
|
3632
|
+
next: callback
|
|
3633
|
+
});
|
|
3634
|
+
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
3635
|
+
port.onDisconnect.addListener(() => {
|
|
3636
|
+
this.cancelSubscription(id);
|
|
3637
|
+
});
|
|
3638
|
+
return filterBanner(await this.#koniState.campaignService.getProcessingCampaign());
|
|
3639
|
+
}
|
|
3640
|
+
async completeCampaignBanner(_ref91) {
|
|
3641
|
+
let {
|
|
3642
|
+
slug
|
|
3643
|
+
} = _ref91;
|
|
3644
|
+
const campaign = await this.#koniState.dbService.getCampaign(slug);
|
|
3645
|
+
if (campaign) {
|
|
3646
|
+
await this.#koniState.dbService.upsertCampaign({
|
|
3647
|
+
...campaign,
|
|
3648
|
+
isDone: true
|
|
3649
|
+
});
|
|
3650
|
+
}
|
|
3651
|
+
return true;
|
|
3652
|
+
}
|
|
3653
|
+
|
|
3654
|
+
/* Campaign */
|
|
3655
|
+
|
|
3615
3656
|
// --------------------------------------------------------------
|
|
3616
3657
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
3617
3658
|
async handle(id, type, request, port) {
|
|
@@ -4048,6 +4089,13 @@ class KoniExtension {
|
|
|
4048
4089
|
// Metadata
|
|
4049
4090
|
case 'pri(metadata.find)':
|
|
4050
4091
|
return this.findRawMetadata(request);
|
|
4092
|
+
|
|
4093
|
+
/* Campaign */
|
|
4094
|
+
case 'pri(campaign.banner.subscribe)':
|
|
4095
|
+
return this.subscribeProcessingBanner(id, port);
|
|
4096
|
+
case 'pri(campaign.banner.complete)':
|
|
4097
|
+
return this.completeCampaignBanner(request);
|
|
4098
|
+
/* Campaign */
|
|
4051
4099
|
// Default
|
|
4052
4100
|
default:
|
|
4053
4101
|
throw new Error(`Unable to handle message of type ${type}`);
|