@lifi/sdk-provider-bitcoin 4.0.0-beta.0 → 4.0.0-beta.10

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 (142) hide show
  1. package/dist/cjs/BitcoinProvider.d.ts +7 -2
  2. package/dist/cjs/BitcoinProvider.js +31 -34
  3. package/dist/cjs/BitcoinProvider.js.map +1 -1
  4. package/dist/cjs/_virtual/_rolldown/runtime.js +23 -0
  5. package/dist/cjs/actions/getBitcoinBalance.d.ts +7 -2
  6. package/dist/cjs/actions/getBitcoinBalance.js +22 -24
  7. package/dist/cjs/actions/getBitcoinBalance.js.map +1 -1
  8. package/dist/cjs/actions/resolveBitcoinAddress.d.ts +5 -1
  9. package/dist/cjs/actions/resolveBitcoinAddress.js +6 -4
  10. package/dist/cjs/actions/resolveBitcoinAddress.js.map +1 -1
  11. package/dist/cjs/client/publicClient.d.ts +15 -4
  12. package/dist/cjs/client/publicClient.js +39 -42
  13. package/dist/cjs/client/publicClient.js.map +1 -1
  14. package/dist/cjs/core/BitcoinStepExecutor.d.ts +16 -12
  15. package/dist/cjs/core/BitcoinStepExecutor.js +46 -51
  16. package/dist/cjs/core/BitcoinStepExecutor.js.map +1 -1
  17. package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.d.ts +9 -4
  18. package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js +73 -99
  19. package/dist/cjs/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -1
  20. package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.d.ts +9 -4
  21. package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js +37 -43
  22. package/dist/cjs/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -1
  23. package/dist/cjs/errors/parseBitcoinErrors.d.ts +7 -2
  24. package/dist/cjs/errors/parseBitcoinErrors.js +18 -26
  25. package/dist/cjs/errors/parseBitcoinErrors.js.map +1 -1
  26. package/dist/cjs/index.d.ts +3 -3
  27. package/dist/cjs/index.js +5 -8
  28. package/dist/cjs/types.d.ts +17 -12
  29. package/dist/cjs/types.js +8 -5
  30. package/dist/cjs/types.js.map +1 -1
  31. package/dist/cjs/utils/generateRedeemScript.d.ts +10 -1
  32. package/dist/cjs/utils/generateRedeemScript.js +12 -5
  33. package/dist/cjs/utils/generateRedeemScript.js.map +1 -1
  34. package/dist/cjs/utils/isPsbtFinalized.d.ts +7 -2
  35. package/dist/cjs/utils/isPsbtFinalized.js +11 -10
  36. package/dist/cjs/utils/isPsbtFinalized.js.map +1 -1
  37. package/dist/cjs/utils/toBigmiChainId.d.ts +8 -3
  38. package/dist/cjs/utils/toBigmiChainId.js +11 -11
  39. package/dist/cjs/utils/toBigmiChainId.js.map +1 -1
  40. package/dist/cjs/utils/toXOnly.d.ts +5 -1
  41. package/dist/cjs/utils/toXOnly.js +4 -3
  42. package/dist/cjs/utils/toXOnly.js.map +1 -1
  43. package/dist/cjs/version.d.ts +6 -2
  44. package/dist/cjs/version.js +8 -5
  45. package/dist/cjs/version.js.map +1 -1
  46. package/dist/esm/BitcoinProvider.d.ts +7 -2
  47. package/dist/esm/BitcoinProvider.d.ts.map +1 -0
  48. package/dist/esm/BitcoinProvider.js +30 -32
  49. package/dist/esm/BitcoinProvider.js.map +1 -1
  50. package/dist/esm/actions/getBitcoinBalance.d.ts +7 -2
  51. package/dist/esm/actions/getBitcoinBalance.d.ts.map +1 -0
  52. package/dist/esm/actions/getBitcoinBalance.js +22 -22
  53. package/dist/esm/actions/getBitcoinBalance.js.map +1 -1
  54. package/dist/esm/actions/resolveBitcoinAddress.d.ts +5 -1
  55. package/dist/esm/actions/resolveBitcoinAddress.d.ts.map +1 -0
  56. package/dist/esm/actions/resolveBitcoinAddress.js +6 -3
  57. package/dist/esm/actions/resolveBitcoinAddress.js.map +1 -1
  58. package/dist/esm/client/publicClient.d.ts +14 -9
  59. package/dist/esm/client/publicClient.d.ts.map +1 -0
  60. package/dist/esm/client/publicClient.js +38 -46
  61. package/dist/esm/client/publicClient.js.map +1 -1
  62. package/dist/esm/core/BitcoinStepExecutor.d.ts +16 -12
  63. package/dist/esm/core/BitcoinStepExecutor.d.ts.map +1 -0
  64. package/dist/esm/core/BitcoinStepExecutor.js +45 -50
  65. package/dist/esm/core/BitcoinStepExecutor.js.map +1 -1
  66. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts +9 -4
  67. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.d.ts.map +1 -0
  68. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js +71 -105
  69. package/dist/esm/core/tasks/BitcoinSignAndExecuteTask.js.map +1 -1
  70. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts +9 -4
  71. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.d.ts.map +1 -0
  72. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js +36 -40
  73. package/dist/esm/core/tasks/BitcoinWaitForTransactionTask.js.map +1 -1
  74. package/dist/esm/errors/parseBitcoinErrors.d.ts +7 -2
  75. package/dist/esm/errors/parseBitcoinErrors.d.ts.map +1 -0
  76. package/dist/esm/errors/parseBitcoinErrors.js +17 -24
  77. package/dist/esm/errors/parseBitcoinErrors.js.map +1 -1
  78. package/dist/esm/index.d.ts +3 -3
  79. package/dist/esm/index.js +3 -4
  80. package/dist/esm/package.json +1 -1
  81. package/dist/esm/types.d.ts +17 -12
  82. package/dist/esm/types.d.ts.map +1 -0
  83. package/dist/esm/types.js +7 -3
  84. package/dist/esm/types.js.map +1 -1
  85. package/dist/esm/utils/generateRedeemScript.d.ts +9 -5
  86. package/dist/esm/utils/generateRedeemScript.d.ts.map +1 -0
  87. package/dist/esm/utils/generateRedeemScript.js +10 -8
  88. package/dist/esm/utils/generateRedeemScript.js.map +1 -1
  89. package/dist/esm/utils/isPsbtFinalized.d.ts +7 -2
  90. package/dist/esm/utils/isPsbtFinalized.d.ts.map +1 -0
  91. package/dist/esm/utils/isPsbtFinalized.js +11 -8
  92. package/dist/esm/utils/isPsbtFinalized.js.map +1 -1
  93. package/dist/esm/utils/toBigmiChainId.d.ts +8 -3
  94. package/dist/esm/utils/toBigmiChainId.d.ts.map +1 -0
  95. package/dist/esm/utils/toBigmiChainId.js +11 -9
  96. package/dist/esm/utils/toBigmiChainId.js.map +1 -1
  97. package/dist/esm/utils/toXOnly.d.ts +5 -1
  98. package/dist/esm/utils/toXOnly.d.ts.map +1 -0
  99. package/dist/esm/utils/toXOnly.js +5 -2
  100. package/dist/esm/utils/toXOnly.js.map +1 -1
  101. package/dist/esm/version.d.ts +6 -2
  102. package/dist/esm/version.d.ts.map +1 -0
  103. package/dist/esm/version.js +6 -2
  104. package/dist/esm/version.js.map +1 -1
  105. package/package.json +6 -6
  106. package/src/actions/getBitcoinBalance.ts +15 -3
  107. package/src/core/BitcoinStepExecutor.ts +4 -2
  108. package/src/utils/generateRedeemScript.ts +3 -1
  109. package/src/utils/toXOnly.ts +1 -1
  110. package/src/version.ts +1 -1
  111. package/dist/cjs/index.js.map +0 -1
  112. package/dist/esm/index.js.map +0 -1
  113. package/dist/types/BitcoinProvider.d.ts +0 -3
  114. package/dist/types/BitcoinProvider.d.ts.map +0 -1
  115. package/dist/types/actions/getBitcoinBalance.d.ts +0 -3
  116. package/dist/types/actions/getBitcoinBalance.d.ts.map +0 -1
  117. package/dist/types/actions/resolveBitcoinAddress.d.ts +0 -2
  118. package/dist/types/actions/resolveBitcoinAddress.d.ts.map +0 -1
  119. package/dist/types/client/publicClient.d.ts +0 -11
  120. package/dist/types/client/publicClient.d.ts.map +0 -1
  121. package/dist/types/core/BitcoinStepExecutor.d.ts +0 -16
  122. package/dist/types/core/BitcoinStepExecutor.d.ts.map +0 -1
  123. package/dist/types/core/tasks/BitcoinSignAndExecuteTask.d.ts +0 -6
  124. package/dist/types/core/tasks/BitcoinSignAndExecuteTask.d.ts.map +0 -1
  125. package/dist/types/core/tasks/BitcoinWaitForTransactionTask.d.ts +0 -6
  126. package/dist/types/core/tasks/BitcoinWaitForTransactionTask.d.ts.map +0 -1
  127. package/dist/types/errors/parseBitcoinErrors.d.ts +0 -3
  128. package/dist/types/errors/parseBitcoinErrors.d.ts.map +0 -1
  129. package/dist/types/index.d.ts +0 -4
  130. package/dist/types/index.d.ts.map +0 -1
  131. package/dist/types/types.d.ts +0 -16
  132. package/dist/types/types.d.ts.map +0 -1
  133. package/dist/types/utils/generateRedeemScript.d.ts +0 -7
  134. package/dist/types/utils/generateRedeemScript.d.ts.map +0 -1
  135. package/dist/types/utils/isPsbtFinalized.d.ts +0 -3
  136. package/dist/types/utils/isPsbtFinalized.d.ts.map +0 -1
  137. package/dist/types/utils/toBigmiChainId.d.ts +0 -4
  138. package/dist/types/utils/toBigmiChainId.d.ts.map +0 -1
  139. package/dist/types/utils/toXOnly.d.ts +0 -2
  140. package/dist/types/utils/toXOnly.d.ts.map +0 -1
  141. package/dist/types/version.d.ts +0 -3
  142. package/dist/types/version.d.ts.map +0 -1
