Version: 0.13.0

Swap

A stateful class that represents a single swap.

It has all the dependencies embedded that are necessary for taking actions on the swap.

Hierarchy

  • Swap

Index

Constructors

Properties

Methods

Constructors

constructor

+ new Swap(cnd: Cnd, self: string, wallets?: undefined | object): Swap

Defined in swap.ts:18

Parameters:

NameType
cndCnd
selfstring
wallets?undefined | object

Returns: Swap

Properties

self

self: string

Defined in swap.ts:22

Methods

accept

accept(tryParams: TryParams): Promise‹void›

Defined in swap.ts:57

Looks for and executes the accept action of this Swap. If the Swap is not in the right state this call will throw a timeout exception.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹void›


decline

decline(tryParams: TryParams): Promise‹void›

Defined in swap.ts:67

Looks for and executes the decline action of this Swap. If the Swap is not in the right state this call will throw a timeout exception.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹void›


deploy

deploy(tryParams: TryParams): Promise‹string›

Defined in swap.ts:80

Looks for and executes the deploy action of this Swap. If the Swap is not in the right state this call will throw a timeout exception.

This is only valid for ERC20 swaps.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹string›

The hash of the transaction that was sent to the blockchain network.


doLedgerAction

doLedgerAction(ledgerAction: LedgerAction): Promise‹string›

Defined in swap.ts:164

Low level API for executing a ledger action returned from Cnd.

Uses the wallets given in the constructor to send transactions according to the given ledger action.

Parameters:

NameTypeDescription
ledgerActionLedgerActionThe ledger action returned from Cnd.

Returns: Promise‹string›


fetchDetails

fetchDetails(): Promise‹SwapDetails

Defined in swap.ts:133

Returns: Promise‹SwapDetails


fund

fund(tryParams: TryParams): Promise‹string›

Defined in swap.ts:95

Looks for and executes the fund action of this Swap. If the Swap is not in the right state this call will throw a timeout exception.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹string›

The hash of the transaction that was sent to the blockchain network.


redeem

redeem(tryParams: TryParams): Promise‹string›

Defined in swap.ts:110

Looks for and executes the redeem action of this Swap. If the Swap is not in the right state this call will throw a timeout exception.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹string›

The hash of the transaction that was sent to the blockchain network.


refund

refund(tryParams: TryParams): Promise‹string›

Defined in swap.ts:125

Looks for and executes the refund action of this Swap. If the Swap is not in the right state this call will throw a timeout exception.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹string›

The hash of the transaction that was sent to the blockchain network.


tryExecuteSirenAction

tryExecuteSirenAction<R>(actionName: string, __namedParameters: object): Promise‹AxiosResponse‹R››

Defined in swap.ts:147

Low level API for executing actions on the Swap.

If you are using any of the above actions (Swap.redeem, etc) you shouldn't need to use this.

Type parameters:

R

Parameters:

actionName: string

The name of the Siren action you want to execute.

__namedParameters: object

NameType
maxTimeoutSecsnumber
tryIntervalSecsnumber

Returns: Promise‹AxiosResponse‹R››

The response from Cnd. The actual response depends on the action you executed (hence the type parameter).


withBitcoinWallet

withBitcoinWallet(bitcoinWallet: BitcoinWallet): Swap

Defined in swap.ts:36

Parameters:

NameType
bitcoinWalletBitcoinWallet

Returns: Swap


withEthereumWallet

withEthereumWallet(ethereumWallet: EthereumWallet): Swap

Defined in swap.ts:41

Parameters:

NameType
ethereumWalletEthereumWallet

Returns: Swap


withLightningWallet

withLightningWallet(lightningWallet: LightningWallet): Swap

Defined in swap.ts:46

Parameters:

NameType
lightningWalletLightningWallet

Returns: Swap