@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.
Files changed (74) hide show
  1. package/background/KoniTypes.d.ts +13 -2
  2. package/background/KoniTypes.js +3 -1
  3. package/cjs/background/KoniTypes.js +3 -1
  4. package/cjs/core/logic-validation/recipientAddress.js +1 -1
  5. package/cjs/core/logic-validation/transfer.js +33 -10
  6. package/cjs/core/types.js +1 -0
  7. package/cjs/koni/background/handlers/Extension.js +81 -8
  8. package/cjs/koni/background/handlers/State.js +2 -0
  9. package/cjs/packageInfo.js +1 -1
  10. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +46 -2
  11. package/cjs/services/balance-service/transfer/token.js +13 -35
  12. package/cjs/services/balance-service/transfer/xcm/index.js +3 -8
  13. package/cjs/services/balance-service/transfer/xcm/utils.js +1 -1
  14. package/cjs/services/chain-service/constants.js +6 -5
  15. package/cjs/services/chain-service/index.js +1 -0
  16. package/cjs/services/chain-service/utils/patch.js +1 -1
  17. package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +55 -0
  18. package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +41 -0
  19. package/cjs/services/migration-service/scripts/index.js +17 -13
  20. package/cjs/services/substrate-proxy-service/constant.js +26 -0
  21. package/cjs/services/substrate-proxy-service/index.js +170 -0
  22. package/cjs/services/transaction-service/index.js +78 -10
  23. package/cjs/services/transaction-service/utils.js +8 -5
  24. package/cjs/types/index.js +11 -0
  25. package/cjs/types/substrateProxyAccount/actions/index.js +1 -0
  26. package/cjs/types/substrateProxyAccount/index.js +16 -0
  27. package/cjs/utils/account/transform.js +5 -4
  28. package/cjs/utils/fee/transfer.js +4 -2
  29. package/core/logic-validation/recipientAddress.js +1 -1
  30. package/core/logic-validation/transfer.d.ts +3 -3
  31. package/core/logic-validation/transfer.js +34 -11
  32. package/core/types.d.ts +2 -1
  33. package/core/types.js +1 -0
  34. package/koni/background/handlers/Extension.d.ts +3 -0
  35. package/koni/background/handlers/Extension.js +81 -8
  36. package/koni/background/handlers/State.d.ts +2 -0
  37. package/koni/background/handlers/State.js +2 -0
  38. package/package.json +36 -6
  39. package/packageInfo.js +1 -1
  40. package/services/balance-service/helpers/subscribe/substrate/index.js +47 -3
  41. package/services/balance-service/transfer/token.d.ts +0 -4
  42. package/services/balance-service/transfer/token.js +12 -33
  43. package/services/balance-service/transfer/xcm/index.js +3 -8
  44. package/services/balance-service/transfer/xcm/utils.d.ts +0 -2
  45. package/services/balance-service/transfer/xcm/utils.js +1 -1
  46. package/services/chain-service/constants.d.ts +1 -1
  47. package/services/chain-service/constants.js +4 -4
  48. package/services/chain-service/index.js +1 -0
  49. package/services/chain-service/utils/patch.d.ts +1 -1
  50. package/services/chain-service/utils/patch.js +1 -1
  51. package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.d.ts +4 -0
  52. package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +46 -0
  53. package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.d.ts +4 -0
  54. package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +33 -0
  55. package/services/migration-service/scripts/index.js +8 -4
  56. package/services/open-gov/interface.d.ts +4 -3
  57. package/services/substrate-proxy-service/constant.d.ts +3 -0
  58. package/services/substrate-proxy-service/constant.js +19 -0
  59. package/services/substrate-proxy-service/index.d.ts +13 -0
  60. package/services/substrate-proxy-service/index.js +159 -0
  61. package/services/transaction-service/index.js +79 -11
  62. package/services/transaction-service/types.d.ts +2 -2
  63. package/services/transaction-service/utils.js +8 -5
  64. package/types/balance/transfer.d.ts +1 -0
  65. package/types/index.d.ts +1 -0
  66. package/types/index.js +1 -0
  67. package/types/substrateProxyAccount/actions/index.d.ts +17 -0
  68. package/types/substrateProxyAccount/actions/index.js +1 -0
  69. package/types/substrateProxyAccount/index.d.ts +23 -0
  70. package/types/substrateProxyAccount/index.js +8 -0
  71. package/types/transaction/request.d.ts +1 -0
  72. package/types/yield/actions/join/submit.d.ts +1 -1
  73. package/utils/account/transform.js +5 -4
  74. package/utils/fee/transfer.js +4 -2
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _actions = require("./actions");
7
+ Object.keys(_actions).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _actions[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _actions[key];
14
+ }
15
+ });
16
+ });
@@ -168,14 +168,15 @@ const EARN_VMANTA_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_VMANTA, _KoniTypes.Ex
168
168
  const EVM_ACTIONS = [_KoniTypes.ExtrinsicType.TOKEN_SPENDING_APPROVAL, _KoniTypes.ExtrinsicType.EVM_EXECUTE];
