@atomiqlabs/sdk 8.8.3 → 8.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.d.ts +1 -0
- package/api/index.js +3 -0
- package/dist/ApiList.d.ts +37 -0
- package/dist/ApiList.js +30 -0
- package/dist/api/ApiEndpoints.d.ts +393 -0
- package/dist/api/ApiEndpoints.js +2 -0
- package/dist/api/ApiParser.d.ts +10 -0
- package/dist/api/ApiParser.js +134 -0
- package/dist/api/ApiTypes.d.ts +157 -0
- package/dist/api/ApiTypes.js +75 -0
- package/dist/api/SerializedAction.d.ts +40 -0
- package/dist/api/SerializedAction.js +59 -0
- package/dist/api/SwapperApi.d.ts +50 -0
- package/dist/api/SwapperApi.js +431 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.js +24 -0
- package/dist/events/UnifiedSwapEventListener.d.ts +4 -3
- package/dist/events/UnifiedSwapEventListener.js +8 -2
- package/dist/http/HttpUtils.d.ts +4 -2
- package/dist/http/HttpUtils.js +10 -4
- package/dist/http/paramcoders/client/StreamingFetchPromise.d.ts +2 -1
- package/dist/http/paramcoders/client/StreamingFetchPromise.js +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/intermediaries/IntermediaryDiscovery.d.ts +7 -2
- package/dist/intermediaries/IntermediaryDiscovery.js +4 -4
- package/dist/intermediaries/apis/IntermediaryAPI.d.ts +171 -14
- package/dist/intermediaries/apis/IntermediaryAPI.js +174 -28
- package/dist/intermediaries/auth/SignedKeyBasedAuth.d.ts +14 -0
- package/dist/intermediaries/auth/SignedKeyBasedAuth.js +68 -0
- package/dist/storage/IUnifiedStorage.d.ts +45 -3
- package/dist/storage/UnifiedSwapStorage.d.ts +8 -2
- package/dist/storage/UnifiedSwapStorage.js +46 -8
- package/dist/swapper/Swapper.d.ts +41 -3
- package/dist/swapper/Swapper.js +93 -48
- package/dist/swapper/SwapperUtils.d.ts +18 -2
- package/dist/swapper/SwapperUtils.js +39 -1
- package/dist/swaps/ISwap.d.ts +70 -9
- package/dist/swaps/ISwap.js +28 -6
- package/dist/swaps/ISwapWrapper.d.ts +11 -1
- package/dist/swaps/ISwapWrapper.js +23 -3
- package/dist/swaps/escrow_swaps/IEscrowSwap.d.ts +1 -1
- package/dist/swaps/escrow_swaps/IEscrowSwap.js +4 -2
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.d.ts +2 -1
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.js +2 -2
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.d.ts +3 -1
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.js +3 -2
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +47 -31
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +201 -67
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +3 -1
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +6 -6
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +82 -15
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +304 -98
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.d.ts +3 -1
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.js +6 -6
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +75 -42
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +424 -87
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.d.ts +3 -1
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +7 -7
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +54 -11
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +214 -41
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.d.ts +2 -1
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.js +7 -8
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.d.ts +3 -1
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.js +5 -5
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +76 -19
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +290 -51
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +3 -1
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +5 -5
- package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +53 -12
- package/dist/swaps/trusted/ln/LnForGasSwap.js +163 -49
- package/dist/swaps/trusted/ln/LnForGasWrapper.js +1 -2
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +14 -13
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +30 -47
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.d.ts +3 -1
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.js +4 -4
- package/dist/types/SwapExecutionAction.d.ts +141 -34
- package/dist/types/SwapExecutionAction.js +104 -0
- package/dist/types/SwapExecutionStep.d.ts +144 -0
- package/dist/types/SwapExecutionStep.js +87 -0
- package/dist/types/TokenAmount.d.ts +6 -0
- package/dist/types/TokenAmount.js +26 -1
- package/dist/utils/BitcoinUtils.d.ts +2 -0
- package/dist/utils/BitcoinUtils.js +34 -1
- package/dist/utils/Utils.d.ts +3 -1
- package/dist/utils/Utils.js +7 -1
- package/package.json +7 -4
- package/src/api/ApiEndpoints.ts +427 -0
- package/src/api/ApiParser.ts +138 -0
- package/src/api/ApiTypes.ts +229 -0
- package/src/api/SerializedAction.ts +97 -0
- package/src/api/SwapperApi.ts +545 -0
- package/src/api/index.ts +5 -0
- package/src/events/UnifiedSwapEventListener.ts +11 -3
- package/src/http/HttpUtils.ts +10 -4
- package/src/http/paramcoders/client/StreamingFetchPromise.ts +4 -2
- package/src/index.ts +1 -0
- package/src/intermediaries/IntermediaryDiscovery.ts +9 -2
- package/src/intermediaries/apis/IntermediaryAPI.ts +314 -30
- package/src/intermediaries/auth/SignedKeyBasedAuth.ts +69 -0
- package/src/storage/IUnifiedStorage.ts +45 -4
- package/src/storage/UnifiedSwapStorage.ts +42 -8
- package/src/swapper/Swapper.ts +134 -52
- package/src/swapper/SwapperUtils.ts +42 -2
- package/src/swaps/ISwap.ts +88 -16
- package/src/swaps/ISwapWrapper.ts +28 -3
- package/src/swaps/escrow_swaps/IEscrowSwap.ts +5 -3
- package/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts +3 -1
- package/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts +4 -1
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +264 -67
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +6 -4
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +390 -89
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts +6 -4
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +548 -94
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +7 -5
- package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +276 -45
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts +7 -6
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts +5 -3
- package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +393 -57
- package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +5 -3
- package/src/swaps/trusted/ln/LnForGasSwap.ts +211 -47
- package/src/swaps/trusted/ln/LnForGasWrapper.ts +1 -2
- package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +32 -51
- package/src/swaps/trusted/onchain/OnchainForGasWrapper.ts +5 -3
- package/src/types/SwapExecutionAction.ts +266 -43
- package/src/types/SwapExecutionStep.ts +224 -0
- package/src/types/TokenAmount.ts +36 -2
- package/src/utils/BitcoinUtils.ts +32 -0
- package/src/utils/Utils.ts +10 -1
- package/src/intermediaries/apis/TrustedIntermediaryAPI.ts +0 -258
|
@@ -12,7 +12,9 @@ import { IAddressSwap } from "../../../IAddressSwap";
|
|
|
12
12
|
import { TokenAmount } from "../../../../types/TokenAmount";
|
|
13
13
|
import { BtcToken, SCToken } from "../../../../types/Token";
|
|
14
14
|
import { LoggerType } from "../../../../utils/Logger";
|
|
15
|
-
import {
|
|
15
|
+
import { SwapExecutionActionSendToAddress, SwapExecutionActionSignPSBT, SwapExecutionActionSignSmartChainTx, SwapExecutionActionWait } from "../../../../types/SwapExecutionAction";
|
|
16
|
+
import { SwapExecutionStepPayment, SwapExecutionStepSettlement, SwapExecutionStepSetup } from "../../../../types/SwapExecutionStep";
|
|
17
|
+
import { SwapStateInfo } from "../../../../types/SwapStateInfo";
|
|
16
18
|
/**
|
|
17
19
|
* State enum for legacy escrow based Bitcoin -> Smart chain swaps.
|
|
18
20
|
*
|
|
@@ -150,6 +152,7 @@ export declare class FromBTCSwap<T extends ChainType = ChainType> extends IFromB
|
|
|
150
152
|
* @inheritDoc
|
|
151
153
|
*/
|
|
152
154
|
getInputTxId(): string | null;
|
|
155
|
+
private _setSubmittedBitcoinTx;
|
|
153
156
|
/**
|
|
154
157
|
* Returns timeout time (in UNIX milliseconds) when the on-chain address will expire and no funds should be sent
|
|
155
158
|
* to that address anymore
|
|
@@ -270,6 +273,7 @@ export declare class FromBTCSwap<T extends ChainType = ChainType> extends IFromB
|
|
|
270
273
|
psbtHex: string;
|
|
271
274
|
psbtBase64: string;
|
|
272
275
|
signInputs: number[];
|
|
276
|
+
feeRate: number;
|
|
273
277
|
}>;
|
|
274
278
|
/**
|
|
275
279
|
* @inheritDoc
|
|
@@ -313,47 +317,47 @@ export declare class FromBTCSwap<T extends ChainType = ChainType> extends IFromB
|
|
|
313
317
|
btcTxCheckIntervalSeconds?: number;
|
|
314
318
|
maxWaitTillAutomaticSettlementSeconds?: number;
|
|
315
319
|
}): Promise<boolean>;
|
|
320
|
+
/**
|
|
321
|
+
* @internal
|
|
322
|
+
*/
|
|
323
|
+
protected _getExecutionStatus(options?: {
|
|
324
|
+
maxWaitTillAutomaticSettlementSeconds?: number;
|
|
325
|
+
}): Promise<{
|
|
326
|
+
steps: [SwapExecutionStepSetup<T["ChainId"]>, SwapExecutionStepPayment<"BITCOIN">, SwapExecutionStepSettlement<T["ChainId"], "awaiting_automatic" | "awaiting_manual">];
|
|
327
|
+
buildCurrentAction: (actionOptions?: {
|
|
328
|
+
bitcoinFeeRate?: number;
|
|
329
|
+
bitcoinWallet?: MinimalBitcoinWalletInterface;
|
|
330
|
+
skipChecks?: boolean;
|
|
331
|
+
manualSettlementSmartChainSigner?: string | T["Signer"] | T["NativeSigner"];
|
|
332
|
+
}) => Promise<SwapExecutionActionSendToAddress<false> | SwapExecutionActionSignPSBT<"FUNDED_PSBT"> | SwapExecutionActionWait<"BITCOIN_CONFS" | "SETTLEMENT"> | SwapExecutionActionSignSmartChainTx<T> | undefined>;
|
|
333
|
+
state: FromBTCSwapState;
|
|
334
|
+
}>;
|
|
316
335
|
/**
|
|
317
336
|
* @inheritDoc
|
|
318
|
-
*
|
|
319
|
-
* @param options.bitcoinFeeRate Optional fee rate to use for the created Bitcoin transaction
|
|
320
|
-
* @param options.bitcoinWallet Bitcoin wallet to use, when provided the function returns a funded
|
|
321
|
-
* psbt (`"FUNDED_PSBT"`), if not passed just a bitcoin receive address is returned (`"ADDRESS"`)
|
|
322
|
-
* @param options.skipChecks Skip checks like making sure init signature is still valid and swap
|
|
323
|
-
* wasn't commited yet (this is handled on swap creation, if you commit right after quoting, you
|
|
324
|
-
* can use `skipChecks=true`)
|
|
325
|
-
*
|
|
326
|
-
* @throws {Error} if the swap or quote is expired, or if triggered in invalid state
|
|
337
|
+
* @internal
|
|
327
338
|
*/
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
psbtBase64: string;
|
|
351
|
-
signInputs: number[];
|
|
352
|
-
address?: undefined;
|
|
353
|
-
amount?: undefined;
|
|
354
|
-
hyperlink?: undefined;
|
|
355
|
-
})[];
|
|
356
|
-
})[]>;
|
|
339
|
+
_submitExecutionTransactions(txs: (T["SignedTXType"] | Transaction | string)[], abortSignal?: AbortSignal, requiredStates?: FromBTCSwapState[], idempotent?: boolean): Promise<string[]>;
|
|
340
|
+
/**
|
|
341
|
+
* @internal
|
|
342
|
+
*/
|
|
343
|
+
private _buildSendToAddressOrSignPsbtAction;
|
|
344
|
+
/**
|
|
345
|
+
* @internal
|
|
346
|
+
*/
|
|
347
|
+
private _buildWaitBitcoinConfirmationsAction;
|
|
348
|
+
/**
|
|
349
|
+
* @internal
|
|
350
|
+
*/
|
|
351
|
+
private _buildWaitSettlementAction;
|
|
352
|
+
/**
|
|
353
|
+
* @internal
|
|
354
|
+
*/
|
|
355
|
+
private _buildInitSmartChainTxAction;
|
|
356
|
+
/**
|
|
357
|
+
* @inheritDoc
|
|
358
|
+
* @internal
|
|
359
|
+
*/
|
|
360
|
+
private _buildClaimSmartChainTxAction;
|
|
357
361
|
/**
|
|
358
362
|
* @inheritDoc
|
|
359
363
|
*
|
|
@@ -367,13 +371,42 @@ export declare class FromBTCSwap<T extends ChainType = ChainType> extends IFromB
|
|
|
367
371
|
* @param options.maxWaitTillAutomaticSettlementSeconds Maximum time to wait for an automatic settlement after
|
|
368
372
|
* the bitcoin transaction is confirmed (defaults to 60 seconds)
|
|
369
373
|
*/
|
|
370
|
-
|
|
374
|
+
getExecutionAction(options?: {
|
|
371
375
|
bitcoinFeeRate?: number;
|
|
372
376
|
bitcoinWallet?: MinimalBitcoinWalletInterface;
|
|
373
377
|
skipChecks?: boolean;
|
|
374
378
|
manualSettlementSmartChainSigner?: string | T["Signer"] | T["NativeSigner"];
|
|
375
379
|
maxWaitTillAutomaticSettlementSeconds?: number;
|
|
376
|
-
}): Promise<
|
|
380
|
+
}): Promise<SwapExecutionActionSendToAddress<false> | SwapExecutionActionSignPSBT<"FUNDED_PSBT"> | SwapExecutionActionWait<"BITCOIN_CONFS" | "SETTLEMENT"> | SwapExecutionActionSignSmartChainTx<T> | undefined>;
|
|
381
|
+
/**
|
|
382
|
+
* @inheritDoc
|
|
383
|
+
*/
|
|
384
|
+
getExecutionStatus(options?: {
|
|
385
|
+
skipBuildingAction?: boolean;
|
|
386
|
+
bitcoinFeeRate?: number;
|
|
387
|
+
bitcoinWallet?: MinimalBitcoinWalletInterface;
|
|
388
|
+
skipChecks?: boolean;
|
|
389
|
+
manualSettlementSmartChainSigner?: string | T["Signer"] | T["NativeSigner"];
|
|
390
|
+
maxWaitTillAutomaticSettlementSeconds?: number;
|
|
391
|
+
}): Promise<{
|
|
392
|
+
steps: [
|
|
393
|
+
SwapExecutionStepSetup<T["ChainId"]>,
|
|
394
|
+
SwapExecutionStepPayment<"BITCOIN">,
|
|
395
|
+
SwapExecutionStepSettlement<T["ChainId"], "awaiting_automatic" | "awaiting_manual">
|
|
396
|
+
];
|
|
397
|
+
currentAction: SwapExecutionActionSendToAddress<false> | SwapExecutionActionSignPSBT<"FUNDED_PSBT"> | SwapExecutionActionWait<"BITCOIN_CONFS" | "SETTLEMENT"> | SwapExecutionActionSignSmartChainTx<T> | undefined;
|
|
398
|
+
stateInfo: SwapStateInfo<FromBTCSwapState>;
|
|
399
|
+
}>;
|
|
400
|
+
/**
|
|
401
|
+
* @inheritDoc
|
|
402
|
+
*/
|
|
403
|
+
getExecutionSteps(options?: {
|
|
404
|
+
maxWaitTillAutomaticSettlementSeconds?: number;
|
|
405
|
+
}): Promise<[
|
|
406
|
+
SwapExecutionStepSetup<T["ChainId"]>,
|
|
407
|
+
SwapExecutionStepPayment<"BITCOIN">,
|
|
408
|
+
SwapExecutionStepSettlement<T["ChainId"], "awaiting_automatic" | "awaiting_manual">
|
|
409
|
+
]>;
|
|
377
410
|
/**
|
|
378
411
|
* @inheritDoc
|
|
379
412
|
*
|
|
@@ -417,7 +450,7 @@ export declare class FromBTCSwap<T extends ChainType = ChainType> extends IFromB
|
|
|
417
450
|
* @throws {Error} If swap is in invalid state (must be {@link FromBTCSwapState.BTC_TX_CONFIRMED})
|
|
418
451
|
* @throws {Error} If the LP refunded sooner than we were able to claim
|
|
419
452
|
*/
|
|
420
|
-
waitTillClaimed(maxWaitTimeSeconds?: number, abortSignal?: AbortSignal): Promise<boolean>;
|
|
453
|
+
waitTillClaimed(maxWaitTimeSeconds?: number, abortSignal?: AbortSignal, pollIntervalSeconds?: number): Promise<boolean>;
|
|
421
454
|
/**
|
|
422
455
|
* @inheritDoc
|
|
423
456
|
*/
|