diff --git a/docs/gRPC.md b/docs/gRPC.md index 7d5373839..8982491b3 100644 --- a/docs/gRPC.md +++ b/docs/gRPC.md @@ -2,58 +2,59 @@ This document describes the different endpoints for the concordium gRPC V2 client. -- [Concordium Nodejs SDK](#concordium-nodejs-sdk) +**Table of Contents** + - [ConcordiumNodeClient](#concordiumnodeclient) - - [Creating a client](#creating-a-client) - - [Send Account Transaction](#send-account-transaction) - - [Create a new account](#create-a-new-account) - - [getAccountInfo](#getaccountinfo) - - [getNextAccountSequenceNumber](#getnextaccountsequencenumber) - - [getBlockItemStatus](#getblockitemstatus) - - [getConsensusStatus](#getconsensusstatus) - - [getCryptographicParameters](#getcryptographicparameters) - - [getBlockChainParameters](#getblockchainparameters) - - [getPoolInfo](#getpoolinfo) - - [getPassiveDelegationInfo](#getpassivedelegationinfo) - - [getTokenomicsInfo](#gettokenomicsinfo) - - [getInstanceInfo](#getinstanceinfo) - - [invokeContract](#invokecontract) - - [getModuleSource](#getmodulesource) - - [getBlocks](#getblocks) - - [getFinalizedBlocks](#getfinalizedblocks) - - [waitForTransactionFinalization](#waitfortransactionfinalization) - - [getAccountList](#getaccountlist) - - [getModuleList](#getmodulelist) - - [getAncestors](#getancestors) - - [getInstanceState](#getinstancestate) - - [instanceStateLookup](#instancestatelookup) - - [getIdentityProviders](#getidentityproviders) - - [getAnonymityRevokers](#getanonymityrevokers) - - [getBlocksAtHeight](#getblocksatheight) - - [getBlockInfo](#getblockinfo) - - [getBakerList](#getbakerlist) - - [getPoolDelegators](#getpooldelegators) - - [getPoolDelegatorsRewardPeriod](#getpooldelegatorsrewardperiod) - - [getPassiveDelegators](#getpassivedelegators) - - [getPassiveDelegatorsRewardPeriod](#getpassivedelegatorsrewardperiod) - - [getBranches](#getbranches) - - [getElectionInfo](#getelectioninfo) - - [getAccountNonFinalizedTransactions](#getaccountnonfinalizedtransactions) - - [getBlockTransactionEvents](#getblocktransactionevents) - - [getNextUpdateSequenceNumbers](#getnextupdatesequencenumbers) - - [shutdown](#shutdown) - - [peerConnect](#peerconnect) - - [peerDisconnect](#peerdisconnect) - - [getBannedPeers](#getbannedpeers) - - [banPeer](#banpeer) - - [unbanPeer](#unbanpeer) - - [dumpStart](#dumpstart) - - [dumpStop](#dumpstop) - - [getNodeInfo](#getnodeinfo) - - [getPeersInfo](#getpeersinfo) - - [getBlockSpecialEvents](#getblockspecialevents) - - [getBlockPendingUpdates](#getblockpendingupdates) - - [getBlockFinalizationSummary](#getblockfinalizationsummary) + - [Creating a client](#creating-a-client) + - [Send Account Transaction](#send-account-transaction) + - [Create a new account](#create-a-new-account) + - [getAccountInfo](#getaccountinfo) + - [getNextAccountSequenceNumber](#getnextaccountsequencenumber) + - [getBlockItemStatus](#getblockitemstatus) + - [getConsensusStatus](#getconsensusstatus) + - [getCryptographicParameters](#getcryptographicparameters) + - [getBlockChainParameters](#getblockchainparameters) + - [getPoolInfo](#getpoolinfo) + - [getPassiveDelegationInfo](#getpassivedelegationinfo) + - [getTokenomicsInfo](#gettokenomicsinfo) + - [getInstanceInfo](#getinstanceinfo) + - [invokeContract](#invokecontract) + - [getModuleSource](#getmodulesource) + - [getBlocks](#getblocks) + - [getFinalizedBlocks](#getfinalizedblocks) + - [waitForTransactionFinalization](#waitfortransactionfinalization) + - [getAccountList](#getaccountlist) + - [getModuleList](#getmodulelist) + - [getAncestors](#getancestors) + - [getInstanceState](#getinstancestate) + - [instanceStateLookup](#instancestatelookup) + - [getIdentityProviders](#getidentityproviders) + - [getAnonymityRevokers](#getanonymityrevokers) + - [getBlocksAtHeight](#getblocksatheight) + - [getBlockInfo](#getblockinfo) + - [getBakerList](#getbakerlist) + - [getPoolDelegators](#getpooldelegators) + - [getPoolDelegatorsRewardPeriod](#getpooldelegatorsrewardperiod) + - [getPassiveDelegators](#getpassivedelegators) + - [getPassiveDelegatorsRewardPeriod](#getpassivedelegatorsrewardperiod) + - [getBranches](#getbranches) + - [getElectionInfo](#getelectioninfo) + - [getAccountNonFinalizedTransactions](#getaccountnonfinalizedtransactions) + - [getBlockTransactionEvents](#getblocktransactionevents) + - [getNextUpdateSequenceNumbers](#getnextupdatesequencenumbers) + - [shutdown](#shutdown) + - [peerConnect](#peerconnect) + - [peerDisconnect](#peerdisconnect) + - [getBannedPeers](#getbannedpeers) + - [banPeer](#banpeer) + - [unbanPeer](#unbanpeer) + - [dumpStart](#dumpstart) + - [dumpStop](#dumpstop) + - [getNodeInfo](#getnodeinfo) + - [getPeersInfo](#getpeersinfo) + - [getBlockSpecialEvents](#getblockspecialevents) + - [getBlockPendingUpdates](#getblockpendingupdates) + - [getBlockFinalizationSummary](#getblockfinalizationsummary) # ConcordiumNodeClient @@ -61,33 +62,14 @@ The ConcordiumNodeClient defines the interface to be used to send and receive da a concordium-node. ## Creating a client -Connection to a node can be done using either an insecure connection or a TLS connection. If the node that you are trying to connect to supports TLS, you can create a TLS connection in the following way: - -```js -import { credentials, Metadata } from "@grpc/grpc-js"; -import { ConcordiumNodeClient } from "@concordium/node-sdk"; - -const metadata = new Metadata(); -metadata.add("authentication", "rpcadmin"); - -const client = new ConcordiumNodeClient( - "127.0.0.1", // ip address - 10000, // port - credentials.createSsl(), - metadata, - 15000 // timeout in ms -); -``` - -The access is controlled by the credentials and the metadata. If the node does not support TLS an insecure connection can be established using `credentials.createInsecure()` instead of `credentials.createSsl()`. - -Note that the web-sdk and node-sdk each exposes a helper function `createConcordiumClient` that creates a client using the appropriate transport (gRPC-web for web and regular gRPC for nodeJS). +The client requires an appropriate transport. However the web-sdk and node-sdk each exposes a helper function `createConcordiumClient` that creates a client using the appropriate transport (gRPC-web for web and regular gRPC for nodeJS). +Please refer the the [node-sdk](../packages/nodejs/README.md#concordiumnodeclient) or [web-sdk's](../packages/web/README.md#concordiumnodeclient) README's to see how to use those functions. ## Send Account Transaction The following example demonstrates how to send any account transaction. -See the Constructing transactions section for the [common package](./#constructing-transactions) for how to create an account transaction. -See the signing a transaction section for the [common package](./#sign-an-account-transaction) for how to sign an account transaction. +See the Constructing transactions section for the [common package](../packages/common/README.md#constructing-transactions) for how to create an account transaction. +See the signing a transaction section for the [common package](../packages/common/README.md#sign-an-account-transaction) for how to sign an account transaction. ```js diff --git a/docs/grpc-v1.md b/docs/grpc-v1.md index 7773eb0bd..372333fc6 100644 --- a/docs/grpc-v1.md +++ b/docs/grpc-v1.md @@ -2,32 +2,32 @@ > :warning: **This explains behaviour of the deprecated v1 concordium client**: check out [the documentation the v2 client](./gRPC) -- [ConcordiumNodeClient](#concordiumnodeclient) - - [Creating a client](#creating-a-client) - - [Send Account Transaction](#send-account-transaction) - - [Create a new account](#create-a-new-account) - - [Construct IdentityInput for creating credentials](#construct-identityinput-for-creating-credentials) - - [Construct from user-cli output:](#construct-from-user-cli-output) - - [Construct from mobile wallet export:](#construct-from-mobile-wallet-export) - - [getAccountInfo](#getaccountinfo) - - [getNextAccountNonce](#getnextaccountnonce) - - [getTransactionStatus](#gettransactionstatus) - - [getBlockSummary](#getblocksummary) - - [getBlockInfo](#getblockinfo) - - [getBlocksAtHeight](#getblocksatheight) - - [getConsensusStatus](#getconsensusstatus) - - [getCryptographicParameters](#getcryptographicparameters) - - [getIdentityProviders](#getidentityproviders) - - [getAnonymityRevokers](#getanonymityrevokers) - - [getPeerList](#getpeerlist) - - [getBakerList](#getbakerlist) - - [getPoolStatus](#getpoolstatus) - - [getRewardStatus](#getrewardstatus) - - [Check block for transfers with memo](#check-block-for-transfers-with-memo) - - [getInstances](#getinstances) - - [getInstanceInfo](#getinstanceinfo) - - [invokeContract](#invokecontract) - - [getModuleSource](#getModuleSource) +**Table of Contents** +- [Creating a client](#creating-a-client) +- [Send Account Transaction](#send-account-transaction) +- [Create a new account](#create-a-new-account) +- [Construct IdentityInput for creating credentials](#construct-identityinput-for-creating-credentials) + - [Construct from user-cli output](#construct-from-user-cli-output) + - [Construct from mobile wallet export](#construct-from-mobile-wallet-export) +- [getAccountInfo](#getaccountinfo) +- [getNextAccountNonce](#getnextaccountnonce) +- [getTransactionStatus](#gettransactionstatus) +- [getBlockSummary](#getblocksummary) +- [getBlockInfo](#getblockinfo) +- [getBlocksAtHeight](#getblocksatheight) +- [getConsensusStatus](#getconsensusstatus) +- [getCryptographicParameters](#getcryptographicparameters) +- [getIdentityProviders](#getidentityproviders) +- [getAnonymityRevokers](#getanonymityrevokers) +- [getPeerList](#getpeerlist) +- [getBakerList](#getbakerlist) +- [getPoolStatus](#getpoolstatus) +- [getRewardStatus](#getrewardstatus) +- [Check block for transfers with memo](#check-block-for-transfers-with-memo) +- [getInstances](#getinstances) +- [getInstanceInfo](#getinstanceinfo) +- [invokeContract](#invokecontract) +- [getModuleSource](#getmodulesource) The ConcordiumNodeClient defines the interface to be used to send and receive data from a concordium-node. diff --git a/packages/common/CHANGELOG.md b/packages/common/CHANGELOG.md index 7ad2915ed..3b4e14160 100644 --- a/packages/common/CHANGELOG.md +++ b/packages/common/CHANGELOG.md @@ -25,6 +25,11 @@ report an error when called with invalid data, such as a receive function with missing schema, or a schema that cannot be parsed. +### Deprecated + +- The JSON-RPC client has been deprecated in favor of the new gRPC v2 client. +- Various types and helper functions used by the JSON-RPC client (and the v1 gRPC client) have also been deprecated. + ## 6.2.0 2023-01-04 ### Added diff --git a/packages/common/README.md b/packages/common/README.md index 1a08f0748..8ad007255 100644 --- a/packages/common/README.md +++ b/packages/common/README.md @@ -9,6 +9,7 @@ This package is the shared library for the nodejs and web SDK's. - [Create a simple transfer with a memo](#create-a-simple-transfer-with-a-memo) - [Create a Register data transaction](#create-a-register-data-transaction) - [Create a configure delegation transaction](#create-a-configure-delegation-transaction) + - [Create a configure baker transaction](#create-a-configure-baker-transaction) - [Create a credential for an existing account](#create-a-credential-for-an-existing-account) - [Create an update credentials transaction](#create-an-update-credentials-transaction) - [Deploy module](#deploy-module) @@ -35,6 +36,7 @@ This package is the shared library for the nodejs and web SDK's. - [Non membership statement](#non-membership-statement) - [Verify Statement (verifyIdstatement)](#verify-statement-verifyidstatement) - [Prove Statement (getIdProof)](#prove-statement-getidproof) +- [ConcordiumNodeClient](#concordiumnodeclient) - [JSON-RPC client](#json-rpc-client) # Constructing transactions diff --git a/packages/common/src/JsonRpcClient.ts b/packages/common/src/JsonRpcClient.ts index 7e0a797be..b380f1cf3 100644 --- a/packages/common/src/JsonRpcClient.ts +++ b/packages/common/src/JsonRpcClient.ts @@ -44,6 +44,9 @@ function transformJsonResponse( return JSON.parse(jsonString, reviver); } +/** + * @deprecated This has been deprecated in favor of the {@link ConcordiumNodeClient} that uses version 2 of the concordium gRPC API + */ export class JsonRpcClient { provider: Provider; diff --git a/packages/common/src/providers/httpProvider.ts b/packages/common/src/providers/httpProvider.ts index 0dec4f2e8..7abb88b5c 100644 --- a/packages/common/src/providers/httpProvider.ts +++ b/packages/common/src/providers/httpProvider.ts @@ -3,6 +3,9 @@ import fetch from 'cross-fetch'; import JSONBig from 'json-bigint'; import { v4 as uuidv4 } from 'uuid'; +/** + * @deprecated This is only used by the JSON-RPC client, which has been deprecated + */ export class HttpProvider implements Provider { request: JsonRpcRequest; cookie?: string; diff --git a/packages/common/src/providers/provider.ts b/packages/common/src/providers/provider.ts index e131d2fb5..67cb1e2b4 100644 --- a/packages/common/src/providers/provider.ts +++ b/packages/common/src/providers/provider.ts @@ -6,6 +6,9 @@ interface JsonRpcResponseBase { id: string | null; } +/** + * @deprecated This is only used by the JSON-RPC client, which has been deprecated + */ export interface JsonRpcResponseError extends JsonRpcResponseBase { error: { code: number; @@ -15,15 +18,24 @@ export interface JsonRpcResponseError extends JsonRpcResponseBase { result?: never; } +/** + * @deprecated This is only used by the JSON-RPC client, which has been deprecated + */ export interface JsonRpcResponseSuccess extends JsonRpcResponseBase { error?: never; result: Result; } +/** + * @deprecated This is only used by the JSON-RPC client, which has been deprecated + */ export type JsonRpcResponse = | JsonRpcResponseError | JsonRpcResponseSuccess; +/** + * @deprecated This is only used by the JSON-RPC client, which has been deprecated + */ export type JsonRpcRequest = ( ...args: | ['getNextAccountNonce', { address: string }] @@ -53,6 +65,9 @@ export type JsonRpcRequest = ( ] ) => Promise; +/** + * @deprecated This is only used by the JSON-RPC client, which has been deprecated + */ export default interface Provider { request: JsonRpcRequest; } diff --git a/packages/common/src/types.ts b/packages/common/src/types.ts index 40ff4a2be..e15d846fd 100644 --- a/packages/common/src/types.ts +++ b/packages/common/src/types.ts @@ -172,26 +172,41 @@ export interface BaseTransactionSummary { index: bigint; } +/** + * @deprecated This is type for describing return types from the V1 gRPC client, which has been deprecated + */ interface GenericTransactionSummary extends BaseTransactionSummary { type: GenericTransactionSummaryType; result: EventResult; } +/** + * @deprecated This is type for describing return types from the V1 gRPC client, which has been deprecated + */ interface TransferWithMemoEventResult { outcome: 'success'; events: [TransferredEvent, MemoEvent]; } +/** + * @deprecated This is type for describing return types from the V1 gRPC client, which has been deprecated + */ export interface TransferWithMemoTransactionSummary extends BaseTransactionSummary { type: TransferWithMemoSummaryType; result: TransferWithMemoEventResult; } +/** + * @deprecated This is helper intented for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export type TransactionSummary = | GenericTransactionSummary | TransferWithMemoTransactionSummary; +/** + * @deprecated This is helper for type describing return types from the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export function instanceOfTransferWithMemoTransactionSummary( object: TransactionSummary ): object is TransferWithMemoTransactionSummary { @@ -200,17 +215,26 @@ export function instanceOfTransferWithMemoTransactionSummary( ); } +/** + * @deprecated This is type describing return types from the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export interface TransactionStatus { status: TransactionStatusEnum; outcomes?: Record; } +/** + * @deprecated This is type describing return types from the V1 gRPC client, which has been deprecated + */ export interface PartyInfo { bakerId: bigint; weight: bigint; signed: boolean; } +/** + * @deprecated This is type describing return types from the V1 gRPC client, which has been deprecated + */ export interface FinalizationData { finalizationIndex: bigint; finalizationDelay: bigint; @@ -475,6 +499,7 @@ interface UpdatesCommon { /** * Used from protocol version 1-3 + * @deprecated This is type describing return types from the JSON-RPC client and the V1 gRPC client, both of which have been deprecated */ export interface UpdatesV0 extends UpdatesCommon { chainParameters: ChainParametersV0; @@ -484,6 +509,7 @@ export interface UpdatesV0 extends UpdatesCommon { /** * Used from protocol version 4 + * @deprecated This is type describing return types from the JSON-RPC client and the V1 gRPC client, both of which have been deprecated */ export interface UpdatesV1 extends UpdatesCommon { chainParameters: ChainParametersV1; @@ -491,8 +517,14 @@ export interface UpdatesV1 extends UpdatesCommon { keys: KeysV1; } +/** + * @deprecated This is type describing return types from the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export type Updates = UpdatesV0 | UpdatesV1; +/** + * @deprecated This is type describing return types from the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ interface BlockSummaryCommon { protocolVersion?: bigint; finalizationData: FinalizationData; @@ -501,6 +533,7 @@ interface BlockSummaryCommon { /** * Used from protocol version 1-3 + * @deprecated This is type describing return types from the JSON-RPC client and the V1 gRPC client, both of which have been deprecated */ export interface BlockSummaryV0 extends BlockSummaryCommon { updates: UpdatesV0; @@ -508,12 +541,16 @@ export interface BlockSummaryV0 extends BlockSummaryCommon { /** * Used from protocol version 4 + * @deprecated This is type describing return types from the JSON-RPC client and the V1 gRPC client, both of which have been deprecated */ export interface BlockSummaryV1 extends BlockSummaryCommon { updates: UpdatesV1; protocolVersion: bigint; } +/** + * @deprecated This is type describing return types from the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export type BlockSummary = BlockSummaryV0 | BlockSummaryV1; interface RewardStatusCommon { @@ -1278,6 +1315,9 @@ export interface AccountTransaction { payload: AccountTransactionPayload; } +/** + * @deprecated This type was for serialization code, which has been moved to rust-bindings + */ export enum ParameterType { /** Nothing. */ Unit = 0, @@ -1410,6 +1450,7 @@ export interface ContractContext { /** * Format of invoker expected by the node for the invokeContract entrypoint. + * @deprecated This is type used by the JSON-RPC client and the V1 gRPC client, both of which have been deprecated */ export type Invoker = | { @@ -1428,6 +1469,7 @@ export type Invoker = /** * Takes an accountAddress or ContractAddress and transforms it into the specific format used for * InvokeContract's invoker parameter. + * @deprecated This is helper intented for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated */ export function buildInvoker( invoker?: AccountAddress | ContractAddress @@ -1466,6 +1508,9 @@ export interface InvokeContractFailedResult { reason: RejectReason; } +/** + * @deprecated This is type for describing return types for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export interface InvokeContractFailedResultV1 { tag: 'failure'; usedEnergy: bigint; @@ -1476,6 +1521,9 @@ export type InvokeContractResult = | InvokeContractSuccessResult | InvokeContractFailedResult; +/** + * @deprecated This is helper intented for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export type InvokeContractResultV1 = | InvokeContractSuccessResult | InvokeContractFailedResultV1; diff --git a/packages/common/src/types/rejectReason.ts b/packages/common/src/types/rejectReason.ts index b28dac017..c18f00415 100644 --- a/packages/common/src/types/rejectReason.ts +++ b/packages/common/src/types/rejectReason.ts @@ -155,6 +155,9 @@ export interface BakerIdRejectReason { contents: BakerId; } +/** + * @deprecated This is type for describing return types for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export interface NumberRejectReason { tag: BakerIdRejectReasonTag; contents: number; @@ -172,6 +175,9 @@ export interface InvalidReceiveMethod { }; } +/** + * @deprecated This is type for describing return types for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export interface InvalidReceiveMethodV1 { tag: RejectReasonTag.InvalidReceiveMethod; contents: [HexString, string]; // [moduleRef, receiveName] @@ -185,6 +191,9 @@ export interface InvalidInitMethod { }; } +/** + * @deprecated This is type for describing return types for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export interface InvalidInitMethodV1 { tag: RejectReasonTag.InvalidInitMethod; contents: [HexString, string]; // [moduleRef, initName] @@ -198,6 +207,9 @@ export interface AmountTooLarge { }; } +/** + * @deprecated This is type for describing return types for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export interface AmountTooLargeV1 { tag: RejectReasonTag.AmountTooLarge; contents: [Address, DigitString]; // [address, amount] @@ -232,6 +244,9 @@ export type RejectReason = | InvalidInitMethod | AmountTooLarge; +/** + * @deprecated This is type for describing return types for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated + */ export type RejectReasonV1 = | RejectReasonCommon | NumberRejectReason diff --git a/packages/common/src/util.ts b/packages/common/src/util.ts index f96aab674..b05d4cc65 100644 --- a/packages/common/src/util.ts +++ b/packages/common/src/util.ts @@ -53,6 +53,7 @@ export function stringToInt(jsonStruct: string, keys: string[]): string { * @param json the json to transform * @param bigIntPropertyKeys the keys in the json that must be converted to strings * @returns the transformed json where numbers have been replaced with strings + * @deprecated This is helper intented for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated */ export function intToStringTransformer( bigIntPropertyKeys: string[] @@ -65,6 +66,7 @@ export function intToStringTransformer( * @param datePropertyKeys the JSON keys that must be parsed as dates * @param bigIntPropertyKeys the JSON keys that must be parsed as big integers * @returns a reviver function that handles dates and big integers + * @deprecated This is helper intented for the JSON-RPC client and the V1 gRPC client, both of which have been deprecated */ export function buildJsonResponseReviver( datePropertyKeys: (keyof T)[], diff --git a/packages/nodejs/CHANGELOG.md b/packages/nodejs/CHANGELOG.md index 9d414524d..e7e6d11de 100644 --- a/packages/nodejs/CHANGELOG.md +++ b/packages/nodejs/CHANGELOG.md @@ -14,6 +14,10 @@ - The value of amount fields in the GRPCv1 client's invokeContract's events has been changed to bigint (instead of string) as the type specifies. +### Deprecated + +- The old gRPC client has been deprecated in favor of the new gRPC v2 client. + ## 6.1.0 2022-11-30 ### Changed diff --git a/packages/nodejs/README.md b/packages/nodejs/README.md index 35f43af58..81438f82d 100644 --- a/packages/nodejs/README.md +++ b/packages/nodejs/README.md @@ -24,8 +24,9 @@ It also requires credentials to be specified. These can be used for create eithe ```js import { credentials } from '@grpc/grpc-js/'; +import { createConcordiumClient } from '@concordium/node-sdk'; ... -return createConcordiumClientV2( +return createConcordiumClient( address, port, credentials.createSsl(), diff --git a/packages/nodejs/src/client.ts b/packages/nodejs/src/client.ts index ff37161c1..9256c5050 100644 --- a/packages/nodejs/src/client.ts +++ b/packages/nodejs/src/client.ts @@ -88,6 +88,7 @@ import { * @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; diff --git a/packages/nodejs/src/clientV2.ts b/packages/nodejs/src/clientV2.ts index 315c34bb5..61ac54701 100644 --- a/packages/nodejs/src/clientV2.ts +++ b/packages/nodejs/src/clientV2.ts @@ -9,7 +9,7 @@ import ConcordiumGRPCClient from '@concordium/common-sdk/lib/GRPCClient'; * @param credentials channel credentials for communicating with the node * @param options optional options for the grpc transport */ -export default function createConcordiumClient( +export function createConcordiumClient( address: string, port: number, credentials: ChannelCredentials, diff --git a/packages/nodejs/src/index.ts b/packages/nodejs/src/index.ts index 41c19ccb6..c5d3e9c18 100644 --- a/packages/nodejs/src/index.ts +++ b/packages/nodejs/src/index.ts @@ -1,8 +1,7 @@ import ConcordiumNodeClient from './client'; -import ConcordiumNodeClientV2 from './clientV2'; +export * from './clientV2'; export { ConcordiumNodeClient }; -export { ConcordiumNodeClientV2 }; export { decryptMobileWalletExport, EncryptedData } from './wallet/crypto'; export { MobileWalletExport } from './wallet/types'; export * from '@concordium/common-sdk'; diff --git a/packages/nodejs/src/types.ts b/packages/nodejs/src/types.ts deleted file mode 100644 index fdeb3f6e6..000000000 --- a/packages/nodejs/src/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { - AccountAddress, - CredentialRegistrationId, -} from '@concordium/common-sdk'; - -export type AccountIdentifierInput = - | AccountAddress - | CredentialRegistrationId - | bigint; diff --git a/packages/nodejs/src/util.ts b/packages/nodejs/src/util.ts index 3048594f3..562471977 100644 --- a/packages/nodejs/src/util.ts +++ b/packages/nodejs/src/util.ts @@ -2,12 +2,16 @@ import * as fs from 'fs'; import { Buffer } from 'buffer/'; import { BoolResponse, JsonResponse } from '../grpc/concordium_p2p_rpc_pb'; +/** + * @deprecated This is a helper function for the v1 gRPC client, which has been deprecated + */ export function intListToStringList(jsonStruct: string): string { return jsonStruct.replace(/(\-?[0-9]+)/g, '"$1"'); } /** - * Unwraps a serialized bool response to the corresponding boolean/ + * Unwraps a serialized bool response to the corresponding boolean. + * @deprecated This is a helper function for the v1 gRPC client, which has been deprecated */ export function unwrapBoolResponse(serializedResponse: Uint8Array): boolean { return BoolResponse.deserializeBinary(serializedResponse).getValue(); @@ -19,6 +23,7 @@ export function unwrapBoolResponse(serializedResponse: Uint8Array): boolean { * @param reviver JSON reviver function to change types while parsing * @param transformer a function to transform the JSON string prior to parsing the JSON * @returns the unwrapped, transformed and parsed JSON object + * @deprecated This is a helper function for the v1 gRPC client, which has been deprecated */ export function unwrapJsonResponse( serializedResponse: Uint8Array, diff --git a/packages/nodejs/test/testHelpers.ts b/packages/nodejs/test/testHelpers.ts index fe3235bf6..ff5d8a3c5 100644 --- a/packages/nodejs/test/testHelpers.ts +++ b/packages/nodejs/test/testHelpers.ts @@ -4,7 +4,7 @@ import ConcordiumNodeClient from '../src/client'; import { IdentityInput } from '@concordium/common-sdk'; import { decryptMobileWalletExport, EncryptedData } from '../src/wallet/crypto'; import { MobileWalletExport } from '../src/wallet/types'; -import createConcordiumClientV2 from '../src/clientV2'; +import { createConcordiumClient } from '../src/clientV2'; import ConcordiumNodeClientV2 from '@concordium/common-sdk/lib/GRPCClient'; export { getModuleBuffer } from '../src/util'; @@ -36,12 +36,9 @@ export function getNodeClientV2( address = 'node.testnet.concordium.com', port = 20000 ): ConcordiumNodeClientV2 { - return createConcordiumClientV2( - address, - port, - credentials.createInsecure(), - { timeout: 15000 } - ); + return createConcordiumClient(address, port, credentials.createInsecure(), { + timeout: 15000, + }); } export function isValidDate(date: Date): boolean { diff --git a/packages/web/CHANGELOG.md b/packages/web/CHANGELOG.md index a90cd0955..edfeab560 100644 --- a/packages/web/CHANGELOG.md +++ b/packages/web/CHANGELOG.md @@ -10,6 +10,10 @@ - Bumped @concordium/common-sdk to 6.3.0. (Adds the gRPC v2 client) +### Deprecated + +- The JSON-RPC client (from common-sdk) has been deprecated in favor of the new gRPC v2 client. + ## 3.2.0 2022-1-4 ### Changed diff --git a/packages/web/README.md b/packages/web/README.md index 944964d62..8b3b78091 100644 --- a/packages/web/README.md +++ b/packages/web/README.md @@ -7,9 +7,8 @@ Wrappers for interacting with the Concordium node, for the web environment. [Note that this package contains and exports the functions from the common-sdk, check the readme of that package for an overview of those](../common/README.md). **Table of Contents** +- [ConcordiumNodeClient](#concordiumnodeclient) - [JSON-RPC client](#json-rpc-client) - - [Creating a client](#creating-a-client) - - [API Entrypoints](#api-entrypoints) - [Creating buffers](#creating-buffers) - [Examples](#examples) - [SendTransaction.html](#sendtransactionhtml) @@ -17,6 +16,10 @@ Wrappers for interacting with the Concordium node, for the web environment. - [Alias.html](#aliashtml) - [GetTransactionStatus.html](#gettransactionstatushtml) - [GetNonce.html](#getnoncehtml) + - [InvokeContract.html](#invokecontracthtml) + - [GetCryptographicParameters.html](#getcryptographicparametershtml) + - [GetAccountInfo.html](#getaccountinfohtml) + - [GetModuleSource.html](#getmodulesourcehtml) - [Build](#build) - [Building for a release](#building-for-a-release) - [Publishing a release](#publishing-a-release) @@ -28,6 +31,7 @@ For an overview of the endpoints, [check here](../../docs/gRPC.md). To create a client, the function `createConcordiumClient` can be used. It requires the address and port of the concordium node. ```js +import { createConcordiumClient } from '@concordium/web-sdk'; ... return createConcordiumClient( address, @@ -38,10 +42,9 @@ return createConcordiumClient( The third argument is additional options. In the example above we sat the timeout for a call to the node to 15 seconds. The options allowed here are those allowed by the [grpcweb-transport](https://www.npmjs.com/package/@protobuf-ts/grpcweb-transport). - # JSON-RPC client > :warning: **The JSON-RPC client has been deprecated**: the gRPC client should be used instead to communicate directly with a node -> To migrate, the migration guide from the v1 client to the v2 client [can be found here](../../docs/grpc-migration.md), as the JSON-RPC's endpoints shares interface with the equivalents in the v1 gRPC cient +> To migrate, the migration guide from the v1 client to the v2 client [can be found here](../../docs/grpc-migration.md), as the JSON-RPC's endpoints shares interface with the equivalent endpoints in the v1 gRPC client The SDK also provides a JSON-RPC client, [check here for the documentation](../../docs/JSON-RPC.md). @@ -84,7 +87,6 @@ An example of getting the info of a given account using a JSON-RPC server. ## GetModuleSource.html An example of getting the source of a model on the chain using a JSON-RPC server. - # Build ## Building for a release