Skip to content

Commit

Permalink
Merge branch 'release/8.0' into json-rpc-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenbf committed Jun 26, 2023
2 parents aecb048 + c622d3b commit b3a00ba
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .markdown-linkcheck.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ignorePatterns": [
{
"pattern": "classes/Common_GRPC_Client.ConcordiumNodeClient.html"
"pattern": "classes/Common_GRPC_Client.ConcordiumGRPCClient.html"
}
]
}
}
8 changes: 4 additions & 4 deletions packages/common/src/GRPCClient.ts
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/JsonRpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function transformJsonResponse<Result>(
}

/**
* @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;
Expand Down
12 changes: 6 additions & 6 deletions packages/common/src/cis0.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Buffer } from 'buffer/';
import { ContractAddress, HexString } from './types';
import ConcordiumNodeClient from './GRPCClient';
import { ConcordiumGRPCClient } from './GRPCClient';
import {
encodeWord16,
makeDeserializeListResponse,
Expand Down Expand Up @@ -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.
Expand All @@ -110,15 +110,15 @@ 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
): Promise<CIS0.SupportResult | undefined>;
/**
* 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.
Expand All @@ -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<CIS0.SupportResult[] | undefined>;
export async function cis0Supports(
grpcClient: ConcordiumNodeClient,
grpcClient: ConcordiumGRPCClient,
contractAddress: ContractAddress,
standardIds: CIS0.StandardIdentifier | CIS0.StandardIdentifier[],
blockHash?: HexString
Expand Down
10 changes: 5 additions & 5 deletions packages/common/src/cis2/CIS2Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
InvokeContractResult,
UpdateContractPayload,
} from '../types';
import ConcordiumNodeClient from '../GRPCClient';
import { ConcordiumGRPCClient } from '../GRPCClient';
import { AccountSigner, signTransaction } from '../signHelpers';
import {
serializeCIS2Transfers,
Expand Down Expand Up @@ -52,7 +52,7 @@ const getDefaultExpiryDate = (): Date => {
*/
class CIS2DryRun {
constructor(
private grpcClient: ConcordiumNodeClient,
private grpcClient: ConcordiumGRPCClient,
private contractAddress: ContractAddress,
private contractName: string
) {}
Expand Down Expand Up @@ -163,7 +163,7 @@ export class CIS2Contract {
private dryRunInstance: CIS2DryRun;

constructor(
private grpcClient: ConcordiumNodeClient,
private grpcClient: ConcordiumGRPCClient,
private contractAddress: ContractAddress,
private contractName: string
) {
Expand All @@ -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<CIS2Contract> {
const instanceInfo = await grpcClient.getInstanceInfo(contractAddress);
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/nodejs/src/clientV2.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 0 additions & 2 deletions packages/nodejs/test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ test.each([CHAIN_GENESIS_BLOCK, PV1_BLOCK, PV4_BLOCK, PV6_BLOCK])(
throw new Error('could not find block');
}

console.log(bs.protocolVersion);

// BlockSummary
expect(typeof bs.protocolVersion).toEqual('bigint');

Expand Down
5 changes: 3 additions & 2 deletions packages/nodejs/test/clientV2.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<v2.AccountInfo> {
const accountInfoRequest = {
Expand Down
5 changes: 2 additions & 3 deletions packages/nodejs/test/testHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { decryptMobileWalletExport, EncryptedData } from '../src/wallet/crypto';
import { MobileWalletExport } from '../src/wallet/types';
import { createConcordiumClient } from '../src/clientV2';
import ConcordiumNodeClient from '../src/client';
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`
Expand Down Expand Up @@ -40,7 +39,7 @@ export function getNodeClient(
export function getNodeClientV2(
address = 'node.testnet.concordium.com',
port = 20000
): ConcordiumNodeClientV2 {
): ConcordiumGRPCClient {
return createConcordiumClient(address, port, credentials.createInsecure(), {
timeout: 15000,
});
Expand All @@ -54,7 +53,7 @@ export function getNodeClientV2(
export function getNodeClientWeb(
address = 'http://node.testnet.concordium.com',
port = 20000
): ConcordiumNodeClientV2 {
): ConcordiumGRPCClient {
const transport = new GrpcWebFetchTransport({
baseUrl: `${address}:${port}`,
timeout: 15000,
Expand Down
5 changes: 2 additions & 3 deletions packages/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for more information

<!--toc:start-->
- [concordium-web-sdk](#concordium-web-sdk)
- [ConcordiumNodeClient](#concordiumnodeclient)
- [ConcordiumGRPCClient](#concordiumgrpcclient)
- [JSON-RPC client](#json-rpc-client)
- [Creating buffers](#creating-buffers)
- [Examples](#examples)
Expand All @@ -29,8 +29,7 @@ for more information
- [SendCIS2UpdateOperator.html](#sendcis2updateoperatorhtml)
<!--toc:end-->

## ConcordiumNodeClient

## ConcordiumGRPCClient
The SDK provides a gRPC client, which can interact with the [Concordium
Node](https://github.com/Concordium/concordium-node) using gRPC-web.

Expand Down
6 changes: 3 additions & 3 deletions pages/cis2-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pages/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pages/misc-pages/grpc-v1.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pages/utility-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b3a00ba

Please sign in to comment.