@subwallet/extension-base 1.3.70-2 → 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 (237) hide show
  1. package/background/KoniTypes.d.ts +13 -2
  2. package/background/KoniTypes.js +68 -9
  3. package/cjs/background/KoniTypes.js +68 -9
  4. package/cjs/constants/blocked-actions.js +3 -0
  5. package/cjs/core/logic-validation/recipientAddress.js +1 -1
  6. package/cjs/core/logic-validation/swap.js +0 -3
  7. package/cjs/core/logic-validation/transfer.js +33 -10
  8. package/cjs/core/substrate/system-pallet.js +0 -2
  9. package/cjs/core/types.js +1 -0
  10. package/cjs/koni/api/nft/wasm_nft/index.js +0 -1
  11. package/cjs/koni/api/staking/bonding/astar.js +0 -2
  12. package/cjs/koni/api/staking/bonding/paraChain.js +0 -3
  13. package/cjs/koni/api/staking/bonding/relayChain.js +2 -4
  14. package/cjs/koni/api/staking/bonding/utils.js +0 -4
  15. package/cjs/koni/background/cron.js +0 -1
  16. package/cjs/koni/background/handlers/Extension.js +235 -166
  17. package/cjs/koni/background/handlers/State.js +56 -52
  18. package/cjs/koni/background/handlers/Tabs.js +39 -34
  19. package/cjs/packageInfo.js +1 -1
  20. package/cjs/page/index.js +7 -0
  21. package/cjs/page/substrate/PostMessageProvider.js +3 -0
  22. package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
  23. package/cjs/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
  24. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +48 -5
  25. package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
  26. package/cjs/services/balance-service/index.js +103 -7
  27. package/cjs/services/balance-service/transfer/bitcoin-transfer.js +0 -1
  28. package/cjs/services/balance-service/transfer/cardano-transfer.js +1 -2
  29. package/cjs/services/balance-service/transfer/smart-contract.js +0 -1
  30. package/cjs/services/balance-service/transfer/token.js +13 -37
  31. package/cjs/services/balance-service/transfer/ton-transfer.js +0 -1
  32. package/cjs/services/balance-service/transfer/xcm/index.js +3 -8
  33. package/cjs/services/balance-service/transfer/xcm/snowBridge.js +0 -1
  34. package/cjs/services/balance-service/transfer/xcm/utils.js +1 -1
  35. package/cjs/services/chain-service/constants.js +6 -5
  36. package/cjs/services/chain-service/handler/CardanoApi.js +3 -1
  37. package/cjs/services/chain-service/handler/SubstrateApi.js +0 -2
  38. package/cjs/services/chain-service/handler/light-client/index.js +1 -2
  39. package/cjs/services/chain-service/health-check/index.js +0 -1
  40. package/cjs/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
  41. package/cjs/services/chain-service/index.js +19 -26
  42. package/cjs/services/chain-service/utils/index.js +21 -25
  43. package/cjs/services/chain-service/utils/patch.js +1 -1
  44. package/cjs/services/earning-service/handlers/base.js +32 -0
  45. package/cjs/services/earning-service/handlers/lending/base.js +0 -2
  46. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -1
  47. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -2
  48. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
  49. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
  50. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -2
  51. package/cjs/services/earning-service/handlers/native-staking/dtao.js +43 -2
  52. package/cjs/services/earning-service/handlers/native-staking/energy.js +0 -1
  53. package/cjs/services/earning-service/handlers/native-staking/mythos.js +0 -2
  54. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -2
  55. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
  56. package/cjs/services/earning-service/handlers/special.js +7 -0
  57. package/cjs/services/history-service/subsquid-multi-chain-history.js +0 -1
  58. package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
  59. package/cjs/services/keyring-service/context/handlers/Migration.js +11 -9
  60. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +18 -13
  61. package/cjs/services/keyring-service/context/state.js +21 -3
  62. package/cjs/services/keyring-service/utils.js +12 -2
  63. package/cjs/services/migration-service/index.js +1 -2
  64. package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +55 -0
  65. package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +41 -0
  66. package/cjs/services/migration-service/scripts/index.js +17 -13
  67. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
  68. package/cjs/services/nft-service/index.js +5 -0
  69. package/cjs/services/open-gov/handler.js +0 -2
  70. package/cjs/services/open-gov/interface.js +4 -1
  71. package/cjs/services/request-service/handler/BitcoinRequestHandler.js +1 -2
  72. package/cjs/services/request-service/handler/CardanoRequestHandler.js +0 -1
  73. package/cjs/services/request-service/handler/EvmRequestHandler.js +0 -1
  74. package/cjs/services/request-service/handler/TonRequestHandler.js +0 -1
  75. package/cjs/services/request-service/helper/index.js +1 -2
  76. package/cjs/services/storage-service/DatabaseService.js +0 -2
  77. package/cjs/services/storage-service/databases/index.js +2 -0
  78. package/cjs/services/substrate-proxy-service/constant.js +26 -0
  79. package/cjs/services/substrate-proxy-service/index.js +170 -0
  80. package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -1
  81. package/cjs/services/swap-service/handler/asset-hub/router.js +0 -1
  82. package/cjs/services/swap-service/handler/chainflip-handler.js +1 -4
  83. package/cjs/services/swap-service/handler/hydradx-handler.js +0 -1
  84. package/cjs/services/swap-service/handler/kyber-handler.js +0 -1
  85. package/cjs/services/swap-service/handler/optimex-handler.js +1 -2
  86. package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -3
  87. package/cjs/services/swap-service/handler/uniswap-handler.js +0 -3
  88. package/cjs/services/transaction-service/event-parser/index.js +6 -6
  89. package/cjs/services/transaction-service/index.js +105 -37
  90. package/cjs/services/transaction-service/utils.js +8 -5
  91. package/cjs/services/wallet-connect-service/index.js +21 -18
  92. package/cjs/services/wallet-connect-service/types.js +1 -1
  93. package/cjs/types/account/info/keyring.js +9 -1
  94. package/cjs/types/balance/index.js +5 -1
  95. package/cjs/types/index.js +11 -0
  96. package/cjs/types/substrateProxyAccount/actions/index.js +1 -0
  97. package/cjs/types/substrateProxyAccount/index.js +16 -0
  98. package/cjs/types/swap/index.js +2 -1
  99. package/cjs/types/transaction/process.js +2 -0
  100. package/cjs/types/yield/actions/join/step.js +17 -1
  101. package/cjs/utils/account/common.js +0 -26
  102. package/cjs/utils/account/derive/info/solo.js +7 -4
  103. package/cjs/utils/account/derive/validate.js +1 -1
  104. package/cjs/utils/account/transform.js +10 -5
  105. package/cjs/utils/auth.js +1 -1
  106. package/cjs/utils/bitcoin/utxo-management.js +0 -1
  107. package/cjs/utils/environment.js +2 -1
  108. package/cjs/utils/fee/transfer.js +5 -4
  109. package/cjs/utils/index.js +1 -2
  110. package/constants/blocked-actions.js +3 -0
  111. package/core/logic-validation/recipientAddress.js +1 -1
  112. package/core/logic-validation/swap.js +0 -3
  113. package/core/logic-validation/transfer.d.ts +3 -3
  114. package/core/logic-validation/transfer.js +34 -11
  115. package/core/substrate/system-pallet.js +0 -2
  116. package/core/types.d.ts +2 -1
  117. package/core/types.js +1 -0
  118. package/koni/api/nft/wasm_nft/index.js +0 -1
  119. package/koni/api/staking/bonding/astar.js +0 -2
  120. package/koni/api/staking/bonding/paraChain.js +0 -3
  121. package/koni/api/staking/bonding/relayChain.js +2 -4
  122. package/koni/api/staking/bonding/utils.js +0 -4
  123. package/koni/background/cron.js +0 -1
  124. package/koni/background/handlers/Extension.d.ts +3 -0
  125. package/koni/background/handlers/Extension.js +89 -19
  126. package/koni/background/handlers/State.d.ts +2 -0
  127. package/koni/background/handlers/State.js +43 -38
  128. package/koni/background/handlers/Tabs.js +9 -3
  129. package/package.json +50 -21
  130. package/packageInfo.js +1 -1
  131. package/page/substrate/PostMessageProvider.js +3 -0
  132. package/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
  133. package/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
  134. package/services/balance-service/helpers/subscribe/substrate/index.js +47 -4
  135. package/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
  136. package/services/balance-service/index.d.ts +8 -0
  137. package/services/balance-service/index.js +105 -9
  138. package/services/balance-service/transfer/bitcoin-transfer.js +0 -1
  139. package/services/balance-service/transfer/smart-contract.js +0 -1
  140. package/services/balance-service/transfer/token.d.ts +0 -4
  141. package/services/balance-service/transfer/token.js +12 -35
  142. package/services/balance-service/transfer/ton-transfer.js +0 -1
  143. package/services/balance-service/transfer/xcm/index.js +3 -8
  144. package/services/balance-service/transfer/xcm/snowBridge.js +0 -1
  145. package/services/balance-service/transfer/xcm/utils.d.ts +0 -2
  146. package/services/balance-service/transfer/xcm/utils.js +1 -1
  147. package/services/chain-service/constants.d.ts +1 -1
  148. package/services/chain-service/constants.js +4 -4
  149. package/services/chain-service/handler/CardanoApi.js +3 -1
  150. package/services/chain-service/handler/SubstrateApi.js +0 -2
  151. package/services/chain-service/health-check/index.js +0 -1
  152. package/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
  153. package/services/chain-service/index.d.ts +0 -1
  154. package/services/chain-service/index.js +16 -23
  155. package/services/chain-service/utils/index.js +22 -26
  156. package/services/chain-service/utils/patch.d.ts +1 -1
  157. package/services/chain-service/utils/patch.js +1 -1
  158. package/services/earning-service/handlers/base.js +32 -0
  159. package/services/earning-service/handlers/lending/base.js +0 -2
  160. package/services/earning-service/handlers/liquid-staking/acala.js +0 -1
  161. package/services/earning-service/handlers/liquid-staking/base.js +0 -2
  162. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
  163. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
  164. package/services/earning-service/handlers/native-staking/astar.js +0 -2
  165. package/services/earning-service/handlers/native-staking/dtao.js +43 -0
  166. package/services/earning-service/handlers/native-staking/energy.js +0 -1
  167. package/services/earning-service/handlers/native-staking/mythos.js +0 -2
  168. package/services/earning-service/handlers/native-staking/para-chain.js +0 -2
  169. package/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
  170. package/services/earning-service/handlers/special.js +7 -0
  171. package/services/history-service/subsquid-multi-chain-history.js +0 -1
  172. package/services/keyring-service/context/handlers/Derive.js +2 -2
  173. package/services/keyring-service/context/handlers/Migration.js +3 -1
  174. package/services/keyring-service/context/handlers/Mnemonic.d.ts +1 -1
  175. package/services/keyring-service/context/handlers/Mnemonic.js +16 -10
  176. package/services/keyring-service/context/state.d.ts +3 -0
  177. package/services/keyring-service/context/state.js +21 -3
  178. package/services/keyring-service/utils.d.ts +1 -0
  179. package/services/keyring-service/utils.js +9 -0
  180. package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.d.ts +4 -0
  181. package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +46 -0
  182. package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.d.ts +4 -0
  183. package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +33 -0
  184. package/services/migration-service/scripts/index.js +8 -4
  185. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
  186. package/services/nft-service/index.js +6 -0
  187. package/services/open-gov/handler.js +0 -2
  188. package/services/open-gov/interface.d.ts +4 -3
  189. package/services/open-gov/interface.js +4 -1
  190. package/services/request-service/handler/CardanoRequestHandler.js +0 -1
  191. package/services/request-service/handler/EvmRequestHandler.js +0 -1
  192. package/services/request-service/handler/TonRequestHandler.js +0 -1
  193. package/services/setting-service/constants.js +0 -1
  194. package/services/storage-service/DatabaseService.js +0 -2
  195. package/services/storage-service/databases/index.js +3 -0
  196. package/services/substrate-proxy-service/constant.d.ts +3 -0
  197. package/services/substrate-proxy-service/constant.js +19 -0
  198. package/services/substrate-proxy-service/index.d.ts +13 -0
  199. package/services/substrate-proxy-service/index.js +159 -0
  200. package/services/swap-service/handler/asset-hub/handler.js +0 -1
  201. package/services/swap-service/handler/asset-hub/router.js +0 -1
  202. package/services/swap-service/handler/chainflip-handler.js +0 -2
  203. package/services/swap-service/handler/hydradx-handler.js +0 -1
  204. package/services/swap-service/handler/kyber-handler.js +0 -1
  205. package/services/swap-service/handler/simpleswap-handler.js +0 -1
  206. package/services/swap-service/handler/uniswap-handler.js +0 -3
  207. package/services/transaction-service/event-parser/index.js +6 -6
  208. package/services/transaction-service/index.js +79 -11
  209. package/services/transaction-service/types.d.ts +2 -2
  210. package/services/transaction-service/utils.js +8 -5
  211. package/services/wallet-connect-service/index.js +21 -18
  212. package/services/wallet-connect-service/types.js +1 -1
  213. package/types/account/action/add/mnemonic.d.ts +3 -2
  214. package/types/account/info/keyring.js +9 -1
  215. package/types/balance/index.js +5 -1
  216. package/types/balance/transfer.d.ts +1 -0
  217. package/types/index.d.ts +1 -0
  218. package/types/index.js +1 -0
  219. package/types/substrateProxyAccount/actions/index.d.ts +17 -0
  220. package/types/substrateProxyAccount/actions/index.js +1 -0
  221. package/types/substrateProxyAccount/index.d.ts +23 -0
  222. package/types/substrateProxyAccount/index.js +8 -0
  223. package/types/swap/index.js +2 -1
  224. package/types/transaction/process.js +3 -1
  225. package/types/transaction/request.d.ts +1 -0
  226. package/types/yield/actions/join/step.js +17 -1
  227. package/types/yield/actions/join/submit.d.ts +1 -1
  228. package/utils/account/common.d.ts +0 -3
  229. package/utils/account/common.js +0 -24
  230. package/utils/account/derive/info/solo.js +8 -5
  231. package/utils/account/derive/validate.d.ts +2 -2
  232. package/utils/account/derive/validate.js +1 -1
  233. package/utils/account/transform.js +10 -5
  234. package/utils/auth.js +2 -2
  235. package/utils/bitcoin/utxo-management.js +0 -1
  236. package/utils/fee/transfer.js +4 -2
  237. package/utils/index.js +2 -5