169
169
  const CLAIM_AVAIL_BRIDGE = [_KoniTypes.ExtrinsicType.CLAIM_BRIDGE];
170
170
  const OPEN_GOV_ACTIONS = [_KoniTypes.ExtrinsicType.GOV_VOTE, _KoniTypes.ExtrinsicType.GOV_UNVOTE, _KoniTypes.ExtrinsicType.GOV_UNLOCK_VOTE];
171
+ const SUBSTRATE_PROXY_ACTION = [_KoniTypes.ExtrinsicType.ADD_SUBSTRATE_PROXY_ACCOUNT, _KoniTypes.ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT];
171
172
  const OTHER_ACTIONS = [_KoniTypes.ExtrinsicType.TRANSFER_XCM, _KoniTypes.ExtrinsicType.SEND_NFT, _KoniTypes.ExtrinsicType.SWAP, _KoniTypes.ExtrinsicType.CROWDLOAN];
172
173
  const getAccountTransactionActions = (signMode, networkType, type, _meta, _specialNetwork) => {
173
174
  if ([_types2.AccountSignMode.PASSWORD, _types2.AccountSignMode.INJECTED].includes(signMode)) {
174
175
  switch (networkType) {
175
176
  case _types2.AccountChainType.SUBSTRATE:
176
- return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
177
+ return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OPEN_GOV_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
177
178
  case _types2.AccountChainType.ETHEREUM:
178
- return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...EVM_ACTIONS];
179
+ return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...SUBSTRATE_PROXY_ACTION, ...EVM_ACTIONS];
179
180
  case _types2.AccountChainType.TON:
180
181
  return [...BASE_TRANSFER_ACTIONS];
181
182
  case _types2.AccountChainType.CARDANO:
@@ -186,7 +187,7 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
186
187
  } else if (signMode === _types2.AccountSignMode.QR) {
187
188
  switch (networkType) {
188
189
  case _types2.AccountChainType.SUBSTRATE:
189
- return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
190
+ return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OPEN_GOV_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
190
191
  case _types2.AccountChainType.ETHEREUM:
191
192
  return [...(_constants.isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
192
193
  case _types2.AccountChainType.TON:
@@ -201,7 +202,7 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
201
202
  case _types2.AccountChainType.SUBSTRATE:
202
203
  return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS,
203
204
  // ...EARN_QDOT_ACTIONS,
204
- ...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
205
+ ...OPEN_GOV_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
205
206
  case _types2.AccountChainType.ETHEREUM:
206
207
  return [...BASE_TRANSFER_ACTIONS, ...EARN_STDOT_ACTIONS, ...EVM_ACTIONS, ...CLAIM_AVAIL_BRIDGE, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
207
208
  // For liquid staking
@@ -329,7 +329,8 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
329
329
  feeType: feeChainType,
330
330
  id: id,
331
331
  error,
332
- isEvmRpcError: isEvmRpcError
332
+ isEvmRpcError: isEvmRpcError,
333
+ maxTransferableWithoutFee: freeBalance.value
333
334
  };
334
335
  };
335
336
  exports.calculateTransferMaxTransferable = calculateTransferMaxTransferable;
@@ -521,7 +522,8 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
521
522
  feeOptions: feeOptions,
522
523
  feeType: feeChainType,
523
524
  id: id,
524
- error
525
+ error,
526
+ maxTransferableWithoutFee: freeBalance.value
525
527
  };
526
528
  };
527
529
  exports.calculateXcmMaxTransferable = calculateXcmMaxTransferable;
@@ -17,7 +17,7 @@ function getConditions(validateRecipientParams) {
17
17
  toAddress
18
18
  } = validateRecipientParams;
19
19
  const conditions = [];
20
- const isSendAction = [ActionType.SEND_FUND, ActionType.SEND_NFT].includes(actionType);
20
+ const isSendAction = [ActionType.SEND_FUND, ActionType.SEND_NFT, ActionType.MANAGE_SUBSTRATE_PROXY_ACCOUNT].includes(actionType);
21
21
  conditions.push(ValidationCondition.IS_NOT_NULL);
22
22
  conditions.push(ValidationCondition.IS_ADDRESS);
23
23
  conditions.push(ValidationCondition.IS_VALID_ADDRESS_FOR_ECOSYSTEM);
@@ -13,8 +13,8 @@ export declare function validateXcmTransferRequest(destTokenInfo: _ChainAsset |
13
13
  export declare function checkSupportForFeature(validationResponse: SWTransactionResponse, blockedFeaturesList: string[], chainInfo: _ChainInfo): void;
14
14
  export declare function checkSupportForAction(validationResponse: SWTransactionResponse, blockedActionsMap: Record<ExtrinsicType, string[]>): void;
15
15
  export declare function checkSupportForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction): void;
16
- export declare function estimateFeeForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction, chainInfo: _ChainInfo, evmApi: _EvmApi, substrateApi: _SubstrateApi, priceMap: Record<string, number>, feeInfo: FeeInfo, nativeTokenInfo: _ChainAsset, nonNativeTokenPayFeeInfo: _ChainAsset | undefined, isTransferLocalTokenAndPayThatTokenAsFee: boolean | undefined): Promise<FeeData>;
17
- export declare function checkSigningAccountForTransaction(validationResponse: SWTransactionResponse, chainInfoMap: Record<string, _ChainInfo>): void;
18
- export declare function checkBalanceWithTransactionFee(validationResponse: SWTransactionResponse, transactionInput: SWTransactionInput, nativeTokenInfo: _ChainAsset, nativeTokenAvailable: AmountData): void;
16
+ export declare function estimateFeeForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction, chainInfo: _ChainInfo, evmApi: _EvmApi, substrateApi: _SubstrateApi, priceMap: Record<string, number>, feeInfo: FeeInfo, nativeTokenInfo: _ChainAsset, nonNativeTokenPayFeeInfo: _ChainAsset | undefined, isTransferLocalTokenAndPayThatTokenAsFee: boolean | undefined, signerSubstrateProxyAddress?: string): Promise<FeeData>;
17
+ export declare function checkSigningAccountForTransaction(validationResponse: SWTransactionResponse, chainInfoMap: Record<string, _ChainInfo>, signer: string): void;
18
+ export declare function checkBalanceWithTransactionFee(validationResponse: SWTransactionResponse, transactionInput: SWTransactionInput, nativeTokenInfo: _ChainAsset, nativeTokenAvailable: AmountData, substrateProxyAccountNativeTokenAvailable?: AmountData): void;
19
19
  export declare function checkTonAddressBounceableAndAccountNotActive(tonApi: _TonApi, validationResponse: SWTransactionResponse): Promise<void>;
