Skip to main content

colonyJS

Namespaces

Enumerations

Interfaces

Type Aliases

AnyCoinMachineClient

Ƭ AnyCoinMachineClient: CoinMachineClientV1 | CoinMachineClientV2 | CoinMachineClientV3 | CoinMachineClientV4 | CoinMachineClientV5


AnyColonyClient

Ƭ AnyColonyClient: ColonyClientV1 | ColonyClientV2 | ColonyClientV3 | ColonyClientV4 | ColonyClientV5 | ColonyClientV6 | ColonyClientV7 | ColonyClientV8 | ColonyClientV9


AnyOneTxPaymentClient

Ƭ AnyOneTxPaymentClient: OneTxPaymentClientV1 | OneTxPaymentClientV2 | OneTxPaymentClientV3


AnyVotingReputationClient

Ƭ AnyVotingReputationClient: VotingReputationClientV1 | VotingReputationClientV2 | VotingReputationClientV3 | VotingReputationClientV4


AnyWhitelistClient

Ƭ AnyWhitelistClient: WhitelistClientV1 | WhitelistClientV2


ColonyRoles

Ƭ ColonyRoles: UserRoles[]

All users that have roles in a colony


ContractClient

Ƭ ContractClient: AnyColonyClient | ColonyNetworkClient | EventsClient | ExtensionClient | TokenClient | TokenLockingClient


DomainRoles

Ƭ DomainRoles: Object

All roles a user has in domainId

Type declaration

NameType
domainIdnumber
rolesColonyRole[]

EventsClient

Ƭ EventsClient: CoinMachineEvents | IColonyEvents | OneTxPaymentEvents | VotingReputationEvents | WhitelistEvents


ExtensionClient

Ƭ ExtensionClient: AnyCoinMachineClient | AnyOneTxPaymentClient | AnyVotingReputationClient | AnyWhitelistClient


Motion

Ƭ Motion: VotingReputation.MotionStructOutput


SignerOrProvider

Ƭ SignerOrProvider: Signer | Provider


TokenClient

Ƭ TokenClient: ColonyTokenClient | Erc20TokenClient | DaiTokenClient


UserRoles

Ƭ UserRoles: Object

All domains the user with address has roles in

Type declaration

NameType
addressstring
domainsDomainRoles[]

Variables

COLONY_VERSION_LATEST

Const COLONY_VERSION_LATEST: number


ExtensionVersions

Const ExtensionVersions: Object

Type declaration

NameType
CoinMachinenumber
OneTxPaymentnumber
VotingReputationnumber
Whitelistnumber

Functions

formatColonyRoles

formatColonyRoles(roleSetEvents, recoveryRoleSetEvents): Promise<ColonyRoles>

Format role events into an Array of all roles in the colony

E.g.:

[{
address: 0x5346D0f80e2816FaD329F2c140c870ffc3c3E2Ef // user address
domains: [{ // all domains the user has a role in
domainId: 1, // domainId for the roles
roles: [1, 2, 3] // Array of `ColonyRole`
}]
}]

Parameters

NameType
roleSetEventsLogDescription[]
recoveryRoleSetEventsLogDescription[]

Returns

Promise<ColonyRoles>


getBlockTime

getBlockTime(provider, blockHash): Promise<number>

Get the JavaScript timestamp for a block

Parameters

NameTypeDescription
providerProviderethers compatible Provider
blockHashstringHash of block to get time for

Returns

Promise<number>

block timestamp in ms


getChildIndex

getChildIndex(client, parentDomainId, domainId): Promise<BigNumber>

Get the child index for a domain inside its corresponding skills parent children array

E.g. (the values will differ for you!): domainId = 1 corresponding skillId = 2 parent of skillId 2:

{
// ...
children: [2]
}

childSkillIndex would be 0 in this case (0-position in children array)

Parameters

NameTypeDescription
clientAnyColonyClientAny ColonyClient
parentDomainIdBigNumberishid of parent domain
domainIdBigNumberishid of the domain

Returns

Promise<BigNumber>

Index in the children array (see above)


getColonyNetworkClient

getColonyNetworkClient(network, signerOrProvider, options?): ColonyNetworkClient

The main entry point for accessing the deployed colonyNetwork contracts

Specify a network and an ethers compatible singer or provider to get back an initialized and extended (ethers) contract client for the colonyNetwork. From here you can access different colonies, extensions, ENS and other features of Colony.

Example

import { getColonyNetworkClient, Network } = from '@colony/colony-js';
import { providers } from 'ethers';

// For local connections (run an Ethereum node on port 8545);
const provider = new providers.JsonRpcProvider();

// Just for reading data - to sign transactions we need to pass in a signer.
const networkClient = await getColonyNetworkClient(Network.Xdai, provider);

Parameters

NameTypeDescription
networkNetworkOne of the available options. See Network.
signerOrProviderSignerOrProviderAn ethers compatible signer or provider instance
options?NetworkClientOptionsHere you can supply options for accessing certain contracts (mostly used in local/dev environments)

Returns

ColonyNetworkClient


getColonyRoles

getColonyRoles(client, options?): Promise<ColonyRoles>

