@subwallet/extension-base 1.3.7-0 → 1.3.8-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 +7 -5
- package/background/KoniTypes.js +1 -1
- package/cjs/background/KoniTypes.js +1 -1
- package/cjs/core/substrate/xcm-parser.js +16 -2
- package/cjs/koni/api/contract-handler/utils/index.js +15 -1
- package/cjs/koni/background/handlers/Extension.js +42 -3
- package/cjs/koni/background/handlers/State.js +11 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/transfer/xcm/index.js +31 -1
- package/cjs/services/balance-service/transfer/xcm/polygonBridge.js +108 -0
- package/cjs/services/chain-online-service/constants.js +32 -0
- package/cjs/services/chain-online-service/index.js +190 -0
- package/cjs/services/chain-service/index.js +87 -127
- package/cjs/services/chain-service/utils/index.js +0 -2
- package/cjs/services/chain-service/utils/patch.js +7 -3
- package/cjs/services/fee-service/utils/index.js +14 -0
- package/cjs/services/inapp-notification-service/consts.js +6 -4
- package/cjs/services/inapp-notification-service/index.js +110 -6
- package/cjs/services/inapp-notification-service/interfaces.js +9 -1
- package/cjs/services/inapp-notification-service/utils/avail.js +88 -0
- package/cjs/services/inapp-notification-service/{utils.js → utils/common.js} +1 -84
- package/cjs/services/inapp-notification-service/utils/index.js +38 -0
- package/cjs/services/inapp-notification-service/utils/polygon.js +66 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBridge.js +37 -0
- package/cjs/services/migration-service/scripts/index.js +3 -1
- package/cjs/services/setting-service/SettingService.js +8 -0
- package/cjs/services/setting-service/constants.js +2 -1
- package/cjs/services/storage-service/DatabaseService.js +3 -0
- package/cjs/services/transaction-service/index.js +1 -1
- package/cjs/stores/ChainlistStore.js +18 -0
- package/cjs/types/index.js +11 -0
- package/cjs/utils/account/transform.js +1 -1
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +15 -2
- package/koni/api/contract-handler/utils/index.d.ts +2 -0
- package/koni/api/contract-handler/utils/index.js +12 -0
- package/koni/api/contract-handler/utils/polygon_bridge_abi.json +1004 -0
- package/koni/background/handlers/Extension.d.ts +2 -0
- package/koni/background/handlers/Extension.js +43 -4
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +11 -2
- package/package.json +56 -14
- package/packageInfo.js +1 -1
- package/services/balance-service/transfer/xcm/index.d.ts +1 -0
- package/services/balance-service/transfer/xcm/index.js +29 -1
- package/services/balance-service/transfer/xcm/polygonBridge.d.ts +22 -0
- package/services/balance-service/transfer/xcm/polygonBridge.js +95 -0
- package/services/chain-online-service/constants.d.ts +4 -0
- package/services/chain-online-service/constants.js +23 -0
- package/services/chain-online-service/index.d.ts +22 -0
- package/services/chain-online-service/index.js +182 -0
- package/services/chain-service/index.d.ts +6 -7
- package/services/chain-service/index.js +78 -116
- package/services/chain-service/utils/index.js +0 -2
- package/services/chain-service/utils/patch.d.ts +16 -1
- package/services/chain-service/utils/patch.js +7 -3
- package/services/fee-service/utils/index.js +14 -0
- package/services/inapp-notification-service/consts.d.ts +3 -1
- package/services/inapp-notification-service/consts.js +6 -4
- package/services/inapp-notification-service/index.d.ts +10 -2
- package/services/inapp-notification-service/index.js +111 -7
- package/services/inapp-notification-service/interfaces.d.ts +27 -3
- package/services/inapp-notification-service/interfaces.js +7 -0
- package/services/inapp-notification-service/utils/avail.d.ts +40 -0
- package/services/inapp-notification-service/utils/avail.js +73 -0
- package/services/inapp-notification-service/utils/common.d.ts +11 -0
- package/services/inapp-notification-service/{utils.js → utils/common.js} +1 -72
- package/services/inapp-notification-service/utils/index.d.ts +3 -0
- package/services/inapp-notification-service/utils/index.js +6 -0
- package/services/inapp-notification-service/utils/polygon.d.ts +71 -0
- package/services/inapp-notification-service/utils/polygon.js +54 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBridge.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBridge.js +29 -0
- package/services/migration-service/scripts/index.js +3 -1
- package/services/setting-service/SettingService.d.ts +4 -0
- package/services/setting-service/SettingService.js +8 -0
- package/services/setting-service/constants.js +2 -1
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +3 -0
- package/services/transaction-service/index.js +1 -1
- package/stores/ChainlistStore.d.ts +7 -0
- package/stores/ChainlistStore.js +10 -0
- package/types/{avail-bridge → bridge}/index.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/notification/index.d.ts +5 -0
- package/utils/account/transform.js +1 -1
- package/services/inapp-notification-service/utils.d.ts +0 -55
- /package/cjs/types/{avail-bridge → bridge}/index.js +0 -0
- /package/types/{avail-bridge → bridge}/index.js +0 -0
|
@@ -257,6 +257,8 @@ export default class KoniExtension {
|
|
|
257
257
|
private fetchInappNotifications;
|
|
258
258
|
private getInappNotification;
|
|
259
259
|
private submitClaimAvailBridge;
|
|
260
|
+
private getIsClaimedPolygonBridge;
|
|
261
|
+
private submitClaimPolygonBridge;
|
|
260
262
|
private subscribeLedgerGenericAllowChains;
|
|
261
263
|
handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
|
|
262
264
|
}
|
|
@@ -26,8 +26,9 @@ import { isBounceableAddress } from '@subwallet/extension-base/services/balance-
|
|
|
26
26
|
import { getERC20TransactionObject, getERC721Transaction, getEVMTransactionObject, getPSP34TransferExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
|
|
27
27
|
import { createTransferExtrinsic, getTransferMockTxFee } from '@subwallet/extension-base/services/balance-service/transfer/token';
|
|
28
28
|
import { createTonTransaction } from '@subwallet/extension-base/services/balance-service/transfer/ton-transfer';
|
|
29
|
-
import { createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createSnowBridgeExtrinsic, createXcmExtrinsic, getXcmMockTxFee } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
29
|
+
import { createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createPolygonBridgeExtrinsic, createSnowBridgeExtrinsic, createXcmExtrinsic, getXcmMockTxFee } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
30
30
|
import { getClaimTxOnAvail, getClaimTxOnEthereum, isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
31
|
+
import { _isPolygonChainBridge, getClaimPolygonBridge, isClaimedPolygonBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
|
|
31
32
|
import { _API_OPTIONS_CHAIN_GROUP, _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
32
33
|
import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
|
|
33
34
|
import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _isAssetSmartContractNft, _isChainEvmCompatible, _isChainTonCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
|
|
@@ -1255,6 +1256,7 @@ export default class KoniExtension {
|
|
|
1255
1256
|
const isAvailBridgeFromEvm = _isPureEvmChain(chainInfoMap[originNetworkKey]) && isAvailChainBridge(destinationNetworkKey);
|
|
1256
1257
|
const isAvailBridgeFromAvail = isAvailChainBridge(originNetworkKey) && _isPureEvmChain(chainInfoMap[destinationNetworkKey]);
|
|
1257
1258
|
const isSnowBridgeEvmTransfer = _isPureEvmChain(chainInfoMap[originNetworkKey]) && _isSnowBridgeXcm(chainInfoMap[originNetworkKey], chainInfoMap[destinationNetworkKey]) && !isAvailBridgeFromEvm;
|
|
1259
|
+
const isPolygonBridgeTransfer = _isPolygonChainBridge(originNetworkKey, destinationNetworkKey);
|
|
1258
1260
|
let additionalValidator;
|
|
1259
1261
|
let eventsHandler;
|
|
1260
1262
|
if (fromKeyPair && destinationTokenInfo) {
|
|
@@ -1271,7 +1273,9 @@ export default class KoniExtension {
|
|
|
1271
1273
|
evmApi
|
|
1272
1274
|
};
|
|
1273
1275
|
let funcCreateExtrinsic;
|
|
1274
|
-
if (
|
|
1276
|
+
if (isPolygonBridgeTransfer) {
|
|
1277
|
+
funcCreateExtrinsic = createPolygonBridgeExtrinsic;
|
|
1278
|
+
} else if (isSnowBridgeEvmTransfer) {
|
|
1275
1279
|
funcCreateExtrinsic = createSnowBridgeExtrinsic;
|
|
1276
1280
|
} else if (isAvailBridgeFromEvm) {
|
|
1277
1281
|
funcCreateExtrinsic = createAvailBridgeTxFromEth;
|
|
@@ -1336,7 +1340,7 @@ export default class KoniExtension {
|
|
|
1336
1340
|
transaction: extrinsic,
|
|
1337
1341
|
data: inputData,
|
|
1338
1342
|
extrinsicType: ExtrinsicType.TRANSFER_XCM,
|
|
1339
|
-
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm ? ChainType.SUBSTRATE : ChainType.EVM,
|
|
1343
|
+
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm && !isPolygonBridgeTransfer ? ChainType.SUBSTRATE : ChainType.EVM,
|
|
1340
1344
|
transferNativeAmount: _isNativeToken(originTokenInfo) ? value : '0',
|
|
1341
1345
|
ignoreWarnings,
|
|
1342
1346
|
isTransferAll: transferAll,
|
|
@@ -3375,7 +3379,7 @@ export default class KoniExtension {
|
|
|
3375
3379
|
chain,
|
|
3376
3380
|
notification
|
|
3377
3381
|
} = data;
|
|
3378
|
-
const extrinsicType = ExtrinsicType.
|
|
3382
|
+
const extrinsicType = ExtrinsicType.CLAIM_BRIDGE;
|
|
3379
3383
|
let transaction = null;
|
|
3380
3384
|
let chainType;
|
|
3381
3385
|
if (isSubstrateAddress(address)) {
|
|
@@ -3396,6 +3400,32 @@ export default class KoniExtension {
|
|
|
3396
3400
|
chainType
|
|
3397
3401
|
});
|
|
3398
3402
|
}
|
|
3403
|
+
async getIsClaimedPolygonBridge(data) {
|
|
3404
|
+
const evmApi = this.#koniState.getEvmApi(data.chainslug);
|
|
3405
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3406
|
+
const isClaimed = await isClaimedPolygonBridge(data.chainslug, data.counter, data.sourceNetwork, evmApi);
|
|
3407
|
+
return isClaimed;
|
|
3408
|
+
}
|
|
3409
|
+
async submitClaimPolygonBridge(data) {
|
|
3410
|
+
const {
|
|
3411
|
+
address,
|
|
3412
|
+
chain,
|
|
3413
|
+
notification
|
|
3414
|
+
} = data;
|
|
3415
|
+
const extrinsicType = ExtrinsicType.CLAIM_BRIDGE;
|
|
3416
|
+
let transaction = null;
|
|
3417
|
+
const evmApi = this.#koniState.getEvmApi(chain);
|
|
3418
|
+
transaction = await getClaimPolygonBridge(chain, notification, evmApi);
|
|
3419
|
+
const chainType = ChainType.EVM;
|
|
3420
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3421
|
+
address,
|
|
3422
|
+
chain,
|
|
3423
|
+
transaction,
|
|
3424
|
+
data,
|
|
3425
|
+
extrinsicType,
|
|
3426
|
+
chainType
|
|
3427
|
+
});
|
|
3428
|
+
}
|
|
3399
3429
|
|
|
3400
3430
|
/* Ledger */
|
|
3401
3431
|
|
|
@@ -3983,6 +4013,8 @@ export default class KoniExtension {
|
|
|
3983
4013
|
return this.fetchInappNotifications(request);
|
|
3984
4014
|
case 'pri(inappNotification.get)':
|
|
3985
4015
|
return this.getInappNotification(request);
|
|
4016
|
+
case 'pri(inappNotification.isClaimedPolygonBridge)':
|
|
4017
|
+
return this.getIsClaimedPolygonBridge(request);
|
|
3986
4018
|
/* Notification service */
|
|
3987
4019
|
|
|
3988
4020
|
/* Avail Bridge */
|
|
@@ -3990,6 +4022,13 @@ export default class KoniExtension {
|
|
|
3990
4022
|
return this.submitClaimAvailBridge(request);
|
|
3991
4023
|
/* Avail Bridge */
|
|
3992
4024
|
|
|
4025
|
+
/* Polygon Bridge */
|
|
4026
|
+
|
|
4027
|
+
case 'pri(polygonBridge.submitClaimPolygonBridge)':
|
|
4028
|
+
return this.submitClaimPolygonBridge(request);
|
|
4029
|
+
|
|
4030
|
+
/* Polygon Bridge */
|
|
4031
|
+
|
|
3993
4032
|
/* Ledger */
|
|
3994
4033
|
case 'pri(ledger.generic.allow)':
|
|
3995
4034
|
return this.subscribeLedgerGenericAllowChains(id, port);
|
|
@@ -6,6 +6,7 @@ import { EnvConfig } from '@subwallet/extension-base/constants';
|
|
|
6
6
|
import { BalanceService } from '@subwallet/extension-base/services/balance-service';
|
|
7
7
|
import BuyService from '@subwallet/extension-base/services/buy-service';
|
|
8
8
|
import CampaignService from '@subwallet/extension-base/services/campaign-service';
|
|
9
|
+
import { ChainOnlineService } from '@subwallet/extension-base/services/chain-online-service';
|
|
9
10
|
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
10
11
|
import { _ChainState, _NetworkUpsertParams, _ValidateCustomAssetRequest } from '@subwallet/extension-base/services/chain-service/types';
|
|
11
12
|
import EarningService from '@subwallet/extension-base/services/earning-service/service';
|
|
@@ -76,6 +77,7 @@ export default class KoniState {
|
|
|
76
77
|
readonly feeService: FeeService;
|
|
77
78
|
readonly swapService: SwapService;
|
|
78
79
|
readonly inappNotificationService: InappNotificationService;
|
|
80
|
+
readonly chainOnlineService: ChainOnlineService;
|
|
79
81
|
private generalStatus;
|
|
80
82
|
private waitSleeping;
|
|
81
83
|
private waitStarting;
|
|
@@ -11,6 +11,7 @@ import { BalanceService } from '@subwallet/extension-base/services/balance-servi
|
|
|
11
11
|
import { ServiceStatus } from '@subwallet/extension-base/services/base/types';
|
|
12
12
|
import BuyService from '@subwallet/extension-base/services/buy-service';
|
|
13
13
|
import CampaignService from '@subwallet/extension-base/services/campaign-service';
|
|
14
|
+
import { ChainOnlineService } from '@subwallet/extension-base/services/chain-online-service';
|
|
14
15
|
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
15
16
|
import { _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _PREDEFINED_SINGLE_MODES } from '@subwallet/extension-base/services/chain-service/constants';
|
|
16
17
|
import { _getEvmChainId, _getSubstrateGenesisHash, _getTokenOnChainAssetId, _isAssetFungibleToken, _isChainEnabled, _isChainTestNet, _parseMetadataForSmartContractAsset } from '@subwallet/extension-base/services/chain-service/utils';
|
|
@@ -105,6 +106,7 @@ export default class KoniState {
|
|
|
105
106
|
this.feeService = new FeeService(this);
|
|
106
107
|
this.swapService = new SwapService(this);
|
|
107
108
|
this.inappNotificationService = new InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
|
|
109
|
+
this.chainOnlineService = new ChainOnlineService(this.chainService, this.settingService, this.eventService, this.dbService);
|
|
108
110
|
this.subscription = new KoniSubscription(this, this.dbService);
|
|
109
111
|
this.cron = new KoniCron(this, this.subscription, this.dbService);
|
|
110
112
|
this.logger = createLogger('State');
|
|
@@ -198,7 +200,6 @@ export default class KoniState {
|
|
|
198
200
|
async init() {
|
|
199
201
|
await this.eventService.waitCryptoReady;
|
|
200
202
|
await this.chainService.init();
|
|
201
|
-
this.afterChainServiceInit();
|
|
202
203
|
await this.migrationService.run();
|
|
203
204
|
this.campaignService.init();
|
|
204
205
|
this.mktCampaignService.init();
|
|
@@ -214,7 +215,11 @@ export default class KoniState {
|
|
|
214
215
|
// TODO: consider moving this to a separate service
|
|
215
216
|
await this.dbService.stores.crowdloan.removeEndedCrowdloans();
|
|
216
217
|
await this.startSubscription();
|
|
218
|
+
this.chainOnlineService.checkLatestData();
|
|
217
219
|
this.chainService.checkLatestData();
|
|
220
|
+
this.chainService.subscribeChainInfoMap().subscribe(() => {
|
|
221
|
+
this.afterChainServiceInit();
|
|
222
|
+
});
|
|
218
223
|
}
|
|
219
224
|
async initMantaPay(password) {
|
|
220
225
|
var _this$chainService, _this$chainService$ma;
|
|
@@ -779,6 +784,7 @@ export default class KoniState {
|
|
|
779
784
|
return this.chainService.stopAllChainApis();
|
|
780
785
|
}
|
|
781
786
|
async resumeAllNetworks() {
|
|
787
|
+
this.chainOnlineService.checkLatestData();
|
|
782
788
|
return this.chainService.resumeAllChainApis();
|
|
783
789
|
}
|
|
784
790
|
publishCrowdloan(reset) {
|
|
@@ -1331,8 +1337,11 @@ export default class KoniState {
|
|
|
1331
1337
|
this.chainService.resetWallet(resetAll);
|
|
1332
1338
|
await this.walletConnectService.resetWallet(resetAll);
|
|
1333
1339
|
await this.chainService.init();
|
|
1334
|
-
this.
|
|
1340
|
+
this.chainOnlineService.checkLatestData();
|
|
1335
1341
|
this.chainService.checkLatestData();
|
|
1342
|
+
this.chainService.subscribeChainInfoMap().subscribe(() => {
|
|
1343
|
+
this.afterChainServiceInit();
|
|
1344
|
+
});
|
|
1336
1345
|
}
|
|
1337
1346
|
async enableMantaPay(updateStore, address, password, seedPhrase) {
|
|
1338
1347
|
var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService11, _this$chainService11$, _this$chainService11$2;
|
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.8-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -271,6 +271,7 @@
|
|
|
271
271
|
"./koni/api/contract-handler/utils/erc721_abi.json": "./koni/api/contract-handler/utils/erc721_abi.json",
|
|
272
272
|
"./koni/api/contract-handler/utils/neuroguns_psp34_abi.json": "./koni/api/contract-handler/utils/neuroguns_psp34_abi.json",
|
|
273
273
|
"./koni/api/contract-handler/utils/pink_psp34_abi.json": "./koni/api/contract-handler/utils/pink_psp34_abi.json",
|
|
274
|
+
"./koni/api/contract-handler/utils/polygon_bridge_abi.json": "./koni/api/contract-handler/utils/polygon_bridge_abi.json",
|
|
274
275
|
"./koni/api/contract-handler/utils/psp22_abi.json": "./koni/api/contract-handler/utils/psp22_abi.json",
|
|
275
276
|
"./koni/api/contract-handler/utils/psp34_abi.json": "./koni/api/contract-handler/utils/psp34_abi.json",
|
|
276
277
|
"./koni/api/contract-handler/utils/snowbridge_gateway_abi.json": "./koni/api/contract-handler/utils/snowbridge_gateway_abi.json",
|
|
@@ -716,6 +717,11 @@
|
|
|
716
717
|
"require": "./cjs/services/balance-service/transfer/xcm/polkadotXcm.js",
|
|
717
718
|
"default": "./services/balance-service/transfer/xcm/polkadotXcm.js"
|
|
718
719
|
},
|
|
720
|
+
"./services/balance-service/transfer/xcm/polygonBridge": {
|
|
721
|
+
"types": "./services/balance-service/transfer/xcm/polygonBridge.d.ts",
|
|
722
|
+
"require": "./cjs/services/balance-service/transfer/xcm/polygonBridge.js",
|
|
723
|
+
"default": "./services/balance-service/transfer/xcm/polygonBridge.js"
|
|
724
|
+
},
|
|
719
725
|
"./services/balance-service/transfer/xcm/snowBridge": {
|
|
720
726
|
"types": "./services/balance-service/transfer/xcm/snowBridge.d.ts",
|
|
721
727
|
"require": "./cjs/services/balance-service/transfer/xcm/snowBridge.js",
|
|
@@ -776,6 +782,16 @@
|
|
|
776
782
|
"require": "./cjs/services/campaign-service/types.js",
|
|
777
783
|
"default": "./services/campaign-service/types.js"
|
|
778
784
|
},
|
|
785
|
+
"./services/chain-online-service": {
|
|
786
|
+
"types": "./services/chain-online-service/index.d.ts",
|
|
787
|
+
"require": "./cjs/services/chain-online-service/index.js",
|
|
788
|
+
"default": "./services/chain-online-service/index.js"
|
|
789
|
+
},
|
|
790
|
+
"./services/chain-online-service/constants": {
|
|
791
|
+
"types": "./services/chain-online-service/constants.d.ts",
|
|
792
|
+
"require": "./cjs/services/chain-online-service/constants.js",
|
|
793
|
+
"default": "./services/chain-online-service/constants.js"
|
|
794
|
+
},
|
|
779
795
|
"./services/chain-service": {
|
|
780
796
|
"types": "./services/chain-service/index.d.ts",
|
|
781
797
|
"require": "./cjs/services/chain-service/index.js",
|
|
@@ -1124,9 +1140,24 @@
|
|
|
1124
1140
|
"default": "./services/inapp-notification-service/interfaces.js"
|
|
1125
1141
|
},
|
|
1126
1142
|
"./services/inapp-notification-service/utils": {
|
|
1127
|
-
"types": "./services/inapp-notification-service/utils.d.ts",
|
|
1128
|
-
"require": "./cjs/services/inapp-notification-service/utils.js",
|
|
1129
|
-
"default": "./services/inapp-notification-service/utils.js"
|
|
1143
|
+
"types": "./services/inapp-notification-service/utils/index.d.ts",
|
|
1144
|
+
"require": "./cjs/services/inapp-notification-service/utils/index.js",
|
|
1145
|
+
"default": "./services/inapp-notification-service/utils/index.js"
|
|
1146
|
+
},
|
|
1147
|
+
"./services/inapp-notification-service/utils/avail": {
|
|
1148
|
+
"types": "./services/inapp-notification-service/utils/avail.d.ts",
|
|
1149
|
+
"require": "./cjs/services/inapp-notification-service/utils/avail.js",
|
|
1150
|
+
"default": "./services/inapp-notification-service/utils/avail.js"
|
|
1151
|
+
},
|
|
1152
|
+
"./services/inapp-notification-service/utils/common": {
|
|
1153
|
+
"types": "./services/inapp-notification-service/utils/common.d.ts",
|
|
1154
|
+
"require": "./cjs/services/inapp-notification-service/utils/common.js",
|
|
1155
|
+
"default": "./services/inapp-notification-service/utils/common.js"
|
|
1156
|
+
},
|
|
1157
|
+
"./services/inapp-notification-service/utils/polygon": {
|
|
1158
|
+
"types": "./services/inapp-notification-service/utils/polygon.d.ts",
|
|
1159
|
+
"require": "./cjs/services/inapp-notification-service/utils/polygon.js",
|
|
1160
|
+
"default": "./services/inapp-notification-service/utils/polygon.js"
|
|
1130
1161
|
},
|
|
1131
1162
|
"./services/keyring-service": {
|
|
1132
1163
|
"types": "./services/keyring-service/index.d.ts",
|
|
@@ -1358,6 +1389,11 @@
|
|
|
1358
1389
|
"require": "./cjs/services/migration-service/scripts/MigrateTransactionHistory.js",
|
|
1359
1390
|
"default": "./services/migration-service/scripts/MigrateTransactionHistory.js"
|
|
1360
1391
|
},
|
|
1392
|
+
"./services/migration-service/scripts/MigrateTransactionHistoryBridge": {
|
|
1393
|
+
"types": "./services/migration-service/scripts/MigrateTransactionHistoryBridge.d.ts",
|
|
1394
|
+
"require": "./cjs/services/migration-service/scripts/MigrateTransactionHistoryBridge.js",
|
|
1395
|
+
"default": "./services/migration-service/scripts/MigrateTransactionHistoryBridge.js"
|
|
1396
|
+
},
|
|
1361
1397
|
"./services/migration-service/scripts/MigrateTransactionHistoryBySymbol": {
|
|
1362
1398
|
"types": "./services/migration-service/scripts/MigrateTransactionHistoryBySymbol.d.ts",
|
|
1363
1399
|
"require": "./cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js",
|
|
@@ -1848,6 +1884,11 @@
|
|
|
1848
1884
|
"require": "./cjs/stores/Base.js",
|
|
1849
1885
|
"default": "./stores/Base.js"
|
|
1850
1886
|
},
|
|
1887
|
+
"./stores/ChainlistStore": {
|
|
1888
|
+
"types": "./stores/ChainlistStore.d.ts",
|
|
1889
|
+
"require": "./cjs/stores/ChainlistStore.js",
|
|
1890
|
+
"default": "./stores/ChainlistStore.js"
|
|
1891
|
+
},
|
|
1851
1892
|
"./stores/CurrentAccountStore": {
|
|
1852
1893
|
"types": "./stores/CurrentAccountStore.d.ts",
|
|
1853
1894
|
"require": "./cjs/stores/CurrentAccountStore.js",
|
|
@@ -2008,16 +2049,16 @@
|
|
|
2008
2049
|
"require": "./cjs/types/account/info/proxy.js",
|
|
2009
2050
|
"default": "./types/account/info/proxy.js"
|
|
2010
2051
|
},
|
|
2011
|
-
"./types/avail-bridge": {
|
|
2012
|
-
"types": "./types/avail-bridge/index.d.ts",
|
|
2013
|
-
"require": "./cjs/types/avail-bridge/index.js",
|
|
2014
|
-
"default": "./types/avail-bridge/index.js"
|
|
2015
|
-
},
|
|
2016
2052
|
"./types/balance": {
|
|
2017
2053
|
"types": "./types/balance/index.d.ts",
|
|
2018
2054
|
"require": "./cjs/types/balance/index.js",
|
|
2019
2055
|
"default": "./types/balance/index.js"
|
|
2020
2056
|
},
|
|
2057
|
+
"./types/bridge": {
|
|
2058
|
+
"types": "./types/bridge/index.d.ts",
|
|
2059
|
+
"require": "./cjs/types/bridge/index.js",
|
|
2060
|
+
"default": "./types/bridge/index.js"
|
|
2061
|
+
},
|
|
2021
2062
|
"./types/buy": {
|
|
2022
2063
|
"types": "./types/buy.d.ts",
|
|
2023
2064
|
"require": "./cjs/types/buy.js",
|
|
@@ -2450,11 +2491,11 @@
|
|
|
2450
2491
|
"@reduxjs/toolkit": "^1.9.1",
|
|
2451
2492
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2452
2493
|
"@substrate/connect": "^0.8.9",
|
|
2453
|
-
"@subwallet/chain-list": "0.2.95-beta.
|
|
2454
|
-
"@subwallet/extension-base": "^1.3.
|
|
2455
|
-
"@subwallet/extension-chains": "^1.3.
|
|
2456
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
2457
|
-
"@subwallet/extension-inject": "^1.3.
|
|
2494
|
+
"@subwallet/chain-list": "0.2.95-beta.1",
|
|
2495
|
+
"@subwallet/extension-base": "^1.3.8-0",
|
|
2496
|
+
"@subwallet/extension-chains": "^1.3.8-0",
|
|
2497
|
+
"@subwallet/extension-dapp": "^1.3.8-0",
|
|
2498
|
+
"@subwallet/extension-inject": "^1.3.8-0",
|
|
2458
2499
|
"@subwallet/keyring": "^0.1.8-beta.0",
|
|
2459
2500
|
"@subwallet/ui-keyring": "^0.1.8-beta.0",
|
|
2460
2501
|
"@ton/core": "^0.56.3",
|
|
@@ -2488,6 +2529,7 @@
|
|
|
2488
2529
|
"protobufjs": "^7.2.4",
|
|
2489
2530
|
"rxjs": "^7.8.1",
|
|
2490
2531
|
"sails-js": "^0.1.6",
|
|
2532
|
+
"ts-md5": "^1.3.1",
|
|
2491
2533
|
"tweetnacl": "^1.0.3",
|
|
2492
2534
|
"uuid": "^9.0.0",
|
|
2493
2535
|
"web3": "^1.10.0",
|
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.8-0'
|
|
11
11
|
};
|
|
@@ -18,4 +18,5 @@ export declare const createSnowBridgeExtrinsic: ({ chainInfoMap, destinationToke
|
|
|
18
18
|
export declare const createXcmExtrinsic: ({ chainInfoMap, destinationTokenInfo, originTokenInfo, recipient, sendingValue, substrateApi }: CreateXcmExtrinsicProps) => Promise<SubmittableExtrinsic<'promise'>>;
|
|
19
19
|
export declare const createAvailBridgeTxFromEth: ({ chainInfoMap, evmApi, originTokenInfo, recipient, sender, sendingValue }: CreateXcmExtrinsicProps) => Promise<TransactionConfig>;
|
|
20
20
|
export declare const createAvailBridgeExtrinsicFromAvail: ({ recipient, sendingValue, substrateApi }: CreateXcmExtrinsicProps) => Promise<SubmittableExtrinsic<'promise'>>;
|
|
21
|
+
export declare const createPolygonBridgeExtrinsic: ({ chainInfoMap, destinationTokenInfo, evmApi, originTokenInfo, recipient, sender, sendingValue }: CreateXcmExtrinsicProps) => Promise<TransactionConfig>;
|
|
21
22
|
export declare const getXcmMockTxFee: (substrateApi: _SubstrateApi, chainInfoMap: Record<string, _ChainInfo>, originTokenInfo: _ChainAsset, destinationTokenInfo: _ChainAsset) => Promise<BigN>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { _isSnowBridgeXcm } from '@subwallet/extension-base/core/substrate/xcm-parser';
|
|
4
|
+
import { _isPolygonBridgeXcm, _isSnowBridgeXcm } from '@subwallet/extension-base/core/substrate/xcm-parser';
|
|
5
5
|
import { getAvailBridgeExtrinsicFromAvail, getAvailBridgeTxFromEth } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
6
6
|
import { getExtrinsicByPolkadotXcmPallet } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polkadotXcm';
|
|
7
|
+
import { _createPolygonBridgeL1toL2Extrinsic, _createPolygonBridgeL2toL1Extrinsic } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
|
|
7
8
|
import { getSnowBridgeEvmTransfer } from '@subwallet/extension-base/services/balance-service/transfer/xcm/snowBridge';
|
|
8
9
|
import { getExtrinsicByXcmPalletPallet } from '@subwallet/extension-base/services/balance-service/transfer/xcm/xcmPallet';
|
|
9
10
|
import { getExtrinsicByXtokensPallet } from '@subwallet/extension-base/services/balance-service/transfer/xcm/xTokens';
|
|
@@ -85,6 +86,33 @@ export const createAvailBridgeExtrinsicFromAvail = async ({
|
|
|
85
86
|
}
|
|
86
87
|
return await getAvailBridgeExtrinsicFromAvail(recipient, sendingValue, substrateApi);
|
|
87
88
|
};
|
|
89
|
+
export const createPolygonBridgeExtrinsic = async ({
|
|
90
|
+
chainInfoMap,
|
|
91
|
+
destinationTokenInfo,
|
|
92
|
+
evmApi,
|
|
93
|
+
originTokenInfo,
|
|
94
|
+
recipient,
|
|
95
|
+
sender,
|
|
96
|
+
sendingValue
|
|
97
|
+
}) => {
|
|
98
|
+
const originChainInfo = chainInfoMap[originTokenInfo.originChain];
|
|
99
|
+
const destinationChainInfo = chainInfoMap[destinationTokenInfo.originChain];
|
|
100
|
+
if (!_isPolygonBridgeXcm(originChainInfo, destinationChainInfo)) {
|
|
101
|
+
throw new Error('This is not a valid PolygonBridge transfer');
|
|
102
|
+
}
|
|
103
|
+
if (!evmApi) {
|
|
104
|
+
throw Error('Evm API is not available');
|
|
105
|
+
}
|
|
106
|
+
if (!sender) {
|
|
107
|
+
throw Error('Sender is required');
|
|
108
|
+
}
|
|
109
|
+
const sourceChain = originChainInfo.slug;
|
|
110
|
+
if (sourceChain === 'polygonzkEvm_cardona' || sourceChain === 'polygonZkEvm') {
|
|
111
|
+
return _createPolygonBridgeL2toL1Extrinsic(originTokenInfo, originChainInfo, sender, recipient, sendingValue, evmApi);
|
|
112
|
+
} else {
|
|
113
|
+
return _createPolygonBridgeL1toL2Extrinsic(originTokenInfo, originChainInfo, sender, recipient, sendingValue, evmApi);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
88
116
|
export const getXcmMockTxFee = async (substrateApi, chainInfoMap, originTokenInfo, destinationTokenInfo) => {
|
|
89
117
|
try {
|
|
90
118
|
var _paymentInfo$partialF;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
+
import { _EvmApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
3
|
+
import { _NotificationInfo } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
4
|
+
import { TransactionConfig } from 'web3-core';
|
|
5
|
+
export interface gasStation {
|
|
6
|
+
safeLow: number;
|
|
7
|
+
standard: number;
|
|
8
|
+
fastLow: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const POLYGON_PROOF_INDEXER: {
|
|
11
|
+
MAINNET: string;
|
|
12
|
+
TESTNET: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const POLYGON_GAS_INDEXER: {
|
|
15
|
+
MAINNET: string;
|
|
16
|
+
TESTNET: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function _createPolygonBridgeL1toL2Extrinsic(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
19
|
+
export declare function _createPolygonBridgeL2toL1Extrinsic(tokenInfo: _ChainAsset, originChainInfo: _ChainInfo, sender: string, recipientAddress: string, value: string, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
20
|
+
export declare function getClaimPolygonBridge(chainSlug: string, notification: _NotificationInfo, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
21
|
+
export declare function isClaimedPolygonBridge(chainSlug: string, counter: number, sourceNetwork: number, evmApi: _EvmApi): Promise<any>;
|
|
22
|
+
export declare function _isPolygonChainBridge(srcChain: string, destChain: string): boolean;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
|
|
5
|
+
import { getWeb3Contract } from '@subwallet/extension-base/koni/api/contract-handler/evm/web3';
|
|
6
|
+
import { _POLYGON_BRIDGE_ABI, getPolygonBridgeContract } from '@subwallet/extension-base/koni/api/contract-handler/utils';
|
|
7
|
+
import { _getContractAddressOfToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
|
+
import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
|
|
9
|
+
export const POLYGON_PROOF_INDEXER = {
|
|
10
|
+
MAINNET: 'https://api-gateway.polygon.technology/api/v3/proof/mainnet/merkle-proof',
|
|
11
|
+
TESTNET: 'https://api-gateway.polygon.technology/api/v3/proof/testnet/merkle-proof'
|
|
12
|
+
};
|
|
13
|
+
export const POLYGON_GAS_INDEXER = {
|
|
14
|
+
MAINNET: 'https://gasstation.polygon.technology/zkevm',
|
|
15
|
+
TESTNET: 'https://gasstation.polygon.technology/zkevm/cardona'
|
|
16
|
+
};
|
|
17
|
+
async function createPolygonBridgeTransaction(tokenInfo, originChainInfo, sender, recipientAddress, value, destinationNetwork, evmApi) {
|
|
18
|
+
var _priority$maxFeePerGa, _priority$maxPriority;
|
|
19
|
+
const polygonBridgeContractAddress = getPolygonBridgeContract(originChainInfo.slug);
|
|
20
|
+
const polygonBridgeContract = getWeb3Contract(polygonBridgeContractAddress, evmApi, _POLYGON_BRIDGE_ABI);
|
|
21
|
+
const tokenContract = _getContractAddressOfToken(tokenInfo) || '0x0000000000000000000000000000000000000000'; // FOR Ethereum: use null address
|
|
22
|
+
|
|
23
|
+
if (tokenContract !== '0x0000000000000000000000000000000000000000') {
|
|
24
|
+
throw new Error('Only native token transfer is supported');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
28
|
+
const transferCall = polygonBridgeContract.methods.bridgeAsset(destinationNetwork, recipientAddress, value, tokenContract, true, '0x');
|
|
29
|
+
const transferEncodedCall = transferCall.encodeABI();
|
|
30
|
+
const priority = await calculateGasFeeParams(evmApi, evmApi.chainSlug);
|
|
31
|
+
const transactionConfig = {
|
|
32
|
+
from: sender,
|
|
33
|
+
to: polygonBridgeContractAddress,
|
|
34
|
+
value: value,
|
|
35
|
+
data: transferEncodedCall,
|
|
36
|
+
gasPrice: priority.gasPrice,
|
|
37
|
+
maxFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
|
|
38
|
+
maxPriorityFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
|
|
39
|
+
};
|
|
40
|
+
const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);
|
|
41
|
+
transactionConfig.gas = gasLimit.toString();
|
|
42
|
+
return transactionConfig;
|
|
43
|
+
}
|
|
44
|
+
export async function _createPolygonBridgeL1toL2Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi) {
|
|
45
|
+
return createPolygonBridgeTransaction(tokenInfo, originChainInfo, sender, recipientAddress, value, 1, evmApi);
|
|
46
|
+
}
|
|
47
|
+
export async function _createPolygonBridgeL2toL1Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi) {
|
|
48
|
+
return createPolygonBridgeTransaction(tokenInfo, originChainInfo, sender, recipientAddress, value, 0, evmApi);
|
|
49
|
+
}
|
|
50
|
+
export async function getClaimPolygonBridge(chainSlug, notification, evmApi) {
|
|
51
|
+
var _priority$maxFeePerGa2, _priority$maxPriority2;
|
|
52
|
+
const polygonBridgeContractAddress = getPolygonBridgeContract(chainSlug);
|
|
53
|
+
const polygonBridgeContract = getWeb3Contract(polygonBridgeContractAddress, evmApi, _POLYGON_BRIDGE_ABI);
|
|
54
|
+
const metadata = notification.metadata;
|
|
55
|
+
const isTestnet = chainSlug === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA;
|
|
56
|
+
const proofDomain = isTestnet ? POLYGON_PROOF_INDEXER.TESTNET : POLYGON_PROOF_INDEXER.MAINNET;
|
|
57
|
+
const proofResponse = await fetch(`${proofDomain}?networkId=${metadata.sourceNetwork}&depositCount=${metadata.counter}`).then(res => res.json());
|
|
58
|
+
const proof = proofResponse.proof;
|
|
59
|
+
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
61
|
+
const transferCall = polygonBridgeContract.methods.claimAsset(proof.merkle_proof, proof.rollup_merkle_proof, metadata.counter, proof.main_exit_root, proof.rollup_exit_root, metadata.originTokenNetwork, metadata.originTokenAddress, metadata.destinationNetwork, metadata.receiver, metadata.amounts[0], '0x');
|
|
62
|
+
const transferEncodedCall = transferCall.encodeABI();
|
|
63
|
+
const priority = await calculateGasFeeParams(evmApi, evmApi.chainSlug);
|
|
64
|
+
const transactionConfig = {
|
|
65
|
+
from: metadata.userAddress,
|
|
66
|
+
to: polygonBridgeContractAddress,
|
|
67
|
+
value: '0',
|
|
68
|
+
data: transferEncodedCall,
|
|
69
|
+
gasPrice: priority.gasPrice,
|
|
70
|
+
maxFeePerGas: (_priority$maxFeePerGa2 = priority.maxFeePerGas) === null || _priority$maxFeePerGa2 === void 0 ? void 0 : _priority$maxFeePerGa2.toString(),
|
|
71
|
+
maxPriorityFeePerGas: (_priority$maxPriority2 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority2 === void 0 ? void 0 : _priority$maxPriority2.toString()
|
|
72
|
+
};
|
|
73
|
+
const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);
|
|
74
|
+
transactionConfig.gas = gasLimit.toString();
|
|
75
|
+
return transactionConfig;
|
|
76
|
+
}
|
|
77
|
+
export async function isClaimedPolygonBridge(chainSlug, counter, sourceNetwork, evmApi) {
|
|
78
|
+
const polygonBridgeContractAddress = getPolygonBridgeContract(chainSlug);
|
|
79
|
+
const polygonBridgeContract = getWeb3Contract(polygonBridgeContractAddress, evmApi, _POLYGON_BRIDGE_ABI);
|
|
80
|
+
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-member-access
|
|
82
|
+
return await polygonBridgeContract.methods.isClaimed(counter, sourceNetwork).call();
|
|
83
|
+
}
|
|
84
|
+
export function _isPolygonChainBridge(srcChain, destChain) {
|
|
85
|
+
if (srcChain === 'polygonzkEvm_cardona' && destChain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
|
|
86
|
+
return true;
|
|
87
|
+
} else if (srcChain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA && destChain === 'polygonzkEvm_cardona') {
|
|
88
|
+
return true;
|
|
89
|
+
} else if (srcChain === 'polygonZkEvm' && destChain === COMMON_CHAIN_SLUGS.ETHEREUM) {
|
|
90
|
+
return true;
|
|
91
|
+
} else if (srcChain === COMMON_CHAIN_SLUGS.ETHEREUM && destChain === 'polygonZkEvm') {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
+
export declare const LATEST_CHAIN_PATCH_FETCHING_INTERVAL = 180000;
|
|
3
|
+
export declare function md5HashChainInfo(data: _ChainInfo): string;
|
|
4
|
+
export declare function md5HashChainAsset(data: _ChainAsset): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { Md5 } from 'ts-md5';
|
|
5
|
+
export const LATEST_CHAIN_PATCH_FETCHING_INTERVAL = 180000;
|
|
6
|
+
export function md5HashChainInfo(data) {
|
|
7
|
+
// todo: use from chain list package later
|
|
8
|
+
const {
|
|
9
|
+
chainStatus,
|
|
10
|
+
icon,
|
|
11
|
+
providers,
|
|
12
|
+
...chainBaseInfo
|
|
13
|
+
} = data;
|
|
14
|
+
return Md5.hashStr(JSON.stringify(chainBaseInfo));
|
|
15
|
+
}
|
|
16
|
+
export function md5HashChainAsset(data) {
|
|
17
|
+
// todo: use from chain list package later
|
|
18
|
+
const {
|
|
19
|
+
icon,
|
|
20
|
+
...assetBaseInfo
|
|
21
|
+
} = data;
|
|
22
|
+
return Md5.hashStr(JSON.stringify(assetBaseInfo));
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
3
|
+
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
4
|
+
import { PatchInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
5
|
+
import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
6
|
+
import SettingService from '@subwallet/extension-base/services/setting-service/SettingService';
|
|
7
|
+
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
|
|
8
|
+
export declare class ChainOnlineService {
|
|
9
|
+
private chainService;
|
|
10
|
+
private settingService;
|
|
11
|
+
private eventService;
|
|
12
|
+
private dbService;
|
|
13
|
+
private firstApplied;
|
|
14
|
+
refreshLatestChainDataTimeOut: NodeJS.Timer | undefined;
|
|
15
|
+
constructor(chainService: ChainService, settingService: SettingService, eventService: EventService, dbService: DatabaseService);
|
|
16
|
+
validatePatchWithHash(latestPatch: PatchInfo): boolean;
|
|
17
|
+
validatePatchBeforeStore(candidateChainInfoMap: Record<string, _ChainInfo>, candidateAssetRegistry: Record<string, _ChainAsset>, latestPatch: PatchInfo): boolean;
|
|
18
|
+
handleLatestPatch(latestPatch: PatchInfo): Promise<void>;
|
|
19
|
+
private fetchLatestPatchData;
|
|
20
|
+
handleLatestPatchData(): void;
|
|
21
|
+
checkLatestData(): void;
|
|
22
|
+
}
|