Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform agnostic sdk #278

Merged
merged 37 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5a9c634
Remove JSON-RPC
soerenbf Sep 26, 2023
8b09769
Remove grpc-v1 from nodejs sdk
soerenbf Sep 26, 2023
fbef3b0
Remove types associated only with v1 api
soerenbf Sep 26, 2023
25d3576
Explicitly state version of types versioned by node protocol version
soerenbf Sep 26, 2023
16767b6
update changelogs
soerenbf Sep 26, 2023
db50900
Cleanup
soerenbf Sep 27, 2023
819a4aa
Lint fix
soerenbf Sep 27, 2023
cf10c5c
Create grpc client from common with grpcweb transport
soerenbf Sep 27, 2023
a2006e5
Create subclasses for transport layers
soerenbf Sep 27, 2023
10c51da
Undo rename
soerenbf Sep 27, 2023
c1ddbf1
Add wallet functionality to common
soerenbf Sep 27, 2023
6f2cb62
Move nodejs specific client to subpath
soerenbf Sep 27, 2023
3108f81
Remove unused packages
soerenbf Sep 27, 2023
04adb0f
Fix example sdk imports
soerenbf Sep 27, 2023
548cc94
Ensure rust-bindings exposes target compatible with bundling for nodejs
soerenbf Sep 28, 2023
702243d
Expose esm web target
soerenbf Sep 28, 2023
2d562b6
Configure browser map
soerenbf Sep 28, 2023
f3ba044
Merge branch 'api-strict-types' into remove-grpc-v1
soerenbf Oct 2, 2023
efc4047
Fix failing tests
soerenbf Oct 2, 2023
906964e
Merge branch 'remove-grpc-v1' into platform-agnostic-sdk
soerenbf Oct 2, 2023
077c25a
Include tests depending on node connection (though not for CI)
soerenbf Oct 2, 2023
b9bd3b1
Merge branch 'api-strict-types' into remove-grpc-v1
soerenbf Oct 2, 2023
0beaf38
Merge branch 'remove-grpc-v1' into platform-agnostic-sdk
soerenbf Oct 2, 2023
8918814
Adapt documentation
soerenbf Oct 2, 2023
dbe2283
Fix documentation links
soerenbf Oct 2, 2023
041da00
Update readmes
soerenbf Oct 3, 2023
b0ef8cc
Fix changelog
soerenbf Oct 3, 2023
20f2074
Add entries in documentation per pub module
soerenbf Oct 3, 2023
efc675c
Fix failing tests
soerenbf Oct 3, 2023
db46bcd
Fix examples
soerenbf Oct 3, 2023
c4b4b77
Merge branch 'release/10' into platform-agnostic-sdk
soerenbf Oct 3, 2023
0c3a47e
Upgrade bs58check to get browser compatibility
soerenbf Oct 4, 2023
15cfbfa
Move nodejs crypto dependants to nodejs subpath
soerenbf Oct 4, 2023
353536a
Remove fetch type def
soerenbf Oct 4, 2023
6ba4ca6
Fix tests
soerenbf Oct 4, 2023
57017ce
Apply suggestions from code review
soerenbf Oct 4, 2023
23840a1
Clean up based on PR review
soerenbf Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 3 additions & 9 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ module.exports = {
tsconfigRootDir: __dirname,
project: [
'./packages/**/tsconfig.json',
'./packages/**/tsconfig.eslint.json',
'./tsconfig.eslint.json',
'./examples/tsconfig.eslint.json',
'./docs/**/tsconfig.json',
'**/tsconfig.eslint.json',
],
},
plugins: ['@typescript-eslint', 'import'],
Expand All @@ -33,12 +32,7 @@ module.exports = {
'import/no-unresolved': [
2,
{
ignore: [
'@concordium/rust-bindings',
'@concordium/common-sdk',
'@concordium/node-sdk',
'grpc-api',
],
ignore: ['@concordium/rust-bindings', 'grpc-api'],
},
],
'import/no-extraneous-dependencies': [
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ jobs:
uses: actions/cache@v3
with:
path: |
./packages/common/src/grpc-api
./packages/nodejs/src/grpc-api
./packages/sdk/src/grpc-api
key: ${{ runner.os }}-grpc-${{ hashFiles('deps/concordium-base/concordium-grpc-api') }}
restore-keys: ${{ runner.os }}-grpc

Expand All @@ -79,9 +78,8 @@ jobs:
with:
name: build-release
path: |
packages/common/lib
packages/nodejs/lib
packages/web/lib
packages/sdk/lib
packages/sdk/src
packages/rust-bindings/lib/**/index*
packages/*/package.json
packages/*/README.md
Expand All @@ -102,14 +100,6 @@ jobs:
with:
name: build-release

- name: Restore grpc
uses: actions/cache/restore@v3
with:
path: |
./packages/common/src/grpc-api
./packages/nodejs/src/grpc-api
key: ${{ runner.os }}-grpc

- name: Restore cached dependencies
uses: actions/cache/restore@v3
with:
Expand Down
45 changes: 10 additions & 35 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ name: Build, lint and typecheck examples
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main, release**]
branches: [ main, release** ]
pull_request:
branches: [main, release**]
branches: [ main, release** ]
# Don't run on draft PR's, see: https://github.com/orgs/community/discussions/25722#discussioncomment-3248917
types: [opened, synchronize, reopened, ready_for_review]
types: [ opened, synchronize, reopened, ready_for_review ]
# Allows us to run the workflow manually from the Actions tab
workflow_dispatch:


env:
DUMMY: 1 # For cache busting.
NODE_VERSION: 18.16.0
Expand Down Expand Up @@ -64,8 +65,7 @@ jobs:
uses: actions/cache@v3
with:
path: |
./packages/common/src/grpc-api
./packages/nodejs/src/grpc-api
./packages/sdk/src/grpc-api
key: ${{ runner.os }}-grpc-${{ hashFiles('deps/concordium-base/concordium-grpc-api') }}-${{ env.DUMMY }}
restore-keys: ${{ runner.os }}-grpc

Expand Down Expand Up @@ -109,9 +109,8 @@ jobs:
name: build-debug
path: |
./packages/rust-bindings/lib
./packages/common/lib
./packages/web/lib
./packages/nodejs/lib
./packages/sdk/lib
./packages/sdk/src
soerenbf marked this conversation as resolved.
Show resolved Hide resolved
./packages/ccd-js-gen/lib

typecheck-examples:
Expand Down Expand Up @@ -141,12 +140,12 @@ jobs:
- name: Typecheck examples
run: yarn workspace @concordium/examples typecheck

common-tests:
tests:
runs-on: ubuntu-22.04
needs: build
defaults:
run:
working-directory: packages/common
working-directory: packages/sdk
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -166,21 +165,13 @@ jobs:
./docs/node_modules
key: ${{ runner.os }}-yarn

- name: Restore grpc
uses: actions/cache/restore@v3
with:
path: |
./packages/common/src/grpc-api
./packages/nodejs/src/grpc-api
key: ${{ runner.os }}-grpc

- name: Get build-debug
uses: ./.github/actions/download-artifact
with:
name: build-debug

- name: Run Tests
run: yarn test
run: yarn test-ci

typedoc:
runs-on: ubuntu-22.04
Expand All @@ -201,14 +192,6 @@ jobs:
./docs/node_modules
key: ${{ runner.os }}-yarn

- name: Restore grpc
uses: actions/cache/restore@v3
with:
path: |
./packages/common/src/grpc-api
./packages/nodejs/src/grpc-api
key: ${{ runner.os }}-grpc

- name: Get build-debug
uses: ./.github/actions/download-artifact
with:
Expand Down Expand Up @@ -237,14 +220,6 @@ jobs:
./docs/node_modules
key: ${{ runner.os }}-yarn

- name: Restore grpc
uses: actions/cache/restore@v3
with:
path: |
./packages/common/src/grpc-api
./packages/nodejs/src/grpc-api
key: ${{ runner.os }}-grpc

- name: Get build-debug
uses: ./.github/actions/download-artifact
with:
Expand Down
10 changes: 5 additions & 5 deletions .markdown-linkcheck.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ignorePatterns": [
{
"pattern": "classes/Common_GRPC_Client.ConcordiumGRPCClient.html"
}
]
"ignorePatterns": [
{
"pattern": "classes/grpc.ConcordiumGRPCClient.html"
}
]
}
4 changes: 2 additions & 2 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ MD035:
style: "consistent"

# MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading
MD036:
MD036: false
# Punctuation characters
punctuation: ".,;:!?。,;:!?"
# punctuation: ".,;:!?。,;:!?"

# MD037/no-space-in-emphasis - Spaces inside emphasis markers
MD037: true
Expand Down
82 changes: 15 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@ Wrappers for interacting with the Concordium node.
- [Concordium SDK for Javascript](#concordium-sdk-for-javascript)
- [Documentation](#documentation)
- [Packages](#packages)
- [Nodejs package](#nodejs-package)
- [Web package](#web-package)
- [Common package](#common-package)
- [SDK package](#sdk-package)
- [Rust-bindings package](#rust-bindings-package)
- [Install/updating dependencies](#installupdating-dependencies)
- [MacOS arm64](#macos-arm64)
- [Build](#build)
- [Building for a release](#building-for-a-release)
- [Building for development](#building-for-development)
- [Making a new release](#making-a-new-release)
- [common](#common)
- [nodejs](#nodejs)
- [web](#web)
- [SDK](#sdk)
- [rust-bindings](#rust-bindings)
- [Test](#test)
<!--toc:end-->
Expand All @@ -37,27 +33,16 @@ for more information

Contains the different packages for the JS-SDKs.

### Nodejs package
### SDK package

The [Nodejs package](./packages/nodejs) contains the Nodejs SDK, particularly
the client that wraps the GRPC calls to the node, is located here.

### Web package

The [Web package](./packages/web) contains the Web SDK, which can used in
a web environment.

### Common package

The [common package](./packages/common) contains the shared library for the
Nodejs and Web SDK's. The GRPC-client, all serialization and most utility
functions are located in this package.
The [SDK](./packages/sdk) contains the actual SDK, which can used in
both a web and nodeJS environment.
soerenbf marked this conversation as resolved.
Show resolved Hide resolved

### Rust-bindings package

The [common package](./packages/common) contains bindings for Rust code,
which is used by the common package. This package is a utility package that
should not be used directly, only through the usage of the common package.
The [rust-bindings](./packages/rust-bindings) contains bindings for Rust code,
which is used by the SDK through WASM. This package is a utility package that
should not be used directly, only through the usage of the SDK.

## Install/updating dependencies

Expand Down Expand Up @@ -96,9 +81,6 @@ yarn build

This will build all the subprojects.

Note that you must have [wasm-pack](https://rustwasm.github.io/wasm-pack/)
installed to build the project.

### Building for development

To build the project quickly during development run
Expand All @@ -115,60 +97,26 @@ Note that this skips generating the grpc API and optimizing the wasm modules.
The following describes the requirements for creating a new release for
each of the packages contained in this repository.

### common
### SDK

- Bump the version in [package.json](./packages/common/package.json).
- Update the [CHANGELOG](./packages/common/CHANGELOG.md) describing the
- Bump the version in [package.json](./packages/sdk/package.json).
- Update the [CHANGELOG](./packages/sdk/CHANGELOG.md) describing the
changes made.
- Update the dependency to common in the [web](./packages/web/package.json)
and [nodejs](./packages/nodejs/package.json) packages.
- Update the CHANGELOG in the [web](./packages/web/CHANGELOG.md) and
[nodejs](./packages/nodejs/CHANGELOG.md) packages.
- Add a change entry: Bumped @concordium/common-sdk to x.y.z.
- Commit and tag the release.
- Tag should be `common/x.y.z`.
- Tag should be `sdk/x.y.z`.
- Run the deploy workflow.
- Under github actions, run the "deploy" workflow and download the
`build-release` artifact. Unpack this file and use it for the release.
- Publish the release to NPM.
- From the common package directory (packages/common) run `yarn npm publish`

### nodejs

- Bump the version in [package.json](./packages/nodejs/package.json).
- Update the [CHANGELOG](./packages/nodejs/CHANGELOG.md) describing the
changes made.
- Commit and tag the release.
- Tag should be `nodejs/x.y.z`.
- Build the release.
- Under github actions, run the "deploy" workflow and download the
`build-release` artifact. Unpack this file and use it for the release.
- Publish the release to NPM.
- From the nodejs package directory (packages/nodejs) run `yarn npm publish`

### web

- Bump the version in [package.json](./packages/web/package.json).
- Update the [CHANGELOG](./packages/web/CHANGELOG.md) describing the
changes made.
- Commit and tag the release.
- Tag should be `web/x.y.z`.
- Build the release.
- Under github actions, run the "deploy" workflow and download the
`build-release` artifact. Unpack this file and use it for the release.
- Publish the release to NPM.
- From the web package directory (packages/web) run `yarn npm publish`
- From the sdk package directory (packages/sdk) run `yarn npm publish`

### rust-bindings

- Bump the version in [package.json](./packages/rust-bindings/package.json).
- Update the [CHANGELOG](./packages/rust-bindings/CHANGELOG.md) describing
the changes made.
- Update the dependency to rust-bindings in the
[common](./packages/common/package.json) and
[web](./packages/web/package.json) packages.
- Update the CHANGELOG in the [common](./packages/common/CHANGELOG.md) and
[web](./packages/web/CHANGELOG.md) packages.
- Update the dependency to rust-bindings in the [sdk](./packages/sdk/package.json)
- Update the CHANGELOG in the [sdk](./packages/sdk/CHANGELOG.md)
- Add a change entry: Bumped @concordium/rust-bindings to x.y.z.
- Commit and tag the release.
- Tag should be `rust-bindings/x.y.z`.
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/cis2-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This document describes the helper class for working with CIS-2 contracts
## CIS2Contract

The CIS2Contract class wraps the
[ConcordiumGRPCClient](../classes/Common_GRPC_Client.ConcordiumGRPCClient.html),
[ConcordiumGRPCClient](../classes/grpc.ConcordiumGRPCClient.html),
defining an interface matching the [CIS-2
standard](https://proposals.concordium.software/CIS/cis-2.html).

Expand Down
15 changes: 7 additions & 8 deletions docs/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.ConcordiumGRPCClient.html)
[GRPC-Client](../classes/grpc.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 All @@ -11,26 +11,25 @@ utility functions}.
A good way to get started is to check out the {@page runnable-examples.md
runnable examples}.

To create a GRPC-Client in NodeJS-SDK:
To create a GRPC-Client for use with nodeJS:

```ts
import { credentials } from '@grpc/grpc-js/';
import { createConcordiumClient } from '@concordium/node-sdk';
import { ConcordiumGRPCNodeClient, credentials } from '@concordium/web-sdk/nodejs';
...
return createConcordiumClient(
return new ConcordiumGRPCNodeClient(
address,
port,
credentials.createSsl(),
{ timeout: 15000 }
);
```

To create a GRPC-Client in the Web-SDK:
To create a GRPC-Client for use in a browser (requires GRPC-web enabled on the node):

```ts
import { createConcordiumClient } from '@concordium/web-sdk';
import { ConcordiumGRPCWebClient } from '@concordium/web-sdk';
...
return createConcordiumClient(
return new ConcordiumGRPCWebClient(
address,
port,
{ timeout: 15000 }
Expand Down
4 changes: 3 additions & 1 deletion docs/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.ConcordiumGRPCClient.html)
check out [the documentation the v2 client](../../classes/grpc.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 Expand Up @@ -49,6 +49,8 @@ interface as the grpc v1 node client:

## GRPCv1-Client

_Only accessible prior to version 10_

The ConcordiumNodeClient defines the interface to be used to send and receive
data from a concordium-node.

Expand Down
Loading