API
Namespaces
Enumerations
- ColonyLabelSuffix
- ColonyRole
- ColonyRpcEndpoint
- Extension
- Id
- MetaTxBroadCasterEndpoint
- MetadataType
- MotionState
- Network
- SupportedExtension
- TeamColor
- UserLabelSuffix
- Vote
Classes
- CloudflareReadonlyAdapter
- Colony
- ColonyEventManager
- ColonyGraph
- ColonyNetwork
- ColonyToken
- ColonyTxCreator
- ERC20Token
- ERC2612Token
- MetaTxCreator
- OneTxPayment
- PinataAdapter
- TxCreator
- VotingReputation
Interfaces
- AnnotationMetadata
- BaseContract
- ColonyEvent
- ColonyEventManagerOptions
- ColonyFilter
- ColonyMetadata
- ColonyMultiFilter
- ColonyNetworkOptions
- ColonyTopic
- DecisionMetadata
- DomainMetadata
- Ethers6Filter
- Ethers6FilterByBlockHash
- EventSources
- GraphDomain
- IpfsAdapter
- MetaTxBaseContract
- NetworkClientOptions
- ParsedLogTransactionReceipt
- PermissionConfig
- SubgraphClientOptions
- SupportedExtensions
- TxConfig
- TxCreatorConfig
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
Name | Type |
---|---|
K | extends MetadataType |
MetadataValue
Ƭ MetadataValue<K
>: ReturnType
<typeof IPFS_METADATA_PARSERS
[K
]>
Type parameters
Name | Type |
---|---|
K | extends MetadataType |
Variables
DecisionMotionCode
• Const
DecisionMotionCode: "0x12345678"
Identifies a motion as a decision
Usually there's no need to use this directly. Use VotingReputation.createDecision instead.
Functions
addressesAreEqual
▸ addressesAreEqual(a
, b
): boolean
Check if two addresses are equal
Parameters
Name | Type |
---|---|
a | string |
b | string |
Returns
boolean
createSubgraphClient
▸ createSubgraphClient(options?
): Client
Creates a Colony Subgraph client
The Colony Subgraph client is nothing else than a ready-to-use urql
client connected to the Colony Subgraph with subscriptions enabled. Please refer to the following references if you'd like to know more about The Graph or GraphQL in general.
The Colony Subgraph's schema and resolvers are kept up-to-date by the Colony team and can be explored here: Colony Subgraph. There you can make test queries to the Colony Subgraph and explore it all the way down the rabbit hole :)
Example
Retrieve the 10 most recent "DomainAdded" events across all Colonies
import { createSubgraphClient, gql } from '@colony/sdk/graph';
const colonySubgraph = createSubgraphClient();
const QUERY = gql`
query DomainAddedEvents {
events(
first: 10
orderBy: timestamp
orderDirection: desc
where: { name_contains: "DomainAdded" }
) {
id
address
associatedColony {
colonyAddress: id
}
name
args
timestamp
}
}
`;
colonySubgraph
.query(QUERY)
.toPromise()
.then((result) => {
console.info(result.data.events[0]);
});
Parameters
Name | Type | Description |
---|---|---|
options? | SubgraphClientOptions | Define configuration options to instantiate the client with |
Returns
Client
A ready-to-use urql
GraphQL client instance
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
Name | Type |
---|---|
eventName | string |
receipt | ContractReceipt | ParsedLogTransactionReceipt |
iface | Interface |
Returns
undefined
| T
extractEvent
▸ extractEvent<T
>(eventName
, receipt
): undefined
| T
Extract event args from a contract receipt
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
eventName | string |
receipt | ContractReceipt | ParsedLogTransactionReceipt |
Returns
undefined
| T
getLogs
▸ getLogs(filter
, provider
): Promise
<Log
[]>
Version of getLogs
that also supports filtering for multiple addresses
Parameters
Name | Type |
---|---|
filter | Ethers6Filter | Ethers6FilterByBlockHash | Promise <Ethers6Filter | Ethers6FilterByBlockHash > |
provider | JsonRpcProvider |
Returns
Promise
<Log
[]>
gql
▸ gql<Data
, Variables
>(strings
, ...interpolations
): TypedDocumentNode
<Data
, Variables
>
Type parameters
Name | Type |
---|---|
Data | any |
Variables | object |
Parameters
Name | Type |
---|---|
strings | TemplateStringsArray |
...interpolations | (string | DocumentNode | TypedDocumentNode <{ [key: string] : any ; }, { [key: string] : any ; }>)[] |
Returns
TypedDocumentNode
<Data
, Variables
>
▸ gql<Data
, Variables
>(string
): TypedDocumentNode
<Data
, Variables
>
Type parameters
Name | Type |
---|---|
Data | any |
Variables | object |
Parameters
Name | Type |
---|---|
string | string |
Returns
TypedDocumentNode
<Data
, Variables
>
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
Name | Type |
---|---|
value | T |
Returns
value is NonNullable<T>
parseRoles
▸ parseRoles(roles
): ColonyRole
[]
Parses a binary role integer into a ColonyRole array
When getting multiple roles from contract methods or events they are usually formatted as a binary number. Here the least significant bit is the role with the index 0 (Recovery).
E.g. 5 = 0b00101 equals Recovery and Arbitration
This function parses these binary integers into a ColonyRole array.
Parameters
Name | Type | Description |
---|---|---|
roles | string | A hex string (e.g. 0x3 = 0b11 equals Recovery and Root roles) |
Returns
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
Name | Type |
---|---|
num | BigNumberish |
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
Name | Type |
---|---|
num | string |
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
Name | Type |
---|---|
str | TemplateStringsArray |
Returns
BigNumber