@atomiqlabs/sdk 8.7.7 → 8.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/api/index.d.ts +1 -0
  2. package/api/index.js +3 -0
  3. package/dist/ApiList.d.ts +37 -0
  4. package/dist/ApiList.js +30 -0
  5. package/dist/api/ApiEndpoints.d.ts +393 -0
  6. package/dist/api/ApiEndpoints.js +2 -0
  7. package/dist/api/ApiParser.d.ts +10 -0
  8. package/dist/api/ApiParser.js +134 -0
  9. package/dist/api/ApiTypes.d.ts +157 -0
  10. package/dist/api/ApiTypes.js +75 -0
  11. package/dist/api/SerializedAction.d.ts +40 -0
  12. package/dist/api/SerializedAction.js +59 -0
  13. package/dist/api/SwapperApi.d.ts +50 -0
  14. package/dist/api/SwapperApi.js +431 -0
  15. package/dist/api/index.d.ts +5 -0
  16. package/dist/api/index.js +24 -0
  17. package/dist/bitcoin/coinselect2/accumulative.d.ts +1 -0
  18. package/dist/bitcoin/coinselect2/accumulative.js +1 -1
  19. package/dist/bitcoin/coinselect2/blackjack.d.ts +1 -0
  20. package/dist/bitcoin/coinselect2/blackjack.js +1 -1
  21. package/dist/bitcoin/coinselect2/index.d.ts +3 -2
  22. package/dist/bitcoin/coinselect2/index.js +2 -2
  23. package/dist/bitcoin/coinselect2/utils.d.ts +7 -2
  24. package/dist/bitcoin/coinselect2/utils.js +45 -10
  25. package/dist/bitcoin/wallet/BitcoinWallet.d.ts +8 -25
  26. package/dist/bitcoin/wallet/BitcoinWallet.js +31 -18
  27. package/dist/bitcoin/wallet/IBitcoinWallet.d.ts +40 -2
  28. package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.d.ts +7 -2
  29. package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.js +10 -4
  30. package/dist/events/UnifiedSwapEventListener.d.ts +4 -3
  31. package/dist/events/UnifiedSwapEventListener.js +8 -2
  32. package/dist/http/HttpUtils.d.ts +4 -2
  33. package/dist/http/HttpUtils.js +10 -4
  34. package/dist/http/paramcoders/client/StreamingFetchPromise.d.ts +2 -1
  35. package/dist/http/paramcoders/client/StreamingFetchPromise.js +3 -2
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +1 -0
  38. package/dist/intermediaries/IntermediaryDiscovery.d.ts +7 -2
  39. package/dist/intermediaries/IntermediaryDiscovery.js +4 -4
  40. package/dist/intermediaries/apis/IntermediaryAPI.d.ts +182 -15
  41. package/dist/intermediaries/apis/IntermediaryAPI.js +192 -31
  42. package/dist/intermediaries/auth/SignedKeyBasedAuth.d.ts +14 -0
  43. package/dist/intermediaries/auth/SignedKeyBasedAuth.js +68 -0
  44. package/dist/storage/IUnifiedStorage.d.ts +45 -3
  45. package/dist/storage/UnifiedSwapStorage.d.ts +8 -2
  46. package/dist/storage/UnifiedSwapStorage.js +46 -8
  47. package/dist/swapper/Swapper.d.ts +77 -4
  48. package/dist/swapper/Swapper.js +117 -25
  49. package/dist/swapper/SwapperUtils.d.ts +18 -2
  50. package/dist/swapper/SwapperUtils.js +39 -1
  51. package/dist/swaps/ISwap.d.ts +70 -9
  52. package/dist/swaps/ISwap.js +28 -6
  53. package/dist/swaps/ISwapWrapper.d.ts +11 -1
  54. package/dist/swaps/ISwapWrapper.js +23 -3
  55. package/dist/swaps/escrow_swaps/IEscrowSwap.d.ts +1 -1
  56. package/dist/swaps/escrow_swaps/IEscrowSwap.js +4 -2
  57. package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.d.ts +2 -1
  58. package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.js +2 -2
  59. package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.d.ts +3 -1
  60. package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.js +3 -2
  61. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +47 -31
  62. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +201 -67
  63. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +3 -1
  64. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +6 -6
  65. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +82 -15
  66. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +304 -98
  67. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.d.ts +3 -1
  68. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.js +6 -6
  69. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +75 -42
  70. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +424 -87
  71. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.d.ts +3 -1
  72. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +7 -7
  73. package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +54 -11
  74. package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +214 -41
  75. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.d.ts +2 -1
  76. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.js +7 -8
  77. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.d.ts +3 -1
  78. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.js +5 -5
  79. package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +85 -22
  80. package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +299 -56
  81. package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +41 -7
  82. package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +183 -58
  83. package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +53 -12
  84. package/dist/swaps/trusted/ln/LnForGasSwap.js +163 -49
  85. package/dist/swaps/trusted/ln/LnForGasWrapper.js +1 -2
  86. package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +14 -13
  87. package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +30 -47
  88. package/dist/swaps/trusted/onchain/OnchainForGasWrapper.d.ts +3 -1
  89. package/dist/swaps/trusted/onchain/OnchainForGasWrapper.js +4 -4
  90. package/dist/types/SwapExecutionAction.d.ts +141 -34
  91. package/dist/types/SwapExecutionAction.js +104 -0
  92. package/dist/types/SwapExecutionStep.d.ts +144 -0
  93. package/dist/types/SwapExecutionStep.js +87 -0
  94. package/dist/types/TokenAmount.d.ts +6 -0
  95. package/dist/types/TokenAmount.js +26 -1
  96. package/dist/utils/BitcoinUtils.d.ts +4 -0
  97. package/dist/utils/BitcoinUtils.js +73 -1
  98. package/dist/utils/BitcoinWalletUtils.d.ts +2 -2
  99. package/dist/utils/Utils.d.ts +3 -1
  100. package/dist/utils/Utils.js +7 -1
  101. package/package.json +7 -4
  102. package/src/api/ApiEndpoints.ts +427 -0
  103. package/src/api/ApiParser.ts +138 -0
  104. package/src/api/ApiTypes.ts +229 -0
  105. package/src/api/SerializedAction.ts +97 -0
  106. package/src/api/SwapperApi.ts +545 -0
  107. package/src/api/index.ts +5 -0
  108. package/src/bitcoin/coinselect2/accumulative.ts +2 -1
  109. package/src/bitcoin/coinselect2/blackjack.ts +2 -1
  110. package/src/bitcoin/coinselect2/index.ts +5 -4
  111. package/src/bitcoin/coinselect2/utils.ts +55 -14
  112. package/src/bitcoin/wallet/BitcoinWallet.ts +69 -57
  113. package/src/bitcoin/wallet/IBitcoinWallet.ts +44 -3
  114. package/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts +12 -4
  115. package/src/events/UnifiedSwapEventListener.ts +11 -3
  116. package/src/http/HttpUtils.ts +10 -4
  117. package/src/http/paramcoders/client/StreamingFetchPromise.ts +4 -2
  118. package/src/index.ts +1 -0
  119. package/src/intermediaries/IntermediaryDiscovery.ts +9 -2
  120. package/src/intermediaries/apis/IntermediaryAPI.ts +335 -35
  121. package/src/intermediaries/auth/SignedKeyBasedAuth.ts +69 -0
  122. package/src/storage/IUnifiedStorage.ts +45 -4
  123. package/src/storage/UnifiedSwapStorage.ts +42 -8
  124. package/src/swapper/Swapper.ts +165 -24
  125. package/src/swapper/SwapperUtils.ts +42 -2
  126. package/src/swaps/ISwap.ts +88 -16
  127. package/src/swaps/ISwapWrapper.ts +28 -3
  128. package/src/swaps/escrow_swaps/IEscrowSwap.ts +5 -3
  129. package/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts +3 -1
  130. package/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts +4 -1
  131. package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +264 -67
  132. package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +6 -4
  133. package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +390 -89
  134. package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts +6 -4
  135. package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +548 -94
  136. package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +7 -5
  137. package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +276 -45
  138. package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts +7 -6
  139. package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts +5 -3
  140. package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +413 -64
  141. package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +239 -61
  142. package/src/swaps/trusted/ln/LnForGasSwap.ts +211 -47
  143. package/src/swaps/trusted/ln/LnForGasWrapper.ts +1 -2
  144. package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +32 -51
  145. package/src/swaps/trusted/onchain/OnchainForGasWrapper.ts +5 -3
  146. package/src/types/SwapExecutionAction.ts +266 -43
  147. package/src/types/SwapExecutionStep.ts +224 -0
  148. package/src/types/TokenAmount.ts +36 -2
  149. package/src/utils/BitcoinUtils.ts +73 -0
  150. package/src/utils/BitcoinWalletUtils.ts +2 -2
  151. package/src/utils/Utils.ts +10 -1
  152. package/src/intermediaries/apis/TrustedIntermediaryAPI.ts +0 -258
