Version: 0.14.1

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: AllWallets): Swap

Defined in src/swap.ts:25

Parameters:

NameType
cndCnd
selfstring
walletsAllWallets

Returns: Swap

Properties

self

self: string

Defined in src/swap.ts:29

Methods

accept

accept(tryParams: TryParams): Promise‹void›

Defined in src/swap.ts:42

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.

throws A Problem from the cnd REST API or an Error.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹void›


decline

decline(tryParams: TryParams): Promise‹void›

Defined in src/swap.ts:53

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.

throws A Problem from the cnd REST API or an Error.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹void›


deploy

deploy(tryParams: TryParams): Promise‹Transaction | string›

Defined in src/swap.ts:67

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.

throws A Problem from the cnd REST API, or WalletError if the blockchain wallet throws, or an Error.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹Transaction | string›

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


doLedgerAction

doLedgerAction(ledgerAction: LedgerAction): Promise‹Transaction | string›

Defined in src/swap.ts:165

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.

throws A WalletError if a wallet or blockchain action failed.

Parameters:

NameTypeDescription
ledgerActionLedgerActionThe ledger action returned from Cnd.

Returns: Promise‹Transaction | string›


fetchDetails

fetchDetails(): Promise‹SwapDetails

Defined in src/swap.ts:129

Fetch the details of a swap.

throws A Problem from the cnd REST API or an Error.

Returns: Promise‹SwapDetails

The details of the swap are returned by cnd REST API.


fund

fund(tryParams: TryParams): Promise‹Transaction | string›

Defined in src/swap.ts:83

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.

throws A Problem from the cnd REST API, or WalletError if the blockchain wallet throws, or an Error.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹Transaction | string›

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


getAlphaDeployTransaction

getAlphaDeployTransaction(): Promise‹Transaction | string | null›

Defined in src/swap.ts:345

Get the Alpha deploy transaction.

Returns: Promise‹Transaction | string | null›

null if cnd hasn't seen a deploy transaction, otherwise, Transaction if supported or the transaction id as string.


getAlphaFundTransaction

getAlphaFundTransaction(): Promise‹Transaction | string | null›

Defined in src/swap.ts:358

Get the Alpha Fund transaction.

Returns: Promise‹Transaction | string | null›

null if cnd hasn't seen a funding transaction, otherwise, Transaction if supported or the transaction id as string.


getAlphaRedeemTransaction

getAlphaRedeemTransaction(): Promise‹Transaction | string | null›

Defined in src/swap.ts:369

Get the Alpha Redeem transaction.

Returns: Promise‹Transaction | string | null›

null if cnd hasn't seen a redeem transaction, otherwise, Transaction if supported or the transaction id as string.


getAlphaRefundTransaction

getAlphaRefundTransaction(): Promise‹Transaction | string | null›

Defined in src/swap.ts:382

Get the Alpha Refund transaction.

Returns: Promise‹Transaction | string | null›

null if cnd hasn't seen a refund transaction, otherwise, Transaction if supported or the transaction id as string.


getBetaDeployTransaction

getBetaDeployTransaction(): Promise‹Transaction | string | null›

Defined in src/swap.ts:395

Get the Beta deploy transaction.

Returns: Promise‹Transaction | string | null›

null if cnd hasn't seen a deploy transaction, otherwise, Transaction if supported or the transaction id as string.


getBetaFundTransaction

getBetaFundTransaction(): Promise‹Transaction | string | null›

Defined in src/swap.ts:408

Get the Beta Fund transaction.

Returns: Promise‹Transaction | string | null›

null if cnd hasn't seen a funding transaction, otherwise, Transaction if supported or the transaction id as string.


getBetaRedeemTransaction

getBetaRedeemTransaction(): Promise‹Transaction | string | null›

Defined in src/swap.ts:419

Get the Beta Redeem transaction.

Returns: Promise‹Transaction | string | null›

null if cnd hasn't seen a redeem transaction, otherwise, Transaction if supported or the transaction id as string.


getBetaRefundTransaction

getBetaRefundTransaction(): Promise‹Transaction | string | null›

Defined in src/swap.ts:432

Get the Beta Refund transaction.

Returns: Promise‹Transaction | string | null›

null if cnd hasn't seen a refund transaction, otherwise, Transaction if supported or the transaction id as string.


redeem

redeem(tryParams: TryParams): Promise‹Transaction | string›

Defined in src/swap.ts:99

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.

throws A Problem from the cnd REST API, or WalletError if the blockchain wallet throws, or an Error.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹Transaction | string›

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


refund

refund(tryParams: TryParams): Promise‹Transaction | string›

Defined in src/swap.ts:115

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.

throws A Problem from the cnd REST API, or WalletError if the blockchain wallet throws, or an Error.

Parameters:

NameTypeDescription
tryParamsTryParamsControls at which stage the exception is thrown.

Returns: Promise‹Transaction | string›

The result of the refund action, a hash of the transaction that was sent to the blockchain.


tryExecuteSirenAction

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

Defined in src/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. This only performs an action on the CND REST API, if an action is needed on another system (e.g blockchain wallet), then the needed information is returned by this function and needs to be processed with doLedgerAction.

throws A Problem from the cnd REST API, or WalletError if the blockchain wallet throws, or an Error.

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