@subwallet/extension-base 1.3.40-0 → 1.3.42-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 (232) hide show
  1. package/background/KoniTypes.d.ts +121 -4
  2. package/background/KoniTypes.js +18 -0
  3. package/background/errors/BitcoinProviderError.d.ts +6 -0
  4. package/background/errors/BitcoinProviderError.js +47 -0
  5. package/cjs/background/KoniTypes.js +20 -1
  6. package/cjs/background/errors/BitcoinProviderError.js +54 -0
  7. package/cjs/constants/bitcoin.js +22 -0
  8. package/cjs/constants/environment.js +4 -2
  9. package/cjs/constants/index.js +16 -1
  10. package/cjs/core/logic-validation/recipientAddress.js +9 -0
  11. package/cjs/core/logic-validation/transfer.js +25 -5
  12. package/cjs/core/types.js +1 -0
  13. package/cjs/core/utils.js +15 -1
  14. package/cjs/koni/background/handlers/Extension.js +96 -41
  15. package/cjs/koni/background/handlers/State.js +52 -11
  16. package/cjs/packageInfo.js +1 -1
  17. package/cjs/services/balance-service/helpers/subscribe/bitcoin.js +94 -0
  18. package/cjs/services/balance-service/helpers/subscribe/evm.js +6 -1
  19. package/cjs/services/balance-service/helpers/subscribe/index.js +19 -7
  20. package/cjs/services/balance-service/index.js +32 -4
  21. package/cjs/services/balance-service/transfer/bitcoin-transfer.js +119 -0
  22. package/cjs/services/balance-service/transfer/token.js +2 -0
  23. package/cjs/services/balance-service/transfer/xcm/index.js +15 -9
  24. package/cjs/services/balance-service/transfer/xcm/utils.js +12 -14
  25. package/cjs/services/base/types.js +2 -0
  26. package/cjs/services/chain-service/constants.js +18 -6
  27. package/cjs/services/chain-service/handler/CardanoApi.js +25 -35
  28. package/cjs/services/chain-service/handler/bitcoin/BitcoinApi.js +105 -0
  29. package/cjs/services/chain-service/handler/bitcoin/BitcoinChainHandler.js +78 -0
  30. package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.js +371 -0
  31. package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.js +19 -0
  32. package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.js +368 -0
  33. package/cjs/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.js +302 -0
  34. package/cjs/services/chain-service/handler/bitcoin/strategy/types.js +1 -0
  35. package/cjs/services/chain-service/index.js +27 -3
  36. package/cjs/services/chain-service/utils/index.js +57 -4
  37. package/cjs/services/chain-service/utils/patch.js +1 -1
  38. package/cjs/services/earning-service/handlers/native-staking/tao.js +4 -38
  39. package/cjs/services/event-service/index.js +4 -0
  40. package/cjs/services/fee-service/service.js +8 -3
  41. package/cjs/services/hiro-service/index.js +96 -0
  42. package/cjs/services/hiro-service/utils/index.js +85 -0
  43. package/cjs/services/history-service/bitcoin-history.js +58 -0
  44. package/cjs/services/history-service/helpers/recoverHistoryStatus.js +96 -4
  45. package/cjs/services/history-service/index.js +41 -3
  46. package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
  47. package/cjs/services/keyring-service/context/handlers/Migration.js +2 -2
  48. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +4 -3
  49. package/cjs/services/migration-service/scripts/MigrateNewUnifiedAccount.js +29 -0
  50. package/cjs/services/migration-service/scripts/index.js +3 -1
  51. package/cjs/services/request-service/handler/BitcoinRequestHandler.js +440 -0
  52. package/cjs/services/request-service/index.js +29 -3
  53. package/cjs/services/rune-service/index.js +105 -0
  54. package/cjs/services/swap-service/handler/chainflip-handler.js +29 -18
  55. package/cjs/services/swap-service/handler/kyber-handler.js +5 -9
  56. package/cjs/services/swap-service/handler/simpleswap-handler.js +4 -7
  57. package/cjs/services/swap-service/handler/uniswap-handler.js +5 -12
  58. package/cjs/services/swap-service/utils.js +46 -37
  59. package/cjs/services/transaction-service/helpers/index.js +7 -1
  60. package/cjs/services/transaction-service/index.js +136 -15
  61. package/cjs/services/transaction-service/utils.js +6 -3
  62. package/cjs/strategy/api-request-strategy/context/base.js +31 -0
  63. package/cjs/strategy/api-request-strategy/index.js +90 -0
  64. package/cjs/strategy/api-request-strategy/types.js +1 -0
  65. package/cjs/strategy/api-request-strategy/utils/index.js +33 -0
  66. package/cjs/types/account/info/keyring.js +1 -1
  67. package/cjs/types/bitcoin.js +24 -0
  68. package/cjs/types/environment.js +19 -0
  69. package/cjs/types/fee/bitcoin.js +1 -0
  70. package/cjs/types/fee/index.js +11 -0
  71. package/cjs/types/index.js +11 -0
  72. package/cjs/utils/account/analyze.js +3 -3
  73. package/cjs/utils/account/common.js +16 -6
  74. package/cjs/utils/account/derive/info/solo.js +68 -19
  75. package/cjs/utils/account/derive/info/unified.js +2 -0
  76. package/cjs/utils/account/derive/validate.js +70 -2
  77. package/cjs/utils/account/transform.js +11 -5
  78. package/cjs/utils/bitcoin/common.js +98 -0
  79. package/cjs/utils/bitcoin/fee.js +21 -0
  80. package/cjs/utils/bitcoin/index.js +38 -0
  81. package/cjs/utils/bitcoin/utxo-management.js +281 -0
  82. package/cjs/utils/environment.js +30 -2
  83. package/cjs/utils/fee/transfer.js +48 -0
  84. package/cjs/utils/index.js +15 -1
  85. package/constants/bitcoin.d.ts +3 -0
  86. package/constants/bitcoin.js +13 -0
  87. package/constants/environment.d.ts +1 -0
  88. package/constants/environment.js +2 -1
  89. package/constants/index.d.ts +2 -0
  90. package/constants/index.js +3 -1
  91. package/core/logic-validation/recipientAddress.js +10 -1
  92. package/core/logic-validation/transfer.d.ts +2 -2
  93. package/core/logic-validation/transfer.js +27 -7
  94. package/core/types.d.ts +1 -0
  95. package/core/types.js +1 -0
  96. package/core/utils.d.ts +1 -0
  97. package/core/utils.js +15 -2
  98. package/koni/background/handlers/Extension.d.ts +2 -0
  99. package/koni/background/handlers/Extension.js +95 -42
  100. package/koni/background/handlers/State.d.ts +7 -3
  101. package/koni/background/handlers/State.js +52 -12
  102. package/package.json +149 -8
  103. package/packageInfo.js +1 -1
  104. package/services/balance-service/helpers/subscribe/bitcoin.d.ts +2 -0
  105. package/services/balance-service/helpers/subscribe/bitcoin.js +87 -0
  106. package/services/balance-service/helpers/subscribe/evm.js +6 -1
  107. package/services/balance-service/helpers/subscribe/index.d.ts +2 -2
  108. package/services/balance-service/helpers/subscribe/index.js +20 -8
  109. package/services/balance-service/index.d.ts +2 -0
  110. package/services/balance-service/index.js +32 -4
  111. package/services/balance-service/transfer/bitcoin-transfer.d.ts +14 -0
  112. package/services/balance-service/transfer/bitcoin-transfer.js +112 -0
  113. package/services/balance-service/transfer/token.js +2 -0
  114. package/services/balance-service/transfer/xcm/index.js +15 -9
  115. package/services/balance-service/transfer/xcm/utils.d.ts +2 -0
  116. package/services/balance-service/transfer/xcm/utils.js +12 -14
  117. package/services/base/types.d.ts +2 -0
  118. package/services/base/types.js +2 -0
  119. package/services/chain-service/constants.d.ts +7 -0
  120. package/services/chain-service/constants.js +12 -5
  121. package/services/chain-service/handler/CardanoApi.d.ts +1 -5
  122. package/services/chain-service/handler/CardanoApi.js +26 -34
  123. package/services/chain-service/handler/bitcoin/BitcoinApi.d.ts +31 -0
  124. package/services/chain-service/handler/bitcoin/BitcoinApi.js +98 -0
  125. package/services/chain-service/handler/bitcoin/BitcoinChainHandler.d.ts +16 -0
  126. package/services/chain-service/handler/bitcoin/BitcoinChainHandler.js +70 -0
  127. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.d.ts +28 -0
  128. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.js +362 -0
  129. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.d.ts +2 -0
  130. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.js +5 -0
  131. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.d.ts +28 -0
  132. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.js +359 -0
  133. package/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.d.ts +28 -0
  134. package/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.js +293 -0
  135. package/services/chain-service/handler/bitcoin/strategy/types.d.ts +291 -0
  136. package/services/chain-service/handler/bitcoin/strategy/types.js +1 -0
  137. package/services/chain-service/index.d.ts +3 -0
  138. package/services/chain-service/index.js +31 -5
  139. package/services/chain-service/types.d.ts +20 -0
  140. package/services/chain-service/utils/index.d.ts +4 -0
  141. package/services/chain-service/utils/index.js +50 -4
  142. package/services/chain-service/utils/patch.js +1 -1
  143. package/services/earning-service/handlers/native-staking/tao.d.ts +0 -11
  144. package/services/earning-service/handlers/native-staking/tao.js +4 -24
  145. package/services/event-service/index.d.ts +3 -0
  146. package/services/event-service/index.js +4 -0
  147. package/services/event-service/types.d.ts +3 -0
  148. package/services/fee-service/service.js +8 -3
  149. package/services/hiro-service/index.d.ts +17 -0
  150. package/services/hiro-service/index.js +88 -0
  151. package/services/hiro-service/utils/index.d.ts +6 -0
  152. package/services/hiro-service/utils/index.js +72 -0
  153. package/services/history-service/bitcoin-history.d.ts +4 -0
  154. package/services/history-service/bitcoin-history.js +52 -0
  155. package/services/history-service/helpers/recoverHistoryStatus.d.ts +3 -1
  156. package/services/history-service/helpers/recoverHistoryStatus.js +96 -4
  157. package/services/history-service/index.d.ts +1 -0
  158. package/services/history-service/index.js +42 -4
  159. package/services/keyring-service/context/handlers/Derive.js +2 -2
  160. package/services/keyring-service/context/handlers/Migration.js +2 -2
  161. package/services/keyring-service/context/handlers/Mnemonic.js +4 -3
  162. package/services/migration-service/scripts/MigrateNewUnifiedAccount.d.ts +4 -0
  163. package/services/migration-service/scripts/MigrateNewUnifiedAccount.js +21 -0
  164. package/services/migration-service/scripts/index.js +3 -1
  165. package/services/request-service/handler/BitcoinRequestHandler.d.ts +23 -0
  166. package/services/request-service/handler/BitcoinRequestHandler.js +427 -0
  167. package/services/request-service/index.d.ts +9 -2
  168. package/services/request-service/index.js +25 -3
  169. package/services/rune-service/index.d.ts +17 -0
  170. package/services/rune-service/index.js +97 -0
  171. package/services/swap-service/handler/chainflip-handler.d.ts +0 -2
  172. package/services/swap-service/handler/chainflip-handler.js +25 -13
  173. package/services/swap-service/handler/kyber-handler.d.ts +0 -1
  174. package/services/swap-service/handler/kyber-handler.js +5 -8
  175. package/services/swap-service/handler/simpleswap-handler.d.ts +0 -1
  176. package/services/swap-service/handler/simpleswap-handler.js +4 -6
  177. package/services/swap-service/handler/uniswap-handler.js +6 -13
  178. package/services/swap-service/utils.d.ts +0 -13
  179. package/services/swap-service/utils.js +46 -34
  180. package/services/transaction-service/helpers/index.d.ts +3 -1
  181. package/services/transaction-service/helpers/index.js +5 -0
  182. package/services/transaction-service/index.d.ts +3 -5
  183. package/services/transaction-service/index.js +135 -16
  184. package/services/transaction-service/types.d.ts +12 -2
  185. package/services/transaction-service/utils.js +7 -4
  186. package/strategy/api-request-strategy/context/base.d.ts +15 -0
  187. package/strategy/api-request-strategy/context/base.js +24 -0
  188. package/strategy/api-request-strategy/index.d.ts +15 -0
  189. package/strategy/api-request-strategy/index.js +83 -0
  190. package/strategy/api-request-strategy/types.d.ts +22 -0
  191. package/strategy/api-request-strategy/types.js +1 -0
  192. package/strategy/api-request-strategy/utils/index.d.ts +2 -0
  193. package/strategy/api-request-strategy/utils/index.js +23 -0
  194. package/types/account/info/keyring.d.ts +1 -1
  195. package/types/account/info/keyring.js +1 -1
  196. package/types/balance/index.d.ts +4 -1
  197. package/types/balance/transfer.d.ts +17 -0
  198. package/types/bitcoin.d.ts +93 -0
  199. package/types/bitcoin.js +17 -0
  200. package/types/environment.d.ts +9 -0
  201. package/types/environment.js +13 -0
  202. package/types/fee/base.d.ts +4 -1
  203. package/types/fee/bitcoin.d.ts +18 -0
  204. package/types/fee/bitcoin.js +1 -0
  205. package/types/fee/index.d.ts +1 -0
  206. package/types/fee/index.js +2 -1
  207. package/types/fee/subscription.d.ts +4 -3
  208. package/types/index.d.ts +1 -0
  209. package/types/index.js +1 -0
  210. package/utils/account/analyze.js +4 -4
  211. package/utils/account/common.d.ts +7 -8
  212. package/utils/account/common.js +16 -6
  213. package/utils/account/derive/info/solo.js +70 -21
  214. package/utils/account/derive/info/unified.js +2 -0
  215. package/utils/account/derive/validate.d.ts +1 -0
  216. package/utils/account/derive/validate.js +68 -1
  217. package/utils/account/transform.d.ts +1 -1
  218. package/utils/account/transform.js +11 -5
  219. package/utils/bitcoin/common.d.ts +22 -0
  220. package/utils/bitcoin/common.js +88 -0
  221. package/utils/bitcoin/fee.d.ts +2 -0
  222. package/utils/bitcoin/fee.js +14 -0
  223. package/utils/bitcoin/index.d.ts +3 -0
  224. package/utils/bitcoin/index.js +6 -0
  225. package/utils/bitcoin/utxo-management.d.ts +33 -0
  226. package/utils/bitcoin/utxo-management.js +266 -0
  227. package/utils/environment.d.ts +2 -0
  228. package/utils/environment.js +27 -1
  229. package/utils/fee/transfer.d.ts +3 -1
  230. package/utils/fee/transfer.js +47 -1
  231. package/utils/index.d.ts +1 -0
  232. package/utils/index.js +6 -3
