Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def pipeline = new org.js.LibPipeline( steps: this,
preBuildCmds: ['npm install -g n','n 16.17.0', 'n prune', 'pnpm install --unsafe-perm'],
testCmds: ['pnpm type-check','pnpm test','npm config set registry "https://nexus.iroha.tech/repository/npm-soramitsu/"'],
pushCmds: ['pnpm jake publish-all'],
secretScannerExclusion: '.*Cargo.toml'
secretScannerExclusion: '.*Cargo.toml\$|.*README.md\$'
)
pipeline.runPipeline()
pipeline.runPipeline()
81 changes: 69 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,97 @@ The Iroha 2 JavaScript library includes the following packages:
- [`@iroha2/crypto-target-web`](./packages/crypto/packages/target-web/) provides compiled crypto WASM for native Web (ESM)
- [`@iroha2/crypto-target-bundler`](./packages/crypto/packages/target-bundler/) provides compiled crypto WASM to use with bundlers such as Webpack
- [`@iroha2/data-model`](./packages/data-model/) provides SCALE codecs for Iroha 2 data model

Other packages you can find in this repository:

- [`@iroha2/client-isomorphic-fetch`](./packages/client-isomorphic-fetch/) fallbacks to `node-fetch` or native `fetch()` in Node.js
- [`@iroha2/client-isomorphic-ws`](./packages/client-isomorphic-ws/) contains isomorphic WebSocket transport for `@iroha2/client`
- [`@iroha2/docs-recipes`](./packages/docs-recipes/) contains code samples used in documentation
- [`@iroha2/data-model-schema`](./packages/data-model-schema/) contains Iroha 2 Schema
- [`@iroha2/i64-fixnum`](./packages/i64-fixnum/) handles operations with fixed-point numbers


## Installation

The packages are published under the `@iroha2` scope into Iroha Nexus Registry. To install them using `npm`/`pnpm`, follow these steps:

1. Configure your package manager to fetch scoped packages from Nexus Registry:

```ini
# FILE: .npmrc
@iroha2:registry=https://nexus.iroha.tech/repository/npm-group/
```
```ini
# FILE: .npmrc
@iroha2:registry=https://nexus.iroha.tech/repository/npm-group/
```

2. Install these packages as any other NPM package:

```shell
npm i @iroha2/client
yarn add @iroha2/data-model
pnpm add @iroha2/crypto-target-web
```
```shell
npm i @iroha2/client
yarn add @iroha2/data-model
pnpm add @iroha2/crypto-target-web
```

## Get Started

