diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 1c89d0f81..a098a85a6 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -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'], @@ -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': [ diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index a03646fa6..a901b6e32 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -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 @@ -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 @@ -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: diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index c253ba796..56b34f3e4 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -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 @@ -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 @@ -107,11 +107,11 @@ jobs: uses: ./.github/actions/upload-artifact with: name: build-debug + # sdk/src is needed here because of sdk/src/grpc-api path: | ./packages/rust-bindings/lib - ./packages/common/lib - ./packages/web/lib - ./packages/nodejs/lib + ./packages/sdk/lib + ./packages/sdk/src ./packages/ccd-js-gen/lib typecheck-examples: @@ -141,12 +141,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 @@ -166,21 +166,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 @@ -201,14 +193,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: @@ -237,14 +221,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: diff --git a/.markdown-linkcheck.json b/.markdown-linkcheck.json index 84e981113..72dc9011a 100644 --- a/.markdown-linkcheck.json +++ b/.markdown-linkcheck.json @@ -1,7 +1,7 @@ { - "ignorePatterns": [ - { - "pattern": "classes/Common_GRPC_Client.ConcordiumGRPCClient.html" - } - ] + "ignorePatterns": [ + { + "pattern": "classes/grpc.ConcordiumGRPCClient.html" + } + ] } diff --git a/.markdownlint.yaml b/.markdownlint.yaml index 3f71faf0f..3b4c96e82 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -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 diff --git a/README.md b/README.md index 83fb004e4..4dff2d4f3 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,7 @@ 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) @@ -20,9 +18,7 @@ Wrappers for interacting with the Concordium node. - [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) @@ -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. ### 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 @@ -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 @@ -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`. diff --git a/docs/pages/cis2-contracts.md b/docs/pages/cis2-contracts.md index b05a0e713..06d830406 100644 --- a/docs/pages/cis2-contracts.md +++ b/docs/pages/cis2-contracts.md @@ -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). diff --git a/docs/pages/documentation.md b/docs/pages/documentation.md index 3b08cb349..9794bd64c 100644 --- a/docs/pages/documentation.md +++ b/docs/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.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 @@ -11,13 +11,12 @@ 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(), @@ -25,12 +24,12 @@ To create a GRPC-Client in NodeJS-SDK: ); ``` -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 } diff --git a/docs/pages/misc-pages/grpc-v1.md b/docs/pages/misc-pages/grpc-v1.md index fde400114..cf930c01f 100644 --- a/docs/pages/misc-pages/grpc-v1.md +++ b/docs/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.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) @@ -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. diff --git a/docs/pages/misc-pages/upgrade-guide.md b/docs/pages/misc-pages/upgrade-guide.md index 1d64a0658..ad4adddf9 100644 --- a/docs/pages/misc-pages/upgrade-guide.md +++ b/docs/pages/misc-pages/upgrade-guide.md @@ -1,6 +1,4 @@ -## Common SDK version 10 (Web 7) (Node 10) - -### Common +## SDK version 10 Several types have been replaced with a module containing the type itself together with functions for constructing and converting the type: @@ -48,12 +46,9 @@ The API now uses dedicated types instead of language primitives: - Uses `Duration` instead of a bigint. Can be constructed using `Duration.fromMillis()`. -### Web - The `@concordium/web-sdk` now requires bundlers to respect `exports` field of `package.json` of a module. This is due to relying on entrypoints declared in -the `exports` field of `@concordium/common-sdk` -and correspondingly `@concordium/rust-bindings` to make it possible to select +the `exports` field of `@concordium/rust-bindings` to make it possible to select only parts of the SDK to include in your application. Furthermore, the SDK is now published as an ES module, making it possible to eliminate dead code. @@ -96,12 +91,9 @@ with web3-id proofs. ### NodeJS -The `@concordium/node-sdk` module is no longer compatible with +The `@concordium/web-sdk` module is not compatible with node versions <16 and is published only as an ES module. -This is due to relying on entrypoints declared in the `exports` field -of `@concordium/common-sdk` and correspondingly `@concordium/rust-bindings` -to make it possible to select only parts of the SDK to include in your -application. +This, in turn, requires users to also run applications as ES modules. The easiest way to run your node application as an ES module, is by setting the `type` field of `package.json` to be set to `"module"`: @@ -121,36 +113,6 @@ For **TypeScript** users, at least typescript version 4.7 is required along with the setting `compilerOptions.moduleResultion` to `"node16"` or `"nodenext"` to match the resolution strategy of node version 16 and later. -The following entrypoints are made available for consumers of -`@concordium/node-sdk`: - -- `@concordium/node-sdk` exposes the full API of the SDK. -- `@concordium/node-sdk/cis0` entrypoint exposes functionality for working -with contracts adhering to the -[CIS-0](https://proposals.concordium.software/CIS/cis-0.html) standard. -- `@concordium/node-sdk/cis2` entrypoint exposes functionality for working -with contracts adhering to the -[CIS-2](https://proposals.concordium.software/CIS/cis-2.html) standard. -- `@concordium/node-sdk/cis4` entrypoint exposes functionality for working -with contracts adhering to the -[CIS-4](https://proposals.concordium.software/CIS/cis-4.html) standard. -- `@concordium/node-sdk/client` entrypoint exposes the **(deprecated)** -grpc client for interacting with a nodes GPRCv1 interface. -- `@concordium/node-sdk/grpc` entrypoint exposes the grpc client for -interacting with a nodes GRPCv2 interface. -- `@concordium/node-sdk/id` entrypoint exposes functionality for working -with ID proofs. -- `@concordium/node-sdk/schema` entrypoint exposes functionality for working -with smart contract schemas, i.e.(de)serializing types using a smart contract schema. - - This uses the wasm entrypoint at `@concordium/rust-bindings/dapp`. -- `@concordium/node-sdk/types` entrypoint exposes functionality for working -with concordium domain types. -- `@concordium/node-sdk/wasm` entrypoint exposes a variety of functionality for -working with concordium domain types, which requires WASM. - - This uses the wasm entrypoint at `@concorodium/rust-bindings/wallet`. -- `@concordium/node-sdk/web3-id` entrypoint exposes functionality for working -with web3-id proofs. - ## Common SDK version 5 to 6 (Web 2->3) (Node 5->6) Some classes and types have been renamed or changed, and should be update if used. diff --git a/docs/pages/utility-functions.md b/docs/pages/utility-functions.md index a85303da6..3939d190f 100644 --- a/docs/pages/utility-functions.md +++ b/docs/pages/utility-functions.md @@ -233,7 +233,7 @@ 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 [`ConcordiumGRPCClient`](../classes/Common_GRPC_Client.ConcordiumGRPCClient.html). +This requires a [`ConcordiumGRPCClient`](../classes/grpc.ConcordiumGRPCClient.html). ```ts const client = ...; // `ConcordiumGRPCClient` diff --git a/docs/tsconfig.json b/docs/tsconfig.json index 3989e2a62..d92fe122c 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -5,7 +5,8 @@ "moduleResolution": "NodeNext" }, "include": [ - "../packages/**/*" + "../packages/**/*", + "./typedoc.config.cjs" ], "exclude": [ "../packages/ccd-js-gen/**/*" diff --git a/docs/typedoc.config.cjs b/docs/typedoc.config.cjs new file mode 100644 index 000000000..a7fd163ad --- /dev/null +++ b/docs/typedoc.config.cjs @@ -0,0 +1,76 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const path = require('node:path'); + +module.exports = { + name: 'Concordium JS-SDK', + out: path.resolve(__dirname, '../typedoc'), + entryPointStrategy: 'expand', + entryPoints: [path.resolve(__dirname, '../packages/sdk/src/pub')], + tsconfig: path.resolve(__dirname, '../tsconfig.json'), + readme: path.resolve(__dirname, './pages/documentation.md'), + plugin: [ + '@knodes/typedoc-plugin-code-blocks', + '@knodes/typedoc-plugin-pages', + 'typedoc-plugin-merge-modules', + ], + mergeModulesMergeMode: 'module', + pluginCodeBlocks: { + source: path.resolve(__dirname, '../examples'), + }, + pluginPages: { + source: path.resolve(__dirname, './pages'), + pages: [ + { + name: 'Concordium JS-SDK', + children: [ + { + name: 'CIS2-Contracts', + source: 'cis2-contracts.md', + }, + { + name: 'Identity Proofs', + source: 'identity-proofs.md', + }, + { + name: 'Runnable Examples', + source: 'runnable-examples.md', + }, + { + name: 'Transactions', + source: 'transactions.md', + }, + { + name: 'Utility Functions', + source: 'utility-functions.md', + }, + { + name: 'Miscellaneous Pages', + childrenDir: 'misc-pages', + children: [ + { + name: 'Account Creation', + source: 'account-creation.md', + }, + { + name: 'Optimizing bundled applications', + source: 'bundler-optimizations.md', + }, + { + name: 'GRPCv1 to GRPCv2 Migration Guide', + source: 'grpc-migration.md', + }, + { + name: 'Old GRPC-Client', + source: 'grpc-v1.md', + }, + { + name: 'Upgrade Guide', + source: 'upgrade-guide.md', + }, + ], + }, + ], + }, + ], + }, +}; diff --git a/docs/typedoc.json b/docs/typedoc.json deleted file mode 100644 index 14bee7d89..000000000 --- a/docs/typedoc.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "Concordium JS-SDKs", - "out": "../typedoc", - "entryPointStrategy": "expand", - "entryPoints": [ - "../packages/web/src/index.ts", - "../packages/nodejs/src/index.ts", - "../packages/common/src/GRPCClient.ts", - "../packages/common/src/types.ts" - ], - "tsconfig": "../tsconfig.json", - "readme": "./pages/documentation.md", - "plugin": [ - "@knodes/typedoc-plugin-code-blocks", - "@knodes/typedoc-plugin-pages", - "typedoc-plugin-merge-modules" - ], - "mergeModulesMergeMode": "module", - "pluginPages": { - "source": "docs/pages", - "pages": [ - { - "name": "Concordium JS-SDKs", - "children": [ - { - "name": "CIS2-Contracts", - "source": "cis2-contracts.md" - }, - { - "name": "Identity Proofs", - "source": "identity-proofs.md" - }, - { - "name": "Runnable Examples", - "source": "runnable-examples.md" - }, - { - "name": "Transactions", - "source": "transactions.md" - }, - { - "name": "Utility Functions", - "source": "utility-functions.md" - }, - { - "name": "Miscellaneous Pages", - "childrenDir": "misc-pages", - "children": [ - { - "name": "Account Creation", - "source": "account-creation.md" - }, - { - "name": "Optimizing bundled applications", - "source": "bundler-optimizations.md" - }, - { - "name": "GRPCv1 to GRPCv2 Migration Guide", - "source": "grpc-migration.md" - }, - { - "name": "Old GRPC-Client", - "source": "grpc-v1.md" - }, - { - "name": "Upgrade Guide", - "source": "upgrade-guide.md" - }, - ] - }, - ] - }, - ] - } -} diff --git a/examples/ccd-js-gen/wCCD/client-tokenMetadata.ts b/examples/ccd-js-gen/wCCD/client-tokenMetadata.ts index 3569afe33..50d3ffb59 100644 --- a/examples/ccd-js-gen/wCCD/client-tokenMetadata.ts +++ b/examples/ccd-js-gen/wCCD/client-tokenMetadata.ts @@ -1,5 +1,6 @@ import { credentials } from '@grpc/grpc-js'; -import * as SDK from '@concordium/node-sdk'; +import * as SDK from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import meow from 'meow'; import { parseEndpoint } from '../../shared/util.js'; @@ -45,7 +46,7 @@ const cli = meow( ); const [address, port, scheme] = parseEndpoint(cli.flags.endpoint); -const grpcClient = SDK.createConcordiumClient( +const grpcClient = new ConcordiumGRPCNodeClient( address, Number(port), scheme === 'https' ? credentials.createSsl() : credentials.createInsecure() diff --git a/examples/ccd-js-gen/wCCD/generate.ts b/examples/ccd-js-gen/wCCD/generate.ts index 10828eb9e..e00ff31f9 100644 --- a/examples/ccd-js-gen/wCCD/generate.ts +++ b/examples/ccd-js-gen/wCCD/generate.ts @@ -1,5 +1,6 @@ import { credentials } from '@grpc/grpc-js'; -import * as SDK from '@concordium/node-sdk'; +import * as SDK from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import * as Gen from '@concordium/ccd-js-gen'; import * as Path from 'node:path'; import * as Url from 'node:url'; @@ -30,7 +31,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const grpcClient = SDK.createConcordiumClient( +const grpcClient = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis2/balanceOf.ts b/examples/cis2/balanceOf.ts index d06b2aba3..ab41b19db 100644 --- a/examples/cis2/balanceOf.ts +++ b/examples/cis2/balanceOf.ts @@ -1,8 +1,5 @@ -import { - createConcordiumClient, - CIS2Contract, - ContractAddress, -} from '@concordium/node-sdk'; +import { CIS2Contract, ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; import { parseAddress, parseEndpoint } from '../shared/util.js'; @@ -54,7 +51,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis2/dryRun.transfer.ts b/examples/cis2/dryRun.transfer.ts index b69b6b099..eac4b31ad 100644 --- a/examples/cis2/dryRun.transfer.ts +++ b/examples/cis2/dryRun.transfer.ts @@ -1,11 +1,11 @@ import { - createConcordiumClient, CIS2, CIS2Contract, ContractAddress, AccountAddress, EntrypointName, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; import { parseAddress, parseEndpoint } from '../shared/util.js'; @@ -70,7 +70,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis2/dryRun.updateOperator.ts b/examples/cis2/dryRun.updateOperator.ts index 3e07ed8ea..54412ae06 100644 --- a/examples/cis2/dryRun.updateOperator.ts +++ b/examples/cis2/dryRun.updateOperator.ts @@ -1,8 +1,5 @@ -import { - createConcordiumClient, - CIS2Contract, - ContractAddress, -} from '@concordium/node-sdk'; +import { CIS2Contract, ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; import { parseAddress, parseEndpoint } from '../shared/util.js'; @@ -54,7 +51,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis2/operatorOf.ts b/examples/cis2/operatorOf.ts index fd54def1d..186f1fa6d 100644 --- a/examples/cis2/operatorOf.ts +++ b/examples/cis2/operatorOf.ts @@ -1,8 +1,5 @@ -import { - createConcordiumClient, - CIS2Contract, - ContractAddress, -} from '@concordium/node-sdk'; +import { CIS2Contract, ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; import { parseAddress, parseEndpoint } from '../shared/util.js'; @@ -54,7 +51,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis2/tokenMetadata.ts b/examples/cis2/tokenMetadata.ts index 82d48b6c0..dbfad7221 100644 --- a/examples/cis2/tokenMetadata.ts +++ b/examples/cis2/tokenMetadata.ts @@ -1,10 +1,8 @@ -import { - createConcordiumClient, - CIS2Contract, - ContractAddress, -} from '@concordium/node-sdk'; +import { CIS2Contract, ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; +import fetch from 'node-fetch'; const cli = meow( ` @@ -47,7 +45,7 @@ const cli = meow( ); const [address, port] = cli.flags.endpoint.split(':'); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis2/transfer.ts b/examples/cis2/transfer.ts index 068d8caee..b78ee1a53 100644 --- a/examples/cis2/transfer.ts +++ b/examples/cis2/transfer.ts @@ -1,5 +1,4 @@ import { - createConcordiumClient, CIS2, CIS2Contract, buildBasicAccountSigner, @@ -7,7 +6,8 @@ import { AccountAddress, EntrypointName, Energy, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; import { parseAddress, parseEndpoint } from '../shared/util.js'; @@ -78,7 +78,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis2/updateOperator.ts b/examples/cis2/updateOperator.ts index aa205d774..e599b5b31 100644 --- a/examples/cis2/updateOperator.ts +++ b/examples/cis2/updateOperator.ts @@ -1,11 +1,11 @@ import { - createConcordiumClient, CIS2Contract, buildBasicAccountSigner, ContractAddress, AccountAddress, Energy, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; import { parseAddress, parseEndpoint } from '../shared/util.js'; @@ -67,7 +67,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/credentialEntry.ts b/examples/cis4/credentialEntry.ts index a81a2f939..8378ccea4 100644 --- a/examples/cis4/credentialEntry.ts +++ b/examples/cis4/credentialEntry.ts @@ -1,11 +1,8 @@ import meow from 'meow'; import { credentials } from '@grpc/grpc-js'; -import { - CIS4Contract, - ContractAddress, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { CIS4Contract, ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -49,7 +46,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/credentialStatus.ts b/examples/cis4/credentialStatus.ts index d0936988b..c159dbef5 100644 --- a/examples/cis4/credentialStatus.ts +++ b/examples/cis4/credentialStatus.ts @@ -1,12 +1,8 @@ import meow from 'meow'; import { credentials } from '@grpc/grpc-js'; -import { - CIS4, - CIS4Contract, - ContractAddress, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { CIS4, CIS4Contract, ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -50,7 +46,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/issuer.ts b/examples/cis4/issuer.ts index b5665cf55..097faa4b5 100644 --- a/examples/cis4/issuer.ts +++ b/examples/cis4/issuer.ts @@ -1,11 +1,8 @@ import meow from 'meow'; import { credentials } from '@grpc/grpc-js'; -import { - CIS4Contract, - ContractAddress, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { CIS4Contract, ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -43,7 +40,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/registerCredential.ts b/examples/cis4/registerCredential.ts index 8e3109934..cd293d574 100644 --- a/examples/cis4/registerCredential.ts +++ b/examples/cis4/registerCredential.ts @@ -10,12 +10,12 @@ import { CIS4, CIS4Contract, ContractAddress, - createConcordiumClient, Energy, HexString, parseWallet, Timestamp, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -82,7 +82,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/registerRevocationKeys.ts b/examples/cis4/registerRevocationKeys.ts index aa48d48d7..777dced26 100644 --- a/examples/cis4/registerRevocationKeys.ts +++ b/examples/cis4/registerRevocationKeys.ts @@ -9,11 +9,11 @@ import { buildAccountSigner, CIS4Contract, ContractAddress, - createConcordiumClient, Energy, HexString, parseWallet, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -66,7 +66,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/registryMetadata.ts b/examples/cis4/registryMetadata.ts index 076ea66ec..0bec48350 100644 --- a/examples/cis4/registryMetadata.ts +++ b/examples/cis4/registryMetadata.ts @@ -1,11 +1,8 @@ import meow from 'meow'; import { credentials } from '@grpc/grpc-js'; -import { - CIS4Contract, - ContractAddress, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { CIS4Contract, ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -43,7 +40,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/removeRevocationKeys.ts b/examples/cis4/removeRevocationKeys.ts index 036ae0235..c23e66030 100644 --- a/examples/cis4/removeRevocationKeys.ts +++ b/examples/cis4/removeRevocationKeys.ts @@ -8,10 +8,10 @@ import { buildAccountSigner, CIS4Contract, ContractAddress, - createConcordiumClient, Energy, parseWallet, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -65,7 +65,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/revocationKeys.ts b/examples/cis4/revocationKeys.ts index 950040782..6c3971157 100644 --- a/examples/cis4/revocationKeys.ts +++ b/examples/cis4/revocationKeys.ts @@ -1,11 +1,8 @@ import meow from 'meow'; import { credentials } from '@grpc/grpc-js'; -import { - CIS4Contract, - ContractAddress, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { CIS4Contract, ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -43,7 +40,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/revokeCredentialAsHolder.ts b/examples/cis4/revokeCredentialAsHolder.ts index 7b1c7da99..aa2577588 100644 --- a/examples/cis4/revokeCredentialAsHolder.ts +++ b/examples/cis4/revokeCredentialAsHolder.ts @@ -8,11 +8,11 @@ import { buildAccountSigner, CIS4Contract, ContractAddress, - createConcordiumClient, Energy, parseWallet, Web3IdSigner, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -74,7 +74,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/revokeCredentialAsIssuer.ts b/examples/cis4/revokeCredentialAsIssuer.ts index 001b388f2..fc56bdbdc 100644 --- a/examples/cis4/revokeCredentialAsIssuer.ts +++ b/examples/cis4/revokeCredentialAsIssuer.ts @@ -8,10 +8,10 @@ import { buildAccountSigner, CIS4Contract, ContractAddress, - createConcordiumClient, Energy, parseWallet, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -69,7 +69,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/cis4/revokeCredentialAsOther.ts b/examples/cis4/revokeCredentialAsOther.ts index a9854e8fc..07769b379 100644 --- a/examples/cis4/revokeCredentialAsOther.ts +++ b/examples/cis4/revokeCredentialAsOther.ts @@ -8,11 +8,11 @@ import { buildAccountSigner, CIS4Contract, ContractAddress, - createConcordiumClient, Energy, parseWallet, Web3IdSigner, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { parseEndpoint } from '../shared/util.js'; const cli = meow( @@ -80,7 +80,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/banPeer.ts b/examples/client/banPeer.ts index 8c4e28b0a..27cb9dca1 100644 --- a/examples/client/banPeer.ts +++ b/examples/client/banPeer.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient } from '@concordium/node-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -35,7 +35,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/dumpStart.ts b/examples/client/dumpStart.ts index 16a5bc9cc..0b3ebe173 100644 --- a/examples/client/dumpStart.ts +++ b/examples/client/dumpStart.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient } from '@concordium/node-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -41,7 +41,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/dumpStop.ts b/examples/client/dumpStop.ts index 7e1daee28..0dffb33e4 100644 --- a/examples/client/dumpStop.ts +++ b/examples/client/dumpStop.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient } from '@concordium/node-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -27,7 +27,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/findFirstFinalizedBlockNoLaterThan.ts b/examples/client/findFirstFinalizedBlockNoLaterThan.ts index b8b34d360..b9b9035b3 100644 --- a/examples/client/findFirstFinalizedBlockNoLaterThan.ts +++ b/examples/client/findFirstFinalizedBlockNoLaterThan.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient } from '@concordium/node-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -42,7 +42,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/findFirstNonGenesisAccount.ts b/examples/client/findFirstNonGenesisAccount.ts index bb0962e2e..b4149fe6d 100644 --- a/examples/client/findFirstNonGenesisAccount.ts +++ b/examples/client/findFirstNonGenesisAccount.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient, streamToList } from '@concordium/node-sdk'; +import { streamToList } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -34,7 +35,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/findInstanceCreation.ts b/examples/client/findInstanceCreation.ts index fe4fed992..06449ed0b 100644 --- a/examples/client/findInstanceCreation.ts +++ b/examples/client/findInstanceCreation.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { ContractAddress, createConcordiumClient } from '@concordium/node-sdk'; +import { ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -47,7 +48,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getAccountInfo.ts b/examples/client/getAccountInfo.ts index dd5de3b6c..575371382 100644 --- a/examples/client/getAccountInfo.ts +++ b/examples/client/getAccountInfo.ts @@ -2,10 +2,10 @@ import { parseEndpoint } from '../shared/util.js'; import { AccountAddress, AccountInfo, + AccountInfoType, BlockHash, - createConcordiumClient, - isDelegatorAccount, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -46,7 +46,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() @@ -76,7 +76,7 @@ const client = createConcordiumClient( console.log('Account address:', accountInfo.accountAddress); // If the account is a delegator print delegator information - if (isDelegatorAccount(accountInfo)) { + if (accountInfo.type === AccountInfoType.Delegator) { console.log( 'Delegated stake amount:', accountInfo.accountDelegation.stakedAmount diff --git a/examples/client/getAccountList.ts b/examples/client/getAccountList.ts index a3cb3c998..a0cf49390 100644 --- a/examples/client/getAccountList.ts +++ b/examples/client/getAccountList.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - createConcordiumClient, - BlockHash, - AccountAddress, -} from '@concordium/node-sdk'; +import { BlockHash, AccountAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getAccountNonFinalizedTransactions.ts b/examples/client/getAccountNonFinalizedTransactions.ts index 693e1da76..6d17c3f3a 100644 --- a/examples/client/getAccountNonFinalizedTransactions.ts +++ b/examples/client/getAccountNonFinalizedTransactions.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - AccountAddress, - createConcordiumClient, - TransactionHash, -} from '@concordium/node-sdk'; +import { AccountAddress, TransactionHash } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -39,7 +36,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getAncestors.ts b/examples/client/getAncestors.ts index 027abccfe..02efc5b2e 100644 --- a/examples/client/getAncestors.ts +++ b/examples/client/getAncestors.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { BlockHash, createConcordiumClient } from '@concordium/node-sdk'; +import { BlockHash } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -40,7 +41,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getAnonymityRevokers.ts b/examples/client/getAnonymityRevokers.ts index 2f88765fe..e3adcb6df 100644 --- a/examples/client/getAnonymityRevokers.ts +++ b/examples/client/getAnonymityRevokers.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - ArInfo, - BlockHash, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { ArInfo, BlockHash } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBakerList.ts b/examples/client/getBakerList.ts index 4d30e52d5..c7f0f0e87 100644 --- a/examples/client/getBakerList.ts +++ b/examples/client/getBakerList.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BakerId, - BlockHash, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { BakerId, BlockHash } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBannedPeers.ts b/examples/client/getBannedPeers.ts index 01585e5f2..5e8d465f3 100644 --- a/examples/client/getBannedPeers.ts +++ b/examples/client/getBannedPeers.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient, IpAddressString } from '@concordium/node-sdk'; +import { IpAddressString } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -27,7 +28,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBlockChainParameters.ts b/examples/client/getBlockChainParameters.ts index 551ea1a33..54b3de953 100644 --- a/examples/client/getBlockChainParameters.ts +++ b/examples/client/getBlockChainParameters.ts @@ -1,11 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - ChainParameters, - createConcordiumClient, - isChainParametersV1, - isChainParametersV2, -} from '@concordium/node-sdk'; +import { BlockHash, ChainParameters } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -38,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() @@ -62,9 +57,9 @@ const client = createConcordiumClient( console.log('Euro per Energy:', euroPerEnergy); // Check version of chain parameters - if (isChainParametersV2(cp)) { + if (cp.version === 2) { console.log('Minimum block time', cp.minBlockTime); - } else if (isChainParametersV1(cp)) { + } else if (cp.version === 1) { console.log('Minimum equity capital:', cp.minimumEquityCapital); } else { console.log( diff --git a/examples/client/getBlockFinalizationSummary.ts b/examples/client/getBlockFinalizationSummary.ts index a067e8040..b61d2d273 100644 --- a/examples/client/getBlockFinalizationSummary.ts +++ b/examples/client/getBlockFinalizationSummary.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockFinalizationSummary, - BlockHash, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { BlockFinalizationSummary, BlockHash } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBlockInfo.ts b/examples/client/getBlockInfo.ts index 10475be1f..bf9b99d09 100644 --- a/examples/client/getBlockInfo.ts +++ b/examples/client/getBlockInfo.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - BlockInfo, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { BlockHash, BlockInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, port, credentials.createInsecure() diff --git a/examples/client/getBlockItemStatus.ts b/examples/client/getBlockItemStatus.ts index e77bd5e6c..f789f3e73 100644 --- a/examples/client/getBlockItemStatus.ts +++ b/examples/client/getBlockItemStatus.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockItemStatus, - TransactionHash, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { BlockItemStatus, TransactionHash } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -39,7 +36,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBlockPendingUpdates.ts b/examples/client/getBlockPendingUpdates.ts index f4f9db43c..bcdeb447f 100644 --- a/examples/client/getBlockPendingUpdates.ts +++ b/examples/client/getBlockPendingUpdates.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - PendingUpdate, -} from '@concordium/node-sdk'; +import { BlockHash, PendingUpdate } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBlockSpecialEvents.ts b/examples/client/getBlockSpecialEvents.ts index 21a25a9e9..50a9b8213 100644 --- a/examples/client/getBlockSpecialEvents.ts +++ b/examples/client/getBlockSpecialEvents.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - BlockSpecialEvent, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { BlockHash, BlockSpecialEvent } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBlockTransactionEvents.ts b/examples/client/getBlockTransactionEvents.ts index 2e61304ce..d312fca62 100644 --- a/examples/client/getBlockTransactionEvents.ts +++ b/examples/client/getBlockTransactionEvents.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - BlockItemSummary, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { BlockHash, BlockItemSummary } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBlocks.ts b/examples/client/getBlocks.ts index ea2452c24..a4e0204ac 100644 --- a/examples/client/getBlocks.ts +++ b/examples/client/getBlocks.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { ArrivedBlockInfo, createConcordiumClient } from '@concordium/node-sdk'; +import { ArrivedBlockInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -27,7 +28,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBlocksAbort.ts b/examples/client/getBlocksAbort.ts index c8630f245..c82f6b2c7 100644 --- a/examples/client/getBlocksAbort.ts +++ b/examples/client/getBlocksAbort.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient, ArrivedBlockInfo } from '@concordium/node-sdk'; +import { ArrivedBlockInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -27,7 +28,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBlocksAtHeightAbsolute.ts b/examples/client/getBlocksAtHeightAbsolute.ts index e264015e8..219cf36bc 100644 --- a/examples/client/getBlocksAtHeightAbsolute.ts +++ b/examples/client/getBlocksAtHeightAbsolute.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { BlockHash, createConcordiumClient } from '@concordium/node-sdk'; +import { BlockHash } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -35,7 +36,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBlocksAtHeightRelative.ts b/examples/client/getBlocksAtHeightRelative.ts index a1649c131..23423635e 100644 --- a/examples/client/getBlocksAtHeightRelative.ts +++ b/examples/client/getBlocksAtHeightRelative.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - BlocksAtHeightRequest, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { BlockHash, BlocksAtHeightRequest } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -53,7 +50,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getBranches.ts b/examples/client/getBranches.ts index e6f1f278c..c64a84223 100644 --- a/examples/client/getBranches.ts +++ b/examples/client/getBranches.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { Branch, createConcordiumClient } from '@concordium/node-sdk'; +import { Branch } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -27,7 +28,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getConsensusStatus.ts b/examples/client/getConsensusStatus.ts index 5cd923587..e3192a547 100644 --- a/examples/client/getConsensusStatus.ts +++ b/examples/client/getConsensusStatus.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { ConsensusStatus, createConcordiumClient } from '@concordium/node-sdk'; +import { ConsensusStatus } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -27,7 +28,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getCryptographicParameters.ts b/examples/client/getCryptographicParameters.ts index 3fa207a81..618da9363 100644 --- a/examples/client/getCryptographicParameters.ts +++ b/examples/client/getCryptographicParameters.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - CryptographicParameters, -} from '@concordium/node-sdk'; +import { BlockHash, CryptographicParameters } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getElectionInfo.ts b/examples/client/getElectionInfo.ts index f700853dc..09097b5c1 100644 --- a/examples/client/getElectionInfo.ts +++ b/examples/client/getElectionInfo.ts @@ -1,10 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - ElectionInfo, - isElectionInfoV0, -} from '@concordium/node-sdk'; +import { BlockHash, ElectionInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -37,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() @@ -66,7 +62,7 @@ const client = createConcordiumClient( console.log('Bakers sorted by lottery power:', sortedBakers); console.log('Election nonce:', electionInfo.electionNonce); - if (isElectionInfoV0(electionInfo)) { + if (electionInfo.version === 0) { console.log('Election difficulty:', electionInfo.electionDifficulty); } // #endregion documentation-snippet diff --git a/examples/client/getEmbeddedSchema.ts b/examples/client/getEmbeddedSchema.ts index 87cddbeab..0d5bc0417 100644 --- a/examples/client/getEmbeddedSchema.ts +++ b/examples/client/getEmbeddedSchema.ts @@ -1,4 +1,5 @@ -import { createConcordiumClient, ModuleReference } from '@concordium/node-sdk'; +import { ModuleReference } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -40,7 +41,7 @@ const cli = meow( ); const [address, port] = cli.flags.endpoint.split(':'); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getFinalizedBlocks.ts b/examples/client/getFinalizedBlocks.ts index 7f74fa32c..1336f77fd 100644 --- a/examples/client/getFinalizedBlocks.ts +++ b/examples/client/getFinalizedBlocks.ts @@ -1,8 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - createConcordiumClient, - FinalizedBlockInfo, -} from '@concordium/node-sdk'; +import { FinalizedBlockInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -30,7 +28,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getFinalizedBlocksFrom.ts b/examples/client/getFinalizedBlocksFrom.ts index 34a43c893..ec0a636ac 100644 --- a/examples/client/getFinalizedBlocksFrom.ts +++ b/examples/client/getFinalizedBlocksFrom.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient } from '@concordium/node-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -39,7 +39,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getIdentityProviders.ts b/examples/client/getIdentityProviders.ts index b6cf4be5a..9bf97fe9d 100644 --- a/examples/client/getIdentityProviders.ts +++ b/examples/client/getIdentityProviders.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - IpInfo, -} from '@concordium/node-sdk'; +import { BlockHash, IpInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getInstanceInfo.ts b/examples/client/getInstanceInfo.ts index 93e1573c8..99a361eee 100644 --- a/examples/client/getInstanceInfo.ts +++ b/examples/client/getInstanceInfo.ts @@ -1,10 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - ContractAddress, - createConcordiumClient, - InstanceInfo, -} from '@concordium/node-sdk'; +import { BlockHash, ContractAddress, InstanceInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -45,7 +41,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getInstanceState.ts b/examples/client/getInstanceState.ts index a06397a2c..be557aa81 100644 --- a/examples/client/getInstanceState.ts +++ b/examples/client/getInstanceState.ts @@ -2,9 +2,9 @@ import { parseEndpoint } from '../shared/util.js'; import { BlockHash, ContractAddress, - createConcordiumClient, InstanceStateKVPair, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -45,7 +45,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getModuleList.ts b/examples/client/getModuleList.ts index 008054624..71822cb54 100644 --- a/examples/client/getModuleList.ts +++ b/examples/client/getModuleList.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - HexString, -} from '@concordium/node-sdk'; +import { BlockHash, HexString } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getModuleSource.ts b/examples/client/getModuleSource.ts index b5fc40386..9182763b7 100644 --- a/examples/client/getModuleSource.ts +++ b/examples/client/getModuleSource.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - ModuleReference, -} from '@concordium/node-sdk'; +import { BlockHash, ModuleReference } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import fs from 'fs'; @@ -51,7 +48,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getNextAccountSequenceNumber.ts b/examples/client/getNextAccountSequenceNumber.ts index e27c22cff..84b9216ba 100644 --- a/examples/client/getNextAccountSequenceNumber.ts +++ b/examples/client/getNextAccountSequenceNumber.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - AccountAddress, - createConcordiumClient, - NextAccountNonce, -} from '@concordium/node-sdk'; +import { AccountAddress, NextAccountNonce } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -39,7 +36,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getNextUpdateSequenceNumbers.ts b/examples/client/getNextUpdateSequenceNumbers.ts index 61802b8bb..7a2fd324a 100644 --- a/examples/client/getNextUpdateSequenceNumbers.ts +++ b/examples/client/getNextUpdateSequenceNumbers.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - NextUpdateSequenceNumbers, -} from '@concordium/node-sdk'; +import { BlockHash, NextUpdateSequenceNumbers } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getNodeInfo.ts b/examples/client/getNodeInfo.ts index 4a2440e81..80423fad8 100644 --- a/examples/client/getNodeInfo.ts +++ b/examples/client/getNodeInfo.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient, NodeInfo } from '@concordium/node-sdk'; +import { NodeInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -32,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getPassiveDelegationInfo.ts b/examples/client/getPassiveDelegationInfo.ts index b14de2a48..5633d5b0a 100644 --- a/examples/client/getPassiveDelegationInfo.ts +++ b/examples/client/getPassiveDelegationInfo.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - PassiveDelegationStatus, -} from '@concordium/node-sdk'; +import { BlockHash, PassiveDelegationStatus } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getPassiveDelegators.ts b/examples/client/getPassiveDelegators.ts index df8520a3a..68d27d338 100644 --- a/examples/client/getPassiveDelegators.ts +++ b/examples/client/getPassiveDelegators.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - DelegatorInfo, -} from '@concordium/node-sdk'; +import { BlockHash, DelegatorInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getPassiveDelegatorsPendingChanges.ts b/examples/client/getPassiveDelegatorsPendingChanges.ts index ea9ebe934..8880b2f0c 100644 --- a/examples/client/getPassiveDelegatorsPendingChanges.ts +++ b/examples/client/getPassiveDelegatorsPendingChanges.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - DelegatorInfo, -} from '@concordium/node-sdk'; +import { BlockHash, DelegatorInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getPassiveDelegatorsRewardPeriod.ts b/examples/client/getPassiveDelegatorsRewardPeriod.ts index fa3bdcb2c..c64499e88 100644 --- a/examples/client/getPassiveDelegatorsRewardPeriod.ts +++ b/examples/client/getPassiveDelegatorsRewardPeriod.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - DelegatorRewardPeriodInfo, -} from '@concordium/node-sdk'; +import { BlockHash, DelegatorRewardPeriodInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -36,7 +33,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getPeersInfo.ts b/examples/client/getPeersInfo.ts index 395d5a17f..ad736fad5 100644 --- a/examples/client/getPeersInfo.ts +++ b/examples/client/getPeersInfo.ts @@ -1,5 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient, PeerInfo } from '@concordium/node-sdk'; +import { PeerInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -27,7 +28,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getPoolDelegators.ts b/examples/client/getPoolDelegators.ts index 2d9e8eacd..e4d4817f0 100644 --- a/examples/client/getPoolDelegators.ts +++ b/examples/client/getPoolDelegators.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - DelegatorInfo, -} from '@concordium/node-sdk'; +import { BlockHash, DelegatorInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -14,7 +11,7 @@ const cli = meow( $ yarn run-example [options] Required: - --pool-owner, -p The BakerId of the pool owner + --pool-owner, -p The BakerId of the pool owner Options --help, -h Displays this message @@ -44,7 +41,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getPoolDelegatorsRewardPeriod.ts b/examples/client/getPoolDelegatorsRewardPeriod.ts index 9652ebf5e..d535bcfb9 100644 --- a/examples/client/getPoolDelegatorsRewardPeriod.ts +++ b/examples/client/getPoolDelegatorsRewardPeriod.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - createConcordiumClient, - DelegatorRewardPeriodInfo, -} from '@concordium/node-sdk'; +import { BlockHash, DelegatorRewardPeriodInfo } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -14,7 +11,7 @@ const cli = meow( $ yarn run-example [options] Required: - --pool-owner, -p The BakerId of the pool owner + --pool-owner, -p The BakerId of the pool owner Options --help, -h Displays this message @@ -44,7 +41,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getPoolInfo.ts b/examples/client/getPoolInfo.ts index 9bf16acb8..4e47c8ee5 100644 --- a/examples/client/getPoolInfo.ts +++ b/examples/client/getPoolInfo.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BakerPoolStatus, - BlockHash, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { BakerPoolStatus, BlockHash } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -14,7 +11,7 @@ const cli = meow( $ yarn run-example [options] Required: - --pool-owner, -p The BakerId of the pool owner + --pool-owner, -p The BakerId of the pool owner Options --help, -h Displays this message @@ -44,7 +41,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/getTokenomicsInfo.ts b/examples/client/getTokenomicsInfo.ts index 3b68a65f6..a7d0a0f74 100644 --- a/examples/client/getTokenomicsInfo.ts +++ b/examples/client/getTokenomicsInfo.ts @@ -1,9 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - isRewardStatusV1, - createConcordiumClient, - BlockHash, -} from '@concordium/node-sdk'; +import { BlockHash } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -44,7 +41,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() @@ -65,7 +62,7 @@ const client = createConcordiumClient( // Protocol version 4 expanded the amount of information in the response, so one should check the type to access that. // This information includes information about the payday and total amount of funds staked. - if (isRewardStatusV1(tokenomics)) { + if (tokenomics.version === 1) { console.log('Next payday time:', tokenomics.nextPaydayTime); console.log( 'Total staked amount by bakers and delegators', diff --git a/examples/client/healthCheck.ts b/examples/client/healthCheck.ts index 183b9b784..c49b22a25 100644 --- a/examples/client/healthCheck.ts +++ b/examples/client/healthCheck.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient } from '@concordium/node-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -27,7 +27,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/instanceStateLookup.ts b/examples/client/instanceStateLookup.ts index 42e49c67e..0d4a038e7 100644 --- a/examples/client/instanceStateLookup.ts +++ b/examples/client/instanceStateLookup.ts @@ -1,10 +1,6 @@ import { parseEndpoint } from '../shared/util.js'; -import { - BlockHash, - ContractAddress, - HexString, - createConcordiumClient, -} from '@concordium/node-sdk'; +import { BlockHash, ContractAddress, HexString } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -51,7 +47,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/invokeContract.ts b/examples/client/invokeContract.ts index dfd67d050..63661f1cd 100644 --- a/examples/client/invokeContract.ts +++ b/examples/client/invokeContract.ts @@ -10,8 +10,8 @@ import { Parameter, ReceiveName, ReturnValue, - createConcordiumClient, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -32,7 +32,7 @@ const cli = meow( --energy, -n The maximum amount of energy to allow for execution, defaults to 1000000 --invoker, -i The address of the invoker, defaults to the zero account address --endpoint, -e Specify endpoint of the form "address:port", defaults to localhost:20000 - --parameter, -p The serialized parameters that the contract will be invoked with, as a + --parameter, -p The serialized parameters that the contract will be invoked with, as a hex string. Will default to an empty hex string meaning no parameters `, { @@ -79,7 +79,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/peerConnect.ts b/examples/client/peerConnect.ts index 7baa36f2b..461e14654 100644 --- a/examples/client/peerConnect.ts +++ b/examples/client/peerConnect.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient } from '@concordium/node-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -41,7 +41,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/peerDisconnect.ts b/examples/client/peerDisconnect.ts index 038475679..eddbf1190 100644 --- a/examples/client/peerDisconnect.ts +++ b/examples/client/peerDisconnect.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient } from '@concordium/node-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -41,7 +41,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/shutdown.ts b/examples/client/shutdown.ts index 705bdba22..ac326179a 100644 --- a/examples/client/shutdown.ts +++ b/examples/client/shutdown.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient } from '@concordium/node-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -27,7 +27,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/client/unbanPeer.ts b/examples/client/unbanPeer.ts index ee3ebd742..1d54805f1 100644 --- a/examples/client/unbanPeer.ts +++ b/examples/client/unbanPeer.ts @@ -1,5 +1,5 @@ import { parseEndpoint } from '../shared/util.js'; -import { createConcordiumClient } from '@concordium/node-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -35,7 +35,7 @@ const cli = meow( const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/common/aliases.ts b/examples/common/aliases.ts index e8c13e858..c20a4fa5b 100644 --- a/examples/common/aliases.ts +++ b/examples/common/aliases.ts @@ -1,4 +1,4 @@ -import { AccountAddress } from '@concordium/node-sdk'; +import { AccountAddress } from '@concordium/web-sdk'; /** * The following shows how to generate an account alias, and how to test diff --git a/examples/common/bakerAdd.ts b/examples/common/bakerAdd.ts index 95956886d..873861374 100644 --- a/examples/common/bakerAdd.ts +++ b/examples/common/bakerAdd.ts @@ -5,14 +5,14 @@ import { AccountTransactionType, signTransaction, TransactionExpiry, - createConcordiumClient, CcdAmount, generateBakerKeys, ConfigureBakerPayload, OpenStatus, parseWallet, buildAccountSigner, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { readFileSync } from 'node:fs'; import { parseEndpoint } from '../shared/util.js'; @@ -55,7 +55,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/common/bakerRemove.ts b/examples/common/bakerRemove.ts index ff21989c4..5c55fc064 100644 --- a/examples/common/bakerRemove.ts +++ b/examples/common/bakerRemove.ts @@ -5,12 +5,12 @@ import { AccountTransactionType, signTransaction, TransactionExpiry, - createConcordiumClient, CcdAmount, ConfigureBakerPayload, parseWallet, buildAccountSigner, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { readFileSync } from 'node:fs'; import { parseEndpoint } from '../shared/util.js'; @@ -47,7 +47,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/common/buildAccountSigner.ts b/examples/common/buildAccountSigner.ts index bf77c6987..0655ae9a4 100644 --- a/examples/common/buildAccountSigner.ts +++ b/examples/common/buildAccountSigner.ts @@ -6,7 +6,7 @@ import { signMessage, buildAccountSigner, parseWallet, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; const cli = meow( ` diff --git a/examples/common/cis0Supports.ts b/examples/common/cis0Supports.ts index 404989837..20461ccdf 100644 --- a/examples/common/cis0Supports.ts +++ b/examples/common/cis0Supports.ts @@ -1,8 +1,5 @@ -import { - createConcordiumClient, - cis0Supports, - ContractAddress, -} from '@concordium/node-sdk'; +import { cis0Supports, ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; import { parseEndpoint } from '../shared/util.js'; @@ -50,7 +47,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/common/delegationAdd.ts b/examples/common/delegationAdd.ts index 06019185a..955a0cf0b 100644 --- a/examples/common/delegationAdd.ts +++ b/examples/common/delegationAdd.ts @@ -5,13 +5,13 @@ import { AccountTransactionType, signTransaction, TransactionExpiry, - createConcordiumClient, ConfigureDelegationPayload, CcdAmount, DelegationTargetType, parseWallet, buildAccountSigner, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { readFileSync } from 'node:fs'; @@ -60,7 +60,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/common/delegationRemove.ts b/examples/common/delegationRemove.ts index 21a448842..0571aa94a 100644 --- a/examples/common/delegationRemove.ts +++ b/examples/common/delegationRemove.ts @@ -5,12 +5,12 @@ import { AccountTransactionType, signTransaction, TransactionExpiry, - createConcordiumClient, ConfigureDelegationPayload, CcdAmount, parseWallet, buildAccountSigner, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { readFileSync } from 'node:fs'; import { parseEndpoint } from '../shared/util.js'; @@ -47,7 +47,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/common/deployModule.ts b/examples/common/deployModule.ts index c2ca72ae8..0492cebb5 100644 --- a/examples/common/deployModule.ts +++ b/examples/common/deployModule.ts @@ -7,10 +7,10 @@ import { DeployModulePayload, signTransaction, TransactionExpiry, - createConcordiumClient, parseWallet, buildAccountSigner, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { readFileSync } from 'node:fs'; import { parseEndpoint } from '../shared/util.js'; @@ -53,7 +53,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/common/simpleTransfer.ts b/examples/common/simpleTransfer.ts index 5f30a9b29..86a9afa7c 100644 --- a/examples/common/simpleTransfer.ts +++ b/examples/common/simpleTransfer.ts @@ -9,10 +9,10 @@ import { NextAccountNonce, signTransaction, TransactionExpiry, - createConcordiumClient, parseWallet, buildAccountSigner, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { readFileSync } from 'node:fs'; import { parseEndpoint } from '../shared/util.js'; @@ -67,7 +67,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/common/statements.ts b/examples/common/statements.ts index 2a33d6035..c79447832 100644 --- a/examples/common/statements.ts +++ b/examples/common/statements.ts @@ -2,7 +2,7 @@ import { IdStatementBuilder, verifyIdstatement, AttributesKeys, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; /** * The following example shows how a proof statement can be built up. diff --git a/examples/common/streamToList.ts b/examples/common/streamToList.ts index b062e1620..66d8c4988 100644 --- a/examples/common/streamToList.ts +++ b/examples/common/streamToList.ts @@ -1,9 +1,5 @@ -import { - BakerId, - BlockHash, - createConcordiumClient, - streamToList, -} from '@concordium/node-sdk'; +import { BakerId, BlockHash, streamToList } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { parseEndpoint } from '../shared/util.js'; @@ -37,7 +33,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/composed-examples/findAccountCreationBlock.ts b/examples/composed-examples/findAccountCreationBlock.ts index b9995831e..0f2af7991 100644 --- a/examples/composed-examples/findAccountCreationBlock.ts +++ b/examples/composed-examples/findAccountCreationBlock.ts @@ -1,8 +1,5 @@ -import { - AccountAddress, - createConcordiumClient, - isRpcError, -} from '@concordium/node-sdk'; +import { AccountAddress, isRpcError } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { parseEndpoint } from '../shared/util.js'; @@ -43,7 +40,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/composed-examples/getEmbeddedSchemaFromInstance.ts b/examples/composed-examples/getEmbeddedSchemaFromInstance.ts index fc8ace93a..c1dea6d12 100644 --- a/examples/composed-examples/getEmbeddedSchemaFromInstance.ts +++ b/examples/composed-examples/getEmbeddedSchemaFromInstance.ts @@ -1,4 +1,5 @@ -import { ContractAddress, createConcordiumClient } from '@concordium/node-sdk'; +import { ContractAddress } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import meow from 'meow'; @@ -45,7 +46,7 @@ const cli = meow( ); const [address, port] = cli.flags.endpoint.split(':'); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/composed-examples/initAndUpdateContract.ts b/examples/composed-examples/initAndUpdateContract.ts index 40edcb27e..6bade971b 100644 --- a/examples/composed-examples/initAndUpdateContract.ts +++ b/examples/composed-examples/initAndUpdateContract.ts @@ -5,7 +5,6 @@ import { AccountTransactionType, CcdAmount, ContractContext, - createConcordiumClient, deserializeReceiveReturnValue, InitContractPayload, ModuleReference, @@ -23,7 +22,8 @@ import { Energy, EntrypointName, ReturnValue, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { readFileSync } from 'node:fs'; import { parseEndpoint } from '../shared/util.js'; @@ -60,7 +60,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/composed-examples/listAccountCreation.ts b/examples/composed-examples/listAccountCreation.ts index 5a404950f..af6e65ade 100644 --- a/examples/composed-examples/listAccountCreation.ts +++ b/examples/composed-examples/listAccountCreation.ts @@ -1,8 +1,5 @@ -import { - createConcordiumClient, - streamToList, - unwrap, -} from '@concordium/node-sdk'; +import { streamToList, unwrap } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { parseEndpoint } from '../shared/util.js'; @@ -42,7 +39,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/composed-examples/listInitialAccounts.ts b/examples/composed-examples/listInitialAccounts.ts index 42daf8cb2..73fc8df95 100644 --- a/examples/composed-examples/listInitialAccounts.ts +++ b/examples/composed-examples/listInitialAccounts.ts @@ -1,4 +1,5 @@ -import { createConcordiumClient, unwrap } from '@concordium/node-sdk'; +import { unwrap } from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; import { credentials } from '@grpc/grpc-js'; import { parseEndpoint } from '../shared/util.js'; @@ -38,7 +39,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/composed-examples/listNumberAccountTransactions.ts b/examples/composed-examples/listNumberAccountTransactions.ts index 4d3bf4bc1..c9b21bc99 100644 --- a/examples/composed-examples/listNumberAccountTransactions.ts +++ b/examples/composed-examples/listNumberAccountTransactions.ts @@ -1,14 +1,14 @@ import { AccountAddress, - createConcordiumClient, isTransferLikeSummary, unwrap, -} from '@concordium/node-sdk'; +} from '@concordium/web-sdk'; +import { ConcordiumGRPCNodeClient } from '@concordium/web-sdk/nodejs'; +import meow from 'meow'; + import { credentials } from '@grpc/grpc-js'; import { parseEndpoint } from '../shared/util.js'; -import meow from 'meow'; - const cli = meow( ` Usage @@ -43,7 +43,7 @@ const cli = meow( ); const [address, port] = parseEndpoint(cli.flags.endpoint); -const client = createConcordiumClient( +const client = new ConcordiumGRPCNodeClient( address, Number(port), credentials.createInsecure() diff --git a/examples/package.json b/examples/package.json index 900a66835..4ecbce92a 100644 --- a/examples/package.json +++ b/examples/package.json @@ -3,20 +3,14 @@ "type": "module", "dependencies": { "@concordium/ccd-js-gen": "workspace:^", - "@concordium/common-sdk": "workspace:^", - "@concordium/node-sdk": "workspace:^", + "@concordium/web-sdk": "workspace:^", "@grpc/grpc-js": "^1.3.4", "@noble/ed25519": "^1.7.1", - "@typescript-eslint/eslint-plugin": "^6.7.0", - "@typescript-eslint/parser": "^6.7.0", "buffer": "^6.0.3", - "eslint": "^7.29.0", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-import": "^2.23.4", - "eslint-plugin-prettier": "^3.4.0", - "lint-staged": "^12.0.2", "meow": "11.0", - "prettier": "^2.3.2", + "node-fetch": "^3.3.2" + }, + "devDependencies": { "ts-node": "10.9", "typescript": "^5.2.2" }, diff --git a/examples/shared/util.ts b/examples/shared/util.ts index c413dfa0b..35e45c5dc 100644 --- a/examples/shared/util.ts +++ b/examples/shared/util.ts @@ -1,4 +1,4 @@ -import { ContractAddress, AccountAddress } from '@concordium/node-sdk'; +import { ContractAddress, AccountAddress } from '@concordium/web-sdk'; export const parseAddress = ( input: string diff --git a/package.json b/package.json index 2d541060f..7d54730ef 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,7 @@ "private": true, "workspaces": { "packages": [ - "./packages/rust-bindings", - "./packages/common", - "./packages/nodejs", - "./packages/web", - "./packages/ccd-js-gen", + "./packages/*", "./examples", "./docs" ] @@ -35,36 +31,19 @@ }, "type": "module", "devDependencies": { - "@babel/core": "^7.17.10", - "@babel/plugin-transform-modules-commonjs": "^7.12.1", - "@babel/plugin-transform-runtime": "^7.12.1", - "@babel/preset-env": "^7.12.1", "@typescript-eslint/eslint-plugin": "^6.7.0", "@typescript-eslint/parser": "^6.7.0", - "babel-jest": "^27.0.6", - "babel-loader": "^8.1.0", "eslint": "^7.29.0", "eslint-config-prettier": "^8.3.0", "eslint-import-resolver-exports": "^1.0.0-beta.5", "eslint-import-resolver-typescript": "^2.7.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^3.4.0", - "glob": "^10.3.4", "husky": "^4.2.5", - "jest": "^29.6.2", "lint-staged": "^12.0.2", "markdown-link-check": "^3.1.4", "markdownlint-cli": "^0.34.0", - "prettier": "^2.3.2", - "stream-browserify": "^3.0.0", - "ts-jest": "^29.1.1", - "ts-node": "^10.9.1", - "typedoc": "^0.23", - "typedoc-plugin-merge-modules": "^4.0.1", - "typedoc-plugin-missing-exports": "^0.23", - "typescript": "^5.2.2", - "webpack": "^5.88.2", - "webpack-cli": "^4.9.2" + "prettier": "^2.3.2" }, "scripts": { "test": "FORCE_COLOR=true yarn workspaces foreach --no-private run test --passWithNoTests", diff --git a/packages/ccd-js-gen/package.json b/packages/ccd-js-gen/package.json index 6ba9ca982..b3a3073a5 100644 --- a/packages/ccd-js-gen/package.json +++ b/packages/ccd-js-gen/package.json @@ -31,20 +31,13 @@ }, "license": "Apache-2.0", "dependencies": { - "@concordium/node-sdk": "9.4.0", + "@concordium/web-sdk": "6.4.0", "buffer": "^6.0.3", "commander": "^11.0.0", "ts-morph": "^19.0.0" }, "devDependencies": { "@types/node": "^20.5.0", - "@typescript-eslint/eslint-plugin": "^6.7.0", - "@typescript-eslint/parser": "^6.7.0", - "eslint": "^7.29.0", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-import": "^2.23.4", - "eslint-plugin-prettier": "^3.4.0", - "prettier": "^2.3.2", "typescript": "^5.2.2" }, "prettier": { diff --git a/packages/ccd-js-gen/src/lib.ts b/packages/ccd-js-gen/src/lib.ts index 3033e5116..394f6a081 100644 --- a/packages/ccd-js-gen/src/lib.ts +++ b/packages/ccd-js-gen/src/lib.ts @@ -1,7 +1,7 @@ import * as fs from 'node:fs/promises'; import * as path from 'node:path'; import * as tsm from 'ts-morph'; -import * as SDK from '@concordium/node-sdk'; +import * as SDK from '@concordium/web-sdk'; /** * Output options for the generated code. @@ -107,7 +107,7 @@ async function addModuleClient( }); moduleSourceFile.addImportDeclaration({ namespaceImport: 'SDK', - moduleSpecifier: '@concordium/common-sdk', + moduleSpecifier: '@concordium/web-sdk', }); const moduleRefId = 'moduleReference'; @@ -359,7 +359,7 @@ This function ensures the smart contract module is deployed on chain. contractSourceFile.addImportDeclaration({ namespaceImport: 'SDK', - moduleSpecifier: '@concordium/common-sdk', + moduleSpecifier: '@concordium/web-sdk', }); contractSourceFile.addVariableStatement({ diff --git a/packages/common/README.md b/packages/common/README.md deleted file mode 100644 index f6f699409..000000000 --- a/packages/common/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Concordium JS SDKs Common Functionality - -This package is the shared library for the NodeJS and Web SDK's. - -Please see the -[documentation](https://developer.concordium.software/concordium-node-sdk-js/index.html) -for more information diff --git a/packages/common/src/pub/util.ts b/packages/common/src/pub/util.ts deleted file mode 100644 index 3bc1944ca..000000000 --- a/packages/common/src/pub/util.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Utility functions needed in web/nodejs packages -export { isValidHash, stringToInt } from '../util.js'; diff --git a/packages/common/tsconfig.build.json b/packages/common/tsconfig.build.json deleted file mode 100644 index 89314c41c..000000000 --- a/packages/common/tsconfig.build.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": [ - "src/**/*", - "types/**/*" - ], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib" - } -} diff --git a/packages/nodejs/CHANGELOG.md b/packages/nodejs/CHANGELOG.md deleted file mode 100644 index b7281ea92..000000000 --- a/packages/nodejs/CHANGELOG.md +++ /dev/null @@ -1,315 +0,0 @@ -# Changelog - -## Unreleased - -### Breaking changes - -- The package is published as an ES module, instead of commonJS. Migration steps can be seen in [the upgrade guide](../../docs/pages/misc-pages/upgrade-guide.md) -- The package has been split into several entrypoints that can be used to limit the scope of what is included from the SDK. - - `@concordium/node-sdk` exposes the full API of the SDK. - - `@concordium/node-sdk/cis0` entrypoint exposes functionality for working with contracts adhering to the [CIS-0](https://proposals.concordium.software/CIS/cis-0.html) standard. - - `@concordium/node-sdk/cis2` entrypoint exposes functionality for working with contracts adhering to the [CIS-2](https://proposals.concordium.software/CIS/cis-2.html) standard. - - `@concordium/node-sdk/cis4` entrypoint exposes functionality for working with contracts adhering to the [CIS-4](https://proposals.concordium.software/CIS/cis-4.html) standard. - - `@concordium/node-sdk/client` entrypoint exposes the **(deprecated)** grpc client for interacting with a nodes GPRCv1 interface. - - `@concordium/node-sdk/grpc` entrypoint exposes the grpc client for interacting with a nodes GRPCv2 interface. - - `@concordium/node-sdk/id` entrypoint exposes functionality for working with ID proofs. - - `@concordium/node-sdk/schema` entrypoint exposes functionality for working with smart contract schemas, i.e.(de)serializing types using a smart contract schema. - - This uses the wasm entrypoint at `@concordium/rust-bindings/dapp`. - - `@concordium/node-sdk/types` entrypoint exposes functionality for working with concordium domain types. - - `@concordium/node-sdk/wasm` entrypoint exposes a variety of functionality for working with concordium domain types, which requires WASM. - - This uses the wasm entrypoint at `@concorodium/rust-bindings/wallet`. - - `@concordium/node-sdk/web3-id` entrypoint exposes functionality for working with web3-id proofs. - - This change makes the library **incompatible** with node versions <16 and requires bundlers to respect the `exports` field of `package.json`. - - For TypeScript projects the minimum required version of typescript is: - - NodeJS: 4.7, `"moduleResolution": "node16" // or "nodenext"` - - Bundled applications (webpack, esbuild, rollup, etc...): 5.0, `"moduleResolution": "bundler"` - -- Removed `ConcordiumNodeClient` and types and functionality associated solely with this class. - -The API now uses dedicated types instead of language primitives: -- Use `AccountAddress` instead of a string with base58 encoding. Use `AccountAddress.fromBase58('')` to construct it. -- Use `BlockHash` instead of a string with hex encoding. Use `BlockHash.fromHexString('')` to construct it. -- Use `TranactionHash` instead of a string with hex encoding. Use `TransactionHash.fromHexString('')` to construct it. -- Use `Energy` instead of a bigint. Use `Energy.create()` to construct it. -- Use `ReceiveName` instead of a string. Use `ReceiveName.fromString('.')` to construct it. -- Use `InitName` instead of a string. Use `Init.fromString('init_')` to construct it. -- Use `ContractName` instead of a string. Use `ContractName.fromString('')` to construct it. -- Use `EntrypointName` instead of a string. Use `EntrypointName.fromString('')` to construct it. -- Use `Parameter` instead of a string with hex encoding. Use `Parameter.fromHexString('')`. -- Use `SequenceNumber` (formerly called nonce) instead of a bigint. Use `SequenceNumber.create()` to construct it. -- Use `Timestamp` instead of a bigint. Can be constructed using `Timestamp.fromMillis()`. -- Use `Duration` instead of a bigint. Can be constructed using `Duration.fromMillis()`. - -Several types have been replaced with a module containing the type itself together with functions for constructing and converting the type: - -- `AccountAddress` is now a module with functions related to account addresses: - - To refer to `AccountAddress` as a type use `AccountAddress.Type`. - - Constructing `new AccountAddress("
")` is now `AccountAddress.fromBase58("
")`. - - `isAlias` and `getAlias` are now accessable from `AccountAddress.isAlias` and `AccountAddress.getAlias`. -- `ContractAddresss` is now a module with functions related to contract addresses: - - To refer to `ContractAddress` as a type use `ContractAddress.Type`. - - To construct the type use `ContractAddress.create(index, subindex)`. -- `CredentialRegistrationId` is now a module with functions related to credential registration IDs: - - To refer to `CredentialRegistrationId` as a type use `CredentialRegistrationId.Type`. - - Constructing `new CredentialRegistrationId("")` is now `CredentialRegistrationId.fromHexString("")`. - -- Renamed `AccountSequenceNumber` module to `SequenceNumber`. -- Fix type for `TranferredEvent` from `ContractTraceEvent` to only be from contract addresses to account addresses. - -### Added - -- All JSON serialization in `serialization.ts` is now handled by `json-bigint` meaning that all functions now correctly handles bigint inputs -- `Timestamp` is now a module with functions related to time. - - To refer to `Timestamp` as a type use `Timestamp.Type`. -- `Duration` is now a module with functions related to durations of time. -- `EntrypointName` is now a module with functions related to entrypoint names of a smart contract. -- `ReceiveName` is now a module with functions related to receive-function names of a smart contract. - -## 9.4.0 - -- Bumped @concordium/common-sdk to 9.4.0. - -## 9.3.0 - -- Bumped @concordium/common-sdk to 9.3.0. - -## 9.2.0 - -- Bumped @concordium/common-sdk to 9.2.0. - -## 9.1.1 - -### Changed - -- Bumped @concordium/common-sdk to 9.1.1. (includes fixes for `verifyWeb3IdCredentialSignature` and `canProveAtomicStatement`) - -## 9.1.0 - -### Changed - -- Bumped @concordium/common-sdk to 9.1.0. (adds methods for creating verifiable presentation (proving statements about Web3Id Credentials)) - -## 9.0.0 - -### Breaking changes - -- Bumped @concordium/common-sdk to 9.0.0. (adds `displayTypeSchemaTemplate/getTransactionKindString` and renames `AccountTransactionType.TransferWithScheduleWithMemo`) - -## 8.0.0 - -### Breaking changes - -- Bumped @concordium/common-sdk to 8.0.0: - - Properly formed errors thrown by functions wrapping WASM execution (from @concordium/rust-bindings) with more helpful error messages. - - Types adapted to changes in protocol version 6. - - and [more](../common/CHANGELOG.md) - -## 7.0.0 2023-05-15 - -### Breaking Changes - -- Bumped @concordium/common-sdk to 7.0.0: - - Updated `blockInfo` so that the `bakerId` field is optional, since it will be undefined for genesis blocks. - - `waitForTransactionFinalization` now returns a `BlockItemSummaryInBlock` - - Added missing version return type in `getModuleSchema`. It now returns an object containing the schema source and version. - -## 6.4.0 2023-5-03 - -### Changed - -- Bumped @concordium/common-sdk to 6.5.0. (Adds `CIS2Contract`) - -## 6.3.0 2023-3-22 - -### Changed - -- Bumped @concordium/common-sdk to 6.4.0. (Adds `deserializeTypeValue`) - -## 6.2.0 2023-2-27 - -### Added - -- Added a `createConcordiumClient` function to create the gRPC v2 client. - -### Changed - -- Bumped @concordium/common-sdk to 6.3.0. (Adds the gRPC v2 client) - -### Fixed - -- 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 - -- Bumped @concordium/common-sdk to 6.1.0. (adds support for id statements and proofs) - -## 6.0.0 2022-11-15 - -### Breaking Changes - -- Bumped @concordium/common-sdk to 6.0.0. (Which changes transaction type names and field names to be aligned with other implementations) - -## 5.0.0 2022-11-8 - -Breaking Changes - -- Bumped @concordium/common-sdk to 5.2.0. (Which changes the function signature of ConcordiumHdWallet and sign helpers functions) - -## 4.0.0 2022-8-26 - -### Breaking Changes - -- Bumped @concordium/common-sdk to 3.0.0. (Which includes breaking changes to schema versioning) - -## 3.0.2 2022-7-26 - -### Fixed - -- `deserializeTransaction` no longer throws an error on expired transactions. - -## 3.0.1 2022-7-26 - -### Fixed - -- `deserializeTransaction` is now exported from index. - -## 3.0.0 - 2022-7-25 - -### Added - -- `deserializeTransaction` function to deserialize transaction created by `serializeAccountTransactionForSubmission` and `serializeCredentialDeploymentTransactionForSubmission`. (Currently SimpleTransfer, SimpleTransferWithMemo and RegisterData are the only supported account transactions kinds) - -### Breaking changes - -- getInstanceInfo, getModuleSource and invokeContract's parameters have changed order. Now the blockHash is the 2nd parameter instead of the 1st. - -## 2.1.1 2022-7-8 - -### Fixed - -- Fixed contract schema serialization for ByteList. - -## 2.1.0 2022-7-5 - -### Added - -- Support deserializing new schema types: ULeb128, ILeb128, ByteArray and ByteList. -- Support deserializing schemas with versioning information. - -### Changed - -- The function for deserializing a module schema `deserialModuleFromBuffer` now have the schema version as an optional argument. The function will try to extract the version from the buffer. When a version is provided it falls back to this, otherwise it throws an error. - -## 2.0.2 2022-6-27 - -### Fixed - -- `getModuleBuffer` returns correct type of `Buffer`. - -## 2.0.1 2022-6-27 - -### Added - -- `getModuleBuffer`, which is `getModuleFromBuffer` renamed (which was removed in 2.0.0). - -### Fixed - -- Error in build, which caused imports to fail. -- Added missing dependency google-protobuf. -- @noble/ed25519 and cross-fetch moved from devDependencies to dependencies. (In common-sdk) - -## 2.0.0 2022-6-24 - -### Added - -- Using `@concordium/common-sdk` as a dependency, and most features have been removed from this package. (But are re-exported instead) -- Support deserializing version 2 schemas. -- Support serializing parameters for contracts using version 2 schemas. -- Support for deploying versioned smart contract modules, which is the format used in cargo-concordium v2+. (This is done by not supplying the version field in the payload) - -### Breaking changes - -- `serializeInitContractParameters` and `serializeUpdateContractParameters` each have an additional parameter, which denotes the version of the schema provided. For existing users that are using V0 contracts, that parameter should be `SchemaVersion.V1`. -- Deserialization of schemas have been changed: types and functions have been renamed and `deserialModuleFromBuffer` have an additional parameter, and now returns a versioned module schema. - -## 1.1.0 2022-06-14 - -### Added - -- Support for the Invoke contract node entrypoint. - -### Fixed - -- Lossy parsing of uint64's from the node, if their value was above MAX_SAFE_INTEGER. - -## 1.0.0 2022-05-11 - -### Added - -- Support for getting baker list from node. -- Support for getting status of a Baker Pool/Passive delegation (required node to have protocol version 4 or later). -- Support for getting reward status of chain at specific block. -- Helper functions for determining the version of `BlockSummary` and nested types. -- Helper functions for determining the version of `AccountInfo` variants. -- Support for the new "configure delegation" transaction type. - -### Changed - -- Updated `BlockSummary` type to include new version, effective from protocol version 4. -- Updated `AccountInfo` type to include new fields related to delegation introduced with protocol version 4. - -## 0.7.3 2022-05-05 - -### Added - -- Export of serializeCredentialDeploymentTransactionForSubmission. - -### Fixed - -- Added missing dependency "google-protobuf" - -## 0.7.2 2022-05-05 - -### Added - -- Export of serializeAccountTransactionForSubmission. - -## 0.7.1 2022-03-09 - -### Added - -- Support for initiating and updating contracts with parameters. - -## 0.6.0 2022-02-02 - -### Added - -- Function to deserialize contract state. -- Support for register data transaction. - -## 0.5.1 2021-11-19 - -### Added - -- Functions to generate account aliases, and check if addresses are aliases. - -## 0.4.0 2021-11-17 - -### Added - -- Support for getting account info for a credential registration id. -- Support for the update credentials account transaction. -- Support for deploy module, initiate contract and update contract (without parameters). - -## 0.3.0 2021-10-28 - -### Added - -- Support for the credential deployment transaction. -- Helpers to decrypt mobile wallet exports, in particular to extract identity information from the export. diff --git a/packages/nodejs/README.md b/packages/nodejs/README.md deleted file mode 100644 index 903c9b681..000000000 --- a/packages/nodejs/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# Concordium NodeJS SDK - -[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](https://github.com/Concordium/.github/blob/main/.github/CODE_OF_CONDUCT.md) - -Wrappers for interacting with the Concordium node, using nodejs. - -Please see the -[documentation](https://developer.concordium.software/concordium-node-sdk-js/index.html) -for more information - -## ConcordiumGRPCClient - -The SDK provides a gRPC client, which can interact with the [Concordium -Node](https://github.com/Concordium/concordium-node) - -For an overview of the endpoints, [click -here](https://developer.concordium.software/concordium-node-sdk-js/modules/Common_GRPC_Client.html). - -To create a client, the function `createConcordiumClient` can be used. It -requires the address and port of the node. It also requires credentials to -be specified. These can be used for create either an insecure connection or -a TLS connection. In the following example the credentials are created for -a TLS connection: - -```ts -import { credentials } from '@grpc/grpc-js/'; -import { createConcordiumClient } from '@concordium/node-sdk'; -... -return createConcordiumClient( - address, - port, - credentials.createSsl(), - { timeout: 15000 } -); -``` - -The fourth 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 -[grpc-transport](https://www.npmjs.com/package/@protobuf-ts/grpc-transport). - -The connection to a node can be either an insecure connection or a TLS -connection. Note that the node that you are trying to connect to must support -TLS, for a TLS connection to work. Otherwise an insecure connection can be -created by using `credentials.createInsecure()` instead. - -To see the documentation for the deprecated v1 client, [click -here](https://developer.concordium.software/concordium-node-sdk-js/pages/misc-pages/grpc-v1.html). -For an overview of how to migrate from the v1 client to the v2 client, [click -here](https://developer.concordium.software/concordium-node-sdk-js/pages/misc-pages/grpc-migration.html). diff --git a/packages/nodejs/jest.config.ts b/packages/nodejs/jest.config.ts deleted file mode 100644 index c2d00acd2..000000000 --- a/packages/nodejs/jest.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { Config } from 'jest'; - -const config: Config = { - preset: 'ts-jest', - testEnvironment: 'node', - moduleFileExtensions: ['js', 'ts', 'json'], - moduleDirectories: ['node_modules'], - moduleNameMapper: { - '^(\\.\\.?\\/.+)\\.js$': '$1', // Remap esmodule file extensions - }, - transform: { - '^.+\\.[jt]sx?$': [ - 'ts-jest', - { - useESM: true, - tsconfig: 'tsconfig.json', - }, - ], - }, - extensionsToTreatAsEsm: ['.ts'], -}; - -export default config; diff --git a/packages/nodejs/package.json b/packages/nodejs/package.json deleted file mode 100644 index 157992838..000000000 --- a/packages/nodejs/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@concordium/node-sdk", - "version": "9.4.0", - "description": "Helpers for interacting with the Concordium node", - "repository": { - "type": "git", - "url": "https://github.com/Concordium/concordium-node-sdk-js", - "directory": "packages/nodejs" - }, - "author": { - "name": "Concordium Software", - "email": "support@concordium.software", - "url": "https://concordium.com" - }, - "license": "Apache-2.0", - "engines": { - "node": ">=14.16.0" - }, - "type": "module", - "exports": { - ".": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" - }, - "./*": { - "types": "./lib/pub/*.d.ts", - "default": "./lib/pub/*.js" - } - }, - "sideEffects": false, - "files": [ - "/lib/**/*" - ], - "devDependencies": { - "@noble/ed25519": "^1.7.1", - "@types/bs58check": "^2.1.0", - "@types/jest": "^26.0.23", - "@typescript-eslint/eslint-plugin": "^6.7.0", - "@typescript-eslint/parser": "^6.7.0", - "babel-jest": "^27.0.6", - "cross-env": "5.0.5", - "eslint": "^7.29.0", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-import": "^2.23.4", - "eslint-plugin-prettier": "^3.4.0", - "isomorphic-fetch": "^3.0.0", - "jest": "^29.6.2", - "lint-staged": "^12.0.2", - "prettier": "^2.3.2", - "rimraf": "^5.0.1", - "ts-jest": "^29.1.1", - "typescript": "^5.2.2" - }, - "prettier": { - "singleQuote": true, - "tabWidth": 4 - }, - "scripts": { - "lint": "eslint . --cache --ext .ts,.tsx --max-warnings 0", - "lint-fix": "yarn --silent lint --fix; exit 0", - "test": "jest", - "build": "tsc -p tsconfig.build.json", - "clean": "rimraf -- lib tsconfig.build.tsbuildinfo" - }, - "dependencies": { - "@concordium/common-sdk": "9.4.0", - "@grpc/grpc-js": "^1.3.4", - "@protobuf-ts/grpc-transport": "^2.8.2" - } -} diff --git a/packages/nodejs/src/clientV2.ts b/packages/nodejs/src/clientV2.ts deleted file mode 100644 index 231ea5540..000000000 --- a/packages/nodejs/src/clientV2.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ChannelCredentials } from '@grpc/grpc-js'; -import { GrpcOptions, GrpcTransport } from '@protobuf-ts/grpc-transport'; -import { ConcordiumGRPCClient } from '@concordium/common-sdk/grpc'; - -/** - * Initialize a gRPC client for a specific concordium node. - * @param address the ip address of the node, e.g. http://127.0.0.1 - * @param port the port to use when econnecting to the node - * @param credentials channel credentials for communicating with the node - * @param options optional options for the grpc transport - */ -export function createConcordiumClient( - address: string, - port: number, - credentials: ChannelCredentials, - options?: Partial -): ConcordiumGRPCClient { - const grpcTransport = new GrpcTransport({ - host: `${address}:${port}`, - channelCredentials: credentials, - ...options, - }); - return new ConcordiumGRPCClient(grpcTransport); -} diff --git a/packages/nodejs/src/index.ts b/packages/nodejs/src/index.ts deleted file mode 100644 index 6d45c3035..000000000 --- a/packages/nodejs/src/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './pub/types.js'; -export * from './pub/schema.js'; -export * from './pub/wasm.js'; -export * from './pub/id.js'; -export * from './pub/grpc.js'; -export * from './pub/cis0.js'; -export * from './pub/cis2.js'; -export * from './pub/cis4.js'; -export * from './pub/web3-id.js'; diff --git a/packages/nodejs/src/pub/cis0.ts b/packages/nodejs/src/pub/cis0.ts deleted file mode 100644 index a15f13bab..000000000 --- a/packages/nodejs/src/pub/cis0.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@concordium/common-sdk/cis0'; diff --git a/packages/nodejs/src/pub/cis2.ts b/packages/nodejs/src/pub/cis2.ts deleted file mode 100644 index 54555ba25..000000000 --- a/packages/nodejs/src/pub/cis2.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@concordium/common-sdk/cis2'; diff --git a/packages/nodejs/src/pub/cis4.ts b/packages/nodejs/src/pub/cis4.ts deleted file mode 100644 index 2804bf8aa..000000000 --- a/packages/nodejs/src/pub/cis4.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@concordium/common-sdk/cis4'; diff --git a/packages/nodejs/src/pub/grpc.ts b/packages/nodejs/src/pub/grpc.ts deleted file mode 100644 index 700efe104..000000000 --- a/packages/nodejs/src/pub/grpc.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '../clientV2.js'; diff --git a/packages/nodejs/src/pub/id.ts b/packages/nodejs/src/pub/id.ts deleted file mode 100644 index ac86f398c..000000000 --- a/packages/nodejs/src/pub/id.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@concordium/common-sdk/id'; diff --git a/packages/nodejs/src/pub/schema.ts b/packages/nodejs/src/pub/schema.ts deleted file mode 100644 index df93faf14..000000000 --- a/packages/nodejs/src/pub/schema.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@concordium/common-sdk/schema'; diff --git a/packages/nodejs/src/pub/types.ts b/packages/nodejs/src/pub/types.ts deleted file mode 100644 index 0d94fd244..000000000 --- a/packages/nodejs/src/pub/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { decryptMobileWalletExport, EncryptedData } from '../wallet/crypto.js'; -export { MobileWalletExport } from '../wallet/types.js'; -export { getModuleBuffer } from '../util.js'; - -export * from '@concordium/common-sdk/types'; diff --git a/packages/nodejs/src/pub/wasm.ts b/packages/nodejs/src/pub/wasm.ts deleted file mode 100644 index cfa2cd663..000000000 --- a/packages/nodejs/src/pub/wasm.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@concordium/common-sdk/wasm'; diff --git a/packages/nodejs/src/pub/web3-id.ts b/packages/nodejs/src/pub/web3-id.ts deleted file mode 100644 index 26a610d1d..000000000 --- a/packages/nodejs/src/pub/web3-id.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@concordium/common-sdk/web3-id'; diff --git a/packages/nodejs/tsconfig.build.json b/packages/nodejs/tsconfig.build.json deleted file mode 100644 index 209459b3e..000000000 --- a/packages/nodejs/tsconfig.build.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": [ - "src/**/*" - ], - "compilerOptions": { - "rootDir": "src", - "outDir": "./lib" - } -} diff --git a/packages/nodejs/tsconfig.json b/packages/nodejs/tsconfig.json deleted file mode 100644 index e61089d57..000000000 --- a/packages/nodejs/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig-base.json", - "include": [ - "src/**/*", - "test/**/*", - "jest.config.ts" - ], - "compilerOptions": { - "module": "Node16", - "moduleResolution": "Node16" - }, - "references": [ - { - "path": "../common" - } - ] -} diff --git a/packages/rust-bindings/package.json b/packages/rust-bindings/package.json index b641f4ea1..8b5609e76 100644 --- a/packages/rust-bindings/package.json +++ b/packages/rust-bindings/package.json @@ -19,19 +19,43 @@ "types": "./lib/dapp/node/index.d.ts", "exports": { ".": { - "types": "./lib/dapp/node/index.d.ts", - "node": "./lib/dapp/node/index.js", - "default": "./lib/dapp/web/index.min.js" + "types": "./lib/dapp/node/cjs/index.d.ts", + "node": { + "module": "./lib/dapp/node/umd/index.min.js", + "default": "./lib/dapp/node/cjs/index.js" + }, + "browser": { + "module": "./lib/dapp/web/umd/index.min.js", + "types": "./lib/dapp/web/esm/index.d.ts", + "import": "./lib/dapp/web/esm/index.js" + }, + "default": "./lib/dapp/web/umd/index.min.js" }, "./dapp": { - "types": "./lib/dapp/node/index.d.ts", - "node": "./lib/dapp/node/index.js", - "default": "./lib/dapp/web/index.min.js" + "types": "./lib/dapp/node/cjs/index.d.ts", + "node": { + "module": "./lib/dapp/node/umd/index.min.js", + "default": "./lib/dapp/node/cjs/index.js" + }, + "browser": { + "module": "./lib/dapp/web/umd/index.min.js", + "types": "./lib/dapp/web/esm/index.d.ts", + "import": "./lib/dapp/web/esm/index.js" + }, + "default": "./lib/dapp/web/umd/index.min.js" }, "./wallet": { - "types": "./lib/wallet/node/index.d.ts", - "node": "./lib/wallet/node/index.js", - "default": "./lib/wallet/web/index.min.js" + "types": "./lib/wallet/node/cjs/index.d.ts", + "node": { + "module": "./lib/wallet/node/umd/index.min.js", + "default": "./lib/wallet/node/cjs/index.js" + }, + "browser": { + "module": "./lib/wallet/web/umd/index.min.js", + "types": "./lib/wallet/web/esm/index.d.ts", + "import": "./lib/wallet/web/esm/index.js" + }, + "default": "./lib/wallet/web/umd/index.min.js" }, "./bundler": { "types": "./lib/dapp/bundler/index.d.ts", @@ -52,19 +76,20 @@ "scripts": { "fmt": "cargo +nightly-2023-04-01-x86_64-unknown-linux-gnu fmt -- --color=always --check", "clippy": "cargo +1.62 clippy --color=always --tests --benches -- -Dclippy::all", - "build-web": "wasm-pack build ./packages/dapp --target web --out-dir $INIT_CWD/pkg/dapp/web --out-name index \"$@\" && wasm-pack build ./packages/wallet --target web --out-dir $INIT_CWD/pkg/wallet/web --out-name index \"$@\" && webpack", - "build-node": "wasm-pack build ./packages/dapp --target nodejs --out-dir $INIT_CWD/lib/dapp/node --out-name index \"$@\" && wasm-pack build ./packages/wallet --target nodejs --out-dir $INIT_CWD/lib/wallet/node --out-name index \"$@\"", + "build-web": "wasm-pack build ./packages/dapp --target web --out-dir $INIT_CWD/lib/dapp/web/esm --out-name index \"$@\" && wasm-pack build ./packages/wallet --target web --out-dir $INIT_CWD/lib/wallet/web/esm --out-name index \"$@\" && webpack", + "build-node": "wasm-pack build ./packages/dapp --target nodejs --out-dir $INIT_CWD/lib/dapp/node/cjs --out-name index \"$@\" && wasm-pack build ./packages/wallet --target nodejs --out-dir $INIT_CWD/lib/wallet/node/cjs --out-name index \"$@\"", "build-bundler": "wasm-pack build ./packages/dapp --target bundler --out-dir $INIT_CWD/lib/dapp/bundler --out-name index \"$@\" && wasm-pack build ./packages/wallet --target bundler --out-dir $INIT_CWD/lib/wallet/bundler --out-name index \"$@\"", "build": "yarn build-node \"$@\" && yarn build-bundler \"$@\" && yarn build-web \"$@\"", "build:rust-bindings": "yarn build", - "clean": "rimraf -- target pkg lib .webpack-cache" + "clean": "rimraf -- target lib .webpack-cache" }, "devDependencies": { "rimraf": "^5.0.1", "ts-loader": "^9.4.4", "typescript": "^5.2.2", "wasm-pack": "^0.12.1", - "webpack": "^5.88.2" + "webpack": "^5.88.2", + "webpack-cli": "^5.1.4" }, "dependencies": { "buffer": "^6.0.3" diff --git a/packages/rust-bindings/ts-src/dapp.ts b/packages/rust-bindings/ts-src/dapp.ts index c6cc17d87..20183aae0 100644 --- a/packages/rust-bindings/ts-src/dapp.ts +++ b/packages/rust-bindings/ts-src/dapp.ts @@ -1,9 +1,9 @@ import { Buffer } from 'buffer/index.js'; -import { initSync } from '../pkg/dapp/web'; -import wasmBase64 from '../pkg/dapp/web/index_bg.wasm'; // Expected to resolve to base64 encoded bytes of wasm module +import { initSync } from '../lib/dapp/web/esm'; +import wasmBase64 from '../lib/dapp/web/esm/index_bg.wasm'; // Expected to resolve to base64 encoded bytes of wasm module const bytes = Buffer.from(wasmBase64 as unknown as string, 'base64'); initSync(bytes); -export * from '../pkg/dapp/web'; +export * from '../lib/dapp/web/esm'; diff --git a/packages/rust-bindings/ts-src/wallet.ts b/packages/rust-bindings/ts-src/wallet.ts index 7a2baf454..cd14edbde 100644 --- a/packages/rust-bindings/ts-src/wallet.ts +++ b/packages/rust-bindings/ts-src/wallet.ts @@ -1,9 +1,9 @@ import { Buffer } from 'buffer/index.js'; -import { initSync } from '../pkg/wallet/web'; -import wasmBase64 from '../pkg/wallet/web/index_bg.wasm'; // Expected to resolve to base64 encoded bytes of wasm module +import { initSync } from '../lib/wallet/web/esm'; +import wasmBase64 from '../lib/wallet/web/esm/index_bg.wasm'; // Expected to resolve to base64 encoded bytes of wasm module const bytes = Buffer.from(wasmBase64 as unknown as string, 'base64'); initSync(bytes); -export * from '../pkg/wallet/web'; +export * from '../lib/wallet/web/esm'; diff --git a/packages/rust-bindings/webpack.config.ts b/packages/rust-bindings/webpack.config.ts index f69207152..3805e887f 100644 --- a/packages/rust-bindings/webpack.config.ts +++ b/packages/rust-bindings/webpack.config.ts @@ -1,55 +1,56 @@ /* eslint-disable import/no-extraneous-dependencies */ -import { Configuration, SourceMapDevToolPlugin } from 'webpack'; +import { Configuration } from 'webpack'; import { resolve } from 'path'; -const config: Configuration = { - mode: 'production', - cache: { - type: 'filesystem', - cacheDirectory: resolve(__dirname, '.webpack-cache'), - }, - entry: { - dapp: resolve(__dirname, './ts-src/dapp.ts'), - wallet: resolve(__dirname, './ts-src/wallet.ts'), - }, - plugins: [ - new SourceMapDevToolPlugin({ - filename: '[file].map', - }), - ], - resolve: { - extensionAlias: { - '.js': ['.ts', '.js'], +function configForTarget(target: 'web' | 'node'): Configuration { + return { + mode: 'production', + cache: { + type: 'filesystem', + cacheDirectory: resolve(__dirname, '.webpack-cache'), }, - extensions: ['.tsx', '.ts', '.js'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: { - loader: 'ts-loader', - options: { - configFile: resolve(__dirname, './tsconfig.build.json'), + target, + entry: { + dapp: resolve(__dirname, './ts-src/dapp.ts'), + wallet: resolve(__dirname, './ts-src/wallet.ts'), + }, + resolve: { + extensionAlias: { + '.js': ['.ts', '.js'], + }, + extensions: ['.tsx', '.ts', '.js'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: { + loader: 'ts-loader', + options: { + configFile: resolve( + __dirname, + './tsconfig.build.json' + ), + }, }, + exclude: /node_modules/, }, - exclude: /node_modules/, - }, - { - test: /\.wasm$/, - type: 'asset/inline', - generator: { - dataUrl: (data: Buffer) => data.toString('base64'), + { + test: /\.wasm$/, + type: 'asset/inline', + generator: { + dataUrl: (data: Buffer) => data.toString('base64'), + }, }, - }, - ], - }, - output: { - filename: '[name]/web/index.min.js', - path: resolve(__dirname, 'lib'), - libraryTarget: 'umd', - publicPath: '', - }, -}; + ], + }, + output: { + filename: `[name]/${target}/umd/index.min.js`, + path: resolve(__dirname, 'lib'), + libraryTarget: 'umd', + publicPath: '', + }, + }; +} -export default config; +export default [configForTarget('web'), configForTarget('node')]; diff --git a/packages/common/CHANGELOG.md b/packages/sdk/CHANGELOG.md similarity index 97% rename from packages/common/CHANGELOG.md rename to packages/sdk/CHANGELOG.md index b499b69e0..6a968ad72 100644 --- a/packages/common/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -84,7 +84,7 @@ Several types have been replaced with a module containing the type itself togeth - `ElectionInfo` - Added type discriminator to different forms of `AccountInfo`. -## 9.4.0 +## 6.4.0 ### Added @@ -109,7 +109,7 @@ Several types have been replaced with a module containing the type itself togeth - Added missing fields to `getBlockChainParameters` response. (rootKeys, level1Keys, level2Keys) - Use of bigint exponentiation causing issues in web. -## 9.3.0 +## 6.3.0 ### Added @@ -120,13 +120,13 @@ Several types have been replaced with a module containing the type itself togeth - Stopped using `replaceDateWithTimeStampAttribute` and `reviveDateFromTimeStampAttribute` for serializing and parsing verifiable presentation. - AttributeType no longer contains `Date`, but now instead has `TimestampAttribute`. The statement builders have their types extended to keep allowing for both `Date` and `TimestampAttribute`. -## 9.2.1 +## 6.2.1 ### Fixed - Missing buffer import causing issues in web. -## 9.2.0 +## 6.2.0 ### Breaking changes @@ -143,14 +143,14 @@ Several types have been replaced with a module containing the type itself togeth - Aligned credential schema types with the tested types in the browser wallet. - `addMinimumAge` now creates the precise age statement instead of one day off. -## 9.1.1 +## 6.1.1 ### Fixes - `verifyWeb3IdCredentialSignature` now supports dates/timestamp attributes. - `canProveAtomicStatement` now supports timestamp attributes, handles undefined attribute value correctly and handles strings correctly for range statements. -## 9.1.0 +## 6.1.0 ### Added @@ -174,7 +174,7 @@ All function parameters now also accepts strings, these strings can use comma as - The max smart contract parameter length was changed to 65535 bytes in protocol version 5 and onwards. Functions which checks the parameter length will now reflect that. -## 9.0.0 +## 6.0.0 ### Breaking changes @@ -189,7 +189,7 @@ All function parameters now also accepts strings, these strings can use comma as - `getTransactionKindString` function. - `displayTypeSchemaTemplate` function. -## 8.0.0 +## 5.0.0 ### Breaking changes @@ -229,13 +229,13 @@ All function parameters now also accepts strings, these strings can use comma as - `serializeUpdateContractParameters` - `serializeTypeValue` -## 7.0.1 2023-05-25 +## 4.0.1 2023-05-25 ### Fixed - Cost calculation for `deployModule` transaction. -## 7.0.0 2023-05-15 +## 4.0.0 2023-05-15 ### Breaking changes @@ -272,7 +272,7 @@ All function parameters now also accepts strings, these strings can use comma as - Bumped @concordium/rust-bindings to 0.12.0. (Adds key derivation for verifiable credentials) -## 6.5.0 2023-5-03 +## 3.5.0 2023-5-03 ### Added @@ -290,20 +290,20 @@ All function parameters now also accepts strings, these strings can use comma as - Fixed bug where `AccountCreationSummary` type did not have fields: `index`, `energyCost`, `hash` -## 6.4.2 2023-04-21 +## 3.4.2 2023-04-21 ### Changed - `generateBakerKeys` now also returns the private baker keys. -## 6.4.1 2023-03-31 +## 3.4.1 2023-03-31 ### Changed - Replace use of `setImmediate` with `setTimeout` since the former is not supported in browsers. -## 6.4.0 2023-03-22 +## 3.4.0 2023-03-22 ### Added @@ -318,7 +318,7 @@ All function parameters now also accepts strings, these strings can use comma as - `serializeTypeValue` now reports an error when called with invalid data, such as a receive function with missing schema, or a schema that cannot be parsed. -## 6.3.0 2023-02-27 +## 3.3.0 2023-02-27 ### Added @@ -351,7 +351,7 @@ All function parameters now also accepts strings, these strings can use comma as - 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 +## 3.2.0 2023-01-04 ### Added @@ -359,7 +359,7 @@ All function parameters now also accepts strings, these strings can use comma as - `getInitContractParameterSchema` Given a buffer containing the schema for a module, extract the schema for a given contract's init function's parameters. - `getReceiveContractParameterSchema` Given a buffer containing the schema for a module, extract the schema for a given contract's receive methods' parameters. -## 6.1.0 2022-11-30 +## 3.1.0 2022-11-30 ### Added @@ -368,7 +368,7 @@ All function parameters now also accepts strings, these strings can use comma as - `getIdProof` function to prove a statement holds for the given identity/account. - Enums for sex and idDocType values. -## 6.0.0 2022-11-15 +## 3.0.0 2022-11-15 ### Breaking changes @@ -382,13 +382,13 @@ All function parameters now also accepts strings, these strings can use comma as - The ability to deserialize error values of receive and init functions using `deserializeReceiveError()` and `deserializeInitError()` respectfully. - Refactored the `upserializeUpdateContractParameters()` and `serializeInitContractParameters()` to call into rust functions. -## 5.2.0 2022-11-8 +## 2.2.0 2022-11-8 ### Added - The ability to deserialize the return values of receive functions using `deserializeReceiveReturnValue()`. -## 5.1.0 2022-9-29 +## 2.1.0 2022-9-29 ### Added @@ -398,7 +398,7 @@ All function parameters now also accepts strings, these strings can use comma as - getAccountInfo no longer relies on instanceof to determine the type of input. -## 5.0.0 2022-9-29 +## 2.0.0 2022-9-29 ### Added @@ -408,7 +408,7 @@ All function parameters now also accepts strings, these strings can use comma as - Updated the signature of helper functions for accounts to sign messages. (and changed the prepend) -## 4.0.0 2022-8-26 +## 1.0.0 2022-8-26 ### Breaking changes @@ -419,7 +419,7 @@ All function parameters now also accepts strings, these strings can use comma as - Added missing `accountAddress` field to `AccountInfo` types. -## 3.0.0 2022-8-26 +## 0.5.0 2022-8-26 ### Added @@ -429,10 +429,11 @@ All function parameters now also accepts strings, these strings can use comma as - SchemaVersion, Module, and schema types are now 0-indexed instead of 1-indexed. This means that the schemas used for V0 contracts are now version 0, and so is the associated types. And the first schema version for V1 contracts are now version 1. -## 2.4.0 2022-8-15 +## 0.4.0 2022-8-15 ### Added +- `deserializeTransaction` function to deserialize transaction created by `serializeAccountTransactionForSubmission` and `serializeCredentialDeploymentTransactionForSubmission`. (Currently SimpleTransfer, SimpleTransferWithMemo and RegisterData are the only supported account transactions kinds) - `createIdentityRequest`, to create identity requests. - `createCredentialV1`, to create credentials using a seedPhrase. - `createIdentityRecoveryRequest`, to create identity recovery requests. @@ -441,54 +442,34 @@ All function parameters now also accepts strings, these strings can use comma as - Added `ConfigureBaker` to `AccountTransactionType` enum. - Added `ConcordiumHdWallet` with functions to get keys and randomness from a seed phrase. -## 2.3.2 2022-7-26 - ### Fixed - `deserializeTransaction` no longer throws an error on expired transactions. - -## 2.3.1 2022-7-26 - -### Fixed - - `deserializeTransaction` is now exported from index. -## 2.3.0 2022-7-25 - -### Added - -- `deserializeTransaction` function to deserialize transaction created by `serializeAccountTransactionForSubmission` and `serializeCredentialDeploymentTransactionForSubmission`. (Currently SimpleTransfer, SimpleTransferWithMemo and RegisterData are the only supported account transactions kinds) - -## 2.2.0 2022-7-21 +## 0.3.0 2022-7-21 ### Added +- Support deserializing new schema types: ULeb128, ILeb128, ByteArray and ByteList. +- Support deserializing schemas with versioning information. - Add support for getAccountInfo, InvokeContract, getCryptographicParameters and getModuleSource with JSON-RPC -## 2.1.1 2022-7-8 - ### Fixed - Fixed contract schema serialization for ByteList -## 2.1.0 2022-7-5 - -### Added - -- Support deserializing new schema types: ULeb128, ILeb128, ByteArray and ByteList. -- Support deserializing schemas with versioning information. - ### Changes - The function for deserializing a module schema `deserialModuleFromBuffer` now have the schema version as an optional argument. The function will try to extract the version from the buffer. When a version is provided it falls back to this, otherwise it throws an error. -## 2.0.1 2022-6-27 +## 0.2.1 2022-6-27 ### Fixed - @noble/ed25519 and cross-fetch moved from devDependencies to dependencies. -## 2.0.0 2022-6-24 +## 0.2.0 2022-6-24 ### Added @@ -501,7 +482,7 @@ All function parameters now also accepts strings, these strings can use comma as - `serializeInitContractParameters` and `serializeUpdateContractParameters` each have an additional parameter, which denotes the version of the schema provided. For existing users that are using V0 contracts, that parameter should be `SchemaVersion.V1`. - Deserialization of schemas have been changed: types and functions have been renamed and `deserialModuleFromBuffer` have an additional parameter. -## 1.0.1 2022-6-2 +## 0.1.1 2022-6-2 ### Fixed @@ -509,6 +490,6 @@ All function parameters now also accepts strings, these strings can use comma as (And update the format of the arguments for the server) - Fixed issue by bumping rust bindings version -## 1.0.0 2022-5-25 +## 0.1.0 2022-5-25 - Initial release diff --git a/packages/sdk/README.md b/packages/sdk/README.md new file mode 100644 index 000000000..860215d58 --- /dev/null +++ b/packages/sdk/README.md @@ -0,0 +1,70 @@ +# concordium-web-sdk + +[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](https://github.com/Concordium/.github/blob/main/.github/CODE_OF_CONDUCT.md) + +Wrappers for interacting with the Concordium node, for the web environment. + +Please see the +[documentation](https://developer.concordium.software/concordium-node-sdk-js/index.html) +for more information + +**Table of Contents:** + + +- [concordium-web-sdk](#concordium-web-sdk) + - [ConcordiumGRPCWebClient](#concordiumgrpcwebclient) + - [ConcordiumGRPCNodeClient](#concordiumgrpcnodeclient) + + +## ConcordiumGRPCWebClient + +The SDK provides a gRPC client, which can interact with the [Concordium +Node](https://github.com/Concordium/concordium-node) using gRPC-web. + +For an overview of the endpoints, [click +here](https://developer.concordium.software/concordium-node-sdk-js/classes/grpc.ConcordiumGRPCClient.html). + +To create a client, the `ConcordiumGRPCWebClient` class can be used. It +requires the address and port of the concordium node. + +```ts +import { ConcordiumGRPCWebClient } from '@concordium/web-sdk'; +... +return new ConcordiumGRPCWebClient( + address, + port, + { timeout: 15000 } +); +``` + +The fourth 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). + +## ConcordiumGRPCNodeClient + +_Note that this can ONLY be used in a nodeJS environment_ + +The SDK provides a gRPC client, which can interact with the [Concordium +Node](https://github.com/Concordium/concordium-node) using gRPC. + +For an overview of the endpoints, [click +here](https://developer.concordium.software/concordium-node-sdk-js/classes/grpc.ConcordiumGRPCClient.html). + +To create a client, the `ConcordiumGRPCNodeClient` class can be used. It +requires the address and port of the concordium node. + +```ts +import { ConcordiumGRPCNodeClient, credentials } from '@concordium/web-sdk/nodejs'; +... +const creds = ...; // e.g. credentias.createInsecure(); +return new ConcordiumGRPCWebClient( + address, + port, + creds, + { timeout: 15000 } +); +``` + +Like with the grpc web client, the fourth argument is additional options. diff --git a/packages/common/jest.config.ts b/packages/sdk/jest.config.ts similarity index 100% rename from packages/common/jest.config.ts rename to packages/sdk/jest.config.ts diff --git a/packages/common/package.json b/packages/sdk/package.json similarity index 56% rename from packages/common/package.json rename to packages/sdk/package.json index a790b4037..1875b273b 100644 --- a/packages/common/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { - "name": "@concordium/common-sdk", - "version": "9.4.0", + "name": "@concordium/web-sdk", + "version": "6.4.0", "license": "Apache-2.0", "engines": { "node": ">=14.16.0" @@ -12,18 +12,31 @@ }, "sideEffects": false, "type": "module", + "main": "./lib/umd/concordium.min.js", + "cdn": "./lib/umd/concordium.min.js", + "types": "./lib/esm/index.d.ts", "exports": { ".": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" + "types": "./lib/esm/index.d.ts", + "bun": "./src/index.ts", + "default": "./lib/esm/index.js" + }, + "./nodejs": { + "types": "./lib/esm/pub/nodejs.d.ts", + "bun": "./src/pub/nodejs.ts", + "node": "./lib/esm/pub/nodejs.js", + "browser": null }, "./*": { - "types": "./lib/pub/*.d.ts", - "default": "./lib/pub/*.js" + "types": "./lib/esm/pub/*.d.ts", + "bun": "./src/pub/*.ts", + "default": "./lib/esm/pub/*.js" } }, "files": [ - "/lib/**/*" + "/src/**/*", + "/lib/esm/**/*", + "/lib/umd/**/*" ], "devDependencies": { "@protobuf-ts/plugin": "^2.9.1", @@ -32,42 +45,39 @@ "@types/jest": "^26.0.23", "@types/json-bigint": "^1.0.1", "@types/uuid": "^8.3.4", - "@typescript-eslint/eslint-plugin": "^6.7.0", - "@typescript-eslint/parser": "^6.7.0", - "babel-jest": "^27.0.6", - "eslint": "^7.29.0", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-prettier": "^3.4.0", + "glob": "^10.3.10", "grpc-tools": "^1.11.2", "grpc_tools_node_protoc_ts": "5.3.0", - "husky": "^4.2.5", "jest": "^29.6.2", - "lint-staged": "^12.0.2", - "prettier": "^2.3.2", "rimraf": "^5.0.1", "ts-jest": "^29.1.1", - "typescript": "^5.2.2" + "typescript": "^5.2.2", + "webpack": "^5.88.2", + "webpack-cli": "^5.1.4" }, "scripts": { "generate-ts-v2": "yarn run grpc_tools_node_protoc --plugin=protoc-gen-ts=../../node_modules/@protobuf-ts/plugin/bin/protoc-gen-ts --ts_opt 'optimize_code_size' --ts_out=src/grpc-api -I ../../deps/concordium-base/concordium-grpc-api ../../deps/concordium-base/concordium-grpc-api/v2/concordium/*.proto", - "generate": "([ -e \"../../deps/concordium-base/concordium-grpc-api\" ] && yarn generate-ts-v2 && node ../../scripts/proto-node-esm-compat.js src/grpc-api) || echo 'Please checkout submodules before building'", + "generate": "([ -e \"../../deps/concordium-base/concordium-grpc-api\" ] && yarn generate-ts-v2 && node scripts/proto-node-esm-compat.js src/grpc-api) || echo 'Please checkout submodules before building'", "lint": "eslint . --cache --ext .ts,.tsx --max-warnings 0", "lint-fix": "yarn --silent lint --fix; exit 0", "test": "jest", + "test-ci": "yarn test ./test/ci", "build": "yarn clean; mkdir -p src/grpc-api; yarn generate && yarn build-dev", - "build-dev": "tsc -p tsconfig.build.json", - "clean": "rimraf -- lib src/grpc-api tsconfig.build.tsbuildinfo" + "build-dev": "tsc -p tsconfig.build.json && yarn webpack", + "webpack": "node --loader ts-node/esm ../../node_modules/.bin/webpack --config webpack.config.ts", + "clean": "rimraf -- lib src/grpc-api" }, "dependencies": { "@concordium/rust-bindings": "1.2.0", - "@grpc/grpc-js": "^1.3.4", + "@grpc/grpc-js": "^1.9.4", "@noble/ed25519": "^1.7.1", + "@protobuf-ts/grpc-transport": "^2.9.1", + "@protobuf-ts/grpcweb-transport": "^2.9.1", "@protobuf-ts/runtime-rpc": "^2.8.2", "@scure/bip39": "^1.1.0", "big.js": "^6.2.0", - "bs58check": "^2.1.2", + "bs58check": "^3.0.1", "buffer": "^6.0.3", - "cross-fetch": "3.1.5", "hash.js": "^1.1.7", "iso-3166-1": "^2.1.1", "json-bigint": "^1.0.0", diff --git a/scripts/proto-node-esm-compat.js b/packages/sdk/scripts/proto-node-esm-compat.js similarity index 100% rename from scripts/proto-node-esm-compat.js rename to packages/sdk/scripts/proto-node-esm-compat.js diff --git a/packages/common/src/GenericContract.ts b/packages/sdk/src/GenericContract.ts similarity index 100% rename from packages/common/src/GenericContract.ts rename to packages/sdk/src/GenericContract.ts diff --git a/packages/common/src/accountHelpers.ts b/packages/sdk/src/accountHelpers.ts similarity index 100% rename from packages/common/src/accountHelpers.ts rename to packages/sdk/src/accountHelpers.ts diff --git a/packages/common/src/accountTransactions.ts b/packages/sdk/src/accountTransactions.ts similarity index 100% rename from packages/common/src/accountTransactions.ts rename to packages/sdk/src/accountTransactions.ts diff --git a/packages/common/src/cis0.ts b/packages/sdk/src/cis0.ts similarity index 100% rename from packages/common/src/cis0.ts rename to packages/sdk/src/cis0.ts diff --git a/packages/common/src/cis2/CIS2Contract.ts b/packages/sdk/src/cis2/CIS2Contract.ts similarity index 100% rename from packages/common/src/cis2/CIS2Contract.ts rename to packages/sdk/src/cis2/CIS2Contract.ts diff --git a/packages/common/src/cis2/index.ts b/packages/sdk/src/cis2/index.ts similarity index 100% rename from packages/common/src/cis2/index.ts rename to packages/sdk/src/cis2/index.ts diff --git a/packages/common/src/cis2/util.ts b/packages/sdk/src/cis2/util.ts similarity index 100% rename from packages/common/src/cis2/util.ts rename to packages/sdk/src/cis2/util.ts diff --git a/packages/common/src/cis4/CIS4Contract.ts b/packages/sdk/src/cis4/CIS4Contract.ts similarity index 100% rename from packages/common/src/cis4/CIS4Contract.ts rename to packages/sdk/src/cis4/CIS4Contract.ts diff --git a/packages/common/src/cis4/index.ts b/packages/sdk/src/cis4/index.ts similarity index 100% rename from packages/common/src/cis4/index.ts rename to packages/sdk/src/cis4/index.ts diff --git a/packages/common/src/cis4/util.ts b/packages/sdk/src/cis4/util.ts similarity index 100% rename from packages/common/src/cis4/util.ts rename to packages/sdk/src/cis4/util.ts diff --git a/packages/common/src/commonProofTypes.ts b/packages/sdk/src/commonProofTypes.ts similarity index 100% rename from packages/common/src/commonProofTypes.ts rename to packages/sdk/src/commonProofTypes.ts diff --git a/packages/common/src/constants.ts b/packages/sdk/src/constants.ts similarity index 100% rename from packages/common/src/constants.ts rename to packages/sdk/src/constants.ts diff --git a/packages/common/src/contractHelpers.ts b/packages/sdk/src/contractHelpers.ts similarity index 100% rename from packages/common/src/contractHelpers.ts rename to packages/sdk/src/contractHelpers.ts diff --git a/packages/common/src/deserialization.ts b/packages/sdk/src/deserialization.ts similarity index 100% rename from packages/common/src/deserialization.ts rename to packages/sdk/src/deserialization.ts diff --git a/packages/common/src/deserializationHelpers.ts b/packages/sdk/src/deserializationHelpers.ts similarity index 100% rename from packages/common/src/deserializationHelpers.ts rename to packages/sdk/src/deserializationHelpers.ts diff --git a/packages/common/src/energyCost.ts b/packages/sdk/src/energyCost.ts similarity index 100% rename from packages/common/src/energyCost.ts rename to packages/sdk/src/energyCost.ts diff --git a/packages/common/src/grpc/GRPCClient.ts b/packages/sdk/src/grpc/GRPCClient.ts similarity index 98% rename from packages/common/src/grpc/GRPCClient.ts rename to packages/sdk/src/grpc/GRPCClient.ts index e7c5dd478..0ca7db5c7 100644 --- a/packages/common/src/grpc/GRPCClient.ts +++ b/packages/sdk/src/grpc/GRPCClient.ts @@ -6,6 +6,10 @@ */ import { Buffer } from 'buffer/index.js'; import type { RpcError, RpcTransport } from '@protobuf-ts/runtime-rpc'; +import { + GrpcWebFetchTransport, + GrpcWebOptions, +} from '@protobuf-ts/grpcweb-transport'; import * as v1 from '../types.js'; import * as v2 from '../grpc-api/v2/concordium/types.js'; @@ -52,11 +56,9 @@ export type FindInstanceCreationReponse = { }; /** - * A concordium-node specific gRPC client wrapper. - * - * @example - * import { ConcordiumGRPCClient } from "..." - * const client = new ConcordiumGRPCClient('127.0.0.1', 20000, credentials, metadata, 15000); + * A concordium-node specific gRPC client wrapper. Only use this if you intend to supply a custom + * transport layer. Otherwise more user-friendly options {@linkcode ConcordiumGRPCWebClient} and + * `ConcordiumGRPCNodeClient` exist for web/nodejs use respectively. */ export class ConcordiumGRPCClient { client: QueriesClient; @@ -1590,6 +1592,28 @@ export function getAccountIdentifierInput( return { accountIdentifierInput: returnIdentifier }; } +/** + * A concordium-node specific gRPC client wrapper, using a grpc-web transport layer. + * This requires that the node at the address supplied has grpc-web enabled. + * + * @example + * import { ConcordiumGRPCWebClient } from "..." + * const client = new ConcordiumGRPCWebClient('127.0.0.1', 20000); + */ +export class ConcordiumGRPCWebClient extends ConcordiumGRPCClient { + constructor( + address: string, + port: number, + options?: Partial + ) { + const transport = new GrpcWebFetchTransport({ + baseUrl: `${address}:${port}`, + ...options, + }); + super(transport); + } +} + /** * @hidden */ diff --git a/packages/common/src/grpc/index.ts b/packages/sdk/src/grpc/index.ts similarity index 79% rename from packages/common/src/grpc/index.ts rename to packages/sdk/src/grpc/index.ts index 503dd857f..f4788b031 100644 --- a/packages/common/src/grpc/index.ts +++ b/packages/sdk/src/grpc/index.ts @@ -1,5 +1,6 @@ export { ConcordiumGRPCClient, + ConcordiumGRPCWebClient, getAccountIdentifierInput, getBlockHashInput, } from './GRPCClient.js'; diff --git a/packages/common/src/grpc/translation.ts b/packages/sdk/src/grpc/translation.ts similarity index 100% rename from packages/common/src/grpc/translation.ts rename to packages/sdk/src/grpc/translation.ts diff --git a/packages/common/src/hash.ts b/packages/sdk/src/hash.ts similarity index 100% rename from packages/common/src/hash.ts rename to packages/sdk/src/hash.ts diff --git a/packages/common/src/id/idProofTypes.ts b/packages/sdk/src/id/idProofTypes.ts similarity index 100% rename from packages/common/src/id/idProofTypes.ts rename to packages/sdk/src/id/idProofTypes.ts diff --git a/packages/common/src/id/idProofs.ts b/packages/sdk/src/id/idProofs.ts similarity index 100% rename from packages/common/src/id/idProofs.ts rename to packages/sdk/src/id/idProofs.ts diff --git a/packages/common/src/id/index.ts b/packages/sdk/src/id/index.ts similarity index 100% rename from packages/common/src/id/index.ts rename to packages/sdk/src/id/index.ts diff --git a/packages/common/src/index.ts b/packages/sdk/src/index.ts similarity index 100% rename from packages/common/src/index.ts rename to packages/sdk/src/index.ts diff --git a/packages/sdk/src/nodejs/grpc.ts b/packages/sdk/src/nodejs/grpc.ts new file mode 100644 index 000000000..22ea58e34 --- /dev/null +++ b/packages/sdk/src/nodejs/grpc.ts @@ -0,0 +1,38 @@ +import { ChannelCredentials } from '@grpc/grpc-js'; +import { GrpcOptions, GrpcTransport } from '@protobuf-ts/grpc-transport'; + +import { ConcordiumGRPCClient } from '../grpc/GRPCClient.js'; + +/** + * A concordium-node specific gRPC client wrapper. + * This will not work in a browser environment, in which case {@link ConcordiumGRPCWebClient} + * should be used instead. + * + * @example + * import { ConcordiumGRPCNodeClient } from "..." + * import { credentials } from '@grpc/grpc-js'; + * + * const creds = ...; // e.g. credentials.createInsecure(); + * const client = new ConcordiumGRPCClient('127.0.0.1', 20000, creds); + */ +export class ConcordiumGRPCNodeClient extends ConcordiumGRPCClient { + constructor( + address: string, + port: number, + credentials: ChannelCredentials, + options?: Partial + ) { + const transport = new GrpcTransport({ + host: `${address}:${port}`, + channelCredentials: credentials, + ...options, + }); + super(transport); + } +} + +export { + credentials, + ChannelCredentials, + CallCredentials, +} from '@grpc/grpc-js'; diff --git a/packages/sdk/src/nodejs/index.ts b/packages/sdk/src/nodejs/index.ts new file mode 100644 index 000000000..a59516ac9 --- /dev/null +++ b/packages/sdk/src/nodejs/index.ts @@ -0,0 +1,4 @@ +export * from './grpc.js'; +export * from './util.js'; +export { decryptMobileWalletExport, EncryptedData } from './wallet/crypto.js'; +export { MobileWalletExport } from './wallet/types.js'; diff --git a/packages/nodejs/src/util.ts b/packages/sdk/src/nodejs/util.ts similarity index 90% rename from packages/nodejs/src/util.ts rename to packages/sdk/src/nodejs/util.ts index ff8fa5069..324028e53 100644 --- a/packages/nodejs/src/util.ts +++ b/packages/sdk/src/nodejs/util.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs'; +import fs from 'node:fs'; /** * Loads the module as a buffer, given the given filePath. diff --git a/packages/nodejs/src/wallet/crypto.ts b/packages/sdk/src/nodejs/wallet/crypto.ts similarity index 100% rename from packages/nodejs/src/wallet/crypto.ts rename to packages/sdk/src/nodejs/wallet/crypto.ts diff --git a/packages/nodejs/src/wallet/types.ts b/packages/sdk/src/nodejs/wallet/types.ts similarity index 92% rename from packages/nodejs/src/wallet/types.ts rename to packages/sdk/src/nodejs/wallet/types.ts index fdec29701..deb44d050 100644 --- a/packages/nodejs/src/wallet/types.ts +++ b/packages/sdk/src/nodejs/wallet/types.ts @@ -1,4 +1,4 @@ -import { IdentityProvider, Versioned } from '@concordium/common-sdk'; +import { IdentityProvider, Versioned } from '../../types.js'; interface CredentialHolderInformation { idCredSecret: string; diff --git a/packages/common/src/overwrites.d.ts b/packages/sdk/src/overwrites.d.ts similarity index 100% rename from packages/common/src/overwrites.d.ts rename to packages/sdk/src/overwrites.d.ts diff --git a/packages/common/src/pub/cis0.ts b/packages/sdk/src/pub/cis0.ts similarity index 100% rename from packages/common/src/pub/cis0.ts rename to packages/sdk/src/pub/cis0.ts diff --git a/packages/common/src/pub/cis2.ts b/packages/sdk/src/pub/cis2.ts similarity index 100% rename from packages/common/src/pub/cis2.ts rename to packages/sdk/src/pub/cis2.ts diff --git a/packages/common/src/pub/cis4.ts b/packages/sdk/src/pub/cis4.ts similarity index 100% rename from packages/common/src/pub/cis4.ts rename to packages/sdk/src/pub/cis4.ts diff --git a/packages/common/src/pub/grpc.ts b/packages/sdk/src/pub/grpc.ts similarity index 100% rename from packages/common/src/pub/grpc.ts rename to packages/sdk/src/pub/grpc.ts diff --git a/packages/common/src/pub/id.ts b/packages/sdk/src/pub/id.ts similarity index 100% rename from packages/common/src/pub/id.ts rename to packages/sdk/src/pub/id.ts diff --git a/packages/sdk/src/pub/nodejs.ts b/packages/sdk/src/pub/nodejs.ts new file mode 100644 index 000000000..a60d4c108 --- /dev/null +++ b/packages/sdk/src/pub/nodejs.ts @@ -0,0 +1 @@ +export * from '../nodejs/index.js'; diff --git a/packages/common/src/pub/schema.ts b/packages/sdk/src/pub/schema.ts similarity index 100% rename from packages/common/src/pub/schema.ts rename to packages/sdk/src/pub/schema.ts diff --git a/packages/common/src/pub/types.ts b/packages/sdk/src/pub/types.ts similarity index 100% rename from packages/common/src/pub/types.ts rename to packages/sdk/src/pub/types.ts diff --git a/packages/sdk/src/pub/util.ts b/packages/sdk/src/pub/util.ts new file mode 100644 index 000000000..c5e58535f --- /dev/null +++ b/packages/sdk/src/pub/util.ts @@ -0,0 +1 @@ +export { toBuffer } from '../util.js'; diff --git a/packages/common/src/pub/wasm.ts b/packages/sdk/src/pub/wasm.ts similarity index 100% rename from packages/common/src/pub/wasm.ts rename to packages/sdk/src/pub/wasm.ts diff --git a/packages/common/src/pub/web3-id.ts b/packages/sdk/src/pub/web3-id.ts similarity index 100% rename from packages/common/src/pub/web3-id.ts rename to packages/sdk/src/pub/web3-id.ts diff --git a/packages/common/src/ratioHelpers.ts b/packages/sdk/src/ratioHelpers.ts similarity index 100% rename from packages/common/src/ratioHelpers.ts rename to packages/sdk/src/ratioHelpers.ts diff --git a/packages/common/src/schema.ts b/packages/sdk/src/schema.ts similarity index 100% rename from packages/common/src/schema.ts rename to packages/sdk/src/schema.ts diff --git a/packages/common/src/schemaTypes.ts b/packages/sdk/src/schemaTypes.ts similarity index 100% rename from packages/common/src/schemaTypes.ts rename to packages/sdk/src/schemaTypes.ts diff --git a/packages/common/src/serialization.ts b/packages/sdk/src/serialization.ts similarity index 100% rename from packages/common/src/serialization.ts rename to packages/sdk/src/serialization.ts diff --git a/packages/common/src/serializationHelpers.ts b/packages/sdk/src/serializationHelpers.ts similarity index 100% rename from packages/common/src/serializationHelpers.ts rename to packages/sdk/src/serializationHelpers.ts diff --git a/packages/common/src/signHelpers.ts b/packages/sdk/src/signHelpers.ts similarity index 100% rename from packages/common/src/signHelpers.ts rename to packages/sdk/src/signHelpers.ts diff --git a/packages/common/src/types.ts b/packages/sdk/src/types.ts similarity index 100% rename from packages/common/src/types.ts rename to packages/sdk/src/types.ts diff --git a/packages/common/src/types/AccountAddress.ts b/packages/sdk/src/types/AccountAddress.ts similarity index 100% rename from packages/common/src/types/AccountAddress.ts rename to packages/sdk/src/types/AccountAddress.ts diff --git a/packages/common/src/types/BlockHash.ts b/packages/sdk/src/types/BlockHash.ts similarity index 100% rename from packages/common/src/types/BlockHash.ts rename to packages/sdk/src/types/BlockHash.ts diff --git a/packages/common/src/types/BlockSpecialEvents.ts b/packages/sdk/src/types/BlockSpecialEvents.ts similarity index 100% rename from packages/common/src/types/BlockSpecialEvents.ts rename to packages/sdk/src/types/BlockSpecialEvents.ts diff --git a/packages/common/src/types/ContractAddress.ts b/packages/sdk/src/types/ContractAddress.ts similarity index 100% rename from packages/common/src/types/ContractAddress.ts rename to packages/sdk/src/types/ContractAddress.ts diff --git a/packages/common/src/types/ContractName.ts b/packages/sdk/src/types/ContractName.ts similarity index 100% rename from packages/common/src/types/ContractName.ts rename to packages/sdk/src/types/ContractName.ts diff --git a/packages/common/src/types/CredentialRegistrationId.ts b/packages/sdk/src/types/CredentialRegistrationId.ts similarity index 100% rename from packages/common/src/types/CredentialRegistrationId.ts rename to packages/sdk/src/types/CredentialRegistrationId.ts diff --git a/packages/common/src/types/DataBlob.ts b/packages/sdk/src/types/DataBlob.ts similarity index 100% rename from packages/common/src/types/DataBlob.ts rename to packages/sdk/src/types/DataBlob.ts diff --git a/packages/common/src/types/Duration.ts b/packages/sdk/src/types/Duration.ts similarity index 100% rename from packages/common/src/types/Duration.ts rename to packages/sdk/src/types/Duration.ts diff --git a/packages/common/src/types/Energy.ts b/packages/sdk/src/types/Energy.ts similarity index 100% rename from packages/common/src/types/Energy.ts rename to packages/sdk/src/types/Energy.ts diff --git a/packages/common/src/types/EntrypointName.ts b/packages/sdk/src/types/EntrypointName.ts similarity index 100% rename from packages/common/src/types/EntrypointName.ts rename to packages/sdk/src/types/EntrypointName.ts diff --git a/packages/common/src/types/InitName.ts b/packages/sdk/src/types/InitName.ts similarity index 100% rename from packages/common/src/types/InitName.ts rename to packages/sdk/src/types/InitName.ts diff --git a/packages/common/src/types/ModuleClient.ts b/packages/sdk/src/types/ModuleClient.ts similarity index 100% rename from packages/common/src/types/ModuleClient.ts rename to packages/sdk/src/types/ModuleClient.ts diff --git a/packages/common/src/types/NodeInfo.ts b/packages/sdk/src/types/NodeInfo.ts similarity index 100% rename from packages/common/src/types/NodeInfo.ts rename to packages/sdk/src/types/NodeInfo.ts diff --git a/packages/common/src/types/Parameter.ts b/packages/sdk/src/types/Parameter.ts similarity index 100% rename from packages/common/src/types/Parameter.ts rename to packages/sdk/src/types/Parameter.ts diff --git a/packages/common/src/types/PeerInfo.ts b/packages/sdk/src/types/PeerInfo.ts similarity index 100% rename from packages/common/src/types/PeerInfo.ts rename to packages/sdk/src/types/PeerInfo.ts diff --git a/packages/common/src/types/ReceiveName.ts b/packages/sdk/src/types/ReceiveName.ts similarity index 100% rename from packages/common/src/types/ReceiveName.ts rename to packages/sdk/src/types/ReceiveName.ts diff --git a/packages/common/src/types/ReturnValue.ts b/packages/sdk/src/types/ReturnValue.ts similarity index 100% rename from packages/common/src/types/ReturnValue.ts rename to packages/sdk/src/types/ReturnValue.ts diff --git a/packages/common/src/types/SequenceNumber.ts b/packages/sdk/src/types/SequenceNumber.ts similarity index 100% rename from packages/common/src/types/SequenceNumber.ts rename to packages/sdk/src/types/SequenceNumber.ts diff --git a/packages/common/src/types/Timestamp.ts b/packages/sdk/src/types/Timestamp.ts similarity index 100% rename from packages/common/src/types/Timestamp.ts rename to packages/sdk/src/types/Timestamp.ts diff --git a/packages/common/src/types/TransactionHash.ts b/packages/sdk/src/types/TransactionHash.ts similarity index 100% rename from packages/common/src/types/TransactionHash.ts rename to packages/sdk/src/types/TransactionHash.ts diff --git a/packages/common/src/types/VerifiablePresentation.ts b/packages/sdk/src/types/VerifiablePresentation.ts similarity index 100% rename from packages/common/src/types/VerifiablePresentation.ts rename to packages/sdk/src/types/VerifiablePresentation.ts diff --git a/packages/common/src/types/VersionedModuleSource.ts b/packages/sdk/src/types/VersionedModuleSource.ts similarity index 100% rename from packages/common/src/types/VersionedModuleSource.ts rename to packages/sdk/src/types/VersionedModuleSource.ts diff --git a/packages/common/src/types/blockItemSummary.ts b/packages/sdk/src/types/blockItemSummary.ts similarity index 100% rename from packages/common/src/types/blockItemSummary.ts rename to packages/sdk/src/types/blockItemSummary.ts diff --git a/packages/common/src/types/ccdAmount.ts b/packages/sdk/src/types/ccdAmount.ts similarity index 100% rename from packages/common/src/types/ccdAmount.ts rename to packages/sdk/src/types/ccdAmount.ts diff --git a/packages/common/src/types/chainUpdate.ts b/packages/sdk/src/types/chainUpdate.ts similarity index 100% rename from packages/common/src/types/chainUpdate.ts rename to packages/sdk/src/types/chainUpdate.ts diff --git a/packages/common/src/types/errors.ts b/packages/sdk/src/types/errors.ts similarity index 100% rename from packages/common/src/types/errors.ts rename to packages/sdk/src/types/errors.ts diff --git a/packages/common/src/types/moduleReference.ts b/packages/sdk/src/types/moduleReference.ts similarity index 100% rename from packages/common/src/types/moduleReference.ts rename to packages/sdk/src/types/moduleReference.ts diff --git a/packages/common/src/types/rejectReason.ts b/packages/sdk/src/types/rejectReason.ts similarity index 100% rename from packages/common/src/types/rejectReason.ts rename to packages/sdk/src/types/rejectReason.ts diff --git a/packages/common/src/types/transactionEvent.ts b/packages/sdk/src/types/transactionEvent.ts similarity index 100% rename from packages/common/src/types/transactionEvent.ts rename to packages/sdk/src/types/transactionEvent.ts diff --git a/packages/common/src/types/transactionExpiry.ts b/packages/sdk/src/types/transactionExpiry.ts similarity index 100% rename from packages/common/src/types/transactionExpiry.ts rename to packages/sdk/src/types/transactionExpiry.ts diff --git a/packages/common/src/uleb128.ts b/packages/sdk/src/uleb128.ts similarity index 100% rename from packages/common/src/uleb128.ts rename to packages/sdk/src/uleb128.ts diff --git a/packages/common/src/util.ts b/packages/sdk/src/util.ts similarity index 98% rename from packages/common/src/util.ts rename to packages/sdk/src/util.ts index 7b876f192..c383b6655 100644 --- a/packages/common/src/util.ts +++ b/packages/sdk/src/util.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ +import { Buffer } from 'buffer/index.js'; import { AccountTransactionSignature, HexString, @@ -230,3 +231,7 @@ export const makeDynamicFunction = export function isDefined(v?: T): v is T { return v !== undefined; } + +export function toBuffer(s: string, encoding?: string): Buffer { + return Buffer.from(s, encoding); +} diff --git a/packages/common/src/versionedTypeHelpers.ts b/packages/sdk/src/versionedTypeHelpers.ts similarity index 100% rename from packages/common/src/versionedTypeHelpers.ts rename to packages/sdk/src/versionedTypeHelpers.ts diff --git a/packages/common/src/wasm/HdWallet.ts b/packages/sdk/src/wasm/HdWallet.ts similarity index 100% rename from packages/common/src/wasm/HdWallet.ts rename to packages/sdk/src/wasm/HdWallet.ts diff --git a/packages/common/src/wasm/accountHelpers.ts b/packages/sdk/src/wasm/accountHelpers.ts similarity index 100% rename from packages/common/src/wasm/accountHelpers.ts rename to packages/sdk/src/wasm/accountHelpers.ts diff --git a/packages/common/src/wasm/credentialDeploymentTransactions.ts b/packages/sdk/src/wasm/credentialDeploymentTransactions.ts similarity index 100% rename from packages/common/src/wasm/credentialDeploymentTransactions.ts rename to packages/sdk/src/wasm/credentialDeploymentTransactions.ts diff --git a/packages/common/src/wasm/deserialization.ts b/packages/sdk/src/wasm/deserialization.ts similarity index 100% rename from packages/common/src/wasm/deserialization.ts rename to packages/sdk/src/wasm/deserialization.ts diff --git a/packages/common/src/wasm/identity.ts b/packages/sdk/src/wasm/identity.ts similarity index 100% rename from packages/common/src/wasm/identity.ts rename to packages/sdk/src/wasm/identity.ts diff --git a/packages/common/src/wasm/index.ts b/packages/sdk/src/wasm/index.ts similarity index 100% rename from packages/common/src/wasm/index.ts rename to packages/sdk/src/wasm/index.ts diff --git a/packages/common/src/wasm/serialization.ts b/packages/sdk/src/wasm/serialization.ts similarity index 100% rename from packages/common/src/wasm/serialization.ts rename to packages/sdk/src/wasm/serialization.ts diff --git a/packages/common/src/wasm/web3Id.ts b/packages/sdk/src/wasm/web3Id.ts similarity index 100% rename from packages/common/src/wasm/web3Id.ts rename to packages/sdk/src/wasm/web3Id.ts diff --git a/packages/common/src/web3-id/index.ts b/packages/sdk/src/web3-id/index.ts similarity index 100% rename from packages/common/src/web3-id/index.ts rename to packages/sdk/src/web3-id/index.ts diff --git a/packages/common/src/web3-id/web3IdHelpers.ts b/packages/sdk/src/web3-id/web3IdHelpers.ts similarity index 100% rename from packages/common/src/web3-id/web3IdHelpers.ts rename to packages/sdk/src/web3-id/web3IdHelpers.ts diff --git a/packages/common/src/web3-id/web3IdProofTypes.ts b/packages/sdk/src/web3-id/web3IdProofTypes.ts similarity index 100% rename from packages/common/src/web3-id/web3IdProofTypes.ts rename to packages/sdk/src/web3-id/web3IdProofTypes.ts diff --git a/packages/common/src/web3-id/web3IdProofs.ts b/packages/sdk/src/web3-id/web3IdProofs.ts similarity index 100% rename from packages/common/src/web3-id/web3IdProofs.ts rename to packages/sdk/src/web3-id/web3IdProofs.ts diff --git a/packages/common/test/HdWallet.test.ts b/packages/sdk/test/ci/HdWallet.test.ts similarity index 98% rename from packages/common/test/HdWallet.test.ts rename to packages/sdk/test/ci/HdWallet.test.ts index 7e670a89c..8af7ceb1a 100644 --- a/packages/common/test/HdWallet.test.ts +++ b/packages/sdk/test/ci/HdWallet.test.ts @@ -1,5 +1,5 @@ -import { ContractAddress } from '../src/index.js'; -import { ConcordiumHdWallet } from '../src/wasm/HdWallet.js'; +import { ContractAddress } from '../../src/index.js'; +import { ConcordiumHdWallet } from '../../src/wasm/HdWallet.js'; import { Buffer } from 'buffer/index.js'; export const TEST_SEED_1 = 'efa5e27326f8fa0902e647b52449bf335b7b605adc387015ec903f41d95080eb71361cbc7fb78721dcd4f3926a337340aa1406df83332c44c1cdcfe100603860'; diff --git a/packages/common/test/VerifiablePresentation.test.ts b/packages/sdk/test/ci/VerifiablePresentation.test.ts similarity index 93% rename from packages/common/test/VerifiablePresentation.test.ts rename to packages/sdk/test/ci/VerifiablePresentation.test.ts index 277c2ab6f..23c82dbc3 100644 --- a/packages/common/test/VerifiablePresentation.test.ts +++ b/packages/sdk/test/ci/VerifiablePresentation.test.ts @@ -1,7 +1,7 @@ import { replaceDateWithTimeStampAttribute, reviveDateFromTimeStampAttribute, -} from '../src/types/VerifiablePresentation.js'; +} from '../../src/types/VerifiablePresentation.js'; const dateValue = '2023-08-24T15:15:29.000Z'; const timestamp = 1692890129000; diff --git a/packages/common/test/accountHelpers.test.ts b/packages/sdk/test/ci/accountHelpers.test.ts similarity index 85% rename from packages/common/test/accountHelpers.test.ts rename to packages/sdk/test/ci/accountHelpers.test.ts index 5bf3b3e00..624c51a22 100644 --- a/packages/common/test/accountHelpers.test.ts +++ b/packages/sdk/test/ci/accountHelpers.test.ts @@ -1,5 +1,5 @@ -import { AccountAddress } from '../src/index.js'; -import { generateBakerKeys } from '../src/wasm/accountHelpers.js'; +import { AccountAddress } from '../../src/index.js'; +import { generateBakerKeys } from '../../src/wasm/accountHelpers.js'; test('generate baker keys', () => { const accountAddress = '3eP94feEdmhYiPC1333F9VoV31KGMswonuHk5tqmZrzf761zK5'; diff --git a/packages/common/test/accountTransactions.test.ts b/packages/sdk/test/ci/accountTransactions.test.ts similarity index 93% rename from packages/common/test/accountTransactions.test.ts rename to packages/sdk/test/ci/accountTransactions.test.ts index 47e09a9ce..2f8c6d591 100644 --- a/packages/common/test/accountTransactions.test.ts +++ b/packages/sdk/test/ci/accountTransactions.test.ts @@ -1,5 +1,5 @@ -import * as AccountAddress from '../src/types/AccountAddress.js'; -import { TransactionExpiry } from '../src/types/transactionExpiry.js'; +import * as AccountAddress from '../../src/types/AccountAddress.js'; +import { TransactionExpiry } from '../../src/types/transactionExpiry.js'; import { OpenStatus, AccountTransaction, @@ -9,7 +9,7 @@ import { getAccountTransactionSignDigest, AccountTransactionHeader, SequenceNumber, -} from '../src/index.js'; +} from '../../src/index.js'; test('configureBaker is serialized correctly', async () => { const senderAccountAddress = diff --git a/packages/common/test/alias.test.ts b/packages/sdk/test/ci/alias.test.ts similarity index 98% rename from packages/common/test/alias.test.ts rename to packages/sdk/test/ci/alias.test.ts index 9633aee6a..130f3a534 100644 --- a/packages/common/test/alias.test.ts +++ b/packages/sdk/test/ci/alias.test.ts @@ -1,4 +1,4 @@ -import * as AccountAddress from '../src/types/AccountAddress.js'; +import * as AccountAddress from '../../src/types/AccountAddress.js'; test('isAlias is reflexive', () => { const address = AccountAddress.fromBuffer( diff --git a/packages/common/test/credentialDeployment.test.ts b/packages/sdk/test/ci/credentialDeployment.test.ts similarity index 85% rename from packages/common/test/credentialDeployment.test.ts rename to packages/sdk/test/ci/credentialDeployment.test.ts index 2304dce45..b1b84d265 100644 --- a/packages/common/test/credentialDeployment.test.ts +++ b/packages/sdk/test/ci/credentialDeployment.test.ts @@ -1,25 +1,25 @@ import { createCredentialTransaction, CredentialInput, -} from '../src/wasm/credentialDeploymentTransactions.js'; +} from '../../src/wasm/credentialDeploymentTransactions.js'; import fs from 'fs'; -import { AttributeKey } from '../src/types.js'; -import { TransactionExpiry } from '../src/index.js'; +import { AttributeKey } from '../../src/types.js'; +import { TransactionExpiry } from '../../src/index.js'; export function createCredentialInput( revealedAttributes: AttributeKey[] ): CredentialInput { const ipInfo = JSON.parse( - fs.readFileSync('./test/resources/ip_info.json').toString() + fs.readFileSync('./test/ci/resources/ip_info.json').toString() ).value; const globalContext = JSON.parse( - fs.readFileSync('./test/resources/global.json').toString() + fs.readFileSync('./test/ci/resources/global.json').toString() ).value; const arsInfos = JSON.parse( - fs.readFileSync('./test/resources/ars_infos.json').toString() + fs.readFileSync('./test/ci/resources/ars_infos.json').toString() ).value; const idObject = JSON.parse( - fs.readFileSync('./test/resources/identity-object.json').toString() + fs.readFileSync('./test/ci/resources/identity-object.json').toString() ).value; const seedAsHex = diff --git a/packages/common/test/deserialization.test.ts b/packages/sdk/test/ci/deserialization.test.ts similarity index 96% rename from packages/common/test/deserialization.test.ts rename to packages/sdk/test/ci/deserialization.test.ts index ebafacc27..411ac63a5 100644 --- a/packages/common/test/deserialization.test.ts +++ b/packages/sdk/test/ci/deserialization.test.ts @@ -1,5 +1,5 @@ -import { deserializeTransaction } from '../src/wasm/deserialization.js'; -import { serializeAccountTransactionForSubmission } from '../src/serialization.js'; +import { deserializeTransaction } from '../../src/wasm/deserialization.js'; +import { serializeAccountTransactionForSubmission } from '../../src/serialization.js'; import { AccountAddress, AccountTransaction, @@ -19,7 +19,7 @@ import { SequenceNumber, CIS2, ContractAddress, -} from '../src/index.js'; +} from '../../src/index.js'; function deserializeAccountTransactionBase( type: AccountTransactionType, diff --git a/packages/common/test/id.test.ts b/packages/sdk/test/ci/id.test.ts similarity index 87% rename from packages/common/test/id.test.ts rename to packages/sdk/test/ci/id.test.ts index af0f2ca4d..ded8db24a 100644 --- a/packages/common/test/id.test.ts +++ b/packages/sdk/test/ci/id.test.ts @@ -3,18 +3,18 @@ import { IdentityRequestInput, IdentityRecoveryRequestInput, createIdentityRecoveryRequest, -} from '../src/wasm/identity.js'; +} from '../../src/wasm/identity.js'; import fs from 'fs'; test('idrequest', () => { const ipInfo = JSON.parse( - fs.readFileSync('./test/resources/ip_info.json').toString() + fs.readFileSync('./test/ci/resources/ip_info.json').toString() ).value; const globalContext = JSON.parse( - fs.readFileSync('./test/resources/global.json').toString() + fs.readFileSync('./test/ci/resources/global.json').toString() ).value; const arsInfos = JSON.parse( - fs.readFileSync('./test/resources/ars_infos.json').toString() + fs.readFileSync('./test/ci/resources/ars_infos.json').toString() ).value; const seed = 'efa5e27326f8fa0902e647b52449bf335b7b605adc387015ec903f41d95080eb71361cbc7fb78721dcd4f3926a337340aa1406df83332c44c1cdcfe100603860'; @@ -49,10 +49,10 @@ test('idrequest', () => { test('Create id recovery request', () => { const ipInfo = JSON.parse( - fs.readFileSync('./test/resources/ip_info.json').toString() + fs.readFileSync('./test/ci/resources/ip_info.json').toString() ).value; const globalContext = JSON.parse( - fs.readFileSync('./test/resources/global.json').toString() + fs.readFileSync('./test/ci/resources/global.json').toString() ).value; const seedAsHex = 'efa5e27326f8fa0902e647b52449bf335b7b605adc387015ec903f41d95080eb71361cbc7fb78721dcd4f3926a337340aa1406df83332c44c1cdcfe100603860'; diff --git a/packages/common/test/idProofs.test.ts b/packages/sdk/test/ci/idProofs.test.ts similarity index 93% rename from packages/common/test/idProofs.test.ts rename to packages/sdk/test/ci/idProofs.test.ts index ea6c17900..bedcd8efe 100644 --- a/packages/common/test/idProofs.test.ts +++ b/packages/sdk/test/ci/idProofs.test.ts @@ -1,13 +1,17 @@ -import { AttributeKeyString, AttributesKeys, IdDocType } from '../src/types.js'; -import { StatementTypes } from '../src/commonProofTypes.js'; +import { + AttributeKeyString, + AttributesKeys, + IdDocType, +} from '../../src/types.js'; +import { StatementTypes } from '../../src/commonProofTypes.js'; import { attributesWithRange, attributesWithSet, RangeStatement, -} from '../src/id/idProofTypes.js'; -import { IdStatementBuilder } from '../src/id/idProofs.js'; +} from '../../src/id/idProofTypes.js'; +import { IdStatementBuilder } from '../../src/id/idProofs.js'; import fs from 'fs'; -import { getIdProof } from '../src/wasm/index.js'; +import { getIdProof } from '../../src/wasm/index.js'; test('Creating a statement with multiple atomic statements on the same attribute fails', () => { const builder = new IdStatementBuilder(true); @@ -117,10 +121,10 @@ test('Empty sets are rejected', () => { test('Can create id Proof', () => { const idObject = JSON.parse( - fs.readFileSync('./test/resources/identity-object.json').toString() + fs.readFileSync('./test/ci/resources/identity-object.json').toString() ).value; const globalContext = JSON.parse( - fs.readFileSync('./test/resources/global.json').toString() + fs.readFileSync('./test/ci/resources/global.json').toString() ).value; const builder = new IdStatementBuilder(true); diff --git a/packages/common/test/module-schema.test.ts b/packages/sdk/test/ci/module-schema.test.ts similarity index 98% rename from packages/common/test/module-schema.test.ts rename to packages/sdk/test/ci/module-schema.test.ts index 5a95a25b7..0e225aeb9 100644 --- a/packages/common/test/module-schema.test.ts +++ b/packages/sdk/test/ci/module-schema.test.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import { getEmbeddedModuleSchema, versionedModuleSourceFromBuffer, -} from '../src/types/VersionedModuleSource.js'; +} from '../../src/types/VersionedModuleSource.js'; // Directory with smart contract modules and schemas for testing. const testFileDir = path.resolve( diff --git a/packages/common/test/resources/ars_infos.json b/packages/sdk/test/ci/resources/ars_infos.json similarity index 100% rename from packages/common/test/resources/ars_infos.json rename to packages/sdk/test/ci/resources/ars_infos.json diff --git a/packages/common/test/resources/auction-with-errors-schema.bin b/packages/sdk/test/ci/resources/auction-with-errors-schema.bin similarity index 100% rename from packages/common/test/resources/auction-with-errors-schema.bin rename to packages/sdk/test/ci/resources/auction-with-errors-schema.bin diff --git a/packages/common/test/resources/cis1-wccd-schema-v0-versioned.bin b/packages/sdk/test/ci/resources/cis1-wccd-schema-v0-versioned.bin similarity index 100% rename from packages/common/test/resources/cis1-wccd-schema-v0-versioned.bin rename to packages/sdk/test/ci/resources/cis1-wccd-schema-v0-versioned.bin diff --git a/packages/common/test/resources/cis2-nft-schema.bin b/packages/sdk/test/ci/resources/cis2-nft-schema.bin similarity index 100% rename from packages/common/test/resources/cis2-nft-schema.bin rename to packages/sdk/test/ci/resources/cis2-nft-schema.bin diff --git a/packages/common/test/resources/cis2-wccd-schema-v1-versioned.bin b/packages/sdk/test/ci/resources/cis2-wccd-schema-v1-versioned.bin similarity index 100% rename from packages/common/test/resources/cis2-wccd-schema-v1-versioned.bin rename to packages/sdk/test/ci/resources/cis2-wccd-schema-v1-versioned.bin diff --git a/packages/common/test/resources/expectedPresentation.ts b/packages/sdk/test/ci/resources/expectedPresentation.ts similarity index 100% rename from packages/common/test/resources/expectedPresentation.ts rename to packages/sdk/test/ci/resources/expectedPresentation.ts diff --git a/packages/common/test/resources/expectedStatements.ts b/packages/sdk/test/ci/resources/expectedStatements.ts similarity index 90% rename from packages/common/test/resources/expectedStatements.ts rename to packages/sdk/test/ci/resources/expectedStatements.ts index c454ce176..b5610a16c 100644 --- a/packages/common/test/resources/expectedStatements.ts +++ b/packages/sdk/test/ci/resources/expectedStatements.ts @@ -1,5 +1,5 @@ -import { ContractAddress } from '../../src/index.js'; -import { CredentialStatement } from '../../src/web3-id/web3IdProofTypes.js'; +import { ContractAddress } from '../../../src/index.js'; +import { CredentialStatement } from '../../../src/web3-id/web3IdProofTypes.js'; export const expectedStatementMixed: CredentialStatement[] = [ { diff --git a/packages/common/test/resources/global.json b/packages/sdk/test/ci/resources/global.json similarity index 100% rename from packages/common/test/resources/global.json rename to packages/sdk/test/ci/resources/global.json diff --git a/packages/common/test/resources/icecream-schema.bin b/packages/sdk/test/ci/resources/icecream-schema.bin similarity index 100% rename from packages/common/test/resources/icecream-schema.bin rename to packages/sdk/test/ci/resources/icecream-schema.bin diff --git a/packages/common/test/resources/icecream-with-schema.wasm b/packages/sdk/test/ci/resources/icecream-with-schema.wasm similarity index 100% rename from packages/common/test/resources/icecream-with-schema.wasm rename to packages/sdk/test/ci/resources/icecream-with-schema.wasm diff --git a/packages/common/test/resources/identity-object.json b/packages/sdk/test/ci/resources/identity-object.json similarity index 100% rename from packages/common/test/resources/identity-object.json rename to packages/sdk/test/ci/resources/identity-object.json diff --git a/packages/common/test/resources/ip_info.json b/packages/sdk/test/ci/resources/ip_info.json similarity index 100% rename from packages/common/test/resources/ip_info.json rename to packages/sdk/test/ci/resources/ip_info.json diff --git a/packages/common/test/resources/schema.ts b/packages/sdk/test/ci/resources/schema.ts similarity index 100% rename from packages/common/test/resources/schema.ts rename to packages/sdk/test/ci/resources/schema.ts diff --git a/packages/common/test/resources/two-step-transfer-schema.bin b/packages/sdk/test/ci/resources/two-step-transfer-schema.bin similarity index 100% rename from packages/common/test/resources/two-step-transfer-schema.bin rename to packages/sdk/test/ci/resources/two-step-transfer-schema.bin diff --git a/packages/common/test/schema.test.ts b/packages/sdk/test/ci/schema.test.ts similarity index 95% rename from packages/common/test/schema.test.ts rename to packages/sdk/test/ci/schema.test.ts index 191e058bc..83387a335 100644 --- a/packages/common/test/schema.test.ts +++ b/packages/sdk/test/ci/schema.test.ts @@ -10,7 +10,7 @@ import { serializeUpdateContractParameters, serializeTypeValue, serializeInitContractParameters, -} from '../src/schema.js'; +} from '../../src/schema.js'; import { CIS2_WCCD_STATE_SCHEMA, V0_PIGGYBANK_SCHEMA, @@ -21,7 +21,7 @@ import { AUCTION_WITH_ERRORS_VIEW_RETURN_VALUE_SCHEMA, TEST_CONTRACT_U64, } from './resources/schema.js'; -import { ContractName, EntrypointName, Parameter } from '../src/index.js'; +import { ContractName, EntrypointName, Parameter } from '../../src/index.js'; const U64_MAX = 18446744073709551615n; @@ -38,7 +38,7 @@ test('U64_MAX can be deserialized', () => { test('schema template display', () => { const fullSchema = Buffer.from( - fs.readFileSync('./test/resources/cis2-nft-schema.bin') + fs.readFileSync('./test/ci/resources/cis2-nft-schema.bin') ); const schemaVersion = 1; const contractName = ContractName.fromStringUnchecked('CIS2-NFT'); @@ -108,7 +108,9 @@ test('Return value can be deserialized - auction', () => { const returnValue = deserializeReceiveReturnValue( auctionRawReturnValue, Buffer.from( - fs.readFileSync('./test/resources/auction-with-errors-schema.bin') + fs.readFileSync( + './test/ci/resources/auction-with-errors-schema.bin' + ) ), ContractName.fromStringUnchecked('auction'), EntrypointName.fromStringUnchecked('view') @@ -193,7 +195,7 @@ test('serialize UpdateContractParameters using CIS2 contract', () => { data: [], }, ], - Buffer.from(fs.readFileSync('./test/resources/cis2-nft-schema.bin')), + Buffer.from(fs.readFileSync('./test/ci/resources/cis2-nft-schema.bin')), 1 ); @@ -225,7 +227,7 @@ test('serialize UpdateContractParameters using CIS2 contract and incorrect name' }, ], Buffer.from( - fs.readFileSync('./test/resources/cis2-nft-schema.bin') + fs.readFileSync('./test/ci/resources/cis2-nft-schema.bin') ), 1 ); @@ -249,7 +251,7 @@ test('serialize type value and serializeUpdateContractParameters give same resul }, ]; const fullSchema = Buffer.from( - fs.readFileSync('./test/resources/cis2-nft-schema.bin') + fs.readFileSync('./test/ci/resources/cis2-nft-schema.bin') ); const schemaVersion = 1; const contractName = ContractName.fromStringUnchecked('CIS2-NFT'); diff --git a/packages/common/test/serialization.test.ts b/packages/sdk/test/ci/serialization.test.ts similarity index 86% rename from packages/common/test/serialization.test.ts rename to packages/sdk/test/ci/serialization.test.ts index 7e0c667a5..9a9ed66fc 100644 --- a/packages/common/test/serialization.test.ts +++ b/packages/sdk/test/ci/serialization.test.ts @@ -1,18 +1,18 @@ -import * as AccountAddress from '../src/types/AccountAddress.js'; -import { CcdAmount } from '../src/types/ccdAmount.js'; +import * as AccountAddress from '../../src/types/AccountAddress.js'; +import { CcdAmount } from '../../src/types/ccdAmount.js'; import { serializeAccountTransactionForSubmission, serializeAccountTransactionSignature, -} from '../src/serialization.js'; +} from '../../src/serialization.js'; import { AccountTransaction, AccountTransactionHeader, AccountTransactionSignature, AccountTransactionType, SimpleTransferPayload, -} from '../src/types.js'; -import { TransactionExpiry } from '../src/types/transactionExpiry.js'; -import { SequenceNumber } from '../src/index.js'; +} from '../../src/types.js'; +import { TransactionExpiry } from '../../src/types/transactionExpiry.js'; +import { SequenceNumber } from '../../src/index.js'; test('fail account transaction serialization if no signatures', () => { const simpleTransferPayload: SimpleTransferPayload = { diff --git a/packages/common/test/signHelpers.test.ts b/packages/sdk/test/ci/signHelpers.test.ts similarity index 99% rename from packages/common/test/signHelpers.test.ts rename to packages/sdk/test/ci/signHelpers.test.ts index 19b987970..4cc0b3ecf 100644 --- a/packages/common/test/signHelpers.test.ts +++ b/packages/sdk/test/ci/signHelpers.test.ts @@ -2,13 +2,13 @@ import { signMessage, buildBasicAccountSigner, verifyMessageSignature, -} from '../src/signHelpers.js'; +} from '../../src/signHelpers.js'; import { AccountAddress, AccountInfo, buildAccountSigner, SimpleAccountKeys, -} from '../src/index.js'; +} from '../../src/index.js'; const TEST_ACCOUNT_SINGLE = AccountAddress.fromBase58( '3eP94feEdmhYiPC1333F9VoV31KGMswonuHk5tqmZrzf761zK5' diff --git a/packages/common/test/types.test.ts b/packages/sdk/test/ci/types.test.ts similarity index 85% rename from packages/common/test/types.test.ts rename to packages/sdk/test/ci/types.test.ts index 26df6d6c3..a24f49c92 100644 --- a/packages/common/test/types.test.ts +++ b/packages/sdk/test/ci/types.test.ts @@ -1,4 +1,4 @@ -import { isRpcError, RpcError } from '../src/index.js'; +import { isRpcError, RpcError } from '../../src/index.js'; test('RPCError', () => { const rpcError: unknown = new RpcError('This is an RpcError'); diff --git a/packages/common/test/types/AccountAddress.test.ts b/packages/sdk/test/ci/types/AccountAddress.test.ts similarity index 92% rename from packages/common/test/types/AccountAddress.test.ts rename to packages/sdk/test/ci/types/AccountAddress.test.ts index d1a326b74..7c91a674a 100644 --- a/packages/common/test/types/AccountAddress.test.ts +++ b/packages/sdk/test/ci/types/AccountAddress.test.ts @@ -1,4 +1,4 @@ -import { AccountAddress } from '../../src/index.js'; +import { AccountAddress } from '../../../src/index.js'; test('Base58 decode-encode results is the same', () => { const address = AccountAddress.fromBuffer(new Uint8Array(32)); diff --git a/packages/common/test/types/blockItemSummary.test.ts b/packages/sdk/test/ci/types/blockItemSummary.test.ts similarity index 99% rename from packages/common/test/types/blockItemSummary.test.ts rename to packages/sdk/test/ci/types/blockItemSummary.test.ts index a7e2e7996..5e48c9b51 100644 --- a/packages/common/test/types/blockItemSummary.test.ts +++ b/packages/sdk/test/ci/types/blockItemSummary.test.ts @@ -27,7 +27,7 @@ import { InitName, Parameter, ReceiveName, -} from '../../src/index.js'; +} from '../../../src/index.js'; const chainUpdate: UpdateSummary = { type: TransactionSummaryType.UpdateTransaction, diff --git a/packages/common/test/types/blockSpecialEvents.test.ts b/packages/sdk/test/ci/types/blockSpecialEvents.test.ts similarity index 99% rename from packages/common/test/types/blockSpecialEvents.test.ts rename to packages/sdk/test/ci/types/blockSpecialEvents.test.ts index 122d8c163..7d33a406a 100644 --- a/packages/common/test/types/blockSpecialEvents.test.ts +++ b/packages/sdk/test/ci/types/blockSpecialEvents.test.ts @@ -8,7 +8,7 @@ import { BlockSpecialEventPaydayAccountReward, BlockSpecialEventBlockReward, specialEventAffectedAccounts, -} from '../../src/index.js'; +} from '../../../src/index.js'; const bakingRewards: BlockSpecialEventBakingRewards = { tag: 'bakingRewards', diff --git a/packages/common/test/types/ccdAmount.test.ts b/packages/sdk/test/ci/types/ccdAmount.test.ts similarity index 97% rename from packages/common/test/types/ccdAmount.test.ts rename to packages/sdk/test/ci/types/ccdAmount.test.ts index 53540985c..a213535b7 100644 --- a/packages/common/test/types/ccdAmount.test.ts +++ b/packages/sdk/test/ci/types/ccdAmount.test.ts @@ -1,5 +1,5 @@ import Big from 'big.js'; -import { CcdAmount } from '../../src/index.js'; +import { CcdAmount } from '../../../src/index.js'; describe('To and from ccd as strings', () => { test('Parses one CCD correctly', () => { diff --git a/packages/common/test/uleb128.test.ts b/packages/sdk/test/ci/uleb128.test.ts similarity index 98% rename from packages/common/test/uleb128.test.ts rename to packages/sdk/test/ci/uleb128.test.ts index 80345307e..7ac52f129 100644 --- a/packages/common/test/uleb128.test.ts +++ b/packages/sdk/test/ci/uleb128.test.ts @@ -2,7 +2,7 @@ import { uleb128Decode, uleb128DecodeWithIndex, uleb128Encode, -} from '../src/uleb128.js'; +} from '../../src/uleb128.js'; test('uleb128 encodes value as expected', () => { let value = 0n; diff --git a/packages/common/test/util.test.ts b/packages/sdk/test/ci/util.test.ts similarity index 87% rename from packages/common/test/util.test.ts rename to packages/sdk/test/ci/util.test.ts index de909806b..7479a1250 100644 --- a/packages/common/test/util.test.ts +++ b/packages/sdk/test/ci/util.test.ts @@ -1,4 +1,4 @@ -import { stringToInt, wasmToSchema } from '../src/util.js'; +import { stringToInt, wasmToSchema } from '../../src/util.js'; import { readFileSync } from 'fs'; test('stringToInt transforms chosen field, but not others', () => { @@ -31,12 +31,14 @@ test('stringToInt will not change the string if no keys match', () => { test('Embedded schema is the same as a seperate schema file', () => { const versionedWasmModule = readFileSync( - 'test/resources/icecream-with-schema.wasm' + 'test/ci/resources/icecream-with-schema.wasm' ); // Strip module version information const wasmModule = versionedWasmModule.subarray(8); - const seperateSchema = readFileSync('test/resources/icecream-schema.bin'); + const seperateSchema = readFileSync( + 'test/ci/resources/icecream-schema.bin' + ); const embeddedSchema = wasmToSchema(wasmModule); expect(new Uint8Array(seperateSchema)).toEqual(embeddedSchema); diff --git a/packages/common/test/web3IdHelpers.test.ts b/packages/sdk/test/ci/web3IdHelpers.test.ts similarity index 98% rename from packages/common/test/web3IdHelpers.test.ts rename to packages/sdk/test/ci/web3IdHelpers.test.ts index b684b3f88..18a37d1c8 100644 --- a/packages/common/test/web3IdHelpers.test.ts +++ b/packages/sdk/test/ci/web3IdHelpers.test.ts @@ -9,10 +9,10 @@ import { timestampToDate, verifyWeb3IdCredentialSignature, ContractAddress, -} from '../src/index.js'; +} from '../../src/index.js'; const globalContext = JSON.parse( - fs.readFileSync('./test/resources/global.json').toString() + fs.readFileSync('./test/ci/resources/global.json').toString() ).value; const signature = diff --git a/packages/common/test/web3Proofs.test.ts b/packages/sdk/test/ci/web3Proofs.test.ts similarity index 98% rename from packages/common/test/web3Proofs.test.ts rename to packages/sdk/test/ci/web3Proofs.test.ts index d8be212e6..128ca765b 100644 --- a/packages/common/test/web3Proofs.test.ts +++ b/packages/sdk/test/ci/web3Proofs.test.ts @@ -14,7 +14,7 @@ import { VerifiablePresentation, verifyAtomicStatements, Web3StatementBuilder, -} from '../src/index.js'; +} from '../../src/index.js'; import { expectedAccountCredentialPresentation, expectedWeb3IdCredentialPresentation, @@ -24,14 +24,14 @@ import { CommitmentInput, CredentialSchemaSubject, TimestampAttribute, -} from '../src/web3-id/web3IdProofTypes.js'; +} from '../../src/web3-id/web3IdProofTypes.js'; import { TEST_SEED_1 } from './HdWallet.test.js'; import fs from 'fs'; import { GenericMembershipStatement, GenericNonMembershipStatement, GenericRangeStatement, -} from '../src/commonProofTypes.js'; +} from '../../src/commonProofTypes.js'; test('Generate V2 statement', () => { const builder = new Web3StatementBuilder(); @@ -57,7 +57,7 @@ test('Generate V2 statement', () => { test('create Web3Id proof with account credentials', () => { const globalContext = JSON.parse( - fs.readFileSync('./test/resources/global.json').toString() + fs.readFileSync('./test/ci/resources/global.json').toString() ).value; const values: Record = {}; @@ -135,7 +135,7 @@ test('create Web3Id proof with account credentials', () => { test('create Web3Id proof with Web3Id Credentials', () => { const globalContext = JSON.parse( - fs.readFileSync('./test/resources/global.json').toString() + fs.readFileSync('./test/ci/resources/global.json').toString() ).value; const randomness: Record = {}; diff --git a/packages/nodejs/test/CIS2Contract.test.ts b/packages/sdk/test/client/CIS2Contract.test.ts similarity index 98% rename from packages/nodejs/test/CIS2Contract.test.ts rename to packages/sdk/test/client/CIS2Contract.test.ts index 33e91db43..a362bd166 100644 --- a/packages/nodejs/test/CIS2Contract.test.ts +++ b/packages/sdk/test/client/CIS2Contract.test.ts @@ -8,10 +8,10 @@ import { Parameter, ReceiveName, TransactionEventTag, -} from '@concordium/common-sdk'; + CIS2Contract, + serializeTypeValue, +} from '../../src/index.js'; import { getNodeClientV2 as getNodeClient } from './testHelpers.js'; -import { CIS2Contract } from '@concordium/common-sdk/cis2'; -import { serializeTypeValue } from '@concordium/common-sdk/schema'; const CIS2_FT_ADDRESS = ContractAddress.create(3496); const CIS2_NFT_ADDRESS = ContractAddress.create(1696); diff --git a/packages/nodejs/test/CIS4Contract.test.ts b/packages/sdk/test/client/CIS4Contract.test.ts similarity index 98% rename from packages/nodejs/test/CIS4Contract.test.ts rename to packages/sdk/test/client/CIS4Contract.test.ts index 76aa2dec9..344175135 100644 --- a/packages/nodejs/test/CIS4Contract.test.ts +++ b/packages/sdk/test/client/CIS4Contract.test.ts @@ -5,9 +5,11 @@ import { Energy, BlockHash, Parameter, -} from '@concordium/common-sdk'; -import { serializeTypeValue } from '@concordium/common-sdk/schema'; -import { CIS4, CIS4Contract, Web3IdSigner } from '@concordium/common-sdk/cis4'; + CIS4, + CIS4Contract, + Web3IdSigner, + serializeTypeValue, +} from '../../src/index.js'; import { getNodeClientV2 as getNodeClient } from './testHelpers.js'; const ISSUER_ACCOUNT = AccountAddress.fromBase58( diff --git a/packages/nodejs/test/cis0.test.ts b/packages/sdk/test/client/cis0.test.ts similarity index 90% rename from packages/nodejs/test/cis0.test.ts rename to packages/sdk/test/client/cis0.test.ts index 6ea83dd07..4e6ce631b 100644 --- a/packages/nodejs/test/cis0.test.ts +++ b/packages/sdk/test/client/cis0.test.ts @@ -1,5 +1,4 @@ -import { CIS0, cis0Supports } from '@concordium/common-sdk/cis0'; -import { ContractAddress } from '@concordium/common-sdk'; +import { CIS0, ContractAddress, cis0Supports } from '../../src/index.js'; import { getNodeClientV2 as getNodeClient } from './testHelpers.js'; const client = getNodeClient(); diff --git a/packages/nodejs/test/clientV2.test.ts b/packages/sdk/test/client/clientV2.test.ts similarity index 97% rename from packages/nodejs/test/clientV2.test.ts rename to packages/sdk/test/client/clientV2.test.ts index 6fc292c59..b9be60d9a 100644 --- a/packages/nodejs/test/clientV2.test.ts +++ b/packages/sdk/test/client/clientV2.test.ts @@ -1,5 +1,5 @@ -import * as v1 from '@concordium/common-sdk'; -import * as v2 from '../../common/lib/grpc-api/v2/concordium/types.js'; +import * as v1 from '../../src/index.js'; +import * as v2 from '../../src/grpc-api/v2/concordium/types.js'; import { testnetBulletproofGenerators } from './resources/bulletproofgenerators.js'; import { buildBasicAccountSigner, @@ -13,9 +13,8 @@ import { serializeAccountTransaction, streamToList, BlockHash, -} from '@concordium/common-sdk'; +} from '../../src/index.js'; import { - getModuleBuffer, getIdentityInput, getNodeClientV2, getNodeClientWeb, @@ -24,12 +23,7 @@ import * as ed from '@noble/ed25519'; import * as expected from './resources/expectedJsons.js'; import { TextEncoder, TextDecoder } from 'util'; -import { - ConcordiumGRPCClient, - getAccountIdentifierInput, - getBlockHashInput, -} from '@concordium/common-sdk/grpc'; -import { deserializeReceiveReturnValue } from '@concordium/common-sdk/schema'; +import { getModuleBuffer } from '../../src/nodejs/index.js'; /* eslint-disable @typescript-eslint/no-explicit-any */ global.TextEncoder = TextEncoder as any; @@ -57,12 +51,12 @@ const testBlockHash = v1.BlockHash.fromHexString( // Retrieves the account info for the given account in the GRPCv2 type format. function getAccountInfoV2( - client: ConcordiumGRPCClient, + client: v1.ConcordiumGRPCClient, accountIdentifier: v1.AccountIdentifierInput ): Promise { const accountInfoRequest = { - blockHash: getBlockHashInput(testBlockHash), - accountIdentifier: getAccountIdentifierInput(accountIdentifier), + blockHash: v1.getBlockHashInput(testBlockHash), + accountIdentifier: v1.getAccountIdentifierInput(accountIdentifier), }; return client.client.getAccountInfo(accountInfoRequest).response; @@ -144,13 +138,13 @@ test.each([clientV2, clientWeb])( ); test.each([clientV2, clientWeb])( + // TODO: fails.. 'accountInfo implementations is the same', async (client) => { const regular = await client.getAccountInfo(testAccount, testBlockHash); const credId = await client.getAccountInfo(testCredId, testBlockHash); const baker = await client.getAccountInfo(testAccBaker, testBlockHash); const deleg = await client.getAccountInfo(testAccDeleg, testBlockHash); - expect(regular).toEqual(expected.regularAccountInfo); expect(credId).toEqual(expected.credIdAccountInfo); expect(baker).toEqual(expected.bakerAccountInfo); @@ -311,7 +305,9 @@ test.each([clientV2, clientWeb])( ); test.each([clientV2, clientWeb])('getModuleSource', async (client) => { - const localModuleBytes = getModuleBuffer('test/resources/piggy_bank.wasm'); + const localModuleBytes = getModuleBuffer( + 'test/client/resources/piggy_bank.wasm' + ); const moduleRef = new v1.ModuleReference( Buffer.from( 'foOYrcQGqX202GnD/XrcgToxg2Z6On2weOuub33OX2Q=', @@ -765,7 +761,7 @@ test.each([clientV2, clientWeb])('getEmbeddedSchema', async (client) => { if (invoked.tag === 'success' && invoked.returnValue) { const rawReturnValue = invoked.returnValue; - const returnValue = deserializeReceiveReturnValue( + const returnValue = v1.deserializeReceiveReturnValue( v1.ReturnValue.toBuffer(rawReturnValue), schema, v1.ContractName.fromStringUnchecked('weather'), diff --git a/packages/nodejs/test/credentialDeployment.test.ts b/packages/sdk/test/client/credentialDeployment.test.ts similarity index 95% rename from packages/nodejs/test/credentialDeployment.test.ts rename to packages/sdk/test/client/credentialDeployment.test.ts index 937ee3011..3aa2c6b1b 100644 --- a/packages/nodejs/test/credentialDeployment.test.ts +++ b/packages/sdk/test/client/credentialDeployment.test.ts @@ -8,19 +8,17 @@ import { getCredentialDeploymentSignDigest, BlockItemKind, createCredentialDeploymentTransaction, -} from '@concordium/common-sdk'; -import fs from 'fs'; -import * as ed from '@noble/ed25519'; -import { deserializeTransaction, serializeCredentialDeploymentTransactionForSubmission, -} from '@concordium/common-sdk/wasm'; +} from '../../src/index.js'; +import fs from 'fs'; +import * as ed from '@noble/ed25519'; test('test deserialize credentialDeployment ', async () => { const identityInput: IdentityInput = getIdentityInput(); const cryptographicParameters = JSON.parse( - fs.readFileSync('../common/test/resources/global.json').toString() + fs.readFileSync('./test/ci/resources/global.json').toString() ).value; if (!cryptographicParameters) { throw new Error('Missing global'); diff --git a/packages/nodejs/test/deserialization.test.ts b/packages/sdk/test/client/deserialization.test.ts similarity index 90% rename from packages/nodejs/test/deserialization.test.ts rename to packages/sdk/test/client/deserialization.test.ts index c55f43958..7e7ca1986 100644 --- a/packages/nodejs/test/deserialization.test.ts +++ b/packages/sdk/test/client/deserialization.test.ts @@ -4,9 +4,9 @@ import { ContractName, isInstanceInfoV0, BlockHash, -} from '@concordium/common-sdk'; + deserializeContractState, +} from '../../src/index.js'; import * as fs from 'fs'; -import { deserializeContractState } from '@concordium/common-sdk/schema'; const client = getNodeClient(); @@ -31,7 +31,7 @@ test.skip('Deserialize state with schema from file (two-step-transfer)', async ( } const schema = Buffer.from( - fs.readFileSync('./test/resources/two-step-transfer-schema.bin') + fs.readFileSync('./test/client/resources/two-step-transfer-schema.bin') ); const state = deserializeContractState( ContractName.fromStringUnchecked('two-step-transfer'), diff --git a/packages/nodejs/test/events.test.ts b/packages/sdk/test/client/events.test.ts similarity index 99% rename from packages/nodejs/test/events.test.ts rename to packages/sdk/test/client/events.test.ts index 48363553a..dd20a905d 100644 --- a/packages/nodejs/test/events.test.ts +++ b/packages/sdk/test/client/events.test.ts @@ -1,5 +1,5 @@ import * as expected from './resources/expectedJsons.js'; -import { streamToList, BlockHash } from '@concordium/common-sdk'; +import { streamToList, BlockHash } from '../../src/index.js'; import { getNodeClientV2 as getNodeClient } from './testHelpers.js'; const client = getNodeClient(); diff --git a/packages/nodejs/test/getConsensusStatus.test.ts b/packages/sdk/test/client/getConsensusStatus.test.ts similarity index 97% rename from packages/nodejs/test/getConsensusStatus.test.ts rename to packages/sdk/test/client/getConsensusStatus.test.ts index 86f06a06c..23f35735e 100644 --- a/packages/nodejs/test/getConsensusStatus.test.ts +++ b/packages/sdk/test/client/getConsensusStatus.test.ts @@ -1,4 +1,4 @@ -import { ConsensusStatus } from '@concordium/common-sdk'; +import { ConsensusStatus } from '../../src/index.js'; import { getNodeClientV2 as getNodeClient } from './testHelpers.js'; const client = getNodeClient(); diff --git a/packages/nodejs/test/manualTests.test.ts b/packages/sdk/test/client/manualTests.test.ts similarity index 91% rename from packages/nodejs/test/manualTests.test.ts rename to packages/sdk/test/client/manualTests.test.ts index 29d32c2a1..51a9c98b6 100644 --- a/packages/nodejs/test/manualTests.test.ts +++ b/packages/sdk/test/client/manualTests.test.ts @@ -1,10 +1,7 @@ -import * as v2 from '../../common/lib/grpc-api/v2/concordium/types.js'; -import * as v1 from '@concordium/common-sdk'; -import { - buildBasicAccountSigner, - signTransaction, -} from '@concordium/common-sdk'; -import { getNodeClientV2 as getNodeClient } from '../test/testHelpers.js'; +import * as v2 from '../../src/grpc-api/v2/concordium/types.js'; +import * as v1 from '../../src/index.js'; +import { buildBasicAccountSigner, signTransaction } from '../../src/index.js'; +import { getNodeClientV2 as getNodeClient } from './testHelpers.js'; const client = getNodeClient(); diff --git a/packages/nodejs/test/rejectReasons.test.ts b/packages/sdk/test/client/rejectReasons.test.ts similarity index 99% rename from packages/nodejs/test/rejectReasons.test.ts rename to packages/sdk/test/client/rejectReasons.test.ts index f19e8d358..91a71a649 100644 --- a/packages/nodejs/test/rejectReasons.test.ts +++ b/packages/sdk/test/client/rejectReasons.test.ts @@ -1,4 +1,4 @@ -import { BlockHash, streamToList } from '@concordium/common-sdk'; +import { BlockHash, streamToList } from '../../src/index.js'; import * as expected from './resources/expectedJsons.js'; import { getNodeClientV2 as getNodeClient } from './testHelpers.js'; diff --git a/packages/nodejs/test/resources/bulletproofgenerators.ts b/packages/sdk/test/client/resources/bulletproofgenerators.ts similarity index 100% rename from packages/nodejs/test/resources/bulletproofgenerators.ts rename to packages/sdk/test/client/resources/bulletproofgenerators.ts diff --git a/packages/nodejs/test/resources/expectedJsons.ts b/packages/sdk/test/client/resources/expectedJsons.ts similarity index 99% rename from packages/nodejs/test/resources/expectedJsons.ts rename to packages/sdk/test/client/resources/expectedJsons.ts index f170864ed..e5ddf3219 100644 --- a/packages/nodejs/test/resources/expectedJsons.ts +++ b/packages/sdk/test/client/resources/expectedJsons.ts @@ -1,7 +1,10 @@ import { AccountAddress, AccountCreationSummary, - AccountInfo, + AccountInfoBaker, + AccountInfoDelegator, + AccountInfoSimple, + AccountInfoType, AmountAddedByDecryptionEvent, AmountTooLarge, BakerEvent, @@ -58,7 +61,7 @@ import { TransferredWithScheduleEvent, UpdateSummary, UpdateType, -} from '@concordium/common-sdk'; +} from '../../../src/index.js'; export const accountInfo = { sequenceNumber: { @@ -1462,7 +1465,8 @@ export const invalidTransferToPublicProofRejectReason = { export const poolWouldBecomeOverDelegatedRejectReason = { tag: 'PoolWouldBecomeOverDelegated', }; -export const bakerAccountInfo: AccountInfo = { +export const bakerAccountInfo: AccountInfoBaker = { + type: AccountInfoType.Baker, accountNonce: SequenceNumber.create(1), accountAmount: 7449646704751788n, accountReleaseSchedule: { total: 0n, schedule: [] }, @@ -1561,7 +1565,8 @@ export const bakerAccountInfo: AccountInfo = { }, }; -export const delegatorAccountInfo: AccountInfo = { +export const delegatorAccountInfo: AccountInfoDelegator = { + type: AccountInfoType.Delegator, accountNonce: SequenceNumber.create(11), accountAmount: 620948501142n, accountReleaseSchedule: { total: 0n, schedule: [] }, @@ -1668,7 +1673,8 @@ export const delegatorAccountInfo: AccountInfo = { }, }; -export const credIdAccountInfo: AccountInfo = { +export const credIdAccountInfo: AccountInfoSimple = { + type: AccountInfoType.Simple, accountNonce: SequenceNumber.create(19), accountAmount: 35495453082577742n, accountReleaseSchedule: { total: 0n, schedule: [] }, @@ -1746,7 +1752,8 @@ export const credIdAccountInfo: AccountInfo = { ), }; -export const regularAccountInfo: AccountInfo = { +export const regularAccountInfo: AccountInfoSimple = { + type: AccountInfoType.Simple, accountNonce: SequenceNumber.create(19), accountAmount: 35495453082577742n, accountReleaseSchedule: { total: 0n, schedule: [] }, diff --git a/packages/nodejs/test/resources/ipVerifyKeys.ts b/packages/sdk/test/client/resources/ipVerifyKeys.ts similarity index 100% rename from packages/nodejs/test/resources/ipVerifyKeys.ts rename to packages/sdk/test/client/resources/ipVerifyKeys.ts diff --git a/packages/nodejs/test/resources/mobileWalletExport.json b/packages/sdk/test/client/resources/mobileWalletExport.json similarity index 100% rename from packages/nodejs/test/resources/mobileWalletExport.json rename to packages/sdk/test/client/resources/mobileWalletExport.json diff --git a/packages/nodejs/test/resources/piggy_bank.wasm b/packages/sdk/test/client/resources/piggy_bank.wasm similarity index 100% rename from packages/nodejs/test/resources/piggy_bank.wasm rename to packages/sdk/test/client/resources/piggy_bank.wasm diff --git a/packages/nodejs/test/resources/schemaFiles/schema11.bin b/packages/sdk/test/client/resources/schemaFiles/schema11.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema11.bin rename to packages/sdk/test/client/resources/schemaFiles/schema11.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema12.bin b/packages/sdk/test/client/resources/schemaFiles/schema12.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema12.bin rename to packages/sdk/test/client/resources/schemaFiles/schema12.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema14.bin b/packages/sdk/test/client/resources/schemaFiles/schema14.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema14.bin rename to packages/sdk/test/client/resources/schemaFiles/schema14.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema15.bin b/packages/sdk/test/client/resources/schemaFiles/schema15.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema15.bin rename to packages/sdk/test/client/resources/schemaFiles/schema15.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema16.bin b/packages/sdk/test/client/resources/schemaFiles/schema16.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema16.bin rename to packages/sdk/test/client/resources/schemaFiles/schema16.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema17.bin b/packages/sdk/test/client/resources/schemaFiles/schema17.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema17.bin rename to packages/sdk/test/client/resources/schemaFiles/schema17.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema18.bin b/packages/sdk/test/client/resources/schemaFiles/schema18.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema18.bin rename to packages/sdk/test/client/resources/schemaFiles/schema18.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema21.bin b/packages/sdk/test/client/resources/schemaFiles/schema21.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema21.bin rename to packages/sdk/test/client/resources/schemaFiles/schema21.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema30.bin b/packages/sdk/test/client/resources/schemaFiles/schema30.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema30.bin rename to packages/sdk/test/client/resources/schemaFiles/schema30.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema31.bin b/packages/sdk/test/client/resources/schemaFiles/schema31.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema31.bin rename to packages/sdk/test/client/resources/schemaFiles/schema31.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema32.bin b/packages/sdk/test/client/resources/schemaFiles/schema32.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema32.bin rename to packages/sdk/test/client/resources/schemaFiles/schema32.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema33.bin b/packages/sdk/test/client/resources/schemaFiles/schema33.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema33.bin rename to packages/sdk/test/client/resources/schemaFiles/schema33.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema34.bin b/packages/sdk/test/client/resources/schemaFiles/schema34.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema34.bin rename to packages/sdk/test/client/resources/schemaFiles/schema34.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema35.bin b/packages/sdk/test/client/resources/schemaFiles/schema35.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema35.bin rename to packages/sdk/test/client/resources/schemaFiles/schema35.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema6.bin b/packages/sdk/test/client/resources/schemaFiles/schema6.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema6.bin rename to packages/sdk/test/client/resources/schemaFiles/schema6.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema8.bin b/packages/sdk/test/client/resources/schemaFiles/schema8.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema8.bin rename to packages/sdk/test/client/resources/schemaFiles/schema8.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema_test.bin b/packages/sdk/test/client/resources/schemaFiles/schema_test.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema_test.bin rename to packages/sdk/test/client/resources/schemaFiles/schema_test.bin diff --git a/packages/nodejs/test/resources/schemaFiles/schema_two_step_transfer.bin b/packages/sdk/test/client/resources/schemaFiles/schema_two_step_transfer.bin similarity index 100% rename from packages/nodejs/test/resources/schemaFiles/schema_two_step_transfer.bin rename to packages/sdk/test/client/resources/schemaFiles/schema_two_step_transfer.bin diff --git a/packages/nodejs/test/resources/smartcontracts/CAddress/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/CAddress/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/CAddress/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/CAddress/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/ComplexEnum1/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/ComplexEnum1/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/ComplexEnum1/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/ComplexEnum1/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/ComplexEnum2/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/ComplexEnum2/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/ComplexEnum2/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/ComplexEnum2/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/ContractForDuration/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/ContractForDuration/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/ContractForDuration/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/ContractForDuration/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/ContractForTime/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/ContractForTime/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/ContractForTime/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/ContractForTime/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/INDBank/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/INDBank/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/INDBank/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/INDBank/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/INDBankBool1/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/INDBankBool1/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/INDBankBool1/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/INDBankBool1/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/INDBankStringArray/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/INDBankStringArray/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/INDBankStringArray/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/INDBankStringArray/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/INDBankU83/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/INDBankU83/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/INDBankU83/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/INDBankU83/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/ListContract/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/ListContract/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/ListContract/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/ListContract/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/MarkSheet/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/MarkSheet/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/MarkSheet/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/MarkSheet/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/SampleContract1/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/SampleContract1/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/SampleContract1/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/SampleContract1/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/SimpleEnum/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/SimpleEnum/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/SimpleEnum/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/SimpleEnum/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/SimpleU8/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/SimpleU8/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/SimpleU8/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/SimpleU8/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/UserAddress/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/UserAddress/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/UserAddress/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/UserAddress/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/UserAmount/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/UserAmount/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/UserAmount/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/UserAmount/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/UserDetails/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/UserDetails/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/UserDetails/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/UserDetails/src/lib.rs diff --git a/packages/nodejs/test/resources/smartcontracts/schema-test/src/lib.rs b/packages/sdk/test/client/resources/smartcontracts/schema-test/src/lib.rs similarity index 100% rename from packages/nodejs/test/resources/smartcontracts/schema-test/src/lib.rs rename to packages/sdk/test/client/resources/smartcontracts/schema-test/src/lib.rs diff --git a/packages/nodejs/test/resources/two-step-transfer-schema.bin b/packages/sdk/test/client/resources/two-step-transfer-schema.bin similarity index 100% rename from packages/nodejs/test/resources/two-step-transfer-schema.bin rename to packages/sdk/test/client/resources/two-step-transfer-schema.bin diff --git a/packages/nodejs/test/specialEvents.test.ts b/packages/sdk/test/client/specialEvents.test.ts similarity index 97% rename from packages/nodejs/test/specialEvents.test.ts rename to packages/sdk/test/client/specialEvents.test.ts index 76307470d..b0c5baa76 100644 --- a/packages/nodejs/test/specialEvents.test.ts +++ b/packages/sdk/test/client/specialEvents.test.ts @@ -1,4 +1,4 @@ -import { streamToList, BlockHash } from '@concordium/common-sdk'; +import { streamToList, BlockHash } from '../../src/index.js'; import * as expected from './resources/expectedJsons.js'; import { getNodeClientV2 as getNodeClient } from './testHelpers.js'; diff --git a/packages/nodejs/test/testHelpers.ts b/packages/sdk/test/client/testHelpers.ts similarity index 67% rename from packages/nodejs/test/testHelpers.ts rename to packages/sdk/test/client/testHelpers.ts index 072f629e5..b45b2339c 100644 --- a/packages/nodejs/test/testHelpers.ts +++ b/packages/sdk/test/client/testHelpers.ts @@ -1,20 +1,18 @@ /* eslint-disable import/no-extraneous-dependencies */ import * as fs from 'fs'; import { credentials } from '@grpc/grpc-js'; -import { IdentityInput } from '@concordium/common-sdk'; -import { ConcordiumGRPCClient } from '@concordium/common-sdk/grpc'; +import { + IdentityInput, + ConcordiumGRPCClient, + ConcordiumGRPCWebClient, +} from '../../src/index.js'; import { decryptMobileWalletExport, EncryptedData, -} from '../src/wallet/crypto.js'; -import { MobileWalletExport } from '../src/wallet/types.js'; -import { createConcordiumClient } from '../src/clientV2.js'; -import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport'; - -// This makes sure the necessary types are added to `globalThis` -import 'isomorphic-fetch'; + MobileWalletExport, +} from '../../src/nodejs/index.js'; -export { getModuleBuffer } from '../src/util.js'; +import { ConcordiumGRPCNodeClient } from '../../src/nodejs/grpc.js'; const TESTNET_NODE = 'node.testnet.concordium.com'; const GRPCV2_PORT = 20000; @@ -27,9 +25,14 @@ export function getNodeClientV2( address = TESTNET_NODE, port = GRPCV2_PORT ): ConcordiumGRPCClient { - return createConcordiumClient(address, port, credentials.createInsecure(), { - timeout: 15000, - }); + return new ConcordiumGRPCNodeClient( + address, + port, + credentials.createInsecure(), + { + timeout: 15000, + } + ); } // TODO find nice way to move this to web/common @@ -41,11 +44,7 @@ export function getNodeClientWeb( address = 'http://node.testnet.concordium.com', port = GRPCV2_PORT ): ConcordiumGRPCClient { - const transport = new GrpcWebFetchTransport({ - baseUrl: `${address}:${port}`, - timeout: 15000, - }); - return new ConcordiumGRPCClient(transport); + return new ConcordiumGRPCWebClient(address, port, { timeout: 15000 }); } export function isValidDate(date: Date): boolean { @@ -54,7 +53,7 @@ export function isValidDate(date: Date): boolean { export function getIdentityInput(): IdentityInput { const rawData = fs.readFileSync( - './test/resources/mobileWalletExport.json', + './test/client/resources/mobileWalletExport.json', 'utf8' ); const mobileWalletExport: EncryptedData = JSON.parse(rawData); diff --git a/packages/web/tsconfig.build.json b/packages/sdk/tsconfig.build.json similarity index 100% rename from packages/web/tsconfig.build.json rename to packages/sdk/tsconfig.build.json diff --git a/packages/common/tsconfig.json b/packages/sdk/tsconfig.json similarity index 83% rename from packages/common/tsconfig.json rename to packages/sdk/tsconfig.json index f92a20b21..dfff192a5 100644 --- a/packages/common/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -8,8 +8,9 @@ }, "include": [ "src/**/*", - "types/**/*", + "scripts/**/*", "test/**/*", + "webpack.config.ts", "jest.config.ts" ] } diff --git a/packages/web/webpack.config.ts b/packages/sdk/webpack.config.ts similarity index 94% rename from packages/web/webpack.config.ts rename to packages/sdk/webpack.config.ts index 2a1f1fd2d..dec381564 100644 --- a/packages/web/webpack.config.ts +++ b/packages/sdk/webpack.config.ts @@ -19,9 +19,6 @@ const config: webpack.Configuration = { new webpack.SourceMapDevToolPlugin({ filename: '[file].map', }), - new webpack.ProvidePlugin({ - process: 'process/browser', - }), ], resolve: { extensionAlias: { diff --git a/packages/web/CHANGELOG.md b/packages/web/CHANGELOG.md deleted file mode 100644 index b99df82b7..000000000 --- a/packages/web/CHANGELOG.md +++ /dev/null @@ -1,258 +0,0 @@ -# Changelog - -## Unreleased - -### Breaking changes - -- The package is published as an ES module, instead of UMD. Migration steps can be seen in [the upgrade guide](../../docs/pages/misc-pages/upgrade-guide.md) -- The package has been split into several entrypoints that can be used to limit the scope of what is included from the SDK. - - `@concordium/web-sdk` exposes the full API of the SDK. - - `@concordium/web-sdk/cis0` entrypoint exposes functionality for working with contracts adhering to the [CIS-0](https://proposals.concordium.software/CIS/cis-0.html) standard. - - `@concordium/web-sdk/cis2` entrypoint exposes functionality for working with contracts adhering to the [CIS-2](https://proposals.concordium.software/CIS/cis-2.html) standard. - - `@concordium/web-sdk/cis4` entrypoint exposes functionality for working with contracts adhering to the [CIS-4](https://proposals.concordium.software/CIS/cis-4.html) standard. - - `@concordium/web-sdk/grpc` entrypoint exposes the grpc client for interacting with a nodes GRPCv2 interface. - - `@concordium/web-sdk/id` entrypoint exposes functionality for working with ID proofs. - - `@concordium/web-sdk/schema` entrypoint exposes functionality for working with smart contract schemas, i.e.(de)serializing types using a smart contract schema. - - This uses the wasm entrypoint at `@concordium/rust-bindings/dapp`. - - `@concordium/web-sdk/types` entrypoint exposes functionality for working with concordium domain types. - - `@concordium/web-sdk/wasm` entrypoint exposes a variety of functionality for working with concordium domain types, which requires WASM. - - This uses the wasm entrypoint at `@concorodium/rust-bindings/wallet`. - - `@concordium/web-sdk/web3-id` entrypoint exposes functionality for working with web3-id proofs. - - This change makes the library **incompatible** with node versions <16 and requires bundlers to respect the `exports` field of `package.json`. - - For TypeScript projects the minimum required version of typescript is: - - NodeJS: 4.7, `"moduleResolution": "node16" // or "nodenext"` - - Bundled applications (webpack, esbuild, rollup, etc...): 5.0, `"moduleResolution": "bundler"` - -The API now uses dedicated types instead of language primitives: -- Use `AccountAddress` instead of a string with base58 encoding. Use `AccountAddress.fromBase58('')` to construct it. -- Use `BlockHash` instead of a string with hex encoding. Use `BlockHash.fromHexString('')` to construct it. -- Use `TranactionHash` instead of a string with hex encoding. Use `TransactionHash.fromHexString('')` to construct it. -- Use `Energy` instead of a bigint. Use `Energy.create()` to construct it. -- Use `ReceiveName` instead of a string. Use `ReceiveName.fromString('.')` to construct it. -- Use `InitName` instead of a string. Use `Init.fromString('init_')` to construct it. -- Use `ContractName` instead of a string. Use `ContractName.fromString('')` to construct it. -- Use `EntrypointName` instead of a string. Use `EntrypointName.fromString('')` to construct it. -- Use `Parameter` instead of a string with hex encoding. Use `Parameter.fromHexString('')`. -- Use `SequenceNumber` (formerly called nonce) instead of a bigint. Use `SequenceNumber.create()` to construct it. -- Use `Timestamp` instead of a bigint. Can be constructed using `Timestamp.fromMillis()`. -- Use `Duration` instead of a bigint. Can be constructed using `Duration.fromMillis()`. - -Several types have been replaced with a module containing the type itself together with functions for constructing and converting the type: -- `AccountAddress` is now a module with functions related to account addresses: - - To refer to `AccountAddress` as a type use `AccountAddress.Type`. - - Constructing `new AccountAddress("
")` is now `AccountAddress.fromBase58("
")`. - - `isAlias` and `getAlias` are now accessable from `AccountAddress.isAlias` and `AccountAddress.getAlias`. -- `ContractAddresss` is now a module with functions related to contract addresses: - - To refer to `ContractAddress` as a type use `ContractAddress.Type`. - - To construct the type use `ContractAddress.create(index, subindex)`. -- `CredentialRegistrationId` is now a module with functions related to credential registration IDs: - - To refer to `CredentialRegistrationId` as a type use `CredentialRegistrationId.Type`. - - Constructing `new CredentialRegistrationId("")` is now `CredentialRegistrationId.fromHexString("")`. -- Removed `JsonRpcClient` and types and functionality associated solely with this class. - -- Renamed `AccountSequenceNumber` module to `SequenceNumber`. -- Fix type for `TranferredEvent` from `ContractTraceEvent` to only be from contract addresses to account addresses. - -### Added - -- All JSON serialization in `serialization.ts` is now handled by `json-bigint` meaning that all functions now correctly handles bigint inputs -- `Timestamp` is now a module with functions related to time. - - To refer to `Timestamp` as a type use `Timestamp.Type`. -- `Duration` is now a module with functions related to durations of time. -- `EntrypointName` is now a module with functions related to entrypoint names of a smart contract. -- `ReceiveName` is now a module with functions related to receive-function names of a smart contract. - -## 6.4.0 - -- Bumped @concordium/common-sdk to 9.4.0. - -## 6.3.0 - -- Bumped @concordium/common-sdk to 9.3.0. - -## 6.2.1 - -- Bumped @concordium/common-sdk to 9.2.1. - -## 6.2.0 - -- Bumped @concordium/common-sdk to 9.2.0. - -## 6.1.1 - -### Changed - -- Bumped @concordium/common-sdk to 9.1.1. (includes fixes for `verifyWeb3IdCredentialSignature` and `canProveAtomicStatement`) - -## 6.1.0 - -### Changed - -- Bumped @concordium/rust-bindings to 1.2.0 and @concordium/common-sdk to 9.1.0. (adds methods for creating verifiable presentation (proving statements about Web3Id Credentials)) - -## 6.0.0 - -### Breaking changes - -- Bumped @concordium/rust-bindings to 1.1.0 and @concordium/common-sdk to 9.0.0. (adds `displayTypeSchemaTemplate/getTransactionKindString` and renames `AccountTransactionType.TransferWithScheduleWithMemo`) - -## 5.0.0 - -### Breaking changes - -- Bumped @concordium/rust-bindings to 1.0.0. (Throws proper `Error`s when execution fails for any WASM entrypoint, with improved error messages) -- Bumped @concordium/common-sdk to 8.0.0: - - Properly formed errors thrown by functions wrapping WASM execution (from @concordium/rust-bindings) with more helpful error messages. - - Types adapted to changes in protocol version 6. - - and [more](../common/CHANGELOG.md) - -## 4.0.1 2023-05-25 - -### Changed - -- Bumped @concordium/common-sdk to 7.0.1. (Fixes `deployModule` cost) - -## 4.0.0 2023-05-15 - -### Breaking Changes - -- Bumped @concordium/rust-bindings to 0.12.0. (Adds key derivation for verifiable credentials) -- Bumped @concordium/common-sdk to 7.0.0: - - Updated `blockInfo` so that the `bakerId` field is optional, since it will be undefined for genesis blocks. - - `waitForTransactionFinalization` now returns a `BlockItemSummaryInBlock` - - Added missing version return type in `getModuleSchema`. It now returns an object containing the schema source and version. - -## 3.5.0 2023-5-03 - -### Changed - -- Bumped @concordium/common-sdk to 6.5.0. (Adds `CIS2Contract`) - -## 3.4.2 2023-4-21 - -### Changed - -- Bumped @concordium/common-sdk to 6.4.2. (`generateBakerKeys` include private baker keys in output) - -## 3.4.1 2023-3-31 - -### Changed - -- Bumped @concordium/common-sdk to 6.4.1. (Fixes `waitForTransactionFinalization`) - -## 3.4.0 2023-3-22 - -### Changed - -- Bumped @concordium/common-sdk to 6.4.0. (Adds `deserializeTypeValue`) - -## 3.3.1 2023-2-27 - -### Fixed - -- Updated rules in package.json to include missing files. - -## 3.3.0 2023-2-27 - -### Added - -- Added a `createConcordiumClient` function to create the gRPC v2 client. - -### Changed - -- 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 - -- Bumped @concordium/common-sdk to 6.2.0. (adds support serializing smart contract types with only the specific type's schema) - -## 3.1.0 2022-11-30 - -### Changed - -- Bumped @concordium/common-sdk to 6.1.0. (adds support for id statements and proofs) - -## 3.0.0 2022-11-15 - -### Changed - -- Bumped @concordium/common-sdk to 6.0.0. (Which changes transaction type names and field names to be aligned with other implementations) - -## 2.1.0 2022-10-27 - -### Changed - -- Bumped @concordium/common-sdk to 5.1.0. (Which adds cookie support to HttpProvider) - -## 2.0.0 2022-9-29 - -### Breaking Changes - -- Bumped @concordium/common-sdk to 5.0.0. (Which changes the function signature of signMessage and verifySignMessage) - -## 1.0.0 2022-9-2 - -### Breaking Changes - -- Bumped @concordium/common-sdk to 4.0.0. (Which changes the function signature of ConcordiumHdWallet) - -## 0.5.0 2022-8-26 - -### Breaking Changes - -- Bumped @concordium/common-sdk to 3.0.0. (Which includes breaking changes to schema versioning) - -## 0.4.0 2022-8-15 - -### Changed - -- Bumped @concordium/common-sdk to 2.4.0. - -## 0.3.0 2022-7-21 - -### Added - -- Add support for getAccountInfo, InvokeContract, getCryptographicParameters and getModuleSource with JSON-RPC -- Support deserializing new schema types: ULeb128, ILeb128, ByteArray and ByteList. -- Support deserializing schemas with versioning information. - -### Changed - -- The function for deserializing a module schema `deserialModuleFromBuffer` now have the schema version as an optional argument. The function will try to extract the version from the buffer. When a version is provided it falls back to this, otherwise it throws an error. - -## 0.2.1 2022-6-27 - -### Fixed - -- @noble/ed25519 and cross-fetch moved from devDependencies to dependencies. (In common-sdk) - -## 0.2.0 2022-6-24 - -### Added - -- Support deserializing version 2 schemas. -- Support serializing parameters for contracts using version 2 schemas. -- Support for deploying versioned smart contract modules, which is the format used in cargo-concordium v2+. (This is done by not supplying the version field in the payload) - -### Breaking changes - -- `serializeInitContractParameters` and `serializeUpdateContractParameters` each have an additional parameter, which denotes the version of the schema provided. For existing users that are using V0 contracts, that parameter should be `SchemaVersion.V1`. -- Deserialization of schemas have been changed: types and functions have been renamed and `getModuleFromBuffer` have an additional parameter. - -## 0.1.2 - -- Add type file missing from the package - -## 0.1.1 - -- Fixed issue with wasm from rust bindings - -## 0.1.0 - -- Initial release diff --git a/packages/web/README.md b/packages/web/README.md deleted file mode 100644 index 9bd324b00..000000000 --- a/packages/web/README.md +++ /dev/null @@ -1,147 +0,0 @@ -# concordium-web-sdk - -[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](https://github.com/Concordium/.github/blob/main/.github/CODE_OF_CONDUCT.md) - -Wrappers for interacting with the Concordium node, for the web environment. - -Please see the -[documentation](https://developer.concordium.software/concordium-node-sdk-js/index.html) -for more information - -**Table of Contents:** - - -- [concordium-web-sdk](#concordium-web-sdk) - - [ConcordiumGRPCClient](#concordiumgrpcclient) - - [JSON-RPC client](#json-rpc-client) - - [Creating buffers](#creating-buffers) - - [Examples](#examples) - - [SendTransaction.html](#sendtransactionhtml) - - [GetInstanceInfo.html](#getinstanceinfohtml) - - [Alias.html](#aliashtml) - - [GetTransactionStatus.html](#gettransactionstatushtml) - - [GetNonce.html](#getnoncehtml) - - [InvokeContract.html](#invokecontracthtml) - - [GetCryptographicParameters.html](#getcryptographicparametershtml) - - [GetAccountInfo.html](#getaccountinfohtml) - - [GetModuleSource.html](#getmodulesourcehtml) - - [SendCIS2Transfer.html](#sendcis2transferhtml) - - [SendCIS2UpdateOperator.html](#sendcis2updateoperatorhtml) - - -## ConcordiumGRPCClient - -The SDK provides a gRPC client, which can interact with the [Concordium -Node](https://github.com/Concordium/concordium-node) using gRPC-web. - -For an overview of the endpoints, [click -here](https://developer.concordium.software/concordium-node-sdk-js/modules/Common_GRPC_Client.html). - -To create a client, the function `createConcordiumClient` can be used. It -requires the address and port of the concordium node. - -```ts -import { createConcordiumClient } from '@concordium/web-sdk'; -... -return createConcordiumClient( - address, - port, - { timeout: 15000 } -); -``` - -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](https://developer.concordium.software/concordium-node-sdk-js/pages/misc-pages/grpc-migration.html), - 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](https://developer.concordium.software/concordium-node-sdk-js/pages/misc-pages/grpc-v1.html). - -## Creating buffers - -Some of the functions in the SDK expects buffers as -input. For this purpose the SDK exports a `toBuffer` -function, which is a polyfill of the [buffer.from from the Nodejs -API](https://nodejs.org/api/buffer.html#static-method-bufferfromstring-encoding) -for strings. - -```ts -const myBuffer = toBuffer('AB2C2D', 'hex'); -``` - -## Examples - -A few simple webpages have been made, to showcase using the web-sdk. They -can be found in the `example` folder. Note that the project should be built -before running the examples, otherwise they won't work. The examples that -use JSON-RPC expect a JSON-RPC server on running at `http://localhost:9095`. - -### SendTransaction.html - -An example of how to send a transaction using the SDK to a JSON-RPC server. - -### GetInstanceInfo.html - -An example of getting the info of a given smart contract instance using a -JSON-RPC server. - -### Alias.html - -A very minimal example of a webpage showing alias'es of a given address, -using the bundled SDK. - -### GetTransactionStatus.html - -A simple example that allows calling a JSON-RPC server for a given -transaction's status and displays the status. - -### GetNonce.html - -A simple example that allows calling a JSON-RPC server for a given account's -next nonce and displays it. - -### InvokeContract.html - -An simple example of how to invoke a given smart contract instance using a -JSON-RPC server. - -### GetCryptographicParameters.html - -An example of getting the crypgographic parameters of the chain using a -JSON-RPC server. - -### GetAccountInfo.html - -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. - -### SendCIS2Transfer.html - -An example of sending a CIS2 "transfer" transaction -by utilizing the `CIS2Contract` class. Please -note that this example requires the [Concordium Wallet for -Web](https://chrome.google.com/webstore/detail/concordium-wallet/mnnkpffndmickbiakofclnpoiajlegmg) -to be installed to work. - -### SendCIS2UpdateOperator.html - -An example of sending a CIS2 "updateOperator" -transaction by utilizing the `CIS2Contract` class. Please -note that this example requires the [Concordium Wallet for -Web](https://chrome.google.com/webstore/detail/concordium-wallet/mnnkpffndmickbiakofclnpoiajlegmg) -to be installed to work. diff --git a/packages/web/example/Alias.html b/packages/web/example/Alias.html deleted file mode 100644 index 8f2d4a36c..000000000 --- a/packages/web/example/Alias.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - -
- -
-