@@ -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
+ });
@@ -55,7 +55,8 @@ exports.SwapFeeType = SwapFeeType;
55
55
  SwapFeeType["PLATFORM_FEE"] = "PLATFORM_FEE";
56
56
  SwapFeeType["NETWORK_FEE"] = "NETWORK_FEE";
57
57
  SwapFeeType["WALLET_FEE"] = "WALLET_FEE";
58
- })(SwapFeeType || (exports.SwapFeeType = SwapFeeType = {}));
58
+ })(SwapFeeType || (exports.SwapFeeType = SwapFeeType = {})); // todo: will be more
59
+ // parameters & responses
59
60
  let DynamicSwapType;
60
61
  exports.DynamicSwapType = DynamicSwapType;
61
62
  (function (DynamicSwapType) {
@@ -25,4 +25,6 @@ exports.StepStatus = StepStatus;
25
25
  StepStatus["TIMEOUT"] = "TIMEOUT";
26
26
  })(StepStatus || (exports.StepStatus = StepStatus = {}));
27
27
  const PROCESSING_STEP_STATUS = [StepStatus.PREPARE, StepStatus.SUBMITTING, StepStatus.PROCESSING];
28
+
29
+ // temp for avoid conflict // todo: recheck to refactor BriefXcmStepV2 and BriefSwapStepV2 later;
28
30
  exports.PROCESSING_STEP_STATUS = PROCESSING_STEP_STATUS;
