@subwallet/extension-base 1.3.22-0 → 1.3.23-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 (193) hide show
  1. package/background/KoniTypes.d.ts +75 -2
  2. package/background/KoniTypes.js +2 -0
  3. package/cjs/background/KoniTypes.js +2 -0
  4. package/cjs/constants/environment.js +4 -2
  5. package/cjs/constants/signing.js +6 -2
  6. package/cjs/core/logic-validation/recipientAddress.js +9 -1
  7. package/cjs/core/logic-validation/transfer.js +35 -29
  8. package/cjs/core/types.js +1 -0
  9. package/cjs/core/utils.js +12 -1
  10. package/cjs/defaults.js +1 -1
  11. package/cjs/koni/api/dotsama/crowdloan.js +1 -1
  12. package/cjs/koni/api/nft/index.js +9 -16
  13. package/cjs/koni/api/staking/index.js +3 -4
  14. package/cjs/koni/background/handlers/Extension.js +234 -96
  15. package/cjs/koni/background/handlers/State.js +15 -0
  16. package/cjs/packageInfo.js +1 -1
  17. package/cjs/services/balance-service/helpers/subscribe/cardano/consts.js +11 -0
  18. package/cjs/services/balance-service/helpers/subscribe/cardano/index.js +63 -0
  19. package/cjs/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
  20. package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +74 -0
  21. package/cjs/services/balance-service/helpers/subscribe/index.js +21 -7
  22. package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +2 -2
  23. package/cjs/services/balance-service/index.js +4 -2
  24. package/cjs/services/balance-service/transfer/cardano-transfer.js +122 -0
  25. package/cjs/services/balance-service/transfer/token.js +4 -4
  26. package/cjs/services/chain-service/handler/CardanoApi.js +176 -0
  27. package/cjs/services/chain-service/handler/CardanoChainHandler.js +83 -0
  28. package/cjs/services/chain-service/handler/TonApi.js +2 -5
  29. package/cjs/services/chain-service/index.js +29 -7
  30. package/cjs/services/chain-service/utils/index.js +40 -11
  31. package/cjs/services/chain-service/utils/patch.js +1 -1
  32. package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
  33. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
  34. package/cjs/services/earning-service/service.js +6 -12
  35. package/cjs/services/fee-service/service.js +19 -8
  36. package/cjs/services/history-service/index.js +4 -6
  37. package/cjs/services/inapp-notification-service/index.js +12 -4
  38. package/cjs/services/keyring-service/context/account-context.js +17 -2
  39. package/cjs/services/keyring-service/context/handlers/Derive.js +10 -7
  40. package/cjs/services/keyring-service/context/handlers/Migration.js +268 -0
  41. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +2 -2
  42. package/cjs/services/keyring-service/context/handlers/Secret.js +1 -1
  43. package/cjs/services/keyring-service/utils.js +18 -0
  44. package/cjs/services/request-service/handler/CardanoRequestHandler.js +172 -0
  45. package/cjs/services/request-service/handler/EvmRequestHandler.js +1 -1
  46. package/cjs/services/request-service/index.js +20 -2
  47. package/cjs/services/setting-service/constants.js +10 -1
  48. package/cjs/services/storage-service/DatabaseService.js +3 -0
  49. package/cjs/services/storage-service/db-stores/InappNotification.js +6 -0
  50. package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -59
  51. package/cjs/services/swap-service/handler/chainflip-handler.js +33 -281
  52. package/cjs/services/swap-service/handler/hydradx-handler.js +23 -190
  53. package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -222
  54. package/cjs/services/swap-service/handler/uniswap-handler.js +331 -0
  55. package/cjs/services/swap-service/index.js +31 -22
  56. package/cjs/services/swap-service/utils.js +21 -38
  57. package/cjs/services/transaction-service/helpers/index.js +6 -1
  58. package/cjs/services/transaction-service/index.js +278 -21
  59. package/cjs/services/transaction-service/utils.js +5 -1
  60. package/cjs/types/account/info/keyring.js +12 -1
  61. package/cjs/types/fee/cardano.js +1 -0
  62. package/cjs/types/swap/index.js +7 -2
  63. package/cjs/utils/account/analyze.js +2 -1
  64. package/cjs/utils/account/common.js +29 -20
  65. package/cjs/utils/account/derive/info/solo.js +9 -4
  66. package/cjs/utils/account/derive/validate.js +36 -2
  67. package/cjs/utils/account/transform.js +38 -13
  68. package/cjs/utils/fee/transfer.js +40 -7
  69. package/cjs/utils/index.js +2 -2
  70. package/cjs/utils/staticData/index.js +7 -2
  71. package/constants/environment.d.ts +1 -0
  72. package/constants/environment.js +2 -1
  73. package/constants/signing.js +6 -2
  74. package/core/logic-validation/recipientAddress.js +11 -3
  75. package/core/logic-validation/transfer.js +9 -3
  76. package/core/substrate/xcm-parser.d.ts +1 -1
  77. package/core/types.d.ts +1 -0
  78. package/core/types.js +1 -0
  79. package/core/utils.d.ts +1 -0
  80. package/core/utils.js +13 -3
  81. package/defaults.d.ts +1 -1
  82. package/defaults.js +1 -1
  83. package/koni/api/dotsama/crowdloan.js +3 -3
  84. package/koni/api/nft/index.js +10 -16
  85. package/koni/api/nft/story_odyssey_nft/index.d.ts +1 -1
  86. package/koni/api/staking/index.js +4 -5
  87. package/koni/background/handlers/Extension.d.ts +9 -0
  88. package/koni/background/handlers/Extension.js +144 -8
  89. package/koni/background/handlers/State.d.ts +5 -1
  90. package/koni/background/handlers/State.js +16 -1
  91. package/package.json +71 -9
  92. package/packageInfo.js +1 -1
  93. package/services/balance-service/helpers/subscribe/cardano/consts.d.ts +1 -0
  94. package/services/balance-service/helpers/subscribe/cardano/consts.js +4 -0
  95. package/services/balance-service/helpers/subscribe/cardano/index.d.ts +2 -0
  96. package/services/balance-service/helpers/subscribe/cardano/index.js +57 -0
  97. package/services/balance-service/helpers/subscribe/cardano/types.d.ts +34 -0
  98. package/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
  99. package/services/balance-service/helpers/subscribe/cardano/utils.d.ts +15 -0
  100. package/services/balance-service/helpers/subscribe/cardano/utils.js +62 -0
  101. package/services/balance-service/helpers/subscribe/index.d.ts +2 -2
  102. package/services/balance-service/helpers/subscribe/index.js +23 -9
  103. package/services/balance-service/helpers/subscribe/ton/utils.d.ts +1 -1
  104. package/services/balance-service/helpers/subscribe/ton/utils.js +1 -1
  105. package/services/balance-service/index.js +4 -2
  106. package/services/balance-service/transfer/cardano-transfer.d.ts +24 -0
  107. package/services/balance-service/transfer/cardano-transfer.js +114 -0
  108. package/services/balance-service/transfer/token.d.ts +1 -1
  109. package/services/balance-service/transfer/token.js +2 -2
  110. package/services/chain-service/handler/CardanoApi.d.ts +38 -0
  111. package/services/chain-service/handler/CardanoApi.js +167 -0
  112. package/services/chain-service/handler/CardanoChainHandler.d.ts +17 -0
  113. package/services/chain-service/handler/CardanoChainHandler.js +75 -0
  114. package/services/chain-service/handler/TonApi.js +3 -6
  115. package/services/chain-service/handler/types.d.ts +1 -0
  116. package/services/chain-service/index.d.ts +3 -1
  117. package/services/chain-service/index.js +29 -7
  118. package/services/chain-service/types.d.ts +9 -1
  119. package/services/chain-service/utils/index.d.ts +4 -0
  120. package/services/chain-service/utils/index.js +32 -11
  121. package/services/chain-service/utils/patch.js +1 -1
  122. package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
  123. package/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
  124. package/services/earning-service/service.js +8 -14
  125. package/services/fee-service/service.js +19 -8
  126. package/services/history-service/index.js +6 -8
  127. package/services/inapp-notification-service/index.d.ts +3 -4
  128. package/services/inapp-notification-service/index.js +14 -6
  129. package/services/keyring-service/context/account-context.d.ts +6 -2
  130. package/services/keyring-service/context/account-context.js +17 -2
  131. package/services/keyring-service/context/handlers/Derive.d.ts +1 -1
  132. package/services/keyring-service/context/handlers/Derive.js +10 -8
  133. package/services/keyring-service/context/handlers/Migration.d.ts +17 -0
  134. package/services/keyring-service/context/handlers/Migration.js +258 -0
  135. package/services/keyring-service/context/handlers/Mnemonic.js +2 -2
  136. package/services/keyring-service/context/handlers/Secret.js +2 -2
  137. package/services/keyring-service/utils.d.ts +2 -0
  138. package/services/keyring-service/utils.js +11 -0
  139. package/services/request-service/handler/CardanoRequestHandler.d.ts +16 -0
  140. package/services/request-service/handler/CardanoRequestHandler.js +163 -0
  141. package/services/request-service/handler/EvmRequestHandler.js +1 -1
  142. package/services/request-service/index.d.ts +6 -3
  143. package/services/request-service/index.js +19 -5
  144. package/services/setting-service/constants.d.ts +3 -0
  145. package/services/setting-service/constants.js +6 -0
  146. package/services/storage-service/DatabaseService.d.ts +1 -0
  147. package/services/storage-service/DatabaseService.js +3 -0
  148. package/services/storage-service/db-stores/InappNotification.d.ts +1 -0
  149. package/services/storage-service/db-stores/InappNotification.js +6 -0
  150. package/services/swap-service/handler/asset-hub/handler.d.ts +1 -4
  151. package/services/swap-service/handler/asset-hub/handler.js +2 -61
  152. package/services/swap-service/handler/base-handler.d.ts +1 -4
  153. package/services/swap-service/handler/chainflip-handler.d.ts +2 -9
  154. package/services/swap-service/handler/chainflip-handler.js +31 -280
  155. package/services/swap-service/handler/hydradx-handler.d.ts +1 -6
  156. package/services/swap-service/handler/hydradx-handler.js +13 -180
  157. package/services/swap-service/handler/simpleswap-handler.d.ts +1 -4
  158. package/services/swap-service/handler/simpleswap-handler.js +5 -226
  159. package/services/swap-service/handler/uniswap-handler.d.ts +41 -0
  160. package/services/swap-service/handler/uniswap-handler.js +323 -0
  161. package/services/swap-service/index.js +30 -22
  162. package/services/swap-service/utils.d.ts +1 -5
  163. package/services/swap-service/utils.js +7 -21
  164. package/services/transaction-service/helpers/index.d.ts +2 -0
  165. package/services/transaction-service/helpers/index.js +4 -0
  166. package/services/transaction-service/index.d.ts +8 -2
  167. package/services/transaction-service/index.js +263 -10
  168. package/services/transaction-service/types.d.ts +7 -0
  169. package/services/transaction-service/utils.js +7 -2
  170. package/types/account/info/keyring.d.ts +4 -1
  171. package/types/account/info/keyring.js +9 -0
  172. package/types/account/info/proxy.d.ts +2 -0
  173. package/types/balance/index.d.ts +4 -1
  174. package/types/fee/base.d.ts +1 -1
  175. package/types/fee/cardano.d.ts +18 -0
  176. package/types/fee/cardano.js +1 -0
  177. package/types/fee/subscription.d.ts +4 -3
  178. package/types/swap/index.d.ts +11 -3
  179. package/types/swap/index.js +7 -2
  180. package/utils/account/analyze.js +2 -1
  181. package/utils/account/common.d.ts +11 -6
  182. package/utils/account/common.js +28 -19
  183. package/utils/account/derive/info/solo.js +10 -5
  184. package/utils/account/derive/validate.d.ts +1 -0
  185. package/utils/account/derive/validate.js +34 -1
  186. package/utils/account/transform.d.ts +2 -1
  187. package/utils/account/transform.js +37 -13
  188. package/utils/fee/transfer.d.ts +2 -1
  189. package/utils/fee/transfer.js +44 -11
  190. package/utils/index.js +4 -4
  191. package/utils/staticData/index.d.ts +4 -1
  192. package/utils/staticData/index.js +5 -1
  193. package/utils/staticData/oldChainPrefix.json +1 -0
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.validateUnifiedDerivationPath = exports.validateTonDerivationPath = exports.validateSr25519DerivationPath = exports.validateOtherSubstrateDerivationPath = exports.validateEvmDerivationPath = exports.validateDerivationPath = void 0;
6
+ exports.validateUnifiedDerivationPath = exports.validateTonDerivationPath = exports.validateSr25519DerivationPath = exports.validateOtherSubstrateDerivationPath = exports.validateEvmDerivationPath = exports.validateDerivationPath = exports.validateCardanoDerivationPath = void 0;
7
7
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
8
8
  // SPDX-License-Identifier: Apache-2.0