@@ -13,6 +13,7 @@ import {SwapExecutionAction} from "../types/SwapExecutionAction";
13
13
  import {LoggerType} from "../utils/Logger";
14
14
  import {isPriceInfoType, PriceInfoType} from "../types/PriceInfoType";
15
15
  import {SwapStateInfo} from "../types/SwapStateInfo";
16
+ import {SwapExecutionStep} from "../types/SwapExecutionStep";
16
17
 
17
18
  /**
18
19
  * Initialization data for creating a swap
@@ -145,6 +146,12 @@ export abstract class ISwap<
145
146
  * @internal
146
147
  */
147
148
  _contractVersion?: string;
149
+ /**
150
+ * Storage specific metadata that can be used for e.g. optimistic concurrency
151
+ *
152
+ * @internal
153
+ */
154
+ _meta?: any;
148
155
 
149
156
 
150
157
  /**
@@ -218,6 +225,7 @@ export abstract class ISwap<
218
225
 
219
226
  this._randomNonce = swapInitOrObj.randomNonce;
220
227
  this._contractVersion = swapInitOrObj.contractVersion;
228
+ this._meta = swapInitOrObj._meta;
221
229
  }
222
230
  if(this.version!==this.currentVersion) {
223
231
  this.upgradeVersion();
@@ -259,13 +267,6 @@ export abstract class ISwap<
259
267
  });
260
268
  }
261
269
 
262
- /**
263
- * Returns a list of steps or transactions required to finish and settle the swap
264
- *
265
- * @param options Additional options for executing the swap
266
- */
267
- public abstract txsExecute(options?: any): Promise<SwapExecutionAction<T>[]>;
268
-
269
270
  /**
270
271
  * Executes the swap with the provided wallet, the exact arguments for this functions differ for various swap
271
272
  * types. Check the `execute()` function signature in the respective swap class to see the required arguments.
@@ -316,6 +317,19 @@ export abstract class ISwap<
316
317
  }
317
318
  }
318
319
 
320
+ /**
321
+ * Returns the specific state along with the human-readable description of that state
322
+ *
323
+ * @internal
324
+ */
325
+ protected _getStateInfo(state: S): SwapStateInfo<S> {
326
+ return {
327
+ state: state,
328
+ name: this.swapStateName(state),
329
+ description: this.swapStateDescription[state]
330
+ };
331
+ }
332
+
319
333
  /**
320
334
  * Re-fetches & revalidates the price data based on the current market prices
321
335
  */