@@ -45,4 +45,20 @@ exports.YieldStepType = YieldStepType;
45
45
  YieldStepType["MINT_SDOT"] = "MINT_SDOT";
46
46
  YieldStepType["MINT_STDOT"] = "MINT_STDOT";
47
47
  YieldStepType["TOKEN_APPROVAL"] = "TOKEN_APPROVAL";
48
- })(YieldStepType || (exports.YieldStepType = YieldStepType = {}));
48
+ })(YieldStepType || (exports.YieldStepType = YieldStepType = {}));
49
+ /**
50
+ * @interface YieldStepDetail
51
+ * @extends BaseYieldStepDetail
52
+ * @description Detail of a step
53
+ * @prop {number} id - Step's id
54
+ * */
55
+ /**
56
+ * @interface YieldTokenBaseInfo
57
+ * @prop {string} slug - Token's slug
58
+ * @prop {string} [amount] - Token's amount
59
+ * */
60
+ /** Base info and fee of a step */
61
+ /**
62
+ * @interface OptimalYieldPath
63
+ * @description Result after generate steps
64
+ * */
@@ -7,7 +7,6 @@ exports.getAccountJsonByAddress = exports.getAccountChainTypeForAddress = export
7
7
  exports.getAddressesByChainType = getAddressesByChainType;