@@ -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,34 @@
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("./core/BitcoinStepExecutor.js");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./_virtual/_rolldown/runtime.js");
3
+ const require_actions_getBitcoinBalance = require("./actions/getBitcoinBalance.js");
4
+ const require_actions_resolveBitcoinAddress = require("./actions/resolveBitcoinAddress.js");
5
+ const require_core_BitcoinStepExecutor = require("./core/BitcoinStepExecutor.js");
6
+ let _bigmi_core = require("@bigmi/core");
7
+ let _lifi_sdk = require("@lifi/sdk");
8
+ //#region src/BitcoinProvider.ts
9
9
  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
- };
10
+ const _options = options ?? {};
11
+ return {
12
+ get type() {
13
+ return _lifi_sdk.ChainType.UTXO;
14
+ },
15
+ isAddress: _bigmi_core.isUTXOAddress,
16
+ resolveAddress: require_actions_resolveBitcoinAddress.resolveBitcoinAddress,
17
+ getBalance: require_actions_getBitcoinBalance.getBitcoinBalance,
18
+ async getStepExecutor(options) {
19
+ if (!_options.getWalletClient) throw new Error("Client is not provided.");
20
+ return new require_core_BitcoinStepExecutor.BitcoinStepExecutor({
21
+ client: await _options.getWalletClient(),
22
+ routeId: options.routeId,
23
+ executionOptions: { ...options.executionOptions }
24
+ });
25
+ },
26
+ setOptions(options) {
27
+ Object.assign(_options, options);
28
+ }
29
+ };
36
30
  }