9
9
 
@@ -105,6 +105,38 @@ const validateTonDerivationPath = raw => {
105
105
  }
106
106
  };
107
107
  exports.validateTonDerivationPath = validateTonDerivationPath;
108
+ const validateCardanoDerivationPath = raw => {
109
+ const reg = /^m\/1852'\/1815'\/(\d+)'(\/\d+')?$/;
110
+ if (raw.match(reg)) {
111
+ const [, firstIndex, secondData] = raw.match(reg);
112
+ const first = parseInt(firstIndex, 10);
113
+ const autoIndexes = [first];
114
+ let depth;
115
+ let suri = `//${first}`;
116
+ if (first === 0) {
117
+ depth = 0;
118
+ } else {
119
+ depth = 1;
120
+ }
121
+ if (secondData) {
122
+ const [, secondIndex] = secondData.match(/\/(\d+)/);
123
+ const second = parseInt(secondIndex, 10);
124
+ autoIndexes.push(second);
125
+ depth = 2;
126
+ suri += `//${second}`;
127
+ }
128
+ return {
129
+ depth,
130
+ type: 'cardano',
131
+ suri,
132
+ derivationPath: raw,
133
+ autoIndexes
134
+ };
135
+ } else {
136
+ return undefined;
137
+ }
138
+ };
139
+ exports.validateCardanoDerivationPath = validateCardanoDerivationPath;
108
140
  const validateSr25519DerivationPath = raw => {
109
141
  const reg = /\/(\/?)([^/]+)/g;
110
142
  const parts = raw.match(reg);
@@ -167,11 +199,13 @@ const validateDerivationPath = (raw, type) => {
167
199
  return validateSr25519DerivationPath(raw);
168
200
  } else if (type === 'ed25519' || type === 'ecdsa') {
169
201
  return validateOtherSubstrateDerivationPath(raw, type);
202
+ } else if (type === 'cardano') {
203
+ return validateCardanoDerivationPath(raw);
170
204
  } else {
171
205
  return undefined;
172
206
  }
173
207
  } else {
174
- return validateUnifiedDerivationPath(raw) || validateEvmDerivationPath(raw) || validateTonDerivationPath(raw) || validateSr25519DerivationPath(raw);
208
+ return validateUnifiedDerivationPath(raw) || validateEvmDerivationPath(raw) || validateTonDerivationPath(raw) || validateSr25519DerivationPath(raw) || validateCardanoDerivationPath(raw);
175
209
  }