8
8
  exports.getAddressesByChainTypeMap = getAddressesByChainTypeMap;
9
9
  exports.isAccountAll = isAccountAll;
10
- exports.modifyAccountName = void 0;
11
10
  exports.quickFormatAddressToCompare = quickFormatAddressToCompare;
12
11
  exports.reformatAddress = reformatAddress;
13
12
  var _constants = require("@subwallet/extension-base/constants");
@@ -80,7 +79,6 @@ function getAddressesByChainType(addresses, chainTypes, chainInfo) {
80
79
  return addressByChainTypeMap[chainType];
81
80
  }).flat(); // todo: recheck
82
81
  }
83
-
84
82
  function getAddressesByChainTypeMap(addresses, chainInfo) {
85
83
  const addressByChainType = {
86
84
  substrate: [],
@@ -120,29 +118,6 @@ function quickFormatAddressToCompare(address) {
120
118
  return reformatAddress(address, 42).toLowerCase();
121
119
  }
122
120
 
123
- /** @deprecated */
124
- const modifyAccountName = (type, name, modify) => {
125
- if (!modify) {
126
- return name;
127
- }
128
- let network = '';
129
- switch (type) {
130
- case 'sr25519':
131
- case 'ed25519':
132
- case 'ecdsa':
133
- network = 'Substrate';
134
- break;
135
- case 'ethereum':
136
- network = 'EVM';
137
- break;
138
- case 'ton':
139
- case 'ton-native':
140
- network = 'Ton';
141
- break;
142
- }
143
- return network ? [name, network].join(' - ') : name;
144
- };
145
-
146
121
  /**
147
122
  * @function getAccountJsonByAddress
148
123
  * @desc Get account info by address
@@ -152,7 +127,6 @@ const modifyAccountName = (type, name, modify) => {
152
127
  * @param {string} address - Address
153
128
  * @returns {AccountJson|null} - Account info or null if not found
154
129
  */
155
- exports.modifyAccountName = modifyAccountName;
156
130
  const getAccountJsonByAddress = address => {
157
131
  try {
158
132
  const pair = _uiKeyring.keyring.getPair(address);
@@ -59,7 +59,7 @@ const parseUnifiedSuriToDerivationPath = (suri, type) => {
59
59
  return path.replace('{firstIndex}', firstIndex);
60
60
  }
61
61
  }
62
- if (_types.SubstrateKeypairTypes.includes(type)) {
62
+ if (_types.DefaultSubstrateKeypairTypes.includes(type)) {
63
63
  return suri;
64
64
  }
65
65
  }
@@ -120,7 +120,7 @@ const getSoloDerivationInfo = function (type) {
120
120
  };
121
121
  }
122
122
  } else {
123
- if (_types.SubstrateKeypairTypes.includes(type)) {
123
+ if (_types.DefaultSubstrateKeypairTypes.includes(type)) {
124
124
  const _type = type;
125
125
  const validateTypeFunc = _type === 'sr25519' ? _validate.validateSr25519DerivationPath : raw => (0, _validate.validateOtherSubstrateDerivationPath)(raw, _type);
126
126
  const validateTypeRs = validateTypeFunc(suri);
@@ -256,7 +256,7 @@ const findSoloNextDerive = parentAddress => {
256
256
  break;
257
257
  }
258
258
  }
259
- const isSubstrate = _types.SubstrateKeypairTypes.includes(parentPair.type);
259
+ const isSubstrate = _types.DefaultSubstrateKeypairTypes.includes(parentPair.type);
260
260
  const indexes = currentDepth > 0 ? deriveInfo.autoIndexes || [] : [];
261
261
  indexes.push(index);
262
262
  const suri = isSubstrate ? [deriveInfo.suri || '', index].join('//') : '//'.concat(indexes.join('//'));
@@ -296,7 +296,10 @@ const derivePair = (parentPair, name, suri, derivationPath) => {
296
296
  };
297
297
  exports.derivePair = derivePair;
298
298
  const getSuri = (seed, type) => {
299
- const extraPath = type ? (0, _keyring.getDerivePath)(type)(0) : '';
299
+ if (!type) {
300
+ return seed;
301
+ }
302
+ const extraPath = (0, _keyring.getDerivePath)(type)(0);
300
303
  return seed + (extraPath ? '/' + extraPath : '');
301
304
  };
302
305
  exports.getSuri = getSuri;
@@ -259,7 +259,7 @@ const validateDerivationPath = (raw, type) => {
259
259
  return validateTonDerivationPath(raw);
260
260
  } else if (type === 'sr25519') {
261
261
  return validateSr25519DerivationPath(raw);
262
- } else if (type === 'ed25519' || type === 'ecdsa') {
262
+ } else if (type === 'ed25519' || type === 'ed25519-tw' || type === 'ecdsa') {
263
263
  return validateOtherSubstrateDerivationPath(raw, type);
264
264
  } else if (type === 'cardano') {
265
265
  return validateCardanoDerivationPath(raw);
@@ -115,7 +115,10 @@ const getAccountActions = (signMode, networkType, type, _meta, parentAccount) =>
115
115
  // QR
116
116
  if (signMode === _types2.AccountSignMode.PASSWORD) {
117
117
  if (networkType === _types2.AccountChainType.ETHEREUM || networkType === _types2.AccountChainType.SUBSTRATE) {
118
- result.push(_types2.AccountActions.EXPORT_QR);
118
+ if (type !== 'ed25519-tw') {
119
+ // todo: recheck if can export this account type
120
+ result.push(_types2.AccountActions.EXPORT_QR);
121
+ }
119
122
  }
120
123
  }
121
124
 
@@ -165,14 +168,15 @@ const EARN_VMANTA_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_VMANTA, _KoniTypes.Ex
165
168
  const EVM_ACTIONS = [_KoniTypes.ExtrinsicType.TOKEN_SPENDING_APPROVAL, _KoniTypes.ExtrinsicType.EVM_EXECUTE];
166
169
  const CLAIM_AVAIL_BRIDGE = [_KoniTypes.ExtrinsicType.CLAIM_BRIDGE];
167
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];
168
172
  const OTHER_ACTIONS = [_KoniTypes.ExtrinsicType.TRANSFER_XCM, _KoniTypes.ExtrinsicType.SEND_NFT, _KoniTypes.ExtrinsicType.SWAP, _KoniTypes.ExtrinsicType.CROWDLOAN];
169
173
  const getAccountTransactionActions = (signMode, networkType, type, _meta, _specialNetwork) => {
170
174
  if ([_types2.AccountSignMode.PASSWORD, _types2.AccountSignMode.INJECTED].includes(signMode)) {
171
175
  switch (networkType) {
172
176
  case _types2.AccountChainType.SUBSTRATE:
173
- 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];
174
178
  case _types2.AccountChainType.ETHEREUM:
175
- 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];
176
180
  case _types2.AccountChainType.TON:
177
181
  return [...BASE_TRANSFER_ACTIONS];
178
182
  case _types2.AccountChainType.CARDANO:
@@ -183,7 +187,7 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
183
187
  } else if (signMode === _types2.AccountSignMode.QR) {
184
188
  switch (networkType) {
185
189
  case _types2.AccountChainType.SUBSTRATE:
186
- 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];
187
191
  case _types2.AccountChainType.ETHEREUM:
188
192
  return [...(_constants.isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
189
193
  case _types2.AccountChainType.TON:
@@ -198,7 +202,7 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
198
202
  case _types2.AccountChainType.SUBSTRATE:
199
203
  return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS,
200
204
  // ...EARN_QDOT_ACTIONS,
201
- ...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
205
+ ...OPEN_GOV_ACTIONS, ...SUBSTRATE_PROXY_ACTION, ...OTHER_ACTIONS];
202
206
  case _types2.AccountChainType.ETHEREUM:
203
207
  return [...BASE_TRANSFER_ACTIONS, ...EARN_STDOT_ACTIONS, ...EVM_ACTIONS, ...CLAIM_AVAIL_BRIDGE, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
204
208
  // For liquid staking
@@ -259,6 +263,7 @@ const getAccountTokenTypes = type => {
259
263
  return [_types._AssetType.NATIVE, _types._AssetType.LOCAL, _types._AssetType.ERC20, _types._AssetType.ERC721];
260
264
  case 'sr25519':
261
265
  case 'ed25519':
266
+ case 'ed25519-tw':
262
267
  case 'ecdsa':
263
268
  return [_types._AssetType.NATIVE, _types._AssetType.LOCAL, _types._AssetType.PSP22, _types._AssetType.PSP34, _types._AssetType.GRC20, _types._AssetType.ERC721, _types._AssetType.VFT];
264
269
  case 'ton':
package/cjs/utils/auth.js CHANGED
@@ -13,7 +13,7 @@ const isAddressValidWithAuthType = (address, accountAuthTypes) => {
13
13
  const keypairType = (0, _keyring.getKeypairTypeByAddress)(address);
14
14
  const validTypes = {
15
15
  evm: _types.EthereumKeypairTypes,
16
- substrate: _types.SubstrateKeypairTypes,
16
+ substrate: _types.AllSubstrateKeypairTypes,
17
17
  ton: _types.TonKeypairTypes,
18
18
  cardano: _types.CardanoKeypairTypes,
19
19
  bitcoin: _types.BitcoinKeypairTypes
@@ -249,7 +249,6 @@ async function getRuneUtxos(bitcoinApi, address) {
249
249
  status: {
250
250
  confirmed: true // not use in filter out rune utxos
251
251
  },
252
-
253
252
  value: utxoValue
254
253
  };
255
254
  runeUtxos.push(item);
@@ -11,7 +11,8 @@ var _mv = require("@subwallet/extension-base/utils/mv3");
11
11
  var _bowser = _interopRequireDefault(require("bowser"));
12
12
  var _KoniTypes = require("../background/KoniTypes");
13
13
  var _constants = require("../constants");
14
- var _navigator3;
14
+ var _navigator3; // Copyright 2019-2022 @polkadot/extension authors & contributors
15
+ // SPDX-License-Identifier: Apache-2.0
15
16
  function detectRuntimeEnvironment() {
16
17
  if (_mv.isSupportWindow && typeof document !== 'undefined') {
17
18
  var _navigator, _window$location, _window$location2;
@@ -31,8 +31,7 @@ var bitcoin = _interopRequireWildcard(require("bitcoinjs-lib"));
31
31
  var _util = require("@polkadot/util");
32
32
  var _utilCrypto = require("@polkadot/util-crypto");
33
33
  var _combine = require("./combine");
34
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
34
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
36
35
  // Copyright 2019-2022 @subwallet/extension-base
37
36
  // SPDX-License-Identifier: Apache-2.0
38
37
 
@@ -330,7 +329,8 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
330
329
  feeType: feeChainType,
331
330
  id: id,
332
331
  error,
333
- isEvmRpcError: isEvmRpcError
332
+ isEvmRpcError: isEvmRpcError,
333
+ maxTransferableWithoutFee: freeBalance.value
334
334
  };
335
335
  };
336
336
  exports.calculateTransferMaxTransferable = calculateTransferMaxTransferable;
@@ -522,7 +522,8 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
522
522
  feeOptions: feeOptions,
523
523
  feeType: feeChainType,
524
524
  id: id,
525
- error
525
+ error,
526
+ maxTransferableWithoutFee: freeBalance.value
526
527
  };
527
528
  };
528
529
  exports.calculateXcmMaxTransferable = calculateXcmMaxTransferable;
@@ -602,7 +602,6 @@ function isSameAddress(address1, address2) {
602
602
  }
603
603
  return (0, _account.reformatAddress)(address1, 0) === (0, _account.reformatAddress)(address2, 0); // TODO: maybe there's a better way
604
604
  }
605
-
606
605
  function isSameAddressType(address1, address2) {
607
606
  const isSameEvmAddress = (0, _utilCrypto.isEthereumAddress)(address1) && (0, _utilCrypto.isEthereumAddress)(address2);
608
607
  const isSameTonAddress = (0, _keyring.isTonAddress)(address1) && (0, _keyring.isTonAddress)(address2);
@@ -614,7 +613,7 @@ function isAddressAndChainCompatible(address, chain) {
614
613
  const keypairType = (0, _keyring.getKeypairTypeByAddress)(address);
615
614
  const isEvmCompatible = (0, _utils._isChainEvmCompatible)(chain) && _types.EthereumKeypairTypes.includes(keypairType); // some chains compatible to substrate and evm, and use evm-address
616
615
  const isTonCompatible = (0, _utils._isPureTonChain)(chain) && _types.TonKeypairTypes.includes(keypairType);
617
- const isSubstrateCompatible = (0, _utils._isPureSubstrateChain)(chain) && _types.SubstrateKeypairTypes.includes(keypairType);
616
+ const isSubstrateCompatible = (0, _utils._isPureSubstrateChain)(chain) && _types.AllSubstrateKeypairTypes.includes(keypairType);
618
617
  const isCardanoCompatible = (0, _utils._isPureCardanoChain)(chain) && _types.CardanoKeypairTypes.includes(keypairType);
619
618
  const isBitcoinCompatible = (0, _utils._isPureBitcoinChain)(chain) && _types.BitcoinKeypairTypes.includes(keypairType);
620
619
  return isEvmCompatible || isSubstrateCompatible || isTonCompatible || isCardanoCompatible || isBitcoinCompatible;
@@ -9,6 +9,9 @@ export const APP_VER = packageInfo.version;
9
9
  const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
10
10
  const branchName = process.env.BRANCH_NAME || 'koni-dev';
11
11
  const targetFolder = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list' : 'preview';
12
+
13
+ // todo: check if can check exactly App Environment, Browser Type, OS Type
14
+
12
15
  export async function fetchBlockedConfigObjects() {
13
16
  const targetFile = `${targetFolder}/envConfig.json`;
14
17
  return await fetchStaticData('blocked-actions', targetFile);
@@ -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);
@@ -34,7 +34,6 @@ export function _validateBalanceToSwapOnAssetHub(fromToken, feeToken, feeTokenCh
34
34
  return new TransactionError(SwapErrorType.SWAP_NOT_ENOUGH_BALANCE, `Insufficient balance. You need more than ${parsedMinSwapValue} ${fromToken.symbol} to start swapping. Deposit ${fromToken.symbol} and try again.`); // todo: min swap or amount?
35
35
  }
36
36
  }
37
-
38
37
  if (new BigN(swapAmount).gte(fromTokenBalance)) {
39
38
  const parsedMaxBalanceSwap = formatNumber(fromTokenBalance, _getAssetDecimals(fromToken));
40
39
  return new TransactionError(SwapErrorType.SWAP_EXCEED_ALLOWANCE, `Amount too high. Lower your amount ${bnFromTokenBalance.gt(0) ? `below ${parsedMaxBalanceSwap} ${fromToken.symbol}` : ''} and try again`);
@@ -62,7 +61,6 @@ export function _validateBalanceToSwap(fromToken, feeToken, feeTokenChainInfo, f
62
61
  return new TransactionError(SwapErrorType.SWAP_NOT_ENOUGH_BALANCE, `Insufficient balance. You need more than ${parsedMinSwapValue} ${fromToken.symbol} to start swapping. Deposit ${fromToken.symbol} and try again.`); // todo: min swap or amount?
63
62
  }
64
63
  }
65
-
66
64
  if (new BigN(swapAmount).gte(fromTokenBalance)) {
67
65
  const parsedMaxBalanceSwap = formatNumber(fromTokenBalance, _getAssetDecimals(fromToken));
68
66
  return new TransactionError(SwapErrorType.SWAP_EXCEED_ALLOWANCE, `Amount too high. Lower your amount ${bnFromTokenBalance.gt(0) ? `below ${parsedMaxBalanceSwap} ${fromToken.symbol}` : ''} and try again`);
@@ -206,7 +204,6 @@ export function _validateBalanceToSwapV2(request) {
206
204
  return new TransactionError(SwapErrorType.SWAP_NOT_ENOUGH_BALANCE, `Insufficient balance. You need more than ${parsedMinSwapValue} ${fromToken.symbol} to start swapping. Deposit ${fromToken.symbol} and try again.`); // todo: min swap or amount?
207
205
  }
208
206
  }
209
-
210
207
  return undefined;
211
208
  }
212
209
  export function _validateSwapRecipientV2(destChainInfo, recipient) {
@@ -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
@@ -18,7 +18,6 @@ export function _getSystemPalletTransferable(accountInfo, existentialDeposit, ex
18
18
  export function _canAccountBeReaped(accountInfo) {
19
19
  return accountInfo.consumers === 0; // might need to check refCount
20
20
  }
21
-
22
21
  export function _isAccountActive(accountInfo) {
23
22
  return !(accountInfo.consumers === 0 && accountInfo.providers === 0 && accountInfo.sufficients === 0);
24
23
  }
@@ -46,7 +45,6 @@ function _getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMo
46
45
  }
47
46
  return _canAccountBeReaped(accountInfo) ? BigInt(0) : bnExistentialDeposit; // account for ED here will go better with max transfer logic
48
47
  }
49
-
50
48
  function _getSystemPalletTransferableV2(accountInfo, existentialDeposit, strictMode) {
51
49
  const bnLocked = BigInt(accountInfo.data.frozen) - BigInt(accountInfo.data.reserved); // locked can go below 0 but this shouldn't matter
52
50
  const bnAppliedExistentialDeposit = _getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMode);
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 = {}));
@@ -398,7 +398,6 @@ export class WasmNftApi extends BaseNftApi {
398
398
  }
399
399
  }
400
400
  }));
