From c622d3b23ebe9382a3cfdb107988c80c6ef711b9 Mon Sep 17 00:00:00 2001 From: Michael Bisgaard Olesen Date: Fri, 23 Jun 2023 12:08:14 +0200 Subject: [PATCH] Name gRPC client (v2) consistently (#191) Rename ConcordiumNodeClient to ConcordiumGRPCClient as that's the name under which it's exported. The name ConcordiumNodeClient is used only internally within common-sdk. The renaming is done only for the v2 client. --------- Co-authored-by: Hjort --- .markdown-linkcheck.json | 4 ++-- packages/common/src/GRPCClient.ts | 8 ++++---- packages/common/src/JsonRpcClient.ts | 2 +- packages/common/src/cis0.ts | 12 ++++++------ packages/common/src/cis2/CIS2Contract.ts | 10 +++++----- packages/common/src/index.ts | 2 +- packages/nodejs/README.md | 2 +- packages/nodejs/src/clientV2.ts | 2 +- packages/nodejs/test/clientV2.test.ts | 5 +++-- packages/nodejs/test/testHelpers.ts | 5 ++--- packages/web/README.md | 5 ++--- pages/cis2-contracts.md | 6 +++--- pages/documentation.md | 2 +- pages/misc-pages/grpc-v1.md | 2 +- pages/utility-functions.md | 4 ++-- 15 files changed, 35 insertions(+), 36 deletions(-) diff --git a/.markdown-linkcheck.json b/.markdown-linkcheck.json index e5088a3cc..84e981113 100644 --- a/.markdown-linkcheck.json +++ b/.markdown-linkcheck.json @@ -1,7 +1,7 @@ { "ignorePatterns": [ { - "pattern": "classes/Common_GRPC_Client.ConcordiumNodeClient.html" + "pattern": "classes/Common_GRPC_Client.ConcordiumGRPCClient.html" } ] -} \ No newline at end of file +} diff --git a/packages/common/src/GRPCClient.ts b/packages/common/src/GRPCClient.ts index 091bb9985..1569caf23 100644 --- a/packages/common/src/GRPCClient.ts +++ b/packages/common/src/GRPCClient.ts @@ -1,6 +1,6 @@ /** * This is the GRPC-Client used by both the Web-SDK and the NodeJS-SDK. Check - * out the {@link ConcordiumNodeClient} + * out the {@link ConcordiumGRPCClient} * * @module Common GRPC-Client */ @@ -45,10 +45,10 @@ export type FindInstanceCreationReponse = { * A concordium-node specific gRPC client wrapper. * * @example - * import ConcordiumNodeClient from "..." - * const client = new ConcordiumNodeClient('127.0.0.1', 20000, credentials, metadata, 15000); + * import { ConcordiumGRPCClient } from "..." + * const client = new ConcordiumGRPCClient('127.0.0.1', 20000, credentials, metadata, 15000); */ -export default class ConcordiumNodeClient { +export class ConcordiumGRPCClient { client: QueriesClient; /** diff --git a/packages/common/src/JsonRpcClient.ts b/packages/common/src/JsonRpcClient.ts index 0323911cf..91ece9bbd 100644 --- a/packages/common/src/JsonRpcClient.ts +++ b/packages/common/src/JsonRpcClient.ts @@ -47,7 +47,7 @@ function transformJsonResponse( } /** - * @deprecated This has been deprecated in favor of the {@link ConcordiumNodeClient} that uses version 2 of the concordium gRPC API + * @deprecated This has been deprecated in favor of the {@link ConcordiumGRPCClient} that uses version 2 of the concordium gRPC API */ export class JsonRpcClient { provider: Provider; diff --git a/packages/common/src/cis0.ts b/packages/common/src/cis0.ts index f1b550fe0..056c4a077 100644 --- a/packages/common/src/cis0.ts +++ b/packages/common/src/cis0.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer/'; import { ContractAddress, HexString } from './types'; -import ConcordiumNodeClient from './GRPCClient'; +import { ConcordiumGRPCClient } from './GRPCClient'; import { encodeWord16, makeDeserializeListResponse, @@ -100,7 +100,7 @@ const deserializeSupportResult = /** * Queries a CIS-0 contract for support for a {@link CIS0.StandardIdentifier}. * - * @param {ConcordiumNodeClient} grpcClient - The client to be used for the query. + * @param {ConcordiumGRPCClient} grpcClient - The client to be used for the query. * @param {ContractAddress} contractAddress - The address of the contract to query. * @param {CIS0.StandardIdentifier} standardId - The standard identifier to query for support in contract. * @param {HexString} [blockHash] - The hash of the block to query at. @@ -110,7 +110,7 @@ const deserializeSupportResult = * @returns {CIS0.SupportResult} The support result of the query, or `undefined` if the contract does not support CIS-0. */ export function cis0Supports( - grpcClient: ConcordiumNodeClient, + grpcClient: ConcordiumGRPCClient, contractAddress: ContractAddress, standardId: CIS0.StandardIdentifier, blockHash?: HexString @@ -118,7 +118,7 @@ export function cis0Supports( /** * Queries a CIS-0 contract for support for a {@link CIS0.StandardIdentifier}. * - * @param {ConcordiumNodeClient} grpcClient - The client to be used for the query. + * @param {ConcordiumGRPCClient} grpcClient - The client to be used for the query. * @param {ContractAddress} contractAddress - The address of the contract to query. * @param {CIS0.StandardIdentifier[]} standardIds - The standard identifiers to query for support in contract. * @param {HexString} [blockHash] - The hash of the block to query at. @@ -128,13 +128,13 @@ export function cis0Supports( * @returns {CIS0.SupportResult[]} The support results of the query ordered by the ID's supplied by the `ids` param, or `undefined` if the contract does not support CIS-0. */ export function cis0Supports( - grpcClient: ConcordiumNodeClient, + grpcClient: ConcordiumGRPCClient, contractAddress: ContractAddress, standardIds: CIS0.StandardIdentifier[], blockHash?: HexString ): Promise; export async function cis0Supports( - grpcClient: ConcordiumNodeClient, + grpcClient: ConcordiumGRPCClient, contractAddress: ContractAddress, standardIds: CIS0.StandardIdentifier | CIS0.StandardIdentifier[], blockHash?: HexString diff --git a/packages/common/src/cis2/CIS2Contract.ts b/packages/common/src/cis2/CIS2Contract.ts index 89ed7d807..17de23169 100644 --- a/packages/common/src/cis2/CIS2Contract.ts +++ b/packages/common/src/cis2/CIS2Contract.ts @@ -6,7 +6,7 @@ import { InvokeContractResult, UpdateContractPayload, } from '../types'; -import ConcordiumNodeClient from '../GRPCClient'; +import { ConcordiumGRPCClient } from '../GRPCClient'; import { AccountSigner, signTransaction } from '../signHelpers'; import { serializeCIS2Transfers, @@ -52,7 +52,7 @@ const getDefaultExpiryDate = (): Date => { */ class CIS2DryRun { constructor( - private grpcClient: ConcordiumNodeClient, + private grpcClient: ConcordiumGRPCClient, private contractAddress: ContractAddress, private contractName: string ) {} @@ -163,7 +163,7 @@ export class CIS2Contract { private dryRunInstance: CIS2DryRun; constructor( - private grpcClient: ConcordiumNodeClient, + private grpcClient: ConcordiumGRPCClient, private contractAddress: ContractAddress, private contractName: string ) { @@ -177,14 +177,14 @@ export class CIS2Contract { /** * Creates a new `CIS2Contract` instance by querying the node for the necessary information through the supplied `grpcClient`. * - * @param {ConcordiumNodeClient} grpcClient - The client used for contract invocations and updates. + * @param {ConcordiumGRPCClient} grpcClient - The client used for contract invocations and updates. * @param {ContractAddress} contractAddress - Address of the contract instance. * * @throws If `InstanceInfo` could not be received for the contract, if the contract does not support the CIS-2 standard, * or if the contract name could not be parsed from the information received from the node. */ static async create( - grpcClient: ConcordiumNodeClient, + grpcClient: ConcordiumGRPCClient, contractAddress: ContractAddress ): Promise { const instanceInfo = await grpcClient.getInstanceInfo(contractAddress); diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index ef0550e90..4b349166e 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -48,7 +48,7 @@ export { isHex, streamToList, wasmToSchema, unwrap } from './util'; export { HttpProvider } from './providers/httpProvider'; export { JsonRpcClient } from './JsonRpcClient'; export * from './identity'; -export { default as ConcordiumGRPCClient } from './GRPCClient'; +export { ConcordiumGRPCClient } from './GRPCClient'; export { getAccountTransactionHandler } from './accountTransactions'; export * from './energyCost'; diff --git a/packages/nodejs/README.md b/packages/nodejs/README.md index 33dac37a9..903c9b681 100644 --- a/packages/nodejs/README.md +++ b/packages/nodejs/README.md @@ -8,7 +8,7 @@ Please see the [documentation](https://developer.concordium.software/concordium-node-sdk-js/index.html) for more information -## ConcordiumNodeClient +## ConcordiumGRPCClient The SDK provides a gRPC client, which can interact with the [Concordium Node](https://github.com/Concordium/concordium-node) diff --git a/packages/nodejs/src/clientV2.ts b/packages/nodejs/src/clientV2.ts index 61ac54701..cb2ac0303 100644 --- a/packages/nodejs/src/clientV2.ts +++ b/packages/nodejs/src/clientV2.ts @@ -1,6 +1,6 @@ import { ChannelCredentials } from '@grpc/grpc-js'; import { GrpcOptions, GrpcTransport } from '@protobuf-ts/grpc-transport'; -import ConcordiumGRPCClient from '@concordium/common-sdk/lib/GRPCClient'; +import { ConcordiumGRPCClient } from '@concordium/common-sdk/lib/GRPCClient'; /** * Initialize a gRPC client for a specific concordium node. diff --git a/packages/nodejs/test/clientV2.test.ts b/packages/nodejs/test/clientV2.test.ts index 569fc7580..5de495a57 100644 --- a/packages/nodejs/test/clientV2.test.ts +++ b/packages/nodejs/test/clientV2.test.ts @@ -1,7 +1,8 @@ import * as v1 from '@concordium/common-sdk'; import * as v2 from '../../common/grpc/v2/concordium/types'; import { testnetBulletproofGenerators } from './resources/bulletproofgenerators'; -import ConcordiumNodeClientV2, { +import { + ConcordiumGRPCClient, getAccountIdentifierInput, getBlockHashInput, } from '@concordium/common-sdk/lib/GRPCClient'; @@ -56,7 +57,7 @@ const testBlockHash = // Retrieves the account info for the given account in the GRPCv2 type format. function getAccountInfoV2( - client: ConcordiumNodeClientV2, + client: ConcordiumGRPCClient, accountIdentifier: v1.AccountIdentifierInput ): Promise { const accountInfoRequest = { diff --git a/packages/nodejs/test/testHelpers.ts b/packages/nodejs/test/testHelpers.ts index 32cd47aba..d69fd3094 100644 --- a/packages/nodejs/test/testHelpers.ts +++ b/packages/nodejs/test/testHelpers.ts @@ -5,7 +5,6 @@ import { ConcordiumGRPCClient, IdentityInput } from '@concordium/common-sdk'; import { decryptMobileWalletExport, EncryptedData } from '../src/wallet/crypto'; import { MobileWalletExport } from '../src/wallet/types'; import { createConcordiumClient } from '../src/clientV2'; -import ConcordiumNodeClientV2 from '@concordium/common-sdk/lib/GRPCClient'; import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport'; // This makes sure the necessary types are added to `globalThis` @@ -20,7 +19,7 @@ export { getModuleBuffer } from '../src/util'; export function getNodeClient( address = 'node.testnet.concordium.com', port = 20000 -): ConcordiumNodeClientV2 { +): ConcordiumGRPCClient { return createConcordiumClient(address, port, credentials.createInsecure(), { timeout: 15000, }); @@ -29,7 +28,7 @@ export function getNodeClient( export function getNodeClientWeb( address = 'http://node.testnet.concordium.com', port = 20000 -): ConcordiumNodeClientV2 { +): ConcordiumGRPCClient { const transport = new GrpcWebFetchTransport({ baseUrl: `${address}:${port}`, timeout: 15000, diff --git a/packages/web/README.md b/packages/web/README.md index 34ebe50d0..b0c593143 100644 --- a/packages/web/README.md +++ b/packages/web/README.md @@ -12,7 +12,7 @@ for more information - [concordium-web-sdk](#concordium-web-sdk) - - [ConcordiumNodeClient](#concordiumnodeclient) + - [ConcordiumGRPCClient](#concordiumgrpcclient) - [JSON-RPC client](#json-rpc-client) - [Creating buffers](#creating-buffers) - [Examples](#examples) @@ -29,8 +29,7 @@ for more information - [SendCIS2UpdateOperator.html](#sendcis2updateoperatorhtml) -## ConcordiumNodeClient - +## ConcordiumGRPCClient The SDK provides a gRPC client, which can interact with the [Concordium Node](https://github.com/Concordium/concordium-node) using gRPC-web. diff --git a/pages/cis2-contracts.md b/pages/cis2-contracts.md index 64c98da3a..b05a0e713 100644 --- a/pages/cis2-contracts.md +++ b/pages/cis2-contracts.md @@ -21,19 +21,19 @@ This document describes the helper class for working with CIS-2 contracts ## CIS2Contract The CIS2Contract class wraps the -[ConcordiumNodeClient](../classes/Common_GRPC_Client.ConcordiumNodeClient.html), +[ConcordiumGRPCClient](../classes/Common_GRPC_Client.ConcordiumGRPCClient.html), defining an interface matching the [CIS-2 standard](https://proposals.concordium.software/CIS/cis-2.html). ### Creating a CIS2Contract -The contract relies on a `ConcordiumNodeClient` instance to communicate +The contract relies on a `ConcordiumGRPCClient` instance to communicate with the node along with a contract address of the CIS-2 contract to invoke functions on. ```ts const contractAddress = {index: 1234n, subindex: 0n}; - const contract = await CIS2Contract.create(nodeClient, contractAddress); // Implied that you already have a `ConcordiumNodeClient` instance of some form. + const contract = await CIS2Contract.create(nodeClient, contractAddress); // Implied that you already have a `ConcordiumGRPCClient` instance of some form. ``` This gets the relevant contract information from the node and checks diff --git a/pages/documentation.md b/pages/documentation.md index a2f1641ee..8a073092a 100644 --- a/pages/documentation.md +++ b/pages/documentation.md @@ -2,7 +2,7 @@ This is the documentation for the Concordium Javascript SDK. Here we cover the JS wrappers for interacting with the Concordium nodes. Most functionality is provideded by the -[GRPC-Client](../classes/Common_GRPC_Client.ConcordiumNodeClient.html) +[GRPC-Client](../classes/Common_GRPC_Client.ConcordiumGRPCClient.html) however there exists additional helper functions, for example to help with creating {@page transactions.md transactions}, or {@page identity-proofs.md creating identity proof statements}, or {@page utility-functions.md general diff --git a/pages/misc-pages/grpc-v1.md b/pages/misc-pages/grpc-v1.md index 6081c41a4..fde400114 100644 --- a/pages/misc-pages/grpc-v1.md +++ b/pages/misc-pages/grpc-v1.md @@ -1,5 +1,5 @@ > :warning: **This explains behaviour of the deprecated v1 concordium client**: -check out [the documentation the v2 client](../../classes/Common_GRPC_Client.ConcordiumNodeClient.html) +check out [the documentation the v2 client](../../classes/Common_GRPC_Client.ConcordiumGRPCClient.html) This describes the JSON-RPC client, which can interact with the [Concordium JSON-RPC server](https://github.com/Concordium/concordium-json-rpc) diff --git a/pages/utility-functions.md b/pages/utility-functions.md index 371852196..a85303da6 100644 --- a/pages/utility-functions.md +++ b/pages/utility-functions.md @@ -233,10 +233,10 @@ and does not give any guarantees for whether the contract adheres to the standard it claims to implement. The function returns `undefined` if the contract does not support CIS-0. -This requires a [`ConcordiumNodeClient`](../classes/Common_GRPC_Client.ConcordiumNodeClient.html). +This requires a [`ConcordiumGRPCClient`](../classes/Common_GRPC_Client.ConcordiumGRPCClient.html). ```ts - const client = ...; // `ConcordiumNodeClient` + const client = ...; // `ConcordiumGRPCClient` const address = {index: 1234n, subindex: 0n}; // Contract to check for support. const standardId = 'CIS-2'; // const standardIds = ['CIS-1', 'CIS-2']; // Example of a list of standards to check for.