@@ -6,6 +6,7 @@ export declare const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
6
6
  export declare const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
7
7
  export declare const ACALA_REFRESH_CROWDLOAN_INTERVAL = 300000;
8
8
  export declare const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
9
+ export declare const BITCOIN_REFRESH_BALANCE_INTERVAL = 600000;
9
10
  export declare const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
10
11
  export declare const CRON_REFRESH_NFT_INTERVAL = 7200000;
11
12
  export declare const CRON_REFRESH_MKT_CAMPAIGN_INTERVAL: number;
@@ -48,3 +49,4 @@ export * from './signing';
48
49
  export * from './staking';
49
50
  export * from './storage';
50
51
  export * from './remind-notification-time';
52
+ export * from './bitcoin';
@@ -8,6 +8,7 @@ export const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
8
8
  export const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
9
9
  export const ACALA_REFRESH_CROWDLOAN_INTERVAL = 300000;
10
10
  export const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
11
+ export const BITCOIN_REFRESH_BALANCE_INTERVAL = 600000;
11
12
  export const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
12
13
  export const CRON_REFRESH_NFT_INTERVAL = 7200000;
13
14
  export const CRON_REFRESH_MKT_CAMPAIGN_INTERVAL = 15 * BASE_MINUTE_INTERVAL;
