Tokens app

This is an app connector for the Tokens app (token-manager.aragonpm.eth). It only supports The Graph for now.

Usage

To connect a Tokens app, you need to pass it to connectTokens():

import connect from '@aragon/connect'
import connectTokens from '@aragon/connect-tokens'

const org = await connect('myorg.aragonid.eth', 'thegraph')
const tokens = await connectTokens(org.app('token-manager'))

It extends the App object, which means that every method and property of App is also available on this object.

connect(app, connector)

Connects and returns a Tokens instance.

NameTypeDescription

app

App or Promise<App>

The app to extend with connected capabilities.

connector

["thegraph", Object] or "thegraph"

Accepts either a string describing the desired connector (only "thegraph" for now), or a tuple to also pass a configuration object to the connector.

returns

Promise<Tokens>

An Tokens instance (see below).

It can throw the following errors:

Error typeDescription

Either the passed value is not a valid app object, or its name is not token-manager.

Either the connector configuration format is not valid, or the connector name is not supported.

A subgraph couldn’t be found with the current network. Pass a subgraphUrl directly, or use one of the supported networks.

Tokens

An object representing the Tokens app, returned by connectTokens(). Use the following API to retrieve its data:

Tokens#token()

Get the Token instance used with the app.

NameTypeDescription

returns

Promise<Token>

A Token object.

This method can throw one of the following errors:

Error typeDescription

The response seems incorrect.

The connection to the remote source failed.

Tokens#holders(filters)

Get a list of token holders.

NameTypeDescription

filters

Object

Optional object allowing to filter the token holders.

filters.first

Number

Maximum number of token holders. Defaults to 1000.

filters.skip

Number

Skip a number of token holders. Defaults to 0.

returns

Promise<TokenHolder[]>

List of token holders.

This method can throw one of the following errors:

Error typeDescription

The response seems incorrect.

The connection to the remote source failed.

Tokens#onHolders(filters, callback)

Subscribe to a list of token holders. The callback is optional, not passing it will return a partially applied function.

NameTypeDescription

filters

Object

Optional object allowing to filter the token holders. See Tokens#holders() for details.

callback

(error: Error, tokenHolders: TokenHolder[]) => void

A callback that will get called every time the result gets updated.

returns

{ unsubscribe: () => void }

Unsubscribe function.

The error passed to callback can be null (no error) or one of the following:

Error typeDescription

The data couldn’t be fetched.

The connection to the remote source failed.

Token

This object represents the token contract (based on MiniMe) used by the Tokens app. It gets returned by Tokens#token() for example.

NameTypeDescription

id

String

Unique identifier representing this token.

address

Address

Address of the MiniMe Token contract.

name

String

The token name (e.g. “Aragon Network Token”).

symbol

String

The token symbol (e.g. “ANT”).

totalSupply

String

The total supply for the token.

transferable

Boolean

Whether the token is transferable.

TokenHolder

This object represents a single token holder. It gets returned by Tokens#holders() for example.

NameTypeDescription

id

String

Unique identifier representing the token holder.

address

Address

Address of the token holder.

balance

String

Current balance.

Last updated