401
-
402
401
  nftOwnerMap[address] = nftIds;
403
402
  } catch (e) {
404
403
  console.error(`${this.chain}`, e);
@@ -114,7 +114,6 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
114
114
  }
115
115
  }
116
116
  }
117
-
118
117
  const unlockingChunks = ledger.unbondingInfo.unlockingChunks;
119
118
  if (unlockingChunks.length > 0) {
120
119
  for (const unlockingChunk of unlockingChunks) {
@@ -200,7 +199,6 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
200
199
  }
201
200
  }
202
201
  }
203
-
204
202
  const unlockingChunks = ledger.unbondingInfo.unlockingChunks;
205
203
  if (unlockingChunks.length > 0) {
206
204
  for (const unlockingChunk of unlockingChunks) {
@@ -132,7 +132,6 @@ export async function getParaChainStakingMetadata(chain, substrateApi) {
132
132
  if (unvestedAllocation) {
133
133
  totalIssuance.add(unvestedAllocation); // for Turing network, read more at https://hackmd.io/@sbAqOuXkRvyiZPOB3Ryn6Q/Sypr3ZJh5
134
134
  }
135
-
136
135
  const inflationConfig = _inflation.toHuman();
137
136
  const inflation = getParaCurrentInflation(parseRawNumber(totalStake.toString()), inflationConfig);
138
137
  const unstakingPeriod = parseInt(unstakingDelay) * _STAKING_ERA_LENGTH_MAP[chain];
@@ -185,7 +184,6 @@ export async function subscribeParaChainNominatorMetadata(chainInfo, address, su
185
184
  }
186
185
  }
187
186
  }
188
-
189
187
  const bnStake = new BN(delegation.amount);
190
188
  const bnUnstakeBalance = unstakingMap[delegation.owner] ? new BN(unstakingMap[delegation.owner].claimable) : BN_ZERO;
191
189
  const bnActiveStake = bnStake.sub(bnUnstakeBalance);
@@ -279,7 +277,6 @@ export async function getParaChainNominatorMetadata(chainInfo, address, substrat
279
277
  }
280
278
  }