@@ -410,6 +424,18 @@ export abstract class ISwap<
410
424
  if((typeof(signer)==="string" ? signer : signer.getAddress())!==this._getInitiator()) throw new Error("Invalid signer provided!");
411
425
  }
412
426
 
427
+ /**
428
+ * Await and prepares a list of passed transactions
429
+ *
430
+ * @param txsPromise
431
+ * @internal
432
+ */
433
+ protected async prepareTransactions(txsPromise: Promise<T["TX"][]>): Promise<T["TX"][]> {
434
+ const txs = await txsPromise;
435
+ if(this.wrapper._chain.prepareTxs==null) return txs;
436
+ return await this.wrapper._chain.prepareTxs(txs);
437
+ }
438
+
413
439
  /**
414
440
  * Returns an escrow hash of the swap
415
441
  *
@@ -546,18 +572,62 @@ export abstract class ISwap<
546
572
  * Returns the current state of the swap along with the human-readable description of the state
547
573
  */
548
574
  public getStateInfo(): SwapStateInfo<S> {
549
- return {
550
- state: this._state,
551
- name: this.swapStateName(this._state),
552
- description: this.swapStateDescription[this._state]
553
- }
575
+ return this._getStateInfo(this._state);
554
576
  }
555
577
 
556
578
  /**
557
- * Returns a state-dependent set of actions for the user to execute, or empty array if there is currently
558
- * no action required from the user to execute.
579
+ * Returns a current state-dependent action for the user to execute, or `undefined` if there is no more action
580
+ * required for this swap - this means that the swap is probably finished (either expired, failed or settled).
581
+ *
582
+ * @param options Optional options argument for the additional action context (i.e. passing bitcoin wallet info to
583
+ * get funded PSBTs or passing the externally-generated swap secret), see the actual type in the respective swap
584
+ * classes
585
+ */
586
+ public abstract getExecutionAction(options?: any): Promise<SwapExecutionAction | undefined>;
587
+
588
+ /**
589
+ * Returns a list of execution steps the user has to go through for a given swap, to see the possible execution
590
+ * steps check out {@link SwapExecutionStep}.
591
+ *
592
+ * @param options Optional options argument for the additional steps context (i.e. automatic settlement timeout),
593
+ * see the actual type in the respective swap classes
594
+ */
595
+ public abstract getExecutionSteps(options?: any): Promise<SwapExecutionStep[]>;
596
+
597
+ /**
598
+ * Returns the current action and the full execution steps for a given swap. Prefer this to calling
599
+ * {@link getExecutionSteps} and {@link getExecutionAction} separately - if called sequentially they might
600
+ * return the respective steps/actions in different states if you hit the state transition boundary.
601
+ *
602
+ * @param options Optional options argument for the additional execution status context, see the actual type in
603
+ * the respective swap classes
559
604
  */