@@ -57,4 +58,5 @@ export * from "./environment.js";
57
58
  export * from "./signing.js";
58
59
  export * from "./staking.js";
59
60
  export * from "./storage.js";
60
- export * from "./remind-notification-time.js";
61
+ export * from "./remind-notification-time.js";
62
+ export * from "./bitcoin.js";
@@ -2,10 +2,11 @@
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, _isValidCardanoAddressFormat, _isValidSubstrateAddressFormat, _isValidTonAddressFormat } from '@subwallet/extension-base/core/utils';
5
+ import { _isAddress, _isNotDuplicateAddress, _isNotNull, _isSupportLedgerAccount, _isValidAddressForEcosystem, _isValidBitcoinAddressFormat, _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
8
  import { isCardanoAddress, isSubstrateAddress, isTonAddress } from '@subwallet/keyring';
9
+ import { isBitcoinAddress } from '@subwallet/keyring/utils/address/validate';
9
10
  function getConditions(validateRecipientParams) {
10
11
  const {
11
12
  account,
@@ -30,6 +31,9 @@ function getConditions(validateRecipientParams) {
30
31
  if (isCardanoAddress(toAddress)) {
31
32
  conditions.push(ValidationCondition.IS_VALID_CARDANO_ADDRESS_FORMAT);
32
33
  }
34
+ if (isBitcoinAddress(toAddress)) {
35
+ conditions.push(ValidationCondition.IS_VALID_BITCOIN_ADDRESS_FORMAT);
36
+ }
33
37
  if (srcChain === destChainInfo.slug && isSendAction && !destChainInfo.tonInfo && !destChainInfo.cardanoInfo) {
34
38
  conditions.push(ValidationCondition.IS_NOT_DUPLICATE_ADDRESS);
35
39
  }
@@ -75,6 +79,11 @@ function getValidationFunctions(conditions) {
75
79
  validationFunctions.push(_isValidCardanoAddressFormat);
76
80
  break;
77
81
  }
82
+ case ValidationCondition.IS_VALID_BITCOIN_ADDRESS_FORMAT:
83
+ {
84
+ validationFunctions.push(_isValidBitcoinAddressFormat);
85
+ break;
86
+ }
78
87
  case ValidationCondition.IS_NOT_DUPLICATE_ADDRESS:
79
88
  {
80
89
  validationFunctions.push(_isNotDuplicateAddress);
@@ -5,7 +5,7 @@ import { TransactionWarning } from '@subwallet/extension-base/background/warning
5
5
  import { FrameSystemAccountInfo } from '@subwallet/extension-base/core/substrate/types';
6
6
  import { _EvmApi, _SubstrateApi, _TonApi } from '@subwallet/extension-base/services/chain-service/types';
7
7
  import { OptionalSWTransaction, SWTransactionInput, SWTransactionResponse } from '@subwallet/extension-base/services/transaction-service/types';
8
- import { EvmFeeInfo } from '@subwallet/extension-base/types';
8
+ import { FeeInfo } from '@subwallet/extension-base/types';
9
9
  import { KeyringPair } from '@subwallet/keyring/types';
10
10
  export declare function validateTransferRequest(tokenInfo: _ChainAsset, from: _Address, to: _Address, value: string | undefined, transferAll: boolean | undefined): TransactionError[];
11
11
  export declare function additionalValidateTransferForRecipient(sendingTokenInfo: _ChainAsset, nativeTokenInfo: _ChainAsset, extrinsicType: ExtrinsicType, receiverSendingTokenKeepAliveBalance: bigint, transferAmount: bigint, senderSendingTokenTransferable?: bigint, receiverSystemAccountInfo?: FrameSystemAccountInfo, isSendingTokenSufficient?: boolean): [TransactionWarning[], TransactionError[]];
@@ -13,7 +13,7 @@ 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: EvmFeeInfo, nativeTokenInfo: _ChainAsset, nonNativeTokenPayFeeInfo: _ChainAsset | undefined, isTransferLocalTokenAndPayThatTokenAsFee: boolean | undefined): Promise<FeeData>;
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
17
  export declare function checkSigningAccountForTransaction(validationResponse: SWTransactionResponse, chainInfoMap: Record<string, _ChainInfo>): void;
18
18
  export declare function checkBalanceWithTransactionFee(validationResponse: SWTransactionResponse, transactionInput: SWTransactionInput, nativeTokenInfo: _ChainAsset, nativeTokenAvailable: AmountData): void;
19
19
  export declare function checkTonAddressBounceableAndAccountNotActive(tonApi: _TonApi, validationResponse: SWTransactionResponse): Promise<void>;
@@ -11,9 +11,9 @@ import { isBounceableAddress } from '@subwallet/extension-base/services/balance-
11
11
  import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
12
12
  import { _getAssetDecimals, _getAssetPriceId, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getTokenMinAmount, _isCIP26Token, _isNativeToken, _isNativeTokenBySlug, _isTokenEvmSmartContract, _isTokenTonSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
13
13
  import { calculateToAmountByReservePool, FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE } from '@subwallet/extension-base/services/fee-service/utils';
14
- import { isCardanoTransaction, isSubstrateTransaction, isTonTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
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, combineEthFee, formatNumber, pairToAccount } from '@subwallet/extension-base/utils';
16
+ import { balanceFormatter, combineBitcoinFee, combineEthFee, formatNumber, getSizeInfo, 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';
@@ -312,6 +312,11 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
312
312
  } = _getChainNativeTokenBasicInfo(chainInfo);
313
313
  estimateFee.decimals = decimals;
314
314
  estimateFee.symbol = symbol;
315
+ const {
316
+ address,
317
+ feeCustom,
318
+ feeOption
319
+ } = validationResponse;
315
320
  if (transaction) {
316
321
  try {
317
322
  if (isSubstrateTransaction(transaction)) {
@@ -321,13 +326,28 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
321
326
  estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
322
327
  } else if (isCardanoTransaction(transaction)) {
323
328
  estimateFee.value = transaction.estimateCardanoFee;
329
+ } else if (isBitcoinTransaction(transaction)) {
330
+ const feeCombine = combineBitcoinFee(feeInfo, feeOption, feeCustom);
331
+ const recipients = [];
332
+ for (const txOutput of transaction.txOutputs) {
333
+ txOutput.address && recipients.push(txOutput.address);
334
+ }
335
+
336
+ // TODO: Need review
337
+ const sizeInfo = getSizeInfo({
338
+ inputLength: transaction.inputCount,
339
+ recipients: recipients,
340
+ sender: address
341
+ });
342
+ estimateFee.value = Math.ceil(feeCombine.feeRate * sizeInfo.txVBytes).toString();
324
343
  } else {
325
- const gasLimit = transaction.gas || (await evmApi.api.eth.estimateGas(transaction));
344
+ const _transaction = transaction;
345
+ const gasLimit = _transaction.gas || (await evmApi.api.eth.estimateGas(_transaction));
326
346
  const feeCombine = combineEthFee(feeInfo, validationResponse.feeOption, validationResponse.feeCustom);
327
- if (transaction.maxFeePerGas) {
328
- estimateFee.value = new BigN(transaction.maxFeePerGas.toString()).multipliedBy(gasLimit).toFixed(0);
329
- } else if (transaction.gasPrice) {
330
- estimateFee.value = new BigN(transaction.gasPrice.toString()).multipliedBy(gasLimit).toFixed(0);
347
+ if (_transaction.maxFeePerGas) {
348
+ estimateFee.value = new BigN(_transaction.maxFeePerGas.toString()).multipliedBy(gasLimit).toFixed(0);
349
+ } else if (_transaction.gasPrice) {
350
+ estimateFee.value = new BigN(_transaction.gasPrice.toString()).multipliedBy(gasLimit).toFixed(0);
331
351
  } else {
332
352
  if (feeCombine.maxFeePerGas) {
333
353
  const maxFee = new BigN(feeCombine.maxFeePerGas); // TODO: Need review
package/core/types.d.ts CHANGED
@@ -8,6 +8,7 @@ export declare enum ValidationCondition {
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
10
  IS_VALID_CARDANO_ADDRESS_FORMAT = "IS_VALID_CARDANO_ADDRESS_FORMAT",
11
+ IS_VALID_BITCOIN_ADDRESS_FORMAT = "IS_VALID_BITCOIN_ADDRESS_FORMAT",
11
12
  IS_NOT_DUPLICATE_ADDRESS = "IS_NOT_DUPLICATE_ADDRESS",
12
13
  IS_SUPPORT_LEDGER_ACCOUNT = "IS_SUPPORT_LEDGER_ACCOUNT"
13
14
  }
package/core/types.js CHANGED
@@ -9,6 +9,7 @@ export let ValidationCondition;
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
11
  ValidationCondition["IS_VALID_CARDANO_ADDRESS_FORMAT"] = "IS_VALID_CARDANO_ADDRESS_FORMAT";
12
+ ValidationCondition["IS_VALID_BITCOIN_ADDRESS_FORMAT"] = "IS_VALID_BITCOIN_ADDRESS_FORMAT";
12
13
  ValidationCondition["IS_NOT_DUPLICATE_ADDRESS"] = "IS_NOT_DUPLICATE_ADDRESS";
13
14
  ValidationCondition["IS_SUPPORT_LEDGER_ACCOUNT"] = "IS_SUPPORT_LEDGER_ACCOUNT";
14
15
  })(ValidationCondition || (ValidationCondition = {}));
package/core/utils.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare function _isValidAddressForEcosystem(validateRecipientParams: Val
13
13
  export declare function _isValidSubstrateAddressFormat(validateRecipientParams: ValidateRecipientParams): string;
14
14
  export declare function _isValidTonAddressFormat(validateRecipientParams: ValidateRecipientParams): string;
15
15
  export declare function _isValidCardanoAddressFormat(validateRecipientParams: ValidateRecipientParams): string;
16
+ export declare function _isValidBitcoinAddressFormat(validateRecipientParams: ValidateRecipientParams): string;
16
17
  export declare function _isNotDuplicateAddress(validateRecipientParams: ValidateRecipientParams): string;
17
18
  export declare function _isSupportLedgerAccount(validateRecipientParams: ValidateRecipientParams): string;
18
19
  export declare const _isSufficientToken: (tokenInfo: _ChainAsset, substrateApi: _SubstrateApi, sufficientChain: SufficientChainsDetails) => Promise<boolean>;
package/core/utils.js CHANGED
@@ -5,9 +5,10 @@ import { _AssetType } from '@subwallet/chain-list/types';
5
5
  import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
6
6
  import { BalanceAccountType } from '@subwallet/extension-base/core/substrate/types';
7
7
  import { tonAddressInfo } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils';
8
- import { _getTokenOnChainAssetId, _getXcmAssetMultilocation, _isBridgedToken, _isChainCardanoCompatible, _isChainEvmCompatible, _isChainSubstrateCompatible, _isChainTonCompatible } from '@subwallet/extension-base/services/chain-service/utils';
8
+ import { _getTokenOnChainAssetId, _getXcmAssetMultilocation, _isBridgedToken, _isChainBitcoinCompatible, _isChainCardanoCompatible, _isChainEvmCompatible, _isChainSubstrateCompatible, _isChainTonCompatible } from '@subwallet/extension-base/services/chain-service/utils';
9
9
  import { isAddressAndChainCompatible, isSameAddress, reformatAddress } from '@subwallet/extension-base/utils';
10
10
  import { isAddress, isCardanoTestnetAddress, isTonAddress } from '@subwallet/keyring';
11
+ import { getBitcoinAddressInfo, validateBitcoinAddress } from '@subwallet/keyring/utils';
11
12
  import { isEthereumAddress } from '@polkadot/util-crypto';
12
13
  export function getStrictMode(type, extrinsicType) {
13
14
  if (type === BalanceAccountType.FrameSystemAccountInfo) {
@@ -55,7 +56,7 @@ export function _isValidAddressForEcosystem(validateRecipientParams) {
55
56
  toAddress
56
57
  } = validateRecipientParams;
57
58
  if (!isAddressAndChainCompatible(toAddress, destChainInfo)) {
58
- if (_isChainEvmCompatible(destChainInfo) || _isChainSubstrateCompatible(destChainInfo) || _isChainTonCompatible(destChainInfo) || _isChainCardanoCompatible(destChainInfo)) {
59
+ if (_isChainEvmCompatible(destChainInfo) || _isChainSubstrateCompatible(destChainInfo) || _isChainTonCompatible(destChainInfo) || _isChainCardanoCompatible(destChainInfo) || _isChainBitcoinCompatible(destChainInfo)) {
59
60
  return 'Recipient address must be the same type as sender address';
60
61
  }
61
62
  return 'Unknown chain type';
@@ -96,6 +97,18 @@ export function _isValidCardanoAddressFormat(validateRecipientParams) {
96
97
  }
97
98
  return '';
98
99
  }
100
+ export function _isValidBitcoinAddressFormat(validateRecipientParams) {
101
+ var _destChainInfo$bitcoi;
102
+ const {
103
+ destChainInfo,
104
+ toAddress
105
+ } = validateRecipientParams;
106
+ const addressInfo = validateBitcoinAddress(toAddress) ? getBitcoinAddressInfo(toAddress) : null;
107
+ if ((addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.network) !== ((_destChainInfo$bitcoi = destChainInfo.bitcoinInfo) === null || _destChainInfo$bitcoi === void 0 ? void 0 : _destChainInfo$bitcoi.bitcoinNetwork)) {
108
+ return `Recipient address must be a valid ${destChainInfo.name} address`;
109
+ }
110
+ return '';
111
+ }
99
112
  export function _isNotDuplicateAddress(validateRecipientParams) {
100
113
  const {
101
114
  fromAddress,
@@ -157,9 +157,11 @@ export default class KoniExtension {
157
157
  private subscribeConfirmations;
158
158
  private subscribeConfirmationsTon;
159
159
  private subscribeConfirmationsCardano;
160
+ private subscribeConfirmationsBitcoin;
160
161
  private completeConfirmation;
161
162
  private completeConfirmationTon;
162
163
  private completeConfirmationCardano;
164
+ private completeConfirmationBitcoin;
163
165
  private getNetworkJsonByChainId;
164
166
  private parseSubstrateTransaction;
165
167
  private parseEVMRLP;
@@ -25,6 +25,7 @@ import { getPoolingBondingExtrinsic, getPoolingUnbondingExtrinsic, validatePoolB
25
25
  import { YIELD_EXTRINSIC_TYPES } from '@subwallet/extension-base/koni/api/yield/helper/utils';
26
26
  import { DEFAULT_CARDANO_TTL_OFFSET } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/consts';
27
27
  import { isBounceableAddress } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils';
28
+ import { createBitcoinTransaction } from '@subwallet/extension-base/services/balance-service/transfer/bitcoin-transfer';
28
29
  import { createCardanoTransaction } from '@subwallet/extension-base/services/balance-service/transfer/cardano-transfer';
29
30
  import { getERC20TransactionObject, getERC721Transaction, getEVMTransactionObject, getPSP34TransferExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
30
31
  import { createSubstrateExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/token';
@@ -37,7 +38,7 @@ import { _isPosChainBridge, getClaimPosBridge } from '@subwallet/extension-base/
37
38
  import { estimateXcmFee } from '@subwallet/extension-base/services/balance-service/transfer/xcm/utils';
38
39
  import { _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
39
40
  import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
40
- import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _isAssetSmartContractNft, _isChainEnabled, _isChainEvmCompatible, _isChainSubstrateCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isNativeTokenBySlug, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByCardano, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
41
+ import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _isAssetSmartContractNft, _isChainEnabled, _isChainEvmCompatible, _isChainSubstrateCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isNativeTokenBySlug, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByBitcoin, _isTokenTransferredByCardano, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
41
42
  import { calculateToAmountByReservePool } from '@subwallet/extension-base/services/fee-service/utils';
42
43
  import { batchExtrinsicSetFeeHydration, getAssetHubTokensCanPayFee, getHydrationTokensCanPayFee } from '@subwallet/extension-base/services/fee-service/utils/tokenPayFee';
43
44
  import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
@@ -51,9 +52,11 @@ import { parseContractInput, parseEvmRlp } from '@subwallet/extension-base/utils
51
52
  import { getId } from '@subwallet/extension-base/utils/getId';
52
53
  import { getKeypairTypeByAddress, isAddress, isCardanoAddress, isSubstrateAddress, isTonAddress } from '@subwallet/keyring';
53
54
  import { CardanoKeypairTypes, EthereumKeypairTypes, SubstrateKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
55
+ import { isBitcoinAddress } from '@subwallet/keyring/utils/address/validate';
54
56
  import { keyring } from '@subwallet/ui-keyring';
55
57
  import { getSdkError } from '@walletconnect/utils';
56
58
  import BigN from 'bignumber.js';
59
+ import * as bitcoin from 'bitcoinjs-lib';
57
60
  import { t } from 'i18next';
58
61
  import { combineLatest, Subject } from 'rxjs';
59
62
  import { TypeRegistry } from '@polkadot/types';
@@ -1244,6 +1247,7 @@ export default class KoniExtension {
1244
1247
  decimals: _getAssetDecimals(transferTokenInfo)
1245
1248
  };
1246
1249
  let transaction;
1250
+ let overrideFeeCustom;
1247
1251
  const transferTokenAvailable = await this.getAddressTransferableBalance({
1248
1252
  address: from,
1249
1253
  networkKey: chain,
@@ -1315,6 +1319,38 @@ export default class KoniExtension {
1315
1319
  cardanoApi,
1316
1320
  nativeTokenInfo
1317
1321
  });
1322
+ } else if (isBitcoinAddress(from) && isBitcoinAddress(to) && _isTokenTransferredByBitcoin(transferTokenInfo)) {
1323
+ // Note: Currently supports transferring only the native token, Bitcoin.
1324
+ chainType = ChainType.BITCOIN;
1325
+ const chainInfo = this.#koniState.getChainInfo(chain);
1326
+ const network = chainInfo.isTestnet ? bitcoin.networks.testnet : bitcoin.networks.bitcoin;
1327
+ const txVal = transferAll ? transferTokenAvailable.value : value || '0';
1328
+ const bitcoinApi = this.#koniState.getBitcoinApi(chain);
1329
+ const feeInfo = await this.#koniState.feeService.subscribeChainFee(getId(), chain, 'bitcoin');
1330
+ let calculatedBitcoinFeeRate;
1331
+ [transaction, transferAmount.value, calculatedBitcoinFeeRate] = await createBitcoinTransaction({
1332
+ bitcoinApi,
1333
+ chain,
1334
+ from,
1335
+ feeInfo,
1336
+ to,
1337
+ transferAll: !!transferAll,
1338
+ value: txVal,
1339
+ network: network
1340
+ });
1341
+ if (calculatedBitcoinFeeRate) {
1342
+ const feeRate = parseFloat(calculatedBitcoinFeeRate);
1343
+ if (!isNaN(feeRate)) {
1344
+ overrideFeeCustom = {
1345
+ feeRate
1346
+ };
1347
+ }
1348
+ }
1349
+
1350
+ // TODO: This is a hotfix until transferMax for Bitcoin is supported.
1351
+ if (transferAll) {
1352
+ inputData.value = transferAmount.value;
1353
+ }
1318
1354
  } else {
1319
1355
  const substrateApi = this.#koniState.getSubstrateApi(chain);
1320
1356
  [transaction, transferAmount.value] = await createSubstrateExtrinsic({
@@ -1405,8 +1441,8 @@ export default class KoniExtension {
1405
1441
  warnings,
1406
1442
  address: from,
1407
1443
  chain,
1408
- feeCustom,
1409
- feeOption,
1444
+ feeCustom: overrideFeeCustom || feeCustom,
1445
+ feeOption: overrideFeeCustom ? 'custom' : feeOption,
1410
1446
  tokenPayFeeSlug,
1411
1447
  chainType,
1412
1448
  transferNativeAmount,
@@ -1452,7 +1488,7 @@ export default class KoniExtension {
1452
1488
  const isPosBridgeTransfer = _isPosChainBridge(originNetworkKey, destinationNetworkKey);
1453
1489
  const isAcrossBridgeTransfer = _isAcrossChainBridge(originNetworkKey, destinationNetworkKey);
1454
1490
  const extrinsicType = ExtrinsicType.TRANSFER_XCM;
1455
- const isSubstrateXcm = !(isAvailBridgeFromEvm || isAvailBridgeFromAvail || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer);
1491
+ const isSubstrateXcm = !(isAvailBridgeFromEvm || isAvailBridgeFromAvail || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer || isAcrossBridgeTransfer);
1456
1492
  const isTransferNative = this.#koniState.getNativeTokenInfo(originNetworkKey).slug === tokenSlug;
1457
1493
  const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNative && tokenSlug === tokenPayFeeSlug;
1458
1494
  let xcmFeeDryRun;
@@ -1534,48 +1570,47 @@ export default class KoniExtension {
1534
1570
  }
1535
1571
  let isSendingTokenSufficient = false;
1536
1572
  let receiverSystemAccountInfo;
1537
- if (!_isChainSubstrateCompatible(chainInfoMap[destinationNetworkKey])) {
1538
- return undefined;
1539
- }
1540
- const setting = {
1541
- visible: true
1542
- };
1543
- await this.#koniState.chainService.updateAssetSetting(destinationTokenInfo.slug, setting, true);
1544
- const {
1545
- value: _senderTransferable
1546
- } = await this.getAddressTransferableBalance({
1547
- address: from,
1548
- networkKey: originNetworkKey,
1549
- token: originTokenInfo.slug
1550
- });
1551
- const senderTransferable = BigInt(_senderTransferable);
1552
- const sendingAmount = BigInt(value);
1553
- const {
1554
- value: _receiverDestinationTokenKeepAliveBalance
1555
- } = await this.getAddressTotalBalance({
1556
- address: to,
1557
- networkKey: destinationNetworkKey,
1558
- token: destinationTokenInfo.slug,
1559
- extrinsicType
1560
- });
1561
- const receiverDestinationTokenKeepAliveBalance = BigInt(_receiverDestinationTokenKeepAliveBalance);
1562
- if (!_isNativeToken(destinationTokenInfo)) {
1563
- const _receiverNativeTotal = await this.getAddressTotalBalance({
1573
+ if (_isChainSubstrateCompatible(chainInfoMap[destinationNetworkKey])) {
1574
+ const setting = {
1575
+ visible: true
1576
+ };
1577
+ await this.#koniState.chainService.updateAssetSetting(destinationTokenInfo.slug, setting, true);
1578
+ const {
1579
+ value: _senderTransferable
1580
+ } = await this.getAddressTransferableBalance({
1581
+ address: from,
1582
+ networkKey: originNetworkKey,
1583
+ token: originTokenInfo.slug
1584
+ });
1585
+ const senderTransferable = BigInt(_senderTransferable);
1586
+ const sendingAmount = BigInt(value);
1587
+ const {
1588
+ value: _receiverDestinationTokenKeepAliveBalance
1589
+ } = await this.getAddressTotalBalance({
1564
1590
  address: to,
1565
1591
  networkKey: destinationNetworkKey,
1566
- token: destinationNativeTokenSlug,
1592
+ token: destinationTokenInfo.slug,
1567
1593
  extrinsicType
1568
1594
  });
1569
- receiverSystemAccountInfo = _receiverNativeTotal.metadata;
1595
+ const receiverDestinationTokenKeepAliveBalance = BigInt(_receiverDestinationTokenKeepAliveBalance);
1596
+ if (!_isNativeToken(destinationTokenInfo)) {
1597
+ const _receiverNativeTotal = await this.getAddressTotalBalance({
1598
+ address: to,
1599
+ networkKey: destinationNetworkKey,
1600
+ token: destinationNativeTokenSlug,
1601
+ extrinsicType
1602
+ });
1603
+ receiverSystemAccountInfo = _receiverNativeTotal.metadata;
1604
+ }
1605
+ const substrateApi = this.#koniState.getSubstrateApi(destinationNetworkKey);
1606
+ const sufficientChain = this.#koniState.chainService.value.sufficientChains;
1607
+ isSendingTokenSufficient = await _isSufficientToken(destinationTokenInfo, substrateApi, sufficientChain);
1608
+ const [warning, error] = additionalValidateTransferForRecipient(destinationTokenInfo, destinationNativeTokenInfo, extrinsicType, receiverDestinationTokenKeepAliveBalance, sendingAmount, senderTransferable,
1609
+ // different from sendingTokenInfo being passed in
1610
+ receiverSystemAccountInfo, isSendingTokenSufficient);
1611
+ warning.length && inputTransaction.warnings.push(...warning);
1612
+ error.length && inputTransaction.errors.push(...error);
1570
1613
  }
1571
- const substrateApi = this.#koniState.getSubstrateApi(destinationNetworkKey);
1572
- const sufficientChain = this.#koniState.chainService.value.sufficientChains;
1573
- isSendingTokenSufficient = await _isSufficientToken(destinationTokenInfo, substrateApi, sufficientChain);
1574
- const [warning, error] = additionalValidateTransferForRecipient(destinationTokenInfo, destinationNativeTokenInfo, extrinsicType, receiverDestinationTokenKeepAliveBalance, sendingAmount, senderTransferable,
1575
- // different from sendingTokenInfo being passed in
1576
- receiverSystemAccountInfo, isSendingTokenSufficient);
1577
- warning.length && inputTransaction.warnings.push(...warning);
1578
- error.length && inputTransaction.errors.push(...error);
1579
1614
  if (isSubstrateXcm) {
1580
1615
  const isDryRunSuccess = await dryRunXcmExtrinsicV2(params);
1581
1616
  if (!isDryRunSuccess) {
@@ -1865,6 +1900,7 @@ export default class KoniExtension {
1865
1900
  destChain: _destChain,
1866
1901
  feeCustom,
1867
1902
  feeOption,
1903
+ to,
1868
1904
  token,
1869
1905
  tokenPayFeeSlug,
1870
1906
  value
@@ -1887,6 +1923,7 @@ export default class KoniExtension {
1887
1923
  }
1888
1924
  const _request = {
1889
1925
  address: address,
1926
+ to: to,
1890
1927
  value,
1891
1928
  // todo: lazy subscribe to improve performance
1892
1929
  cardanoApi: this.#koniState.chainService.getCardanoApi(chain),
@@ -1899,6 +1936,7 @@ export default class KoniExtension {
1899
1936
  srcToken,
1900
1937
  substrateApi: this.#koniState.chainService.getSubstrateApi(chain),
1901
1938
  tonApi: this.#koniState.chainService.getTonApi(chain),
1939
+ bitcoinApi: this.#koniState.chainService.getBitcoinApi(chain),
1902
1940
  isTransferLocalTokenAndPayThatTokenAsFee,
1903
1941
  isTransferNativeTokenAndPayLocalTokenAsFee,
1904
1942
  nativeToken
@@ -2096,6 +2134,15 @@ export default class KoniExtension {
2096
2134
  });
2097
2135
  return this.#koniState.getConfirmationsQueueSubjectCardano().getValue();
2098
2136
  }
2137
+ subscribeConfirmationsBitcoin(id, port) {
2138
+ const cb = createSubscription(id, port);
2139
+ const subscription = this.#koniState.getConfirmationsQueueSubjectBitcoin().subscribe(cb);
2140
+ this.createUnsubscriptionHandle(id, subscription.unsubscribe);
2141
+ port.onDisconnect.addListener(() => {
2142
+ this.cancelSubscription(id);
2143
+ });
2144
+ return this.#koniState.getConfirmationsQueueSubjectBitcoin().getValue();
2145
+ }
2099
2146
  async completeConfirmation(request) {
2100
2147
  return await this.#koniState.completeConfirmation(request);
2101
2148
  }
@@ -2105,7 +2152,9 @@ export default class KoniExtension {
2105
2152
  async completeConfirmationCardano(request) {
2106
2153
  return await this.#koniState.completeConfirmationCardano(request);
2107
2154
  }
2108
-
2155
+ async completeConfirmationBitcoin(request) {
2156
+ return await this.#koniState.completeConfirmationBitcoin(request);
2157
+ }
2109
2158
  /// Sign Qr
2110
2159
 
2111
2160
  getNetworkJsonByChainId(chainId) {
@@ -4641,12 +4690,16 @@ export default class KoniExtension {
4641
4690
  return this.subscribeConfirmationsTon(id, port);
4642
4691
  case 'pri(confirmationsCardano.subscribe)':
4643
4692
  return this.subscribeConfirmationsCardano(id, port);
4693
+ case 'pri(confirmationsBitcoin.subscribe)':
4694
+ return this.subscribeConfirmationsBitcoin(id, port);
4644
4695
  case 'pri(confirmations.complete)':
4645
4696
  return await this.completeConfirmation(request);
4646
4697
  case 'pri(confirmationsTon.complete)':
4647
4698
  return await this.completeConfirmationTon(request);
4648
4699
  case 'pri(confirmationsCardano.complete)':
4649
4700
  return await this.completeConfirmationCardano(request);
4701
+ case 'pri(confirmationsBitcoin.complete)':
4702
+ return await this.completeConfirmationBitcoin(request);
4650
4703
 
4651
4704
  /// Stake
4652
4705
  case 'pri(bonding.getBondingOptions)':
@@ -1,7 +1,7 @@
1
1
  /// <reference types="chrome" />
2
2
  import * as CardanoWasm from '@emurgo/cardano-serialization-lib-nodejs';
3
3
  import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
4
- import { AddTokenRequestExternal, AmountData, ApiMap, AuthRequestV2, ChainStakingMetadata, ConfirmationsQueue, ConfirmationsQueueCardano, ConfirmationsQueueTon, CrowdloanItem, CrowdloanJson, EvmSendTransactionParams, ExternalRequestPromise, MantaPayConfig, MantaPaySyncState, NftCollection, NftItem, NftJson, NominatorMetadata, RequestAccountExportPrivateKey, RequestCardanoSignData, RequestCardanoSignTransaction, RequestConfirmationComplete, RequestConfirmationCompleteCardano, RequestConfirmationCompleteTon, RequestCrowdloanContributions, RequestSettingsType, ResponseAccountExportPrivateKey, ResponseCardanoSignData, ResponseCardanoSignTransaction, ServiceInfo, SingleModeJson, StakingItem, StakingJson, StakingRewardItem, StakingRewardJson, StakingType, UiSettings } from '@subwallet/extension-base/background/KoniTypes';
4
+ import { AddTokenRequestExternal, AmountData, ApiMap, AuthRequestV2, ChainStakingMetadata, ConfirmationsQueue, ConfirmationsQueueBitcoin, ConfirmationsQueueCardano, ConfirmationsQueueTon, CrowdloanItem, CrowdloanJson, EvmSendTransactionParams, ExternalRequestPromise, MantaPayConfig, MantaPaySyncState, NftCollection, NftItem, NftJson, NominatorMetadata, RequestAccountExportPrivateKey, RequestCardanoSignData, RequestCardanoSignTransaction, RequestConfirmationComplete, RequestConfirmationCompleteBitcoin, RequestConfirmationCompleteCardano, RequestConfirmationCompleteTon, RequestCrowdloanContributions, RequestSettingsType, ResponseAccountExportPrivateKey, ResponseCardanoSignData, ResponseCardanoSignTransaction, ServiceInfo, SingleModeJson, StakingItem, StakingJson, StakingRewardItem, StakingRewardJson, StakingType, UiSettings } from '@subwallet/extension-base/background/KoniTypes';
5
5
  import { RequestAuthorizeTab, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, RequestSign, ResponseRpcListProviders, ResponseSigning } from '@subwallet/extension-base/background/types';
6
6
  import { EnvConfig } from '@subwallet/extension-base/constants';
7
7
  import { BalanceService } from '@subwallet/extension-base/services/balance-service';
@@ -82,6 +82,7 @@ export default class KoniState {
82
82
  private generalStatus;
83
83
  private waitSleeping;
84
84
  private waitStarting;
85
+ private waitStartingFull;
85
86
  constructor(providers?: Providers);
86
87
  get knownMetadata(): MetadataDef[];
87
88
  injectMetadata(request: MetadataDef): boolean;
@@ -100,7 +101,6 @@ export default class KoniState {
100
101
  init(): Promise<void>;
101
102
  initMantaPay(password: string): Promise<void>;
102
103
  private startSubscription;
103
- onReady(): void;
104
104
  updateKeyringState(isReady?: boolean, callback?: () => void): void;
105
105
  private lazyNext;
106
106
  getAuthRequestV2(id: string): AuthRequestV2;
@@ -196,6 +196,7 @@ export default class KoniState {
196
196
  getTonApi(networkKey: string): import("../../../services/chain-service/handler/TonApi").TonApi;
197
197
  getCardanoApiMap(): Record<string, import("../../../services/chain-service/handler/CardanoApi").CardanoApi>;
198
198
  getCardanoApi(networkKey: string): import("../../../services/chain-service/handler/CardanoApi").CardanoApi;
199
+ getBitcoinApi(networkKey: string): import("../../../services/chain-service/handler/bitcoin/BitcoinApi").BitcoinApi;
199
200
  getApiMap(): ApiMap;
200
201
  refreshSubstrateApi(key: string): boolean;
201
202
  refreshWeb3Api(key: string): void;
@@ -224,9 +225,11 @@ export default class KoniState {
224
225
  getConfirmationsQueueSubject(): BehaviorSubject<ConfirmationsQueue>;
225
226
  getConfirmationsQueueSubjectTon(): BehaviorSubject<ConfirmationsQueueTon>;
226
227
  getConfirmationsQueueSubjectCardano(): BehaviorSubject<ConfirmationsQueueCardano>;
228
+ getConfirmationsQueueSubjectBitcoin(): BehaviorSubject<ConfirmationsQueueBitcoin>;
227
229
  completeConfirmation(request: RequestConfirmationComplete): Promise<boolean>;
228
230
  completeConfirmationTon(request: RequestConfirmationCompleteTon): Promise<boolean>;
229
231
  completeConfirmationCardano(request: RequestConfirmationCompleteCardano): Promise<boolean>;
232
+ completeConfirmationBitcoin(request: RequestConfirmationCompleteBitcoin): Promise<boolean>;
230
233
  private onMV3Update;
231
234
  private storePreviousVersionData;
232
235
  migrateMV3LocalStorage(data: string): Promise<boolean>;
@@ -241,7 +244,8 @@ export default class KoniState {
241
244
  get activeChainSlugs(): string[];
242
245
  sleep(): Promise<void>;
243
246
  private _start;
244
- wakeup(): Promise<void>;
247
+ private _startFull;
248
+ wakeup(fullWakeup?: boolean): Promise<void>;
245
249
  cancelSubscription(id: string): boolean;
246
250
  createUnsubscriptionHandle(id: string, unsubscribe: () => void): void;
247
251
  get detectBalanceChainSlugMap(): Record<string, string>;