@lifi/sdk-provider-bitcoin 4.0.0-beta.3 → 4.0.0-beta.4

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.
@@ -10,9 +10,9 @@ declare class BitcoinStepExecutor extends BaseStepExecutor {
10
10
  private client;
11
11
  constructor(options: BitcoinStepExecutorOptions);
12
12
  checkClient: (step: LiFiStepExtended) => void;
13
- createPipeline: (context: BitcoinStepExecutorContext) => TaskPipeline;
14
- parseErrors: (error: Error, step?: LiFiStepExtended, action?: ExecutionAction) => Promise<SDKError>;
15
- createContext: (baseContext: StepExecutorBaseContext) => Promise<BitcoinStepExecutorContext>;
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
16
  }
17
17
  //#endregion
18
18
  export { BitcoinStepExecutor };
@@ -4,44 +4,43 @@ const require_client_publicClient = require("../client/publicClient.js");
4
4
  const require_errors_parseBitcoinErrors = require("../errors/parseBitcoinErrors.js");
5
5
  const require_core_tasks_BitcoinSignAndExecuteTask = require("./tasks/BitcoinSignAndExecuteTask.js");
6
6
  const require_core_tasks_BitcoinWaitForTransactionTask = require("./tasks/BitcoinWaitForTransactionTask.js");
7
- const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js");
8
7
  let _lifi_sdk = require("@lifi/sdk");
9
8
  //#region src/core/BitcoinStepExecutor.ts