560
- public abstract getCurrentActions(): Promise<SwapExecutionAction<T>[]>;
605
+ public abstract getExecutionStatus(options?: { skipBuildingAction?: boolean } & any): Promise<{
606
+ steps: SwapExecutionStep[],
607
+ currentAction: SwapExecutionAction | undefined,
608
+ stateInfo: SwapStateInfo<S>
609
+ }>;
610
+
611
+ /**
612
+ * Submits signed transactions obtained from the execution action back to the swap.
613
+ *
614
+ * @remarks This endpoint will also wait till the submitted transactions are confirmed (on a smart-chain side)
615
+ * and till the swap state change is observed from the authoritative chain/intermediary state.
616
+ *
617
+ * If invalid transactions are submitted, i.e. sending a simple noop or transfer transaction instead of the
618
+ * expected tx, this call may wait indefinitely unless aborted via the AbortSignal.
619
+ *
620
+ * @param txs Signed transactions
621
+ * @param abortSignal Abort signal
622
+ * @param requiredStates Optional list of states that the swap has to be in for the transactions to be
623
+ * submitted, else throws
624
+ * @param idempotent Whether the tx submission should be handled idempotently, meaning if any of the supplied
625
+ * transactions are already processed as e.g. init, claim, refund or execution transactions the function just
626
+ * returns these transaction IDs without actually submitting them
627
+ *
628
+ * @internal
629
+ */
630
+ abstract _submitExecutionTransactions(txs: (T["SignedTXType"] | string | any)[], abortSignal?: AbortSignal, requiredStates?: S[], idempotent?: boolean): Promise<string[]>;
561
631
 
562
632
  //////////////////////////////
563
633
  //// Amounts & fees
@@ -656,7 +726,9 @@ export abstract class ISwap<
656
726
  exactIn: this.exactIn,
657
727
  createdAt: this.createdAt,
658
728
  randomNonce: this._randomNonce,
659
- contractVersion: this._contractVersion
729
+ contractVersion: this._contractVersion,
730
+
731
+ _meta: this._meta
660
732
  }
661
733
  }
662
734
 
