/// import { ChannelCredentials, Metadata } from '@grpc/grpc-js'; import { P2PClient } from '../grpc/concordium_p2p_rpc_grpc_pb'; import { PeerListResponse } from '../grpc/concordium_p2p_rpc_pb'; import { AccountAddress as Address, CredentialRegistrationId, AccountInfo, AccountTransaction, AccountTransactionSignature, ArInfo, BlockInfo, BlockSummary, ConsensusStatus, ContractAddress, CredentialDeploymentTransaction, CryptographicParameters, IpInfo, NextAccountNonce, TransactionStatus, Versioned, InstanceInfo, BakerId, PoolStatus, BakerPoolStatus, RewardStatus, PassiveDelegationStatus, ContractContext, InvokeContractResultV1, ModuleReference } from '@concordium/common-sdk'; /** * A concordium-node specific gRPC client wrapper. * * @example * import ConcordiumNodeClient from "..." * const client = new ConcordiumNodeClient('127.0.0.1', 10000, credentials, metadata, 15000); * @deprecated This has been succeeded by the new V2 client, check {@link createConcordiumClient} */ export default class ConcordiumNodeClient { client: P2PClient; metadata: Metadata; address: string; port: number; timeout: number; /** * Initialize a gRPC client for a specific concordium node. * @param address the ip address of the node, e.g. 127.0.0.1 * @param port the port to use when econnecting to the node * @param credentials credentials to use to connect to the node * @param timeout milliseconds to wait before timing out * @param options optional options for the P2PClient */ constructor(address: string, port: number, credentials: ChannelCredentials, metadata: Metadata, timeout: number, options?: Record); /** * Sends a credential deployment transaction, for creating a new account, * to the node to be put in a block on the chain. * * Note that a transaction can still fail even if it was accepted by the node. * To keep track of the transaction use getTransactionStatus. * @param credentialDeploymentTransaction the credential deployment transaction to send to the node * @param signatures the signatures on the hash of the serialized unsigned credential deployment information, in order * @returns true if the transaction was accepted, otherwise false */ sendCredentialDeploymentTransaction(credentialDeploymentTransaction: CredentialDeploymentTransaction, signatures: string[]): Promise; /** * Serializes and sends an account transaction to the node to be * put in a block on the chain. * * Note that a transaction can still fail even if it was accepted by the node. * To keep track of the transaction use getTransactionStatus. * @param accountTransaction the transaction to send to the node * @param signatures the signatures on the signing digest of the transaction * @returns true if the transaction was accepted, otherwise false */ sendAccountTransaction(accountTransaction: AccountTransaction, signatures: AccountTransactionSignature): Promise; /** * Retrieves the account info for the given account. If the provided block * hash is in a block prior to the finalization of the account, then the account * information will not be available. * A credential registration id can also be provided, instead of an address. In this case * the node will return the account info of the account, which the corresponding credential * is (or was) deployed to. * @param accountAddress base58 account address (or a credential registration id) to get the account info for * @param blockHash the block hash to get the account info at * @returns the account info for the provided account address, undefined is the account does not exist */ getAccountInfo(accountAddress: string | Address | CredentialRegistrationId, blockHash: string): Promise; /** * Retrieves the next account nonce for the given account. The account nonce is * used in all account transactions as part of their header. * @param accountAddress base58 account address to get the next account nonce for * @returns the next account nonce, and a boolean indicating if the nonce is reliable */ getNextAccountNonce(accountAddress: Address): Promise; /** * Retrieves a status for the given transaction. * @param transactionHash the transaction to get a status for * @returns the transaction status for the given transaction, or undefined if the transaction does not exist */ getTransactionStatus(transactionHash: string): Promise; /** * Retrieves the block summary for a specific block. This contains information * about finalization, update sequence numbers (their nonce), update queues, * updateable chain parameters and transaction summaries for any transaction * in the block. * @param blockHash the block to get the summary for * @returns the block summary for the given block, or undefined if the block does not exist */ getBlockSummary(blockHash: string): Promise; /** * Retrieves information about a specific block. * @param blockHash the block to get information about * @returns the block information for the given block, or undefined if the block does not exist */ getBlockInfo(blockHash: string): Promise; /** * Retrieves the blocks are the given height. * @param height the block height as a positive integer * @returns a string array containing the blocks at the given height, i.e. ['blockHash1', 'blockHash2', ...] */ getBlocksAtHeight(height: bigint): Promise; /** * Retrieves the consensus status information from the node. Note that the optional * fields will only be unavailable for a newly started node that has not processed * enough data yet. */ getConsensusStatus(): Promise; /** * Retrieves the global cryptographic parameters on the blockchain at * the provided block. * @param blockHash the block to get the cryptographic parameters at * @returns the global cryptographic parameters at the given block, or undefined it the block does not exist. */ getCryptographicParameters(blockHash: string): Promise | undefined>; /** * Retrieves a list of the node's peers and connection information related to them. * @param includeBootstrappers whether or not any bootstrapper nodes should be included in the list * @returns a list of the node's peers and connection information related to them */ getPeerList(includeBootstrappers: boolean): Promise; /** * Retrieves the list of identity providers at the provided blockhash. * @param blockHash the block to get the identity providers at * @returns the list of identity providers at the given block */ getIdentityProviders(blockHash: string): Promise; /** * Retrieves the list of anonymity revokers at the provided blockhash. * @param blockHash the block to get the anonymity revokers at * @returns the list of anonymity revokers at the given block */ getAnonymityRevokers(blockHash: string): Promise; /** * Retrieves the addresses of all smart contract instances. * @param blockHash the block hash to get the smart contact instances at * @returns a list of contract addresses on the chain, i.e. [{"subindex":0,"index":0},{"subindex":0,"index":1}, ....] */ getInstances(blockHash: string): Promise; /** * Retrieve information about a given smart contract instance. * @param blockHash the block hash to get the smart contact instances at * @param address the address of the smart contract * @returns A JSON object with information about the contract instance */ getInstanceInfo(address: ContractAddress, blockHash: string): Promise; getRewardStatus(blockHash: string): Promise; /** * Retrieve list of bakers on the network. * @param blockHash the block hash to get the smart contact instances at * @returns A JSON list of baker IDs */ getBakerList(blockHash: string): Promise; /** * Gets the status of passive delegation. * @param blockHash the block hash the status at * @returns The status of passive delegation. */ getPoolStatus(blockHash: string): Promise; /** * Gets the status a baker. * @param blockHash the block hash the status at * @param bakerId the ID of the baker to get the status for. * @returns The status of the corresponding baker pool. */ getPoolStatus(blockHash: string, bakerId: BakerId): Promise; /** * Gets the status of either a baker, if a baker ID is supplied, or passive delegation if left undefined. * @param blockHash the block hash the status at * @param [bakerId] the ID of the baker to get the status for. If left undefined, the status of passive delegation is returned. * @returns The status of the corresponding pool. */ getPoolStatus(blockHash: string, bakerId?: BakerId): Promise; /** * Retrieves the source of the given module at * the provided block. * @param moduleReference the module's reference, which is the hex encoded hash of the source. * @param blockHash the block to get the cryptographic parameters at * @returns the source of the module as raw bytes. */ getModuleSource(moduleReference: ModuleReference, blockHash: string): Promise; /** * Invokes a smart contract. * @param context the collection of details used to invoke the contract. Must include the address of the contract and the method invoked. * @param blockHash the block hash at which the contract should be invoked at. The contract is invoked in the state at the end of this block. * @returns If the node was able to invoke, then a object describing the outcome is returned. * The outcome is determined by the `tag` field, which is either `success` or `failure`. * The `usedEnergy` field will always be present, and is the amount of NRG was used during the execution. * If the tag is `success`, then an `events` field is present, and it contains the events that would have been generated. * If invoking a V1 contract and it produces a return value, it will be present in the `returnValue` field. * If the tag is `failure`, then a `reason` field is present, and it contains the reason the update would have been rejected. * If either the block does not exist, or then node fails to parse of any of the inputs, then undefined is returned. */ invokeContract(contractContext: ContractContext, blockHash: string): Promise; sendRequest(command: any, input: T): Promise; }