176
210
  };
177
211
  exports.validateDerivationPath = validateDerivationPath;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.transformAddresses = exports.transformAddress = exports.transformAccounts = exports.transformAccount = exports.singleAddressToAccount = exports.pairToAccount = exports.getAccountTransactionActions = exports.getAccountTokenTypes = exports.getAccountSignMode = exports.getAccountChainType = exports.getAccountActions = exports.createAccountProxyId = exports.convertAccountProxyType = exports.combineAllAccountProxy = exports.combineAccountsWithSubjectInfo = exports.combineAccountsWithKeyPair = exports._combineAccounts = void 0;
6
+ exports.transformAddresses = exports.transformAddress = exports.transformAccounts = exports.transformAccount = exports.singleAddressToAccount = exports.pairToAccount = exports.getDefaultKeypairTypeFromAccountChainType = exports.getAccountTransactionActions = exports.getAccountTokenTypes = exports.getAccountSignMode = exports.getAccountChainTypeFromKeypairType = exports.getAccountActions = exports.createAccountProxyId = exports.convertAccountProxyType = exports.combineAllAccountProxy = exports.combineAccountsWithSubjectInfo = exports.combineAccountsWithKeyPair = exports._combineAccounts = void 0;
7
7
  var _types = require("@subwallet/chain-list/types");
8
8
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
9
9
  var _constants = require("@subwallet/extension-base/constants");
@@ -39,10 +39,24 @@ const createAccountProxyId = (_suri, derivationPath) => {
39
39
  return (0, _utilCrypto.blake2AsHex)(data, 256);
40
40
  };
41
41
  exports.createAccountProxyId = createAccountProxyId;
