Skip to main content

API

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

EventSource

Ƭ EventSource: EventSources[keyof EventSources]

An EventSource is essentially an ethers contract, that we can keep track of


MetadataEvent

Ƭ MetadataEvent<K>: typeof IPFS_METADATA_EVENTS[K]

Type parameters

NameType
Kextends MetadataType

MetadataValue

Ƭ MetadataValue<K>: ReturnType<typeof IPFS_METADATA_PARSERS[K]>

Type parameters

NameType
Kextends MetadataType

Functions

addressesAreEqual

addressesAreEqual(a, b): boolean

Check if two addresses are equal

Parameters

NameType
astring
bstring

Returns

boolean


extractCustomEvent

extractCustomEvent<T>(eventName, receipt, iface): undefined | T

Manually extract an event using the interface (e.g. if emitting contract is a different one than the calling contract)

Type parameters

Name
T

Parameters

NameType
eventNamestring
receiptContractReceipt | ParsedLogTransactionReceipt
ifaceInterface

Returns

undefined | T


extractEvent

extractEvent<T>(eventName, receipt): undefined | T

Extract event args from a contract receipt

Type parameters

Name
T

Parameters

NameType
eventNamestring
receiptContractReceipt | ParsedLogTransactionReceipt

Returns

undefined | T


getLogs

getLogs(filter, provider): Promise<Log[]>

Version of getLogs that also supports filtering for multiple addresses

Parameters

NameType
filterEthers6Filter | Ethers6FilterByBlockHash | Promise<Ethers6Filter | Ethers6FilterByBlockHash>
providerJsonRpcProvider

Returns

Promise<Log[]>


nonNullable

nonNullable<T>(value): value is NonNullable<T>

Use this to filter empty undefinied values from arrays in a type-safe way

Type parameters

Name
T

Parameters

NameType
valueT

Returns

value is NonNullable<T>


toEth

toEth(num): string

Convert any number to ETH (remove 18 zeros)

Example

import { toEth } from '@colony/sdk';

const oneEther = BigNumber.from("1000000000000000000");
console.log(toEth(oneEther)); // 1.0

Parameters

NameType
numBigNumberish

Returns

string


toWei

toWei(num): BigNumber

Convert any number to wei (add 18 zeros)

Example

import { toWei } from '@colony/sdk';

const oneEther = '1.0';
console.log(toWei(oneEther)); // { BigNumber: "1000000000000000000" }

Parameters

NameType
numstring

Returns

BigNumber


w

w(str): BigNumber

Short-hand method to convert a number to wei using JS tagged template strings

See also here: http://tc39wiki.calculist.org/es6/template-strings/

Remarks

This is only useful in contexts where the number is hard-coded (e.g. examples)

Example

import { w } from '@colony/sdk';

console.log(w`1.0`); // { BigNumber: "1000000000000000000" }

Parameters

NameType
strTemplateStringsArray

Returns

BigNumber