@subwallet/extension-base 1.1.2-1 → 1.1.4-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 +18 -0
- package/background/KoniTypes.js +2 -1
- package/cjs/background/KoniTypes.js +4 -2
- package/cjs/koni/api/dotsama/transfer.js +0 -2
- package/cjs/koni/api/nft/config.js +13 -13
- package/cjs/koni/api/nft/nft.js +1 -1
- package/cjs/koni/api/nft/rmrk_nft/index.js +57 -48
- package/cjs/koni/background/handlers/Extension.js +179 -120
- package/cjs/koni/background/handlers/State.js +73 -48
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +2 -1
- package/cjs/services/chain-service/handler/SubstrateApi.js +8 -0
- package/cjs/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
- package/cjs/services/chain-service/handler/manta/manta-extension-sdk-empty.js +13 -0
- package/cjs/services/chain-service/index.js +20 -6
- package/cjs/services/request-service/handler/PopupHandler.js +2 -2
- package/cjs/services/request-service/helper/index.js +2 -26
- package/cjs/services/storage-service/db-stores/Metadata.js +1 -1
- package/cjs/services/wallet-connect-service/constants.js +8 -5
- package/cjs/services/wallet-connect-service/index.js +50 -36
- package/cjs/utils/environment.js +32 -2
- package/cjs/utils/index.js +21 -5
- package/cjs/utils/registry.js +25 -0
- package/koni/api/dotsama/transfer.js +0 -2
- package/koni/api/nft/config.d.ts +3 -3
- package/koni/api/nft/config.js +9 -9
- package/koni/api/nft/nft.js +1 -1
- package/koni/api/nft/rmrk_nft/index.d.ts +0 -1
- package/koni/api/nft/rmrk_nft/index.js +58 -49
- package/koni/background/handlers/Extension.d.ts +2 -0
- package/koni/background/handlers/Extension.js +72 -15
- package/koni/background/handlers/State.d.ts +7 -2
- package/koni/background/handlers/State.js +73 -48
- package/package.json +17 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +2 -1
- package/services/chain-service/handler/SubstrateApi.js +8 -0
- package/services/chain-service/handler/manta/MantaPrivateHandler.d.ts +1 -1
- package/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
- package/services/chain-service/handler/manta/manta-extension-sdk-empty.d.ts +4 -0
- package/services/chain-service/handler/manta/manta-extension-sdk-empty.js +5 -0
- package/services/chain-service/index.d.ts +2 -1
- package/services/chain-service/index.js +20 -6
- package/services/request-service/handler/PopupHandler.js +1 -1
- package/services/request-service/helper/index.d.ts +0 -2
- package/services/request-service/helper/index.js +0 -23
- package/services/request-service/types.d.ts +0 -1
- package/services/storage-service/db-stores/Metadata.js +1 -1
- package/services/wallet-connect-service/constants.d.ts +2 -1
- package/services/wallet-connect-service/constants.js +5 -3
- package/services/wallet-connect-service/index.d.ts +0 -1
- package/services/wallet-connect-service/index.js +50 -36
- package/utils/environment.d.ts +4 -1
- package/utils/environment.js +28 -1
- package/utils/index.d.ts +2 -0
- package/utils/index.js +4 -1
- package/utils/registry.d.ts +4 -0
- package/utils/registry.js +18 -0
|
@@ -20,7 +20,7 @@ import { getPoolingBondingExtrinsic, getPoolingUnbondingExtrinsic, validatePoolB
|
|
|
20
20
|
import { getERC20TransactionObject, getERC721Transaction, getEVMTransactionObject } from '@subwallet/extension-base/koni/api/tokens/evm/transfer';
|
|
21
21
|
import { getPSP34TransferExtrinsic } from '@subwallet/extension-base/koni/api/tokens/wasm';
|
|
22
22
|
import { createXcmExtrinsic } from '@subwallet/extension-base/koni/api/xcm';
|
|
23
|
-
import { _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
23
|
+
import { _API_OPTIONS_CHAIN_GROUP, _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
24
24
|
import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
|
|
25
25
|
import { _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getSubstrateGenesisHash, _getTokenMinAmount, _isAssetSmartContractNft, _isChainEvmCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isTokenEvmSmartContract, _isTokenTransferredByEvm } from '@subwallet/extension-base/services/chain-service/utils';
|
|
26
26
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
@@ -879,6 +879,12 @@ export default class KoniExtension {
|
|
|
879
879
|
this.#koniState.updateSetting('language', language);
|
|
880
880
|
return true;
|
|
881
881
|
}
|
|
882
|
+
setShowBalance({
|
|
883
|
+
enable
|
|
884
|
+
}) {
|
|
885
|
+
this.#koniState.updateSetting('isShowBalance', enable);
|
|
886
|
+
return true;
|
|
887
|
+
}
|
|
882
888
|
async subscribeAuthUrls(id, port) {
|
|
883
889
|
const cb = createSubscription(id, port);
|
|
884
890
|
const authorizeUrlSubscription = this.#koniState.subscribeAuthorizeUrlSubject().subscribe({
|
|
@@ -1479,6 +1485,8 @@ export default class KoniExtension {
|
|
|
1479
1485
|
|
|
1480
1486
|
const additionalValidator = async inputTransaction => {
|
|
1481
1487
|
const minAmount = tokenInfo.minAmount || '0';
|
|
1488
|
+
|
|
1489
|
+
// Check ed for sender
|
|
1482
1490
|
if (!isTransferNativeToken) {
|
|
1483
1491
|
const {
|
|
1484
1492
|
value: balance
|
|
@@ -1494,10 +1502,12 @@ export default class KoniExtension {
|
|
|
1494
1502
|
const {
|
|
1495
1503
|
value: receiverBalance
|
|
1496
1504
|
} = await this.getAddressFreeBalance({
|
|
1497
|
-
address:
|
|
1505
|
+
address: to,
|
|
1498
1506
|
networkKey,
|
|
1499
1507
|
token: tokenSlug
|
|
1500
1508
|
});
|
|
1509
|
+
|
|
1510
|
+
// Check ed for receiver
|
|
1501
1511
|
if (new BigN(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
|
|
1502
1512
|
const atLeast = new BigN(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
|
|
1503
1513
|
const atLeastStr = formatNumber(atLeast, tokenInfo.decimals || 0, balanceFormatter);
|
|
@@ -1561,16 +1571,24 @@ export default class KoniExtension {
|
|
|
1561
1571
|
additionalValidator = async inputTransaction => {
|
|
1562
1572
|
const destMinAmount = destinationTokenInfo.minAmount || '0';
|
|
1563
1573
|
const atLeast = new BigN(destMinAmount).multipliedBy(XCM_MIN_AMOUNT_RATIO);
|
|
1574
|
+
|
|
1575
|
+
// Check ed for receiver
|
|
1564
1576
|
if (new BigN(value).lt(atLeast)) {
|
|
1565
1577
|
const atLeastStr = formatNumber(atLeast, destinationTokenInfo.decimals || 0, balanceFormatter);
|
|
1566
1578
|
inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, `You must transfer at least ${atLeastStr} ${originTokenInfo.symbol} to keep the destination account alive`));
|
|
1567
1579
|
}
|
|
1568
1580
|
const srcMinAmount = originTokenInfo.minAmount || '0';
|
|
1569
1581
|
const isTransferNativeToken = originTokenInfo.assetType === _AssetType.NATIVE;
|
|
1582
|
+
|
|
1583
|
+
// Check ed for sender
|
|
1570
1584
|
if (!isTransferNativeToken) {
|
|
1571
1585
|
const {
|
|
1572
1586
|
value: balance
|
|
1573
|
-
} = await this
|
|
1587
|
+
} = await this.getAddressFreeBalance({
|
|
1588
|
+
address: from,
|
|
1589
|
+
networkKey: originNetworkKey,
|
|
1590
|
+
token: originTokenInfo.slug
|
|
1591
|
+
});
|
|
1574
1592
|
if (new BigN(balance).minus(value).lt(srcMinAmount)) {
|
|
1575
1593
|
inputTransaction.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
|
|
1576
1594
|
}
|
|
@@ -2747,7 +2765,7 @@ export default class KoniExtension {
|
|
|
2747
2765
|
const {
|
|
2748
2766
|
payload
|
|
2749
2767
|
} = request;
|
|
2750
|
-
|
|
2768
|
+
let registry = new TypeRegistry();
|
|
2751
2769
|
let isEvm = false;
|
|
2752
2770
|
if (isJsonPayload(payload)) {
|
|
2753
2771
|
// Get the metadata for the genesisHash
|
|
@@ -2759,6 +2777,15 @@ export default class KoniExtension {
|
|
|
2759
2777
|
registry.register(currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.types);
|
|
2760
2778
|
}
|
|
2761
2779
|
const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
|
|
2780
|
+
if (chainInfo && _API_OPTIONS_CHAIN_GROUP.avail.includes(chainInfo.slug)) {
|
|
2781
|
+
const isChainActive = this.#koniState.getChainStateByKey(chainInfo.slug).active;
|
|
2782
|
+
if (!isChainActive) {
|
|
2783
|
+
reject(new Error('Unable to sign'));
|
|
2784
|
+
return false;
|
|
2785
|
+
} else {
|
|
2786
|
+
registry = this.#koniState.getSubstrateApi(chainInfo.slug).api.registry;
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2762
2789
|
if (chainInfo) {
|
|
2763
2790
|
isEvm = _isChainEvmCompatible(chainInfo);
|
|
2764
2791
|
}
|
|
@@ -3201,6 +3228,7 @@ export default class KoniExtension {
|
|
|
3201
3228
|
return new Promise(resolve => setTimeout(resolve, 1500));
|
|
3202
3229
|
}
|
|
3203
3230
|
try {
|
|
3231
|
+
var _this$koniState$chain, _this$koniState$chain2;
|
|
3204
3232
|
await this.#koniState.chainService.enableChain(_DEFAULT_MANTA_ZK_CHAIN);
|
|
3205
3233
|
this.#koniState.chainService.setMantaZkAssetSettings(true);
|
|
3206
3234
|
const mnemonic = this.keyringExportMnemonic({
|
|
@@ -3219,16 +3247,16 @@ export default class KoniExtension {
|
|
|
3219
3247
|
await this.saveCurrentAccountAddress({
|
|
3220
3248
|
address
|
|
3221
3249
|
});
|
|
3222
|
-
const unsubSyncProgress = await this.#koniState.chainService.mantaPay.subscribeSyncProgress();
|
|
3250
|
+
const unsubSyncProgress = await ((_this$koniState$chain = this.#koniState.chainService) === null || _this$koniState$chain === void 0 ? void 0 : (_this$koniState$chain2 = _this$koniState$chain.mantaPay) === null || _this$koniState$chain2 === void 0 ? void 0 : _this$koniState$chain2.subscribeSyncProgress());
|
|
3223
3251
|
console.debug('Start initial sync for MantaPay');
|
|
3224
3252
|
this.#koniState.initialSyncMantaPay(address).then(() => {
|
|
3225
3253
|
console.debug('Finished initial sync for MantaPay');
|
|
3226
3254
|
this.#skipAutoLock = false;
|
|
3227
|
-
unsubSyncProgress();
|
|
3255
|
+
unsubSyncProgress && unsubSyncProgress();
|
|
3228
3256
|
}).catch(e => {
|
|
3229
3257
|
console.error('Error syncing MantaPay', e);
|
|
3230
3258
|
this.#skipAutoLock = false;
|
|
3231
|
-
unsubSyncProgress();
|
|
3259
|
+
unsubSyncProgress && unsubSyncProgress();
|
|
3232
3260
|
});
|
|
3233
3261
|
return {
|
|
3234
3262
|
success: !!result,
|
|
@@ -3250,29 +3278,32 @@ export default class KoniExtension {
|
|
|
3250
3278
|
}
|
|
3251
3279
|
}
|
|
3252
3280
|
async initSyncMantaPay(address) {
|
|
3253
|
-
|
|
3281
|
+
var _this$koniState$chain3, _this$koniState$chain4, _this$koniState$chain5, _this$koniState$chain6;
|
|
3282
|
+
if ((_this$koniState$chain3 = this.#koniState.chainService) !== null && _this$koniState$chain3 !== void 0 && (_this$koniState$chain4 = _this$koniState$chain3.mantaPay) !== null && _this$koniState$chain4 !== void 0 && _this$koniState$chain4.getSyncState().isSyncing) {
|
|
3254
3283
|
return;
|
|
3255
3284
|
}
|
|
3256
3285
|
this.#skipAutoLock = true;
|
|
3257
3286
|
await this.saveCurrentAccountAddress({
|
|
3258
3287
|
address
|
|
3259
3288
|
});
|
|
3260
|
-
const unsubSyncProgress = await this.#koniState.chainService.mantaPay.subscribeSyncProgress();
|
|
3289
|
+
const unsubSyncProgress = await ((_this$koniState$chain5 = this.#koniState.chainService) === null || _this$koniState$chain5 === void 0 ? void 0 : (_this$koniState$chain6 = _this$koniState$chain5.mantaPay) === null || _this$koniState$chain6 === void 0 ? void 0 : _this$koniState$chain6.subscribeSyncProgress());
|
|
3261
3290
|
console.debug('Start initial sync for MantaPay');
|
|
3262
3291
|
this.#koniState.initialSyncMantaPay(address).then(() => {
|
|
3292
|
+
var _this$koniState$chain7, _this$koniState$chain8;
|
|
3263
3293
|
console.debug('Finished initial sync for MantaPay');
|
|
3264
3294
|
this.#skipAutoLock = false;
|
|
3265
|
-
unsubSyncProgress();
|
|
3295
|
+
unsubSyncProgress && unsubSyncProgress();
|
|
3266
3296
|
// make sure the sync state is set, just in case it gets unsubscribed
|
|
3267
|
-
this.#koniState.chainService.mantaPay.setSyncState({
|
|
3297
|
+
(_this$koniState$chain7 = this.#koniState.chainService) === null || _this$koniState$chain7 === void 0 ? void 0 : (_this$koniState$chain8 = _this$koniState$chain7.mantaPay) === null || _this$koniState$chain8 === void 0 ? void 0 : _this$koniState$chain8.setSyncState({
|
|
3268
3298
|
progress: 100,
|
|
3269
3299
|
isSyncing: false
|
|
3270
3300
|
});
|
|
3271
3301
|
}).catch(e => {
|
|
3302
|
+
var _this$koniState$chain9, _this$koniState$chain10;
|
|
3272
3303
|
console.error('Error syncing MantaPay', e);
|
|
3273
3304
|
this.#skipAutoLock = false;
|
|
3274
|
-
unsubSyncProgress();
|
|
3275
|
-
this.#koniState.chainService.mantaPay.setSyncState({
|
|
3305
|
+
unsubSyncProgress && unsubSyncProgress();
|
|
3306
|
+
(_this$koniState$chain9 = this.#koniState.chainService) === null || _this$koniState$chain9 === void 0 ? void 0 : (_this$koniState$chain10 = _this$koniState$chain9.mantaPay) === null || _this$koniState$chain10 === void 0 ? void 0 : _this$koniState$chain10.setSyncState({
|
|
3276
3307
|
progress: 0,
|
|
3277
3308
|
isSyncing: false
|
|
3278
3309
|
});
|
|
@@ -3295,8 +3326,9 @@ export default class KoniExtension {
|
|
|
3295
3326
|
return this.#koniState.getMantaPayConfig('calamari');
|
|
3296
3327
|
}
|
|
3297
3328
|
subscribeMantaPaySyncState(id, port) {
|
|
3329
|
+
var _this$koniState$subsc, _this$koniState$chain11, _this$koniState$chain12;
|
|
3298
3330
|
const cb = createSubscription(id, port);
|
|
3299
|
-
const syncingStateSubscription = this.#koniState.subscribeMantaPaySyncState().subscribe({
|
|
3331
|
+
const syncingStateSubscription = (_this$koniState$subsc = this.#koniState.subscribeMantaPaySyncState()) === null || _this$koniState$subsc === void 0 ? void 0 : _this$koniState$subsc.subscribe({
|
|
3300
3332
|
next: rs => {
|
|
3301
3333
|
cb(rs);
|
|
3302
3334
|
}
|
|
@@ -3305,7 +3337,26 @@ export default class KoniExtension {
|
|
|
3305
3337
|
port.onDisconnect.addListener(() => {
|
|
3306
3338
|
this.cancelSubscription(id);
|
|
3307
3339
|
});
|
|
3308
|
-
return this.#koniState.chainService.mantaPay.getSyncState()
|
|
3340
|
+
return ((_this$koniState$chain11 = this.#koniState.chainService) === null || _this$koniState$chain11 === void 0 ? void 0 : (_this$koniState$chain12 = _this$koniState$chain11.mantaPay) === null || _this$koniState$chain12 === void 0 ? void 0 : _this$koniState$chain12.getSyncState()) || {
|
|
3341
|
+
isSyncing: false,
|
|
3342
|
+
progress: 0,
|
|
3343
|
+
needManualSync: false
|
|
3344
|
+
};
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3347
|
+
/// Metadata
|
|
3348
|
+
|
|
3349
|
+
async findRawMetadata({
|
|
3350
|
+
genesisHash
|
|
3351
|
+
}) {
|
|
3352
|
+
const {
|
|
3353
|
+
metadata,
|
|
3354
|
+
specVersion
|
|
3355
|
+
} = await this.#koniState.findMetadata(genesisHash);
|
|
3356
|
+
return {
|
|
3357
|
+
rawMetadata: metadata,
|
|
3358
|
+
specVersion
|
|
3359
|
+
};
|
|
3309
3360
|
}
|
|
3310
3361
|
|
|
3311
3362
|
// --------------------------------------------------------------
|
|
@@ -3417,6 +3468,8 @@ export default class KoniExtension {
|
|
|
3417
3468
|
return this.setShowZeroBalance(request);
|
|
3418
3469
|
case 'pri(settings.saveLanguage)':
|
|
3419
3470
|
return this.setLanguage(request);
|
|
3471
|
+
case 'pri(settings.saveShowBalance)':
|
|
3472
|
+
return this.setShowBalance(request);
|
|
3420
3473
|
case 'pri(price.getPrice)':
|
|
3421
3474
|
return await this.getPrice();
|
|
3422
3475
|
case 'pri(price.getSubscription)':
|
|
@@ -3710,6 +3763,10 @@ export default class KoniExtension {
|
|
|
3710
3763
|
return await this.disableMantaPay(request);
|
|
3711
3764
|
case 'pri(mantaPay.subscribeSyncingState)':
|
|
3712
3765
|
return this.subscribeMantaPaySyncState(id, port);
|
|
3766
|
+
|
|
3767
|
+
// Metadata
|
|
3768
|
+
case 'pri(metadata.find)':
|
|
3769
|
+
return this.findRawMetadata(request);
|
|
3713
3770
|
// Default
|
|
3714
3771
|
default:
|
|
3715
3772
|
throw new Error(`Unable to handle message of type ${type}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="chrome" />
|
|
2
2
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
3
|
-
import { AddTokenRequestExternal, AmountData, ApiMap, AuthRequestV2, BalanceItem, BalanceJson, ChainStakingMetadata, ConfirmationsQueue, CrowdloanItem, CrowdloanJson, CurrentAccountInfo, EvmSendTransactionParams, ExternalRequestPromise, MantaPayConfig, NftCollection, NftItem, NftJson, NominatorMetadata, RequestAccountExportPrivateKey, RequestCheckPublicAndSecretKey, RequestConfirmationComplete, RequestSettingsType, ResponseAccountExportPrivateKey, ResponseCheckPublicAndSecretKey, ServiceInfo, SingleModeJson, StakingItem, StakingJson, StakingRewardItem, StakingRewardJson, StakingType, UiSettings } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
+
import { AddTokenRequestExternal, AmountData, ApiMap, AuthRequestV2, BalanceItem, BalanceJson, ChainStakingMetadata, ConfirmationsQueue, CrowdloanItem, CrowdloanJson, CurrentAccountInfo, EvmSendTransactionParams, ExternalRequestPromise, MantaPayConfig, MantaPaySyncState, NftCollection, NftItem, NftJson, NominatorMetadata, RequestAccountExportPrivateKey, RequestCheckPublicAndSecretKey, RequestConfirmationComplete, RequestSettingsType, ResponseAccountExportPrivateKey, ResponseCheckPublicAndSecretKey, ServiceInfo, SingleModeJson, StakingItem, StakingJson, StakingRewardItem, StakingRewardJson, StakingType, UiSettings } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
4
|
import { AccountJson, RequestAuthorizeTab, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, RequestSign, ResponseRpcListProviders, ResponseSigning } from '@subwallet/extension-base/background/types';
|
|
5
5
|
import { BalanceService } from '@subwallet/extension-base/services/balance-service';
|
|
6
6
|
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
@@ -139,6 +139,7 @@ export default class KoniState {
|
|
|
139
139
|
getSettings(callback: (settings: UiSettings) => void): void;
|
|
140
140
|
setSettings(settings: UiSettings, callback?: () => void): void;
|
|
141
141
|
updateSetting<T extends keyof UiSettings>(key: T, value: UiSettings[T]): void;
|
|
142
|
+
setShowBalance(value: boolean): void;
|
|
142
143
|
subscribeSettingsSubject(): Subject<RequestSettingsType>;
|
|
143
144
|
getAccountAddress(): string | null;
|
|
144
145
|
getDecodedAddresses(address?: string): string[];
|
|
@@ -236,6 +237,10 @@ export default class KoniState {
|
|
|
236
237
|
subscribeMantaPayBalance(): () => void;
|
|
237
238
|
syncMantaPay(): Promise<void>;
|
|
238
239
|
getMantaPayZkBalance(address: string, tokenInfo: _ChainAsset): Promise<AmountData>;
|
|
239
|
-
subscribeMantaPaySyncState(): Subject<
|
|
240
|
+
subscribeMantaPaySyncState(): Subject<MantaPaySyncState>;
|
|
241
|
+
findMetadata(hash: string): Promise<{
|
|
242
|
+
metadata: string;
|
|
243
|
+
specVersion: number;
|
|
244
|
+
}>;
|
|
240
245
|
}
|
|
241
246
|
export {};
|
|
@@ -213,7 +213,8 @@ export default class KoniState {
|
|
|
213
213
|
await this.startSubscription();
|
|
214
214
|
}
|
|
215
215
|
async initMantaPay(password) {
|
|
216
|
-
|
|
216
|
+
var _this$chainService, _this$chainService$ma;
|
|
217
|
+
const mantaPayConfig = await ((_this$chainService = this.chainService) === null || _this$chainService === void 0 ? void 0 : (_this$chainService$ma = _this$chainService.mantaPay) === null || _this$chainService$ma === void 0 ? void 0 : _this$chainService$ma.getMantaPayFirstConfig(_DEFAULT_MANTA_ZK_CHAIN));
|
|
217
218
|
if (mantaPayConfig && mantaPayConfig.enabled && !this.isMantaPayEnabled) {
|
|
218
219
|
// only init the first login
|
|
219
220
|
console.debug('Initiating MantaPay for', mantaPayConfig.address);
|
|
@@ -614,6 +615,15 @@ export default class KoniState {
|
|
|
614
615
|
this.settingService.setSettings(newSettings);
|
|
615
616
|
});
|
|
616
617
|
}
|
|
618
|
+
setShowBalance(value) {
|
|
619
|
+
this.settingService.getSettings(settings => {
|
|
620
|
+
const newSettings = {
|
|
621
|
+
...settings,
|
|
622
|
+
isShowBalance: value
|
|
623
|
+
};
|
|
624
|
+
this.settingService.setSettings(newSettings);
|
|
625
|
+
});
|
|
626
|
+
}
|
|
617
627
|
subscribeSettingsSubject() {
|
|
618
628
|
return this.settingService.getSubject();
|
|
619
629
|
}
|
|
@@ -862,7 +872,8 @@ export default class KoniState {
|
|
|
862
872
|
async disableChain(chainSlug) {
|
|
863
873
|
await this.chainService.updateAssetSettingByChain(chainSlug, false);
|
|
864
874
|
if (_MANTA_ZK_CHAIN_GROUP.includes(chainSlug)) {
|
|
865
|
-
|
|
875
|
+
var _this$chainService2, _this$chainService2$m;
|
|
876
|
+
const mantaPayConfig = await ((_this$chainService2 = this.chainService) === null || _this$chainService2 === void 0 ? void 0 : (_this$chainService2$m = _this$chainService2.mantaPay) === null || _this$chainService2$m === void 0 ? void 0 : _this$chainService2$m.getMantaPayFirstConfig(_DEFAULT_MANTA_ZK_CHAIN));
|
|
866
877
|
if (mantaPayConfig && mantaPayConfig.enabled && this.isMantaPayEnabled) {
|
|
867
878
|
await this.disableMantaPay(mantaPayConfig.address);
|
|
868
879
|
}
|
|
@@ -1533,95 +1544,95 @@ export default class KoniState {
|
|
|
1533
1544
|
await this.chainService.init();
|
|
1534
1545
|
}
|
|
1535
1546
|
async enableMantaPay(updateStore, address, password, seedPhrase) {
|
|
1536
|
-
var _this$
|
|
1547
|
+
var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService11, _this$chainService11$, _this$chainService11$2;
|
|
1537
1548
|
if (!address || isEthereumAddress(address)) {
|
|
1538
1549
|
return;
|
|
1539
1550
|
}
|
|
1540
|
-
this.chainService.mantaPay.setCurrentAddress(address);
|
|
1541
|
-
await ((_this$
|
|
1551
|
+
(_this$chainService3 = this.chainService) === null || _this$chainService3 === void 0 ? void 0 : (_this$chainService3$m = _this$chainService3.mantaPay) === null || _this$chainService3$m === void 0 ? void 0 : _this$chainService3$m.setCurrentAddress(address);
|
|
1552
|
+
await ((_this$chainService4 = this.chainService) === null || _this$chainService4 === void 0 ? void 0 : (_this$chainService4$m = _this$chainService4.mantaPay) === null || _this$chainService4$m === void 0 ? void 0 : (_this$chainService4$m2 = _this$chainService4$m.privateWallet) === null || _this$chainService4$m2 === void 0 ? void 0 : _this$chainService4$m2.initialSigner());
|
|
1542
1553
|
if (updateStore && seedPhrase) {
|
|
1543
|
-
var _this$
|
|
1554
|
+
var _this$chainService5, _this$chainService5$m, _this$chainService5$m2, _this$chainService6, _this$chainService6$m, _this$chainService6$m2, _this$chainService7, _this$chainService7$m, _this$chainService7$m2, _this$chainService8, _this$chainService8$m;
|
|
1544
1555
|
// first time initiation
|
|
1545
|
-
await ((_this$
|
|
1546
|
-
const authContext = await ((_this$
|
|
1547
|
-
await ((_this$
|
|
1556
|
+
await ((_this$chainService5 = this.chainService) === null || _this$chainService5 === void 0 ? void 0 : (_this$chainService5$m = _this$chainService5.mantaPay) === null || _this$chainService5$m === void 0 ? void 0 : (_this$chainService5$m2 = _this$chainService5$m.privateWallet) === null || _this$chainService5$m2 === void 0 ? void 0 : _this$chainService5$m2.loadUserSeedPhrase(seedPhrase));
|
|
1557
|
+
const authContext = await ((_this$chainService6 = this.chainService) === null || _this$chainService6 === void 0 ? void 0 : (_this$chainService6$m = _this$chainService6.mantaPay) === null || _this$chainService6$m === void 0 ? void 0 : (_this$chainService6$m2 = _this$chainService6$m.privateWallet) === null || _this$chainService6$m2 === void 0 ? void 0 : _this$chainService6$m2.getAuthorizationContext());
|
|
1558
|
+
await ((_this$chainService7 = this.chainService) === null || _this$chainService7 === void 0 ? void 0 : (_this$chainService7$m = _this$chainService7.mantaPay) === null || _this$chainService7$m === void 0 ? void 0 : (_this$chainService7$m2 = _this$chainService7$m.privateWallet) === null || _this$chainService7$m2 === void 0 ? void 0 : _this$chainService7$m2.loadAuthorizationContext(authContext));
|
|
1548
1559
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
1549
1560
|
const encryptedData = await passworder.encrypt(password, authContext);
|
|
1550
|
-
await this.chainService.mantaPay.saveMantaAuthContext({
|
|
1561
|
+
await ((_this$chainService8 = this.chainService) === null || _this$chainService8 === void 0 ? void 0 : (_this$chainService8$m = _this$chainService8.mantaPay) === null || _this$chainService8$m === void 0 ? void 0 : _this$chainService8$m.saveMantaAuthContext({
|
|
1551
1562
|
chain: _DEFAULT_MANTA_ZK_CHAIN,
|
|
1552
1563
|
address,
|
|
1553
1564
|
data: encryptedData
|
|
1554
|
-
});
|
|
1565
|
+
}));
|
|
1555
1566
|
} else {
|
|
1556
|
-
var _this$
|
|
1557
|
-
const authContext = await this.chainService.mantaPay.getMantaAuthContext(address, _DEFAULT_MANTA_ZK_CHAIN);
|
|
1567
|
+
var _this$chainService9, _this$chainService9$m, _this$chainService10, _this$chainService10$, _this$chainService10$2;
|
|
1568
|
+
const authContext = await ((_this$chainService9 = this.chainService) === null || _this$chainService9 === void 0 ? void 0 : (_this$chainService9$m = _this$chainService9.mantaPay) === null || _this$chainService9$m === void 0 ? void 0 : _this$chainService9$m.getMantaAuthContext(address, _DEFAULT_MANTA_ZK_CHAIN));
|
|
1558
1569
|
|
|
1559
1570
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
1560
1571
|
const decryptedData = await passworder.decrypt(password, authContext.data);
|
|
1561
1572
|
|
|
1562
1573
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
|
|
1563
1574
|
const proofAuthKey = new Uint8Array(Object.values(decryptedData.proof_authorization_key));
|
|
1564
|
-
await ((_this$
|
|
1575
|
+
await ((_this$chainService10 = this.chainService) === null || _this$chainService10 === void 0 ? void 0 : (_this$chainService10$ = _this$chainService10.mantaPay) === null || _this$chainService10$ === void 0 ? void 0 : (_this$chainService10$2 = _this$chainService10$.privateWallet) === null || _this$chainService10$2 === void 0 ? void 0 : _this$chainService10$2.loadAuthorizationContext({
|
|
1565
1576
|
proof_authorization_key: proofAuthKey
|
|
1566
1577
|
}));
|
|
1567
1578
|
}
|
|
1568
|
-
const zkAddress = await ((_this$
|
|
1579
|
+
const zkAddress = await ((_this$chainService11 = this.chainService) === null || _this$chainService11 === void 0 ? void 0 : (_this$chainService11$ = _this$chainService11.mantaPay) === null || _this$chainService11$ === void 0 ? void 0 : (_this$chainService11$2 = _this$chainService11$.privateWallet) === null || _this$chainService11$2 === void 0 ? void 0 : _this$chainService11$2.getZkAddress());
|
|
1569
1580
|
if (updateStore) {
|
|
1570
|
-
var _this$
|
|
1571
|
-
await this.chainService.mantaPay
|
|
1581
|
+
var _this$chainService12, _this$chainService12$, _this$chainService13, _this$chainService13$, _this$chainService13$2, _this$chainService13$3;
|
|
1582
|
+
await ((_this$chainService12 = this.chainService) === null || _this$chainService12 === void 0 ? void 0 : (_this$chainService12$ = _this$chainService12.mantaPay) === null || _this$chainService12$ === void 0 ? void 0 : _this$chainService12$.saveMantaPayConfig({
|
|
1572
1583
|
address,
|
|
1573
1584
|
zkAddress: zkAddress,
|
|
1574
1585
|
enabled: true,
|
|
1575
|
-
chain: (_this$
|
|
1586
|
+
chain: (_this$chainService13 = this.chainService) === null || _this$chainService13 === void 0 ? void 0 : (_this$chainService13$ = _this$chainService13.mantaPay) === null || _this$chainService13$ === void 0 ? void 0 : (_this$chainService13$2 = _this$chainService13$.privateWallet) === null || _this$chainService13$2 === void 0 ? void 0 : (_this$chainService13$3 = _this$chainService13$2.network) === null || _this$chainService13$3 === void 0 ? void 0 : _this$chainService13$3.toLowerCase(),
|
|
1576
1587
|
isInitialSync: false
|
|
1577
|
-
});
|
|
1588
|
+
}));
|
|
1578
1589
|
}
|
|
1579
1590
|
this.isMantaPayEnabled = true;
|
|
1580
1591
|
return zkAddress;
|
|
1581
1592
|
}
|
|
1582
1593
|
async disableMantaPay(address) {
|
|
1583
|
-
var _this$
|
|
1584
|
-
const config = await this.chainService.mantaPay
|
|
1594
|
+
var _this$chainService14, _this$chainService14$, _this$chainService15, _this$chainService15$, _this$chainService15$2, _this$chainService16, _this$chainService16$, _this$chainService16$2, _this$chainService17, _this$chainService17$, _this$chainService18, _this$chainService18$;
|
|
1595
|
+
const config = await ((_this$chainService14 = this.chainService) === null || _this$chainService14 === void 0 ? void 0 : (_this$chainService14$ = _this$chainService14.mantaPay) === null || _this$chainService14$ === void 0 ? void 0 : _this$chainService14$.getMantaPayConfig(address, _DEFAULT_MANTA_ZK_CHAIN));
|
|
1585
1596
|
if (!config) {
|
|
1586
1597
|
return false;
|
|
1587
1598
|
}
|
|
1588
|
-
await ((_this$
|
|
1589
|
-
await ((_this$
|
|
1590
|
-
// await this.chainService
|
|
1591
|
-
await this.chainService.mantaPay
|
|
1592
|
-
await this.chainService.mantaPay
|
|
1599
|
+
await ((_this$chainService15 = this.chainService) === null || _this$chainService15 === void 0 ? void 0 : (_this$chainService15$ = _this$chainService15.mantaPay) === null || _this$chainService15$ === void 0 ? void 0 : (_this$chainService15$2 = _this$chainService15$.privateWallet) === null || _this$chainService15$2 === void 0 ? void 0 : _this$chainService15$2.dropAuthorizationContext());
|
|
1600
|
+
await ((_this$chainService16 = this.chainService) === null || _this$chainService16 === void 0 ? void 0 : (_this$chainService16$ = _this$chainService16.mantaPay) === null || _this$chainService16$ === void 0 ? void 0 : (_this$chainService16$2 = _this$chainService16$.privateWallet) === null || _this$chainService16$2 === void 0 ? void 0 : _this$chainService16$2.dropUserSeedPhrase());
|
|
1601
|
+
// await this.chainService?.mantaPay?.privateWallet?.resetState();
|
|
1602
|
+
await ((_this$chainService17 = this.chainService) === null || _this$chainService17 === void 0 ? void 0 : (_this$chainService17$ = _this$chainService17.mantaPay) === null || _this$chainService17$ === void 0 ? void 0 : _this$chainService17$.deleteMantaPayConfig(address, _DEFAULT_MANTA_ZK_CHAIN));
|
|
1603
|
+
await ((_this$chainService18 = this.chainService) === null || _this$chainService18 === void 0 ? void 0 : (_this$chainService18$ = _this$chainService18.mantaPay) === null || _this$chainService18$ === void 0 ? void 0 : _this$chainService18$.deleteMantaAuthContext(address, _DEFAULT_MANTA_ZK_CHAIN));
|
|
1593
1604
|
this.chainService.setMantaZkAssetSettings(false);
|
|
1594
1605
|
this.isMantaPayEnabled = false;
|
|
1595
1606
|
return true;
|
|
1596
1607
|
}
|
|
1597
1608
|
async initialSyncMantaPay(address) {
|
|
1598
|
-
var _this$
|
|
1609
|
+
var _this$chainService19, _this$chainService19$, _this$chainService20, _this$chainService20$, _this$chainService20$2, _this$chainService20$3, _this$chainService21, _this$chainService21$, _this$chainService21$2, _this$chainService22, _this$chainService22$;
|
|
1599
1610
|
if (!address || isEthereumAddress(address)) {
|
|
1600
1611
|
return;
|
|
1601
1612
|
}
|
|
1602
|
-
this.chainService.mantaPay
|
|
1603
|
-
await ((_this$
|
|
1604
|
-
const syncResult = await ((_this$
|
|
1605
|
-
await this.chainService.mantaPay
|
|
1613
|
+
(_this$chainService19 = this.chainService) === null || _this$chainService19 === void 0 ? void 0 : (_this$chainService19$ = _this$chainService19.mantaPay) === null || _this$chainService19$ === void 0 ? void 0 : _this$chainService19$.setCurrentAddress(address);
|
|
1614
|
+
await ((_this$chainService20 = this.chainService) === null || _this$chainService20 === void 0 ? void 0 : (_this$chainService20$ = _this$chainService20.mantaPay) === null || _this$chainService20$ === void 0 ? void 0 : (_this$chainService20$2 = _this$chainService20$.privateWallet) === null || _this$chainService20$2 === void 0 ? void 0 : (_this$chainService20$3 = _this$chainService20$2.baseWallet) === null || _this$chainService20$3 === void 0 ? void 0 : _this$chainService20$3.isApiReady());
|
|
1615
|
+
const syncResult = await ((_this$chainService21 = this.chainService) === null || _this$chainService21 === void 0 ? void 0 : (_this$chainService21$ = _this$chainService21.mantaPay) === null || _this$chainService21$ === void 0 ? void 0 : (_this$chainService21$2 = _this$chainService21$.privateWallet) === null || _this$chainService21$2 === void 0 ? void 0 : _this$chainService21$2.initialWalletSync());
|
|
1616
|
+
await ((_this$chainService22 = this.chainService) === null || _this$chainService22 === void 0 ? void 0 : (_this$chainService22$ = _this$chainService22.mantaPay) === null || _this$chainService22$ === void 0 ? void 0 : _this$chainService22$.updateMantaPayConfig(address, _DEFAULT_MANTA_ZK_CHAIN, {
|
|
1606
1617
|
isInitialSync: true
|
|
1607
|
-
});
|
|
1618
|
+
}));
|
|
1608
1619
|
this.eventService.emit('mantaPay.initSync', undefined);
|
|
1609
1620
|
return syncResult;
|
|
1610
1621
|
}
|
|
1611
1622
|
getMantaZkBalance() {
|
|
1612
|
-
var _this$
|
|
1613
|
-
if (!this.chainService || !this.chainService.mantaPay) {
|
|
1623
|
+
var _this$chainService23, _this$chainService24, _this$chainService24$, _this$chainService24$2, _this$chainService25, _this$chainService25$, _this$chainService26, _this$chainService26$, _this$chainService26$2;
|
|
1624
|
+
if (!this.chainService || !((_this$chainService23 = this.chainService) !== null && _this$chainService23 !== void 0 && _this$chainService23.mantaPay)) {
|
|
1614
1625
|
return;
|
|
1615
1626
|
}
|
|
1616
|
-
if (!((_this$
|
|
1627
|
+
if (!((_this$chainService24 = this.chainService) !== null && _this$chainService24 !== void 0 && (_this$chainService24$ = _this$chainService24.mantaPay) !== null && _this$chainService24$ !== void 0 && (_this$chainService24$2 = _this$chainService24$.privateWallet) !== null && _this$chainService24$2 !== void 0 && _this$chainService24$2.initialSyncIsFinished)) {
|
|
1617
1628
|
return;
|
|
1618
1629
|
}
|
|
1619
|
-
const chain = (_this$
|
|
1630
|
+
const chain = (_this$chainService25 = this.chainService) === null || _this$chainService25 === void 0 ? void 0 : (_this$chainService25$ = _this$chainService25.mantaPay.privateWallet) === null || _this$chainService25$ === void 0 ? void 0 : _this$chainService25$.network;
|
|
1620
1631
|
if (!chain) {
|
|
1621
1632
|
return;
|
|
1622
1633
|
}
|
|
1623
1634
|
const assetMap = this.chainService.getMantaZkAssets(chain === null || chain === void 0 ? void 0 : chain.toLowerCase());
|
|
1624
|
-
(_this$
|
|
1635
|
+
(_this$chainService26 = this.chainService) === null || _this$chainService26 === void 0 ? void 0 : (_this$chainService26$ = _this$chainService26.mantaPay) === null || _this$chainService26$ === void 0 ? void 0 : (_this$chainService26$2 = _this$chainService26$.privateWallet) === null || _this$chainService26$2 === void 0 ? void 0 : _this$chainService26$2.getMultiZkBalance(Object.values(assetMap).map(tokenInfo => new BN(_getTokenOnChainAssetId(tokenInfo)))).then(zkBalances => {
|
|
1625
1636
|
const assetList = Object.values(assetMap);
|
|
1626
1637
|
for (let i = 0; i < assetList.length; i++) {
|
|
1627
1638
|
var _zkBalances$i;
|
|
@@ -1638,8 +1649,9 @@ export default class KoniState {
|
|
|
1638
1649
|
}).catch(console.warn);
|
|
1639
1650
|
}
|
|
1640
1651
|
subscribeMantaPayBalance() {
|
|
1652
|
+
var _this$chainService27, _this$chainService27$;
|
|
1641
1653
|
let interval;
|
|
1642
|
-
this.chainService.mantaPay
|
|
1654
|
+
(_this$chainService27 = this.chainService) === null || _this$chainService27 === void 0 ? void 0 : (_this$chainService27$ = _this$chainService27.mantaPay) === null || _this$chainService27$ === void 0 ? void 0 : _this$chainService27$.getMantaPayConfig(this.keyringService.currentAccount.address, _DEFAULT_MANTA_ZK_CHAIN).then(config => {
|
|
1643
1655
|
if (config && config.enabled && config.isInitialSync) {
|
|
1644
1656
|
this.getMantaZkBalance();
|
|
1645
1657
|
interval = setInterval(this.getMantaZkBalance, MANTA_PAY_BALANCE_INTERVAL);
|
|
@@ -1650,23 +1662,23 @@ export default class KoniState {
|
|
|
1650
1662
|
};
|
|
1651
1663
|
}
|
|
1652
1664
|
async syncMantaPay() {
|
|
1653
|
-
var _this$
|
|
1654
|
-
const config = await this.chainService.mantaPay
|
|
1665
|
+
var _this$chainService28, _this$chainService28$, _this$chainService29, _this$chainService29$, _this$chainService29$2;
|
|
1666
|
+
const config = await ((_this$chainService28 = this.chainService) === null || _this$chainService28 === void 0 ? void 0 : (_this$chainService28$ = _this$chainService28.mantaPay) === null || _this$chainService28$ === void 0 ? void 0 : _this$chainService28$.getMantaPayFirstConfig(_DEFAULT_MANTA_ZK_CHAIN));
|
|
1655
1667
|
if (!config.isInitialSync) {
|
|
1656
1668
|
return;
|
|
1657
1669
|
}
|
|
1658
|
-
if ((_this$
|
|
1659
|
-
var _this$
|
|
1660
|
-
await ((_this$
|
|
1670
|
+
if ((_this$chainService29 = this.chainService) !== null && _this$chainService29 !== void 0 && (_this$chainService29$ = _this$chainService29.mantaPay) !== null && _this$chainService29$ !== void 0 && (_this$chainService29$2 = _this$chainService29$.privateWallet) !== null && _this$chainService29$2 !== void 0 && _this$chainService29$2.initialSyncIsFinished) {
|
|
1671
|
+
var _this$chainService30, _this$chainService30$, _this$chainService30$2;
|
|
1672
|
+
await ((_this$chainService30 = this.chainService) === null || _this$chainService30 === void 0 ? void 0 : (_this$chainService30$ = _this$chainService30.mantaPay) === null || _this$chainService30$ === void 0 ? void 0 : (_this$chainService30$2 = _this$chainService30$.privateWallet) === null || _this$chainService30$2 === void 0 ? void 0 : _this$chainService30$2.walletSync());
|
|
1661
1673
|
} else {
|
|
1662
|
-
var _this$
|
|
1663
|
-
await ((_this$
|
|
1674
|
+
var _this$chainService31, _this$chainService31$, _this$chainService31$2;
|
|
1675
|
+
await ((_this$chainService31 = this.chainService) === null || _this$chainService31 === void 0 ? void 0 : (_this$chainService31$ = _this$chainService31.mantaPay) === null || _this$chainService31$ === void 0 ? void 0 : (_this$chainService31$2 = _this$chainService31$.privateWallet) === null || _this$chainService31$2 === void 0 ? void 0 : _this$chainService31$2.initialWalletSync());
|
|
1664
1676
|
}
|
|
1665
1677
|
}
|
|
1666
1678
|
async getMantaPayZkBalance(address, tokenInfo) {
|
|
1667
|
-
var _this$
|
|
1679
|
+
var _this$chainService32, _this$chainService32$, _this$chainService32$2;
|
|
1668
1680
|
const bnAssetId = new BN(_getTokenOnChainAssetId(tokenInfo));
|
|
1669
|
-
const balance = await ((_this$
|
|
1681
|
+
const balance = await ((_this$chainService32 = this.chainService) === null || _this$chainService32 === void 0 ? void 0 : (_this$chainService32$ = _this$chainService32.mantaPay) === null || _this$chainService32$ === void 0 ? void 0 : (_this$chainService32$2 = _this$chainService32$.privateWallet) === null || _this$chainService32$2 === void 0 ? void 0 : _this$chainService32$2.getZkBalance(bnAssetId));
|
|
1670
1682
|
return {
|
|
1671
1683
|
decimals: tokenInfo.decimals || 0,
|
|
1672
1684
|
symbol: tokenInfo.symbol,
|
|
@@ -1674,6 +1686,19 @@ export default class KoniState {
|
|
|
1674
1686
|
};
|
|
1675
1687
|
}
|
|
1676
1688
|
subscribeMantaPaySyncState() {
|
|
1677
|
-
|
|
1689
|
+
var _this$chainService33, _this$chainService34, _this$chainService34$;
|
|
1690
|
+
if (!((_this$chainService33 = this.chainService) !== null && _this$chainService33 !== void 0 && _this$chainService33.mantaPay)) {
|
|
1691
|
+
return new Subject();
|
|
1692
|
+
}
|
|
1693
|
+
return (_this$chainService34 = this.chainService) === null || _this$chainService34 === void 0 ? void 0 : (_this$chainService34$ = _this$chainService34.mantaPay) === null || _this$chainService34$ === void 0 ? void 0 : _this$chainService34$.subscribeSyncState();
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
// Metadata
|
|
1697
|
+
async findMetadata(hash) {
|
|
1698
|
+
const metadata = await this.chainService.getMetadataByHash(hash);
|
|
1699
|
+
return {
|
|
1700
|
+
metadata: (metadata === null || metadata === void 0 ? void 0 : metadata.hexValue) || '',
|
|
1701
|
+
specVersion: parseInt((metadata === null || metadata === void 0 ? void 0 : metadata.specVersion) || '0')
|
|
1702
|
+
};
|
|
1678
1703
|
}
|
|
1679
1704
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.4-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -530,6 +530,11 @@
|
|
|
530
530
|
"require": "./cjs/services/chain-service/handler/light-client/index.js",
|
|
531
531
|
"default": "./services/chain-service/handler/light-client/index.js"
|
|
532
532
|
},
|
|
533
|
+
"./services/chain-service/handler/manta/manta-extension-sdk-empty": {
|
|
534
|
+
"types": "./services/chain-service/handler/manta/manta-extension-sdk-empty.d.ts",
|
|
535
|
+
"require": "./cjs/services/chain-service/handler/manta/manta-extension-sdk-empty.js",
|
|
536
|
+
"default": "./services/chain-service/handler/manta/manta-extension-sdk-empty.js"
|
|
537
|
+
},
|
|
533
538
|
"./services/chain-service/handler/manta/MantaPrivateHandler": {
|
|
534
539
|
"types": "./services/chain-service/handler/manta/MantaPrivateHandler.d.ts",
|
|
535
540
|
"require": "./cjs/services/chain-service/handler/manta/MantaPrivateHandler.js",
|
|
@@ -1125,6 +1130,11 @@
|
|
|
1125
1130
|
"require": "./cjs/utils/promise.js",
|
|
1126
1131
|
"default": "./utils/promise.js"
|
|
1127
1132
|
},
|
|
1133
|
+
"./utils/registry": {
|
|
1134
|
+
"types": "./utils/registry.d.ts",
|
|
1135
|
+
"require": "./cjs/utils/registry.js",
|
|
1136
|
+
"default": "./utils/registry.js"
|
|
1137
|
+
},
|
|
1128
1138
|
"./utils/request": {
|
|
1129
1139
|
"types": "./utils/request.d.ts",
|
|
1130
1140
|
"require": "./cjs/utils/request.js",
|
|
@@ -1163,16 +1173,17 @@
|
|
|
1163
1173
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1164
1174
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1165
1175
|
"@substrate/connect": "^0.7.26",
|
|
1166
|
-
"@subwallet/chain-list": "^0.2.
|
|
1167
|
-
"@subwallet/extension-base": "^1.1.
|
|
1168
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1169
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1170
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1176
|
+
"@subwallet/chain-list": "^0.2.7",
|
|
1177
|
+
"@subwallet/extension-base": "^1.1.4-0",
|
|
1178
|
+
"@subwallet/extension-chains": "^1.1.4-0",
|
|
1179
|
+
"@subwallet/extension-dapp": "^1.1.4-0",
|
|
1180
|
+
"@subwallet/extension-inject": "^1.1.4-0",
|
|
1171
1181
|
"@subwallet/keyring": "^0.0.10",
|
|
1172
1182
|
"@subwallet/ui-keyring": "^0.0.10",
|
|
1173
1183
|
"@walletconnect/sign-client": "^2.8.4",
|
|
1174
1184
|
"@walletconnect/types": "^2.8.4",
|
|
1175
1185
|
"@walletconnect/utils": "^2.8.4",
|
|
1186
|
+
"avail-js-sdk": "^0.0.10",
|
|
1176
1187
|
"axios": "^1.2.1",
|
|
1177
1188
|
"bignumber.js": "^9.1.1",
|
|
1178
1189
|
"bn.js": "^5.2.1",
|
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.1.
|
|
10
|
+
version: '1.1.4-0'
|
|
11
11
|
};
|
|
@@ -5,6 +5,7 @@ export declare const API_MAX_RETRY = 2;
|
|
|
5
5
|
export declare const _API_OPTIONS_CHAIN_GROUP: {
|
|
6
6
|
acala: string[];
|
|
7
7
|
turing: string[];
|
|
8
|
+
avail: string[];
|
|
8
9
|
};
|
|
9
10
|
export declare const _PREDEFINED_SINGLE_MODES: Record<string, SingleModeJson>;
|
|
10
11
|
export declare const _PURE_EVM_CHAINS: string[];
|
|
@@ -9,7 +9,8 @@ export const API_CONNECT_TIMEOUT = 30000;
|
|
|
9
9
|
export const API_MAX_RETRY = 2;
|
|
10
10
|
export const _API_OPTIONS_CHAIN_GROUP = {
|
|
11
11
|
acala: ['acala', 'karura', 'origintrail', 'kintsugi'],
|
|
12
|
-
turing: ['turingStaging', 'turing']
|
|
12
|
+
turing: ['turingStaging', 'turing'],
|
|
13
|
+
avail: ['kate']
|
|
13
14
|
};
|
|
14
15
|
export const _PREDEFINED_SINGLE_MODES = {
|
|
15
16
|
subspace: {
|
|
@@ -8,6 +8,7 @@ import { _API_OPTIONS_CHAIN_GROUP, API_AUTO_CONNECT_MS, API_CONNECT_TIMEOUT } fr
|
|
|
8
8
|
import { getSubstrateConnectProvider } from '@subwallet/extension-base/services/chain-service/handler/light-client';
|
|
9
9
|
import { DEFAULT_AUX } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
|
|
10
10
|
import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
|
|
11
|
+
import { spec as availSpec } from 'avail-js-sdk';
|
|
11
12
|
import { BehaviorSubject } from 'rxjs';
|
|
12
13
|
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
13
14
|
import { typesBundle } from '@polkadot/apps-config/api';
|
|
@@ -63,6 +64,13 @@ export class SubstrateApi {
|
|
|
63
64
|
rpc: oakRpc,
|
|
64
65
|
types: oakTypes
|
|
65
66
|
});
|
|
67
|
+
} else if (_API_OPTIONS_CHAIN_GROUP.avail.includes(this.chainSlug)) {
|
|
68
|
+
return new ApiPromise({
|
|
69
|
+
provider,
|
|
70
|
+
rpc: availSpec.rpc,
|
|
71
|
+
types: availSpec.types,
|
|
72
|
+
signedExtensions: availSpec.signedExtensions
|
|
73
|
+
});
|
|
66
74
|
} else {
|
|
67
75
|
return new ApiPromise(apiOption);
|
|
68
76
|
}
|
|
@@ -23,7 +23,7 @@ export declare class MantaPrivateHandler {
|
|
|
23
23
|
deleteMantaAuthContext(address: string, chain: string): Promise<number>;
|
|
24
24
|
private saveLedgerState;
|
|
25
25
|
private getLedgerState;
|
|
26
|
-
initMantaPay(providerUrl: string, network: string): Promise<import("
|
|
26
|
+
initMantaPay(providerUrl: string, network: string): Promise<import("avail-js-sdk").ApiPromise>;
|
|
27
27
|
getCurrentLedgerState(): Promise<number>;
|
|
28
28
|
setSyncState(data: MantaPaySyncState): void;
|
|
29
29
|
subscribeSyncProgress(): Promise<() => void>;
|
|
@@ -88,7 +88,7 @@ export class MantaPrivateHandler {
|
|
|
88
88
|
|
|
89
89
|
const baseWallet = await BaseWallet.init({
|
|
90
90
|
apiEndpoint: providerUrl,
|
|
91
|
-
loggingEnabled:
|
|
91
|
+
loggingEnabled: true,
|
|
92
92
|
provingFilePath: './manta-pay/proving',
|
|
93
93
|
parametersFilePath: './manta-pay/parameters',
|
|
94
94
|
saveStorageStateToLocal: this.saveLedgerState.bind(this),
|