Skip to main content

IFromBTCLNWrapper<T, D, O>

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts:27

Base class for wrappers of escrow-based Lightning -> Smart chain swaps

Extends​

Extended by​

Type Parameters​

Type ParameterDefault type
T extends ChainType-
D extends IFromBTCLNDefinition<T, IFromBTCLNWrapper<T, D>, IEscrowSwap<T, D>>-
O extends ISwapWrapperOptionsISwapWrapperOptions

Constructors​

Constructor​

new IFromBTCLNWrapper<T, D, O>(
chainIdentifier,
unifiedStorage,
unifiedChainEvents,
chain,
prices,
tokens,
versionedContracts,
lnApi,
lpApi,
options,
events?): IFromBTCLNWrapper<T, D, O>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts:50

Parameters​

ParameterTypeDescription
chainIdentifierstring
unifiedStorageUnifiedSwapStorage<T>Storage interface for the current environment
unifiedChainEventsUnifiedSwapEventListener<T>On-chain event listener
chainT["ChainInterface"]
pricesISwapPriceSwap pricing handler
tokensWrapperCtorTokens
versionedContracts{ [version: string]: object; }
lnApiLightningNetworkApi
lpApiIntermediaryAPI
optionsO
events?EventEmitter<{ swapState: [IEscrowSwap<ChainType, IEscrowSwapDefinition<ChainType, IEscrowSwapWrapper<ChainType, any, ISwapWrapperOptions>, IEscrowSwap<ChainType, any, any>>, number>]; }>Instance to use for emitting events

Returns​

IFromBTCLNWrapper<T, D, O>

Overrides​

IFromBTCWrapper.constructor

Properties​

_versionedContracts​

readonly _versionedContracts: object = {};

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts:55

Index Signature​

[version: string]: object

Inherited from​

IFromBTCWrapper._versionedContracts


chainIdentifier​

readonly chainIdentifier: T["ChainId"];

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:164

Chain identifier string of this wrapper

Inherited from​

IFromBTCWrapper.chainIdentifier


events​

readonly events: EventEmitter<{
swapState: [D["Swap"]];
}>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:168

Event emitter emitting "swapState" event when swap's state changes

Inherited from​

IFromBTCWrapper.events


TYPE​

abstract readonly TYPE: SwapType;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts:33

Swap type

Inherited from​

IEscrowSwapWrapper.TYPE

Methods​

checkPastSwaps()​

checkPastSwaps(pastSwaps?, noSave?): Promise<{
changedSwaps: D["Swap"][];
removeSwaps: D["Swap"][];
}>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:424

Runs checks on all the known pending swaps, syncing their state from on-chain data

Parameters​

ParameterTypeDescription
pastSwaps?D["Swap"][]Optional array of past swaps to check, otherwise all relevant swaps will be fetched from the persistent storage
noSave?booleanWhether to skip saving the swap changes in the persistent storage

Returns​

Promise<{ changedSwaps: D["Swap"][]; removeSwaps: D["Swap"][]; }>

Remarks​

Doesn't work properly if you pass non-persisted swaps

Inherited from​

IFromBTCWrapper.checkPastSwaps


init()​

init(noTimers, noCheckPastSwaps): Promise<void>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:360

Initializes the swap wrapper, needs to be called before any other action can be taken

Parameters​

ParameterTypeDefault valueDescription
noTimersbooleanfalseWhether to skip scheduling a tick timer for the swaps, if the tick timer is not initiated the swap states depending on e.g. expiry can be out of sync with the actual expiration of the swap
noCheckPastSwapsbooleanfalseWhether to skip checking past swaps on initialization (by default all pending swaps are re-checked on init, and their state is synchronized from the on-chain data)

Returns​

Promise<void>

Inherited from​

IFromBTCWrapper.init


recoverFromSwapDataAndState()​

abstract recoverFromSwapDataAndState(
init,
state,
contractVersion,
lp?): Promise<D["Swap"]>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts:274

Recovers a swap from smart chain on-chain data, please note that not all values for the recovered swaps might be populated, as some data is purely off-chain and can never be recovered purely from on-chain data.

Parameters​

ParameterTypeDescription
init{ data: T["Data"]; getInitTxId: () => Promise<string>; getTxBlock: () => Promise<{ blockHeight: number; blockTime: number; }>; }Swap escrow initialization transaction and swap data
init.dataT["Data"]-
init.getInitTxId() => Promise<string>-
init.getTxBlock() => Promise<{ blockHeight: number; blockTime: number; }>-
state?SwapCommitStateCurrent on-chain state of the swap
contractVersion?string-
lp?IntermediaryIntermediary (LP) used as a counterparty for the swap

Returns​

Promise<D["Swap"]>

Inherited from​

IFromBTCWrapper.recoverFromSwapDataAndState


stop()​

stop(): Promise<void>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:401

Un-subscribes from event listeners on the smart chain, terminates the tick interval and stops this wrapper

Returns​

Promise<void>

Inherited from​

IFromBTCWrapper.stop


tick()​

tick(swaps?, abortSignal?): Promise<void>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:459

Invokes ISwap._tick on all the known swaps

Parameters​

ParameterTypeDescription
swaps?D["Swap"][]Optional array of swaps to invoke _tick() on, otherwise all relevant swaps will be fetched from the persistent storage
abortSignal?AbortSignalAbort signal

Returns​

Promise<void>

Inherited from​

IFromBTCWrapper.tick