281
279
  }
282
-
283
280
  const bnStake = new BN(delegation.amount);
284
281
  const bnUnstakeBalance = unstakingMap[delegation.owner] ? new BN(unstakingMap[delegation.owner].claimable) : BN_ZERO;
285
282
  const bnActiveStake = bnStake.sub(bnUnstakeBalance);
@@ -221,7 +221,6 @@ export async function subscribeRelayChainNominatorMetadata(chainInfo, address, s
221
221
  });
222
222
  }));
223
223
  }
224
-
225
224
  let stakingStatus = EarningStatus.NOT_EARNING;
226
225
  const bnActiveStake = new BN(activeStake);
227
226
  let waitingNominationCount = 0;
@@ -273,13 +272,13 @@ export async function subscribeRelayChainNominatorMetadata(chainInfo, address, s
273
272
  * Deprecated
274
273
  * */
275
274
  export async function getRelayChainNominatorMetadata(chainInfo, address, substrateApi) {
276
- var _chainApi$api$query10, _chainApi$api$query11, _chainApi$api$query12, _chainApi$api$query13, _chainApi$api$query14, _chainApi$api$query15, _chainApi$api$query16, _chainApi$api$query17, _chainApi$api$query18, _chainApi$api$query19, _chainApi$api$query20, _chainApi$api$query21, _chainApi$api$query22, _chainApi$api$query23;
275
+ var _chainApi$api$query0, _chainApi$api$query0$, _chainApi$api$query1, _chainApi$api$query1$, _chainApi$api$query10, _chainApi$api$query11, _chainApi$api$query12, _chainApi$api$query13, _chainApi$api$query14, _chainApi$api$query15, _chainApi$api$query16, _chainApi$api$query17, _chainApi$api$query18, _chainApi$api$query19;
277
276
  if (isEthereumAddress(address)) {
278
277
  return;
279
278
  }
280
279
  const chain = chainInfo.slug;
281
280
  const chainApi = await substrateApi.isReady;
282
- const [_ledger, _nominations, _currentEra, _bonded, _minimumActiveStake, _minNominatorBond] = await Promise.all([(_chainApi$api$query10 = chainApi.api.query) === null || _chainApi$api$query10 === void 0 ? void 0 : (_chainApi$api$query11 = _chainApi$api$query10.staking) === null || _chainApi$api$query11 === void 0 ? void 0 : _chainApi$api$query11.ledger(address), (_chainApi$api$query12 = chainApi.api.query) === null || _chainApi$api$query12 === void 0 ? void 0 : (_chainApi$api$query13 = _chainApi$api$query12.staking) === null || _chainApi$api$query13 === void 0 ? void 0 : _chainApi$api$query13.nominators(address), (_chainApi$api$query14 = chainApi.api.query) === null || _chainApi$api$query14 === void 0 ? void 0 : (_chainApi$api$query15 = _chainApi$api$query14.staking) === null || _chainApi$api$query15 === void 0 ? void 0 : _chainApi$api$query15.currentEra(), (_chainApi$api$query16 = chainApi.api.query) === null || _chainApi$api$query16 === void 0 ? void 0 : (_chainApi$api$query17 = _chainApi$api$query16.staking) === null || _chainApi$api$query17 === void 0 ? void 0 : _chainApi$api$query17.bonded(address), ((_chainApi$api$query18 = chainApi.api.query) === null || _chainApi$api$query18 === void 0 ? void 0 : (_chainApi$api$query19 = _chainApi$api$query18.staking) === null || _chainApi$api$query19 === void 0 ? void 0 : _chainApi$api$query19.minimumActiveStake) && ((_chainApi$api$query20 = chainApi.api.query) === null || _chainApi$api$query20 === void 0 ? void 0 : (_chainApi$api$query21 = _chainApi$api$query20.staking) === null || _chainApi$api$query21 === void 0 ? void 0 : _chainApi$api$query21.minimumActiveStake()), (_chainApi$api$query22 = chainApi.api.query) === null || _chainApi$api$query22 === void 0 ? void 0 : (_chainApi$api$query23 = _chainApi$api$query22.staking) === null || _chainApi$api$query23 === void 0 ? void 0 : _chainApi$api$query23.minNominatorBond()]);
281
+ const [_ledger, _nominations, _currentEra, _bonded, _minimumActiveStake, _minNominatorBond] = await Promise.all([(_chainApi$api$query0 = chainApi.api.query) === null || _chainApi$api$query0 === void 0 ? void 0 : (_chainApi$api$query0$ = _chainApi$api$query0.staking) === null || _chainApi$api$query0$ === void 0 ? void 0 : _chainApi$api$query0$.ledger(address), (_chainApi$api$query1 = chainApi.api.query) === null || _chainApi$api$query1 === void 0 ? void 0 : (_chainApi$api$query1$ = _chainApi$api$query1.staking) === null || _chainApi$api$query1$ === void 0 ? void 0 : _chainApi$api$query1$.nominators(address), (_chainApi$api$query10 = chainApi.api.query) === null || _chainApi$api$query10 === void 0 ? void 0 : (_chainApi$api$query11 = _chainApi$api$query10.staking) === null || _chainApi$api$query11 === void 0 ? void 0 : _chainApi$api$query11.currentEra(), (_chainApi$api$query12 = chainApi.api.query) === null || _chainApi$api$query12 === void 0 ? void 0 : (_chainApi$api$query13 = _chainApi$api$query12.staking) === null || _chainApi$api$query13 === void 0 ? void 0 : _chainApi$api$query13.bonded(address), ((_chainApi$api$query14 = chainApi.api.query) === null || _chainApi$api$query14 === void 0 ? void 0 : (_chainApi$api$query15 = _chainApi$api$query14.staking) === null || _chainApi$api$query15 === void 0 ? void 0 : _chainApi$api$query15.minimumActiveStake) && ((_chainApi$api$query16 = chainApi.api.query) === null || _chainApi$api$query16 === void 0 ? void 0 : (_chainApi$api$query17 = _chainApi$api$query16.staking) === null || _chainApi$api$query17 === void 0 ? void 0 : _chainApi$api$query17.minimumActiveStake()), (_chainApi$api$query18 = chainApi.api.query) === null || _chainApi$api$query18 === void 0 ? void 0 : (_chainApi$api$query19 = _chainApi$api$query18.staking) === null || _chainApi$api$query19 === void 0 ? void 0 : _chainApi$api$query19.minNominatorBond()]);
283
282
  const minActiveStake = (_minimumActiveStake === null || _minimumActiveStake === void 0 ? void 0 : _minimumActiveStake.toString()) || '0';
284
283
  const minNominatorBond = _minNominatorBond.toString();
285
284
  const bnMinActiveStake = new BN(minActiveStake);
@@ -334,7 +333,6 @@ export async function getRelayChainNominatorMetadata(chainInfo, address, substra
334
333
  });
335
334
  }));
