Events

The Events interface provides a uniform mechanism for listening to global messages, for example, transfer state changes. The events interface is based on the NodeJS Events module.

Examples

Listening and responding to events can be done in the following way:

1
2
3
import { events } from 'cryptoasset-wallet'

events.on('eventName', callbackArgs => { ... })

e.g. monitoring the completion of all transfers can be achieved through the following:

1
2
3
4
5
import { events } from 'cryptoasset-wallet'

events.on('transferCompleted', transfer => {
    console.log("Transfer with hash " + transfer.transactionHash + " has completed!")
})

A full events reference including supported names and corresponding callback arguments can be found below.

Supported Events

The following tables outlines the currently provided events.

General Events
Name Description Callback args
transferSubmitted Indicates a transfer has been submitted to a ledger Transfer context
transferCompleted Indicates a transfer has been completed on a ledger Transfer context
walletUpdated Indicates a wallet has been updated and may need perisistence Updated Wallet context
Delegated Authorization Events
Name Description Callback args
accountPermissionRequested Indicates the wallet agent may require permission over this delegator account Account context, permissionsPayload object
accountPermissionRequired Indicates the wallet needs permission over this account to complete an action Account context, permissionsPayload object
accountRegistrationRequested Indicates an account can be registered as an agent for future delegation Account context, registrationDetails object
walletRegistrationRequired Indicates the wallet needs to be registered as an agent against the auth model Wallet context, registrationPayload object