Utils

Exponential backoff

backoffIntervalStep(n, multiplier)

Returns the next interval to use for exponential backoff. This curve yields every value 4 times before doubling in the next step. The function is multiplier * 2**Math.floor(n/4). By default (multiplier = 1s), the intervals reach ca. 1 minute (total time elapsed ca. 4 minutes) after step 24, so it is advised to declare a timeout after a certain number of steps.

Arguments:
  • n (number) – step on the interval curve
  • multiplier (number) – multiplier, default 1000 (1s)
Returns:

number

AccountSpec serialization

serializeAccountSpec(accountSpec)

Serializes accountSpec, e.g. { chainId: ‘foo’, address: ‘bar’ } => foo/bar

Arguments:
  • accountSpec (models/account.AccountSpec) –
Returns:

string

deserializeAccountSpec(serialized)

Deserializes accountSpec, e.g. foo/bar => { chainId: ‘foo’, address: ‘bar’ }. If string has no /, uses whole string as address with empty chainId.

Arguments:
  • serialized (string) –
Returns:

models/account.AccountSpec