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(bitcoinWallet: BitcoinWallet, ethereumWallet: EthereumWallet, cnd: Cnd, self: string): Swap

Defined in swap.ts:14

Parameters:

NameType
bitcoinWalletBitcoinWallet
ethereumWalletEthereumWallet
cndCnd
selfstring

Returns: Swap

Properties

self

self: string

Defined in swap.ts:19

Methods

accept

accept(tryParams: TryParams): Promise‹void›

Defined in swap.ts:28

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:38

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:51

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:135

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:104

Returns: Promise‹SwapDetails


fund

fund(tryParams: TryParams): Promise‹string›

Defined in swap.ts:66

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:81

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:96

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:118

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).