@@ -1,4 +1,4 @@
1
- import {ChainEvent, ChainType} from "@atomiqlabs/base";
1
+ import {ChainEvent, ChainType, isAbstractSigner} from "@atomiqlabs/base";
2
2
  import {EventEmitter} from "events";
3
3
  import {ISwap} from "./ISwap";
4
4
  import {ISwapPrice} from "../prices/abstract/ISwapPrice";
@@ -12,6 +12,7 @@ import {getLogger} from "../utils/Logger";
12
12
  import {PriceInfoType} from "../types/PriceInfoType";
13
13
  import {fromHumanReadableString} from "../utils/TokenUtils";
14
14
  import {UserError} from "../errors/UserError";
15
+ import {IntermediaryAPI} from "../intermediaries/apis/IntermediaryAPI";
15
16
 
16
17
  export const DEFAULT_MAX_PARALLEL_SWAP_TICKS = 50;
17
18
  export const DEFAULT_MAX_PARALLEL_SWAP_SYNCS = 50;
@@ -150,6 +151,11 @@ export abstract class ISwapWrapper<
150
151
  readonly _tokens: {
151
152
  [tokenAddress: string]: SCToken<T["ChainId"]>
152
153
  };
154
+ /**
155
+ * LP API Used to communicate with the LPs
156
+ * @internal
157
+ */
158
+ readonly _lpApi: IntermediaryAPI;
153
159
 
154
160
 
155
161
  /**
@@ -169,6 +175,7 @@ export abstract class ISwapWrapper<
169
175
  chain: T["ChainInterface"],
170
176
  prices: ISwapPrice,
171
177
  tokens: WrapperCtorTokens,
178
+ lpApi: IntermediaryAPI,
172
179
  options: O,
173
180
  events?: EventEmitter<{swapState: [ISwap]}>
174
181
  ) {
@@ -184,6 +191,7 @@ export abstract class ISwapWrapper<
184
191
  this._chain = chain;
185
192
  this._prices = prices;
186
193
  this.events = events || new EventEmitter();
194
+ this._lpApi = lpApi;
187
195
  this._options = options;
188
196
  this._tokens = tokens;
189
197
  }
@@ -426,8 +434,8 @@ export abstract class ISwapWrapper<
426
434
  for(let i=0; i<pastSwaps.length; i+=maxParallelSyncs) {
427
435
  const {removeSwaps, changedSwaps} = await this._checkPastSwaps(pastSwaps.slice(i, i+maxParallelSyncs));
428
436
  if (!noSave) {
429
- await this.unifiedStorage.removeAll(removeSwaps);
430
- await this.unifiedStorage.saveAll(changedSwaps);
437
+ await this.unifiedStorage.removeAll(removeSwaps, true);
438
+ await this.unifiedStorage.saveAll(changedSwaps, true);
431
439
  changedSwaps.forEach(swap => swap._emitEvent());
432
440
  removeSwaps.forEach(swap => swap._emitEvent());
433
441
  }
@@ -537,4 +545,21 @@ export abstract class ISwapWrapper<
537
545
  return this.pendingSwaps.get(id)?.deref() ?? null;
538
546
  }
539
547
 
548
+ /**
549
+ * @internal
550
+ */
551
+ async _getSignerAddress(signer?: string | T["Signer"] | T["NativeSigner"]): Promise<string | undefined> {
552
+ let address: string | undefined = undefined;
553
+ if(signer!=null) {
554
+ if (typeof (signer) === "string") {
555
+ address = signer;
556
+ } else if (isAbstractSigner(signer)) {
557
+ address = signer.getAddress();
558
+ } else {
559
+ address = (await this._chain.wrapSigner(signer)).getAddress();
560
+ }
561
+ }
562
+ return address;
563
+ }
564
+
540
565
  }
@@ -169,7 +169,7 @@ export abstract class IEscrowSwap<
169
169
  * @param abortSignal
170
170
  * @internal
171
171
  */