Get an array of all roles in the colony

Parameters

NameTypeDescription
clientAnyColonyClientAny ColonyClient
options?LogOptions-

Returns

Promise<ColonyRoles>

Array of user roles in a colony (see above) fetching it's own network events


getEvents

getEvents(client, filter, options?): Promise<LogDescription[]>

Get parsed event data from filter

Example:

// Gets the logs for the `ColonyFundsClaimed` event (not filtered)
const filter = colonyClient.filters.ColonyFundsClaimed(null, null, null);
const events = await getEvents(colonyClient, filter);

Parameters

NameTypeDescription
clientContractClientAny of the intantiated contract clients
filterFilterethers compatible Filter object
options?LogOptionsConfiguration options to filter logs

Returns

Promise<LogDescription[]>

Parsed ethers LogDescription array (events)


getExtensionHash

getExtensionHash(extensionName): string

Hashes to identify the colony extension contracts

Parameters

NameType
extensionNamestring

Returns

string


getExtensionPermissionProofs

getExtensionPermissionProofs(colonyClient, domainId, address?): Promise<[BigNumberish, BigNumberish]>

Wrapper around getPermissionProofs to check two types of permissions: Funding and Administration To be used for checking an extension's permission in said colony

Parameters

NameTypeDescription
colonyClientAugmentedIColony<AnyIColony>Any ColonyClient
domainIdBigNumberishDomain id the method needs to act in
address?stringAddress of the extension

Returns

Promise<[BigNumberish, BigNumberish]>

Tuple of [permissionDomainId, childSkillIndex]


getHistoricColonyRoles

getHistoricColonyRoles(client, fromBlock?, toBlock?): Promise<ColonyRoles>

Parameters

NameType
clientAnyColonyClient
fromBlock?number
toBlock?number

Returns

Promise<ColonyRoles>


getLogs

getLogs(client, filter, options?): Promise<Log[]>

Get raw (unparsed logs) from filter

Example:

// Gets the logs for the `ColonyFundsClaimed` event (not filtered)
const filter = colonyClient.filters.ColonyFundsClaimed(null, null, null);
const logs = await getLogs(colonyClient, filter);

Parameters

NameTypeDescription
clientContractClientAny of the intantiated contract clients
filterFilterethers compatible Filter object
optionsLogOptionsConfiguration options to filter logs

Returns

Promise<Log[]>

ethers Log array


getMultipleEvents

getMultipleEvents(client, filters, options?): Promise<LogDescription[]>

Get multiple events from multiple filters

Remarks

only works when all events are emitted by the same contract!

Parameters

NameTypeDescription
clientContractClientAny of the intantiated contract clients
filtersEventFilter[]-
options?LogOptionsConfiguration options to filter logs

Returns

Promise<LogDescription[]>

Parsed ethers LogDescription array (events)


getPermissionProofs

getPermissionProofs(client, domainId, role, customAddress?): Promise<[BigNumber, BigNumber]>

Get the permission proofs for a user address and a certain role

Certain methods on Colony contracts require so called "permission proofs". These are made up by the permissionDomainId and the childSkillIndex. We shall attempt an explanation here.

Domains within a colony can be nested and all the permissions in a parent domain apply for all child domains. Yet at the time of calling a domain-permissioned method the contracts are unaware of the parent domain a certain user has the required permission in. So when we these methods are called we have to supply them the id of the parent domain the user has the permission in (it could also be the very same domain id they want to act in!). Furthermore for the contracts the unidirectional chain downwards we have to supply the method wuth the index of the domains associated skill in its parents children array (childSkillIndex, see [[getChildIndex]]). The contracts are then able to verify the permissions (the role) claimed by the caller.

tl;dr:

  • permissionDomainId: id of the parent domain of the required domain the user has the required permission in
  • childSkillIndex: the child index for a domain inside its corresponding skills parent children array

Parameters

NameTypeDescription
clientAnyColonyClientAny ColonyClient
domainIdBigNumberishDomain id the method needs to act in
roleColonyRolePermissioning role that the methods needs to function
customAddress?stringA custom address to get the permission proofs for (defaults to the signer's address)

Returns

Promise<[BigNumber, BigNumber]>

Tuple of [permissionDomainId, childSkillIndex]


getPotDomain

getPotDomain(client, potId): Promise<BigNumberish>

Get the associated domain for a pot id

Remarks

pots can be associated with different types, like domains, payments or tasks See [[FundingPotAssociatedType]] for details

Parameters

NameTypeDescription
clientAnyColonyClientAny ColonyClient
potIdBigNumberishThe funding pot id

Returns

Promise<BigNumberish>

The associated domainId


isExtensionCompatible

isExtensionCompatible(extension, extensionVersion, colonyVersion): boolean

Checks the compatibility of an extension version with a colony version it requests to be installed in Returns true if an extension version is compatible with the given colony version

Parameters

NameTypeDescription
extensionExtensionA valid Extension contract name
extensionVersionExtensionVersionThe version of the extension to check against the colony
colonyVersion2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9The version of the colony to check for

Returns

boolean

indication whether extension in given version is compatible with colony at the given version