@subwallet/extension-base 1.3.71-0 → 1.3.72-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 +13 -2
- package/background/KoniTypes.js +3 -1
- package/cjs/background/KoniTypes.js +3 -1
- package/cjs/core/logic-validation/recipientAddress.js +1 -1
- package/cjs/core/logic-validation/transfer.js +33 -10
- package/cjs/core/types.js +1 -0
- package/cjs/koni/background/handlers/Extension.js +81 -8
- package/cjs/koni/background/handlers/State.js +2 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +46 -2
- package/cjs/services/balance-service/transfer/token.js +13 -35
- package/cjs/services/balance-service/transfer/xcm/index.js +3 -8
- package/cjs/services/balance-service/transfer/xcm/utils.js +1 -1
- package/cjs/services/chain-service/constants.js +6 -5
- package/cjs/services/chain-service/index.js +1 -0
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +55 -0
- package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +41 -0
- package/cjs/services/migration-service/scripts/index.js +17 -13
- package/cjs/services/substrate-proxy-service/constant.js +26 -0
- package/cjs/services/substrate-proxy-service/index.js +170 -0
- package/cjs/services/transaction-service/index.js +78 -10
- package/cjs/services/transaction-service/utils.js +8 -5
- package/cjs/types/index.js +11 -0
- package/cjs/types/substrateProxyAccount/actions/index.js +1 -0
- package/cjs/types/substrateProxyAccount/index.js +16 -0
- package/cjs/utils/account/transform.js +5 -4
- package/cjs/utils/fee/transfer.js +4 -2
- package/core/logic-validation/recipientAddress.js +1 -1
- package/core/logic-validation/transfer.d.ts +3 -3
- package/core/logic-validation/transfer.js +34 -11
- package/core/types.d.ts +2 -1
- package/core/types.js +1 -0
- package/koni/background/handlers/Extension.d.ts +3 -0
- package/koni/background/handlers/Extension.js +81 -8
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +2 -0
- package/package.json +36 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +47 -3
- package/services/balance-service/transfer/token.d.ts +0 -4
- package/services/balance-service/transfer/token.js +12 -33
- package/services/balance-service/transfer/xcm/index.js +3 -8
- package/services/balance-service/transfer/xcm/utils.d.ts +0 -2
- package/services/balance-service/transfer/xcm/utils.js +1 -1
- package/services/chain-service/constants.d.ts +1 -1
- package/services/chain-service/constants.js +4 -4
- package/services/chain-service/index.js +1 -0
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +46 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +33 -0
- package/services/migration-service/scripts/index.js +8 -4
- package/services/open-gov/interface.d.ts +4 -3
- package/services/substrate-proxy-service/constant.d.ts +3 -0
- package/services/substrate-proxy-service/constant.js +19 -0
- package/services/substrate-proxy-service/index.d.ts +13 -0
- package/services/substrate-proxy-service/index.js +159 -0
- package/services/transaction-service/index.js +79 -11
- package/services/transaction-service/types.d.ts +2 -2
- package/services/transaction-service/utils.js +8 -5
- package/types/balance/transfer.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/substrateProxyAccount/actions/index.d.ts +17 -0
- package/types/substrateProxyAccount/actions/index.js +1 -0
- package/types/substrateProxyAccount/index.d.ts +23 -0
- package/types/substrateProxyAccount/index.js +8 -0
- package/types/transaction/request.d.ts +1 -0
- package/types/yield/actions/join/submit.d.ts +1 -1
- package/utils/account/transform.js +5 -4
- package/utils/fee/transfer.js +4 -2
|
@@ -35,6 +35,7 @@ import { SignerResult } from '@polkadot/types/types/extrinsic';
|
|
|
35
35
|
import { HexString } from '@polkadot/util/types';
|
|
36
36
|
import { EarningImpactResult } from '../services/earning-service/handlers/native-staking/dtao';
|
|
37
37
|
import { GovVoteRequest, GovVotingInfo, RemoveVoteRequest, UnlockVoteRequest } from '../services/open-gov/interface';
|
|
38
|
+
import { RequestAddSubstrateProxyAccount, RequestGetSubstrateProxyAccountGroup, RequestRemoveSubstrateProxyAccount, SubstrateProxyAccountGroup } from '../types/substrateProxyAccount';
|
|
38
39
|
import { TransactionWarning } from './warnings/TransactionWarning';
|
|
39
40
|
export declare enum RuntimeEnvironment {
|
|
40
41
|
Web = "Web",
|
|
@@ -450,8 +451,10 @@ export declare enum ExtrinsicType {
|
|
|
450
451
|
CLAIM_BRIDGE = "claim.claim_bridge",
|
|
451
452
|
GOV_VOTE = "gov.vote",
|
|
452
453
|
GOV_UNVOTE = "gov.unvote",
|
|
453
|
-
GOV_UNLOCK_VOTE = "gov.
|
|
454
|
+
GOV_UNLOCK_VOTE = "gov.unlock_vote",
|
|
454
455
|
EVM_EXECUTE = "evm.execute",
|
|
456
|
+
ADD_SUBSTRATE_PROXY_ACCOUNT = "substrateProxyAccount.add",
|
|
457
|
+
REMOVE_SUBSTRATE_PROXY_ACCOUNT = "substrateProxyAccount.remove",
|
|
455
458
|
UNKNOWN = "unknown"
|
|
456
459
|
}
|
|
457
460
|
export interface ExtrinsicDataTypeMap {
|
|
@@ -494,9 +497,12 @@ export interface ExtrinsicDataTypeMap {
|
|
|
494
497
|
[ExtrinsicType.CLAIM_BRIDGE]: RequestClaimBridge;
|
|
495
498
|
[ExtrinsicType.EVM_EXECUTE]: TransactionConfig;
|
|
496
499
|
[ExtrinsicType.CROWDLOAN]: any;
|
|
500
|
+
[ExtrinsicType.SWAP]: SwapTxData;
|
|
497
501
|
[ExtrinsicType.GOV_VOTE]: GovVoteRequest;
|
|
498
502
|
[ExtrinsicType.GOV_UNVOTE]: RemoveVoteRequest;
|
|
499
503
|
[ExtrinsicType.GOV_UNLOCK_VOTE]: UnlockVoteRequest;
|
|
504
|
+
[ExtrinsicType.ADD_SUBSTRATE_PROXY_ACCOUNT]: RequestAddSubstrateProxyAccount;
|
|
505
|
+
[ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT]: RequestRemoveSubstrateProxyAccount;
|
|
500
506
|
[ExtrinsicType.SWAP]: SwapTxData;
|
|
501
507
|
[ExtrinsicType.UNKNOWN]: any;
|
|
502
508
|
}
|
|
@@ -607,6 +613,7 @@ export interface TransactionHistoryItem<ET extends ExtrinsicType = ExtrinsicType
|
|
|
607
613
|
addressPrefix?: number;
|
|
608
614
|
processId?: string;
|
|
609
615
|
apiTxIndex?: number;
|
|
616
|
+
substrateProxyAddresses?: string[];
|
|
610
617
|
}
|
|
611
618
|
export interface SWWarning {
|
|
612
619
|
errorType: string;
|
|
@@ -766,7 +773,7 @@ export declare type TxResultType = {
|
|
|
766
773
|
fee?: string;
|
|
767
774
|
feeSymbol?: string;
|
|
768
775
|
};
|
|
769
|
-
export interface NftTransactionRequest {
|
|
776
|
+
export interface NftTransactionRequest extends BaseRequestSign {
|
|
770
777
|
networkKey: string;
|
|
771
778
|
senderAddress: string;
|
|
772
779
|
recipientAddress: string;
|
|
@@ -834,6 +841,7 @@ export interface SubstrateNftSubmitTransaction extends BaseRequestSign {
|
|
|
834
841
|
senderAddress: string;
|
|
835
842
|
nftItemName?: string;
|
|
836
843
|
recipientAddress: string;
|
|
844
|
+
nftItem: NftItem;
|
|
837
845
|
}
|
|
838
846
|
export declare type RequestSubstrateNftSubmitTransaction = InternalRequestSign<SubstrateNftSubmitTransaction>;
|
|
839
847
|
export interface RequestAccountMeta {
|
|
@@ -2095,6 +2103,9 @@ export interface KoniRequestSignatures {
|
|
|
2095
2103
|
'pri(openGov.unvote)': [RemoveVoteRequest, SWTransactionResponse];
|
|
2096
2104
|
'pri(openGov.subscribeGovLockedInfo)': [null, GovVotingInfo[], GovVotingInfo[]];
|
|
2097
2105
|
'pri(openGov.unlockVote)': [UnlockVoteRequest, SWTransactionResponse];
|
|
2106
|
+
'pri(substrateProxyAccount.getGroupInfo)': [RequestGetSubstrateProxyAccountGroup, SubstrateProxyAccountGroup];
|
|
2107
|
+
'pri(substrateProxyAccount.add)': [RequestAddSubstrateProxyAccount, SWTransactionResponse];
|
|
2108
|
+
'pri(substrateProxyAccount.remove)': [RequestRemoveSubstrateProxyAccount, SWTransactionResponse];
|
|
2098
2109
|
}
|
|
2099
2110
|
export interface ApplicationMetadataType {
|
|
2100
2111
|
version: string;
|
package/background/KoniTypes.js
CHANGED
|
@@ -117,8 +117,10 @@ export let ExtrinsicType;
|
|
|
117
117
|
ExtrinsicType["CLAIM_BRIDGE"] = "claim.claim_bridge";
|
|
118
118
|
ExtrinsicType["GOV_VOTE"] = "gov.vote";
|
|
119
119
|
ExtrinsicType["GOV_UNVOTE"] = "gov.unvote";
|
|
120
|
-
ExtrinsicType["GOV_UNLOCK_VOTE"] = "gov.
|
|
120
|
+
ExtrinsicType["GOV_UNLOCK_VOTE"] = "gov.unlock_vote";
|
|
121
121
|
ExtrinsicType["EVM_EXECUTE"] = "evm.execute";
|
|
122
|
+
ExtrinsicType["ADD_SUBSTRATE_PROXY_ACCOUNT"] = "substrateProxyAccount.add";
|
|
123
|
+
ExtrinsicType["REMOVE_SUBSTRATE_PROXY_ACCOUNT"] = "substrateProxyAccount.remove";
|
|
122
124
|
ExtrinsicType["UNKNOWN"] = "unknown";
|
|
123
125
|
})(ExtrinsicType || (ExtrinsicType = {}));
|
|
124
126
|
export let ExtrinsicStatus;
|
|
@@ -132,8 +132,10 @@ exports.ExtrinsicType = ExtrinsicType;
|
|
|
132
132
|
ExtrinsicType["CLAIM_BRIDGE"] = "claim.claim_bridge";
|
|
133
133
|
ExtrinsicType["GOV_VOTE"] = "gov.vote";
|
|
134
134
|
ExtrinsicType["GOV_UNVOTE"] = "gov.unvote";
|
|
135
|
-
ExtrinsicType["GOV_UNLOCK_VOTE"] = "gov.
|
|
135
|
+
ExtrinsicType["GOV_UNLOCK_VOTE"] = "gov.unlock_vote";
|
|
136
136
|
ExtrinsicType["EVM_EXECUTE"] = "evm.execute";
|
|
137
|
+
ExtrinsicType["ADD_SUBSTRATE_PROXY_ACCOUNT"] = "substrateProxyAccount.add";
|
|
138
|
+
ExtrinsicType["REMOVE_SUBSTRATE_PROXY_ACCOUNT"] = "substrateProxyAccount.remove";
|
|
137
139
|
ExtrinsicType["UNKNOWN"] = "unknown";
|
|
138
140
|
})(ExtrinsicType || (exports.ExtrinsicType = ExtrinsicType = {}));
|
|
139
141
|
let ExtrinsicStatus;
|
|
@@ -23,7 +23,7 @@ function getConditions(validateRecipientParams) {
|
|
|
23
23
|
toAddress
|
|
24
24
|
} = validateRecipientParams;
|
|
25
25
|
const conditions = [];
|
|
26
|
-
const isSendAction = [_types.ActionType.SEND_FUND, _types.ActionType.SEND_NFT].includes(actionType);
|
|
26
|
+
const isSendAction = [_types.ActionType.SEND_FUND, _types.ActionType.SEND_NFT, _types.ActionType.MANAGE_SUBSTRATE_PROXY_ACCOUNT].includes(actionType);
|
|
27
27
|
conditions.push(_types.ValidationCondition.IS_NOT_NULL);
|
|
28
28
|
conditions.push(_types.ValidationCondition.IS_ADDRESS);
|
|
29
29
|
conditions.push(_types.ValidationCondition.IS_VALID_ADDRESS_FOR_ECOSYSTEM);
|
|
@@ -326,7 +326,7 @@ function checkSupportForTransaction(validationResponse, transaction) {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
async function estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, isTransferLocalTokenAndPayThatTokenAsFee) {
|
|
329
|
+
async function estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, isTransferLocalTokenAndPayThatTokenAsFee, signerSubstrateProxyAddress) {
|
|
330
330
|
const estimateFee = {
|
|
331
331
|
symbol: '',
|
|
332
332
|
decimals: 0,
|
|
@@ -347,8 +347,14 @@ async function estimateFeeForTransaction(validationResponse, transaction, chainI
|
|
|
347
347
|
if (transaction) {
|
|
348
348
|
try {
|
|
349
349
|
if ((0, _helpers.isSubstrateTransaction)(transaction)) {
|
|
350
|
-
|
|
351
|
-
|
|
350
|
+
if (signerSubstrateProxyAddress && !(0, _utils5.isSameAddress)(signerSubstrateProxyAddress, address)) {
|
|
351
|
+
await substrateApi.isReady;
|
|
352
|
+
const estimateExtrinsic = substrateApi.api.tx.proxy.proxy(address, null, transaction);
|
|
353
|
+
estimateFee.value = (await estimateExtrinsic.paymentInfo(signerSubstrateProxyAddress)).partialFee.toString();
|
|
354
|
+
} else {
|
|
355
|
+
var _validationResponse$x;
|
|
356
|
+
estimateFee.value = (_validationResponse$x = validationResponse.xcmFeeDryRun) !== null && _validationResponse$x !== void 0 ? _validationResponse$x : (await transaction.paymentInfo(validationResponse.address)).partialFee.toString();
|
|
357
|
+
}
|
|
352
358
|
} else if ((0, _helpers.isTonTransaction)(transaction)) {
|
|
353
359
|
estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
|
|
354
360
|
} else if ((0, _helpers.isCardanoTransaction)(transaction)) {
|
|
@@ -415,14 +421,13 @@ async function estimateFeeForTransaction(validationResponse, transaction, chainI
|
|
|
415
421
|
}
|
|
416
422
|
return estimateFee;
|
|
417
423
|
}
|
|
418
|
-
function checkSigningAccountForTransaction(validationResponse, chainInfoMap) {
|
|
424
|
+
function checkSigningAccountForTransaction(validationResponse, chainInfoMap, signer) {
|
|
419
425
|
const {
|
|
420
|
-
address,
|
|
421
426
|
chain,
|
|
422
427
|
chainType,
|
|
423
428
|
extrinsicType
|
|
424
429
|
} = validationResponse;
|
|
425
|
-
const pair = _uiKeyring.keyring.getPair(
|
|
430
|
+
const pair = _uiKeyring.keyring.getPair(signer);
|
|
426
431
|
if (!pair) {
|
|
427
432
|
validationResponse.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.INTERNAL_ERROR, (0, _i18next.t)('bg.TRANSACTION.core.validation.transfer.unableToFindAccount')));
|
|
428
433
|
} else {
|
|
@@ -442,7 +447,7 @@ function checkSigningAccountForTransaction(validationResponse, chainInfoMap) {
|
|
|
442
447
|
}
|
|
443
448
|
}
|
|
444
449
|
}
|
|
445
|
-
function checkBalanceWithTransactionFee(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable) {
|
|
450
|
+
function checkBalanceWithTransactionFee(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable, substrateProxyAccountNativeTokenAvailable) {
|
|
446
451
|
if (!validationResponse.estimateFee) {
|
|
447
452
|
// todo: estimateFee should be must-have, need to refactor interface
|
|
448
453
|
return;
|
|
@@ -451,6 +456,7 @@ function checkBalanceWithTransactionFee(validationResponse, transactionInput, na
|
|
|
451
456
|
edAsWarning,
|
|
452
457
|
extrinsicType,
|
|
453
458
|
isTransferAll,
|
|
459
|
+
signerSubstrateProxyAddress,
|
|
454
460
|
skipFeeValidation,
|
|
455
461
|
tokenPayFeeSlug
|
|
456
462
|
} = transactionInput;
|
|
@@ -461,12 +467,29 @@ function checkBalanceWithTransactionFee(validationResponse, transactionInput, na
|
|
|
461
467
|
const bnFee = new _bignumber.default(validationResponse.estimateFee.value);
|
|
462
468
|
const bnNativeTokenAvailable = new _bignumber.default(nativeTokenAvailable.value);
|
|
463
469
|
const bnNativeTokenTransferAmount = new _bignumber.default(validationResponse.transferNativeAmount || '0');
|
|
464
|
-
if (!bnNativeTokenAvailable.gt(0)) {
|
|
470
|
+
if (!bnNativeTokenAvailable.gt(0) && !substrateProxyAccountNativeTokenAvailable) {
|
|
465
471
|
validationResponse.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
466
472
|
}
|
|
467
473
|
const isChainNotSupportTransferAll = [..._constants2._TRANSFER_CHAIN_GROUP.acala, ..._constants2._TRANSFER_CHAIN_GROUP.genshiro, ..._constants2._TRANSFER_CHAIN_GROUP.bitcountry, ..._constants2._TRANSFER_CHAIN_GROUP.statemine].includes(nativeTokenInfo.originChain);
|
|
468
|
-
if (
|
|
469
|
-
|
|
474
|
+
if (!substrateProxyAccountNativeTokenAvailable) {
|
|
475
|
+
if (bnNativeTokenTransferAmount.plus(bnFee).gt(bnNativeTokenAvailable) && (!isTransferAll || isChainNotSupportTransferAll)) {
|
|
476
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.NOT_ENOUGH_BALANCE)); // todo: should be generalized and reused in all features
|
|
477
|
+
}
|
|
478
|
+
} else {
|
|
479
|
+
const bnSubstrateProxyAccountNativeTokenAvailable = new _bignumber.default(substrateProxyAccountNativeTokenAvailable.value);
|
|
480
|
+
if (bnNativeTokenTransferAmount.gt(bnNativeTokenAvailable) && (!isTransferAll || isChainNotSupportTransferAll) || bnFee.gt(bnSubstrateProxyAccountNativeTokenAvailable)) {
|
|
481
|
+
if (signerSubstrateProxyAddress) {
|
|
482
|
+
const account = (0, _utils5.getAccountJsonByAddress)(signerSubstrateProxyAddress);
|
|
483
|
+
const accountName = account === null || account === void 0 ? void 0 : account.name;
|
|
484
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.NOT_ENOUGH_BALANCE, (0, _i18next.t)('bg.TRANSACTION.core.validation.transfer.proxyAccountNotEnoughBalance', {
|
|
485
|
+
replace: {
|
|
486
|
+
accountName: accountName || signerSubstrateProxyAddress
|
|
487
|
+
}
|
|
488
|
+
})));
|
|
489
|
+
} else {
|
|
490
|
+
validationResponse.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
491
|
+
}
|
|
492
|
+
}
|
|
470
493
|
}
|
|
471
494
|
|
|
472
495
|
// todo: only system.pallet has metadata, we should add for other pallets and mechanisms as well
|
package/cjs/core/types.js
CHANGED
|
@@ -25,4 +25,5 @@ exports.ActionType = ActionType;
|
|
|
25
25
|
ActionType["SEND_FUND"] = "SEND_FUND";
|
|
26
26
|
ActionType["SEND_NFT"] = "SEND_NFT";
|
|
27
27
|
ActionType["SWAP"] = "SWAP";
|
|
28
|
+
ActionType["MANAGE_SUBSTRATE_PROXY_ACCOUNT"] = "MANAGE_SUBSTRATE_PROXY_ACCOUNT";
|
|
28
29
|
})(ActionType || (exports.ActionType = ActionType = {}));
|
|
@@ -1304,6 +1304,7 @@ class KoniExtension {
|
|
|
1304
1304
|
feeCustom,
|
|
1305
1305
|
feeOption,
|
|
1306
1306
|
from,
|
|
1307
|
+
signerSubstrateProxyAddress,
|
|
1307
1308
|
to,
|
|
1308
1309
|
tokenPayFeeSlug,
|
|
1309
1310
|
tokenSlug,
|
|
@@ -1537,6 +1538,7 @@ class KoniExtension {
|
|
|
1537
1538
|
isTransferAll: isTransferNativeToken ? transferAll : false,
|
|
1538
1539
|
isTransferLocalTokenAndPayThatTokenAsFee,
|
|
1539
1540
|
edAsWarning: isTransferNativeToken,
|
|
1541
|
+
signerSubstrateProxyAddress,
|
|
1540
1542
|
additionalValidator: additionalValidator
|
|
1541
1543
|
});
|
|
1542
1544
|
}
|
|
@@ -1548,6 +1550,7 @@ class KoniExtension {
|
|
|
1548
1550
|
from,
|
|
1549
1551
|
isPassConfirmation,
|
|
1550
1552
|
originNetworkKey,
|
|
1553
|
+
signerSubstrateProxyAddress,
|
|
1551
1554
|
to,
|
|
1552
1555
|
tokenPayFeeSlug,
|
|
1553
1556
|
tokenSlug,
|
|
@@ -1743,7 +1746,8 @@ class KoniExtension {
|
|
|
1743
1746
|
xcmFeeDryRun,
|
|
1744
1747
|
errors,
|
|
1745
1748
|
additionalValidator: additionalValidator,
|
|
1746
|
-
eventsHandler: eventsHandler
|
|
1749
|
+
eventsHandler: eventsHandler,
|
|
1750
|
+
signerSubstrateProxyAddress
|
|
1747
1751
|
});
|
|
1748
1752
|
}
|
|
1749
1753
|
async makeBitcoinDappTransferConfirmation(inputData) {
|
|
@@ -2393,7 +2397,8 @@ class KoniExtension {
|
|
|
2393
2397
|
feeOptions: feeOptions,
|
|
2394
2398
|
feeType,
|
|
2395
2399
|
error,
|
|
2396
|
-
id
|
|
2400
|
+
id,
|
|
2401
|
+
maxTransferableWithoutFee: freeBalance.value
|
|
2397
2402
|
};
|
|
2398
2403
|
};
|
|
2399
2404
|
const subscription = (0, _rxjs.combineLatest)({
|
|
@@ -2480,7 +2485,8 @@ class KoniExtension {
|
|
|
2480
2485
|
const {
|
|
2481
2486
|
params,
|
|
2482
2487
|
recipientAddress,
|
|
2483
|
-
senderAddress
|
|
2488
|
+
senderAddress,
|
|
2489
|
+
signerSubstrateProxyAddress
|
|
2484
2490
|
} = inputData;
|
|
2485
2491
|
const isSendingSelf = (0, _transfer2.isRecipientSelf)(senderAddress, recipientAddress);
|
|
2486
2492
|
|
|
@@ -2501,7 +2507,8 @@ class KoniExtension {
|
|
|
2501
2507
|
isSendingSelf
|
|
2502
2508
|
},
|
|
2503
2509
|
extrinsicType: _KoniTypes.ExtrinsicType.SEND_NFT,
|
|
2504
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
2510
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
2511
|
+
signerSubstrateProxyAddress
|
|
2505
2512
|
});
|
|
2506
2513
|
return {
|
|
2507
2514
|
...rs,
|
|
@@ -3834,7 +3841,8 @@ class KoniExtension {
|
|
|
3834
3841
|
isPassConfirmation,
|
|
3835
3842
|
onSend,
|
|
3836
3843
|
path,
|
|
3837
|
-
processId
|
|
3844
|
+
processId,
|
|
3845
|
+
signerSubstrateProxyAddress
|
|
3838
3846
|
} = inputData;
|
|
3839
3847
|
const {
|
|
3840
3848
|
address
|
|
@@ -3965,6 +3973,7 @@ class KoniExtension {
|
|
|
3965
3973
|
// change this depends on step
|
|
3966
3974
|
chainType,
|
|
3967
3975
|
resolveOnDone: !isLastStep,
|
|
3976
|
+
signerSubstrateProxyAddress,
|
|
3968
3977
|
transferNativeAmount,
|
|
3969
3978
|
balanceType: balanceTypeForPool,
|
|
3970
3979
|
skipFeeValidation: isMintingStep && isPoolSupportAlternativeFee,
|
|
@@ -3977,6 +3986,7 @@ class KoniExtension {
|
|
|
3977
3986
|
async handleYieldLeave(params) {
|
|
3978
3987
|
const {
|
|
3979
3988
|
address,
|
|
3989
|
+
signerSubstrateProxyAddress,
|
|
3980
3990
|
slug
|
|
3981
3991
|
} = params;
|
|
3982
3992
|
const leaveValidation = await this.#koniState.earningService.validateYieldLeave(params);
|
|
@@ -3992,6 +4002,7 @@ class KoniExtension {
|
|
|
3992
4002
|
data: params,
|
|
3993
4003
|
// TODO
|
|
3994
4004
|
extrinsicType,
|
|
4005
|
+
signerSubstrateProxyAddress,
|
|
3995
4006
|
chainType: (handler === null || handler === void 0 ? void 0 : handler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
3996
4007
|
});
|
|
3997
4008
|
}
|
|
@@ -4068,6 +4079,7 @@ class KoniExtension {
|
|
|
4068
4079
|
async yieldSubmitWithdrawal(params) {
|
|
4069
4080
|
const {
|
|
4070
4081
|
address,
|
|
4082
|
+
signerSubstrateProxyAddress,
|
|
4071
4083
|
slug
|
|
4072
4084
|
} = params;
|
|
4073
4085
|
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
@@ -4081,6 +4093,7 @@ class KoniExtension {
|
|
|
4081
4093
|
transaction: extrinsic,
|
|
4082
4094
|
data: params,
|
|
4083
4095
|
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
|
|
4096
|
+
signerSubstrateProxyAddress,
|
|
4084
4097
|
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
4085
4098
|
});
|
|
4086
4099
|
}
|
|
@@ -4088,6 +4101,7 @@ class KoniExtension {
|
|
|
4088
4101
|
const {
|
|
4089
4102
|
address,
|
|
4090
4103
|
selectedUnstaking,
|
|
4104
|
+
signerSubstrateProxyAddress,
|
|
4091
4105
|
slug
|
|
4092
4106
|
} = params;
|
|
4093
4107
|
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
@@ -4102,12 +4116,14 @@ class KoniExtension {
|
|
|
4102
4116
|
transaction: extrinsic,
|
|
4103
4117
|
data: params,
|
|
4104
4118
|
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE,
|
|
4119
|
+
signerSubstrateProxyAddress,
|
|
4105
4120
|
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
4106
4121
|
});
|
|
4107
4122
|
}
|
|
4108
4123
|
async yieldSubmitClaimReward(params) {
|
|
4109
4124
|
const {
|
|
4110
4125
|
address,
|
|
4126
|
+
signerSubstrateProxyAddress,
|
|
4111
4127
|
slug
|
|
4112
4128
|
} = params;
|
|
4113
4129
|
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
@@ -4120,6 +4136,7 @@ class KoniExtension {
|
|
|
4120
4136
|
chain: poolHandler.chain,
|
|
4121
4137
|
transaction: extrinsic,
|
|
4122
4138
|
data: params,
|
|
4139
|
+
signerSubstrateProxyAddress,
|
|
4123
4140
|
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD,
|
|
4124
4141
|
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
4125
4142
|
});
|
|
@@ -4138,6 +4155,7 @@ class KoniExtension {
|
|
|
4138
4155
|
async handleYieldChangeValidator(params) {
|
|
4139
4156
|
const {
|
|
4140
4157
|
address,
|
|
4158
|
+
signerSubstrateProxyAddress,
|
|
4141
4159
|
slug
|
|
4142
4160
|
} = params;
|
|
4143
4161
|
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
@@ -4150,6 +4168,7 @@ class KoniExtension {
|
|
|
4150
4168
|
chain: poolHandler.chain,
|
|
4151
4169
|
transaction: extrinsic,
|
|
4152
4170
|
data: params,
|
|
4171
|
+
signerSubstrateProxyAddress,
|
|
4153
4172
|
extrinsicType: _KoniTypes.ExtrinsicType.CHANGE_EARNING_VALIDATOR,
|
|
4154
4173
|
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4155
4174
|
});
|
|
@@ -4836,6 +4855,48 @@ class KoniExtension {
|
|
|
4836
4855
|
pingSession(request) {
|
|
4837
4856
|
return this.#koniState.keyringService.context.pingSession(request);
|
|
4838
4857
|
}
|
|
4858
|
+
getSubstrateProxyAccountGroup(request) {
|
|
4859
|
+
return this.#koniState.substrateProxyAccountService.getSubstrateProxyAccountGroup(request);
|
|
4860
|
+
}
|
|
4861
|
+
async handleAddSubstrateProxyAccount(params) {
|
|
4862
|
+
const {
|
|
4863
|
+
address,
|
|
4864
|
+
chain,
|
|
4865
|
+
signerSubstrateProxyAddress
|
|
4866
|
+
} = params;
|
|
4867
|
+
const validationErrors = await this.#koniState.substrateProxyAccountService.validateAddSubstrateProxyAccount(params, signerSubstrateProxyAddress);
|
|
4868
|
+
if (validationErrors.length > 0) {
|
|
4869
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(validationErrors);
|
|
4870
|
+
}
|
|
4871
|
+
const extrinsic = await this.#koniState.substrateProxyAccountService.addSubstrateProxyAccounts(params);
|
|
4872
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
4873
|
+
address,
|
|
4874
|
+
chain,
|
|
4875
|
+
transaction: extrinsic,
|
|
4876
|
+
data: params,
|
|
4877
|
+
extrinsicType: _KoniTypes.ExtrinsicType.ADD_SUBSTRATE_PROXY_ACCOUNT,
|
|
4878
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
4879
|
+
signerSubstrateProxyAddress
|
|
4880
|
+
});
|
|
4881
|
+
}
|
|
4882
|
+
async handleRemoveSubstrateProxyAccount(params) {
|
|
4883
|
+
const {
|
|
4884
|
+
address,
|
|
4885
|
+
chain,
|
|
4886
|
+
signerSubstrateProxyAddress
|
|
4887
|
+
} = params;
|
|
4888
|
+
const extrinsic = await this.#koniState.substrateProxyAccountService.removeSubstrateProxyAccounts(params);
|
|
4889
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
4890
|
+
address,
|
|
4891
|
+
chain,
|
|
4892
|
+
transaction: extrinsic,
|
|
4893
|
+
data: params,
|
|
4894
|
+
extrinsicType: _KoniTypes.ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT,
|
|
4895
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
4896
|
+
signerSubstrateProxyAddress
|
|
4897
|
+
});
|
|
4898
|
+
}
|
|
4899
|
+
|
|
4839
4900
|
/* Migrate Unified Account */
|
|
4840
4901
|
|
|
4841
4902
|
/* Open Gov */
|
|
@@ -4848,7 +4909,8 @@ class KoniExtension {
|
|
|
4848
4909
|
transaction: extrinsic,
|
|
4849
4910
|
data: request,
|
|
4850
4911
|
extrinsicType: _KoniTypes.ExtrinsicType.GOV_VOTE,
|
|
4851
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4912
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
4913
|
+
signerSubstrateProxyAddress: request.signerSubstrateProxyAddress
|
|
4852
4914
|
});
|
|
4853
4915
|
}
|
|
4854
4916
|
async handleRemoveVote(request) {
|
|
@@ -4859,7 +4921,8 @@ class KoniExtension {
|
|
|
4859
4921
|
transaction: extrinsic,
|
|
4860
4922
|
data: request,
|
|
4861
4923
|
extrinsicType: _KoniTypes.ExtrinsicType.GOV_UNVOTE,
|
|
4862
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4924
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
4925
|
+
signerSubstrateProxyAddress: request.signerSubstrateProxyAddress
|
|
4863
4926
|
});
|
|
4864
4927
|
}
|
|
4865
4928
|
async handleUnlockVote(request) {
|
|
@@ -4870,7 +4933,8 @@ class KoniExtension {
|
|
|
4870
4933
|
transaction: extrinsic,
|
|
4871
4934
|
data: request,
|
|
4872
4935
|
extrinsicType: _KoniTypes.ExtrinsicType.GOV_UNLOCK_VOTE,
|
|
4873
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
4936
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
4937
|
+
signerSubstrateProxyAddress: request.signerSubstrateProxyAddress
|
|
4874
4938
|
});
|
|
4875
4939
|
}
|
|
4876
4940
|
async subscribeGovLockedInfo(id, port) {
|
|
@@ -5558,6 +5622,15 @@ class KoniExtension {
|
|
|
5558
5622
|
return this.handleUnlockVote(request);
|
|
5559
5623
|
case 'pri(openGov.subscribeGovLockedInfo)':
|
|
5560
5624
|
return this.subscribeGovLockedInfo(id, port);
|
|
5625
|
+
|
|
5626
|
+
// Proxy
|
|
5627
|
+
case 'pri(substrateProxyAccount.getGroupInfo)':
|
|
5628
|
+
return this.getSubstrateProxyAccountGroup(request);
|
|
5629
|
+
case 'pri(substrateProxyAccount.add)':
|
|
5630
|
+
return this.handleAddSubstrateProxyAccount(request);
|
|
5631
|
+
case 'pri(substrateProxyAccount.remove)':
|
|
5632
|
+
return this.handleRemoveSubstrateProxyAccount(request);
|
|
5633
|
+
|
|
5561
5634
|
// Default
|
|
5562
5635
|
default:
|
|
5563
5636
|
throw new Error(`Unable to handle message of type ${type}`);
|
|
@@ -42,6 +42,7 @@ var _helper = require("@subwallet/extension-base/services/request-service/helper
|
|
|
42
42
|
var _SettingService = _interopRequireDefault(require("@subwallet/extension-base/services/setting-service/SettingService"));
|
|
43
43
|
var _DatabaseService = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/DatabaseService"));
|
|
44
44
|
var _subscanService = require("@subwallet/extension-base/services/subscan-service");
|
|
45
|
+
var _substrateProxyService = _interopRequireDefault(require("@subwallet/extension-base/services/substrate-proxy-service"));
|
|
45
46
|
var _swapService = require("@subwallet/extension-base/services/swap-service");
|
|
46
47
|
var _transactionService = _interopRequireDefault(require("@subwallet/extension-base/services/transaction-service"));
|
|
47
48
|
var _walletConnectService = _interopRequireDefault(require("@subwallet/extension-base/services/wallet-connect-service"));
|
|
@@ -132,6 +133,7 @@ class KoniState {
|
|
|
132
133
|
this.inappNotificationService = new _inappNotificationService.InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
|
|
133
134
|
this.chainOnlineService = new _chainOnlineService.ChainOnlineService(this.chainService, this.settingService, this.eventService, this.dbService);
|
|
134
135
|
this.openGovService = new _openGov.default(this);
|
|
136
|
+
this.substrateProxyAccountService = new _substrateProxyService.default(this);
|
|
135
137
|
this.subscription = new _subscription.KoniSubscription(this, this.dbService);
|
|
136
138
|
this.cron = new _cron.KoniCron(this, this.subscription, this.dbService);
|
|
137
139
|
this.logger = (0, _util.logger)('State');
|
package/cjs/packageInfo.js
CHANGED
|
@@ -437,16 +437,27 @@ const subscribeAssetsAccountPallet = async _ref7 => {
|
|
|
437
437
|
}
|
|
438
438
|
});
|
|
439
439
|
const unsubList = await Promise.all(Object.values(tokenMap).map(tokenInfo => {
|
|
440
|
+
if (tokenInfo.slug === 'energy_web_x-LOCAL-stEWT') {
|
|
441
|
+
return (0, _rxjs.timer)(0, _constants.CRON_REFRESH_PRICE_INTERVAL).subscribe(() => {
|
|
442
|
+
const getEwtFrozenBalance = async () => {
|
|
443
|
+
const ewtTokenBalances = await queryEwtFrozenBalance(substrateApi, addresses, assetMap[tokenInfo.slug], extrinsicType);
|
|
444
|
+
callback(ewtTokenBalances);
|
|
445
|
+
};
|
|
446
|
+
getEwtFrozenBalance().catch(console.error);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
440
449
|
try {
|
|
441
450
|
const assetIndex = (0, _utils2._getTokenOnChainAssetId)(tokenInfo);
|
|
442
|
-
if (assetIndex === '-1') {
|
|
451
|
+
if (assetIndex === '-1' && !_constants2.USE_MULTILOCATION_INDEX.includes(chainInfo.slug)) {
|
|
443
452
|
return undefined;
|
|
444
453
|
}
|
|
454
|
+
const version = ['statemint', 'statemine', 'westend_assethub'].includes(chainInfo.slug) ? 4 : 3;
|
|
455
|
+
const index = _constants2.USE_MULTILOCATION_INDEX.includes(chainInfo.slug) ? (0, _xcmParser._adaptX1Interior)((0, _utils2._getXcmAssetMultilocation)(tokenInfo), version) : assetIndex;
|
|
445
456
|
const params = [{
|
|
446
457
|
section: 'query',
|
|
447
458
|
module: assetsAccountKey.split('_')[1],
|
|
448
459
|
method: assetsAccountKey.split('_')[2],
|
|
449
|
-
args: addresses.map(address => [
|
|
460
|
+
args: addresses.map(address => [index, address])
|
|
450
461
|
}];
|
|
451
462
|
|
|
452
463
|
// Get Token Balance
|
|
@@ -610,4 +621,37 @@ async function queryGigaTokenBalance(substrateApi, addresses, tokenInfo, extrins
|
|
|
610
621
|
locked: totalLockedFromTransfer.toString()
|
|
611
622
|
};
|
|
612
623
|
}));
|
|
624
|
+
}
|
|
625
|
+
async function queryEwtFrozenBalance(substrateApi, addresses, tokenInfo, extrinsicType) {
|
|
626
|
+
const multilocation = (0, _utils2._getXcmAssetMultilocation)(tokenInfo);
|
|
627
|
+
return await Promise.all(addresses.map(async address => {
|
|
628
|
+
const [_frozenBalance, _balanceInfo] = await Promise.all([substrateApi.api.query.assetsFreezer.frozenBalances(multilocation, address), substrateApi.api.query.assets.account(multilocation, address)]);
|
|
629
|
+
const balanceInfo = _balanceInfo.toPrimitive();
|
|
630
|
+
if (!balanceInfo) {
|
|
631
|
+
// no balance info response
|
|
632
|
+
return {
|
|
633
|
+
address: address,
|
|
634
|
+
tokenSlug: tokenInfo.slug,
|
|
635
|
+
free: '0',
|
|
636
|
+
locked: '0',
|
|
637
|
+
state: _KoniTypes.APIItemState.READY
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
const transferableBalance = (0, _assetsPallet._getAssetsPalletTransferable)(balanceInfo, (0, _utils2._getAssetExistentialDeposit)(tokenInfo), extrinsicType);
|
|
641
|
+
const totalLockedFromTransfer = (0, _assetsPallet._getAssetsPalletLocked)(balanceInfo);
|
|
642
|
+
let freeBalance = transferableBalance;
|
|
643
|
+
let lockedBalance = totalLockedFromTransfer;
|
|
644
|
+
const frozenBalance = _frozenBalance.toPrimitive();
|
|
645
|
+
if (frozenBalance) {
|
|
646
|
+
freeBalance = transferableBalance - BigInt(frozenBalance);
|
|
647
|
+
lockedBalance = totalLockedFromTransfer + BigInt(frozenBalance);
|
|
648
|
+
}
|
|
649
|
+
return {
|
|
650
|
+
address: address,
|
|
651
|
+
tokenSlug: tokenInfo.slug,
|
|
652
|
+
free: freeBalance.toString(),
|
|
653
|
+
locked: lockedBalance.toString(),
|
|
654
|
+
state: _KoniTypes.APIItemState.READY
|
|
655
|
+
};
|
|
656
|
+
}));
|
|
613
657
|
}
|
|
@@ -4,9 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getTransferMockTxFee = exports.
|
|
7
|
+
exports.getTransferMockTxFee = exports.createSubstrateExtrinsic = void 0;
|
|
8
8
|
var _api = require("@gear-js/api");
|
|
9
9
|
var _types = require("@subwallet/chain-list/types");
|
|
10
|
+
var _xcmParser = require("@subwallet/extension-base/core/substrate/xcm-parser");
|
|
10
11
|
var _wasm = require("@subwallet/extension-base/koni/api/contract-handler/wasm");
|
|
11
12
|
var _utils = require("@subwallet/extension-base/koni/api/contract-handler/wasm/utils");
|
|
12
13
|
var _utils2 = require("@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils");
|
|
@@ -24,7 +25,7 @@ var _utilCrypto = require("@polkadot/util-crypto");
|
|
|
24
25
|
// SPDX-License-Identifier: Apache-2.0
|
|
25
26
|
|
|
26
27
|
const createSubstrateExtrinsic = async _ref => {
|
|
27
|
-
var _tokenInfo$metadata
|
|
28
|
+
var _tokenInfo$metadata;
|
|
28
29
|
let {
|
|
29
30
|
from,
|
|
30
31
|
networkKey,
|
|
@@ -102,7 +103,15 @@ const createSubstrateExtrinsic = async _ref => {
|
|
|
102
103
|
} else if (_constants._TRANSFER_CHAIN_GROUP.bitcountry.includes(networkKey) && !(0, _utils3._isNativeToken)(tokenInfo)) {
|
|
103
104
|
transfer = api.tx.currencies.transfer(to, (0, _utils3._getTokenOnChainInfo)(tokenInfo), value);
|
|
104
105
|
} else if (_constants._TRANSFER_CHAIN_GROUP.statemine.includes(networkKey) && !(0, _utils3._isNativeToken)(tokenInfo)) {
|
|
105
|
-
|
|
106
|
+
if (_constants.USE_MULTILOCATION_INDEX.includes(networkKey)) {
|
|
107
|
+
const version = ['statemint', 'statemine', 'westend_assethub'].includes(networkKey) ? 4 : 3;
|
|
108
|
+
const multilocationIndex = (0, _xcmParser._adaptX1Interior)((0, _utils3._getXcmAssetMultilocation)(tokenInfo), version);
|
|
109
|
+
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
transfer = api.tx.assets.transfer(multilocationIndex, to, value);
|
|
112
|
+
} else {
|
|
113
|
+
transfer = api.tx.assets.transfer((0, _utils3._getTokenOnChainAssetId)(tokenInfo), to, value);
|
|
114
|
+
}
|
|
106
115
|
} else if (_constants._TRANSFER_CHAIN_GROUP.sora_substrate.includes(networkKey) && isTxAssetsSupported) {
|
|
107
116
|
transfer = api.tx.assets.transfer((0, _utils3._getTokenOnChainAssetId)(tokenInfo), to, value);
|
|
108
117
|
} else if (isTxBalancesSupported && (0, _utils3._isNativeToken)(tokenInfo)) {
|
|
@@ -120,18 +129,6 @@ const createSubstrateExtrinsic = async _ref => {
|
|
|
120
129
|
}
|
|
121
130
|
} else if (_constants._TRANSFER_CHAIN_GROUP.truth.includes(networkKey)) {
|
|
122
131
|
transfer = api.tx.assetManager.transfer(to, (0, _utils3._getTokenOnChainInfo)(tokenInfo), value);
|
|
123
|
-
} else if (_constants._TRANSFER_CHAIN_GROUP.bittensor.includes(networkKey) && (_tokenInfo$metadata2 = tokenInfo.metadata) !== null && _tokenInfo$metadata2 !== void 0 && _tokenInfo$metadata2.netuid) {
|
|
124
|
-
var _tokenInfo$metadata3;
|
|
125
|
-
const {
|
|
126
|
-
accountHotKey,
|
|
127
|
-
isEnableTransferSubnet
|
|
128
|
-
} = await getAccountNetuidTokenInfo(from, tokenInfo, substrateApi);
|
|
129
|
-
const tokenNetuid = (_tokenInfo$metadata3 = tokenInfo.metadata) === null || _tokenInfo$metadata3 === void 0 ? void 0 : _tokenInfo$metadata3.netuid;
|
|
130
|
-
if (isEnableTransferSubnet && accountHotKey) {
|
|
131
|
-
transfer = api.tx.subtensorModule.transferStake(from, accountHotKey, tokenNetuid, tokenNetuid, value);
|
|
132
|
-
} else {
|
|
133
|
-
return [null, value];
|
|
134
|
-
}
|
|
135
132
|
}
|
|
136
133
|
return [transfer, transferAmount || value];
|
|
137
134
|
};
|
|
@@ -190,23 +187,4 @@ const getTransferMockTxFee = async (address, chainInfo, tokenInfo, api) => {
|
|
|
190
187
|
return new _bignumber.default(0);
|
|
191
188
|
}
|
|
192
189
|
};
|
|
193
|
-
exports.getTransferMockTxFee = getTransferMockTxFee;
|
|
194
|
-
const getAccountNetuidTokenInfo = async (address, tokenInfo, substrateApi) => {
|
|
195
|
-
var _tokenInfo$metadata4;
|
|
196
|
-
const tokenNetuid = (_tokenInfo$metadata4 = tokenInfo.metadata) === null || _tokenInfo$metadata4 === void 0 ? void 0 : _tokenInfo$metadata4.netuid;
|
|
197
|
-
if (!tokenNetuid) {
|
|
198
|
-
return {
|
|
199
|
-
isEnableTransferSubnet: false,
|
|
200
|
-
accountHotKey: undefined
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
const [isTransferToggle, rawStakeInfoForColdKey] = await Promise.all([substrateApi.api.query.subtensorModule.transferToggle(tokenNetuid), substrateApi.api.call.stakeInfoRuntimeApi.getStakeInfoForColdkey(address)]);
|
|
204
|
-
const isEnableTransferSubnet = isTransferToggle.toPrimitive();
|
|
205
|
-
const taoStakeInfos = rawStakeInfoForColdKey.toPrimitive();
|
|
206
|
-
const accountHotKey = taoStakeInfos.find(value => value.netuid === tokenNetuid);
|
|
207
|
-
return {
|
|
208
|
-
isEnableTransferSubnet,
|
|
209
|
-
accountHotKey: accountHotKey === null || accountHotKey === void 0 ? void 0 : accountHotKey.hotkey
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
exports.getAccountNetuidTokenInfo = getAccountNetuidTokenInfo;
|
|
190
|
+
exports.getTransferMockTxFee = getTransferMockTxFee;
|
|
@@ -119,8 +119,6 @@ const dryRunXcmExtrinsicV2 = async function (request) {
|
|
|
119
119
|
const originDryRunRs = dryRunResult.origin;
|
|
120
120
|
if (originDryRunRs.success) {
|
|
121
121
|
const {
|
|
122
|
-
assetHub,
|
|
123
|
-
bridgeHub,
|
|
124
122
|
destination,
|
|
125
123
|
hops
|
|
126
124
|
} = dryRunResult;
|
|
@@ -129,12 +127,9 @@ const dryRunXcmExtrinsicV2 = async function (request) {
|
|
|
129
127
|
return false;
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
|
-
if ((
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return (0, _utils.isChainNotSupportDryRun)(destination.failureReason) || (0, _utils.isChainNotSupportPolkadotApi)(destination.failureReason);
|
|
136
|
-
}
|
|
137
|
-
return false;
|
|
130
|
+
if ((destination === null || destination === void 0 ? void 0 : destination.success) === false) {
|
|
131
|
+
// pass dry-run in these cases
|
|
132
|
+
return (0, _utils.isChainNotSupportDryRun)(destination.failureReason) || (0, _utils.isChainNotSupportPolkadotApi)(destination.failureReason);
|
|
138
133
|
}
|
|
139
134
|
return true;
|
|
140
135
|
}
|
|
@@ -18,7 +18,7 @@ var _util = require("@polkadot/util");
|
|
|
18
18
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
19
19
|
// SPDX-License-Identifier: Apache-2.0
|
|
20
20
|
|
|
21
|
-
const version = '/
|
|
21
|
+
const version = '/v5';
|
|
22
22
|
const paraSpellApi = {
|
|
23
23
|
buildXcm: `${version}/x-transfer`,
|
|
24
24
|
feeXcm: `${version}/xcm-fee`,
|