31
+ //#endregion
32
+ exports.BitcoinProvider = BitcoinProvider;
33
+
37
34
  //# 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,0EAAmE;AAGnE,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,EAAE;CACtD,OAAO;EACL,IAAI,OAAO;GACT,OAAOA,UAAAA,UAAU;;EAEnB,WAAWC,YAAAA;EACX,gBAAgBC,sCAAAA;EAChB,YAAYC,kCAAAA;EACZ,MAAM,gBACJ,SAC8B;GAC9B,IAAI,CAAC,SAAS,iBACZ,MAAM,IAAI,MAAM,0BAA0B;GAa5C,OAAO,IARcC,iCAAAA,oBAAoB;IACvC,QAAQ,MAHiB,SAAS,iBAAiB;IAInD,SAAS,QAAQ;IACjB,kBAAkB,EAChB,GAAG,QAAQ,kBACZ;IACF,CAEc;;EAEjB,WAAW,SAAiC;GAC1C,OAAO,OAAO,UAAU,QAAQ;;EAEnC"}
@@ -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,26 @@
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
+ require("../_virtual/_rolldown/runtime.js");
3
+ const require_client_publicClient = require("../client/publicClient.js");
4
+ let _lifi_sdk = require("@lifi/sdk");
5
+ //#region src/actions/getBitcoinBalance.ts
6
6
  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
