SignersUtils

SignersUtils

SignersUtils is a toolbox that aims to ease the handling of multisignature transactions. The idea behind it is to fetch all required data once and to cache the responses into the transaction. Then, all the utilities can function in a synchronous (immediate) manner.

Those are automatically available in cosmicLink.transaction after await cosmicLink.lock() is ran. Alternatively, you can extend a transaction or generate its SignersUtils by using module:signersUtils. There's no cosmicLib.SignersUtils constructor.

An instance of SignersUtils is always tied to a given transaction. This is why none of the provided methods take a transaction as parameter.

Members Methods
sources: Array of transaction sources hasSigner: Test if a key is a legit signer for transaction
signers: Table of transaction signers hasSigned: Test if a key has signed transaction
signersList: Array of transaction signers
Source:

Example

const cosmicLink = new CosmicLink({ memo: 'Donation', maxDate: 2019 })
 .addOperation('payment', { destination: 'tips*cosmic.link', amount: 10 })

await cosmicLink.lock({ network: 'test', source: 'myaddress*example.org' })

console.log(cosmicLink.transaction.signers)
console.log(cosmicLink.transaction.hasSigner(GB...DXEZ))

Members

signers :Object

A table of the signers for each transaction source.

Source:
Type:
  • Object

signersList :Array

A list of the legit signers for the transaction.

Source:
Type:
  • Array

sources :Array

A list of the sources involved in the transaction.

Source:
Type:
  • Array

Methods

hasSigned(accountId) → {boolean}

Tests if accountId has signed the transaction.

Source:
Parameters:
Name Type Description
accountId string
Returns:
Type:
boolean
Example
if (transaction.hasSigned(GB...DEZX)) console.log('Has signed')

hasSigner(accountId) → {boolean}

Tests if accountId is a legit signer for the transaction.

Source:
Parameters:
Name Type Description
accountId string
Returns:
Type:
boolean
Example
if (transaction.hasSigner(GB...DEZX)) console.log('Legit signer')