42
- const getAccountChainType = type => {
43
- return type ? _types3.EthereumKeypairTypes.includes(type) ? _types2.AccountChainType.ETHEREUM : _types3.TonKeypairTypes.includes(type) ? _types2.AccountChainType.TON : _types3.BitcoinKeypairTypes.includes(type) ? _types2.AccountChainType.BITCOIN : _types2.AccountChainType.SUBSTRATE : _types2.AccountChainType.SUBSTRATE;
42
+ const getAccountChainTypeFromKeypairType = type => {
43
+ return type ? _types3.EthereumKeypairTypes.includes(type) ? _types2.AccountChainType.ETHEREUM : _types3.TonKeypairTypes.includes(type) ? _types2.AccountChainType.TON : _types3.BitcoinKeypairTypes.includes(type) ? _types2.AccountChainType.BITCOIN : _types3.CardanoKeypairTypes.includes(type) ? _types2.AccountChainType.CARDANO : _types2.AccountChainType.SUBSTRATE : _types2.AccountChainType.SUBSTRATE;
44
44
  };
45
- exports.getAccountChainType = getAccountChainType;
45
+ exports.getAccountChainTypeFromKeypairType = getAccountChainTypeFromKeypairType;
46
+ const getDefaultKeypairTypeFromAccountChainType = type => {
47
+ if (type === _types2.AccountChainType.ETHEREUM) {
48
+ return 'ethereum';
49
+ } else if (type === _types2.AccountChainType.TON) {
50
+ return 'ton';
51
+ } else if (type === _types2.AccountChainType.BITCOIN) {
52
+ return 'bitcoin-84';
53
+ } else if (type === _types2.AccountChainType.CARDANO) {
54
+ return 'cardano';
55
+ } else {
56
+ return 'sr25519';
57
+ }
58
+ };
59
+ exports.getDefaultKeypairTypeFromAccountChainType = getDefaultKeypairTypeFromAccountChainType;
46
60
  const getAccountSignMode = (address, _meta) => {
47
61
  const meta = _meta;
48
62
  if (!address || !meta) {
@@ -77,6 +91,7 @@ const getAccountActions = (signMode, networkType, type, _meta, parentAccount) =>
77
91
  const result = [];
78
92
  const meta = _meta;
79
93
 
94
+ // todo: check this function for Cardano
80
95
  // JSON
81
96
  if (signMode === _types2.AccountSignMode.PASSWORD) {
82
97
  result.push(_types2.AccountActions.EXPORT_JSON);
@@ -156,6 +171,8 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
156
171
  return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...EVM_ACTIONS];
157
172
  case _types2.AccountChainType.TON:
158
173
  return [...BASE_TRANSFER_ACTIONS];
174
+ case _types2.AccountChainType.CARDANO:
175
+ return [...BASE_TRANSFER_ACTIONS];
159
176
  }
160
177
  } else if (signMode === _types2.AccountSignMode.QR) {
161
178
  switch (networkType) {
@@ -165,6 +182,8 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
165
182
  return [...(_constants.isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
166
183
  case _types2.AccountChainType.TON:
167
184
  return [];
185
+ case _types2.AccountChainType.CARDANO:
186
+ return [];
168
187
  }
169
188
  } else if (signMode === _types2.AccountSignMode.GENERIC_LEDGER) {
170
189
  switch (networkType) {
@@ -180,6 +199,8 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
180
199
  _KoniTypes.ExtrinsicType.SEND_NFT, _KoniTypes.ExtrinsicType.SWAP];
181
200
  case _types2.AccountChainType.TON:
182
201
  return [...BASE_TRANSFER_ACTIONS];
202
+ case _types2.AccountChainType.CARDANO:
203
+ return [];
183
204
  }
184
205
  } else if (signMode === _types2.AccountSignMode.LEGACY_LEDGER) {
185
206
  // Only for Substrate
@@ -240,6 +261,8 @@ const getAccountTokenTypes = type => {
240
261
  case 'bitcoin-86':
241
262
  case 'bittest-86':
242
263
  return [_types._AssetType.NATIVE, _types._AssetType.RUNE, _types._AssetType.BRC20];
264
+ case 'cardano':
265
+ return [_types._AssetType.NATIVE, _types._AssetType.CIP26];
243
266
  default:
244
267
  return [];
245
268
  }
@@ -265,7 +288,7 @@ exports.getAccountTokenTypes = getAccountTokenTypes;
265
288
  const transformAccount = (address, _type, meta, chainInfoMap, parentAccount) => {
266
289
  const signMode = getAccountSignMode(address, meta);
267
290
  const type = _type || (0, _keyring.getKeypairTypeByAddress)(address);
268
- const chainType = getAccountChainType(type);
291
+ const chainType = getAccountChainTypeFromKeypairType(type);
269
292
  let specialChain;
270
293
  if (!chainInfoMap) {
271
294
  return {
@@ -329,7 +352,7 @@ const transformAccounts = accounts => Object.values(accounts).map(data => single
329
352
  exports.transformAccounts = transformAccounts;
330
353
  const transformAddress = (address, meta) => {
331
354
  const type = (0, _keyring.getKeypairTypeByAddress)(address);
332
- const chainType = getAccountChainType(type);
355
+ const chainType = getAccountChainTypeFromKeypairType(type);
333
356
  return {
334
357
  address,
335
358
  ...meta,
@@ -411,6 +434,7 @@ const _combineAccounts = (accounts, modifyPairs, accountProxies) => {
411
434
  let tokenTypes = [];
412
435
  let accountActions = [];
413
436
  let specialChain;
437
+ let isNeedMigrateUnifiedAccount;
414
438
  if (value.accounts.length > 1) {
415
439
  accountType = _types2.AccountProxyType.UNIFIED;
416
440
  chainTypes = Array.from(value.accounts.reduce((rs, account) => rs.add(account.chainType), new Set()));
@@ -420,6 +444,9 @@ const _combineAccounts = (accounts, modifyPairs, accountProxies) => {
420
444
  }
421
445
  return rs;
422
446
  }, new Set()));
447
+ if (chainTypes.length < _types2.SUPPORTED_ACCOUNT_CHAIN_TYPES.length) {
448
+ isNeedMigrateUnifiedAccount = true;
449
+ }
423
450
 
424
451
  /* Account actions */
425
452
 
@@ -451,6 +478,9 @@ const _combineAccounts = (accounts, modifyPairs, accountProxies) => {
451
478
  if (account.chainType === _types2.AccountChainType.TON) {
452
479
  accountActions = accountActions.filter(action => action !== _types2.AccountActions.DERIVE);
453
480
  }
481
+ if (chainTypes.length === 1 && accountActions.includes(_types2.AccountActions.EXPORT_MNEMONIC) && account.isMasterAccount && account.type !== 'ton-native') {
482
+ isNeedMigrateUnifiedAccount = true;
483
+ }
454
484
  switch (account.signMode) {
455
485
  case _types2.AccountSignMode.GENERIC_LEDGER:
456
486
  case _types2.AccountSignMode.LEGACY_LEDGER:
@@ -464,7 +494,8 @@ const _combineAccounts = (accounts, modifyPairs, accountProxies) => {
464
494
  chainTypes,
465
495
  specialChain,
466
496
  tokenTypes,
467
- accountActions
497
+ accountActions,
498
+ isNeedMigrateUnifiedAccount
468
499
  }];
469
500
  }));
470
501
  const deepSearchParentId = parentId => {
@@ -543,15 +574,9 @@ const combineAllAccountProxy = accountProxies => {
543
574
  const tokenTypes = new Set();
544
575
  const specialChain = accountProxies.length === 1 ? accountProxies[0].specialChain : undefined;
545
576
  for (const accountProxy of accountProxies) {
546
- // Have 4 network types, but at the moment, we only support 3 network types
547
- if (chainTypes.size === 3) {
548
- break;
549
- }
550
577
  for (const chainType of accountProxy.chainTypes) {
551
578
  chainTypes.add(chainType);
552
579
  }
553
- }
554
- for (const accountProxy of accountProxies) {
555
580
  for (const tokenType of accountProxy.tokenTypes) {
556
581
  tokenTypes.add(tokenType);
557
582
  }
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.detectTransferTxType = exports.calculateXCMMaxTransferable = exports.calculateTransferMaxTransferable = exports.calculateMaxTransferable = void 0;
8
8
  var _constants = require("@subwallet/extension-base/constants");
9
9
  var _xcmParser = require("@subwallet/extension-base/core/substrate/xcm-parser");
10
+ var _consts = require("@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/consts");
11
+ var _cardanoTransfer = require("@subwallet/extension-base/services/balance-service/transfer/cardano-transfer");
10
12
  var _smartContract = require("@subwallet/extension-base/services/balance-service/transfer/smart-contract");
11
13
  var _token = require("@subwallet/extension-base/services/balance-service/transfer/token");
12
14
  var _tonTransfer = require("@subwallet/extension-base/services/balance-service/transfer/ton-transfer");
@@ -39,6 +41,8 @@ const detectTransferTxType = (srcToken, srcChain, destChain) => {
39
41
  return 'evm';
40
42
  } else if ((0, _utils._isChainTonCompatible)(srcChain) && (0, _utils._isTokenTransferredByTon)(srcToken)) {
41
43
  return 'ton';
44
+ } else if ((0, _utils._isChainCardanoCompatible)(srcChain) && (0, _utils._isTokenTransferredByCardano)(srcToken)) {
45
+ return 'cardano';
42
46
  } else {
43
47
  return 'substrate';
44
48
  }
@@ -64,6 +68,7 @@ exports.calculateMaxTransferable = calculateMaxTransferable;
64
68
  const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) => {
65
69
  const {
66
70
  address,
71
+ cardanoApi,
67
72
  destChain,
68
73
  evmApi,
69
74
  feeCustom,
@@ -128,8 +133,21 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
128
133
  // currently not used
129
134
  tonApi
130
135
  });
136
+ } else if ((0, _keyring.isCardanoAddress)(address) && (0, _utils._isTokenTransferredByCardano)(srcToken)) {
137
+ const isTransferNativeToken = (0, _utils._isNativeToken)(srcToken);
138
+ [transaction] = await (0, _cardanoTransfer.createCardanoTransaction)({
139
+ tokenInfo: srcToken,
140
+ from: address,
141
+ to: address,
142
+ networkKey: srcChain.slug,
143
+ value: isTransferNativeToken ? '1000000' : '1',
144
+ cardanoTtlOffset: _consts.DEFAULT_CARDANO_TTL_OFFSET,
145
+ transferAll: false,
146
+ cardanoApi,
147
+ nativeTokenInfo: nativeToken
148
+ });
131
149
  } else {
132
- [transaction] = await (0, _token.createTransferExtrinsic)({
150
+ [transaction] = await (0, _token.createSubstrateExtrinsic)({
133
151
  transferAll: false,
134
152
  value: '0',
135
153
  from: address,
@@ -174,12 +192,27 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
174
192
  estimatedFee
175
193
  };
176
194
  } else {
177
- if (transaction && (0, _helpers.isTonTransaction)(transaction)) {
178
- estimatedFee = transaction.estimateFee;
179
- feeOptions = {
180
- ...fee,
181
- estimatedFee: estimatedFee
182
- };
195
+ if (transaction) {
196
+ if ((0, _helpers.isTonTransaction)(transaction)) {
197
+ estimatedFee = transaction.estimateFee;
198
+ feeOptions = {
199
+ ...fee,
200
+ estimatedFee: estimatedFee
201
+ };
202
+ } else if ((0, _helpers.isCardanoTransaction)(transaction)) {
203
+ estimatedFee = transaction.estimateCardanoFee;
204
+ feeOptions = {
205
+ ...fee,
206
+ estimatedFee: estimatedFee
207
+ };
208
+ } else {
209
+ // Not implemented yet
210
+ estimatedFee = '0';
211
+ feeOptions = {
212
+ ...fee,
213
+ estimatedFee: '0'
214
+ };
215
+ }
183
216
  } else {
184
217
  // Not implemented yet
185
218
  estimatedFee = '0';
@@ -577,8 +577,8 @@ function isAddressAndChainCompatible(address, chain) {
577
577
  const isEvmCompatible = (0, _utilCrypto.isEthereumAddress)(address) && (0, _utils._isChainEvmCompatible)(chain);
578
578
  const isTonCompatible = (0, _keyring.isTonAddress)(address) && (0, _utils._isChainTonCompatible)(chain);
579
579
  const isSubstrateCompatible = !(0, _utilCrypto.isEthereumAddress)(address) && !(0, _keyring.isTonAddress)(address) && (0, _utils._isChainSubstrateCompatible)(chain); // todo: need isSubstrateAddress util function to check exactly
580
-
581
- return isEvmCompatible || isSubstrateCompatible || isTonCompatible;
580
+ const isCardanoCompatible = (0, _keyring.isCardanoAddress)(address) && (0, _utils._isChainCardanoCompatible)(chain);
581
+ return isEvmCompatible || isSubstrateCompatible || isTonCompatible || isCardanoCompatible;
582
582
  }
583
583
  function getDomainFromUrl(url) {
584
584
  return url.replace(/^(https?:\/\/)?(www\.)?/, '').split('/')[0];
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.termAndCondition = exports.staticData = exports.remindNotificationTime = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.blockedActionsFeatures = exports.blockedActions = exports.StaticKey = void 0;
6
+ exports.termAndCondition = exports.staticData = exports.remindNotificationTime = exports.oldChainPrefix = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.blockedActionsFeatures = exports.blockedActions = exports.StaticKey = void 0;
7
7
  var _chainList = require("@subwallet/chain-list");
8
8
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
9
9
  // SPDX-License-Identifier: Apache-2.0
@@ -36,7 +36,10 @@ const remindNotificationTime = require('./remindNotificationTime.json');
36
36
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
37
37
  exports.remindNotificationTime = remindNotificationTime;
38
38
  const blockedActions = require('./blockedActions.json');
39
+ // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
39
40
  exports.blockedActions = blockedActions;
41
+ const oldChainPrefix = require('./oldChainPrefix.json');
42
+ exports.oldChainPrefix = oldChainPrefix;
40
43
  let StaticKey;
41
44
  exports.StaticKey = StaticKey;
42
45
  (function (StaticKey) {
@@ -50,6 +53,7 @@ exports.StaticKey = StaticKey;
50
53
  StaticKey["BLOCKED_ACTIONS_FEATURES"] = "blocked-actions-features";
51
54
  StaticKey["REMIND_NOTIFICATION_TIME"] = "remind-notification-time";
52
55
  StaticKey["BLOCKED_ACTIONS"] = "blocked-actions";
56
+ StaticKey["OLD_CHAIN_PREFIX"] = "old-chain-prefix";
53
57
  })(StaticKey || (exports.StaticKey = StaticKey = {}));
54
58
  const staticData = {
55
59
  [StaticKey.CHAINS]: Object.values(_chainList.ChainInfoMap),
@@ -61,6 +65,7 @@ const staticData = {
61
65
  [StaticKey.BUY_TOKEN_CONFIGS]: buyTokenConfigs,
62
66
  [StaticKey.BLOCKED_ACTIONS_FEATURES]: blockedActionsFeatures,
63
67
  [StaticKey.REMIND_NOTIFICATION_TIME]: remindNotificationTime,
64
- [StaticKey.BLOCKED_ACTIONS]: blockedActions
68
+ [StaticKey.BLOCKED_ACTIONS]: blockedActions,
69
+ [StaticKey.OLD_CHAIN_PREFIX]: oldChainPrefix
65
70
  };
66
71
  exports.staticData = staticData;
@@ -1 +1,2 @@
1
1
  export declare const isProductionMode: boolean;
2
+ export declare const BACKEND_API_URL: string;
@@ -3,4 +3,5 @@
3
3
 
4
4
  const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
5
5
  const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
6
- export const isProductionMode = PRODUCTION_BRANCHES.indexOf(branchName) > -1;
6
+ export const isProductionMode = PRODUCTION_BRANCHES.indexOf(branchName) > -1;
7
+ export const BACKEND_API_URL = process.env.SUBWALLET_API || (isProductionMode ? 'https://sw-services.subwallet.app/api' : 'https://sw-services.subwallet.app/api'); // TODO: Rollback dev URL
@@ -6,10 +6,14 @@ import { AccountChainType } from '@subwallet/extension-base/types';
6
6
  export const SIGNING_COMPATIBLE_MAP = {
7
7
  [ChainType.SUBSTRATE]: [AccountChainType.SUBSTRATE, AccountChainType.ETHEREUM],
8
8
  [ChainType.EVM]: [AccountChainType.ETHEREUM],
9
- [ChainType.TON]: [AccountChainType.TON]
9
+ [ChainType.BITCOIN]: [AccountChainType.BITCOIN],
10
+ [ChainType.TON]: [AccountChainType.TON],
11
+ [ChainType.CARDANO]: [AccountChainType.CARDANO]
10
12
  };
11
13
  export const LEDGER_SIGNING_COMPATIBLE_MAP = {
12
14
  [ChainType.SUBSTRATE]: [AccountChainType.SUBSTRATE],
13
15
  [ChainType.EVM]: [AccountChainType.ETHEREUM],
14
- [ChainType.TON]: [AccountChainType.TON]
16
+ [ChainType.BITCOIN]: [AccountChainType.BITCOIN],
17
+ [ChainType.TON]: [AccountChainType.TON],
18
+ [ChainType.CARDANO]: [AccountChainType.CARDANO]
15
19
  };
@@ -2,10 +2,10 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { ActionType, ValidationCondition } from '@subwallet/extension-base/core/types';
5
- import { _isAddress, _isNotDuplicateAddress, _isNotNull, _isSupportLedgerAccount, _isValidAddressForEcosystem, _isValidSubstrateAddressFormat, _isValidTonAddressFormat } from '@subwallet/extension-base/core/utils';
5
+ import { _isAddress, _isNotDuplicateAddress, _isNotNull, _isSupportLedgerAccount, _isValidAddressForEcosystem, _isValidCardanoAddressFormat, _isValidSubstrateAddressFormat, _isValidTonAddressFormat } from '@subwallet/extension-base/core/utils';
6
6
  import { AccountSignMode } from '@subwallet/extension-base/types';
7
7
  import { detectTranslate } from '@subwallet/extension-base/utils';
8
- import { isSubstrateAddress, isTonAddress } from '@subwallet/keyring';
8
+ import { isCardanoAddress, isSubstrateAddress, isTonAddress } from '@subwallet/keyring';
9
9
  function getConditions(validateRecipientParams) {
10
10
  const {
11
11
  account,
@@ -27,7 +27,10 @@ function getConditions(validateRecipientParams) {
27
27
  if (isTonAddress(toAddress)) {
28
28
  conditions.push(ValidationCondition.IS_VALID_TON_ADDRESS_FORMAT);
29
29
  }
30
- if (srcChain === destChainInfo.slug && isSendAction && !destChainInfo.tonInfo) {
30
+ if (isCardanoAddress(toAddress)) {
31
+ conditions.push(ValidationCondition.IS_VALID_CARDANO_ADDRESS_FORMAT);
32
+ }
33
+ if (srcChain === destChainInfo.slug && isSendAction && !destChainInfo.tonInfo && !destChainInfo.cardanoInfo) {
31
34
  conditions.push(ValidationCondition.IS_NOT_DUPLICATE_ADDRESS);
32
35
  }
33
36
  if (account !== null && account !== void 0 && account.isHardware) {
@@ -67,6 +70,11 @@ function getValidationFunctions(conditions) {
67
70
  validationFunctions.push(_isValidTonAddressFormat);
68
71
  break;
69
72
  }
73
+ case ValidationCondition.IS_VALID_CARDANO_ADDRESS_FORMAT:
74
+ {
75
+ validationFunctions.push(_isValidCardanoAddressFormat);
76
+ break;
77
+ }
70
78
  case ValidationCondition.IS_NOT_DUPLICATE_ADDRESS:
71
79
  {
72
80
  validationFunctions.push(_isNotDuplicateAddress);
@@ -6,14 +6,15 @@ import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
6
6
  import { TransactionWarning } from '@subwallet/extension-base/background/warnings/TransactionWarning';
7
7
  import { LEDGER_SIGNING_COMPATIBLE_MAP, SIGNING_COMPATIBLE_MAP, XCM_MIN_AMOUNT_RATIO } from '@subwallet/extension-base/constants';
8
8
  import { _canAccountBeReaped, _isAccountActive } from '@subwallet/extension-base/core/substrate/system-pallet';
9
+ import { getCardanoAssetId } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/utils';
9
10
  import { isBounceableAddress } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils';
10
11
  import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
11
- import { _getAssetDecimals, _getChainExistentialDeposit, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getTokenMinAmount, _isNativeToken, _isTokenEvmSmartContract, _isTokenTonSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
12
+ import { _getAssetDecimals, _getChainExistentialDeposit, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getTokenMinAmount, _isCIP26Token, _isNativeToken, _isTokenEvmSmartContract, _isTokenTonSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
12
13
  import { calculateToAmountByReservePool, FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE } from '@subwallet/extension-base/services/fee-service/utils';
13
- import { isSubstrateTransaction, isTonTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
14
+ import { isCardanoTransaction, isSubstrateTransaction, isTonTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
14
15
  import { AccountSignMode, BasicTxErrorType, BasicTxWarningCode, TransferTxErrorType } from '@subwallet/extension-base/types';
15
16
  import { balanceFormatter, combineEthFee, formatNumber, pairToAccount } from '@subwallet/extension-base/utils';
16
- import { isTonAddress } from '@subwallet/keyring';
17
+ import { isCardanoAddress, isTonAddress } from '@subwallet/keyring';
17
18
  import { keyring } from '@subwallet/ui-keyring';
18
19
  import BigN from 'bignumber.js';
19
20
  import { t } from 'i18next';
@@ -36,6 +37,9 @@ export function validateTransferRequest(tokenInfo, from, to, value, transferAll)
36
37
  if (isTonAddress(from) && isTonAddress(to) && _isTokenTonSmartContract(tokenInfo) && _getContractAddressOfToken(tokenInfo).length === 0) {
37
38
  errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, t('Not found TEP74 address for this token')));
38
39
  }
40
+ if (isCardanoAddress(from) && isCardanoAddress(to) && _isCIP26Token(tokenInfo) && getCardanoAssetId(tokenInfo).length === 0) {
41
+ errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, t('Not found policy id of this token')));
42
+ }
39
43
  return errors;
40
44
  }
41
45
  export function additionalValidateTransferForRecipient(sendingTokenInfo, nativeTokenInfo, extrinsicType, receiverSendingTokenKeepAliveBalance, transferAmount, senderSendingTokenTransferable, receiverSystemAccountInfo, isSendingTokenSufficient) {
@@ -346,6 +350,8 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
346
350
  estimateFee.value = (await transaction.paymentInfo(validationResponse.address)).partialFee.toString();
347
351
  } else if (isTonTransaction(transaction)) {
348
352
  estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
353
+ } else if (isCardanoTransaction(transaction)) {
354
+ estimateFee.value = transaction.estimateCardanoFee;
349
355
  } else {
350
356
  const gasLimit = transaction.gas || (await evmApi.api.eth.estimateGas(transaction));
351
357
  const feeCombine = combineEthFee(feeInfo, validationResponse.feeOption, validationResponse.feeCustom);
@@ -1,6 +1,6 @@
1
1
  import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
2
2
  import { _Address } from '@subwallet/extension-base/background/KoniTypes';
3
- export declare function _getXcmDestWeight(originChainInfo: _ChainInfo): 5000000000 | "Unlimited";
3
+ export declare function _getXcmDestWeight(originChainInfo: _ChainInfo): "Unlimited" | 5000000000;
4
4
  export declare function _getXcmBeneficiary(destChainInfo: _ChainInfo, recipient: _Address, version: number): {
5
5
  [x: string]: {
6
6
  parents: number;
package/core/types.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare enum ValidationCondition {
7
7
  IS_VALID_ADDRESS_FOR_ECOSYSTEM = "IS_VALID_ADDRESS_FOR_ECOSYSTEM",
8
8
  IS_VALID_SUBSTRATE_ADDRESS_FORMAT = "IS_VALID_SUBSTRATE_ADDRESS_FORMAT",
9
9
  IS_VALID_TON_ADDRESS_FORMAT = "IS_VALID_TON_ADDRESS_FORMAT",
10
+ IS_VALID_CARDANO_ADDRESS_FORMAT = "IS_VALID_CARDANO_ADDRESS_FORMAT",
10
11
  IS_NOT_DUPLICATE_ADDRESS = "IS_NOT_DUPLICATE_ADDRESS",
11
12
  IS_SUPPORT_LEDGER_ACCOUNT = "IS_SUPPORT_LEDGER_ACCOUNT"
12
13
  }
package/core/types.js CHANGED
@@ -8,6 +8,7 @@ export let ValidationCondition;
8
8
  ValidationCondition["IS_VALID_ADDRESS_FOR_ECOSYSTEM"] = "IS_VALID_ADDRESS_FOR_ECOSYSTEM";
9
9
  ValidationCondition["IS_VALID_SUBSTRATE_ADDRESS_FORMAT"] = "IS_VALID_SUBSTRATE_ADDRESS_FORMAT";
10
10
  ValidationCondition["IS_VALID_TON_ADDRESS_FORMAT"] = "IS_VALID_TON_ADDRESS_FORMAT";
11
+ ValidationCondition["IS_VALID_CARDANO_ADDRESS_FORMAT"] = "IS_VALID_CARDANO_ADDRESS_FORMAT";
11
12
  ValidationCondition["IS_NOT_DUPLICATE_ADDRESS"] = "IS_NOT_DUPLICATE_ADDRESS";
12
13
  ValidationCondition["IS_SUPPORT_LEDGER_ACCOUNT"] = "IS_SUPPORT_LEDGER_ACCOUNT";
13
14
  })(ValidationCondition || (ValidationCondition = {}));
package/core/utils.d.ts CHANGED
@@ -10,5 +10,6 @@ export declare function _isAddress(validateRecipientParams: ValidateRecipientPar
10
10
  export declare function _isValidAddressForEcosystem(validateRecipientParams: ValidateRecipientParams): string;
11
11
  export declare function _isValidSubstrateAddressFormat(validateRecipientParams: ValidateRecipientParams): string;
12
12
  export declare function _isValidTonAddressFormat(validateRecipientParams: ValidateRecipientParams): string;
13
+ export declare function _isValidCardanoAddressFormat(validateRecipientParams: ValidateRecipientParams): string;
13
14
  export declare function _isNotDuplicateAddress(validateRecipientParams: ValidateRecipientParams): string;
14
15
  export declare function _isSupportLedgerAccount(validateRecipientParams: ValidateRecipientParams): string;
package/core/utils.js CHANGED
@@ -4,9 +4,9 @@
4
4
  import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
5
5
  import { BalanceAccountType } from '@subwallet/extension-base/core/substrate/types';
6
6
  import { tonAddressInfo } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils';
7
- import { _isChainEvmCompatible, _isChainSubstrateCompatible, _isChainTonCompatible } from '@subwallet/extension-base/services/chain-service/utils';
7
+ import { _isChainCardanoCompatible, _isChainEvmCompatible, _isChainSubstrateCompatible, _isChainTonCompatible } from '@subwallet/extension-base/services/chain-service/utils';
8
8
  import { isAddressAndChainCompatible, isSameAddress, reformatAddress } from '@subwallet/extension-base/utils';
9
- import { isAddress, isTonAddress } from '@subwallet/keyring';
9
+ import { isAddress, isCardanoTestnetAddress, isTonAddress } from '@subwallet/keyring';
10
10
  import { isEthereumAddress } from '@polkadot/util-crypto';
11
11
  export function getStrictMode(type, extrinsicType) {
12
12
  if (type === BalanceAccountType.FrameSystemAccountInfo) {
@@ -54,7 +54,7 @@ export function _isValidAddressForEcosystem(validateRecipientParams) {
54
54
  toAddress
55
55
  } = validateRecipientParams;
56
56
  if (!isAddressAndChainCompatible(toAddress, destChainInfo)) {
57
- if (_isChainEvmCompatible(destChainInfo) || _isChainSubstrateCompatible(destChainInfo) || _isChainTonCompatible(destChainInfo)) {
57
+ if (_isChainEvmCompatible(destChainInfo) || _isChainSubstrateCompatible(destChainInfo) || _isChainTonCompatible(destChainInfo) || _isChainCardanoCompatible(destChainInfo)) {
58
58
  return 'Recipient address must be the same type as sender address';
59
59
  }
60
60
  return 'Unknown chain type';
@@ -85,6 +85,16 @@ export function _isValidTonAddressFormat(validateRecipientParams) {
85
85
  }
86
86
  return '';
87
87
  }
88
+ export function _isValidCardanoAddressFormat(validateRecipientParams) {
89
+ const {
90
+ destChainInfo,
91
+ toAddress
92
+ } = validateRecipientParams;
93
+ if (isCardanoTestnetAddress(toAddress) !== destChainInfo.isTestnet) {
94
+ return `Recipient address must be a valid ${destChainInfo.name} address`;
95
+ }
96
+ return '';
97
+ }
88
98
  export function _isNotDuplicateAddress(validateRecipientParams) {
89
99
  const {
90
100
  fromAddress,
package/defaults.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const ALLOWED_PATH: readonly ["/", "/settings/security", "/transaction-submission", "/accounts/connect-ledger", "/accounts/restore-json", "/accounts/detail", "/accounts/new-seed-phrase"];
1
+ declare const ALLOWED_PATH: readonly ["/", "/settings/security", "/transaction-submission", "/accounts/connect-ledger", "/accounts/restore-json", "/accounts/detail", "/accounts/new-seed-phrase", "/migrate-account"];
2
2
  declare const PHISHING_PAGE_REDIRECT = "/phishing-page-detected";
3
3
  declare const EXTENSION_PREFIX: string;
4
4
  declare const ID_PREFIX: string;
package/defaults.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright 2019-2022 @polkadot/extension-base authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- const ALLOWED_PATH = ['/', '/settings/security', '/transaction-submission', '/accounts/connect-ledger', '/accounts/restore-json', '/accounts/detail', '/accounts/new-seed-phrase'];
4
+ const ALLOWED_PATH = ['/', '/settings/security', '/transaction-submission', '/accounts/connect-ledger', '/accounts/restore-json', '/accounts/detail', '/accounts/new-seed-phrase', '/migrate-account'];
5
5
  const PHISHING_PAGE_REDIRECT = '/phishing-page-detected';
6
6
  const EXTENSION_PREFIX = process.env.EXTENSION_PREFIX || '';
7
7
  const ID_PREFIX = process.env.ID_PREFIX || EXTENSION_PREFIX || '';
@@ -3,10 +3,10 @@
3
3
 
4
4
  import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
5
5
  import { _FundStatus } from '@subwallet/chain-list/types';
6
- import { APIItemState, CrowdloanParaState } from '@subwallet/extension-base/background/KoniTypes';
6
+ import { APIItemState, ChainType, CrowdloanParaState } from '@subwallet/extension-base/background/KoniTypes';
7
7
  import { ACALA_REFRESH_CROWDLOAN_INTERVAL } from '@subwallet/extension-base/constants';
8
8
  import registry from '@subwallet/extension-base/koni/api/dotsama/typeRegistry';
9
- import { categoryAddresses, fetchJson, reformatAddress } from '@subwallet/extension-base/utils';
9
+ import { fetchJson, getAddressesByChainType, reformatAddress } from '@subwallet/extension-base/utils';
10
10
  import { fetchStaticData } from '@subwallet/extension-base/utils/fetchStaticData';
11
11
  import { BN } from '@polkadot/util';
12
12
  const STATUS_MAP = {
@@ -164,7 +164,7 @@ export async function subscribeCrowdloan(addresses, substrateApiMap, callback) {
164
164
  const now = Date.now();
165
165
  const polkadotAPI = await substrateApiMap[COMMON_CHAIN_SLUGS.POLKADOT].isReady;
166
166
  const kusamaAPI = await substrateApiMap[COMMON_CHAIN_SLUGS.KUSAMA].isReady;
167
- const substrateAddresses = categoryAddresses(addresses).substrate;
167
+ const substrateAddresses = getAddressesByChainType(addresses, [ChainType.SUBSTRATE]);
168
168
  const hexAddresses = substrateAddresses.map(address => {
169
169
  return registry.createType('AccountId', address).toHex();
170
170
  });
@@ -1,6 +1,7 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { ChainType } from '@subwallet/extension-base/background/KoniTypes';
4
5
  import { AcalaNftApi } from '@subwallet/extension-base/koni/api/nft/acala_nft';
5
6
  import AssetHubUniquesPalletApi from '@subwallet/extension-base/koni/api/nft/assethub_unique';
6
7
  import { BitCountryNftApi } from '@subwallet/extension-base/koni/api/nft/bit.country';
@@ -10,21 +11,18 @@ import { KaruraNftApi } from '@subwallet/extension-base/koni/api/nft/karura_nft'
10
11
  import OrdinalNftApi from '@subwallet/extension-base/koni/api/nft/ordinal_nft';
11
12
  import { RmrkNftApi } from '@subwallet/extension-base/koni/api/nft/rmrk_nft';
12
13
  import { UniqueNftApi } from '@subwallet/extension-base/koni/api/nft/unique_network_nft';
13
- // import UniqueNftApi from '@subwallet/extension-base/koni/api/nft/unique_nft';
14
14
  import { VaraNftApi } from '@subwallet/extension-base/koni/api/nft/vara_nft';
15
15
  import { WasmNftApi } from '@subwallet/extension-base/koni/api/nft/wasm_nft';
16
16
  import { _NFT_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
17
17
  import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft, _isSupportOrdinal } from '@subwallet/extension-base/services/chain-service/utils';
18
- import { categoryAddresses, targetIsWeb } from '@subwallet/extension-base/utils';
18
+ import { getAddressesByChainType, targetIsWeb } from '@subwallet/extension-base/utils';
19
19
  import AssetHubNftsPalletApi from "./assethub_nft/index.js";
20
20
  import { RariNftApi } from "./rari/index.js";
21
21
  import { OdysseyNftApi } from "./story_odyssey_nft/index.js";
22
22
  import { TernoaNftApi } from "./ternoa_nft/index.js";
23
23
  function createSubstrateNftApi(chain, substrateApi, addresses) {
24
- const {
25
- evm: evmAddresses,
26
- substrate: substrateAddresses
27
- } = categoryAddresses(addresses);
24
+ const evmAddresses = getAddressesByChainType(addresses, [ChainType.EVM]);
25
+ const substrateAddresses = getAddressesByChainType(addresses, [ChainType.SUBSTRATE]);
28
26
  if (_NFT_CHAIN_GROUP.acala.includes(chain)) {
29
27
  return [new AcalaNftApi(substrateApi, substrateAddresses, chain)];
30
28
  } else if (_NFT_CHAIN_GROUP.karura.includes(chain)) {
@@ -55,11 +53,11 @@ function createSubstrateNftApi(chain, substrateApi, addresses) {
55
53
  return null;
56
54
  }
57
55
  function createWasmNftApi(chain, apiProps, addresses) {
58
- const substrateAddresses = categoryAddresses(addresses).substrate;
56
+ const substrateAddresses = getAddressesByChainType(addresses, [ChainType.SUBSTRATE]);
59
57
  return new WasmNftApi(apiProps, substrateAddresses, chain);
60
58
  }
61
59
  function createWeb3NftApi(chain, evmApi, addresses) {
62
- const evmAddresses = categoryAddresses(addresses).evm;
60
+ const evmAddresses = getAddressesByChainType(addresses, [ChainType.EVM]);
63
61
  return new EvmNftApi(evmApi, evmAddresses, chain);
64
62
  }
65
63
  const createOrdinalApi = (chain, subscanChain, addresses) => {
@@ -93,10 +91,8 @@ export class NftHandler {
93
91
  }
94
92
  setAddresses(addresses) {
95
93
  this.addresses = addresses;
96
- const {
97
- evm: evmAddresses,
98
- substrate: substrateAddresses
99
- } = categoryAddresses(addresses);
94
+ const evmAddresses = getAddressesByChainType(addresses, [ChainType.EVM]);
95
+ const substrateAddresses = getAddressesByChainType(addresses, [ChainType.SUBSTRATE]);
100
96
  for (const handler of this.handlers) {
101
97
  const useAddresses = handler.isEthereum ? evmAddresses : substrateAddresses;
102
98
  handler.setAddresses(useAddresses);
@@ -121,10 +117,8 @@ export class NftHandler {
121
117
  if (this.needSetupApi) {
122
118
  // setup connections for first time use
123
119
  this.handlers = [];
124
- const {
125
- evm: evmAddresses,
126
- substrate: substrateAddresses
127
- } = categoryAddresses(this.addresses);
120
+ const evmAddresses = getAddressesByChainType(this.addresses, [ChainType.EVM]);
121
+ const substrateAddresses = getAddressesByChainType(this.addresses, [ChainType.SUBSTRATE]);
128
122
  Object.entries(this.chainInfoMap).forEach(([chain, chainInfo]) => {
129
123
  if (_isChainSupportNativeNft(chainInfo)) {
130
124
  if (this.substrateApiMap[chain]) {