- }));
7
+ if (tokens.length === 0) return [];
8
+ const { chainId } = tokens[0];
9
+ for (const token of tokens) if (token.chainId !== chainId) console.warn("Requested tokens have to be on the same chain.");
10
+ const bigmiClient = await require_client_publicClient.getBitcoinPublicClient(client, _lifi_sdk.ChainId.BTC);
11
+ const [balance, blockCount] = await Promise.allSettled([bigmiClient.getBalance({ address: walletAddress }), bigmiClient.getBlockCount()]);
12
+ const blockNumber = blockCount.status === "fulfilled" ? BigInt(blockCount.value) : 0n;
13
+ if (balance.status !== "fulfilled") return tokens.map((token) => ({
14
+ ...token,
15
+ blockNumber
16
+ }));
17
+ return tokens.map((token) => ({
18
+ ...token,
19
+ amount: balance.value,
20
+ blockNumber
21
+ }));
26
22
  };
23
+ //#endregion
27
24
  exports.getBitcoinBalance = getBitcoinBalance;
25
+
28
26
  //# 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,EAAE;CAEX,MAAM,EAAE,YAAY,OAAO;CAC3B,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,YAAY,SACpB,QAAQ,KAAK,iDAAiD;CAGlE,MAAM,cAAc,MAAMA,4BAAAA,uBAAuB,QAAQC,UAAAA,QAAQ,IAAI;CACrE,MAAM,CAAC,SAAS,cAAc,MAAM,QAAQ,WAAW,CACrD,YAAY,WAAW,EAAE,SAAS,eAAe,CAAC,EAClD,YAAY,eAAe,CAC5B,CAAC;CAEF,MAAM,cACJ,WAAW,WAAW,cAAc,OAAO,WAAW,MAAM,GAAG;CAEjE,IAAI,QAAQ,WAAW,aAGrB,OAAO,OAAO,KAAK,WAAW;EAC5B,GAAG;EACH;EACD,EAAE;CAGL,OAAO,OAAO,KAAK,WAAW;EAC5B,GAAG;EACH,QAAQ,QAAQ;EAChB;EACD,EAAE"}