336
335
  }
337
-
338
336
  let stakingStatus = EarningStatus.NOT_EARNING;
339
337
  const bnActiveStake = new BN(activeStake);
340
338
  let waitingNominationCount = 0;
@@ -69,7 +69,6 @@ export function calculateChainStakedReturn(inflation, totalEraStake, totalIssuan
69
69
  if (_STAKING_CHAIN_GROUP.aleph.includes(networkKey)) {
70
70
  stakedReturn *= 0.9; // 10% goes to treasury
71
71
  }
72
-
73
72
  return stakedReturn;
74
73
  }
75
74
  export async function calculateChainStakedReturnV2(chainInfo, totalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, inflation, isCompound) {
@@ -136,11 +135,9 @@ export function calculateValidatorStakedReturn(chainStakedReturn, totalValidator
136
135
  const stakedReturn = (adjusted > Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : adjusted) / 100;
137
136
  return stakedReturn * (100 - commission) / 100; // Deduct commission
138
137
  }
139
-
140
138
  export function getCommission(commissionString) {
141
139
  return parseFloat(commissionString.split('%')[0]); // Example: 12%
142
140
  }
143
-
144
141
  export function getParaCurrentInflation(totalStaked, inflationConfig) {
145
142
  // read more at https://hackmd.io/@sbAqOuXkRvyiZPOB3Ryn6Q/Sypr3ZJh5
146
143
  const expectMin = parseRawNumber(inflationConfig.expect.min);
@@ -263,7 +260,6 @@ export function getYieldAvailableActionsByPosition(yieldPosition, yieldPoolInfo,
263
260
  result.push(YieldAction.START_EARNING);
264
261
  result.push(YieldAction.WITHDRAW_EARNING); // TODO
265
262
  }
266
-
267
263
  return result;
268
264
  }
269
265
  export let StakingAction;
@@ -13,7 +13,6 @@ export class KoniCron {
13
13
  this.state = state;
14
14
  // this.init();
15
15
  }
16
-
17
16
  cronMap = {};
18
17
  subjectMap = {};
19
18
  getCron = name => {