@subwallet/extension-base 1.3.29-1 → 1.3.31-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 +16 -4
- package/background/errors/SwapError.js +1 -1
- package/cjs/background/errors/SwapError.js +1 -1
- package/cjs/constants/blocked-actions.js +2 -2
- package/cjs/constants/paraspell-chain-map.js +13 -0
- package/cjs/constants/remind-notification-time.js +3 -3
- package/cjs/core/logic-validation/swap.js +63 -4
- package/cjs/core/logic-validation/transfer.js +13 -1
- package/cjs/core/substrate/xcm-parser.js +5 -1
- package/cjs/core/utils.js +36 -15
- package/cjs/koni/background/handlers/Extension.js +141 -172
- package/cjs/koni/background/handlers/State.js +8 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/process.js +27 -0
- package/cjs/services/balance-service/index.js +9 -0
- package/cjs/services/balance-service/transfer/xcm/acrossBridge/index.js +229 -0
- package/cjs/services/balance-service/transfer/xcm/availBridge.js +6 -6
- package/cjs/services/balance-service/transfer/xcm/index.js +96 -7
- package/cjs/services/balance-service/transfer/xcm/utils.js +213 -0
- package/cjs/services/chain-service/constants.js +2 -4
- package/cjs/services/chain-service/index.js +71 -17
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/base.js +6 -3
- package/cjs/services/earning-service/handlers/native-staking/base.js +4 -1
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +68 -50
- package/cjs/services/earning-service/handlers/native-staking/tao.js +12 -2
- package/cjs/services/earning-service/handlers/special.js +18 -9
- package/cjs/services/earning-service/service.js +2 -1
- package/cjs/services/fee-service/utils/index.js +16 -4
- package/cjs/services/inapp-notification-service/index.js +19 -13
- package/cjs/services/keyring-service/context/handlers/Ledger.js +1 -1
- package/cjs/services/keyring-service/context/state.js +3 -0
- package/cjs/services/migration-service/scripts/DisableZeroBalanceTokens.js +60 -0
- package/cjs/services/migration-service/scripts/EnableChain.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +3 -2
- package/cjs/services/swap-service/handler/asset-hub/handler.js +61 -314
- package/cjs/services/swap-service/handler/base-handler.js +406 -231
- package/cjs/services/swap-service/handler/chainflip-handler.js +18 -40
- package/cjs/services/swap-service/handler/hydradx-handler.js +77 -269
- package/cjs/services/swap-service/handler/simpleswap-handler.js +27 -48
- package/cjs/services/swap-service/handler/uniswap-handler.js +33 -54
- package/cjs/services/swap-service/index.js +154 -143
- package/cjs/services/swap-service/utils.js +107 -17
- package/cjs/services/transaction-service/index.js +1 -1
- package/cjs/services/transaction-service/utils.js +38 -14
- package/cjs/types/swap/index.js +13 -1
- package/cjs/utils/fee/transfer.js +52 -28
- package/cjs/utils/staticData/index.js +7 -2
- package/cjs/utils/swap.js +5 -1
- package/constants/blocked-actions.d.ts +1 -1
- package/constants/blocked-actions.js +1 -1
- package/constants/paraspell-chain-map.d.ts +1 -0
- package/constants/paraspell-chain-map.js +7 -0
- package/constants/remind-notification-time.d.ts +1 -1
- package/constants/remind-notification-time.js +1 -1
- package/core/logic-validation/swap.d.ts +15 -0
- package/core/logic-validation/swap.js +60 -4
- package/core/logic-validation/transfer.d.ts +1 -0
- package/core/logic-validation/transfer.js +12 -1
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +4 -1
- package/core/utils.d.ts +2 -2
- package/core/utils.js +36 -15
- package/koni/background/handlers/Extension.d.ts +1 -1
- package/koni/background/handlers/Extension.js +66 -98
- package/koni/background/handlers/State.d.ts +1 -0
- package/koni/background/handlers/State.js +7 -1
- package/package.json +23 -13
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/process.d.ts +2 -1
- package/services/balance-service/helpers/process.js +26 -0
- package/services/balance-service/index.js +11 -2
- package/services/balance-service/transfer/xcm/acrossBridge/index.d.ts +15 -0
- package/services/balance-service/transfer/xcm/acrossBridge/index.js +216 -0
- package/services/balance-service/transfer/xcm/availBridge.js +6 -6
- package/services/balance-service/transfer/xcm/index.d.ts +5 -1
- package/services/balance-service/transfer/xcm/index.js +85 -1
- package/services/balance-service/transfer/xcm/utils.d.ts +11 -0
- package/services/balance-service/transfer/xcm/utils.js +208 -0
- package/services/base/types.d.ts +0 -4
- package/services/chain-service/constants.d.ts +0 -1
- package/services/chain-service/constants.js +1 -2
- package/services/chain-service/index.d.ts +9 -2
- package/services/chain-service/index.js +72 -18
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/base.d.ts +4 -3
- package/services/earning-service/handlers/base.js +6 -4
- package/services/earning-service/handlers/native-staking/base.js +4 -1
- package/services/earning-service/handlers/native-staking/dtao.d.ts +9 -6
- package/services/earning-service/handlers/native-staking/dtao.js +69 -48
- package/services/earning-service/handlers/native-staking/tao.js +12 -2
- package/services/earning-service/handlers/special.js +19 -10
- package/services/earning-service/service.d.ts +2 -1
- package/services/earning-service/service.js +2 -1
- package/services/fee-service/utils/index.d.ts +1 -0
- package/services/fee-service/utils/index.js +14 -4
- package/services/inapp-notification-service/index.js +13 -7
- package/services/keyring-service/context/handlers/Ledger.js +1 -1
- package/services/keyring-service/context/state.d.ts +1 -0
- package/services/keyring-service/context/state.js +3 -0
- package/services/migration-service/scripts/DisableZeroBalanceTokens.d.ts +4 -0
- package/services/migration-service/scripts/DisableZeroBalanceTokens.js +51 -0
- package/services/migration-service/scripts/EnableChain.js +1 -1
- package/services/migration-service/scripts/index.js +3 -2
- package/services/swap-service/handler/asset-hub/handler.d.ts +2 -9
- package/services/swap-service/handler/asset-hub/handler.js +64 -317
- package/services/swap-service/handler/base-handler.d.ts +6 -9
- package/services/swap-service/handler/base-handler.js +405 -230
- package/services/swap-service/handler/chainflip-handler.d.ts +2 -4
- package/services/swap-service/handler/chainflip-handler.js +15 -37
- package/services/swap-service/handler/hydradx-handler.d.ts +3 -10
- package/services/swap-service/handler/hydradx-handler.js +78 -270
- package/services/swap-service/handler/simpleswap-handler.d.ts +2 -4
- package/services/swap-service/handler/simpleswap-handler.js +24 -45
- package/services/swap-service/handler/uniswap-handler.d.ts +4 -6
- package/services/swap-service/handler/uniswap-handler.js +25 -46
- package/services/swap-service/index.d.ts +8 -14
- package/services/swap-service/index.js +141 -129
- package/services/swap-service/utils.d.ts +11 -3
- package/services/swap-service/utils.js +96 -15
- package/services/transaction-service/index.js +2 -2
- package/services/transaction-service/types.d.ts +3 -2
- package/services/transaction-service/utils.d.ts +1 -0
- package/services/transaction-service/utils.js +38 -15
- package/types/balance/transfer.d.ts +1 -0
- package/types/service-base.d.ts +2 -3
- package/types/swap/index.d.ts +25 -9
- package/types/swap/index.js +10 -0
- package/types/transaction/process.d.ts +19 -0
- package/types/transaction/request.d.ts +7 -0
- package/types/yield/actions/join/submit.d.ts +4 -1
- package/types/yield/actions/others.d.ts +2 -0
- package/utils/fee/transfer.d.ts +1 -0
- package/utils/fee/transfer.js +54 -30
- package/utils/staticData/index.d.ts +4 -1
- package/utils/staticData/index.js +5 -1
- package/utils/staticData/paraSpellChainMap.json +1 -0
- package/utils/swap.d.ts +3 -0
- package/utils/swap.js +3 -0
- package/cjs/services/swap-service/interface.js +0 -14
- package/services/swap-service/interface.d.ts +0 -9
- package/services/swap-service/interface.js +0 -8
|
@@ -35,6 +35,7 @@ var _smartContract = require("@subwallet/extension-base/services/balance-service
|
|
|
35
35
|
var _token = require("@subwallet/extension-base/services/balance-service/transfer/token");
|
|
36
36
|
var _tonTransfer = require("@subwallet/extension-base/services/balance-service/transfer/ton-transfer");
|
|
37
37
|
var _xcm = require("@subwallet/extension-base/services/balance-service/transfer/xcm");
|
|
38
|
+
var _acrossBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/acrossBridge");
|
|
38
39
|
var _availBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge");
|
|
39
40
|
var _polygonBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge");
|
|
40
41
|
var _posBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge");
|
|
@@ -293,7 +294,6 @@ class KoniExtension {
|
|
|
293
294
|
const transformedAccounts = Object.values(accountProxies);
|
|
294
295
|
responseData.accounts = transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [(0, _utils7.combineAllAccountProxy)(transformedAccounts), ...transformedAccounts] : [];
|
|
295
296
|
responseData.currentAccountProxy = currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.proxyId;
|
|
296
|
-
console.debug('subscriptionAccountGroups', responseData);
|
|
297
297
|
cb(responseData);
|
|
298
298
|
});
|
|
299
299
|
this.createUnsubscriptionHandle(id, () => {
|
|
@@ -1148,9 +1148,10 @@ class KoniExtension {
|
|
|
1148
1148
|
owner,
|
|
1149
1149
|
spenderAddress
|
|
1150
1150
|
} = params;
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1151
|
+
|
|
1152
|
+
// if (!isSnowBridgeGatewayContract(spenderAddress) && !isAvailBridgeGatewayContract(spenderAddress)) {
|
|
1153
|
+
// throw new Error('Only SnowBridge and AvailBridge is supported'); // todo: support all ERC20 spending approval
|
|
1154
|
+
// }
|
|
1154
1155
|
|
|
1155
1156
|
const evmApi = this.#koniState.getEvmApi(chain);
|
|
1156
1157
|
const transactionConfig = await (0, _web.getERC20SpendingApprovalTx)(spenderAddress, owner, contractAddress, evmApi, amount);
|
|
@@ -1342,7 +1343,8 @@ class KoniExtension {
|
|
|
1342
1343
|
const receiverSendingTokenKeepAliveBalance = BigInt(_receiverSendingTokenKeepAliveBalance);
|
|
1343
1344
|
const amount = BigInt(transferAmount.value);
|
|
1344
1345
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
1345
|
-
const
|
|
1346
|
+
const sufficientChain = this.#koniState.chainService.value.sufficientChains;
|
|
1347
|
+
const isSendingTokenSufficient = await (0, _utils._isSufficientToken)(transferTokenInfo, substrateApi, sufficientChain);
|
|
1346
1348
|
const [warnings, errors] = (0, _transfer.additionalValidateTransferForRecipient)(transferTokenInfo, nativeTokenInfo, extrinsicType, receiverSendingTokenKeepAliveBalance, amount, senderSendingTokenTransferable, receiverSystemAccountInfo, isSendingTokenSufficient);
|
|
1347
1349
|
warnings.length && inputTransaction.warnings.push(...warnings);
|
|
1348
1350
|
errors.length && inputTransaction.errors.push(...errors);
|
|
@@ -1394,7 +1396,7 @@ class KoniExtension {
|
|
|
1394
1396
|
const destinationNativeTokenInfo = this.#koniState.getNativeTokenInfo(destinationNetworkKey);
|
|
1395
1397
|
const destinationNativeTokenSlug = destinationNativeTokenInfo.slug;
|
|
1396
1398
|
const [errors, fromKeyPair] = (0, _transfer.validateXcmTransferRequest)(destinationTokenInfo, from, value);
|
|
1397
|
-
let extrinsic
|
|
1399
|
+
let extrinsic;
|
|
1398
1400
|
if (errors.length > 0) {
|
|
1399
1401
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(errors);
|
|
1400
1402
|
}
|
|
@@ -1404,9 +1406,12 @@ class KoniExtension {
|
|
|
1404
1406
|
const isSnowBridgeEvmTransfer = (0, _utils5._isPureEvmChain)(chainInfoMap[originNetworkKey]) && (0, _xcmParser._isSnowBridgeXcm)(chainInfoMap[originNetworkKey], chainInfoMap[destinationNetworkKey]) && !isAvailBridgeFromEvm;
|
|
1405
1407
|
const isPolygonBridgeTransfer = (0, _polygonBridge._isPolygonChainBridge)(originNetworkKey, destinationNetworkKey);
|
|
1406
1408
|
const isPosBridgeTransfer = (0, _posBridge._isPosChainBridge)(originNetworkKey, destinationNetworkKey);
|
|
1409
|
+
const isAcrossBridgeTransfer = (0, _acrossBridge._isAcrossChainBridge)(originNetworkKey, destinationNetworkKey);
|
|
1407
1410
|
const extrinsicType = _KoniTypes.ExtrinsicType.TRANSFER_XCM;
|
|
1411
|
+
const isSubstrateXcm = !(isAvailBridgeFromEvm || isAvailBridgeFromAvail || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer);
|
|
1408
1412
|
const isTransferNative = this.#koniState.getNativeTokenInfo(originNetworkKey).slug === tokenSlug;
|
|
1409
1413
|
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNative && tokenSlug === tokenPayFeeSlug;
|
|
1414
|
+
let xcmFeeDryRun;
|
|
1410
1415
|
let additionalValidator;
|
|
1411
1416
|
let eventsHandler;
|
|
1412
1417
|
if (fromKeyPair && destinationTokenInfo) {
|
|
@@ -1417,6 +1422,9 @@ class KoniExtension {
|
|
|
1417
1422
|
if (isPosBridgeTransfer || isPolygonBridgeTransfer) {
|
|
1418
1423
|
funcCreateExtrinsic = _xcm.createPolygonBridgeExtrinsic;
|
|
1419
1424
|
type = 'evm';
|
|
1425
|
+
} else if (isAcrossBridgeTransfer) {
|
|
1426
|
+
funcCreateExtrinsic = _xcm.createAcrossBridgeExtrinsic;
|
|
1427
|
+
type = 'evm';
|
|
1420
1428
|
} else if (isSnowBridgeEvmTransfer) {
|
|
1421
1429
|
funcCreateExtrinsic = _xcm.createSnowBridgeExtrinsic;
|
|
1422
1430
|
type = 'evm';
|
|
@@ -1427,7 +1435,7 @@ class KoniExtension {
|
|
|
1427
1435
|
funcCreateExtrinsic = _xcm.createAvailBridgeExtrinsicFromAvail;
|
|
1428
1436
|
type = 'substrate';
|
|
1429
1437
|
} else {
|
|
1430
|
-
funcCreateExtrinsic = _xcm.
|
|
1438
|
+
funcCreateExtrinsic = _xcm.createXcmExtrinsicV2;
|
|
1431
1439
|
type = 'substrate';
|
|
1432
1440
|
}
|
|
1433
1441
|
const feeInfo = await this.#koniState.feeService.subscribeChainFee((0, _getId.getId)(), originNetworkKey, type);
|
|
@@ -1446,6 +1454,19 @@ class KoniExtension {
|
|
|
1446
1454
|
feeInfo
|
|
1447
1455
|
};
|
|
1448
1456
|
extrinsic = await funcCreateExtrinsic(params);
|
|
1457
|
+
let dryRunInfo;
|
|
1458
|
+
if (isSubstrateXcm) {
|
|
1459
|
+
dryRunInfo = await (0, _xcm.dryRunXcmExtrinsicV2)(params);
|
|
1460
|
+
xcmFeeDryRun = dryRunInfo.fee;
|
|
1461
|
+
}
|
|
1462
|
+
if (isAcrossBridgeTransfer) {
|
|
1463
|
+
const metadata = await (0, _acrossBridge.getAcrossQuote)(params);
|
|
1464
|
+
inputData.metadata = {
|
|
1465
|
+
amountOut: metadata.outputAmount,
|
|
1466
|
+
rate: metadata.rate,
|
|
1467
|
+
destChainSlug: destinationTokenInfo.slug
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1449
1470
|
if (_constants._SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(originNetworkKey)) {
|
|
1450
1471
|
var _this$koniState$chain2, _substrateApi$api$que2;
|
|
1451
1472
|
const hydrationFeeAssetId = tokenPayFeeSlug && ((_this$koniState$chain2 = this.#koniState.chainService.getAssetBySlug(tokenPayFeeSlug).metadata) === null || _this$koniState$chain2 === void 0 ? void 0 : _this$koniState$chain2.assetId);
|
|
@@ -1455,11 +1476,20 @@ class KoniExtension {
|
|
|
1455
1476
|
extrinsic = (0, _tokenPayFee.batchExtrinsicSetFeeHydration)(substrateApi, _extrinsic, feeSetting, hydrationFeeAssetId);
|
|
1456
1477
|
}
|
|
1457
1478
|
additionalValidator = async inputTransaction => {
|
|
1479
|
+
// hotfix xcm mythos to mythos chain
|
|
1480
|
+
const mythosError = (0, _transfer.validateXcmMinAmountToMythos)(destinationNetworkKey, destinationTokenInfo.slug, value);
|
|
1481
|
+
if (mythosError) {
|
|
1482
|
+
inputTransaction.errors.push(mythosError);
|
|
1483
|
+
}
|
|
1458
1484
|
let isSendingTokenSufficient = false;
|
|
1459
1485
|
let receiverSystemAccountInfo;
|
|
1460
1486
|
if (!(0, _utils5._isChainSubstrateCompatible)(chainInfoMap[destinationNetworkKey])) {
|
|
1461
1487
|
return undefined;
|
|
1462
1488
|
}
|
|
1489
|
+
const setting = {
|
|
1490
|
+
visible: true
|
|
1491
|
+
};
|
|
1492
|
+
await this.#koniState.chainService.updateAssetSetting(destinationTokenInfo.slug, setting, true);
|
|
1463
1493
|
const {
|
|
1464
1494
|
value: _senderTransferable
|
|
1465
1495
|
} = await this.getAddressTransferableBalance({
|
|
@@ -1487,15 +1517,17 @@ class KoniExtension {
|
|
|
1487
1517
|
});
|
|
1488
1518
|
receiverSystemAccountInfo = _receiverNativeTotal.metadata;
|
|
1489
1519
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
}
|
|
1520
|
+
const substrateApi = this.#koniState.getSubstrateApi(destinationNetworkKey);
|
|
1521
|
+
const sufficientChain = this.#koniState.chainService.value.sufficientChains;
|
|
1522
|
+
isSendingTokenSufficient = await (0, _utils._isSufficientToken)(destinationTokenInfo, substrateApi, sufficientChain);
|
|
1494
1523
|
const [warning, error] = (0, _transfer.additionalValidateTransferForRecipient)(destinationTokenInfo, destinationNativeTokenInfo, extrinsicType, receiverDestinationTokenKeepAliveBalance, sendingAmount, senderTransferable,
|
|
1495
1524
|
// different from sendingTokenInfo being passed in
|
|
1496
1525
|
receiverSystemAccountInfo, isSendingTokenSufficient);
|
|
1497
1526
|
warning.length && inputTransaction.warnings.push(...warning);
|
|
1498
1527
|
error.length && inputTransaction.errors.push(...error);
|
|
1528
|
+
if (isSubstrateXcm && !dryRunInfo.success) {
|
|
1529
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_types3.BasicTxErrorType.UNABLE_TO_SEND, 'Unable to perform transaction. Select another token or destination chain and try again'));
|
|
1530
|
+
}
|
|
1499
1531
|
};
|
|
1500
1532
|
eventsHandler = eventEmitter => {
|
|
1501
1533
|
eventEmitter.on('send', () => {
|
|
@@ -1528,13 +1560,14 @@ class KoniExtension {
|
|
|
1528
1560
|
transaction: extrinsic,
|
|
1529
1561
|
data: inputData,
|
|
1530
1562
|
extrinsicType,
|
|
1531
|
-
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm && !isPolygonBridgeTransfer && !isPosBridgeTransfer ? _KoniTypes.ChainType.SUBSTRATE : _KoniTypes.ChainType.EVM,
|
|
1563
|
+
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm && !isPolygonBridgeTransfer && !isPosBridgeTransfer && !isAcrossBridgeTransfer ? _KoniTypes.ChainType.SUBSTRATE : _KoniTypes.ChainType.EVM,
|
|
1532
1564
|
transferNativeAmount: (0, _utils5._isNativeToken)(originTokenInfo) ? value : '0',
|
|
1533
1565
|
ignoreWarnings,
|
|
1534
1566
|
tokenPayFeeSlug,
|
|
1535
1567
|
isTransferAll: transferAll,
|
|
1536
1568
|
isTransferLocalTokenAndPayThatTokenAsFee,
|
|
1537
1569
|
isPassConfirmation,
|
|
1570
|
+
xcmFeeDryRun,
|
|
1538
1571
|
errors,
|
|
1539
1572
|
additionalValidator: additionalValidator,
|
|
1540
1573
|
eventsHandler: eventsHandler
|
|
@@ -1666,14 +1699,21 @@ class KoniExtension {
|
|
|
1666
1699
|
} = _ref30;
|
|
1667
1700
|
return await this.#koniState.enableChain(chainSlug, enableTokens);
|
|
1668
1701
|
}
|
|
1702
|
+
async enableChainWithPriorityAssets(_ref31) {
|
|
1703
|
+
let {
|
|
1704
|
+
chainSlug,
|
|
1705
|
+
enableTokens
|
|
1706
|
+
} = _ref31;
|
|
1707
|
+
return await this.#koniState.enableChainWithPriorityAssets(chainSlug, enableTokens);
|
|
1708
|
+
}
|
|
1669
1709
|
async reconnectChain(chainSlug) {
|
|
1670
1710
|
return this.#koniState.chainService.reconnectChain(chainSlug);
|
|
1671
1711
|
}
|
|
1672
|
-
async validateNetwork(
|
|
1712
|
+
async validateNetwork(_ref32) {
|
|
1673
1713
|
let {
|
|
1674
1714
|
existedChainSlug,
|
|
1675
1715
|
provider
|
|
1676
|
-
} =
|
|
1716
|
+
} = _ref32;
|
|
1677
1717
|
return await this.#koniState.validateCustomChain(provider, existedChainSlug);
|
|
1678
1718
|
}
|
|
1679
1719
|
resetDefaultNetwork() {
|
|
@@ -1745,13 +1785,13 @@ class KoniExtension {
|
|
|
1745
1785
|
async validateCustomAsset(data) {
|
|
1746
1786
|
return await this.#koniState.validateCustomAsset(data);
|
|
1747
1787
|
}
|
|
1748
|
-
async getAddressTransferableBalance(
|
|
1788
|
+
async getAddressTransferableBalance(_ref33) {
|
|
1749
1789
|
let {
|
|
1750
1790
|
address,
|
|
1751
1791
|
extrinsicType,
|
|
1752
1792
|
networkKey,
|
|
1753
1793
|
token
|
|
1754
|
-
} =
|
|
1794
|
+
} = _ref33;
|
|
1755
1795
|
if (token && _constants2._MANTA_ZK_CHAIN_GROUP.includes(networkKey)) {
|
|
1756
1796
|
const tokenInfo = this.#koniState.chainService.getAssetBySlug(token);
|
|
1757
1797
|
if (tokenInfo.symbol.startsWith(_constants2._ZK_ASSET_PREFIX)) {
|
|
@@ -1760,13 +1800,13 @@ class KoniExtension {
|
|
|
1760
1800
|
}
|
|
1761
1801
|
return await this.#koniState.balanceService.getTransferableBalance(address, networkKey, token, extrinsicType);
|
|
1762
1802
|
}
|
|
1763
|
-
async getAddressTotalBalance(
|
|
1803
|
+
async getAddressTotalBalance(_ref34) {
|
|
1764
1804
|
let {
|
|
1765
1805
|
address,
|
|
1766
1806
|
extrinsicType,
|
|
1767
1807
|
networkKey,
|
|
1768
1808
|
token
|
|
1769
|
-
} =
|
|
1809
|
+
} = _ref34;
|
|
1770
1810
|
return await this.#koniState.balanceService.getTotalBalance(address, networkKey, token, extrinsicType);
|
|
1771
1811
|
}
|
|
1772
1812
|
async subscribeMaxTransferable(request, id, port) {
|
|
@@ -1777,7 +1817,8 @@ class KoniExtension {
|
|
|
1777
1817
|
feeCustom,
|
|
1778
1818
|
feeOption,
|
|
1779
1819
|
token,
|
|
1780
|
-
tokenPayFeeSlug
|
|
1820
|
+
tokenPayFeeSlug,
|
|
1821
|
+
value
|
|
1781
1822
|
} = request;
|
|
1782
1823
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1783
1824
|
const transferTokenInfo = this.#koniState.chainService.getAssetBySlug(token);
|
|
@@ -1797,6 +1838,8 @@ class KoniExtension {
|
|
|
1797
1838
|
}
|
|
1798
1839
|
const _request = {
|
|
1799
1840
|
address: address,
|
|
1841
|
+
value,
|
|
1842
|
+
// todo: lazy subscribe to improve performance
|
|
1800
1843
|
cardanoApi: this.#koniState.chainService.getCardanoApi(chain),
|
|
1801
1844
|
destChain,
|
|
1802
1845
|
destToken,
|
|
@@ -1815,11 +1858,11 @@ class KoniExtension {
|
|
|
1815
1858
|
freeBalance: freeBalanceSubject,
|
|
1816
1859
|
fee: feeSubject
|
|
1817
1860
|
}).subscribe({
|
|
1818
|
-
next:
|
|
1861
|
+
next: _ref35 => {
|
|
1819
1862
|
let {
|
|
1820
1863
|
fee,
|
|
1821
1864
|
freeBalance
|
|
1822
|
-
} =
|
|
1865
|
+
} = _ref35;
|
|
1823
1866
|
(0, _utils7.calculateMaxTransferable)(id, _request, freeBalance, fee).then(cb).catch(console.error);
|
|
1824
1867
|
}
|
|
1825
1868
|
});
|
|
@@ -1853,13 +1896,13 @@ class KoniExtension {
|
|
|
1853
1896
|
});
|
|
1854
1897
|
return (0, _utils7.calculateMaxTransferable)(id, _request, freeBalance, fee);
|
|
1855
1898
|
}
|
|
1856
|
-
async subscribeAddressTransferableBalance(
|
|
1899
|
+
async subscribeAddressTransferableBalance(_ref36, id, port) {
|
|
1857
1900
|
let {
|
|
1858
1901
|
address,
|
|
1859
1902
|
extrinsicType,
|
|
1860
1903
|
networkKey,
|
|
1861
1904
|
token
|
|
1862
|
-
} =
|
|
1905
|
+
} = _ref36;
|
|
1863
1906
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1864
1907
|
const convertData = data => {
|
|
1865
1908
|
return {
|
|
@@ -1910,11 +1953,11 @@ class KoniExtension {
|
|
|
1910
1953
|
isSendingSelf
|
|
1911
1954
|
};
|
|
1912
1955
|
}
|
|
1913
|
-
async enableChains(
|
|
1956
|
+
async enableChains(_ref37) {
|
|
1914
1957
|
let {
|
|
1915
1958
|
chainSlugs,
|
|
1916
1959
|
enableTokens
|
|
1917
|
-
} =
|
|
1960
|
+
} = _ref37;
|
|
1918
1961
|
try {
|
|
1919
1962
|
await Promise.all(chainSlugs.map(chainSlug => this.enableChain({
|
|
1920
1963
|
chainSlug,
|
|
@@ -2047,30 +2090,30 @@ class KoniExtension {
|
|
|
2047
2090
|
|
|
2048
2091
|
// Parse transaction
|
|
2049
2092
|
|
|
2050
|
-
parseSubstrateTransaction(
|
|
2093
|
+
parseSubstrateTransaction(_ref38) {
|
|
2051
2094
|
let {
|
|
2052
2095
|
data,
|
|
2053
2096
|
networkKey
|
|
2054
|
-
} =
|
|
2097
|
+
} = _ref38;
|
|
2055
2098
|
const apiProps = this.#koniState.getSubstrateApi(networkKey);
|
|
2056
2099
|
const apiPromise = apiProps.api;
|
|
2057
2100
|
return (0, _parseTransaction.parseSubstrateTransaction)(data, apiPromise);
|
|
2058
2101
|
}
|
|
2059
|
-
async parseEVMRLP(
|
|
2102
|
+
async parseEVMRLP(_ref39) {
|
|
2060
2103
|
let {
|
|
2061
2104
|
data
|
|
2062
|
-
} =
|
|
2105
|
+
} = _ref39;
|
|
2063
2106
|
return await (0, _parseTransaction2.parseEvmRlp)(data, this.#koniState.getChainInfoMap(), this.#koniState.getEvmApiMap());
|
|
2064
2107
|
}
|
|
2065
2108
|
|
|
2066
2109
|
// Sign
|
|
2067
2110
|
|
|
2068
|
-
qrSignSubstrate(
|
|
2111
|
+
qrSignSubstrate(_ref40) {
|
|
2069
2112
|
let {
|
|
2070
2113
|
address,
|
|
2071
2114
|
data,
|
|
2072
2115
|
networkKey
|
|
2073
|
-
} =
|
|
2116
|
+
} = _ref40;
|
|
2074
2117
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
2075
2118
|
(0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
|
|
2076
2119
|
if (pair.isLocked) {
|
|
@@ -2087,13 +2130,13 @@ class KoniExtension {
|
|
|
2087
2130
|
signature: signed
|
|
2088
2131
|
};
|
|
2089
2132
|
}
|
|
2090
|
-
async qrSignEVM(
|
|
2133
|
+
async qrSignEVM(_ref41) {
|
|
2091
2134
|
let {
|
|
2092
2135
|
address,
|
|
2093
2136
|
chainId,
|
|
2094
2137
|
message,
|
|
2095
2138
|
type
|
|
2096
|
-
} =
|
|
2139
|
+
} = _ref41;
|
|
2097
2140
|
let signed;
|
|
2098
2141
|
const network = this.getNetworkJsonByChainId(chainId);
|
|
2099
2142
|
if (!network) {
|
|
@@ -2177,11 +2220,11 @@ class KoniExtension {
|
|
|
2177
2220
|
});
|
|
2178
2221
|
return this.#koniState.getNominatorMetadata();
|
|
2179
2222
|
}
|
|
2180
|
-
async getBondingOptions(
|
|
2223
|
+
async getBondingOptions(_ref42) {
|
|
2181
2224
|
let {
|
|
2182
2225
|
chain,
|
|
2183
2226
|
type
|
|
2184
|
-
} =
|
|
2227
|
+
} = _ref42;
|
|
2185
2228
|
const apiProps = this.#koniState.getSubstrateApi(chain);
|
|
2186
2229
|
const chainInfo = this.#koniState.getChainInfo(chain);
|
|
2187
2230
|
const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, type);
|
|
@@ -2371,12 +2414,12 @@ class KoniExtension {
|
|
|
2371
2414
|
}
|
|
2372
2415
|
|
|
2373
2416
|
// EVM Transaction
|
|
2374
|
-
async parseContractInput(
|
|
2417
|
+
async parseContractInput(_ref43) {
|
|
2375
2418
|
let {
|
|
2376
2419
|
chainId,
|
|
2377
2420
|
contract,
|
|
2378
2421
|
data
|
|
2379
|
-
} =
|
|
2422
|
+
} = _ref43;
|
|
2380
2423
|
const network = this.getNetworkJsonByChainId(chainId);
|
|
2381
2424
|
return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
|
|
2382
2425
|
}
|
|
@@ -2476,10 +2519,10 @@ class KoniExtension {
|
|
|
2476
2519
|
|
|
2477
2520
|
// Unlock wallet
|
|
2478
2521
|
|
|
2479
|
-
keyringUnlock(
|
|
2522
|
+
keyringUnlock(_ref44) {
|
|
2480
2523
|
let {
|
|
2481
2524
|
password
|
|
2482
|
-
} =
|
|
2525
|
+
} = _ref44;
|
|
2483
2526
|
try {
|
|
2484
2527
|
_uiKeyring.keyring.unlockKeyring(password);
|
|
2485
2528
|
// this.#koniState.initMantaPay(password)
|
|
@@ -2510,11 +2553,11 @@ class KoniExtension {
|
|
|
2510
2553
|
|
|
2511
2554
|
// Export mnemonic
|
|
2512
2555
|
|
|
2513
|
-
keyringExportMnemonic(
|
|
2556
|
+
keyringExportMnemonic(_ref45) {
|
|
2514
2557
|
let {
|
|
2515
2558
|
address,
|
|
2516
2559
|
password
|
|
2517
|
-
} =
|
|
2560
|
+
} = _ref45;
|
|
2518
2561
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
2519
2562
|
const result = pair.exportMnemonic(password);
|
|
2520
2563
|
return {
|
|
@@ -2524,10 +2567,10 @@ class KoniExtension {
|
|
|
2524
2567
|
|
|
2525
2568
|
// Reset wallet
|
|
2526
2569
|
|
|
2527
|
-
async resetWallet(
|
|
2570
|
+
async resetWallet(_ref46) {
|
|
2528
2571
|
let {
|
|
2529
2572
|
resetAll
|
|
2530
|
-
} =
|
|
2573
|
+
} = _ref46;
|
|
2531
2574
|
try {
|
|
2532
2575
|
await this.#koniState.resetWallet(resetAll);
|
|
2533
2576
|
return {
|
|
@@ -2543,10 +2586,10 @@ class KoniExtension {
|
|
|
2543
2586
|
}
|
|
2544
2587
|
|
|
2545
2588
|
// Signing substrate request
|
|
2546
|
-
async signingApprovePasswordV2(
|
|
2589
|
+
async signingApprovePasswordV2(_ref47) {
|
|
2547
2590
|
let {
|
|
2548
2591
|
id
|
|
2549
|
-
} =
|
|
2592
|
+
} = _ref47;
|
|
2550
2593
|
const queued = this.#koniState.getSignRequest(id);
|
|
2551
2594
|
(0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
|
|
2552
2595
|
const {
|
|
@@ -2704,10 +2747,10 @@ class KoniExtension {
|
|
|
2704
2747
|
getSupportedSmartContractTypes() {
|
|
2705
2748
|
return this.#koniState.getSupportedSmartContractTypes();
|
|
2706
2749
|
}
|
|
2707
|
-
getTransaction(
|
|
2750
|
+
getTransaction(_ref48) {
|
|
2708
2751
|
let {
|
|
2709
2752
|
id
|
|
2710
|
-
} =
|
|
2753
|
+
} = _ref48;
|
|
2711
2754
|
const {
|
|
2712
2755
|
transaction,
|
|
2713
2756
|
...transactionResult
|
|
@@ -2717,8 +2760,8 @@ class KoniExtension {
|
|
|
2717
2760
|
async subscribeTransactions(id, port) {
|
|
2718
2761
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
2719
2762
|
function convertRs(rs, processMap) {
|
|
2720
|
-
return Object.fromEntries(Object.entries(rs).map(
|
|
2721
|
-
let [key, value] =
|
|
2763
|
+
return Object.fromEntries(Object.entries(rs).map(_ref49 => {
|
|
2764
|
+
let [key, value] = _ref49;
|
|
2722
2765
|
const {
|
|
2723
2766
|
additionalValidator,
|
|
2724
2767
|
eventsHandler,
|
|
@@ -2742,11 +2785,11 @@ class KoniExtension {
|
|
|
2742
2785
|
const subscription = (0, _rxjs.combineLatest)({
|
|
2743
2786
|
transactions: transactionsObservable,
|
|
2744
2787
|
processMap: processTransactionObservable
|
|
2745
|
-
}).subscribe(
|
|
2788
|
+
}).subscribe(_ref50 => {
|
|
2746
2789
|
let {
|
|
2747
2790
|
processMap,
|
|
2748
2791
|
transactions
|
|
2749
|
-
} =
|
|
2792
|
+
} = _ref50;
|
|
2750
2793
|
cb(convertRs(transactions, processMap));
|
|
2751
2794
|
});
|
|
2752
2795
|
port.onDisconnect.addListener(() => {
|
|
@@ -2767,10 +2810,10 @@ class KoniExtension {
|
|
|
2767
2810
|
});
|
|
2768
2811
|
return notificationSubject.value;
|
|
2769
2812
|
}
|
|
2770
|
-
async reloadCron(
|
|
2813
|
+
async reloadCron(_ref51) {
|
|
2771
2814
|
let {
|
|
2772
2815
|
data
|
|
2773
|
-
} =
|
|
2816
|
+
} = _ref51;
|
|
2774
2817
|
if (data === 'nft') {
|
|
2775
2818
|
return await this.#koniState.reloadNft();
|
|
2776
2819
|
} else if (data === 'staking') {
|
|
@@ -2813,10 +2856,10 @@ class KoniExtension {
|
|
|
2813
2856
|
}
|
|
2814
2857
|
|
|
2815
2858
|
// Phishing detect
|
|
2816
|
-
async passPhishingPage(
|
|
2859
|
+
async passPhishingPage(_ref52) {
|
|
2817
2860
|
let {
|
|
2818
2861
|
url
|
|
2819
|
-
} =
|
|
2862
|
+
} = _ref52;
|
|
2820
2863
|
return await this.#koniState.approvePassPhishingPage(url);
|
|
2821
2864
|
}
|
|
2822
2865
|
|
|
@@ -2837,10 +2880,10 @@ class KoniExtension {
|
|
|
2837
2880
|
/// Wallet connect
|
|
2838
2881
|
|
|
2839
2882
|
// Connect
|
|
2840
|
-
async connectWalletConnect(
|
|
2883
|
+
async connectWalletConnect(_ref53) {
|
|
2841
2884
|
let {
|
|
2842
2885
|
uri
|
|
2843
|
-
} =
|
|
2886
|
+
} = _ref53;
|
|
2844
2887
|
await this.#koniState.walletConnectService.connect(uri);
|
|
2845
2888
|
return true;
|
|
2846
2889
|
}
|
|
@@ -2853,11 +2896,11 @@ class KoniExtension {
|
|
|
2853
2896
|
});
|
|
2854
2897
|
return this.#koniState.requestService.allConnectWCRequests;
|
|
2855
2898
|
}
|
|
2856
|
-
async approveWalletConnectSession(
|
|
2899
|
+
async approveWalletConnectSession(_ref54) {
|
|
2857
2900
|
let {
|
|
2858
2901
|
accounts: selectedAccounts,
|
|
2859
2902
|
id
|
|
2860
|
-
} =
|
|
2903
|
+
} = _ref54;
|
|
2861
2904
|
const request = this.#koniState.requestService.getConnectWCRequest(id);
|
|
2862
2905
|
if ((0, _helpers2.isProposalExpired)(request.request.params)) {
|
|
2863
2906
|
throw new Error('The proposal has been expired');
|
|
@@ -2869,8 +2912,8 @@ class KoniExtension {
|
|
|
2869
2912
|
const availableNamespaces = {};
|
|
2870
2913
|
const namespaces = {};
|
|
2871
2914
|
const chainInfoMap = this.#koniState.getChainInfoMap();
|
|
2872
|
-
Object.entries(requiredNamespaces).forEach(
|
|
2873
|
-
let [key, namespace] =
|
|
2915
|
+
Object.entries(requiredNamespaces).forEach(_ref55 => {
|
|
2916
|
+
let [key, namespace] = _ref55;
|
|
2874
2917
|
if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
|
|
2875
2918
|
if (namespace.chains) {
|
|
2876
2919
|
const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
|
|
@@ -2883,8 +2926,8 @@ class KoniExtension {
|
|
|
2883
2926
|
throw new Error((0, _utils8.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
|
|
2884
2927
|
}
|
|
2885
2928
|
});
|
|
2886
|
-
Object.entries(optionalNamespaces).forEach(
|
|
2887
|
-
let [key, namespace] =
|
|
2929
|
+
Object.entries(optionalNamespaces).forEach(_ref56 => {
|
|
2930
|
+
let [key, namespace] = _ref56;
|
|
2888
2931
|
if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
|
|
2889
2932
|
if (namespace.chains) {
|
|
2890
2933
|
const supportChains = namespace.chains.filter(chain => (0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap)) || [];
|
|
@@ -2908,8 +2951,8 @@ class KoniExtension {
|
|
|
2908
2951
|
}
|
|
2909
2952
|
}
|
|
2910
2953
|
});
|
|
2911
|
-
Object.entries(availableNamespaces).forEach(
|
|
2912
|
-
let [key, namespace] =
|
|
2954
|
+
Object.entries(availableNamespaces).forEach(_ref57 => {
|
|
2955
|
+
let [key, namespace] = _ref57;
|
|
2913
2956
|
if (namespace.chains) {
|
|
2914
2957
|
const accounts = selectedAccounts.filter(address => {
|
|
2915
2958
|
const [_namespace] = address.split(':');
|
|
@@ -2933,10 +2976,10 @@ class KoniExtension {
|
|
|
2933
2976
|
request.resolve();
|
|
2934
2977
|
return true;
|
|
2935
2978
|
}
|
|
2936
|
-
async rejectWalletConnectSession(
|
|
2979
|
+
async rejectWalletConnectSession(_ref58) {
|
|
2937
2980
|
let {
|
|
2938
2981
|
id
|
|
2939
|
-
} =
|
|
2982
|
+
} = _ref58;
|
|
2940
2983
|
const request = this.#koniState.requestService.getConnectWCRequest(id);
|
|
2941
2984
|
const wcId = request.request.id;
|
|
2942
2985
|
if ((0, _helpers2.isProposalExpired)(request.request.params)) {
|
|
@@ -2958,10 +3001,10 @@ class KoniExtension {
|
|
|
2958
3001
|
});
|
|
2959
3002
|
return this.#koniState.walletConnectService.sessions;
|
|
2960
3003
|
}
|
|
2961
|
-
async disconnectWalletConnectSession(
|
|
3004
|
+
async disconnectWalletConnectSession(_ref59) {
|
|
2962
3005
|
let {
|
|
2963
3006
|
topic
|
|
2964
|
-
} =
|
|
3007
|
+
} = _ref59;
|
|
2965
3008
|
await this.#koniState.walletConnectService.disconnect(topic);
|
|
2966
3009
|
return true;
|
|
2967
3010
|
}
|
|
@@ -2974,18 +3017,18 @@ class KoniExtension {
|
|
|
2974
3017
|
});
|
|
2975
3018
|
return this.#koniState.requestService.allNotSupportWCRequests;
|
|
2976
3019
|
}
|
|
2977
|
-
approveWalletConnectNotSupport(
|
|
3020
|
+
approveWalletConnectNotSupport(_ref60) {
|
|
2978
3021
|
let {
|
|
2979
3022
|
id
|
|
2980
|
-
} =
|
|
3023
|
+
} = _ref60;
|
|
2981
3024
|
const request = this.#koniState.requestService.getNotSupportWCRequest(id);
|
|
2982
3025
|
request.resolve();
|
|
2983
3026
|
return true;
|
|
2984
3027
|
}
|
|
2985
|
-
rejectWalletConnectNotSupport(
|
|
3028
|
+
rejectWalletConnectNotSupport(_ref61) {
|
|
2986
3029
|
let {
|
|
2987
3030
|
id
|
|
2988
|
-
} =
|
|
3031
|
+
} = _ref61;
|
|
2989
3032
|
const request = this.#koniState.requestService.getNotSupportWCRequest(id);
|
|
2990
3033
|
request.reject(new Error('USER_REJECTED'));
|
|
2991
3034
|
return true;
|
|
@@ -2993,11 +3036,11 @@ class KoniExtension {
|
|
|
2993
3036
|
|
|
2994
3037
|
/// Manta
|
|
2995
3038
|
|
|
2996
|
-
async enableMantaPay(
|
|
3039
|
+
async enableMantaPay(_ref62) {
|
|
2997
3040
|
let {
|
|
2998
3041
|
address,
|
|
2999
3042
|
password
|
|
3000
|
-
} =
|
|
3043
|
+
} = _ref62;
|
|
3001
3044
|
// always takes the current account
|
|
3002
3045
|
function timeout() {
|
|
3003
3046
|
return new Promise(resolve => setTimeout(resolve, 1500));
|
|
@@ -3087,11 +3130,11 @@ class KoniExtension {
|
|
|
3087
3130
|
async disableMantaPay(address) {
|
|
3088
3131
|
return this.#koniState.disableMantaPay(address);
|
|
3089
3132
|
}
|
|
3090
|
-
async isTonBounceableAddress(
|
|
3133
|
+
async isTonBounceableAddress(_ref63) {
|
|
3091
3134
|
let {
|
|
3092
3135
|
address,
|
|
3093
3136
|
chain
|
|
3094
|
-
} =
|
|
3137
|
+
} = _ref63;
|
|
3095
3138
|
try {
|
|
3096
3139
|
const tonApi = this.#koniState.getTonApi(chain);
|
|
3097
3140
|
const state = await tonApi.getAccountState(address);
|
|
@@ -3137,10 +3180,10 @@ class KoniExtension {
|
|
|
3137
3180
|
|
|
3138
3181
|
/* Metadata */
|
|
3139
3182
|
|
|
3140
|
-
async findRawMetadata(
|
|
3183
|
+
async findRawMetadata(_ref64) {
|
|
3141
3184
|
let {
|
|
3142
3185
|
genesisHash
|
|
3143
|
-
} =
|
|
3186
|
+
} = _ref64;
|
|
3144
3187
|
const {
|
|
3145
3188
|
metadata,
|
|
3146
3189
|
specVersion,
|
|
@@ -3154,20 +3197,20 @@ class KoniExtension {
|
|
|
3154
3197
|
userExtensions
|
|
3155
3198
|
};
|
|
3156
3199
|
}
|
|
3157
|
-
async calculateMetadataHash(
|
|
3200
|
+
async calculateMetadataHash(_ref65) {
|
|
3158
3201
|
let {
|
|
3159
3202
|
chain
|
|
3160
|
-
} =
|
|
3203
|
+
} = _ref65;
|
|
3161
3204
|
const hash = await this.#koniState.calculateMetadataHash(chain);
|
|
3162
3205
|
return {
|
|
3163
3206
|
metadataHash: hash || ''
|
|
3164
3207
|
};
|
|
3165
3208
|
}
|
|
3166
|
-
async shortenMetadata(
|
|
3209
|
+
async shortenMetadata(_ref66) {
|
|
3167
3210
|
let {
|
|
3168
3211
|
chain,
|
|
3169
3212
|
txBlob
|
|
3170
|
-
} =
|
|
3213
|
+
} = _ref66;
|
|
3171
3214
|
const shorten = await this.#koniState.shortenMetadata(chain, txBlob);
|
|
3172
3215
|
return {
|
|
3173
3216
|
txMetadata: shorten || ''
|
|
@@ -3520,18 +3563,18 @@ class KoniExtension {
|
|
|
3520
3563
|
|
|
3521
3564
|
/* Campaign */
|
|
3522
3565
|
|
|
3523
|
-
unlockDotCheckCanMint(
|
|
3566
|
+
unlockDotCheckCanMint(_ref67) {
|
|
3524
3567
|
let {
|
|
3525
3568
|
address,
|
|
3526
3569
|
network,
|
|
3527
3570
|
slug
|
|
3528
|
-
} =
|
|
3571
|
+
} = _ref67;
|
|
3529
3572
|
return this.#koniState.mintCampaignService.unlockDotCampaign.canMint(address, slug, network);
|
|
3530
3573
|
}
|
|
3531
|
-
unlockDotSubscribeMintedData(id, port,
|
|
3574
|
+
unlockDotSubscribeMintedData(id, port, _ref68) {
|
|
3532
3575
|
let {
|
|
3533
3576
|
transactionId
|
|
3534
|
-
} =
|
|
3577
|
+
} = _ref68;
|
|
3535
3578
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3536
3579
|
const subscription = this.#koniState.mintCampaignService.unlockDotCampaign.subscribeMintedNft(transactionId, cb);
|
|
3537
3580
|
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
@@ -3563,10 +3606,10 @@ class KoniExtension {
|
|
|
3563
3606
|
});
|
|
3564
3607
|
return filterBanner(await this.#koniState.campaignService.getProcessingCampaign());
|
|
3565
3608
|
}
|
|
3566
|
-
async completeCampaignBanner(
|
|
3609
|
+
async completeCampaignBanner(_ref69) {
|
|
3567
3610
|
let {
|
|
3568
3611
|
slug
|
|
3569
|
-
} =
|
|
3612
|
+
} = _ref69;
|
|
3570
3613
|
const campaign = await this.#koniState.dbService.getCampaign(slug);
|
|
3571
3614
|
if (campaign) {
|
|
3572
3615
|
await this.#koniState.dbService.upsertCampaign({
|
|
@@ -3699,11 +3742,9 @@ class KoniExtension {
|
|
|
3699
3742
|
ready = true;
|
|
3700
3743
|
return this.#koniState.swapService.getSwapPairs();
|
|
3701
3744
|
}
|
|
3702
|
-
async getOptimalSwapProcessOnSelectQuote(request) {
|
|
3703
|
-
return this.#koniState.swapService.generateOptimalProcessWithoutPath(request);
|
|
3704
|
-
}
|
|
3705
3745
|
async handleSwapRequest(request) {
|
|
3706
|
-
|
|
3746
|
+
// @ts-ignore
|
|
3747
|
+
return Promise.resolve(null);
|
|
3707
3748
|
}
|
|
3708
3749
|
async handleSwapRequestV2(request) {
|
|
3709
3750
|
return this.#koniState.swapService.handleSwapRequestV2(request);
|
|
@@ -3715,7 +3756,7 @@ class KoniExtension {
|
|
|
3715
3756
|
return swapQuoteResponse;
|
|
3716
3757
|
}
|
|
3717
3758
|
async validateSwapProcess(params) {
|
|
3718
|
-
return this.#koniState.swapService.
|
|
3759
|
+
return this.#koniState.swapService.validateSwapProcessV2(params);
|
|
3719
3760
|
}
|
|
3720
3761
|
async handleSwapStep(inputData) {
|
|
3721
3762
|
const {
|
|
@@ -3745,7 +3786,7 @@ class KoniExtension {
|
|
|
3745
3786
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types3.BasicTxErrorType.INTERNAL_ERROR)]);
|
|
3746
3787
|
}
|
|
3747
3788
|
const isLastStep = inputData.currentStep + 1 === process.steps.length;
|
|
3748
|
-
const swapValidations = await this.#koniState.swapService.
|
|
3789
|
+
const swapValidations = await this.#koniState.swapService.validateSwapProcessV2({
|
|
3749
3790
|
address,
|
|
3750
3791
|
process,
|
|
3751
3792
|
selectedQuote: quote,
|
|
@@ -3769,9 +3810,9 @@ class KoniExtension {
|
|
|
3769
3810
|
status: _types3.StepStatus.FAILED
|
|
3770
3811
|
});
|
|
3771
3812
|
}
|
|
3813
|
+
console.log('Error handling process step', e);
|
|
3772
3814
|
throw e;
|
|
3773
3815
|
}
|
|
3774
|
-
console.log('swap data', submitData);
|
|
3775
3816
|
|
|
3776
3817
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3777
3818
|
const {
|
|
@@ -3783,17 +3824,12 @@ class KoniExtension {
|
|
|
3783
3824
|
txChain,
|
|
3784
3825
|
txData
|
|
3785
3826
|
} = submitData;
|
|
3786
|
-
|
|
3787
|
-
// const chosenFeeToken = process.steps.findIndex((step) => step.type === SwapStepType.SET_FEE_TOKEN) > -1;
|
|
3788
|
-
// const allowSkipValidation = [ExtrinsicType.SET_FEE_TOKEN, ExtrinsicType.SWAP].includes(extrinsicType);
|
|
3789
|
-
|
|
3790
3827
|
const eventsHandler = eventEmitter => {
|
|
3791
3828
|
if (onSend) {
|
|
3792
3829
|
eventEmitter.on('send', onSend);
|
|
3793
3830
|
}
|
|
3794
3831
|
};
|
|
3795
3832
|
if (processId) {
|
|
3796
|
-
const _step = process.steps[inputData.currentStep];
|
|
3797
3833
|
if (!this.#koniState.transactionService.checkProcessExist(processId) && step) {
|
|
3798
3834
|
const combineInfo = {
|
|
3799
3835
|
provider: quote.provider,
|
|
@@ -3811,23 +3847,6 @@ class KoniExtension {
|
|
|
3811
3847
|
combineInfo,
|
|
3812
3848
|
steps: inputData.process.steps.map((step, index) => {
|
|
3813
3849
|
const fee = inputData.process.totalFee[index];
|
|
3814
|
-
if (step.type === _types3.SwapStepType.SWAP) {
|
|
3815
|
-
const metadata = {
|
|
3816
|
-
pair: quote.pair,
|
|
3817
|
-
aliveUntil: quote.aliveUntil,
|
|
3818
|
-
fromAmount: quote.fromAmount,
|
|
3819
|
-
rate: quote.rate,
|
|
3820
|
-
provider: quote.provider,
|
|
3821
|
-
route: quote.route,
|
|
3822
|
-
toAmount: quote.toAmount
|
|
3823
|
-
};
|
|
3824
|
-
return {
|
|
3825
|
-
...step,
|
|
3826
|
-
status: _types3.StepStatus.QUEUED,
|
|
3827
|
-
fee,
|
|
3828
|
-
metadata: metadata
|
|
3829
|
-
};
|
|
3830
|
-
}
|
|
3831
3850
|
return {
|
|
3832
3851
|
...step,
|
|
3833
3852
|
fee,
|
|
@@ -3837,34 +3856,6 @@ class KoniExtension {
|
|
|
3837
3856
|
status: _types3.StepStatus.QUEUED
|
|
3838
3857
|
});
|
|
3839
3858
|
}
|
|
3840
|
-
const isLastStep = inputData.currentStep === process.steps.length - 1;
|
|
3841
|
-
if (isLastStep) {
|
|
3842
|
-
const metadata = {
|
|
3843
|
-
pair: quote.pair,
|
|
3844
|
-
aliveUntil: quote.aliveUntil,
|
|
3845
|
-
fromAmount: quote.fromAmount,
|
|
3846
|
-
rate: quote.rate,
|
|
3847
|
-
provider: quote.provider,
|
|
3848
|
-
route: quote.route,
|
|
3849
|
-
toAmount: quote.toAmount
|
|
3850
|
-
};
|
|
3851
|
-
const step = {
|
|
3852
|
-
..._step,
|
|
3853
|
-
// In case one sign, status already set to prepare before
|
|
3854
|
-
status: process.steps.length > 2 ? _types3.StepStatus.PREPARE : _types3.StepStatus.QUEUED,
|
|
3855
|
-
fee: process.totalFee[inputData.currentStep],
|
|
3856
|
-
metadata: metadata
|
|
3857
|
-
};
|
|
3858
|
-
const combineInfo = {
|
|
3859
|
-
provider: quote.provider,
|
|
3860
|
-
slippage: inputData.slippage,
|
|
3861
|
-
address,
|
|
3862
|
-
recipient,
|
|
3863
|
-
quote,
|
|
3864
|
-
process
|
|
3865
|
-
};
|
|
3866
|
-
await this.#koniState.transactionService.updateProcessInfo(processId, combineInfo, step);
|
|
3867
|
-
}
|
|
3868
3859
|
}
|
|
3869
3860
|
if (isPermit) {
|
|
3870
3861
|
return await this.#koniState.transactionService.handlePermitTransaction({
|
|
@@ -4096,32 +4087,10 @@ class KoniExtension {
|
|
|
4096
4087
|
nextTxType: _KoniTypes.ExtrinsicType.SWAP
|
|
4097
4088
|
};
|
|
4098
4089
|
submitData = async (step, callback) => {
|
|
4099
|
-
const isLastStep = step === stepNums - 1;
|
|
4100
4090
|
const isPassConfirmation = !callback;
|
|
4101
4091
|
const onSend = callback
|
|
4102
4092
|
// eslint-disable-next-line node/no-callback-literal
|
|
4103
4093
|
? rs => callback(rs) : undefined;
|
|
4104
|
-
const specialCaseForUniswap = data.quote.provider.id === _types3.SwapProviderId.UNISWAP && !!data.process.steps.find(step => step.type === _types3.SwapStepType.PERMIT);
|
|
4105
|
-
if (stepNums > 2 && isLastStep && !specialCaseForUniswap) {
|
|
4106
|
-
const quote = data.quote;
|
|
4107
|
-
const latestSwapQuote = await this.getLatestSwapQuote({
|
|
4108
|
-
address: data.address,
|
|
4109
|
-
currentQuote: quote.provider,
|
|
4110
|
-
feeToken: quote.feeInfo.selectedFeeToken,
|
|
4111
|
-
recipient: data.recipient,
|
|
4112
|
-
pair: quote.pair,
|
|
4113
|
-
fromAmount: quote.fromAmount,
|
|
4114
|
-
slippage: data.slippage
|
|
4115
|
-
});
|
|
4116
|
-
return this.handleSwapStep({
|
|
4117
|
-
...data,
|
|
4118
|
-
quote: latestSwapQuote.optimalQuote || data.quote,
|
|
4119
|
-
currentStep: step,
|
|
4120
|
-
isPassConfirmation,
|
|
4121
|
-
errorOnTimeOut: true,
|
|
4122
|
-
processId
|
|
4123
|
-
});
|
|
4124
|
-
}
|
|
4125
4094
|
return this.handleSwapStep({
|
|
4126
4095
|
...data,
|
|
4127
4096
|
currentStep: step,
|
|
@@ -4156,8 +4125,8 @@ class KoniExtension {
|
|
|
4156
4125
|
resolve();
|
|
4157
4126
|
}
|
|
4158
4127
|
};
|
|
4159
|
-
this.#koniState.balanceService.subscribeTransferableBalance(address, waitXcmData.chain, waitXcmData.token, waitXcmData.nextTxType, onRs).then(
|
|
4160
|
-
let [_unsub, rs] =
|
|
4128
|
+
this.#koniState.balanceService.subscribeTransferableBalance(address, waitXcmData.chain, waitXcmData.token, waitXcmData.nextTxType, onRs).then(_ref70 => {
|
|
4129
|
+
let [_unsub, rs] = _ref70;
|
|
4161
4130
|
unsub = _unsub;
|
|
4162
4131
|
onRs(rs);
|
|
4163
4132
|
}).catch(console.error);
|
|
@@ -4548,6 +4517,8 @@ class KoniExtension {
|
|
|
4548
4517
|
return this.getSupportedSmartContractTypes();
|
|
4549
4518
|
case 'pri(chainService.enableChain)':
|
|
4550
4519
|
return await this.enableChain(request);
|
|
4520
|
+
case 'pri(chainService.enableChainWithPriorityAssets)':
|
|
4521
|
+
return await this.enableChainWithPriorityAssets(request);
|
|
4551
4522
|
case 'pri(chainService.reconnectChain)':
|
|
4552
4523
|
return await this.reconnectChain(request);
|
|
4553
4524
|
case 'pri(chainService.disableChain)':
|
|
@@ -4824,8 +4795,6 @@ class KoniExtension {
|
|
|
4824
4795
|
/* Swap service */
|
|
4825
4796
|
case 'pri(swapService.subscribePairs)':
|
|
4826
4797
|
return this.subscribeSwapPairs(id, port);
|
|
4827
|
-
case 'pri(swapService.getOptimalProcessOnSelectQuote)':
|
|
4828
|
-
return this.getOptimalSwapProcessOnSelectQuote(request);
|
|
4829
4798
|
case 'pri(swapService.handleSwapRequest)':
|
|
4830
4799
|
return this.handleSwapRequest(request);
|
|
4831
4800
|
case 'pri(swapService.handleSwapRequestV2)':
|