@@ -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"}
@@ -1,4 +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';
3
- export type PublicClient = Client<FallbackTransport<readonly HttpTransport[]>, Chain, Account | undefined, UTXOSchema, PublicActions & WalletActions>;
4
- export declare const getBitcoinPublicClient: (client: SDKClient, chainId: number) => Promise<PublicClient>;
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
5
+ type PublicClient = Client<FallbackTransport<readonly HttpTransport[]>, Chain, Account | undefined, UTXOSchema, PublicActions & WalletActions>;
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,44 @@
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
+ require("../_virtual/_rolldown/runtime.js");
3
+ const require_utils_toBigmiChainId = require("../utils/toBigmiChainId.js");
4
+ let _bigmi_core = require("@bigmi/core");
5
+ //#region src/client/publicClient.ts
6
6
  const publicClients = {};
7
+ /**
8
+ * Get an instance of a provider for a specific chain
9
+ * @param client - The SDK client
10
+ * @param chainId - Id of the chain the provider is for
11
+ * @returns The public client for the given chain
12
+ */
7
13
  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];
14
+ if (!publicClients[chainId]) {
15
+ const fallbackTransports = (await client.getRpcUrlsByChainId(chainId)).map((url) => (0, _bigmi_core.http)(url, { fetchOptions: { method: "POST" } }));
16
+ const _chain = await client.getChainById(chainId);
17
+ publicClients[chainId] = (0, _bigmi_core.createClient)({
18
+ chain: {
19
+ ..._chain,
20
+ ..._chain.metamask,
21
+ id: require_utils_toBigmiChainId.toBigmiChainId(_chain.id),
22
+ name: _chain.metamask.chainName,
23
+ rpcUrls: {
24
+ default: { http: _chain.metamask.rpcUrls },
25
+ public: { http: _chain.metamask.rpcUrls }
26
+ }
27
+ },
28
+ rpcSchema: (0, _bigmi_core.rpcSchema)(),
29
+ transport: (0, _bigmi_core.fallback)([
30
+ (0, _bigmi_core.blockchair)(),
31
+ (0, _bigmi_core.blockcypher)(),
32
+ (0, _bigmi_core.mempool)(),
33
+ ...fallbackTransports
34
+ ]),
35
+ pollingInterval: 1e4
36
+ }).extend(_bigmi_core.publicActions).extend(_bigmi_core.walletActions);
37
+ }
38
+ if (!publicClients[chainId]) throw new Error(`Unable to configure provider for chain ${chainId}`);
39
+ return publicClients[chainId];
45
40
  };
41
+ //#endregion
46
42
  exports.getBitcoinPublicClient = getBitcoinPublicClient;
43
+
47
44
  //# 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,EAAE;;;;;;;AAQtD,MAAa,yBAAyB,OACpC,QACA,YAC0B;CAC1B,IAAI,CAAC,cAAc,UAAU;EAE3B,MAAM,sBAAqB,MADR,OAAO,oBAAoB,QAAQ,EACtB,KAAK,SAAA,GAAA,YAAA,MAC9B,KAAK,EACR,cAAc,EACZ,QAAQ,QACT,EACF,CAAC,CACH;EACD,MAAM,SAAS,MAAM,OAAO,aAAa,QAAQ;EAwBjD,cAAc,YAAA,GAAA,YAAA,cAbmB;GAC/B,OAAA;IAVA,GAAG;IACH,GAAG,OAAO;IACV,IAAIA,6BAAAA,eAAe,OAAO,GAAG;IAC7B,MAAM,OAAO,SAAS;IACtB,SAAS;KACP,SAAS,EAAE,MAAM,OAAO,SAAS,SAAS;KAC1C,QAAQ,EAAE,MAAM,OAAO,SAAS,SAAS;KAC1C;IAGI;GACL,YAAA,GAAA,YAAA,YAAkC;GAClC,YAAA,GAAA,YAAA,UAAoB;iCACN;kCACC;8BACJ;IACT,GAAG;IACJ,CAAC;GACF,iBAAiB;GAClB,CAAC,CACC,OAAOC,YAAAA,cAAc,CACrB,OAAOC,YAAAA,cAC0B;;CAGtC,IAAI,CAAC,cAAc,UACjB,MAAM,IAAI,MAAM,0CAA0C,UAAU;CAGtE,OAAO,cAAc"}