172
- protected async watchdogWaitTillCommited(intervalSeconds?: number, abortSignal?: AbortSignal): Promise<boolean> {
172
+ protected async watchdogWaitTillCommited(intervalSeconds?: number, abortSignal?: AbortSignal): Promise<SwapCommitState | null> {
173
173
  if(this._data==null) throw new Error("Tried to await commitment but data is null, invalid state?");
174
174
 
175
175
  intervalSeconds ??= 5;
@@ -181,13 +181,15 @@ export abstract class IEscrowSwap<
181
181
  if(
182
182
  status?.type===SwapCommitStateType.NOT_COMMITED &&
183
183
  await this._verifyQuoteDefinitelyExpired()
184
- ) return false;
184
+ ) return null;
185
185
  } catch (e) {
186
186
  this.logger.error("watchdogWaitTillCommited(): Error when fetching commit status or signature expiry: ", e);
187
187
  }
188
188
  }
189
189
  if(abortSignal!=null) abortSignal.throwIfAborted();
190
- return status?.type!==SwapCommitStateType.EXPIRED;
190
+ return status?.type===SwapCommitStateType.EXPIRED
191
+ ? null
192
+ : status;
191
193
  }
192
194
 
193
195
  /**
@@ -16,6 +16,7 @@ import {EventEmitter} from "events";
16
16
  import {SwapType} from "../../enums/SwapType";
17
17
  import {IEscrowSwap} from "./IEscrowSwap";
18
18
  import {Intermediary} from "../../intermediaries/Intermediary";
19
+ import {IntermediaryAPI} from "../../intermediaries/apis/IntermediaryAPI";
19
20
 
20
21
  export type IEscrowSwapDefinition<T extends ChainType, W extends IEscrowSwapWrapper<T, any>, S extends IEscrowSwap<T>> = SwapTypeDefinition<T, W, S>;
21
22
 
@@ -65,6 +66,7 @@ export abstract class IEscrowSwapWrapper<
65
66
  chain: T["ChainInterface"],
66
67
  prices: ISwapPrice,
67
68
  tokens: WrapperCtorTokens,
69
+ lpApi: IntermediaryAPI,
68
70
  options: O,
69
71
  versionedContracts: {
70
72
  [version: string]: {
@@ -74,7 +76,7 @@ export abstract class IEscrowSwapWrapper<
74
76
  },
75
77
  events?: EventEmitter<{swapState: [ISwap]}>
76
78
  ) {
77
- super(chainIdentifier, unifiedStorage, unifiedChainEvents, chain, prices, tokens, options, events);
79
+ super(chainIdentifier, unifiedStorage, unifiedChainEvents, chain, prices, tokens, lpApi, options, events);
78
80
  this._versionedContracts = versionedContracts;
79
81
  }
80
82
 
@@ -15,6 +15,7 @@ import {UserError} from "../../../errors/UserError";
15
15
  import { sha256 } from "@noble/hashes/sha256";
16
16
  import {IEscrowSwap} from "../IEscrowSwap";
17
17
  import {LNURLWithdrawParamsWithUrl} from "../../../types/lnurl/LNURLWithdraw";
18
+ import {IntermediaryAPI} from "../../../intermediaries/apis/IntermediaryAPI";
18
19
 
19
20
  export type IFromBTCLNDefinition<T extends ChainType, W extends IFromBTCLNWrapper<T, any>, S extends IEscrowSwap<T>> = IFromBTCDefinition<T, W, S>;
20
21
 
@@ -42,6 +43,7 @@ export abstract class IFromBTCLNWrapper<
42
43
  * @param tokens
43
44
  * @param versionedContracts
44
45
  * @param lnApi
46
+ * @param lpApi
45
47
  * @param options
46
48
  * @param events Instance to use for emitting events
47
49
  */
@@ -59,10 +61,11 @@ export abstract class IFromBTCLNWrapper<
59
61
  }
60
62
  },
61
63
  lnApi: LightningNetworkApi,
64
+ lpApi: IntermediaryAPI,
62
65
  options: O,
63
66
  events?: EventEmitter<{swapState: [IEscrowSwap]}>
64
67
  ) {
65
- super(chainIdentifier, unifiedStorage, unifiedChainEvents, chain, prices, tokens, options, versionedContracts, events);
68
+ super(chainIdentifier, unifiedStorage, unifiedChainEvents, chain, prices, tokens, lpApi, options, versionedContracts, events);
66
69
  this.lnApi = lnApi;
67
70
  }
68
71