Check out [Hyperledger Iroha 2 Tutorial](https://hyperledger.github.io/iroha-2-docs/) that introduces you to Iroha 2 concepts and features and provides you with a step-by-step guide for JavaScript/TypeScript.

## Explore Jake tasks
## Maintenance

### Explore Jake tasks

```bash
pnpm jake -t
```

### Manually update reference Iroha version

1. Update `packages/dev-iroha-bins/src/config.ts`:

```ts
const config: Config = {
// ...

// update git repo reference here
git: {
repo: 'https://github.com/hyperledger/iroha.git',
revision: 'b783f10fa7de26ed1fdd4c526bd162f8636f1a65',
},

// ...
}
```

2. Set the same Iroha version in `packages/data-model-rust-samples/Cargo.toml`:

```toml
iroha_data_model = { git = 'https://github.com/hyperledger/iroha.git', rev = "b783f10fa7de26ed1fdd4c526bd162f8636f1a65" }
```

3. Update JSON data-model samples used for tests. In `packages/data-model-rust-samples`, run:

```bash
cargo run > output.json
```

4. Re-compile data-model schema:

```bash
pnpm --filter data-model-schema compile
```

5. Run codegen for data-model:

```bash
pnpm --filter data-model codegen
```

6. Use tests and TypeScript hints and update the rest of the SDK:

```bash
pnpm -w type-check
pnpm -w test
```

7. Update `packages/client/README.md` and `packages/data-model/README.md`. In the beginning they have the following note:

> This package targets `hyperledger/iroha` at current `iroha2-lts` branch, which has a hash `b783f10fa7de26ed1fdd4c526bd162f8636f1a65`.

Put here a new Iroha 2 reference commit information.
73 changes: 72 additions & 1 deletion packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,76 @@
# @iroha2/client

## 4.0.0

### Major Changes

- e27467e: Update client library after data-model update in Iroha 2.
- bd757cf: **refactor!**: make `Torii` stateless; force prerequisites to be passed for each method.

##### What is the change

Previously, `Torii` was a class, and its constructor accepted all prerequisites at once:

```ts
const torii = new Torii({ apiURL, telemetryURL, fetch, ws })

torii.submit(transaction)
torii.getStatus()
torii.listenForEvents({ filter })
```

Now, `Torii` is a compendium of different methods. Each method has its own prerequisites:

```ts
Torii.submit({ apiURL, fetch }, transaction)

Torii.getStatus({ telemetryURL, fetch })

Torii.listenForEvents({ apiURL, ws }, { filter })
```

##### Why the change was made

This change was introduced to allow you to only provide the prerequisites each method actually needs. For example, you no longer need to provide `ws` when all you want to do is submit a transaction. Only `fetch` and `apiURL` are needed for transaction to be submitted.

##### How to update your code

You should pass the necessary prerequisites for each `Torii` method invocation.

Previously, you had to create a single `Torii` instance:

```ts
const torii = new Torii({ apiURL, telemetryURL, fetch, ws })
```

You no longer need a single `Torii` instance. Instead, you create an object with necessary prerequisites:

```ts
const pre = { apiURL, fetch }
```

Then pass the prerequisites when you need to call this method:

```ts
Torii.submit(pre, transaction)
```

### Minor Changes

- e27467e: Some functions were renamed:

- `makeSignedTransaction` → `makeVersionedSignedTransaction`
- `makeSignedQuery` → `makeVersionedSignedQuery`

Old names are still accessible. They are marked as `deprecated` and will be removed in future major releases.

- bd757cf: **feat**: expose `keyPair` as a `public readonly` field from `Signer`

### Patch Changes

- Updated dependencies [e27467e]
- @iroha2/data-model@4.0.0

## 3.0.0

### Major Changes
Expand All @@ -18,7 +89,7 @@

##### How to update your code

The changes you need to make to the code are rather straightforward. Here we provide a couple of examples for you to compare the code before and after this breaking change. You can refer to `Torii`, `Signer` and `Client` type definitions for details.
The changes you need to make to the code are rather straightforward. Here we provide a couple of examples for you to compare the code before and after this breaking change. You can refer to `Torii`, `Signer` and `Client` type definitions for details.

`Client` used to be initialized like this:

Expand Down
2 changes: 1 addition & 1 deletion packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Client for Iroha 2, which is used to submit requests to Iroha peer.

## Target version

This package targets `hyperledger/iroha` at current `iroha2-lts` branch, which has a hash `9bfdb39aaaa2490a82a17ebc255d3557d3ad38da`.
This package targets `hyperledger/iroha` at current `iroha2-lts` branch, which has a hash `b783f10fa7de26ed1fdd4c526bd162f8636f1a65`.

## Installation

Expand Down
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iroha2/client",
"version": "3.0.0",
"version": "4.0.0",
"module": "dist/lib.mjs",
"main": "dist/lib.cjs",
"types": "dist/lib.d.ts",
Expand Down Expand Up @@ -38,7 +38,7 @@
},
"dependencies": {
"@iroha2/crypto-core": "workspace:^0.1.1",
"@iroha2/data-model": "workspace:3.0.0",
"@iroha2/data-model": "workspace:4.0.0",
"@types/ws": "^8.2.2",
"debug": "^4.3.4",
"emittery": "^0.10.1",
Expand Down
Loading