@@ -1,15 +1,19 @@
1
- import type { Client } from '@bigmi/core';
2
- import { BaseStepExecutor, type ExecutionAction, type LiFiStepExtended, type SDKError, type StepExecutorBaseContext, type StepExecutorOptions, TaskPipeline } from '@lifi/sdk';
3
- import type { BitcoinStepExecutorContext } from '../types.js';
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
4
6
  interface BitcoinStepExecutorOptions extends StepExecutorOptions {
5
- client: Client;
7
+ client: Client;
6
8
  }
7
- export declare class BitcoinStepExecutor extends BaseStepExecutor {
8
- private client;
9
- constructor(options: BitcoinStepExecutorOptions);
10
- checkClient: (step: LiFiStepExtended) => void;
11
- createPipeline: (context: BitcoinStepExecutorContext) => TaskPipeline;
12
- parseErrors: (error: Error, step?: LiFiStepExtended, action?: ExecutionAction) => Promise<SDKError>;
13
- createContext: (baseContext: StepExecutorBaseContext) => Promise<BitcoinStepExecutorContext>;
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>;
14
16
  }
15
- export {};
17
+ //#endregion
18
+ export { BitcoinStepExecutor };
19
+ //# sourceMappingURL=BitcoinStepExecutor.d.ts.map
@@ -1,53 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BitcoinStepExecutor = void 0;
4
- const sdk_1 = require("@lifi/sdk");
5
- const publicClient_js_1 = require("../client/publicClient.js");
6
- const parseBitcoinErrors_js_1 = require("../errors/parseBitcoinErrors.js");
7
- const BitcoinSignAndExecuteTask_js_1 = require("./tasks/BitcoinSignAndExecuteTask.js");
8
- const BitcoinWaitForTransactionTask_js_1 = require("./tasks/BitcoinWaitForTransactionTask.js");
9
- class BitcoinStepExecutor extends sdk_1.BaseStepExecutor {
10
- client;
11
- constructor(options) {
12
- super(options);
13
- this.client = options.client;
14
- }
15
- checkClient = (step) => {
16
- if (this.client.account?.address !== step.action.fromAddress) {
17
- throw new sdk_1.TransactionError(sdk_1.LiFiErrorCode.WalletChangedDuringExecution, 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.');
18
- }
19
- };
20
- createPipeline = (context) => {
21
- const { step, isBridgeExecution } = context;
22
- const tasks = [
23
- new sdk_1.CheckBalanceTask(),
24
- new sdk_1.PrepareTransactionTask(),
25
- new BitcoinSignAndExecuteTask_js_1.BitcoinSignAndExecuteTask(),
26
- new BitcoinWaitForTransactionTask_js_1.BitcoinWaitForTransactionTask(),
27
- new sdk_1.WaitForTransactionStatusTask(isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'),
28
- ];
29
- const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP');
30
- const taskName = swapOrBridgeAction?.txHash
31
- ? swapOrBridgeAction?.status === 'DONE'
32
- ? sdk_1.WaitForTransactionStatusTask.name
33
- : BitcoinWaitForTransactionTask_js_1.BitcoinWaitForTransactionTask.name
34
- : sdk_1.CheckBalanceTask.name;
35
- const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
36
- const tasksToRun = tasks.slice(firstTaskIndex);
37
- return new sdk_1.TaskPipeline(tasksToRun);
38
- };
39
- parseErrors = (error, step, action) => (0, parseBitcoinErrors_js_1.parseBitcoinErrors)(error, step, action);
40
- createContext = async (baseContext) => {
41
- const { client, fromChain } = baseContext;
42
- const publicClient = await (0, publicClient_js_1.getBitcoinPublicClient)(client, fromChain.id);
43
- return {
44
- ...baseContext,
45
- pollingIntervalMs: 10_000,
46
- checkClient: this.checkClient,
47
- walletClient: this.client,
48
- publicClient,
49
- };
50
- };
51
- }
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../_virtual/_rolldown/runtime.js");
3
+ const require_client_publicClient = require("../client/publicClient.js");
4
+ const require_errors_parseBitcoinErrors = require("../errors/parseBitcoinErrors.js");
5
+ const require_core_tasks_BitcoinSignAndExecuteTask = require("./tasks/BitcoinSignAndExecuteTask.js");
6
+ const require_core_tasks_BitcoinWaitForTransactionTask = require("./tasks/BitcoinWaitForTransactionTask.js");
7
+ let _lifi_sdk = require("@lifi/sdk");
8
+ //#region src/core/BitcoinStepExecutor.ts
9
+ var BitcoinStepExecutor = class extends _lifi_sdk.BaseStepExecutor {
10
+ client;
11
+ constructor(options) {
12
+ super(options);
13
+ this.client = options.client;
14
+ }
15
+ checkClient = (step) => {
16
+ 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.");
17
+ };
18
+ createPipeline = (context) => {
19
+ const { step, isBridgeExecution } = context;
20
+ const tasks = [
21
+ new _lifi_sdk.CheckBalanceTask(),
22
+ new _lifi_sdk.PrepareTransactionTask(),
23
+ new require_core_tasks_BitcoinSignAndExecuteTask.BitcoinSignAndExecuteTask(),
24
+ new require_core_tasks_BitcoinWaitForTransactionTask.BitcoinWaitForTransactionTask(),
25
+ new _lifi_sdk.WaitForTransactionStatusTask(isBridgeExecution ? "RECEIVING_CHAIN" : "SWAP")
26
+ ];
27
+ const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
28
+ const taskName = swapOrBridgeAction?.txHash ? swapOrBridgeAction?.status === "DONE" ? _lifi_sdk.WaitForTransactionStatusTask.name : require_core_tasks_BitcoinWaitForTransactionTask.BitcoinWaitForTransactionTask.name : _lifi_sdk.CheckBalanceTask.name;
29
+ const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
30
+ return new _lifi_sdk.TaskPipeline(tasks.slice(firstTaskIndex));
31
+ };
32
+ parseErrors = (error, step, action) => require_errors_parseBitcoinErrors.parseBitcoinErrors(error, step, action);
33
+ createContext = async (baseContext) => {
34
+ const { client, fromChain } = baseContext;
35
+ const publicClient = await require_client_publicClient.getBitcoinPublicClient(client, fromChain.id);
36
+ return {
37
+ ...baseContext,
38
+ pollingIntervalMs: 1e4,
39
+ checkClient: this.checkClient,
40
+ walletClient: this.client,
41
+ publicClient
42
+ };
43
+ };
44
+ };
45
+ //#endregion
52
46
  exports.BitcoinStepExecutor = BitcoinStepExecutor;
47
+
53
48
  //# sourceMappingURL=BitcoinStepExecutor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BitcoinStepExecutor.js","sourceRoot":"","sources":["../../../src/core/BitcoinStepExecutor.ts"],"names":[],"mappings":";;;AACA,mCAakB;AAClB,+DAAkE;AAClE,2EAAoE;AAEpE,uFAAgF;AAChF,+FAAwF;AAMxF,MAAa,mBAAoB,SAAQ,sBAAgB;IAC/C,MAAM,CAAQ;IAEtB,YAAY,OAAmC;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC9B,CAAC;IAED,WAAW,GAAG,CAAC,IAAsB,EAAE,EAAE;QAGvC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YAC7D,MAAM,IAAI,sBAAgB,CACxB,mBAAa,CAAC,4BAA4B,EAC1C,mHAAmH,CACpH,CAAA;QACH,CAAC;IACH,CAAC,CAAA;IAEQ,cAAc,GAAG,CAAC,OAAmC,EAAE,EAAE;QAChE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAA;QAE3C,MAAM,KAAK,GAAG;YACZ,IAAI,sBAAgB,EAAE;YACtB,IAAI,4BAAsB,EAAE;YAC5B,IAAI,wDAAyB,EAAE;YAC/B,IAAI,gEAA6B,EAAE;YACnC,IAAI,kCAA4B,CAC9B,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAC/C;SACF,CAAA;QACD,MAAM,kBAAkB,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CACtD,IAAI,EACJ,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAC3C,CAAA;QAED,MAAM,QAAQ,GAAG,kBAAkB,EAAE,MAAM;YACzC,CAAC,CAAC,kBAAkB,EAAE,MAAM,KAAK,MAAM;gBACrC,CAAC,CAAC,kCAA4B,CAAC,IAAI;gBACnC,CAAC,CAAC,gEAA6B,CAAC,IAAI;YACtC,CAAC,CAAC,sBAAgB,CAAC,IAAI,CAAA;QAEzB,MAAM,cAAc,GAAG,KAAK,CAAC,SAAS,CACpC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,CAC7C,CAAA;QAED,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QAE9C,OAAO,IAAI,kBAAY,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC,CAAA;IAEQ,WAAW,GAAG,CACrB,KAAY,EACZ,IAAuB,EACvB,MAAwB,EACL,EAAE,CAAC,IAAA,0CAAkB,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IAEtD,aAAa,GAAG,KAAK,EAC5B,WAAoC,EACC,EAAE;QACvC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,WAAW,CAAA;QAEzC,MAAM,YAAY,GAAG,MAAM,IAAA,wCAAsB,EAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,CAAA;QAEvE,OAAO;YACL,GAAG,WAAW;YACd,iBAAiB,EAAE,MAAM;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,MAAM;YACzB,YAAY;SACb,CAAA;IACH,CAAC,CAAA;CACF;AAxED,kDAwEC"}
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,QAAQ;EACd,KAAK,SAAS,QAAQ;;CAGxB,eAAe,SAAiC;EAG9C,IAAI,KAAK,OAAO,SAAS,YAAY,KAAK,OAAO,aAC/C,MAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,8BACd,oHACD;;CAIL,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,sBAAsB;EAEpC,MAAM,QAAQ;GACZ,IAAIC,UAAAA,kBAAkB;GACtB,IAAIC,UAAAA,wBAAwB;GAC5B,IAAIC,6CAAAA,2BAA2B;GAC/B,IAAIC,iDAAAA,+BAA+B;GACnC,IAAIC,UAAAA,6BACF,oBAAoB,oBAAoB,OACzC;GACF;EACD,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,OACrC;EAED,MAAM,WAAW,oBAAoB,SACjC,oBAAoB,WAAW,SAC7BA,UAAAA,6BAA6B,OAC7BD,iDAAAA,8BAA8B,OAChCH,UAAAA,iBAAiB;EAErB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,SACrC;EAID,OAAO,IAAIK,UAAAA,aAFQ,MAAM,MAAM,eAEG,CAAC;;CAGrC,eACE,OACA,MACA,WACsBC,kCAAAA,mBAAmB,OAAO,MAAM,OAAO;CAE/D,gBAAyB,OACvB,gBACwC;EACxC,MAAM,EAAE,QAAQ,cAAc;EAE9B,MAAM,eAAe,MAAMC,4BAAAA,uBAAuB,QAAQ,UAAU,GAAG;EAEvE,OAAO;GACL,GAAG;GACH,mBAAmB;GACnB,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB;GACD"}
@@ -1,5 +1,10 @@
1
- import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk';
2
- import type { BitcoinStepExecutorContext } from '../../types.js';
3
- export declare class BitcoinSignAndExecuteTask extends BaseStepExecutionTask {
4
- run(context: BitcoinStepExecutorContext): Promise<TaskResult>;
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>;
5
7
  }
8
+ //#endregion
9
+ export { BitcoinSignAndExecuteTask };
10
+ //# sourceMappingURL=BitcoinSignAndExecuteTask.d.ts.map