@daostack/client › Globals › Arc
Class: Arc
The Arc class holds all configuration. Any useage of the library typically will start with instantiating a new Arc instance
returns
an instance of Arc
Hierarchy
-
↳ Arc
Index
Constructors
Properties
- Logger
- apolloClient
- blockHeaderSubscription
- contractInfos
- contracts
- contractsR
- graphqlHttpProvider
- graphqlSubscribeToQueries
- graphqlWsProvider
- ipfs
- ipfsProvider
- observedAccounts
- pendingOperations
- web3
- web3Provider
- web3ProviderRead
- web3Read
Methods
- GENToken
- allowance
- approveForStaking
- dao
- daos
- ethBalance
- events
- fetchContractInfos
- getABI
- getAccount
- getContract
- getContractInfo
- getContractInfoByName
- getObservable
- getObservableList
- getObservableListWithFilter
- getObservableObject
- proposal
- proposals
- saveIPFSData
- scheme
- schemes
- sendQuery
- sendTransaction
- setAccount
- setContractInfos
- tags
Constructors
constructor
+ new Arc(options
: object): Arc
Overrides GraphNodeObserver.constructor
Defined in arc.ts:51
Parameters:
▪ options: object
Name | Type | Description |
---|---|---|
contractInfos? |
IContractInfo[] | Information about the contracts. Cf. setContractInfos and fetchContractInfos |
graphqlHttpProvider? |
undefined | string | - |
graphqlPrefetchHook? |
undefined | function | this function will be called before a query is sent to the graphql provider |
graphqlSubscribeToQueries? |
undefined | false | true | determines whether a query should subscribe to updates from the graphProvider. Default is true. |
graphqlWsProvider? |
undefined | string | - |
ipfsProvider? |
IPFSProvider | - |
web3Provider? |
undefined | string | - |
web3ProviderRead? |
undefined | string | - |
Returns: Arc
Properties
Logger
• Logger: GlobalLogger = Logger
Inherited from GraphNodeObserver.Logger
Defined in graphnode.ts:117
Optional
apolloClient
• apolloClient? : ApolloClient‹object›
Inherited from GraphNodeObserver.apolloClient
Defined in graphnode.ts:118
blockHeaderSubscription
• blockHeaderSubscription: *Subscription | undefined* = undefined |
Defined in arc.ts:44
contractInfos
• contractInfos: IContractInfo[]
Defined in arc.ts:39
a mapping of contrct names to contract addresses
contracts
• contracts: object
Defined in arc.ts:40
Type declaration:
- [ key: string]: any
contractsR
• contractsR: object
Defined in arc.ts:41
Type declaration:
- [ key: string]: any
Optional
graphqlHttpProvider
• graphqlHttpProvider? : *undefined | string* |
Inherited from GraphNodeObserver.graphqlHttpProvider
Defined in graphnode.ts:115
Optional
graphqlSubscribeToQueries
• graphqlSubscribeToQueries? : *undefined | false | true* |
Inherited from GraphNodeObserver.graphqlSubscribeToQueries
Defined in graphnode.ts:119
Optional
graphqlWsProvider
• graphqlWsProvider? : *undefined | string* |
Inherited from GraphNodeObserver.graphqlWsProvider
Defined in graphnode.ts:116
ipfs
• ipfs: any
Defined in arc.ts:33
ipfsProvider
• ipfsProvider: IPFSProvider
Defined in arc.ts:29
observedAccounts
• observedAccounts: object
Defined in arc.ts:45
Type declaration:
-
[ address: string]: object
-
lastBalance? : *undefined string* -
observable? : Observable‹BN›
-
observer? : Observer‹BN›
- subscriptionsCount: number
pendingOperations
• pendingOperations: Observable‹Array‹Operation‹any››› = of()
Defined in arc.ts:31
web3
• web3: any
Defined in arc.ts:34
web3Provider
• web3Provider: Web3Provider = “”
Defined in arc.ts:27
web3ProviderRead
• web3ProviderRead: Web3Provider = “”
Defined in arc.ts:28
web3Read
• web3Read: any
Defined in arc.ts:35
Methods
GENToken
▸ GENToken(): Token‹›
Defined in arc.ts:341
get the GEN Token
Returns: Token‹›
a Token instance
allowance
▸ allowance(owner
: Address, spender
: Address): Observable‹BN›
Defined in arc.ts:402
How much GEN spender may spend on behalve of the owner
Parameters:
Name | Type | Description |
---|---|---|
owner |
Address | Address of the owner of the tokens |
spender |
Address | Address of the spender |
Returns: Observable‹BN›
approveForStaking
▸ approveForStaking(spender
: Address, amount
: BN): IOperationObservable‹ITransactionUpdate‹any››
Defined in arc.ts:392
Parameters:
Name | Type |
---|---|
spender |
Address |
amount |
BN |
Returns: IOperationObservable‹ITransactionUpdate‹any››
dao
Defined in arc.ts:134
get a DAO instance from an address
Parameters:
Name | Type | Description |
---|---|---|
address |
Address | address of the dao Avatar |
Returns: DAO
an instance of a DAO
daos
▸ daos(options
: IDAOQueryOptions, apolloQueryOptions
: IApolloQueryOptions): Observable‹DAO[]›
Defined in arc.ts:144
return an observable of the list of DAOs
Parameters:
Name | Type | Default | Description |
---|---|---|---|
options |
IDAOQueryOptions | {} | options to pass on to the query |
apolloQueryOptions |
IApolloQueryOptions | {} | - |
Returns: Observable‹DAO[]›
ethBalance
▸ ethBalance(owner
: Address): Observable‹BN›
Defined in arc.ts:180
Parameters:
Name | Type |
---|---|
owner |
Address |
Returns: Observable‹BN›
events
▸ events(options
: IEventQueryOptions, apolloQueryOptions
: IApolloQueryOptions): Observable‹Event[]›
Defined in arc.ts:173
Parameters:
Name | Type | Default |
---|---|---|
options |
IEventQueryOptions | {} |
apolloQueryOptions |
IApolloQueryOptions | {} |
Returns: Observable‹Event[]›
fetchContractInfos
▸ fetchContractInfos(apolloQueryOptions
: IApolloQueryOptions): Promise‹IContractInfo[]›
Defined in arc.ts:113
fetch contractInfos from the subgraph
Parameters:
Name | Type | Default |
---|---|---|
apolloQueryOptions |
IApolloQueryOptions | {} |
Returns: Promise‹IContractInfo[]›
a list of IContractInfo instances
getABI
▸ getABI(address? : Address, abiName? : undefined |
string, version? : undefined |
string): any |
Defined in arc.ts:284
Parameters:
Name | Type |
---|---|
address? |
Address |
abiName? |
undefined | string |
version? |
undefined | string |
Returns: any
getAccount
▸ getAccount(): Observable‹Address›
Defined in arc.ts:354
Returns: Observable‹Address›
getContract
▸ getContract(address : Address, abi? : any, mode? : undefined |
“readonly”): any |
Defined in arc.ts:313
return a web3 Contract instance.
Parameters:
Name | Type | Description |
---|---|---|
address |
Address | address of the contract to look up in self.contractInfos |
abi? |
any | - |
mode? |
undefined | “readonly” | - |
Returns: any
a web3 contract instance
getContractInfo
▸ getContractInfo(address
: Address): IContractInfo
Defined in arc.ts:259
return information about the contract
Parameters:
Name | Type |
---|---|
address |
Address |
Returns: IContractInfo
an IContractInfo instance
getContractInfoByName
▸ getContractInfoByName(name
: string, version
: string): IContractInfo
Defined in arc.ts:272
Parameters:
Name | Type |
---|---|
name |
string |
version |
string |
Returns: IContractInfo
getObservable
▸ getObservable(query
: any, apolloQueryOptions
: IApolloQueryOptions): any
Inherited from GraphNodeObserver.getObservable
Defined in graphnode.ts:145
Given a gql query, will return an observable of query results
Parameters:
Name | Type | Default | Description |
---|---|---|---|
query |
any | - | a gql query object to execute |
apolloQueryOptions |
IApolloQueryOptions | {} | options to pass on to Apollo, cf .. |
Returns: any
an Observable that will first yield the current result, and yields updates every time the data changes
getObservableList
▸ getObservableList(query
: any, itemMap
: function, apolloQueryOptions
: IApolloQueryOptions): any
Inherited from GraphNodeObserver.getObservableList
Defined in graphnode.ts:246
Returns an observable that:
- sends a query over http and returns the current list of results
- subscribes over a websocket to changes, and returns the updated list.
example:
const query = gql`
{
daos {
id
address
}
}`
getObservableList(query, (r:any) => new DAO(r.address))
Parameters:
▪ query: any
The query to be run
▪Default value
itemMap: function= (o) => o
(optional) a function that takes elements of the list and creates new objects
▸ (o : object): *object |
null* |
Parameters:
Name | Type |
---|---|
o |
object |
▪Default value
apolloQueryOptions: IApolloQueryOptions= {}
Returns: any
an Observable
getObservableListWithFilter
▸ getObservableListWithFilter(query
: any, itemMap
: function, filterFunc
: function, apolloQueryOptions
: IApolloQueryOptions): any
Inherited from GraphNodeObserver.getObservableListWithFilter
Defined in graphnode.ts:285
Returns an observable that:
- sends a query over http and returns the current list of results
- subscribes over a websocket to changes, and returns the updated list
example:
const query = gql
{ daos { id address } }
getObservableList(query, (r:any) => new DAO(r.address), filter((r:any) => r.address === “0x1234…”))
Parameters:
▪ query: any
The query to be run
▪Default value
itemMap: function= (o) => o
(optional) a function that takes elements of the list and creates new objects
▸ (o : object): *object |
null* |
Parameters:
Name | Type |
---|---|
o |
object |
▪ filterFunc: function
▸ (o
: object): boolean
Parameters:
Name | Type |
---|---|
o |
object |
▪Default value
apolloQueryOptions: IApolloQueryOptions= {}
Returns: any
getObservableObject
▸ getObservableObject(query
: any, itemMap
: function, apolloQueryOptions
: IApolloQueryOptions): any
Inherited from GraphNodeObserver.getObservableObject
Defined in graphnode.ts:302
Parameters:
▪ query: any
▪Default value
itemMap: function= (o) => o
▸ (o : object): *object |
null* |
Parameters:
Name | Type |
---|---|
o |
object |
▪Default value
apolloQueryOptions: IApolloQueryOptions= {}
Returns: any
proposal
▸ proposal(id
: string): Proposal
Defined in arc.ts:163
Parameters:
Name | Type |
---|---|
id |
string |
Returns: Proposal
proposals
▸ proposals(options
: IProposalQueryOptions, apolloQueryOptions
: IApolloQueryOptions): Observable‹Proposal[]›
Defined in arc.ts:167
Parameters:
Name | Type | Default |
---|---|---|
options |
IProposalQueryOptions | {} |
apolloQueryOptions |
IApolloQueryOptions | {} |
Returns: Observable‹Proposal[]›
saveIPFSData
▸ saveIPFSData(options
: object): Promise‹string›
Defined in arc.ts:427
save data of a proposal to IPFS, return the IPFS hash
Parameters:
▪ options: object
an Object to save. This object must have title, url and desction defined
Name | Type |
---|---|
description? |
undefined | string |
tags? |
string[] |
title? |
undefined | string |
url? |
undefined | string |
Returns: Promise‹string›
a Promise that resolves in the IPFS Hash where the file is saved
scheme
▸ scheme(id
: string): Scheme
Defined in arc.ts:152
Parameters:
Name | Type |
---|---|
id |
string |
Returns: Scheme
schemes
▸ schemes(options
: ISchemeQueryOptions, apolloQueryOptions
: IApolloQueryOptions): Observable‹Scheme[]›
Defined in arc.ts:156
Parameters:
Name | Type | Default |
---|---|---|
options |
ISchemeQueryOptions | {} |
apolloQueryOptions |
IApolloQueryOptions | {} |
Returns: Observable‹Scheme[]›
sendQuery
▸ sendQuery(query
: any, apolloQueryOptions
: IApolloQueryOptions): Promise‹object›
Inherited from GraphNodeObserver.sendQuery
Defined in graphnode.ts:322
Parameters:
Name | Type | Default |
---|---|---|
query |
any | - |
apolloQueryOptions |
IApolloQueryOptions | {} |
Returns: Promise‹object›
sendTransaction
▸ sendTransaction<T>(transaction : any, mapToObject : function, errorHandler? : undefined |
function): Operation‹T› |
Defined in arc.ts:413
send an Ethereum transaction
Type parameters:
▪ T
Parameters:
▪ transaction: any
▪ mapToObject: function
▸ (receipt
: web3receipt): T
Parameters:
Name | Type |
---|---|
receipt |
web3receipt |
▪Optional errorHandler: *undefined |
function* |
Returns: Operation‹T›
An observable of
setAccount
▸ setAccount(address
: Address): void
Defined in arc.ts:388
Parameters:
Name | Type |
---|---|
address |
Address |
Returns: void
setContractInfos
▸ setContractInfos(contractInfos
: IContractInfo[]): Promise‹void›
Defined in arc.ts:102
set the contract addresses
Parameters:
Name | Type | Description |
---|---|---|
contractInfos |
IContractInfo[] | a list of IContractInfo objects |
Returns: Promise‹void›
tags
▸ tags(options
: ITagQueryOptions, apolloQueryOptions
: IApolloQueryOptions): Observable‹Tag[]›
Defined in arc.ts:148
Parameters:
Name | Type | Default |
---|---|---|
options |
ITagQueryOptions | {} |
apolloQueryOptions |
IApolloQueryOptions | {} |
Returns: Observable‹Tag[]›