20
20
  export declare function validateXcmMinAmountToMythos(destChain: string, destToken: string, amount: string): TransactionError | undefined;
@@ -13,7 +13,7 @@ import { _getAssetDecimals, _getAssetPriceId, _getAssetSymbol, _getChainNativeTo
13
13
  import { calculateToAmountByReservePool, FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE } from '@subwallet/extension-base/services/fee-service/utils';
14
14
  import { isBitcoinTransaction, isCardanoTransaction, isSubstrateTransaction, isTonTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
15
15
  import { AccountSignMode, BasicTxErrorType, BasicTxWarningCode, TransferTxErrorType } from '@subwallet/extension-base/types';
16
- import { balanceFormatter, combineBitcoinFee, combineEthFee, formatNumber, getSizeInfo, pairToAccount } from '@subwallet/extension-base/utils';
16
+ import { balanceFormatter, combineBitcoinFee, combineEthFee, formatNumber, getAccountJsonByAddress, getSizeInfo, isSameAddress, pairToAccount } from '@subwallet/extension-base/utils';
17
17
  import { isCardanoAddress, isTonAddress } from '@subwallet/keyring';
18
18
  import { keyring } from '@subwallet/ui-keyring';
19
19
  import BigN from 'bignumber.js';
@@ -310,7 +310,7 @@ export function checkSupportForTransaction(validationResponse, transaction) {
310
310
  }
311
311
  }
312
312
  }