10
9
  var BitcoinStepExecutor = class extends _lifi_sdk.BaseStepExecutor {
10
+ client;
11
11
  constructor(options) {
12
12
  super(options);
13
- require_defineProperty._defineProperty(this, "client", void 0);
14
- require_defineProperty._defineProperty(this, "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
- require_defineProperty._defineProperty(this, "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
- require_defineProperty._defineProperty(this, "parseErrors", (error, step, action) => require_errors_parseBitcoinErrors.parseBitcoinErrors(error, step, action));
32
- require_defineProperty._defineProperty(this, "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
13
  this.client = options.client;
44
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
+ };
45
44
  };
46
45
  //#endregion
47
46
  exports.BitcoinStepExecutor = BitcoinStepExecutor;
@@ -1 +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;CAGxD,YAAY,SAAqC;AAC/C,QAAM,QAAQ;+CAHR,UAAA,KAAA,EAAc;+CAOtB,gBAAe,SAAiC;AAG9C,OAAI,KAAK,OAAO,SAAS,YAAY,KAAK,OAAO,YAC/C,OAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,8BACd,oHACD;IAEJ;+CAEQ,mBACP,YACiB;GACjB,MAAM,EAAE,MAAM,sBAAsB;GAEpC,MAAM,QAAQ;IACZ,IAAIC,UAAAA,kBAAkB;IACtB,IAAIC,UAAAA,wBAAwB;IAC5B,IAAIC,6CAAAA,2BAA2B;IAC/B,IAAIC,iDAAAA,+BAA+B;IACnC,IAAIC,UAAAA,6BACF,oBAAoB,oBAAoB,OACzC;IACF;GACD,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,OACrC;GAED,MAAM,WAAW,oBAAoB,SACjC,oBAAoB,WAAW,SAC7BA,UAAAA,6BAA6B,OAC7BD,iDAAAA,8BAA8B,OAChCH,UAAAA,iBAAiB;GAErB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,SACrC;AAID,UAAO,IAAIK,UAAAA,aAFQ,MAAM,MAAM,eAAe,CAEX;IACpC;+CAEQ,gBACP,OACA,MACA,WACsBC,kCAAAA,mBAAmB,OAAO,MAAM,OAAO,CAAA;+CAEtD,iBAAgB,OACvB,gBACwC;GACxC,MAAM,EAAE,QAAQ,cAAc;GAE9B,MAAM,eAAe,MAAMC,4BAAAA,uBAAuB,QAAQ,UAAU,GAAG;AAEvE,UAAO;IACL,GAAG;IACH,mBAAmB;IACnB,aAAa,KAAK;IAClB,cAAc,KAAK;IACnB;IACD;IACF;AApEC,OAAK,SAAS,QAAQ"}
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;AAC/C,QAAM,QAAQ;AACd,OAAK,SAAS,QAAQ;;CAGxB,eAAe,SAAiC;AAG9C,MAAI,KAAK,OAAO,SAAS,YAAY,KAAK,OAAO,YAC/C,OAAM,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;AAID,SAAO,IAAIK,UAAAA,aAFQ,MAAM,MAAM,eAAe,CAEX;;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;AAEvE,SAAO;GACL,GAAG;GACH,mBAAmB;GACnB,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB;GACD"}
@@ -1,6 +1,6 @@
1
1
  //#region src/version.d.ts
2
2
  declare const name = "@lifi/sdk-provider-bitcoin";
3
- declare const version = "4.0.0-beta.3";
3
+ declare const version = "4.0.0-beta.4";
4
4
  //#endregion
5
5
  export { name, version };
6
6
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/version.ts
3
3
  const name = "@lifi/sdk-provider-bitcoin";
4
- const version = "4.0.0-beta.3";
4
+ const version = "4.0.0-beta.4";
5
5
  //#endregion
6
6
  exports.name = name;
7
7
  exports.version = version;
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-bitcoin'\nexport const version = '4.0.0-beta.3'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-bitcoin'\nexport const version = '4.0.0-beta.4'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
@@ -10,9 +10,9 @@ declare class BitcoinStepExecutor extends BaseStepExecutor {
10
10
  private client;
11
11
  constructor(options: BitcoinStepExecutorOptions);
12
12
  checkClient: (step: LiFiStepExtended) => void;
13
- createPipeline: (context: BitcoinStepExecutorContext) => TaskPipeline;
14
- parseErrors: (error: Error, step?: LiFiStepExtended, action?: ExecutionAction) => Promise<SDKError>;
15
- createContext: (baseContext: StepExecutorBaseContext) => Promise<BitcoinStepExecutorContext>;
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
16
  }
17
17
  //#endregion
18
18
  export { BitcoinStepExecutor };
@@ -1 +1 @@
1
- {"version":3,"file":"BitcoinStepExecutor.d.ts","names":[],"sources":["../../../src/core/BitcoinStepExecutor.ts"],"mappings":";;;;;UAqBU,0BAAA,SAAmC,mBAAA;EAC3C,MAAA,EAAQ,MAAA;AAAA;AAAA,cAGG,mBAAA,SAA4B,gBAAA;EAAA,QAC/B,MAAA;EAER,WAAA,CAAY,OAAA,EAAS,0BAAA;EAKrB,WAAA,GAAe,IAAA,EAAM,gBAAA;EAWrB,cAAA,GACE,OAAA,EAAS,0BAAA,KACR,YAAA;EAgCH,WAAA,GACE,KAAA,EAAO,KAAA,EACP,IAAA,GAAO,gBAAA,EACP,MAAA,GAAS,eAAA,KACR,OAAA,CAAQ,QAAA;EAEX,aAAA,GACE,WAAA,EAAa,uBAAA,KACZ,OAAA,CAAQ,0BAAA;AAAA"}
1
+ {"version":3,"file":"BitcoinStepExecutor.d.ts","names":[],"sources":["../../../src/core/BitcoinStepExecutor.ts"],"mappings":";;;;;UAqBU,0BAAA,SAAmC,mBAAA;EAC3C,MAAA,EAAQ,MAAA;AAAA;AAAA,cAGG,mBAAA,SAA4B,gBAAA;EAAA,QAC/B,MAAA;EAER,WAAA,CAAY,OAAA,EAAS,0BAAA;EAKrB,WAAA,GAAe,IAAA,EAAM,gBAAA;EAAA,SAWZ,cAAA,GACP,OAAA,EAAS,0BAAA,KACR,YAAA;EAAA,SAgCM,WAAA,GACP,KAAA,EAAO,KAAA,EACP,IAAA,GAAO,gBAAA,EACP,MAAA,GAAS,eAAA,KACR,OAAA,CAAQ,QAAA;EAAA,SAEF,aAAA,GACP,WAAA,EAAa,uBAAA,KACZ,OAAA,CAAQ,0BAAA;AAAA"}
@@ -2,44 +2,43 @@ import { getBitcoinPublicClient } from "../client/publicClient.js";
2
2
  import { parseBitcoinErrors } from "../errors/parseBitcoinErrors.js";
3
3
  import { BitcoinSignAndExecuteTask } from "./tasks/BitcoinSignAndExecuteTask.js";
4
4
  import { BitcoinWaitForTransactionTask } from "./tasks/BitcoinWaitForTransactionTask.js";
5
- import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js";
6
5
  import { BaseStepExecutor, CheckBalanceTask, LiFiErrorCode, PrepareTransactionTask, TaskPipeline, TransactionError, WaitForTransactionStatusTask } from "@lifi/sdk";
7
6
  //#region src/core/BitcoinStepExecutor.ts
8
7
  var BitcoinStepExecutor = class extends BaseStepExecutor {
8
+ client;
9
9
  constructor(options) {
10
10
  super(options);
11
- _defineProperty(this, "client", void 0);
12
- _defineProperty(this, "checkClient", (step) => {
13
- if (this.client.account?.address !== step.action.fromAddress) throw new TransactionError(LiFiErrorCode.WalletChangedDuringExecution, "The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.");
14
- });
15
- _defineProperty(this, "createPipeline", (context) => {
16
- const { step, isBridgeExecution } = context;
17
- const tasks = [
18
- new CheckBalanceTask(),
19
- new PrepareTransactionTask(),
20
- new BitcoinSignAndExecuteTask(),
21
- new BitcoinWaitForTransactionTask(),
22
- new WaitForTransactionStatusTask(isBridgeExecution ? "RECEIVING_CHAIN" : "SWAP")
23
- ];
24
- const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
25
- const taskName = swapOrBridgeAction?.txHash ? swapOrBridgeAction?.status === "DONE" ? WaitForTransactionStatusTask.name : BitcoinWaitForTransactionTask.name : CheckBalanceTask.name;
26
- const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
27
- return new TaskPipeline(tasks.slice(firstTaskIndex));
28
- });
29
- _defineProperty(this, "parseErrors", (error, step, action) => parseBitcoinErrors(error, step, action));
30
- _defineProperty(this, "createContext", async (baseContext) => {
31
- const { client, fromChain } = baseContext;
32
- const publicClient = await getBitcoinPublicClient(client, fromChain.id);
33
- return {
34
- ...baseContext,
35
- pollingIntervalMs: 1e4,
36
- checkClient: this.checkClient,
37
- walletClient: this.client,
38
- publicClient
39
- };
40
- });
41
11
  this.client = options.client;
42
12
  }
13
+ checkClient = (step) => {
14
+ if (this.client.account?.address !== step.action.fromAddress) throw new TransactionError(LiFiErrorCode.WalletChangedDuringExecution, "The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.");
15
+ };
16
+ createPipeline = (context) => {
17
+ const { step, isBridgeExecution } = context;
18
+ const tasks = [
19
+ new CheckBalanceTask(),
20
+ new PrepareTransactionTask(),
21
+ new BitcoinSignAndExecuteTask(),
22
+ new BitcoinWaitForTransactionTask(),
23
+ new WaitForTransactionStatusTask(isBridgeExecution ? "RECEIVING_CHAIN" : "SWAP")
24
+ ];
25
+ const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
26
+ const taskName = swapOrBridgeAction?.txHash ? swapOrBridgeAction?.status === "DONE" ? WaitForTransactionStatusTask.name : BitcoinWaitForTransactionTask.name : CheckBalanceTask.name;
27
+ const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
28
+ return new TaskPipeline(tasks.slice(firstTaskIndex));
29
+ };
30
+ parseErrors = (error, step, action) => parseBitcoinErrors(error, step, action);
31
+ createContext = async (baseContext) => {
32
+ const { client, fromChain } = baseContext;
33
+ const publicClient = await getBitcoinPublicClient(client, fromChain.id);
34
+ return {
35
+ ...baseContext,
36
+ pollingIntervalMs: 1e4,
37
+ checkClient: this.checkClient,
38
+ walletClient: this.client,
39
+ publicClient
40
+ };
41
+ };
43
42
  };
44
43
  //#endregion
45
44
  export { BitcoinStepExecutor };
@@ -1 +1 @@
1
- {"version":3,"file":"BitcoinStepExecutor.js","names":[],"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,cAAyC,iBAAiB;CAGxD,YAAY,SAAqC;AAC/C,QAAM,QAAQ;wBAHR,UAAA,KAAA,EAAc;wBAOtB,gBAAe,SAAiC;AAG9C,OAAI,KAAK,OAAO,SAAS,YAAY,KAAK,OAAO,YAC/C,OAAM,IAAI,iBACR,cAAc,8BACd,oHACD;IAEJ;wBAEQ,mBACP,YACiB;GACjB,MAAM,EAAE,MAAM,sBAAsB;GAEpC,MAAM,QAAQ;IACZ,IAAI,kBAAkB;IACtB,IAAI,wBAAwB;IAC5B,IAAI,2BAA2B;IAC/B,IAAI,+BAA+B;IACnC,IAAI,6BACF,oBAAoB,oBAAoB,OACzC;IACF;GACD,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,OACrC;GAED,MAAM,WAAW,oBAAoB,SACjC,oBAAoB,WAAW,SAC7B,6BAA6B,OAC7B,8BAA8B,OAChC,iBAAiB;GAErB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,SACrC;AAID,UAAO,IAAI,aAFQ,MAAM,MAAM,eAAe,CAEX;IACpC;wBAEQ,gBACP,OACA,MACA,WACsB,mBAAmB,OAAO,MAAM,OAAO,CAAA;wBAEtD,iBAAgB,OACvB,gBACwC;GACxC,MAAM,EAAE,QAAQ,cAAc;GAE9B,MAAM,eAAe,MAAM,uBAAuB,QAAQ,UAAU,GAAG;AAEvE,UAAO;IACL,GAAG;IACH,mBAAmB;IACnB,aAAa,KAAK;IAClB,cAAc,KAAK;IACnB;IACD;IACF;AApEC,OAAK,SAAS,QAAQ"}
1
+ {"version":3,"file":"BitcoinStepExecutor.js","names":[],"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,cAAyC,iBAAiB;CACxD;CAEA,YAAY,SAAqC;AAC/C,QAAM,QAAQ;AACd,OAAK,SAAS,QAAQ;;CAGxB,eAAe,SAAiC;AAG9C,MAAI,KAAK,OAAO,SAAS,YAAY,KAAK,OAAO,YAC/C,OAAM,IAAI,iBACR,cAAc,8BACd,oHACD;;CAIL,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,sBAAsB;EAEpC,MAAM,QAAQ;GACZ,IAAI,kBAAkB;GACtB,IAAI,wBAAwB;GAC5B,IAAI,2BAA2B;GAC/B,IAAI,+BAA+B;GACnC,IAAI,6BACF,oBAAoB,oBAAoB,OACzC;GACF;EACD,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,OACrC;EAED,MAAM,WAAW,oBAAoB,SACjC,oBAAoB,WAAW,SAC7B,6BAA6B,OAC7B,8BAA8B,OAChC,iBAAiB;EAErB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,SACrC;AAID,SAAO,IAAI,aAFQ,MAAM,MAAM,eAAe,CAEX;;CAGrC,eACE,OACA,MACA,WACsB,mBAAmB,OAAO,MAAM,OAAO;CAE/D,gBAAyB,OACvB,gBACwC;EACxC,MAAM,EAAE,QAAQ,cAAc;EAE9B,MAAM,eAAe,MAAM,uBAAuB,QAAQ,UAAU,GAAG;AAEvE,SAAO;GACL,GAAG;GACH,mBAAmB;GACnB,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB;GACD"}
@@ -1,6 +1,6 @@
1
1
  //#region src/version.d.ts
2
2
  declare const name = "@lifi/sdk-provider-bitcoin";
3
- declare const version = "4.0.0-beta.3";
3
+ declare const version = "4.0.0-beta.4";
4
4
  //#endregion
5
5
  export { name, version };
6
6
  //# sourceMappingURL=version.d.ts.map
@@ -1,6 +1,6 @@
1
1
  //#region src/version.ts
2
2
  const name = "@lifi/sdk-provider-bitcoin";
3
- const version = "4.0.0-beta.3";
3
+ const version = "4.0.0-beta.4";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-bitcoin'\nexport const version = '4.0.0-beta.3'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-bitcoin'\nexport const version = '4.0.0-beta.4'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk-provider-bitcoin",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.4",
4
4
  "description": "LI.FI Bitcoin SDK Provider for Any-to-Any Cross-Chain-Swap",
5
5
  "homepage": "https://github.com/lifinance/sdk",
6
6
  "bugs": {
@@ -28,11 +28,11 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "dependencies": {
31
- "@bigmi/core": "^0.7.1",
31
+ "@bigmi/core": "^0.8.0",
32
32
  "@bitcoinerlab/secp256k1": "^1.2.0",
33
33
  "bech32": "^2.0.0",
34
34
  "bitcoinjs-lib": "^7.0.1",
35
- "@lifi/sdk": "4.0.0-beta.3"
35
+ "@lifi/sdk": "4.0.0-beta.4"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk-provider-bitcoin'
2
- export const version = '4.0.0-beta.3'
2
+ export const version = '4.0.0-beta.4'
@@ -1,12 +0,0 @@
1
- const require_toPropertyKey = require("./toPropertyKey.js");
2
- //#region \0@oxc-project+runtime@0.115.0/helpers/defineProperty.js
3
- function _defineProperty(e, r, t) {
4
- return (r = require_toPropertyKey.toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5
- value: t,
6
- enumerable: !0,
7
- configurable: !0,
8
- writable: !0
9
- }) : e[r] = t, e;
10
- }
11
- //#endregion
12
- exports._defineProperty = _defineProperty;
@@ -1,14 +0,0 @@
1
- const require_typeof = require("./typeof.js");
2
- //#region \0@oxc-project+runtime@0.115.0/helpers/toPrimitive.js
3
- function toPrimitive(t, r) {
4
- if ("object" != require_typeof._typeof(t) || !t) return t;
5
- var e = t[Symbol.toPrimitive];
6
- if (void 0 !== e) {
7
- var i = e.call(t, r || "default");
8
- if ("object" != require_typeof._typeof(i)) return i;
9
- throw new TypeError("@@toPrimitive must return a primitive value.");
10
- }
11
- return ("string" === r ? String : Number)(t);
12
- }
13
- //#endregion
14
- exports.toPrimitive = toPrimitive;
@@ -1,9 +0,0 @@
1
- const require_typeof = require("./typeof.js");
2
- const require_toPrimitive = require("./toPrimitive.js");
3
- //#region \0@oxc-project+runtime@0.115.0/helpers/toPropertyKey.js
4
- function toPropertyKey(t) {
5
- var i = require_toPrimitive.toPrimitive(t, "string");
6
- return "symbol" == require_typeof._typeof(i) ? i : i + "";
7
- }
8
- //#endregion
9
- exports.toPropertyKey = toPropertyKey;
@@ -1,16 +0,0 @@
1
- //#region \0@oxc-project+runtime@0.115.0/helpers/typeof.js
2
- function _typeof(o) {
3
- "@babel/helpers - typeof";
4
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
5
- return typeof o;
6
- } : function(o) {
7
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
8
- }, _typeof(o);
9
- }
10
- //#endregion
11
- Object.defineProperty(exports, "_typeof", {
12
- enumerable: true,
13
- get: function() {
14
- return _typeof;
15
- }
16
- });
@@ -1,12 +0,0 @@
1
- import { toPropertyKey } from "./toPropertyKey.js";
2
- //#region \0@oxc-project+runtime@0.115.0/helpers/defineProperty.js
3
- function _defineProperty(e, r, t) {
4
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5
- value: t,
6
- enumerable: !0,
7
- configurable: !0,
8
- writable: !0
9
- }) : e[r] = t, e;
10
- }
11
- //#endregion
12
- export { _defineProperty };
@@ -1,14 +0,0 @@
1
- import { _typeof } from "./typeof.js";
2
- //#region \0@oxc-project+runtime@0.115.0/helpers/toPrimitive.js
3
- function toPrimitive(t, r) {
4
- if ("object" != _typeof(t) || !t) return t;
5
- var e = t[Symbol.toPrimitive];
6
- if (void 0 !== e) {
7
- var i = e.call(t, r || "default");
8
- if ("object" != _typeof(i)) return i;
9
- throw new TypeError("@@toPrimitive must return a primitive value.");
10
- }
11
- return ("string" === r ? String : Number)(t);
12
- }
13
- //#endregion
14
- export { toPrimitive };
@@ -1,9 +0,0 @@
1
- import { _typeof } from "./typeof.js";
2
- import { toPrimitive } from "./toPrimitive.js";
3
- //#region \0@oxc-project+runtime@0.115.0/helpers/toPropertyKey.js
4
- function toPropertyKey(t) {
5
- var i = toPrimitive(t, "string");
6
- return "symbol" == _typeof(i) ? i : i + "";
7
- }
8
- //#endregion
9
- export { toPropertyKey };
@@ -1,11 +0,0 @@
1
- //#region \0@oxc-project+runtime@0.115.0/helpers/typeof.js
2
- function _typeof(o) {
3
- "@babel/helpers - typeof";
4
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
5
- return typeof o;
6
- } : function(o) {
7
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
8
- }, _typeof(o);
9
- }
10
- //#endregion
11
- export { _typeof };