Class: CometaClient
CometaClient is a client that interacts with the Cometa service. Cometa service is used to store contract metadata: source code, ABI, etc. CometaClient
Example
import { CometaClient } from '@nilfoundation/niljs';
const service = new CometaClient({
transport: new HttpTransport({
endpoint: COMETA_ENDPOINT,
}),
});
Extends
Constructors
new CometaClient()
new CometaClient(config): CometaClient
Parameters
Parameter | Type |
---|---|
|
Returns
Overrides
Defined
@nilfoundation/niljs/src/clients/CometaClient.ts:22
Properties
shardId?
optional shardId: number;
The ID of the shard with which the client needs to interact. The shard with this ID will be used in every call made by the client.
Inherited from
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:26
transport
readonly transport: ITransport;
The ITransport to be used in the client. See ITransport.
Inherited from
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:18
Methods
compileContract()
compileContract(inputJson): Promise<ContractData>
Compiles the contract.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The JSON input. |
Returns
Promise
<ContractData
>
The contract metadata.
Defined
@nilfoundation/niljs/src/clients/CometaClient.ts:56
decodeTransactionsCallData()
decodeTransactionsCallData(data): Promise<string[]>
Accepts an array of transaction data and returns an array of decoded function names called by the transactions.
Parameters
Parameter | Type | Description |
---|---|---|
| The data to decode. |
Returns
Promise
<string
[]>
The decoded data.
Defined
@nilfoundation/niljs/src/clients/CometaClient.ts:119
getAbi()
getAbi(address): Promise<string>
Returns the abi of the contract.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Address of the contract. |
Returns
Promise
<string
>
Abi of the contract.
Defined
@nilfoundation/niljs/src/clients/CometaClient.ts:95
getContract()
getContract(address): Promise<ContractData>
Returns the contract metadata.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Address of the contract. |
Returns
Promise
<ContractData
>
The contract metadata.
Defined
@nilfoundation/niljs/src/clients/CometaClient.ts:31
getLocation()
getLocation(address, pc): Promise<Location>
Returns the contract metadata.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Address of the contract. |
|
| Program counter. |
Returns
Promise
<Location
>
The contract metadata.
Defined
@nilfoundation/niljs/src/clients/CometaClient.ts:44
getShardId()
getShardId(): undefined | number
Returns the shard ID.
Returns
undefined
| number
The shard ID.
Inherited from
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:51
getSourceCode()
getSourceCode(address): Promise<Record<string, string>>
Returns the source code of the contract by address.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Address of the contract. |
Returns
Promise
<Record
<string
, string
>>
The source code of the contract.
Defined
@nilfoundation/niljs/src/clients/CometaClient.ts:107
registerContract()
registerContract(inputJson, address): Promise<unknown>
Register the contract.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The JSON input for compiler. |
|
| Address of the contract. |
Returns
Promise
<unknown
>
Defined
@nilfoundation/niljs/src/clients/CometaClient.ts:81
registerContractData()
registerContractData(contractData, address): Promise<unknown>
Register the contract by compilation result.
Parameters
Parameter | Type | Description |
---|---|---|
| The contract data. | |
|
| Address of the contract. |
Returns
Promise
<unknown
>
Defined
@nilfoundation/niljs/src/clients/CometaClient.ts:69
request()
protected request<T>(requestObject): Promise<T>
Sends a request.
Type Parameters
Type Parameter |
---|
|
Parameters
Parameter | Type | Description |
---|---|---|
|
| The request object. It contains the request method and parameters. |
Returns
Promise
<T
>
The response.
Inherited from
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:43
setShardId()
setShardId(shardId): void
Sets the shard ID.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The shard ID. |
Returns
void
Throws
Will throw an error if the provided shard ID is invalid.
Example
client.setShardId(1);
Inherited from
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:62