Skip to content

Commit

Permalink
Merge pull request #146 from Concordium/deprecate-and-cleanup
Browse files Browse the repository at this point in the history
Deprecate and cleanup
  • Loading branch information
shjortConcordium authored Feb 24, 2023
2 parents e8b0c0d + 5bc5c3e commit ee5de69
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 126 deletions.
130 changes: 56 additions & 74 deletions docs/gRPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,74 @@

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

The ConcordiumNodeClient defines the interface to be used to send and receive data from
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

Expand Down
52 changes: 26 additions & 26 deletions docs/grpc-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/JsonRpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ function transformJsonResponse<Result>(
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;

Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/providers/httpProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions packages/common/src/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Result> extends JsonRpcResponseBase {
error?: never;
result: Result;
}

/**
* @deprecated This is only used by the JSON-RPC client, which has been deprecated
*/
export type JsonRpcResponse<Result> =
| JsonRpcResponseError
| JsonRpcResponseSuccess<Result>;

/**
* @deprecated This is only used by the JSON-RPC client, which has been deprecated
*/
export type JsonRpcRequest = (
...args:
| ['getNextAccountNonce', { address: string }]
Expand Down Expand Up @@ -53,6 +65,9 @@ export type JsonRpcRequest = (
]
) => Promise<string>;

/**
* @deprecated This is only used by the JSON-RPC client, which has been deprecated
*/
export default interface Provider {
request: JsonRpcRequest;
}
Loading

0 comments on commit ee5de69

Please sign in to comment.