@lifi/sdk-provider-bitcoin 4.0.1-alpha.0 → 4.0.1

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 (152) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +88 -5
  3. package/dist/cjs/BitcoinProvider.d.ts +7 -2
  4. package/dist/cjs/BitcoinProvider.js +30 -34
  5. package/dist/cjs/BitcoinProvider.js.map +1 -1
  6. package/dist/cjs/_virtual/_rolldown/runtime.js +23 -0
  7. package/dist/cjs/actions/getBitcoinBalance.d.ts +7 -2
  8. package/dist/cjs/actions/getBitcoinBalance.js +21 -24
  9. package/dist/cjs/actions/getBitcoinBalance.js.map +1 -1
  10. package/dist/cjs/actions/resolveBitcoinAddress.d.ts +5 -1
  11. package/dist/cjs/actions/resolveBitcoinAddress.js +6 -4
  12. package/dist/cjs/actions/resolveBitcoinAddress.js.map +1 -1
  13. package/dist/cjs/client/publicClient.d.ts +14 -4
  14. package/dist/cjs/client/publicClient.js +38 -42
  15. package/dist/cjs/client/publicClient.js.map +1 -1
  16. package/dist/cjs/core/BitcoinStepExecutor.d.ts +19 -0
  17. package/dist/cjs/core/BitcoinStepExecutor.js +47 -0
  18. package/dist/cjs/core/BitcoinStepExecutor.js.map +1 -0
  19. package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.d.ts +10 -0
  20. package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js +75 -0
  21. package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -0
  22. package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.d.ts +10 -0
  23. package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js +38 -0
  24. package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -0
  25. package/dist/cjs/errors/parseBitcoinErrors.d.ts +7 -2
  26. package/dist/cjs/errors/parseBitcoinErrors.js +17 -26
  27. package/dist/cjs/errors/parseBitcoinErrors.js.map +1 -1
  28. package/dist/cjs/index.d.ts +3 -3
  29. package/dist/cjs/index.js +5 -8
  30. package/dist/cjs/types.d.ts +18 -7
  31. package/dist/cjs/types.js +7 -5
  32. package/dist/cjs/types.js.map +1 -1
  33. package/dist/cjs/utils/generateRedeemScript.d.ts +10 -1
  34. package/dist/cjs/utils/generateRedeemScript.js +11 -5
  35. package/dist/cjs/utils/generateRedeemScript.js.map +1 -1
  36. package/dist/cjs/utils/isPsbtFinalized.d.ts +7 -2
  37. package/dist/cjs/utils/isPsbtFinalized.js +11 -10
  38. package/dist/cjs/utils/isPsbtFinalized.js.map +1 -1
  39. package/dist/cjs/utils/toBigmiChainId.d.ts +8 -3
  40. package/dist/cjs/utils/toBigmiChainId.js +10 -11
  41. package/dist/cjs/utils/toBigmiChainId.js.map +1 -1
  42. package/dist/cjs/utils/toXOnly.d.ts +5 -1
  43. package/dist/cjs/utils/toXOnly.js +4 -3
  44. package/dist/cjs/utils/toXOnly.js.map +1 -1
  45. package/dist/cjs/version.d.ts +6 -2
  46. package/dist/cjs/version.js +8 -5
  47. package/dist/cjs/version.js.map +1 -1
  48. package/dist/esm/BitcoinProvider.d.ts +7 -2
  49. package/dist/esm/BitcoinProvider.d.ts.map +1 -0
  50. package/dist/esm/BitcoinProvider.js +30 -32
  51. package/dist/esm/BitcoinProvider.js.map +1 -1
  52. package/dist/esm/actions/getBitcoinBalance.d.ts +7 -2
  53. package/dist/esm/actions/getBitcoinBalance.d.ts.map +1 -0
  54. package/dist/esm/actions/getBitcoinBalance.js +22 -22
  55. package/dist/esm/actions/getBitcoinBalance.js.map +1 -1
  56. package/dist/esm/actions/resolveBitcoinAddress.d.ts +5 -1
  57. package/dist/esm/actions/resolveBitcoinAddress.d.ts.map +1 -0
  58. package/dist/esm/actions/resolveBitcoinAddress.js +6 -3
  59. package/dist/esm/actions/resolveBitcoinAddress.js.map +1 -1
  60. package/dist/esm/client/publicClient.d.ts +13 -9
  61. package/dist/esm/client/publicClient.d.ts.map +1 -0
  62. package/dist/esm/client/publicClient.js +38 -46
  63. package/dist/esm/client/publicClient.js.map +1 -1
  64. package/dist/esm/core/BitcoinStepExecutor.d.ts +19 -0
  65. package/dist/esm/core/BitcoinStepExecutor.d.ts.map +1 -0
  66. package/dist/esm/core/BitcoinStepExecutor.js +46 -0
  67. package/dist/esm/core/BitcoinStepExecutor.js.map +1 -0
  68. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts +10 -0
  69. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts.map +1 -0
  70. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js +72 -0
  71. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -0
  72. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts +10 -0
  73. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts.map +1 -0
  74. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js +37 -0
  75. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -0
  76. package/dist/esm/errors/parseBitcoinErrors.d.ts +7 -2
  77. package/dist/esm/errors/parseBitcoinErrors.d.ts.map +1 -0
  78. package/dist/esm/errors/parseBitcoinErrors.js +17 -24
  79. package/dist/esm/errors/parseBitcoinErrors.js.map +1 -1
  80. package/dist/esm/index.d.ts +3 -3
  81. package/dist/esm/index.js +3 -4
  82. package/dist/esm/package.json +1 -1
  83. package/dist/esm/types.d.ts +18 -7
  84. package/dist/esm/types.d.ts.map +1 -0
  85. package/dist/esm/types.js +7 -3
  86. package/dist/esm/types.js.map +1 -1
  87. package/dist/esm/utils/generateRedeemScript.d.ts +9 -5
  88. package/dist/esm/utils/generateRedeemScript.d.ts.map +1 -0
  89. package/dist/esm/utils/generateRedeemScript.js +10 -8
  90. package/dist/esm/utils/generateRedeemScript.js.map +1 -1
  91. package/dist/esm/utils/isPsbtFinalized.d.ts +7 -2
  92. package/dist/esm/utils/isPsbtFinalized.d.ts.map +1 -0
  93. package/dist/esm/utils/isPsbtFinalized.js +11 -8
  94. package/dist/esm/utils/isPsbtFinalized.js.map +1 -1
  95. package/dist/esm/utils/toBigmiChainId.d.ts +8 -3
  96. package/dist/esm/utils/toBigmiChainId.d.ts.map +1 -0
  97. package/dist/esm/utils/toBigmiChainId.js +11 -9
  98. package/dist/esm/utils/toBigmiChainId.js.map +1 -1
  99. package/dist/esm/utils/toXOnly.d.ts +5 -1
  100. package/dist/esm/utils/toXOnly.d.ts.map +1 -0
  101. package/dist/esm/utils/toXOnly.js +5 -2
  102. package/dist/esm/utils/toXOnly.js.map +1 -1
  103. package/dist/esm/version.d.ts +6 -2
  104. package/dist/esm/version.d.ts.map +1 -0
  105. package/dist/esm/version.js +6 -2
  106. package/dist/esm/version.js.map +1 -1
  107. package/package.json +7 -6
  108. package/src/BitcoinProvider.ts +1 -1
  109. package/src/actions/getBitcoinBalance.ts +15 -3
  110. package/src/client/publicClient.ts +1 -1
  111. package/src/core/BitcoinStepExecutor.ts +100 -0
  112. package/src/core/tasks/BitcoinSignAndExecuteTask.ts +168 -0
  113. package/src/core/tasks/BitcoinWaitForTransactionTask.ts +74 -0
  114. package/src/types.ts +13 -1
  115. package/src/utils/generateRedeemScript.ts +3 -1
  116. package/src/utils/toXOnly.ts +1 -1
  117. package/src/version.ts +1 -1
  118. package/dist/cjs/BitcoinStepExecutor.d.ts +0 -12
  119. package/dist/cjs/BitcoinStepExecutor.js +0 -198
  120. package/dist/cjs/BitcoinStepExecutor.js.map +0 -1
  121. package/dist/cjs/index.js.map +0 -1
  122. package/dist/esm/BitcoinStepExecutor.d.ts +0 -12
  123. package/dist/esm/BitcoinStepExecutor.js +0 -210
  124. package/dist/esm/BitcoinStepExecutor.js.map +0 -1
  125. package/dist/esm/index.js.map +0 -1
  126. package/dist/types/BitcoinProvider.d.ts +0 -3
  127. package/dist/types/BitcoinProvider.d.ts.map +0 -1
  128. package/dist/types/BitcoinStepExecutor.d.ts +0 -13
  129. package/dist/types/BitcoinStepExecutor.d.ts.map +0 -1
  130. package/dist/types/actions/getBitcoinBalance.d.ts +0 -3
  131. package/dist/types/actions/getBitcoinBalance.d.ts.map +0 -1
  132. package/dist/types/actions/resolveBitcoinAddress.d.ts +0 -2
  133. package/dist/types/actions/resolveBitcoinAddress.d.ts.map +0 -1
  134. package/dist/types/client/publicClient.d.ts +0 -12
  135. package/dist/types/client/publicClient.d.ts.map +0 -1
  136. package/dist/types/errors/parseBitcoinErrors.d.ts +0 -3
  137. package/dist/types/errors/parseBitcoinErrors.d.ts.map +0 -1
  138. package/dist/types/index.d.ts +0 -4
  139. package/dist/types/index.d.ts.map +0 -1
  140. package/dist/types/types.d.ts +0 -10
  141. package/dist/types/types.d.ts.map +0 -1
  142. package/dist/types/utils/generateRedeemScript.d.ts +0 -7
  143. package/dist/types/utils/generateRedeemScript.d.ts.map +0 -1
  144. package/dist/types/utils/isPsbtFinalized.d.ts +0 -3
  145. package/dist/types/utils/isPsbtFinalized.d.ts.map +0 -1
  146. package/dist/types/utils/toBigmiChainId.d.ts +0 -4
  147. package/dist/types/utils/toBigmiChainId.d.ts.map +0 -1
  148. package/dist/types/utils/toXOnly.d.ts +0 -2
  149. package/dist/types/utils/toXOnly.d.ts.map +0 -1
  150. package/dist/types/version.d.ts +0 -3
  151. package/dist/types/version.d.ts.map +0 -1
  152. package/src/BitcoinStepExecutor.ts +0 -333
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # @lifi/sdk-provider-bitcoin
2
+
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`bf3d047`](https://github.com/lifinance/sdk/commit/bf3d047ebdc9a8b3a5a6362f65d25aa1eb652ffa)]:
8
+ - @lifi/sdk@4.0.1
9
+
10
+ ## 4.0.0
11
+
12
+ ### Patch Changes
13
+
14
+ - [#398](https://github.com/lifinance/sdk/pull/398) [`e4e4600`](https://github.com/lifinance/sdk/commit/e4e460063aa22d672f1ea3fd26ffa9faf2655398) Thanks [@chybisov](https://github.com/chybisov)! - Bump @bigmi/core to 0.8.1.
15
+
16
+ - Updated dependencies []:
17
+ - @lifi/sdk@4.0.0
18
+
19
+ ## 4.0.0-beta.12
20
+
21
+ ### Patch Changes
22
+
23
+ - [#398](https://github.com/lifinance/sdk/pull/398) [`e4e4600`](https://github.com/lifinance/sdk/commit/e4e460063aa22d672f1ea3fd26ffa9faf2655398) Thanks [@chybisov](https://github.com/chybisov)! - Bump @bigmi/core to 0.8.1.
package/README.md CHANGED
@@ -13,18 +13,23 @@
13
13
 
14
14
  [**LI.FI SDK**](https://docs.li.fi/sdk/overview) features include:
15
15
 
16
+ - **Modular architecture** - Install only the provider packages you need for your supported blockchain ecosystems (EVM, Solana, Bitcoin, Sui, Tron)
16
17
  - All ecosystems, chains, bridges, exchanges, and solvers that [LI.FI](https://docs.li.fi/introduction/chains) supports
17
18
  - Complete functionality covering full-cycle from obtaining routes/quotes to executing transactions
18
19
  - Easy tracking of the route and quote execution through the robust event and hooks handling
19
20
  - Highly customizable settings to tailor the SDK to your specific needs including configuration of RPCs and options to allow or deny certain chains, tokens, bridges, exchanges, solvers
20
21
  - Supports widely adopted industry standards, including [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792), [ERC-2612](https://eips.ethereum.org/EIPS/eip-2612), [EIP-712](https://eips.ethereum.org/EIPS/eip-712), and [Permit2](https://github.com/Uniswap/permit2)
21
- - SDK ecosystem providers are based on industry-standard libraries ([Viem](https://viem.sh/), [Wallet Standard](https://github.com/wallet-standard/wallet-standard), [Bigmi](https://github.com/lifinance/bigmi))
22
+ - SDK ecosystem providers are based on industry-standard libraries ([Viem](https://viem.sh/) for EVM, [Solana Kit](https://github.com/solana-labs/solana-web3.js) for Solana, [Bigmi](https://github.com/lifinance/bigmi) for Bitcoin, [Mysten Sui SDK](https://github.com/MystenLabs/sui/tree/main/sdk) for Sui, [TronWeb](https://tronweb.network/) for Tron)
22
23
  - Support for arbitrary contract calls on the destination chain
23
24
  - Designed for optimal performance with tree-shaking and dead-code elimination, ensuring minimal bundle sizes and faster page load times in front-end environments
24
25
  - Compatibility tested with Node.js and popular front-end tools like Vite
25
26
 
26
27
  ## Installation
27
28
 
29
+ The LI.FI SDK follows a modular architecture. Install the core SDK package and the provider packages for the blockchain ecosystems you need:
30
+
31
+ ### Core SDK
32
+
28
33
  ```bash
29
34
  pnpm add @lifi/sdk
30
35
  ```
@@ -35,17 +40,95 @@ or
35
40
  npm install --save @lifi/sdk
36
41
  ```
37
42
 
43
+ ### Provider Packages
44
+
45
+ Install provider packages based on the blockchain ecosystems you want to support:
46
+
47
+ **EVM Chains (Ethereum, Polygon, Arbitrum, Optimism, etc.)**
48
+ ```bash
49
+ pnpm add @lifi/sdk-provider-ethereum
50
+ ```
51
+
52
+ **Solana**
53
+ ```bash
54
+ pnpm add @lifi/sdk-provider-solana
55
+ ```
56
+
57
+ **Bitcoin**
58
+ ```bash
59
+ pnpm add @lifi/sdk-provider-bitcoin
60
+ ```
61
+
62
+ **Sui**
63
+ ```bash
64
+ pnpm add @lifi/sdk-provider-sui
65
+ ```
66
+
67
+ **Tron**
68
+ ```bash
69
+ pnpm add @lifi/sdk-provider-tron
70
+ ```
71
+
72
+ ## Architecture
73
+
74
+ The LI.FI SDK uses a modular provider architecture:
75
+
76
+ - **`@lifi/sdk`** - Core SDK package containing shared functionality, actions, and execution logic
77
+ - **Provider packages** - Ecosystem-specific packages that handle wallet interactions and transaction execution for different blockchain types
78
+
79
+ This architecture allows you to:
80
+ - Install only the providers you need, reducing bundle size
81
+ - Use ecosystem-specific libraries optimized for each blockchain
82
+ - Maintain clean separation between core SDK logic and blockchain-specific implementations
83
+
38
84
  ## Quick Start
39
85
 
40
86
  ### Set up the SDK
41
87
 
42
- Firstly, create SDK config with your integrator string.
88
+ Create SDK config with your integrator string and configure the providers for the blockchain ecosystems you want to support.
43
89
 
90
+ **For EVM chains:**
44
91
  ```ts
45
- import { createConfig } from '@lifi/sdk'
92
+ import { createClient } from '@lifi/sdk'
93
+ import { EthereumProvider } from '@lifi/sdk-provider-ethereum'
94
+ import { createWalletClient, http } from 'viem'
95
+ import { mainnet } from 'viem/chains'
96
+
97
+ // Add your account (e.g. privateKeyToAccount, mnemonicToAccount)
98
+ const walletClient = createWalletClient({
99
+ account,
100
+ chain: mainnet,
101
+ transport: http(),
102
+ })
46
103
 
47
- createConfig({
104
+ const client = createClient({
105
+ integrator: 'Your dApp/company name',
106
+ providers: [
107
+ EthereumProvider({
108
+ getWalletClient: () => Promise.resolve(walletClient),
109
+ }),
110
+ ],
111
+ })
112
+ ```
113
+
114
+ **For multiple ecosystems:**
115
+ ```ts
116
+ import { createClient } from '@lifi/sdk'
117
+ import { EthereumProvider } from '@lifi/sdk-provider-ethereum'
118
+ import { SolanaProvider } from '@lifi/sdk-provider-solana'
119
+ import { BitcoinProvider } from '@lifi/sdk-provider-bitcoin'
120
+ import { SuiProvider } from '@lifi/sdk-provider-sui'
121
+ import { TronProvider } from '@lifi/sdk-provider-tron'
122
+
123
+ const client = createClient({
48
124
  integrator: 'Your dApp/company name',
125
+ providers: [
126
+ EthereumProvider({ /* options */ }),
127
+ SolanaProvider({ /* options */ }),
128
+ BitcoinProvider({ /* options */ }),
129
+ SuiProvider({ /* options */ }),
130
+ TronProvider({ /* options */ }),
131
+ ],
49
132
  })
50
133
  ```
51
134
 
@@ -56,7 +139,7 @@ Now you can interact with the SDK and for example request a quote.
56
139
  ```ts
57
140
  import { ChainId, getQuote } from '@lifi/sdk'
58
141
 
59
- const quote = await getQuote({
142
+ const quote = await getQuote(client, {
60
143
  fromAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
61
144
  fromChain: ChainId.ARB,
62
145
  toChain: ChainId.OPT,
@@ -1,2 +1,7 @@
1
- import type { BitcoinProviderOptions, BitcoinSDKProvider } from './types.js';
2
- export declare function BitcoinProvider(options?: BitcoinProviderOptions): BitcoinSDKProvider;
1
+ import { BitcoinProviderOptions, BitcoinSDKProvider } from "./types.js";
2
+
3
+ //#region src/BitcoinProvider.d.ts
4
+ declare function BitcoinProvider(options?: BitcoinProviderOptions): BitcoinSDKProvider;
5
+ //#endregion
6
+ export { BitcoinProvider };
7
+ //# sourceMappingURL=BitcoinProvider.d.ts.map
@@ -1,37 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BitcoinProvider = BitcoinProvider;
4
- const core_1 = require("@bigmi/core");
5
- const sdk_1 = require("@lifi/sdk");
6
- const getBitcoinBalance_js_1 = require("./actions/getBitcoinBalance.js");
7
- const resolveBitcoinAddress_js_1 = require("./actions/resolveBitcoinAddress.js");
8
- const BitcoinStepExecutor_js_1 = require("./BitcoinStepExecutor.js");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_actions_getBitcoinBalance = require("./actions/getBitcoinBalance.js");
3
+ const require_actions_resolveBitcoinAddress = require("./actions/resolveBitcoinAddress.js");
4
+ const require_core_BitcoinStepExecutor = require("./core/BitcoinStepExecutor.js");
5
+ let _bigmi_core = require("@bigmi/core");
6
+ let _lifi_sdk = require("@lifi/sdk");
7
+ //#region src/BitcoinProvider.ts
9
8
  function BitcoinProvider(options) {
10
- const _options = options ?? {};
11
- return {
12
- get type() {
13
- return sdk_1.ChainType.UTXO;
14
- },
15
- isAddress: core_1.isUTXOAddress,
16
- resolveAddress: resolveBitcoinAddress_js_1.resolveBitcoinAddress,
17
- getBalance: getBitcoinBalance_js_1.getBitcoinBalance,
18
- async getStepExecutor(options) {
19
- if (!_options.getWalletClient) {
20
- throw new Error('Client is not provided.');
21
- }
22
- const walletClient = await _options.getWalletClient();
23
- const executor = new BitcoinStepExecutor_js_1.BitcoinStepExecutor({
24
- client: walletClient,
25
- routeId: options.routeId,
26
- executionOptions: {
27
- ...options.executionOptions,
28
- },
29
- });
30
- return executor;
31
- },
32
- setOptions(options) {
33
- Object.assign(_options, options);
34
- },
35
- };
9
+ const _options = options ?? {};
10
+ return {
11
+ get type() {
12
+ return _lifi_sdk.ChainType.UTXO;
13
+ },
14
+ isAddress: _bigmi_core.isUTXOAddress,
15
+ resolveAddress: require_actions_resolveBitcoinAddress.resolveBitcoinAddress,
16
+ getBalance: require_actions_getBitcoinBalance.getBitcoinBalance,
17
+ async getStepExecutor(options) {
18
+ if (!_options.getWalletClient) throw new Error("Client is not provided.");
19
+ return new require_core_BitcoinStepExecutor.BitcoinStepExecutor({
20
+ client: await _options.getWalletClient(),
21
+ routeId: options.routeId,
22
+ executionOptions: { ...options.executionOptions }
23
+ });
24
+ },
25
+ setOptions(options) {
26
+ Object.assign(_options, options);
27
+ }
28
+ };
36
29
  }
30
+ //#endregion
31
+ exports.BitcoinProvider = BitcoinProvider;
32
+
37
33
  //# sourceMappingURL=BitcoinProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BitcoinProvider.js","sourceRoot":"","sources":["../../src/BitcoinProvider.ts"],"names":[],"mappings":";;AAOA,0CAkCC;AAzCD,sCAA2C;AAC3C,mCAA+D;AAC/D,yEAAkE;AAClE,iFAA0E;AAC1E,qEAA8D;AAG9D,SAAgB,eAAe,CAC7B,OAAgC;IAEhC,MAAM,QAAQ,GAA2B,OAAO,IAAI,EAAE,CAAA;IACtD,OAAO;QACL,IAAI,IAAI;YACN,OAAO,eAAS,CAAC,IAAI,CAAA;QACvB,CAAC;QACD,SAAS,EAAE,oBAAa;QACxB,cAAc,EAAE,gDAAqB;QACrC,UAAU,EAAE,wCAAiB;QAC7B,KAAK,CAAC,eAAe,CACnB,OAA4B;YAE5B,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;YAC5C,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,eAAe,EAAE,CAAA;YAErD,MAAM,QAAQ,GAAG,IAAI,4CAAmB,CAAC;gBACvC,MAAM,EAAE,YAAY;gBACpB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,gBAAgB,EAAE;oBAChB,GAAG,OAAO,CAAC,gBAAgB;iBAC5B;aACF,CAAC,CAAA;YAEF,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,UAAU,CAAC,OAA+B;YACxC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAClC,CAAC;KACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"BitcoinProvider.js","names":["ChainType","isUTXOAddress","resolveBitcoinAddress","getBitcoinBalance","BitcoinStepExecutor"],"sources":["../../src/BitcoinProvider.ts"],"sourcesContent":["import { isUTXOAddress } from '@bigmi/core'\nimport { ChainType, type StepExecutorOptions } from '@lifi/sdk'\nimport { getBitcoinBalance } from './actions/getBitcoinBalance.js'\nimport { resolveBitcoinAddress } from './actions/resolveBitcoinAddress.js'\nimport { BitcoinStepExecutor } from './core/BitcoinStepExecutor.js'\nimport type { BitcoinProviderOptions, BitcoinSDKProvider } from './types.js'\n\nexport function BitcoinProvider(\n options?: BitcoinProviderOptions\n): BitcoinSDKProvider {\n const _options: BitcoinProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.UTXO\n },\n isAddress: isUTXOAddress,\n resolveAddress: resolveBitcoinAddress,\n getBalance: getBitcoinBalance,\n async getStepExecutor(\n options: StepExecutorOptions\n ): Promise<BitcoinStepExecutor> {\n if (!_options.getWalletClient) {\n throw new Error('Client is not provided.')\n }\n\n const walletClient = await _options.getWalletClient()\n\n const executor = new BitcoinStepExecutor({\n client: walletClient,\n routeId: options.routeId,\n executionOptions: {\n ...options.executionOptions,\n },\n })\n\n return executor\n },\n setOptions(options: BitcoinProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,gBACd,SACoB;CACpB,MAAM,WAAmC,WAAW,CAAC;CACrD,OAAO;EACL,IAAI,OAAO;GACT,OAAOA,UAAAA,UAAU;EACnB;EACA,WAAWC,YAAAA;EACX,gBAAgBC,sCAAAA;EAChB,YAAYC,kCAAAA;EACZ,MAAM,gBACJ,SAC8B;GAC9B,IAAI,CAAC,SAAS,iBACZ,MAAM,IAAI,MAAM,yBAAyB;GAa3C,OAAO,IARcC,iCAAAA,oBAAoB;IACvC,QAAQ,MAHiB,SAAS,gBAAgB;IAIlD,SAAS,QAAQ;IACjB,kBAAkB,EAChB,GAAG,QAAQ,iBACb;GACF,CAEc;EAChB;EACA,WAAW,SAAiC;GAC1C,OAAO,OAAO,UAAU,OAAO;EACjC;CACF;AACF"}
@@ -0,0 +1,23 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ exports.__toESM = __toESM;
@@ -1,2 +1,7 @@
1
- import { type SDKClient, type Token, type TokenAmount } from '@lifi/sdk';
2
- export declare const getBitcoinBalance: (client: SDKClient, walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
1
+ import { SDKClient, Token, TokenAmount } from "@lifi/sdk";
2
+
3
+ //#region src/actions/getBitcoinBalance.d.ts
4
+ declare const getBitcoinBalance: (client: SDKClient, walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
5
+ //#endregion
6
+ export { getBitcoinBalance };
7
+ //# sourceMappingURL=getBitcoinBalance.d.ts.map
@@ -1,28 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBitcoinBalance = void 0;
4
- const sdk_1 = require("@lifi/sdk");
5
- const publicClient_js_1 = require("../client/publicClient.js");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_client_publicClient = require("../client/publicClient.js");
3
+ let _lifi_sdk = require("@lifi/sdk");
4
+ //#region src/actions/getBitcoinBalance.ts
6
5
  const getBitcoinBalance = async (client, walletAddress, tokens) => {
7
- if (tokens.length === 0) {
8
- return [];
9
- }
10
- const { chainId } = tokens[0];
11
- for (const token of tokens) {
12
- if (token.chainId !== chainId) {
13
- console.warn('Requested tokens have to be on the same chain.');
14
- }
15
- }
16
- const bigmiClient = await (0, publicClient_js_1.getBitcoinPublicClient)(client, sdk_1.ChainId.BTC);
17
- const [balance, blockCount] = await Promise.all([
18
- bigmiClient.getBalance({ address: walletAddress }),
19
- bigmiClient.getBlockCount(),
20
- ]);
21
- return tokens.map((token) => ({
22
- ...token,
23
- amount: balance,
24
- blockNumber: BigInt(blockCount),
25
- }));
6
+ if (tokens.length === 0) return [];
7
+ const { chainId } = tokens[0];
8
+ for (const token of tokens) if (token.chainId !== chainId) console.warn("Requested tokens have to be on the same chain.");
9
+ const bigmiClient = await require_client_publicClient.getBitcoinPublicClient(client, _lifi_sdk.ChainId.BTC);
10
+ const [balance, blockCount] = await Promise.allSettled([bigmiClient.getBalance({ address: walletAddress }), bigmiClient.getBlockCount()]);
11
+ const blockNumber = blockCount.status === "fulfilled" ? BigInt(blockCount.value) : 0n;
12
+ if (balance.status !== "fulfilled") return tokens.map((token) => ({
13
+ ...token,
14
+ blockNumber
15
+ }));
16
+ return tokens.map((token) => ({
17
+ ...token,
18
+ amount: balance.value,
19
+ blockNumber
20
+ }));
26
21
  };
22
+ //#endregion
27
23
  exports.getBitcoinBalance = getBitcoinBalance;
24
+
28
25
  //# sourceMappingURL=getBitcoinBalance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getBitcoinBalance.js","sourceRoot":"","sources":["../../../src/actions/getBitcoinBalance.ts"],"names":[],"mappings":";;;AAAA,mCAKkB;AAClB,+DAAkE;AAE3D,MAAM,iBAAiB,GAAG,KAAK,EACpC,MAAiB,EACjB,aAAqB,EACrB,MAAe,EACS,EAAE;IAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,CAAA;IACX,CAAC;IACD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAA;QAChE,CAAC;IACH,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,IAAA,wCAAsB,EAAC,MAAM,EAAE,aAAO,CAAC,GAAG,CAAC,CAAA;IACrE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC9C,WAAW,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;QAClD,WAAW,CAAC,aAAa,EAAE;KAC5B,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5B,GAAG,KAAK;QACR,MAAM,EAAE,OAAO;QACf,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC;KAChC,CAAC,CAAC,CAAA;AACL,CAAC,CAAA;AAzBY,QAAA,iBAAiB,qBAyB7B"}
1
+ {"version":3,"file":"getBitcoinBalance.js","names":["getBitcoinPublicClient","ChainId"],"sources":["../../../src/actions/getBitcoinBalance.ts"],"sourcesContent":["import {\n ChainId,\n type SDKClient,\n type Token,\n type TokenAmount,\n} from '@lifi/sdk'\nimport { getBitcoinPublicClient } from '../client/publicClient.js'\n\nexport const getBitcoinBalance = async (\n client: SDKClient,\n walletAddress: string,\n tokens: Token[]\n): Promise<TokenAmount[]> => {\n if (tokens.length === 0) {\n return []\n }\n const { chainId } = tokens[0]\n for (const token of tokens) {\n if (token.chainId !== chainId) {\n console.warn('Requested tokens have to be on the same chain.')\n }\n }\n const bigmiClient = await getBitcoinPublicClient(client, ChainId.BTC)\n const [balance, blockCount] = await Promise.allSettled([\n bigmiClient.getBalance({ address: walletAddress }),\n bigmiClient.getBlockCount(),\n ])\n\n const blockNumber =\n blockCount.status === 'fulfilled' ? BigInt(blockCount.value) : 0n\n\n if (balance.status !== 'fulfilled') {\n // RPC failed — leave amount undefined so callers can distinguish\n // an unknown balance from a known zero.\n return tokens.map((token) => ({\n ...token,\n blockNumber,\n }))\n }\n\n return tokens.map((token) => ({\n ...token,\n amount: balance.value,\n blockNumber,\n }))\n}\n"],"mappings":";;;;AAQA,MAAa,oBAAoB,OAC/B,QACA,eACA,WAC2B;CAC3B,IAAI,OAAO,WAAW,GACpB,OAAO,CAAC;CAEV,MAAM,EAAE,YAAY,OAAO;CAC3B,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,YAAY,SACpB,QAAQ,KAAK,gDAAgD;CAGjE,MAAM,cAAc,MAAMA,4BAAAA,uBAAuB,QAAQC,UAAAA,QAAQ,GAAG;CACpE,MAAM,CAAC,SAAS,cAAc,MAAM,QAAQ,WAAW,CACrD,YAAY,WAAW,EAAE,SAAS,cAAc,CAAC,GACjD,YAAY,cAAc,CAC5B,CAAC;CAED,MAAM,cACJ,WAAW,WAAW,cAAc,OAAO,WAAW,KAAK,IAAI;CAEjE,IAAI,QAAQ,WAAW,aAGrB,OAAO,OAAO,KAAK,WAAW;EAC5B,GAAG;EACH;CACF,EAAE;CAGJ,OAAO,OAAO,KAAK,WAAW;EAC5B,GAAG;EACH,QAAQ,QAAQ;EAChB;CACF,EAAE;AACJ"}
@@ -1 +1,5 @@
1
- export declare function resolveBitcoinAddress(name: string): Promise<string | undefined>;
1
+ //#region src/actions/resolveBitcoinAddress.d.ts
2
+ declare function resolveBitcoinAddress(name: string): Promise<string | undefined>;
3
+ //#endregion
4
+ export { resolveBitcoinAddress };
5
+ //# sourceMappingURL=resolveBitcoinAddress.d.ts.map
@@ -1,7 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveBitcoinAddress = resolveBitcoinAddress;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/actions/resolveBitcoinAddress.ts
4
3
  async function resolveBitcoinAddress(name) {
5
- return name;
4
+ return name;
6
5
  }
6
+ //#endregion
7
+ exports.resolveBitcoinAddress = resolveBitcoinAddress;
8
+
7
9
  //# sourceMappingURL=resolveBitcoinAddress.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveBitcoinAddress.js","sourceRoot":"","sources":["../../../src/actions/resolveBitcoinAddress.ts"],"names":[],"mappings":";;AAAA,sDAKC;AALM,KAAK,UAAU,qBAAqB,CACzC,IAAY;IAGZ,OAAO,IAAI,CAAA;AACb,CAAC"}
1
+ {"version":3,"file":"resolveBitcoinAddress.js","names":[],"sources":["../../../src/actions/resolveBitcoinAddress.ts"],"sourcesContent":["export async function resolveBitcoinAddress(\n name: string\n): Promise<string | undefined> {\n // Not supported on UTXO yet\n return name\n}\n"],"mappings":";;AAAA,eAAsB,sBACpB,MAC6B;CAE7B,OAAO;AACT"}
@@ -1,5 +1,15 @@
1
- import { type Account, type Chain, type Client, type FallbackTransport, type HttpTransport, type PublicActions, type UTXOSchema, type WalletActions } from '@bigmi/core';
2
- import type { SDKClient } from '@lifi/sdk';
1
+ import { Account, Chain, Client, FallbackTransport, HttpTransport, PublicActions, UTXOSchema, WalletActions } from "@bigmi/core";
2
+ import { SDKClient } from "@lifi/sdk";
3
+
4
+ //#region src/client/publicClient.d.ts
3
5
  type PublicClient = Client<FallbackTransport<readonly HttpTransport[]>, Chain, Account | undefined, UTXOSchema, PublicActions & WalletActions>;
4
- export declare const getBitcoinPublicClient: (client: SDKClient, chainId: number) => Promise<PublicClient>;
5
- export {};
6
+ /**
7
+ * Get an instance of a provider for a specific chain
8
+ * @param client - The SDK client
9
+ * @param chainId - Id of the chain the provider is for
10
+ * @returns The public client for the given chain
11
+ */
12
+ declare const getBitcoinPublicClient: (client: SDKClient, chainId: number) => Promise<PublicClient>;
13
+ //#endregion
14
+ export { PublicClient, getBitcoinPublicClient };
15
+ //# sourceMappingURL=publicClient.d.ts.map
@@ -1,47 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBitcoinPublicClient = void 0;
4
- const core_1 = require("@bigmi/core");
5
- const toBigmiChainId_js_1 = require("../utils/toBigmiChainId.js");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_utils_toBigmiChainId = require("../utils/toBigmiChainId.js");
3
+ let _bigmi_core = require("@bigmi/core");
4
+ //#region src/client/publicClient.ts
6
5
  const publicClients = {};
6
+ /**
7
+ * Get an instance of a provider for a specific chain
8
+ * @param client - The SDK client
9
+ * @param chainId - Id of the chain the provider is for
10
+ * @returns The public client for the given chain
11
+ */
7
12
  const getBitcoinPublicClient = async (client, chainId) => {
8
- if (!publicClients[chainId]) {
9
- const urls = await client.getRpcUrlsByChainId(chainId);
10
- const fallbackTransports = urls.map((url) => (0, core_1.http)(url, {
11
- fetchOptions: {
12
- method: 'POST',
13
- },
14
- }));
15
- const _chain = await client.getChainById(chainId);
16
- const chain = {
17
- ..._chain,
18
- ..._chain.metamask,
19
- id: (0, toBigmiChainId_js_1.toBigmiChainId)(_chain.id),
20
- name: _chain.metamask.chainName,
21
- rpcUrls: {
22
- default: { http: _chain.metamask.rpcUrls },
23
- public: { http: _chain.metamask.rpcUrls },
24
- },
25
- };
26
- const bigmiClient = (0, core_1.createClient)({
27
- chain,
28
- rpcSchema: (0, core_1.rpcSchema)(),
29
- transport: (0, core_1.fallback)([
30
- (0, core_1.blockchair)(),
31
- (0, core_1.blockcypher)(),
32
- (0, core_1.mempool)(),
33
- ...fallbackTransports,
34
- ]),
35
- pollingInterval: 10_000,
36
- })
37
- .extend(core_1.publicActions)
38
- .extend(core_1.walletActions);
39
- publicClients[chainId] = bigmiClient;
40
- }
41
- if (!publicClients[chainId]) {
42
- throw new Error(`Unable to configure provider for chain ${chainId}`);
43
- }
44
- return publicClients[chainId];
13
+ if (!publicClients[chainId]) {
14
+ const fallbackTransports = (await client.getRpcUrlsByChainId(chainId)).map((url) => (0, _bigmi_core.http)(url, { fetchOptions: { method: "POST" } }));
15
+ const _chain = await client.getChainById(chainId);
16
+ publicClients[chainId] = (0, _bigmi_core.createClient)({
17
+ chain: {
18
+ ..._chain,
19
+ ..._chain.metamask,
20
+ id: require_utils_toBigmiChainId.toBigmiChainId(_chain.id),
21
+ name: _chain.metamask.chainName,
22
+ rpcUrls: {
23
+ default: { http: _chain.metamask.rpcUrls },
24
+ public: { http: _chain.metamask.rpcUrls }
25
+ }
26
+ },
27
+ rpcSchema: (0, _bigmi_core.rpcSchema)(),
28
+ transport: (0, _bigmi_core.fallback)([
29
+ (0, _bigmi_core.blockchair)(),
30
+ (0, _bigmi_core.blockcypher)(),
31
+ (0, _bigmi_core.mempool)(),
32
+ ...fallbackTransports
33
+ ]),
34
+ pollingInterval: 1e4
35
+ }).extend(_bigmi_core.publicActions).extend(_bigmi_core.walletActions);
36
+ }
37
+ if (!publicClients[chainId]) throw new Error(`Unable to configure provider for chain ${chainId}`);
38
+ return publicClients[chainId];
45
39
  };
40
+ //#endregion
46
41
  exports.getBitcoinPublicClient = getBitcoinPublicClient;
42
+
47
43
  //# sourceMappingURL=publicClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"publicClient.js","sourceRoot":"","sources":["../../../src/client/publicClient.ts"],"names":[],"mappings":";;;AAAA,sCAkBoB;AAEpB,kEAA2D;AAW3D,MAAM,aAAa,GAAiC,EAAE,CAAA;AAQ/C,MAAM,sBAAsB,GAAG,KAAK,EACzC,MAAiB,EACjB,OAAe,EACQ,EAAE;IACzB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;QACtD,MAAM,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAC1C,IAAA,WAAI,EAAC,GAAG,EAAE;YACR,YAAY,EAAE;gBACZ,MAAM,EAAE,MAAM;aACf;SACF,CAAC,CACH,CAAA;QACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;QACjD,MAAM,KAAK,GAAU;YACnB,GAAG,MAAM;YACT,GAAG,MAAM,CAAC,QAAQ;YAClB,EAAE,EAAE,IAAA,kCAAc,EAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS;YAC/B,OAAO,EAAE;gBACP,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE;gBAC1C,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE;aAC1C;SACF,CAAA;QACD,MAAM,WAAW,GAAG,IAAA,mBAAY,EAAC;YAC/B,KAAK;YACL,SAAS,EAAE,IAAA,gBAAS,GAAc;YAClC,SAAS,EAAE,IAAA,eAAQ,EAAC;gBAClB,IAAA,iBAAU,GAAE;gBACZ,IAAA,kBAAW,GAAE;gBACb,IAAA,cAAO,GAAE;gBACT,GAAG,kBAAkB;aACtB,CAAC;YACF,eAAe,EAAE,MAAM;SACxB,CAAC;aACC,MAAM,CAAC,oBAAa,CAAC;aACrB,MAAM,CAAC,oBAAa,CAAC,CAAA;QACxB,aAAa,CAAC,OAAO,CAAC,GAAG,WAAW,CAAA;IACtC,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,0CAA0C,OAAO,EAAE,CAAC,CAAA;IACtE,CAAC;IAED,OAAO,aAAa,CAAC,OAAO,CAAC,CAAA;AAC/B,CAAC,CAAA;AA7CY,QAAA,sBAAsB,0BA6ClC"}
1
+ {"version":3,"file":"publicClient.js","names":["toBigmiChainId","publicActions","walletActions"],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import {\n type Account,\n blockchair,\n blockcypher,\n type Chain,\n type Client,\n createClient,\n type FallbackTransport,\n fallback,\n type HttpTransport,\n http,\n mempool,\n type PublicActions,\n publicActions,\n rpcSchema,\n type UTXOSchema,\n type WalletActions,\n walletActions,\n} from '@bigmi/core'\nimport type { SDKClient } from '@lifi/sdk'\nimport { toBigmiChainId } from '../utils/toBigmiChainId.js'\n\nexport type PublicClient = Client<\n FallbackTransport<readonly HttpTransport[]>,\n Chain,\n Account | undefined,\n UTXOSchema,\n PublicActions & WalletActions\n>\n\n// cached providers\nconst publicClients: Record<number, PublicClient> = {}\n\n/**\n * Get an instance of a provider for a specific chain\n * @param client - The SDK client\n * @param chainId - Id of the chain the provider is for\n * @returns The public client for the given chain\n */\nexport const getBitcoinPublicClient = async (\n client: SDKClient,\n chainId: number\n): Promise<PublicClient> => {\n if (!publicClients[chainId]) {\n const urls = await client.getRpcUrlsByChainId(chainId)\n const fallbackTransports = urls.map((url) =>\n http(url, {\n fetchOptions: {\n method: 'POST',\n },\n })\n )\n const _chain = await client.getChainById(chainId)\n const chain: Chain = {\n ..._chain,\n ..._chain.metamask,\n id: toBigmiChainId(_chain.id),\n name: _chain.metamask.chainName,\n rpcUrls: {\n default: { http: _chain.metamask.rpcUrls },\n public: { http: _chain.metamask.rpcUrls },\n },\n }\n const bigmiClient = createClient({\n chain,\n rpcSchema: rpcSchema<UTXOSchema>(),\n transport: fallback([\n blockchair(),\n blockcypher(),\n mempool(),\n ...fallbackTransports,\n ]),\n pollingInterval: 10_000,\n })\n .extend(publicActions)\n .extend(walletActions)\n publicClients[chainId] = bigmiClient\n }\n\n if (!publicClients[chainId]) {\n throw new Error(`Unable to configure provider for chain ${chainId}`)\n }\n\n return publicClients[chainId]\n}\n"],"mappings":";;;;AA+BA,MAAM,gBAA8C,CAAC;;;;;;;AAQrD,MAAa,yBAAyB,OACpC,QACA,YAC0B;CAC1B,IAAI,CAAC,cAAc,UAAU;EAE3B,MAAM,sBAAqB,MADR,OAAO,oBAAoB,OAAO,EAAA,CACrB,KAAK,SAAA,GAAA,YAAA,KAAA,CAC9B,KAAK,EACR,cAAc,EACZ,QAAQ,OACV,EACF,CAAC,CACH;EACA,MAAM,SAAS,MAAM,OAAO,aAAa,OAAO;EAwBhD,cAAc,YAAA,GAAA,YAAA,aAAA,CAbmB;GAC/B,OAAA;IAVA,GAAG;IACH,GAAG,OAAO;IACV,IAAIA,6BAAAA,eAAe,OAAO,EAAE;IAC5B,MAAM,OAAO,SAAS;IACtB,SAAS;KACP,SAAS,EAAE,MAAM,OAAO,SAAS,QAAQ;KACzC,QAAQ,EAAE,MAAM,OAAO,SAAS,QAAQ;IAC1C;GAGI;GACJ,YAAA,GAAA,YAAA,UAAA,CAAiC;GACjC,YAAA,GAAA,YAAA,SAAA,CAAoB;gCACP;iCACC;6BACJ;IACR,GAAG;GACL,CAAC;GACD,iBAAiB;EACnB,CAAC,CAAC,CACC,OAAOC,YAAAA,aAAa,CAAC,CACrB,OAAOC,YAAAA,aACyB;CACrC;CAEA,IAAI,CAAC,cAAc,UACjB,MAAM,IAAI,MAAM,0CAA0C,SAAS;CAGrE,OAAO,cAAc;AACvB"}
@@ -0,0 +1,19 @@
1
+ import { BitcoinStepExecutorContext } from "../types.js";
2
+ import { Client } from "@bigmi/core";
3
+ import { BaseStepExecutor, ExecutionAction, LiFiStepExtended, SDKError, StepExecutorBaseContext, StepExecutorOptions, TaskPipeline } from "@lifi/sdk";
4
+
5
+ //#region src/core/BitcoinStepExecutor.d.ts
6
+ interface BitcoinStepExecutorOptions extends StepExecutorOptions {
7
+ client: Client;
8
+ }
9
+ declare class BitcoinStepExecutor extends BaseStepExecutor {
10
+ private client;
11
+ constructor(options: BitcoinStepExecutorOptions);
12
+ checkClient: (step: LiFiStepExtended) => void;
13
+ override createPipeline: (context: BitcoinStepExecutorContext) => TaskPipeline;
14
+ override parseErrors: (error: Error, step?: LiFiStepExtended, action?: ExecutionAction) => Promise<SDKError>;
15
+ override createContext: (baseContext: StepExecutorBaseContext) => Promise<BitcoinStepExecutorContext>;
16
+ }
17
+ //#endregion
18
+ export { BitcoinStepExecutor };
19
+ //# sourceMappingURL=BitcoinStepExecutor.d.ts.map
@@ -0,0 +1,47 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_client_publicClient = require("../client/publicClient.js");
3
+ const require_errors_parseBitcoinErrors = require("../errors/parseBitcoinErrors.js");
4
+ const require_core_tasks_BitcoinSignAndExecuteTask = require("./tasks/BitcoinSignAndExecuteTask.js");
5
+ const require_core_tasks_BitcoinWaitForTransactionTask = require("./tasks/BitcoinWaitForTransactionTask.js");
6
+ let _lifi_sdk = require("@lifi/sdk");
7
+ //#region src/core/BitcoinStepExecutor.ts
8
+ var BitcoinStepExecutor = class extends _lifi_sdk.BaseStepExecutor {
9
+ client;
10
+ constructor(options) {
11
+ super(options);
12
+ this.client = options.client;
13
+ }
14
+ checkClient = (step) => {
15
+ if (this.client.account?.address !== step.action.fromAddress) throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.WalletChangedDuringExecution, "The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.");
16
+ };
17
+ createPipeline = (context) => {
18
+ const { step, isBridgeExecution } = context;
19
+ const tasks = [
20
+ new _lifi_sdk.CheckBalanceTask(),
21
+ new _lifi_sdk.PrepareTransactionTask(),
22
+ new require_core_tasks_BitcoinSignAndExecuteTask.BitcoinSignAndExecuteTask(),
23
+ new require_core_tasks_BitcoinWaitForTransactionTask.BitcoinWaitForTransactionTask(),
24
+ new _lifi_sdk.WaitForTransactionStatusTask(isBridgeExecution ? "RECEIVING_CHAIN" : "SWAP")
25
+ ];
26
+ const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
27
+ const taskName = swapOrBridgeAction?.txHash ? swapOrBridgeAction?.status === "DONE" ? _lifi_sdk.WaitForTransactionStatusTask.name : require_core_tasks_BitcoinWaitForTransactionTask.BitcoinWaitForTransactionTask.name : _lifi_sdk.CheckBalanceTask.name;
28
+ const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
29
+ return new _lifi_sdk.TaskPipeline(tasks.slice(firstTaskIndex));
30
+ };
31
+ parseErrors = (error, step, action) => require_errors_parseBitcoinErrors.parseBitcoinErrors(error, step, action);
32
+ createContext = async (baseContext) => {
33
+ const { client, fromChain } = baseContext;
34
+ const publicClient = await require_client_publicClient.getBitcoinPublicClient(client, fromChain.id);
35
+ return {
36
+ ...baseContext,
37
+ pollingIntervalMs: 1e4,
38
+ checkClient: this.checkClient,
39
+ walletClient: this.client,
40
+ publicClient
41
+ };
42
+ };
43
+ };
44
+ //#endregion
45
+ exports.BitcoinStepExecutor = BitcoinStepExecutor;
46
+
47
+ //# sourceMappingURL=BitcoinStepExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BitcoinStepExecutor.js","names":["BaseStepExecutor","TransactionError","LiFiErrorCode","CheckBalanceTask","PrepareTransactionTask","BitcoinSignAndExecuteTask","BitcoinWaitForTransactionTask","WaitForTransactionStatusTask","TaskPipeline","parseBitcoinErrors","getBitcoinPublicClient"],"sources":["../../../src/core/BitcoinStepExecutor.ts"],"sourcesContent":["import type { Client } from '@bigmi/core'\nimport {\n BaseStepExecutor,\n CheckBalanceTask,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStepExtended,\n PrepareTransactionTask,\n type SDKError,\n type StepExecutorBaseContext,\n type StepExecutorOptions,\n TaskPipeline,\n TransactionError,\n WaitForTransactionStatusTask,\n} from '@lifi/sdk'\nimport { getBitcoinPublicClient } from '../client/publicClient.js'\nimport { parseBitcoinErrors } from '../errors/parseBitcoinErrors.js'\nimport type { BitcoinStepExecutorContext } from '../types.js'\nimport { BitcoinSignAndExecuteTask } from './tasks/BitcoinSignAndExecuteTask.js'\nimport { BitcoinWaitForTransactionTask } from './tasks/BitcoinWaitForTransactionTask.js'\n\ninterface BitcoinStepExecutorOptions extends StepExecutorOptions {\n client: Client\n}\n\nexport class BitcoinStepExecutor extends BaseStepExecutor {\n private client: Client\n\n constructor(options: BitcoinStepExecutorOptions) {\n super(options)\n this.client = options.client\n }\n\n checkClient = (step: LiFiStepExtended): void => {\n // TODO: check chain and possibly implement chain switch?\n // Prevent execution of the quote by wallet different from the one which requested the quote\n if (this.client.account?.address !== step.action.fromAddress) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n }\n\n override createPipeline = (\n context: BitcoinStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution } = context\n\n const tasks = [\n new CheckBalanceTask(),\n new PrepareTransactionTask(),\n new BitcoinSignAndExecuteTask(),\n new BitcoinWaitForTransactionTask(),\n new WaitForTransactionStatusTask(\n isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'\n ),\n ]\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n const taskName = swapOrBridgeAction?.txHash\n ? swapOrBridgeAction?.status === 'DONE'\n ? WaitForTransactionStatusTask.name\n : BitcoinWaitForTransactionTask.name\n : CheckBalanceTask.name\n\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor.name === taskName\n )\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction\n ): Promise<SDKError> => parseBitcoinErrors(error, step, action)\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<BitcoinStepExecutorContext> => {\n const { client, fromChain } = baseContext\n\n const publicClient = await getBitcoinPublicClient(client, fromChain.id)\n\n return {\n ...baseContext,\n pollingIntervalMs: 10_000,\n checkClient: this.checkClient,\n walletClient: this.client,\n publicClient,\n }\n }\n}\n"],"mappings":";;;;;;;AAyBA,IAAa,sBAAb,cAAyCA,UAAAA,iBAAiB;CACxD;CAEA,YAAY,SAAqC;EAC/C,MAAM,OAAO;EACb,KAAK,SAAS,QAAQ;CACxB;CAEA,eAAe,SAAiC;EAG9C,IAAI,KAAK,OAAO,SAAS,YAAY,KAAK,OAAO,aAC/C,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,8BACd,mHACF;CAEJ;CAEA,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,sBAAsB;EAEpC,MAAM,QAAQ;GACZ,IAAIC,UAAAA,iBAAiB;GACrB,IAAIC,UAAAA,uBAAuB;GAC3B,IAAIC,6CAAAA,0BAA0B;GAC9B,IAAIC,iDAAAA,8BAA8B;GAClC,IAAIC,UAAAA,6BACF,oBAAoB,oBAAoB,MAC1C;EACF;EACA,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,MACtC;EAEA,MAAM,WAAW,oBAAoB,SACjC,oBAAoB,WAAW,SAC7BA,UAAAA,6BAA6B,OAC7BD,iDAAAA,8BAA8B,OAChCH,UAAAA,iBAAiB;EAErB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,QACtC;EAIA,OAAO,IAAIK,UAAAA,aAFQ,MAAM,MAAM,cAEE,CAAC;CACpC;CAEA,eACE,OACA,MACA,WACsBC,kCAAAA,mBAAmB,OAAO,MAAM,MAAM;CAE9D,gBAAyB,OACvB,gBACwC;EACxC,MAAM,EAAE,QAAQ,cAAc;EAE9B,MAAM,eAAe,MAAMC,4BAAAA,uBAAuB,QAAQ,UAAU,EAAE;EAEtE,OAAO;GACL,GAAG;GACH,mBAAmB;GACnB,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB;EACF;CACF;AACF"}
@@ -0,0 +1,10 @@
1
+ import { BitcoinStepExecutorContext } from "../../types.js";
2
+ import { BaseStepExecutionTask, TaskResult } from "@lifi/sdk";
3
+
4
+ //#region src/core/tasks/BitcoinSignAndExecuteTask.d.ts
5
+ declare class BitcoinSignAndExecuteTask extends BaseStepExecutionTask {
6
+ run(context: BitcoinStepExecutorContext): Promise<TaskResult>;
7
+ }
8
+ //#endregion
9
+ export { BitcoinSignAndExecuteTask };
10
+ //# sourceMappingURL=BitcoinSignAndExecuteTask.d.ts.map