313
- export async function estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, isTransferLocalTokenAndPayThatTokenAsFee) {
313
+ export async function estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, isTransferLocalTokenAndPayThatTokenAsFee, signerSubstrateProxyAddress) {
314
314
  const estimateFee = {
315
315
  symbol: '',
316
316
  decimals: 0,
@@ -331,8 +331,14 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
331
331
  if (transaction) {
332
332
  try {
333
333
  if (isSubstrateTransaction(transaction)) {
334
- var _validationResponse$x;
335
- estimateFee.value = (_validationResponse$x = validationResponse.xcmFeeDryRun) !== null && _validationResponse$x !== void 0 ? _validationResponse$x : (await transaction.paymentInfo(validationResponse.address)).partialFee.toString();
334
+ if (signerSubstrateProxyAddress && !isSameAddress(signerSubstrateProxyAddress, address)) {
335
+ await substrateApi.isReady;
336
+ const estimateExtrinsic = substrateApi.api.tx.proxy.proxy(address, null, transaction);
337
+ estimateFee.value = (await estimateExtrinsic.paymentInfo(signerSubstrateProxyAddress)).partialFee.toString();
338
+ } else {
339
+ var _validationResponse$x;
340
+ estimateFee.value = (_validationResponse$x = validationResponse.xcmFeeDryRun) !== null && _validationResponse$x !== void 0 ? _validationResponse$x : (await transaction.paymentInfo(validationResponse.address)).partialFee.toString();
341
+ }
336
342
  } else if (isTonTransaction(transaction)) {
337
343
  estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
338
344
  } else if (isCardanoTransaction(transaction)) {
@@ -399,14 +405,13 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
399
405
  }
400
406
  return estimateFee;
401
407
  }
402
- export function checkSigningAccountForTransaction(validationResponse, chainInfoMap) {
408
+ export function checkSigningAccountForTransaction(validationResponse, chainInfoMap, signer) {
403
409
  const {
404
- address,
405
410
  chain,
406
411
  chainType,
407
412
  extrinsicType
408
413
  } = validationResponse;
409
- const pair = keyring.getPair(address);
414
+ const pair = keyring.getPair(signer);
410
415
  if (!pair) {
411
416
  validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, t('bg.TRANSACTION.core.validation.transfer.unableToFindAccount')));
412
417
  } else {
@@ -426,7 +431,7 @@ export function checkSigningAccountForTransaction(validationResponse, chainInfoM
426
431
  }
427
432
  }
428
433
  }
429
- export function checkBalanceWithTransactionFee(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable) {
434
+ export function checkBalanceWithTransactionFee(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable, substrateProxyAccountNativeTokenAvailable) {
430
435
  if (!validationResponse.estimateFee) {
431
436
  // todo: estimateFee should be must-have, need to refactor interface
432
437
  return;
@@ -435,6 +440,7 @@ export function checkBalanceWithTransactionFee(validationResponse, transactionIn
435
440
  edAsWarning,
436
441
  extrinsicType,
437
442
  isTransferAll,
443
+ signerSubstrateProxyAddress,
438
444
  skipFeeValidation,
439
445
  tokenPayFeeSlug
440
446
  } = transactionInput;
@@ -445,12 +451,29 @@ export function checkBalanceWithTransactionFee(validationResponse, transactionIn
445
451
  const bnFee = new BigN(validationResponse.estimateFee.value);
446
452
  const bnNativeTokenAvailable = new BigN(nativeTokenAvailable.value);
447
453
  const bnNativeTokenTransferAmount = new BigN(validationResponse.transferNativeAmount || '0');
448
- if (!bnNativeTokenAvailable.gt(0)) {
454
+ if (!bnNativeTokenAvailable.gt(0) && !substrateProxyAccountNativeTokenAvailable) {
449
455
  validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
450
456
  }
451
457
  const isChainNotSupportTransferAll = [..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.genshiro, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.statemine].includes(nativeTokenInfo.originChain);
452
- if (bnNativeTokenTransferAmount.plus(bnFee).gt(bnNativeTokenAvailable) && (!isTransferAll || isChainNotSupportTransferAll)) {
453
- validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE)); // todo: should be generalized and reused in all features
458
+ if (!substrateProxyAccountNativeTokenAvailable) {
459
+ if (bnNativeTokenTransferAmount.plus(bnFee).gt(bnNativeTokenAvailable) && (!isTransferAll || isChainNotSupportTransferAll)) {
460
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE)); // todo: should be generalized and reused in all features
461
+ }
462
+ } else {
463
+ const bnSubstrateProxyAccountNativeTokenAvailable = new BigN(substrateProxyAccountNativeTokenAvailable.value);
464
+ if (bnNativeTokenTransferAmount.gt(bnNativeTokenAvailable) && (!isTransferAll || isChainNotSupportTransferAll) || bnFee.gt(bnSubstrateProxyAccountNativeTokenAvailable)) {
465
+ if (signerSubstrateProxyAddress) {
466
+ const account = getAccountJsonByAddress(signerSubstrateProxyAddress);
467
+ const accountName = account === null || account === void 0 ? void 0 : account.name;
468
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE, t('bg.TRANSACTION.core.validation.transfer.proxyAccountNotEnoughBalance', {
469
+ replace: {
470
+ accountName: accountName || signerSubstrateProxyAddress
471
+ }
472
+ })));
473
+ } else {
474
+ validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
475
+ }
476
+ }
454
477
  }
455
478
 
456
479
  // todo: only system.pallet has metadata, we should add for other pallets and mechanisms as well
package/core/types.d.ts CHANGED
@@ -15,7 +15,8 @@ export declare enum ValidationCondition {
15
15
  export declare enum ActionType {
16
16
  SEND_FUND = "SEND_FUND",
17
17
  SEND_NFT = "SEND_NFT",
18
- SWAP = "SWAP"
18
+ SWAP = "SWAP",
19
+ MANAGE_SUBSTRATE_PROXY_ACCOUNT = "MANAGE_SUBSTRATE_PROXY_ACCOUNT"
19
20
  }
20
21
  export interface ValidateRecipientParams {
21
22
  srcChain: string;
package/core/types.js CHANGED
@@ -18,4 +18,5 @@ export let ActionType;
18
18
  ActionType["SEND_FUND"] = "SEND_FUND";
19
19
  ActionType["SEND_NFT"] = "SEND_NFT";
20
20
  ActionType["SWAP"] = "SWAP";
21
+ ActionType["MANAGE_SUBSTRATE_PROXY_ACCOUNT"] = "MANAGE_SUBSTRATE_PROXY_ACCOUNT";
21
22
  })(ActionType || (ActionType = {}));
@@ -291,6 +291,9 @@ export default class KoniExtension {
291
291
  private migrateUnifiedAndFetchEligibleSoloAccounts;
292
292
  private migrateSoloAccount;
293
293
  private pingSession;
294
+ private getSubstrateProxyAccountGroup;
295
+ private handleAddSubstrateProxyAccount;
296
+ private handleRemoveSubstrateProxyAccount;
294
297
  private handleVote;
295
298
  private handleRemoveVote;
296
299
  private handleUnlockVote;
@@ -1255,6 +1255,7 @@ export default class KoniExtension {
1255
1255
  feeCustom,
1256
1256
  feeOption,
1257
1257
  from,
1258
+ signerSubstrateProxyAddress,
1258
1259
  to,
1259
1260
  tokenPayFeeSlug,
1260
1261
  tokenSlug,
@@ -1488,6 +1489,7 @@ export default class KoniExtension {
1488
1489
  isTransferAll: isTransferNativeToken ? transferAll : false,
1489
1490
  isTransferLocalTokenAndPayThatTokenAsFee,
1490
1491
  edAsWarning: isTransferNativeToken,
1492
+ signerSubstrateProxyAddress,
1491
1493
  additionalValidator: additionalValidator
1492
1494
  });
1493
1495
  }
@@ -1499,6 +1501,7 @@ export default class KoniExtension {
1499
1501
  from,
1500
1502
  isPassConfirmation,
1501
1503
  originNetworkKey,
1504
+ signerSubstrateProxyAddress,
1502
1505
  to,
1503
1506
  tokenPayFeeSlug,
1504
1507
  tokenSlug,
@@ -1694,7 +1697,8 @@ export default class KoniExtension {
1694
1697
  xcmFeeDryRun,
1695
1698
  errors,
1696
1699
  additionalValidator: additionalValidator,
1697
- eventsHandler: eventsHandler
1700
+ eventsHandler: eventsHandler,
1701
+ signerSubstrateProxyAddress
1698
1702
  });
1699
1703
  }
1700
1704
  async makeBitcoinDappTransferConfirmation(inputData) {
@@ -2334,7 +2338,8 @@ export default class KoniExtension {
2334
2338
  feeOptions: feeOptions,
2335
2339
  feeType,
2336
2340
  error,
2337
- id
2341
+ id,
2342
+ maxTransferableWithoutFee: freeBalance.value
2338
2343
  };
2339
2344
  };
2340
2345
  const subscription = combineLatest({
@@ -2418,7 +2423,8 @@ export default class KoniExtension {
2418
2423
  const {
2419
2424
  params,
2420
2425
  recipientAddress,
2421
- senderAddress
2426
+ senderAddress,
2427
+ signerSubstrateProxyAddress
2422
2428
  } = inputData;
2423
2429
  const isSendingSelf = isRecipientSelf(senderAddress, recipientAddress);
2424
2430
 
@@ -2439,7 +2445,8 @@ export default class KoniExtension {
2439
2445
  isSendingSelf
2440
2446
  },
2441
2447
  extrinsicType: ExtrinsicType.SEND_NFT,
2442
- chainType: ChainType.SUBSTRATE
2448
+ chainType: ChainType.SUBSTRATE,
2449
+ signerSubstrateProxyAddress
2443
2450
  });
2444
2451
  return {
2445
2452
  ...rs,
@@ -3742,7 +3749,8 @@ export default class KoniExtension {
3742
3749
  isPassConfirmation,
3743
3750
  onSend,
3744
3751
  path,
3745
- processId
3752
+ processId,
3753
+ signerSubstrateProxyAddress
3746
3754
  } = inputData;
3747
3755
  const {
3748
3756
  address
@@ -3873,6 +3881,7 @@ export default class KoniExtension {
3873
3881
  // change this depends on step
3874
3882
  chainType,
3875
3883
  resolveOnDone: !isLastStep,
3884
+ signerSubstrateProxyAddress,
3876
3885
  transferNativeAmount,
3877
3886
  balanceType: balanceTypeForPool,
3878
3887
  skipFeeValidation: isMintingStep && isPoolSupportAlternativeFee,
@@ -3885,6 +3894,7 @@ export default class KoniExtension {
3885
3894
  async handleYieldLeave(params) {
3886
3895
  const {
3887
3896
  address,
3897
+ signerSubstrateProxyAddress,
3888
3898
  slug
3889
3899
  } = params;
3890
3900
  const leaveValidation = await this.#koniState.earningService.validateYieldLeave(params);
@@ -3900,6 +3910,7 @@ export default class KoniExtension {
3900
3910
  data: params,
3901
3911
  // TODO
3902
3912
  extrinsicType,
3913
+ signerSubstrateProxyAddress,
3903
3914
  chainType: (handler === null || handler === void 0 ? void 0 : handler.transactionChainType) || ChainType.SUBSTRATE
3904
3915
  });
3905
3916
  }
@@ -3976,6 +3987,7 @@ export default class KoniExtension {
3976
3987
  async yieldSubmitWithdrawal(params) {
3977
3988
  const {
3978
3989
  address,
3990
+ signerSubstrateProxyAddress,
3979
3991
  slug
3980
3992
  } = params;
3981
3993
  const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
@@ -3989,6 +4001,7 @@ export default class KoniExtension {
3989
4001
  transaction: extrinsic,
3990
4002
  data: params,
3991
4003
  extrinsicType: ExtrinsicType.STAKING_WITHDRAW,
4004
+ signerSubstrateProxyAddress,
3992
4005
  chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || ChainType.SUBSTRATE
3993
4006
  });
3994
4007
  }
@@ -3996,6 +4009,7 @@ export default class KoniExtension {
3996
4009
  const {
3997
4010
  address,
3998
4011
  selectedUnstaking,
4012
+ signerSubstrateProxyAddress,
3999
4013
  slug
4000
4014
  } = params;
4001
4015
  const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
@@ -4010,12 +4024,14 @@ export default class KoniExtension {
4010
4024
  transaction: extrinsic,
4011
4025
  data: params,
4012
4026
  extrinsicType: ExtrinsicType.STAKING_CANCEL_UNSTAKE,
4027
+ signerSubstrateProxyAddress,
4013
4028
  chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || ChainType.SUBSTRATE
4014
4029
  });
4015
4030
  }
4016
4031
  async yieldSubmitClaimReward(params) {
4017
4032
  const {
4018
4033
  address,
4034
+ signerSubstrateProxyAddress,
4019
4035
  slug
4020
4036
  } = params;
4021
4037
  const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
@@ -4028,6 +4044,7 @@ export default class KoniExtension {
4028
4044
  chain: poolHandler.chain,
4029
4045
  transaction: extrinsic,
4030
4046
  data: params,
4047
+ signerSubstrateProxyAddress,
4031
4048
  extrinsicType: ExtrinsicType.STAKING_CLAIM_REWARD,
4032
4049
  chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || ChainType.SUBSTRATE
4033
4050
  });
@@ -4046,6 +4063,7 @@ export default class KoniExtension {
4046
4063
  async handleYieldChangeValidator(params) {
4047
4064
  const {
4048
4065
  address,
4066
+ signerSubstrateProxyAddress,
4049
4067
  slug
4050
4068
  } = params;
4051
4069
  const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
@@ -4058,6 +4076,7 @@ export default class KoniExtension {
4058
4076
  chain: poolHandler.chain,
4059
4077
  transaction: extrinsic,
4060
4078
  data: params,
4079
+ signerSubstrateProxyAddress,
4061
4080
  extrinsicType: ExtrinsicType.CHANGE_EARNING_VALIDATOR,
4062
4081
  chainType: ChainType.SUBSTRATE
4063
4082
  });
@@ -4739,6 +4758,48 @@ export default class KoniExtension {
4739
4758
  pingSession(request) {
4740
4759
  return this.#koniState.keyringService.context.pingSession(request);
4741
4760
  }
4761
+ getSubstrateProxyAccountGroup(request) {
4762
+ return this.#koniState.substrateProxyAccountService.getSubstrateProxyAccountGroup(request);
4763
+ }
4764
+ async handleAddSubstrateProxyAccount(params) {
4765
+ const {
4766
+ address,
4767
+ chain,
4768
+ signerSubstrateProxyAddress
4769
+ } = params;
4770
+ const validationErrors = await this.#koniState.substrateProxyAccountService.validateAddSubstrateProxyAccount(params, signerSubstrateProxyAddress);
4771
+ if (validationErrors.length > 0) {
4772
+ return this.#koniState.transactionService.generateBeforeHandleResponseErrors(validationErrors);
4773
+ }
4774
+ const extrinsic = await this.#koniState.substrateProxyAccountService.addSubstrateProxyAccounts(params);
4775
+ return await this.#koniState.transactionService.handleTransaction({
4776
+ address,
4777
+ chain,
4778
+ transaction: extrinsic,
4779
+ data: params,
4780
+ extrinsicType: ExtrinsicType.ADD_SUBSTRATE_PROXY_ACCOUNT,
4781
+ chainType: ChainType.SUBSTRATE,
4782
+ signerSubstrateProxyAddress
4783
+ });
4784
+ }
4785
+ async handleRemoveSubstrateProxyAccount(params) {
4786
+ const {
4787
+ address,
4788
+ chain,
4789
+ signerSubstrateProxyAddress
4790
+ } = params;
4791
+ const extrinsic = await this.#koniState.substrateProxyAccountService.removeSubstrateProxyAccounts(params);
4792
+ return await this.#koniState.transactionService.handleTransaction({
4793
+ address,
4794
+ chain,
4795
+ transaction: extrinsic,
4796
+ data: params,
4797
+ extrinsicType: ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT,
4798
+ chainType: ChainType.SUBSTRATE,
4799
+ signerSubstrateProxyAddress
4800
+ });
4801
+ }
4802
+
4742
4803
  /* Migrate Unified Account */
4743
4804
 
4744
4805
  /* Open Gov */
@@ -4751,7 +4812,8 @@ export default class KoniExtension {
4751
4812
  transaction: extrinsic,
4752
4813
  data: request,
4753
4814
  extrinsicType: ExtrinsicType.GOV_VOTE,
4754
- chainType: ChainType.SUBSTRATE
4815
+ chainType: ChainType.SUBSTRATE,
4816
+ signerSubstrateProxyAddress: request.signerSubstrateProxyAddress
4755
4817
  });
4756
4818
  }
4757
4819
  async handleRemoveVote(request) {
@@ -4762,7 +4824,8 @@ export default class KoniExtension {
4762
4824
  transaction: extrinsic,
4763
4825
  data: request,
4764
4826
  extrinsicType: ExtrinsicType.GOV_UNVOTE,
4765
- chainType: ChainType.SUBSTRATE
4827
+ chainType: ChainType.SUBSTRATE,
4828
+ signerSubstrateProxyAddress: request.signerSubstrateProxyAddress
4766
4829
  });
4767
4830
  }
4768
4831
  async handleUnlockVote(request) {
@@ -4773,7 +4836,8 @@ export default class KoniExtension {
4773
4836
  transaction: extrinsic,
4774
4837
  data: request,
4775
4838
  extrinsicType: ExtrinsicType.GOV_UNLOCK_VOTE,
4776
- chainType: ChainType.SUBSTRATE
4839
+ chainType: ChainType.SUBSTRATE,
4840
+ signerSubstrateProxyAddress: request.signerSubstrateProxyAddress
4777
4841
  });
4778
4842
  }
4779
4843
  async subscribeGovLockedInfo(id, port) {
@@ -5461,6 +5525,15 @@ export default class KoniExtension {
5461
5525
  return this.handleUnlockVote(request);
5462
5526
  case 'pri(openGov.subscribeGovLockedInfo)':
5463
5527
  return this.subscribeGovLockedInfo(id, port);
5528
+
5529
+ // Proxy
5530
+ case 'pri(substrateProxyAccount.getGroupInfo)':
5531
+ return this.getSubstrateProxyAccountGroup(request);
5532
+ case 'pri(substrateProxyAccount.add)':
5533
+ return this.handleAddSubstrateProxyAccount(request);
5534
+ case 'pri(substrateProxyAccount.remove)':
5535
+ return this.handleRemoveSubstrateProxyAccount(request);
5536
+
5464
5537
  // Default
5465
5538
  default:
5466
5539
  throw new Error(`Unable to handle message of type ${type}`);
@@ -28,6 +28,7 @@ import { AuthUrls, MetaRequest, SignRequest } from '@subwallet/extension-base/se
28
28
  import SettingService from '@subwallet/extension-base/services/setting-service/SettingService';
29
29
  import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
30
30
  import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
31
+ import SubstrateProxyAccountService from '@subwallet/extension-base/services/substrate-proxy-service';
31
32
  import { SwapService } from '@subwallet/extension-base/services/swap-service';
32
33
  import TransactionService from '@subwallet/extension-base/services/transaction-service';
33
34
  import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
@@ -83,6 +84,7 @@ export default class KoniState {
83
84
  readonly inappNotificationService: InappNotificationService;
84
85
  readonly chainOnlineService: ChainOnlineService;
85
86
  readonly openGovService: OpenGovService;
87
+ readonly substrateProxyAccountService: SubstrateProxyAccountService;
86
88
  private generalStatus;
87
89
  private waitSleeping;
88
90
  private waitStarting;
@@ -38,6 +38,7 @@ import { convertAssetToValue, convertValueToAsset, extractKeyHashesFromCollatera
38
38
  import SettingService from '@subwallet/extension-base/services/setting-service/SettingService';
39
39
  import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
40
40
  import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
41
+ import SubstrateProxyAccountService from '@subwallet/extension-base/services/substrate-proxy-service';
41
42
  import { SwapService } from '@subwallet/extension-base/services/swap-service';
42
43
  import TransactionService from '@subwallet/extension-base/services/transaction-service';
43
44
  import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
@@ -124,6 +125,7 @@ export default class KoniState {
124
125
  this.inappNotificationService = new InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
125
126
  this.chainOnlineService = new ChainOnlineService(this.chainService, this.settingService, this.eventService, this.dbService);
126
127
  this.openGovService = new OpenGovService(this);
128
+ this.substrateProxyAccountService = new SubstrateProxyAccountService(this);
127
129
  this.subscription = new KoniSubscription(this, this.dbService);
128
130
  this.cron = new KoniCron(this, this.subscription, this.dbService);
129
131
  this.logger = createLogger('State');
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.3.71-0",
20
+ "version": "1.3.72-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1486,6 +1486,11 @@
1486
1486
  "require": "./cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251107.js",
1487
1487
  "default": "./services/migration-service/scripts/databases/MigrateAssetSetting20251107.js"
1488
1488
  },
1489
+ "./services/migration-service/scripts/databases/MigrateAssetSetting20251223": {
1490
+ "types": "./services/migration-service/scripts/databases/MigrateAssetSetting20251223.d.ts",
1491
+ "require": "./cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js",
1492
+ "default": "./services/migration-service/scripts/databases/MigrateAssetSetting20251223.js"
1493
+ },
1489
1494
  "./services/migration-service/scripts/databases/MigrateEarningHistory": {
1490
1495
  "types": "./services/migration-service/scripts/databases/MigrateEarningHistory.d.ts",
1491
1496
  "require": "./cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js",
@@ -1631,6 +1636,11 @@
1631
1636
  "require": "./cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107.js",
1632
1637
  "default": "./services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107.js"
1633
1638
  },
1639
+ "./services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223": {
1640
+ "types": "./services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.d.ts",
1641
+ "require": "./cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js",
1642
+ "default": "./services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js"
1643
+ },
1634
1644
  "./services/migration-service/scripts/MigrateWalletReference": {
1635
1645
  "types": "./services/migration-service/scripts/MigrateWalletReference.d.ts",
1636
1646
  "require": "./cjs/services/migration-service/scripts/MigrateWalletReference.js",
@@ -2026,6 +2036,16 @@
2026
2036
  "require": "./cjs/services/subscan-service/types.js",
2027
2037
  "default": "./services/subscan-service/types.js"
2028
2038
  },
2039
+ "./services/substrate-proxy-service": {
2040
+ "types": "./services/substrate-proxy-service/index.d.ts",
2041
+ "require": "./cjs/services/substrate-proxy-service/index.js",
2042
+ "default": "./services/substrate-proxy-service/index.js"
2043
+ },
2044
+ "./services/substrate-proxy-service/constant": {
2045
+ "types": "./services/substrate-proxy-service/constant.d.ts",
2046
+ "require": "./cjs/services/substrate-proxy-service/constant.js",
2047
+ "default": "./services/substrate-proxy-service/constant.js"
2048
+ },
2029
2049
  "./services/swap-service": {
2030
2050
  "types": "./services/swap-service/index.d.ts",
2031
2051
  "require": "./cjs/services/swap-service/index.js",
@@ -2521,6 +2541,16 @@
2521
2541
  "require": "./cjs/types/setting.js",
2522
2542
  "default": "./types/setting.js"
2523
2543
  },
2544
+ "./types/substrateProxyAccount": {
2545
+ "types": "./types/substrateProxyAccount/index.d.ts",
2546
+ "require": "./cjs/types/substrateProxyAccount/index.js",
2547
+ "default": "./types/substrateProxyAccount/index.js"
2548
+ },
2549
+ "./types/substrateProxyAccount/actions": {
2550
+ "types": "./types/substrateProxyAccount/actions/index.d.ts",
2551
+ "require": "./cjs/types/substrateProxyAccount/actions/index.js",
2552
+ "default": "./types/substrateProxyAccount/actions/index.js"
2553
+ },
2524
2554
  "./types/swap": {
2525
2555
  "types": "./types/swap/index.d.ts",
2526
2556
  "require": "./cjs/types/swap/index.js",
@@ -2943,11 +2973,11 @@
2943
2973
  "@sora-substrate/type-definitions": "^1.17.7",
2944
2974
  "@substrate/connect": "^0.8.9",
2945
2975
  "@subwallet-monorepos/subwallet-services-sdk": "0.1.14",
2946
- "@subwallet/chain-list": "0.2.122",
2947
- "@subwallet/extension-base": "^1.3.71-0",
2948
- "@subwallet/extension-chains": "^1.3.71-0",
2949
- "@subwallet/extension-dapp": "^1.3.71-0",
2950
- "@subwallet/extension-inject": "^1.3.71-0",
2976
+ "@subwallet/chain-list": "0.2.123",
2977
+ "@subwallet/extension-base": "^1.3.72-0",
2978
+ "@subwallet/extension-chains": "^1.3.72-0",
2979
+ "@subwallet/extension-dapp": "^1.3.72-0",
2980
+ "@subwallet/extension-inject": "^1.3.72-0",
2951
2981
  "@subwallet/keyring": "^0.1.14",
2952
2982
  "@subwallet/ui-keyring": "^0.1.14",
2953
2983
  "@ton/core": "^0.56.3",
package/packageInfo.js CHANGED
@@ -7,5 +7,5 @@ export const packageInfo = {
7
7
  name: '@subwallet/extension-base',
8
8
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
9
9
  type: 'esm',
10
- version: '1.3.71-0'
10
+ version: '1.3.72-0'
11
11
  };