From 521156b6a5e08f09a4e780892094742371e3b643 Mon Sep 17 00:00:00 2001 From: antonmazhuto Date: Tue, 3 Jun 2025 01:32:46 +0300 Subject: [PATCH 01/13] Release v2.15.0 --- CHANGELOG.md | 4 ++ examples/cli/CHANGELOG.md | 4 ++ examples/cli/package.json | 4 +- examples/node/CHANGELOG.md | 4 ++ examples/node/package.json | 6 +-- lerna.json | 2 +- package-lock.json | 58 +++++++++++++------------- packages/blockchain/CHANGELOG.md | 4 ++ packages/blockchain/package.json | 2 +- packages/changelog-preset/CHANGELOG.md | 4 ++ packages/changelog-preset/package.json | 2 +- packages/cli/CHANGELOG.md | 4 ++ packages/cli/package.json | 6 +-- packages/ddc-client/CHANGELOG.md | 4 ++ packages/ddc-client/package.json | 8 ++-- packages/ddc/CHANGELOG.md | 4 ++ packages/ddc/package.json | 4 +- packages/eslint-config/CHANGELOG.md | 4 ++ packages/eslint-config/package.json | 2 +- packages/file-storage/CHANGELOG.md | 4 ++ packages/file-storage/package.json | 6 +-- packages/typedoc-config/CHANGELOG.md | 4 ++ packages/typedoc-config/package.json | 2 +- playground/CHANGELOG.md | 4 ++ playground/package.json | 6 +-- tests/CHANGELOG.md | 4 ++ tests/package.json | 10 ++--- 27 files changed, 111 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb0dd99b..e474f23e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) + +**Note:** Version bump only for package cere-ddc-sdk + ## [2.14.1](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.13.0...v2.14.1) (2025-01-28) ### Miscellaneous Chores diff --git a/examples/cli/CHANGELOG.md b/examples/cli/CHANGELOG.md index af753e03..6347b42b 100644 --- a/examples/cli/CHANGELOG.md +++ b/examples/cli/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/cli-examples + ## [2.14.1](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.13.0...v2.14.1) (2025-01-28) **Note:** Version bump only for package @cere-ddc-sdk/cli-examples diff --git a/examples/cli/package.json b/examples/cli/package.json index ae216452..47623e2e 100644 --- a/examples/cli/package.json +++ b/examples/cli/package.json @@ -1,8 +1,8 @@ { "name": "@cere-ddc-sdk/cli-examples", - "version": "2.14.1", + "version": "2.15.0", "private": true, "dependencies": { - "@cere-ddc-sdk/cli": "2.14.1" + "@cere-ddc-sdk/cli": "2.15.0" } } diff --git a/examples/node/CHANGELOG.md b/examples/node/CHANGELOG.md index 03a858b5..caac2c1c 100644 --- a/examples/node/CHANGELOG.md +++ b/examples/node/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/node-examples + ## [2.14.1](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.13.0...v2.14.1) (2025-01-28) **Note:** Version bump only for package @cere-ddc-sdk/node-examples diff --git a/examples/node/package.json b/examples/node/package.json index 952f543e..c3559480 100644 --- a/examples/node/package.json +++ b/examples/node/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/node-examples", - "version": "2.14.1", + "version": "2.15.0", "private": true, "type": "module", "scripts": { @@ -14,8 +14,8 @@ "example:8": "ts-node --esm ./8-sudo-batch-remove-buckets/index.ts" }, "dependencies": { - "@cere-ddc-sdk/blockchain": "^2.14.1", - "@cere-ddc-sdk/ddc-client": "2.14.1", + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc-client": "2.15.0", "@types/json-bigint": "^1.0.4", "json-bigint": "^1.0.0", "ts-node": "^10.9.2" diff --git a/lerna.json b/lerna.json index c51a579e..e884c578 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "2.14.1", + "version": "2.15.0", "command": { "publish": { "directory": "{workspaceRoot}/{projectRoot}/package" diff --git a/package-lock.json b/package-lock.json index 47f4a0d4..cca0b7e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,17 +38,17 @@ }, "examples/cli": { "name": "@cere-ddc-sdk/cli-examples", - "version": "2.14.1", + "version": "2.15.0", "dependencies": { - "@cere-ddc-sdk/cli": "2.14.1" + "@cere-ddc-sdk/cli": "2.15.0" } }, "examples/node": { "name": "@cere-ddc-sdk/node-examples", - "version": "2.14.1", + "version": "2.15.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "^2.14.1", - "@cere-ddc-sdk/ddc-client": "2.14.1", + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc-client": "2.15.0", "@types/json-bigint": "^1.0.4", "json-bigint": "^1.0.0", "ts-node": "^10.9.2" @@ -23143,7 +23143,7 @@ }, "packages/blockchain": { "name": "@cere-ddc-sdk/blockchain", - "version": "2.14.1", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { "@cere/embed-wallet-inject": "^0.20.1", @@ -23477,7 +23477,7 @@ }, "packages/changelog-preset": { "name": "@cere-ddc-sdk/conventional-changelog-changelog-preset", - "version": "2.7.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { "conventional-changelog-conventionalcommits": "^7.0.2" @@ -23485,11 +23485,11 @@ }, "packages/cli": { "name": "@cere-ddc-sdk/cli", - "version": "2.14.1", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/ddc": "2.14.1", - "@cere-ddc-sdk/ddc-client": "2.14.1", + "@cere-ddc-sdk/ddc": "2.15.0", + "@cere-ddc-sdk/ddc-client": "2.15.0", "@polkadot/util-crypto": "^13.3.1", "@types/yargs": "^17.0.32", "yargs": "^17.7.2" @@ -23503,10 +23503,10 @@ }, "packages/ddc": { "name": "@cere-ddc-sdk/ddc", - "version": "2.14.1", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.14.1", + "@cere-ddc-sdk/blockchain": "2.15.0", "@grpc/grpc-js": "^1.9.13", "@protobuf-ts/grpc-transport": "^2.9.3", "@protobuf-ts/runtime": "^2.9.3", @@ -23535,12 +23535,12 @@ }, "packages/ddc-client": { "name": "@cere-ddc-sdk/ddc-client", - "version": "2.14.1", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.14.1", - "@cere-ddc-sdk/ddc": "2.14.1", - "@cere-ddc-sdk/file-storage": "2.14.1" + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc": "2.15.0", + "@cere-ddc-sdk/file-storage": "2.15.0" } }, "packages/ddc/node_modules/buffer": { @@ -23567,7 +23567,7 @@ }, "packages/eslint-config": { "name": "@cere-ddc-sdk/eslint-config", - "version": "2.7.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { "@typescript-eslint/eslint-plugin": "^6.16.0", @@ -23584,16 +23584,16 @@ }, "packages/file-storage": { "name": "@cere-ddc-sdk/file-storage", - "version": "2.14.1", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.14.1", - "@cere-ddc-sdk/ddc": "2.14.1" + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc": "2.15.0" } }, "packages/typedoc-config": { "name": "@cere-ddc-sdk/typedoc-config", - "version": "2.7.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { "typedoc-plugin-markdown": "^3.17.1" @@ -23604,10 +23604,10 @@ }, "playground": { "name": "@cere-ddc-sdk/playground", - "version": "2.14.1", + "version": "2.15.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.14.1", - "@cere-ddc-sdk/ddc-client": "2.14.1", + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc-client": "2.15.0", "@cere/embed-wallet": "^0.20.1", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", @@ -23631,12 +23631,12 @@ }, "tests": { "name": "@cere-ddc-sdk/tests", - "version": "2.14.1", + "version": "2.15.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.14.1", - "@cere-ddc-sdk/ddc": "2.14.1", - "@cere-ddc-sdk/ddc-client": "2.14.1", - "@cere-ddc-sdk/file-storage": "2.14.1", + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc": "2.15.0", + "@cere-ddc-sdk/ddc-client": "2.15.0", + "@cere-ddc-sdk/file-storage": "2.15.0", "@types/jest": "^29.5.11", "internal-ip": "6.2.0", "jest": "^29.7.0", diff --git a/packages/blockchain/CHANGELOG.md b/packages/blockchain/CHANGELOG.md index 39a0c97e..b1ea8fbb 100644 --- a/packages/blockchain/CHANGELOG.md +++ b/packages/blockchain/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/blockchain + ## [2.14.1](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.13.0...v2.14.1) (2025-01-28) **Note:** Version bump only for package @cere-ddc-sdk/blockchain diff --git a/packages/blockchain/package.json b/packages/blockchain/package.json index 7f243b3f..87468700 100644 --- a/packages/blockchain/package.json +++ b/packages/blockchain/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/blockchain", - "version": "2.14.1", + "version": "2.15.0", "description": "Cere Blockchain client", "type": "module", "main": "dist/index.cjs", diff --git a/packages/changelog-preset/CHANGELOG.md b/packages/changelog-preset/CHANGELOG.md index 255c58eb..9012028f 100644 --- a/packages/changelog-preset/CHANGELOG.md +++ b/packages/changelog-preset/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/conventional-changelog-changelog-preset + ## [2.7.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.7.0-rc.2...v2.7.0) (2024-05-06) **Note:** Version bump only for package @cere-ddc-sdk/conventional-changelog-changelog-preset diff --git a/packages/changelog-preset/package.json b/packages/changelog-preset/package.json index c9249c12..4c4896f3 100644 --- a/packages/changelog-preset/package.json +++ b/packages/changelog-preset/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/conventional-changelog-changelog-preset", - "version": "2.7.0", + "version": "2.15.0", "private": true, "author": "Cere Network Date: Tue, 3 Jun 2025 01:36:00 +0300 Subject: [PATCH 02/13] Release v2.15.0 --- CHANGELOG.md | 2 ++ examples/cli/CHANGELOG.md | 2 ++ examples/node/CHANGELOG.md | 2 ++ packages/blockchain/CHANGELOG.md | 2 ++ packages/changelog-preset/CHANGELOG.md | 2 ++ packages/cli/CHANGELOG.md | 2 ++ packages/ddc-client/CHANGELOG.md | 2 ++ packages/ddc/CHANGELOG.md | 2 ++ packages/eslint-config/CHANGELOG.md | 2 ++ packages/file-storage/CHANGELOG.md | 2 ++ packages/typedoc-config/CHANGELOG.md | 2 ++ playground/CHANGELOG.md | 2 ++ tests/CHANGELOG.md | 2 ++ 13 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e474f23e..bb99dce2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package cere-ddc-sdk + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package cere-ddc-sdk diff --git a/examples/cli/CHANGELOG.md b/examples/cli/CHANGELOG.md index 6347b42b..87a003d8 100644 --- a/examples/cli/CHANGELOG.md +++ b/examples/cli/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/cli-examples + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/cli-examples diff --git a/examples/node/CHANGELOG.md b/examples/node/CHANGELOG.md index caac2c1c..56a30f59 100644 --- a/examples/node/CHANGELOG.md +++ b/examples/node/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/node-examples + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/node-examples diff --git a/packages/blockchain/CHANGELOG.md b/packages/blockchain/CHANGELOG.md index b1ea8fbb..31f45456 100644 --- a/packages/blockchain/CHANGELOG.md +++ b/packages/blockchain/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/blockchain + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/blockchain diff --git a/packages/changelog-preset/CHANGELOG.md b/packages/changelog-preset/CHANGELOG.md index 9012028f..7d88593d 100644 --- a/packages/changelog-preset/CHANGELOG.md +++ b/packages/changelog-preset/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/conventional-changelog-changelog-preset + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/conventional-changelog-changelog-preset diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 73f648e9..7f1a3b6b 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/cli + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/cli diff --git a/packages/ddc-client/CHANGELOG.md b/packages/ddc-client/CHANGELOG.md index 97af45f0..0a2af5c8 100644 --- a/packages/ddc-client/CHANGELOG.md +++ b/packages/ddc-client/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/ddc-client + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/ddc-client diff --git a/packages/ddc/CHANGELOG.md b/packages/ddc/CHANGELOG.md index f5ec964e..5690d09d 100644 --- a/packages/ddc/CHANGELOG.md +++ b/packages/ddc/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/ddc + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/ddc diff --git a/packages/eslint-config/CHANGELOG.md b/packages/eslint-config/CHANGELOG.md index 0ebec0b8..1d8ba4c0 100644 --- a/packages/eslint-config/CHANGELOG.md +++ b/packages/eslint-config/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/eslint-config + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/eslint-config diff --git a/packages/file-storage/CHANGELOG.md b/packages/file-storage/CHANGELOG.md index 20d58d97..c15e6ac9 100644 --- a/packages/file-storage/CHANGELOG.md +++ b/packages/file-storage/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/file-storage + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/file-storage diff --git a/packages/typedoc-config/CHANGELOG.md b/packages/typedoc-config/CHANGELOG.md index 8382096a..abddf35f 100644 --- a/packages/typedoc-config/CHANGELOG.md +++ b/packages/typedoc-config/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/typedoc-config + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/typedoc-config diff --git a/playground/CHANGELOG.md b/playground/CHANGELOG.md index 2db7606f..df711a10 100644 --- a/playground/CHANGELOG.md +++ b/playground/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/playground + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/playground diff --git a/tests/CHANGELOG.md b/tests/CHANGELOG.md index a0abf285..3ebfdfbd 100644 --- a/tests/CHANGELOG.md +++ b/tests/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +**Note:** Version bump only for package @cere-ddc-sdk/tests + ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/tests From e74a3f6f7f2e8ef7c5a064bb7c713baada6f137d Mon Sep 17 00:00:00 2001 From: antonmazhuto Date: Tue, 3 Jun 2025 01:36:47 +0300 Subject: [PATCH 03/13] Release v2.16.0 --- CHANGELOG.md | 4 ++ examples/cli/CHANGELOG.md | 4 ++ examples/cli/package.json | 4 +- examples/node/CHANGELOG.md | 4 ++ examples/node/package.json | 6 +-- lerna.json | 2 +- package-lock.json | 58 +++++++++++++------------- packages/blockchain/CHANGELOG.md | 4 ++ packages/blockchain/package.json | 2 +- packages/changelog-preset/CHANGELOG.md | 4 ++ packages/changelog-preset/package.json | 2 +- packages/cli/CHANGELOG.md | 4 ++ packages/cli/package.json | 6 +-- packages/ddc-client/CHANGELOG.md | 4 ++ packages/ddc-client/package.json | 8 ++-- packages/ddc/CHANGELOG.md | 4 ++ packages/ddc/package.json | 4 +- packages/eslint-config/CHANGELOG.md | 4 ++ packages/eslint-config/package.json | 2 +- packages/file-storage/CHANGELOG.md | 4 ++ packages/file-storage/package.json | 6 +-- packages/typedoc-config/CHANGELOG.md | 4 ++ packages/typedoc-config/package.json | 2 +- playground/CHANGELOG.md | 4 ++ playground/package.json | 6 +-- tests/CHANGELOG.md | 4 ++ tests/package.json | 10 ++--- 27 files changed, 111 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb99dce2..56bff0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.16.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.15.0...v2.16.0) (2025-06-02) + +**Note:** Version bump only for package cere-ddc-sdk + **Note:** Version bump only for package cere-ddc-sdk ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) diff --git a/examples/cli/CHANGELOG.md b/examples/cli/CHANGELOG.md index 87a003d8..3fa05804 100644 --- a/examples/cli/CHANGELOG.md +++ b/examples/cli/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.16.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.15.0...v2.16.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/cli-examples + **Note:** Version bump only for package @cere-ddc-sdk/cli-examples ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) diff --git a/examples/cli/package.json b/examples/cli/package.json index 47623e2e..1f84da04 100644 --- a/examples/cli/package.json +++ b/examples/cli/package.json @@ -1,8 +1,8 @@ { "name": "@cere-ddc-sdk/cli-examples", - "version": "2.15.0", + "version": "2.16.0", "private": true, "dependencies": { - "@cere-ddc-sdk/cli": "2.15.0" + "@cere-ddc-sdk/cli": "2.16.0" } } diff --git a/examples/node/CHANGELOG.md b/examples/node/CHANGELOG.md index 56a30f59..c678b197 100644 --- a/examples/node/CHANGELOG.md +++ b/examples/node/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.16.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.15.0...v2.16.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/node-examples + **Note:** Version bump only for package @cere-ddc-sdk/node-examples ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) diff --git a/examples/node/package.json b/examples/node/package.json index c3559480..e2c2e8fe 100644 --- a/examples/node/package.json +++ b/examples/node/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/node-examples", - "version": "2.15.0", + "version": "2.16.0", "private": true, "type": "module", "scripts": { @@ -14,8 +14,8 @@ "example:8": "ts-node --esm ./8-sudo-batch-remove-buckets/index.ts" }, "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc-client": "2.15.0", + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc-client": "2.16.0", "@types/json-bigint": "^1.0.4", "json-bigint": "^1.0.0", "ts-node": "^10.9.2" diff --git a/lerna.json b/lerna.json index e884c578..555c2087 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "2.15.0", + "version": "2.16.0", "command": { "publish": { "directory": "{workspaceRoot}/{projectRoot}/package" diff --git a/package-lock.json b/package-lock.json index cca0b7e1..2feeb487 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,17 +38,17 @@ }, "examples/cli": { "name": "@cere-ddc-sdk/cli-examples", - "version": "2.15.0", + "version": "2.16.0", "dependencies": { - "@cere-ddc-sdk/cli": "2.15.0" + "@cere-ddc-sdk/cli": "2.16.0" } }, "examples/node": { "name": "@cere-ddc-sdk/node-examples", - "version": "2.15.0", + "version": "2.16.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc-client": "2.15.0", + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc-client": "2.16.0", "@types/json-bigint": "^1.0.4", "json-bigint": "^1.0.0", "ts-node": "^10.9.2" @@ -23143,7 +23143,7 @@ }, "packages/blockchain": { "name": "@cere-ddc-sdk/blockchain", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { "@cere/embed-wallet-inject": "^0.20.1", @@ -23477,7 +23477,7 @@ }, "packages/changelog-preset": { "name": "@cere-ddc-sdk/conventional-changelog-changelog-preset", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { "conventional-changelog-conventionalcommits": "^7.0.2" @@ -23485,11 +23485,11 @@ }, "packages/cli": { "name": "@cere-ddc-sdk/cli", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/ddc": "2.15.0", - "@cere-ddc-sdk/ddc-client": "2.15.0", + "@cere-ddc-sdk/ddc": "2.16.0", + "@cere-ddc-sdk/ddc-client": "2.16.0", "@polkadot/util-crypto": "^13.3.1", "@types/yargs": "^17.0.32", "yargs": "^17.7.2" @@ -23503,10 +23503,10 @@ }, "packages/ddc": { "name": "@cere-ddc-sdk/ddc", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/blockchain": "2.16.0", "@grpc/grpc-js": "^1.9.13", "@protobuf-ts/grpc-transport": "^2.9.3", "@protobuf-ts/runtime": "^2.9.3", @@ -23535,12 +23535,12 @@ }, "packages/ddc-client": { "name": "@cere-ddc-sdk/ddc-client", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc": "2.15.0", - "@cere-ddc-sdk/file-storage": "2.15.0" + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc": "2.16.0", + "@cere-ddc-sdk/file-storage": "2.16.0" } }, "packages/ddc/node_modules/buffer": { @@ -23567,7 +23567,7 @@ }, "packages/eslint-config": { "name": "@cere-ddc-sdk/eslint-config", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { "@typescript-eslint/eslint-plugin": "^6.16.0", @@ -23584,16 +23584,16 @@ }, "packages/file-storage": { "name": "@cere-ddc-sdk/file-storage", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc": "2.15.0" + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc": "2.16.0" } }, "packages/typedoc-config": { "name": "@cere-ddc-sdk/typedoc-config", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { "typedoc-plugin-markdown": "^3.17.1" @@ -23604,10 +23604,10 @@ }, "playground": { "name": "@cere-ddc-sdk/playground", - "version": "2.15.0", + "version": "2.16.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc-client": "2.15.0", + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc-client": "2.16.0", "@cere/embed-wallet": "^0.20.1", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", @@ -23631,12 +23631,12 @@ }, "tests": { "name": "@cere-ddc-sdk/tests", - "version": "2.15.0", + "version": "2.16.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc": "2.15.0", - "@cere-ddc-sdk/ddc-client": "2.15.0", - "@cere-ddc-sdk/file-storage": "2.15.0", + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc": "2.16.0", + "@cere-ddc-sdk/ddc-client": "2.16.0", + "@cere-ddc-sdk/file-storage": "2.16.0", "@types/jest": "^29.5.11", "internal-ip": "6.2.0", "jest": "^29.7.0", diff --git a/packages/blockchain/CHANGELOG.md b/packages/blockchain/CHANGELOG.md index 31f45456..33a93c07 100644 --- a/packages/blockchain/CHANGELOG.md +++ b/packages/blockchain/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.16.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.15.0...v2.16.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/blockchain + **Note:** Version bump only for package @cere-ddc-sdk/blockchain ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) diff --git a/packages/blockchain/package.json b/packages/blockchain/package.json index 87468700..e80b5c4f 100644 --- a/packages/blockchain/package.json +++ b/packages/blockchain/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/blockchain", - "version": "2.15.0", + "version": "2.16.0", "description": "Cere Blockchain client", "type": "module", "main": "dist/index.cjs", diff --git a/packages/changelog-preset/CHANGELOG.md b/packages/changelog-preset/CHANGELOG.md index 7d88593d..b25216a5 100644 --- a/packages/changelog-preset/CHANGELOG.md +++ b/packages/changelog-preset/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.16.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.15.0...v2.16.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/conventional-changelog-changelog-preset + **Note:** Version bump only for package @cere-ddc-sdk/conventional-changelog-changelog-preset ## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) diff --git a/packages/changelog-preset/package.json b/packages/changelog-preset/package.json index 4c4896f3..e4915b78 100644 --- a/packages/changelog-preset/package.json +++ b/packages/changelog-preset/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/conventional-changelog-changelog-preset", - "version": "2.15.0", + "version": "2.16.0", "private": true, "author": "Cere Network Date: Tue, 3 Jun 2025 01:42:29 +0300 Subject: [PATCH 04/13] Release v2.15.0 --- CHANGELOG.md | 4 ++ examples/cli/CHANGELOG.md | 4 ++ examples/cli/package.json | 4 +- examples/node/CHANGELOG.md | 4 ++ examples/node/package.json | 6 +-- lerna.json | 2 +- package-lock.json | 58 +++++++++++++------------- packages/blockchain/CHANGELOG.md | 4 ++ packages/blockchain/package.json | 2 +- packages/changelog-preset/CHANGELOG.md | 4 ++ packages/changelog-preset/package.json | 2 +- packages/cli/CHANGELOG.md | 4 ++ packages/cli/package.json | 6 +-- packages/ddc-client/CHANGELOG.md | 4 ++ packages/ddc-client/package.json | 8 ++-- packages/ddc/CHANGELOG.md | 4 ++ packages/ddc/package.json | 4 +- packages/eslint-config/CHANGELOG.md | 4 ++ packages/eslint-config/package.json | 2 +- packages/file-storage/CHANGELOG.md | 4 ++ packages/file-storage/package.json | 6 +-- packages/typedoc-config/CHANGELOG.md | 4 ++ packages/typedoc-config/package.json | 2 +- playground/CHANGELOG.md | 4 ++ playground/package.json | 6 +-- tests/CHANGELOG.md | 4 ++ tests/package.json | 10 ++--- 27 files changed, 111 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56bff0ad..45027955 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) + +**Note:** Version bump only for package cere-ddc-sdk + ## [2.16.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.15.0...v2.16.0) (2025-06-02) **Note:** Version bump only for package cere-ddc-sdk diff --git a/examples/cli/CHANGELOG.md b/examples/cli/CHANGELOG.md index 3fa05804..e5751a01 100644 --- a/examples/cli/CHANGELOG.md +++ b/examples/cli/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/cli-examples + ## [2.16.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.15.0...v2.16.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/cli-examples diff --git a/examples/cli/package.json b/examples/cli/package.json index 1f84da04..47623e2e 100644 --- a/examples/cli/package.json +++ b/examples/cli/package.json @@ -1,8 +1,8 @@ { "name": "@cere-ddc-sdk/cli-examples", - "version": "2.16.0", + "version": "2.15.0", "private": true, "dependencies": { - "@cere-ddc-sdk/cli": "2.16.0" + "@cere-ddc-sdk/cli": "2.15.0" } } diff --git a/examples/node/CHANGELOG.md b/examples/node/CHANGELOG.md index c678b197..1a15b0fd 100644 --- a/examples/node/CHANGELOG.md +++ b/examples/node/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/node-examples + ## [2.16.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.15.0...v2.16.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/node-examples diff --git a/examples/node/package.json b/examples/node/package.json index e2c2e8fe..c3559480 100644 --- a/examples/node/package.json +++ b/examples/node/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/node-examples", - "version": "2.16.0", + "version": "2.15.0", "private": true, "type": "module", "scripts": { @@ -14,8 +14,8 @@ "example:8": "ts-node --esm ./8-sudo-batch-remove-buckets/index.ts" }, "dependencies": { - "@cere-ddc-sdk/blockchain": "2.16.0", - "@cere-ddc-sdk/ddc-client": "2.16.0", + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc-client": "2.15.0", "@types/json-bigint": "^1.0.4", "json-bigint": "^1.0.0", "ts-node": "^10.9.2" diff --git a/lerna.json b/lerna.json index 555c2087..e884c578 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "2.16.0", + "version": "2.15.0", "command": { "publish": { "directory": "{workspaceRoot}/{projectRoot}/package" diff --git a/package-lock.json b/package-lock.json index 2feeb487..cca0b7e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,17 +38,17 @@ }, "examples/cli": { "name": "@cere-ddc-sdk/cli-examples", - "version": "2.16.0", + "version": "2.15.0", "dependencies": { - "@cere-ddc-sdk/cli": "2.16.0" + "@cere-ddc-sdk/cli": "2.15.0" } }, "examples/node": { "name": "@cere-ddc-sdk/node-examples", - "version": "2.16.0", + "version": "2.15.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.16.0", - "@cere-ddc-sdk/ddc-client": "2.16.0", + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc-client": "2.15.0", "@types/json-bigint": "^1.0.4", "json-bigint": "^1.0.0", "ts-node": "^10.9.2" @@ -23143,7 +23143,7 @@ }, "packages/blockchain": { "name": "@cere-ddc-sdk/blockchain", - "version": "2.16.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { "@cere/embed-wallet-inject": "^0.20.1", @@ -23477,7 +23477,7 @@ }, "packages/changelog-preset": { "name": "@cere-ddc-sdk/conventional-changelog-changelog-preset", - "version": "2.16.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { "conventional-changelog-conventionalcommits": "^7.0.2" @@ -23485,11 +23485,11 @@ }, "packages/cli": { "name": "@cere-ddc-sdk/cli", - "version": "2.16.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/ddc": "2.16.0", - "@cere-ddc-sdk/ddc-client": "2.16.0", + "@cere-ddc-sdk/ddc": "2.15.0", + "@cere-ddc-sdk/ddc-client": "2.15.0", "@polkadot/util-crypto": "^13.3.1", "@types/yargs": "^17.0.32", "yargs": "^17.7.2" @@ -23503,10 +23503,10 @@ }, "packages/ddc": { "name": "@cere-ddc-sdk/ddc", - "version": "2.16.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/blockchain": "2.15.0", "@grpc/grpc-js": "^1.9.13", "@protobuf-ts/grpc-transport": "^2.9.3", "@protobuf-ts/runtime": "^2.9.3", @@ -23535,12 +23535,12 @@ }, "packages/ddc-client": { "name": "@cere-ddc-sdk/ddc-client", - "version": "2.16.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.16.0", - "@cere-ddc-sdk/ddc": "2.16.0", - "@cere-ddc-sdk/file-storage": "2.16.0" + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc": "2.15.0", + "@cere-ddc-sdk/file-storage": "2.15.0" } }, "packages/ddc/node_modules/buffer": { @@ -23567,7 +23567,7 @@ }, "packages/eslint-config": { "name": "@cere-ddc-sdk/eslint-config", - "version": "2.16.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { "@typescript-eslint/eslint-plugin": "^6.16.0", @@ -23584,16 +23584,16 @@ }, "packages/file-storage": { "name": "@cere-ddc-sdk/file-storage", - "version": "2.16.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.16.0", - "@cere-ddc-sdk/ddc": "2.16.0" + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc": "2.15.0" } }, "packages/typedoc-config": { "name": "@cere-ddc-sdk/typedoc-config", - "version": "2.16.0", + "version": "2.15.0", "license": "Apache-2.0", "dependencies": { "typedoc-plugin-markdown": "^3.17.1" @@ -23604,10 +23604,10 @@ }, "playground": { "name": "@cere-ddc-sdk/playground", - "version": "2.16.0", + "version": "2.15.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.16.0", - "@cere-ddc-sdk/ddc-client": "2.16.0", + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc-client": "2.15.0", "@cere/embed-wallet": "^0.20.1", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", @@ -23631,12 +23631,12 @@ }, "tests": { "name": "@cere-ddc-sdk/tests", - "version": "2.16.0", + "version": "2.15.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.16.0", - "@cere-ddc-sdk/ddc": "2.16.0", - "@cere-ddc-sdk/ddc-client": "2.16.0", - "@cere-ddc-sdk/file-storage": "2.16.0", + "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/ddc": "2.15.0", + "@cere-ddc-sdk/ddc-client": "2.15.0", + "@cere-ddc-sdk/file-storage": "2.15.0", "@types/jest": "^29.5.11", "internal-ip": "6.2.0", "jest": "^29.7.0", diff --git a/packages/blockchain/CHANGELOG.md b/packages/blockchain/CHANGELOG.md index 33a93c07..f120092c 100644 --- a/packages/blockchain/CHANGELOG.md +++ b/packages/blockchain/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/blockchain + ## [2.16.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.15.0...v2.16.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/blockchain diff --git a/packages/blockchain/package.json b/packages/blockchain/package.json index e80b5c4f..87468700 100644 --- a/packages/blockchain/package.json +++ b/packages/blockchain/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/blockchain", - "version": "2.16.0", + "version": "2.15.0", "description": "Cere Blockchain client", "type": "module", "main": "dist/index.cjs", diff --git a/packages/changelog-preset/CHANGELOG.md b/packages/changelog-preset/CHANGELOG.md index b25216a5..c1dfc6e6 100644 --- a/packages/changelog-preset/CHANGELOG.md +++ b/packages/changelog-preset/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.15.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.14.1...v2.15.0) (2025-06-02) + +**Note:** Version bump only for package @cere-ddc-sdk/conventional-changelog-changelog-preset + ## [2.16.0](https://github.com/Cerebellum-Network/cere-ddc-sdk-js/compare/v2.15.0...v2.16.0) (2025-06-02) **Note:** Version bump only for package @cere-ddc-sdk/conventional-changelog-changelog-preset diff --git a/packages/changelog-preset/package.json b/packages/changelog-preset/package.json index e4915b78..4c4896f3 100644 --- a/packages/changelog-preset/package.json +++ b/packages/changelog-preset/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/conventional-changelog-changelog-preset", - "version": "2.16.0", + "version": "2.15.0", "private": true, "author": "Cere Network Date: Thu, 14 Aug 2025 15:11:33 +0300 Subject: [PATCH 05/13] Migrate deposits to smart contract --- packages/blockchain/src/Blockchain.ts | 18 + .../blockchain/src/CustomerDepositContract.ts | 297 ++++ .../blockchain/src/abi/customer_deposit.json | 1238 +++++++++++++++++ packages/blockchain/src/index.ts | 1 + packages/ddc-client/src/DdcClient.ts | 87 +- packages/ddc/src/presets.ts | 6 + playground/src/Playground.tsx | 26 +- tests/helpers/ddc.ts | 1 + 8 files changed, 1644 insertions(+), 30 deletions(-) create mode 100644 packages/blockchain/src/CustomerDepositContract.ts create mode 100644 packages/blockchain/src/abi/customer_deposit.json diff --git a/packages/blockchain/src/Blockchain.ts b/packages/blockchain/src/Blockchain.ts index 6079ba7f..4656bf3a 100644 --- a/packages/blockchain/src/Blockchain.ts +++ b/packages/blockchain/src/Blockchain.ts @@ -11,6 +11,7 @@ import { DDCClustersPallet } from './DDCClustersPallet'; import { DDCStakingPallet } from './DDCStakingPallet'; import { DDCCustomersPallet } from './DDCCustomersPallet'; import { DDCClustersGovPallet } from './DDCClustersGovPallet'; +import { CustomerDepositContract } from './CustomerDepositContract'; export type SendOptions = Pick, 'nonce' | 'signer'> & { account: AddressOrPair | Signer; @@ -332,6 +333,23 @@ export class Blockchain { const { number } = await this.api.rpc.chain.getHeader(); return number.toNumber(); } + + /** + * Creates an instance of CustomerDepositContract to work with the deposit smart contract. + * + * @param contractAddress - Address of the deployed smart contract customer deposit + * @returns Instance of CustomerDepositContract + * + * @example + * ```typescript + * const contractAddress = '5GBWmgdFAMqm8ZgAHGobqDqX6tjLxJhv53ygjNtaaAn3sjeZ'; + * const contract = blockchain.getCustomerDepositContract(contractAddress); + * const balance = await contract.getBalance('5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMae2Qu'); + * ``` + */ + getCustomerDepositContract(contractAddress: string): CustomerDepositContract { + return new CustomerDepositContract(this.api, contractAddress); + } } export type Sendable = SubmittableExtrinsic<'promise'>; diff --git a/packages/blockchain/src/CustomerDepositContract.ts b/packages/blockchain/src/CustomerDepositContract.ts new file mode 100644 index 00000000..e671ed53 --- /dev/null +++ b/packages/blockchain/src/CustomerDepositContract.ts @@ -0,0 +1,297 @@ +import { ApiPromise } from '@polkadot/api'; +import { ContractPromise } from '@polkadot/api-contract'; +import { WeightV2 } from '@polkadot/types/interfaces'; +import { SubmittableExtrinsic } from '@polkadot/api-base/types'; +import { AccountId } from './index'; +import customerDepositAbi from './abi/customer_deposit.json'; + +type Sendable = SubmittableExtrinsic<'promise'>; + +/** + * Ledger client balance information + */ +export interface Ledger { + /** The owner of the account whose balance is blocked for DDC */ + owner: AccountId; + /** Total balance of the owner */ + total: bigint; + /** Active owner balance amount for DDC payments */ + active: bigint; + /** Balances in the process of unlocking */ + unlocking: UnlockChunk[]; +} + +/** + * Information on unblocking funds + */ +export interface UnlockChunk { + /** Amount to unlock */ + value: bigint; + /** Block number where funds will be unlocked */ + block: number; +} /** + * Wrapper class for working with the customer deposit smart contract. + * Provides methods for managing customer deposits via the smart contract + * + * @example + * ```typescript + * const contract = new CustomerDepositContract(api, contractAddress); + * const balance = await contract.getBalance('5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMae2Qu'); + * ``` + */ +export class CustomerDepositContract { + private readonly apiPromise: ApiPromise; + private readonly contract: ContractPromise; + private readonly defaultGasLimit: WeightV2; + + constructor(apiPromise: ApiPromise, contractAddress: string) { + this.apiPromise = apiPromise; + this.contract = new ContractPromise(apiPromise, customerDepositAbi, contractAddress); + this.defaultGasLimit = apiPromise.registry.createType('WeightV2', { + refTime: 10000000000n, + proofSize: 10000000000n, + }); + } + + /** + * Gets the client's balance in the DDC cluster. + * + * @param owner - The address of the account owner + * @returns Promise that resolves to balance information or null if the balance is not found + * + * @example + * ```typescript + * const balance = await contract.getBalance('5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMae2Qu'); + * console.log(balance); + * ``` + */ + async getBalance(owner: AccountId): Promise { + try { + const { result } = await this.contract.query['ddcBalancesFetcher::getBalance']( + owner, + { gasLimit: this.defaultGasLimit }, + owner, + ); + + console.log('Smart contract query result type:', typeof result); + console.log('Smart contract query result:', result); + + if (result && (result as any).isOk) { + const rawResult = (result as any).asOk; + console.log('Raw result:', rawResult); + console.log('Raw result type:', typeof rawResult); + console.log('Raw result data:', rawResult.data); + console.log('Raw result flags:', rawResult.flags); + + try { + const rawData = rawResult.data; + if (!rawData) { + console.log('No raw data found'); + return null; + } + + console.log('Raw hex data:', rawData.toHex()); + const hexData = rawData.toHex(); + + console.log('First bytes:', hexData.slice(0, 8)); // первые 4 байта + console.log('Second byte (Option discriminant):', hexData.slice(4, 6)); // второй байт + + const optionDiscriminant = hexData.slice(4, 6); + + if (optionDiscriminant === '01') { + console.log('Option is Some - parsing ledger data...'); + + const ledgerHex = '0x' + hexData.slice(6); + console.log('Ledger hex:', ledgerHex); + + if (ledgerHex.length >= 130) { + const accountHex = ledgerHex.slice(0, 66); // 32 bytes = 64 hex chars + 0x + const totalHex = '0x' + ledgerHex.slice(66, 98); // 16 bytes = 32 hex chars + const activeHex = '0x' + ledgerHex.slice(98, 130); // 16 bytes = 32 hex chars + + console.log('Account hex:', accountHex); + console.log('Total hex:', totalHex); + console.log('Active hex:', activeHex); + + const totalBytes = totalHex.slice(2).match(/.{2}/g)?.reverse().join('') || '0'; + const activeBytes = activeHex.slice(2).match(/.{2}/g)?.reverse().join('') || '0'; + + const total = BigInt('0x' + totalBytes); + const active = BigInt('0x' + activeBytes); + + console.log('Parsed total:', total.toString()); + console.log('Parsed active:', active.toString()); + + return { + owner: owner, + total, + active, + unlocking: [], + }; + } else { + console.error('Insufficient hex data length:', ledgerHex.length); + return null; + } + } else if (optionDiscriminant === '00') { + console.log('Option is None - no balance data'); + return null; + } else { + console.error('Unknown Option discriminant:', optionDiscriminant); + return null; + } + } catch (parseError) { + console.error('Error parsing raw data:', parseError); + return null; + } + } else { + console.error('Smart contract query failed - not OK result:', result); + if (result && (result as any).isErr) { + console.error('Error details:', (result as any).asErr); + } + return null; + } + } catch (error) { + console.error('Error getting balance:', error); + } + return null; + } + + /** + * Gets client balances in a DDC cluster with pagination. + * + * @param fromIndex - Start index for pagination + * @param limit - Limit on the number of records + * @returns Promise that resolves to an array of balances + * + * @example + * ```typescript + * const balances = await contract.getBalances(0, 10); + * console.log(balances); + * ``` + */ + async getBalances(fromIndex: number, limit: number): Promise { + try { + const { result } = await this.contract.query['ddcBalancesFetcher::getBalances']( + 'anyone', // caller doesn't matter for queries + { gasLimit: this.defaultGasLimit }, + fromIndex, + limit, + ); + + if (result && (result as any).isOk) { + const balances = (result as any).asOk; + if (Array.isArray(balances)) { + return balances.map((data: any) => ({ + owner: data.owner?.toString() || '', + total: BigInt(data.total?.toString() || '0'), + active: BigInt(data.active?.toString() || '0'), + unlocking: + data.unlocking?.map((chunk: any) => ({ + value: BigInt(chunk.value?.toString() || '0'), + block: Number(chunk.block) || 0, + })) || [], + })); + } + } + } catch (error) { + console.error('Error getting balances:', error); + } + return []; + } + + /** + * Tops up balance the deposit balance on behalf of the owner. + * + * @param value - Amount to deposit + * @returns Transaction to execute + * + * @example + * ```typescript + * const tx = contract.deposit(100n); + * const result = await blockchain.send(tx, { account: signer }); + * ``` + */ + deposit(value: bigint): Sendable { + const tx = this.contract.tx['ddcBalancesDepositor::deposit']({ + gasLimit: this.defaultGasLimit, + storageDepositLimit: null, + value, + }); + return tx as unknown as Sendable; + } + + /** + * Tops up the deposit balance for a specific owner on behalf of the faucet. + * + * @param clusterId - Cluster ID for the deposit + * @param owner - Account owner address to top up + * @param value - Amount to deposit + * @returns Transaction to execute + * + * @example + * ```typescript + * const tx = contract.depositFor('0x...', '5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMae2Qu', 100n); + * const result = await blockchain.send(tx, { account: signer }); + * ``` + */ + depositFor(clusterId: string, owner: AccountId, value: bigint): Sendable { + const tx = this.contract.tx['ddcBalancesDepositor::depositFor']( + { + gasLimit: this.defaultGasLimit, + storageDepositLimit: null, + }, + clusterId, + value, + owner, + ); + return tx as unknown as Sendable; + } + + /** + * Initiates unlocking of the deposit balance on behalf of the owner. + * + * @param clusterId - Cluster ID to unlock the deposit + * @param value - Amount to unlock + * @returns Transaction to execute + * + * @example + * ```typescript + * const tx = contract.unlockDeposit('0x...', 50n); + * const result = await blockchain.send(tx, { account: signer }); + * ``` + */ + unlockDeposit(clusterId: string, value: bigint): Sendable { + const tx = this.contract.tx['ddcBalancesDepositor::unlockDeposit']( + { + gasLimit: this.defaultGasLimit, + storageDepositLimit: null, + }, + clusterId, + value, + ); + return tx as unknown as Sendable; + } + + /** + * Outputs the unlocked deposit balance on behalf of the owner. + * + * @returns The transaction to execute + * + * @example + * ```typescript + * const tx = contract.withdrawUnlocked('0x...'); + * const result = await blockchain.send(tx, { account: signer }); + * ``` + */ + withdrawUnlocked(clusterId: string): Sendable { + const tx = this.contract.tx['ddcBalancesDepositor::withdrawUnlocked']( + { + gasLimit: this.defaultGasLimit, + storageDepositLimit: null, + }, + clusterId, + ); + return tx as unknown as Sendable; + } + +} diff --git a/packages/blockchain/src/abi/customer_deposit.json b/packages/blockchain/src/abi/customer_deposit.json new file mode 100644 index 00000000..318e5496 --- /dev/null +++ b/packages/blockchain/src/abi/customer_deposit.json @@ -0,0 +1,1238 @@ +{ + "source": { + "hash": "0xbbbf3041f70477a87350a2ffedb2bb9c065d10b11c5e9348816e8bc039e1ed6c", + "language": "ink! 5.1.1", + "compiler": "rustc 1.82.0", + "build_info": { + "build_mode": "Release", + "cargo_contract_version": "4.1.3", + "rust_toolchain": "stable-aarch64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": false, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "customer-deposit", + "version": "5.1.0", + "authors": ["Use Ink "] + }, + "image": null, + "spec": { + "constructors": [ + { + "args": [ + { + "label": "cluster_id", + "type": { + "displayName": ["ClusterId20"], + "type": 18 + } + }, + { + "label": "unlock_delay_blocks", + "type": { + "displayName": ["u32"], + "type": 1 + } + } + ], + "default": false, + "docs": [], + "label": "new", + "payable": false, + "returnType": { + "displayName": ["ink_primitives", "ConstructorResult"], + "type": 19 + }, + "selector": "0x9bae9d5e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": ["AccountId"], + "type": 6 + }, + "balance": { + "displayName": ["Balance"], + "type": 2 + }, + "blockNumber": { + "displayName": ["BlockNumber"], + "type": 1 + }, + "chainExtension": { + "displayName": ["ChainExtension"], + "type": 37 + }, + "hash": { + "displayName": ["Hash"], + "type": 36 + }, + "maxEventTopics": 4, + "staticBufferSize": 16384, + "timestamp": { + "displayName": ["Timestamp"], + "type": 14 + } + }, + "events": [ + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "cluster_id", + "type": { + "displayName": ["ClusterId"], + "type": 18 + } + }, + { + "docs": [], + "indexed": true, + "label": "owner_id", + "type": { + "displayName": ["AccountId"], + "type": 21 + } + }, + { + "docs": [], + "indexed": false, + "label": "amount", + "type": { + "displayName": ["Balance"], + "type": 2 + } + } + ], + "docs": ["This event should be emitted for any customer who deposited funds."], + "label": "DdcBalanceDeposited", + "module_path": "ddc_primitives::contracts::customer_deposit::events", + "signature_topic": "0x5b6d40e103624b4c551be042e050915209a5ab49a928c3b181a06a3a1885e6f0" + }, + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "cluster_id", + "type": { + "displayName": ["ClusterId"], + "type": 18 + } + }, + { + "docs": [], + "indexed": true, + "label": "owner_id", + "type": { + "displayName": ["AccountId"], + "type": 21 + } + }, + { + "docs": [], + "indexed": false, + "label": "amount", + "type": { + "displayName": ["Balance"], + "type": 2 + } + } + ], + "docs": ["This event should be emitted for any customer who initiated unlocking of deposit."], + "label": "DdcBalanceUnlocked", + "module_path": "ddc_primitives::contracts::customer_deposit::events", + "signature_topic": "0x23675c3332cb2187e6029af300d9b5e14814a1212cfaec983f962988aa488653" + }, + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "cluster_id", + "type": { + "displayName": ["ClusterId"], + "type": 18 + } + }, + { + "docs": [], + "indexed": true, + "label": "owner_id", + "type": { + "displayName": ["AccountId"], + "type": 21 + } + }, + { + "docs": [], + "indexed": false, + "label": "amount", + "type": { + "displayName": ["Balance"], + "type": 2 + } + } + ], + "docs": ["This event should be emitted for any customer who did withdrawal of unlocked funds."], + "label": "DdcBalanceWithdrawn", + "module_path": "ddc_primitives::contracts::customer_deposit::events", + "signature_topic": "0x55b26822df868a289423cd7b3a691f8789e9bcb61d3e4cb994e6e8b593046dbd" + }, + { + "args": [ + { + "docs": [], + "indexed": true, + "label": "cluster_id", + "type": { + "displayName": ["ClusterId"], + "type": 18 + } + }, + { + "docs": [], + "indexed": true, + "label": "owner_id", + "type": { + "displayName": ["AccountId"], + "type": 21 + } + }, + { + "docs": [], + "indexed": false, + "label": "charged", + "type": { + "displayName": ["Balance"], + "type": 2 + } + }, + { + "docs": [], + "indexed": false, + "label": "expected", + "type": { + "displayName": ["Balance"], + "type": 2 + } + } + ], + "docs": ["This event should be emitted for any customer who has been charged during payouts."], + "label": "DdcBalanceCharged", + "module_path": "ddc_primitives::contracts::customer_deposit::events", + "signature_topic": "0x9db6acf54011fb413d2878834705faf7952aa27a12db083b35fca6c64ca2b2d0" + } + ], + "lang_error": { + "displayName": ["ink", "LangError"], + "type": 20 + }, + "messages": [ + { + "args": [ + { + "label": "owner", + "type": { + "displayName": ["AccountId32"], + "type": 21 + } + } + ], + "default": false, + "docs": [" Fetches customer balance in DDC cluster."], + "label": "DdcBalancesFetcher::get_balance", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["ink", "MessageResult"], + "type": 22 + }, + "selector": "0xa40735c6" + }, + { + "args": [ + { + "label": "from_index", + "type": { + "displayName": ["u64"], + "type": 14 + } + }, + { + "label": "limit", + "type": { + "displayName": ["u64"], + "type": 14 + } + } + ], + "default": false, + "docs": [" Fetches customers balances in DDC cluster in a paginated manner."], + "label": "DdcBalancesFetcher::get_balances", + "mutates": false, + "payable": false, + "returnType": { + "displayName": ["ink", "MessageResult"], + "type": 27 + }, + "selector": "0xbc7c9644" + }, + { + "args": [], + "default": false, + "docs": [" Top up deposit balance on behalf its owner."], + "label": "DdcBalancesDepositor::deposit", + "mutates": true, + "payable": true, + "returnType": { + "displayName": ["ink", "MessageResult"], + "type": 29 + }, + "selector": "0x2d1d8745" + }, + { + "args": [ + { + "label": "owner", + "type": { + "displayName": ["AccountId32"], + "type": 21 + } + } + ], + "default": false, + "docs": [" Top up deposit balance for specific owner on behalf faucet."], + "label": "DdcBalancesDepositor::deposit_for", + "mutates": true, + "payable": true, + "returnType": { + "displayName": ["ink", "MessageResult"], + "type": 29 + }, + "selector": "0xd8c1df42" + }, + { + "args": [ + { + "label": "value", + "type": { + "displayName": ["BalanceU128"], + "type": 2 + } + } + ], + "default": false, + "docs": [" Initiate unlocking of deposit balance on behalf its owner."], + "label": "DdcBalancesDepositor::unlock_deposit", + "mutates": true, + "payable": false, + "returnType": { + "displayName": ["ink", "MessageResult"], + "type": 29 + }, + "selector": "0x91be5b57" + }, + { + "args": [], + "default": false, + "docs": [" Withdraw unlocked deposit balance on behalf its owner."], + "label": "DdcBalancesDepositor::withdraw_unlocked", + "mutates": true, + "payable": false, + "returnType": { + "displayName": ["ink", "MessageResult"], + "type": 29 + }, + "selector": "0x52402e18" + }, + { + "args": [ + { + "label": "payout_vault", + "type": { + "displayName": ["AccountId32"], + "type": 21 + } + }, + { + "label": "batch", + "type": { + "displayName": ["Vec"], + "type": 33 + } + } + ], + "default": false, + "docs": [" Charges customers for DDC service usage while DAC-based payouts are in progress."], + "label": "DdcPayoutsPayer::charge", + "mutates": true, + "payable": false, + "returnType": { + "displayName": ["ink", "MessageResult"], + "type": 35 + }, + "selector": "0x18c2a328" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "array": { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 0 + } + }, + "len": 20, + "offset": "0x00000000" + } + }, + "name": "cluster_id" + }, + { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 1 + } + }, + "name": "unlock_delay_blocks" + }, + { + "layout": { + "root": { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "leaf": { + "key": "0x02c047f0", + "ty": 2 + } + }, + "name": "total" + }, + { + "layout": { + "leaf": { + "key": "0x02c047f0", + "ty": 2 + } + }, + "name": "active" + }, + { + "layout": { + "leaf": { + "key": "0x02c047f0", + "ty": 3 + } + }, + "name": "unlocking" + } + ], + "name": "CustomerLedger" + } + }, + "root_key": "0x02c047f0", + "ty": 5 + } + }, + "name": "balances" + }, + { + "layout": { + "root": { + "layout": { + "leaf": { + "key": "0x421d3cb3", + "ty": 6 + } + }, + "root_key": "0x421d3cb3", + "ty": 13 + } + }, + "name": "accounts" + }, + { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 14 + } + }, + "name": "count" + } + ], + "name": "CustomerDepositContract" + } + }, + "root_key": "0x00000000", + "ty": 17 + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 1, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 2, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 3, + "type": { + "def": { + "sequence": { + "type": 4 + } + } + } + }, + { + "id": 4, + "type": { + "def": { + "composite": { + "fields": [ + { + "name": "value", + "type": 2, + "typeName": "Balance" + }, + { + "name": "block", + "type": 1, + "typeName": "BlockNumber" + } + ] + } + }, + "path": ["customer_deposit", "customer_deposit", "LinearUnlockChunk"] + } + }, + { + "id": 5, + "type": { + "def": { + "composite": {} + }, + "params": [ + { + "name": "K", + "type": 6 + }, + { + "name": "V", + "type": 8 + }, + { + "name": "KeyType", + "type": 9 + } + ], + "path": ["ink_storage", "lazy", "mapping", "Mapping"] + } + }, + { + "id": 6, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 7, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": ["ink_primitives", "types", "AccountId"] + } + }, + { + "id": 7, + "type": { + "def": { + "array": { + "len": 32, + "type": 0 + } + } + } + }, + { + "id": 8, + "type": { + "def": { + "composite": { + "fields": [ + { + "name": "total", + "type": 2, + "typeName": "Balance" + }, + { + "name": "active", + "type": 2, + "typeName": "Balance" + }, + { + "name": "unlocking", + "type": 3, + "typeName": "Vec" + } + ] + } + }, + "path": ["customer_deposit", "customer_deposit", "CustomerLedger"] + } + }, + { + "id": 9, + "type": { + "def": { + "composite": {} + }, + "params": [ + { + "name": "L", + "type": 10 + }, + { + "name": "R", + "type": 11 + } + ], + "path": ["ink_storage_traits", "impls", "ResolverKey"] + } + }, + { + "id": 10, + "type": { + "def": { + "composite": {} + }, + "path": ["ink_storage_traits", "impls", "AutoKey"] + } + }, + { + "id": 11, + "type": { + "def": { + "composite": {} + }, + "params": [ + { + "name": "ParentKey", + "type": 12 + } + ], + "path": ["ink_storage_traits", "impls", "ManualKey"] + } + }, + { + "id": 12, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 13, + "type": { + "def": { + "composite": {} + }, + "params": [ + { + "name": "K", + "type": 14 + }, + { + "name": "V", + "type": 6 + }, + { + "name": "KeyType", + "type": 15 + } + ], + "path": ["ink_storage", "lazy", "mapping", "Mapping"] + } + }, + { + "id": 14, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 15, + "type": { + "def": { + "composite": {} + }, + "params": [ + { + "name": "L", + "type": 10 + }, + { + "name": "R", + "type": 16 + } + ], + "path": ["ink_storage_traits", "impls", "ResolverKey"] + } + }, + { + "id": 16, + "type": { + "def": { + "composite": {} + }, + "params": [ + { + "name": "ParentKey", + "type": 12 + } + ], + "path": ["ink_storage_traits", "impls", "ManualKey"] + } + }, + { + "id": 17, + "type": { + "def": { + "composite": { + "fields": [ + { + "name": "cluster_id", + "type": 18, + "typeName": ",>>::Type" + }, + { + "name": "unlock_delay_blocks", + "type": 1, + "typeName": ",>>::Type" + }, + { + "name": "balances", + "type": 5, + "typeName": " as::ink::storage::traits::\nAutoStorableHint<::ink::storage::traits::ManualKey<4031234050u32,\n()>,>>::Type" + }, + { + "name": "accounts", + "type": 13, + "typeName": " as::ink::storage::traits::\nAutoStorableHint<::ink::storage::traits::ManualKey<3007061314u32,\n()>,>>::Type" + }, + { + "name": "count", + "type": 14, + "typeName": ",>>::Type" + } + ] + } + }, + "path": ["customer_deposit", "customer_deposit", "CustomerDepositContract"] + } + }, + { + "id": 18, + "type": { + "def": { + "array": { + "len": 20, + "type": 0 + } + } + } + }, + { + "id": 19, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 12 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 20 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 12 + }, + { + "name": "E", + "type": 20 + } + ], + "path": ["Result"] + } + }, + { + "id": 20, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": ["ink_primitives", "LangError"] + } + }, + { + "id": 21, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 7, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": ["sp_core", "crypto", "AccountId32"] + } + }, + { + "id": 22, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 23 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 20 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 23 + }, + { + "name": "E", + "type": 20 + } + ], + "path": ["Result"] + } + }, + { + "id": 23, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "None" + }, + { + "fields": [ + { + "type": 24 + } + ], + "index": 1, + "name": "Some" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 24 + } + ], + "path": ["Option"] + } + }, + { + "id": 24, + "type": { + "def": { + "composite": { + "fields": [ + { + "name": "owner", + "type": 21, + "typeName": "AccountId" + }, + { + "name": "total", + "type": 2, + "typeName": "Balance" + }, + { + "name": "active", + "type": 2, + "typeName": "Balance" + }, + { + "name": "unlocking", + "type": 25, + "typeName": "Vec" + } + ] + } + }, + "path": ["ddc_primitives", "contracts", "customer_deposit", "types", "Ledger"] + } + }, + { + "id": 25, + "type": { + "def": { + "sequence": { + "type": 26 + } + } + } + }, + { + "id": 26, + "type": { + "def": { + "composite": { + "fields": [ + { + "name": "value", + "type": 2, + "typeName": "Balance" + }, + { + "name": "block", + "type": 1, + "typeName": "BlockNumber" + } + ] + } + }, + "path": ["ddc_primitives", "contracts", "customer_deposit", "types", "UnlockChunk"] + } + }, + { + "id": 27, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 28 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 20 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 28 + }, + { + "name": "E", + "type": 20 + } + ], + "path": ["Result"] + } + }, + { + "id": 28, + "type": { + "def": { + "sequence": { + "type": 24 + } + } + } + }, + { + "id": 29, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 30 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 20 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 30 + }, + { + "name": "E", + "type": 20 + } + ], + "path": ["Result"] + } + }, + { + "id": 30, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 12 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 31 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 12 + }, + { + "name": "E", + "type": 31 + } + ], + "path": ["Result"] + } + }, + { + "id": 31, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 32, + "typeName": "u16" + } + ], + "index": 0, + "name": "Code" + } + ] + } + }, + "path": ["ddc_primitives", "contracts", "customer_deposit", "errors", "Error"] + } + }, + { + "id": 32, + "type": { + "def": { + "primitive": "u16" + } + } + }, + { + "id": 33, + "type": { + "def": { + "sequence": { + "type": 34 + } + } + } + }, + { + "id": 34, + "type": { + "def": { + "tuple": [21, 2] + } + } + }, + { + "id": 35, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 33 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 20 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 33 + }, + { + "name": "E", + "type": 20 + } + ], + "path": ["Result"] + } + }, + { + "id": 36, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 7, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": ["ink_primitives", "types", "Hash"] + } + }, + { + "id": 37, + "type": { + "def": { + "variant": {} + }, + "path": ["customer_deposit", "DdcPayoutsExtension"] + } + } + ], + "version": 5 +} diff --git a/packages/blockchain/src/index.ts b/packages/blockchain/src/index.ts index 4ca74e88..ce5a48cd 100644 --- a/packages/blockchain/src/index.ts +++ b/packages/blockchain/src/index.ts @@ -21,6 +21,7 @@ export * from './Signer'; * Pallets */ export * from './DDCCustomersPallet'; +export * from './CustomerDepositContract'; export * from './DDCStakingPallet'; export * from './DDCClustersPallet'; export * from './DDCNodesPallet'; diff --git a/packages/ddc-client/src/DdcClient.ts b/packages/ddc-client/src/DdcClient.ts index e7e093db..21c28bef 100644 --- a/packages/ddc-client/src/DdcClient.ts +++ b/packages/ddc-client/src/DdcClient.ts @@ -19,13 +19,22 @@ import { CnsRecordGetOptions, } from '@cere-ddc-sdk/ddc'; import { FileStorage, File, FileStoreOptions, FileResponse, FileReadOptions } from '@cere-ddc-sdk/file-storage'; -import { AccountId, Blockchain, BucketId, BucketParams, ClusterId, Sendable } from '@cere-ddc-sdk/blockchain'; +import { + AccountId, + Blockchain, + BucketId, + BucketParams, + ClusterId, + CustomerDepositContract, + Ledger, +} from '@cere-ddc-sdk/blockchain'; import { DagNodeUri, DdcUri, FileUri } from './DdcUri'; export type DdcClientConfig = Omit & Omit & { blockchain: Blockchain | ConfigPreset['blockchain']; + customerDepositContractAddress: string; }; type DepositBalanceOptions = { @@ -43,8 +52,9 @@ export class DdcClient { private readonly fileStorage: FileStorage; private readonly signer: Signer; private readonly logger: Logger; + private readonly customerDepositContract: CustomerDepositContract; - constructor(uriOrSigner: Signer | string, config: DdcClientConfig = DEFAULT_PRESET) { + constructor(uriOrSigner: Signer | string, config: DdcClientConfig) { const logger = createLogger('DdcClient', config); const blockchain = typeof config.blockchain === 'string' ? new Blockchain({ wsEndpoint: config.blockchain }) : config.blockchain; @@ -60,6 +70,8 @@ export class DdcClient { this.ddcNode = new BalancedNode({ ...config, router, logger }); this.fileStorage = new FileStorage(router, { ...config, logger }); + this.customerDepositContract = blockchain.getCustomerDepositContract(config.customerDepositContractAddress); + logger.debug(config, 'DdcClient created'); if (config.logErrors !== false) { @@ -67,6 +79,7 @@ export class DdcClient { 'getBalance', 'depositBalance', 'getDeposit', + 'getLedger', 'createBucket', 'getBucket', 'getBucketList', @@ -156,21 +169,17 @@ export class DdcClient { * ``` * */ async depositBalance(clusterId: ClusterId, amount: bigint, options: DepositBalanceOptions = {}) { - let tx: Sendable; - const currentDeposit = - options.allowExtra === false - ? null - : await this.blockchain.ddcCustomers.getStackingInfo(clusterId, this.signer.address); - - if (currentDeposit === null) { - this.logger.info('Depositing balance %s to %s for cluster %s', amount, this.signer.address, clusterId); - tx = this.blockchain.ddcCustomers.deposit(clusterId, amount); - } else { - this.logger.info('Depositing extra balance %s to %s for cluster %s', amount, this.signer.address, clusterId); - tx = this.blockchain.ddcCustomers.depositExtra(clusterId, amount); - } + this.logger.info('Depositing balance %s to %s using smart contract', amount, this.signer.address); + const tx = this.customerDepositContract.deposit(amount); + const result = await this.blockchain.send(tx, { account: this.signer }); + + this.logger.info('Deposit transaction result:', result); + this.logger.info( + 'Deposit transaction events:', + result.events.map((e) => `${e.section}.${e.method}: ${JSON.stringify(e.data)}`), + ); - return this.blockchain.send(tx, { account: this.signer }); + return result; } /** @@ -195,8 +204,8 @@ export class DdcClient { * ``` * */ async depositBalanceFor(targetAddress: AccountId, clusterId: ClusterId, amount: bigint) { - this.logger.info('Depositing balance %s for %s in cluster %s', amount, targetAddress, clusterId); - const tx = this.blockchain.ddcCustomers.depositFor(targetAddress, clusterId, amount); + this.logger.info('Depositing balance %s for %s using smart contract', amount, targetAddress); + const tx = this.customerDepositContract.depositFor(clusterId, targetAddress, amount); return this.blockchain.send(tx, { account: this.signer }); } @@ -219,11 +228,12 @@ export class DdcClient { * */ async getDeposit(clusterId: ClusterId, accountId?: AccountId) { const targetAccountId = accountId || this.signer.address; - this.logger.info('Getting the account deposit %s for cluster %s', targetAccountId, clusterId); - const info = await this.blockchain.ddcCustomers.getStackingInfo(clusterId, targetAccountId); - const deposit = BigInt(info?.active || 0n); - this.logger.info('The account (%s) deposit for cluster %s is %s', targetAccountId, clusterId, deposit); + this.logger.info('Getting the account deposit %s using smart contract', targetAccountId); + const ledger = await this.customerDepositContract.getBalance(targetAccountId); + const deposit = ledger?.active || 0n; + + this.logger.info('The account (%s) deposit is %s', targetAccountId, deposit); return deposit; } @@ -246,8 +256,8 @@ export class DdcClient { * ``` * */ async unlockDeposit(clusterId: ClusterId, amount: bigint) { - this.logger.info('Unlocking deposit %s for cluster %s', amount, clusterId); - const tx = this.blockchain.ddcCustomers.unlockDeposit(clusterId, amount); + this.logger.info('Unlocking deposit %s using smart contract', amount); + const tx = this.customerDepositContract.unlockDeposit(clusterId, amount); return this.blockchain.send(tx, { account: this.signer }); } @@ -268,11 +278,36 @@ export class DdcClient { * ``` * */ async withdrawUnlockedDeposit(clusterId: ClusterId) { - this.logger.info('Withdrawing unlocked deposit for cluster %s', clusterId); - const tx = this.blockchain.ddcCustomers.withdrawUnlockedDeposit(clusterId); + this.logger.info('Withdrawing unlocked deposit using smart contract'); + const tx = this.customerDepositContract.withdrawUnlocked(clusterId); return this.blockchain.send(tx, { account: this.signer }); } + /** + * Gets full client (ledger) balance information from the smart contract. + * Includes active funds, total amount, and unlock information. + * + * @param accountId - Optional account ID. If not specified, the signer's address is used. + * @returns Promise that resolves to balance information, or null if not found + * + * @example + * ```typescript + * const ledger = await ddcClient.getLedger(); + * console.log('Active balance:', ledger?.active); + * console.log('Total balance:', ledger?.total); + * console.log('Unlocking chunks:', ledger?.unlocking); + * ``` + */ + async getLedger(clusterId?: ClusterId, accountId?: AccountId): Promise { + const targetAccountId = accountId || this.signer.address; + + this.logger.info('Getting ledger information for account %s', targetAccountId); + const ledger = await this.customerDepositContract.getBalance(targetAccountId); + this.logger.info('Got ledger: %o', ledger); + + return ledger; + } + /** * Creates a new bucket on a specified cluster. * diff --git a/packages/ddc/src/presets.ts b/packages/ddc/src/presets.ts index 59905d1f..39d3ec82 100644 --- a/packages/ddc/src/presets.ts +++ b/packages/ddc/src/presets.ts @@ -4,6 +4,7 @@ import { RouterNode } from './routing'; export type ConfigPreset = { blockchain: string; nodes?: RouterNode[]; + customerDepositContractAddress: string; }; /** @@ -13,6 +14,7 @@ export type ConfigPreset = { */ export const MAINNET: ConfigPreset = { blockchain: 'wss://rpc.mainnet.cere.network/ws', + customerDepositContractAddress: '', // @TODO }; /** @@ -22,6 +24,7 @@ export const MAINNET: ConfigPreset = { */ export const TESTNET: ConfigPreset = { blockchain: 'wss://rpc.testnet.cere.network/ws', + customerDepositContractAddress: '', // @TODO }; /** @@ -31,6 +34,7 @@ export const TESTNET: ConfigPreset = { */ export const DEVNET: ConfigPreset = { blockchain: 'wss://archive.devnet.cere.network/ws', + customerDepositContractAddress: '6TZJb1s7PMa9UcHnjickVtiNG2JjYN6wNYU3CTMvji1VxTMY', }; export const DEFAULT_PRESET = TESTNET; @@ -45,6 +49,7 @@ export const DEFAULT_PRESET = TESTNET; */ export const DEVNET_STATIC: ConfigPreset = { blockchain: 'wss://archive.devnet.cere.network/ws', + customerDepositContractAddress: '6TZJb1s7PMa9UcHnjickVtiNG2JjYN6wNYU3CTMvji1VxTMY', nodes: [ { mode: StorageNodeMode.Full, @@ -110,6 +115,7 @@ export const DEVNET_STATIC: ConfigPreset = { */ export const TESTNET_STATIC: ConfigPreset = { blockchain: 'wss://rpc.testnet.cere.network/ws', + customerDepositContractAddress: '', // @TODO nodes: [ { mode: StorageNodeMode.Full, diff --git a/playground/src/Playground.tsx b/playground/src/Playground.tsx index 74506403..ff2d22f5 100644 --- a/playground/src/Playground.tsx +++ b/playground/src/Playground.tsx @@ -63,12 +63,25 @@ const Dropzone = styled(Box)(({ theme }) => ({ })); const bcPresets = { - devnet: { ...DEVNET, baseUrl: 'https://storage.devnet.cere.network' }, - testnet: { ...TESTNET, baseUrl: 'https://storage.testnet.cere.network' }, - mainnet: { ...MAINNET, baseUrl: 'https://storage.dragon.cere.network' }, + devnet: { + ...DEVNET, + baseUrl: 'https://storage.devnet.cere.network', + customerDepositContractAddress: DEVNET.customerDepositContractAddress, + }, + testnet: { + ...TESTNET, + baseUrl: 'https://storage.testnet.cere.network', + customerDepositContractAddress: TESTNET.customerDepositContractAddress, + }, + mainnet: { + ...MAINNET, + baseUrl: 'https://storage.dragon.cere.network', + customerDepositContractAddress: MAINNET.customerDepositContractAddress, + }, custom: { blockchain: __BC_ENDPOINT__ || '', baseUrl: 'http://localhost:8091', + customerDepositContractAddress: DEVNET.customerDepositContractAddress, }, }; @@ -245,7 +258,12 @@ export const Playground = () => { try { setInProgress(true); const blockchain = await Blockchain.connect({ wsEndpoint: preset.blockchain }); - const client = await DdcClient.create(signer!, { ...preset, blockchain, logLevel: 'debug' }); + const client = await DdcClient.create(signer!, { + ...preset, + blockchain, + logLevel: 'debug', + customerDepositContractAddress: bcPresets[selectedBc]?.customerDepositContractAddress ?? '', + }); const [clusters, balance] = await Promise.all([blockchain.ddcClusters.listClusters(), client.getBalance()]); setBlockchain(blockchain); diff --git a/tests/helpers/ddc.ts b/tests/helpers/ddc.ts index 319adfa7..4d829530 100644 --- a/tests/helpers/ddc.ts +++ b/tests/helpers/ddc.ts @@ -53,5 +53,6 @@ type ClientOptions = Pick; export const getClientConfig = (options: ClientOptions = {}): DdcClientConfig => ({ blockchain: BLOCKCHAIN_RPC_URL, logLevel: options.logLevel || 'silent', + customerDepositContractAddress: '6TZJb1s7PMa9UcHnjickVtiNG2JjYN6wNYU3CTMvji1VxTMY', ...options, }); From cb4904d41c4a88834b32822d30d765b153a4a804 Mon Sep 17 00:00:00 2001 From: antonmazhuto Date: Thu, 14 Aug 2025 16:54:31 +0300 Subject: [PATCH 06/13] Improved the way of getting balance data --- .../blockchain/src/CustomerDepositContract.ts | 179 ++++-------------- packages/ddc-client/src/DdcClient.ts | 14 +- 2 files changed, 36 insertions(+), 157 deletions(-) diff --git a/packages/blockchain/src/CustomerDepositContract.ts b/packages/blockchain/src/CustomerDepositContract.ts index e671ed53..c34d4b18 100644 --- a/packages/blockchain/src/CustomerDepositContract.ts +++ b/packages/blockchain/src/CustomerDepositContract.ts @@ -7,38 +7,18 @@ import customerDepositAbi from './abi/customer_deposit.json'; type Sendable = SubmittableExtrinsic<'promise'>; -/** - * Ledger client balance information - */ export interface Ledger { - /** The owner of the account whose balance is blocked for DDC */ owner: AccountId; - /** Total balance of the owner */ total: bigint; - /** Active owner balance amount for DDC payments */ active: bigint; - /** Balances in the process of unlocking */ unlocking: UnlockChunk[]; } -/** - * Information on unblocking funds - */ export interface UnlockChunk { - /** Amount to unlock */ value: bigint; - /** Block number where funds will be unlocked */ block: number; -} /** - * Wrapper class for working with the customer deposit smart contract. - * Provides methods for managing customer deposits via the smart contract - * - * @example - * ```typescript - * const contract = new CustomerDepositContract(api, contractAddress); - * const balance = await contract.getBalance('5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMae2Qu'); - * ``` - */ +} + export class CustomerDepositContract { private readonly apiPromise: ApiPromise; private readonly contract: ContractPromise; @@ -53,150 +33,58 @@ export class CustomerDepositContract { }); } + private toBigIntSafe(value: string | number | bigint): bigint { + if (typeof value === 'string') { + value = value.replace(/[^\d-]/g, ''); + } + return BigInt(value); + } + /** * Gets the client's balance in the DDC cluster. * * @param owner - The address of the account owner * @returns Promise that resolves to balance information or null if the balance is not found - * - * @example - * ```typescript - * const balance = await contract.getBalance('5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMae2Qu'); - * console.log(balance); - * ``` */ async getBalance(owner: AccountId): Promise { try { - const { result } = await this.contract.query['ddcBalancesFetcher::getBalance']( + const { result, output } = await this.contract.query['ddcBalancesFetcher::getBalance']( owner, { gasLimit: this.defaultGasLimit }, owner, ); - console.log('Smart contract query result type:', typeof result); - console.log('Smart contract query result:', result); - - if (result && (result as any).isOk) { - const rawResult = (result as any).asOk; - console.log('Raw result:', rawResult); - console.log('Raw result type:', typeof rawResult); - console.log('Raw result data:', rawResult.data); - console.log('Raw result flags:', rawResult.flags); - - try { - const rawData = rawResult.data; - if (!rawData) { - console.log('No raw data found'); - return null; - } - - console.log('Raw hex data:', rawData.toHex()); - const hexData = rawData.toHex(); - - console.log('First bytes:', hexData.slice(0, 8)); // первые 4 байта - console.log('Second byte (Option discriminant):', hexData.slice(4, 6)); // второй байт - - const optionDiscriminant = hexData.slice(4, 6); - - if (optionDiscriminant === '01') { - console.log('Option is Some - parsing ledger data...'); - - const ledgerHex = '0x' + hexData.slice(6); - console.log('Ledger hex:', ledgerHex); - - if (ledgerHex.length >= 130) { - const accountHex = ledgerHex.slice(0, 66); // 32 bytes = 64 hex chars + 0x - const totalHex = '0x' + ledgerHex.slice(66, 98); // 16 bytes = 32 hex chars - const activeHex = '0x' + ledgerHex.slice(98, 130); // 16 bytes = 32 hex chars - - console.log('Account hex:', accountHex); - console.log('Total hex:', totalHex); - console.log('Active hex:', activeHex); - - const totalBytes = totalHex.slice(2).match(/.{2}/g)?.reverse().join('') || '0'; - const activeBytes = activeHex.slice(2).match(/.{2}/g)?.reverse().join('') || '0'; - - const total = BigInt('0x' + totalBytes); - const active = BigInt('0x' + activeBytes); + if (!result.isOk || !output) { + return null; + } - console.log('Parsed total:', total.toString()); - console.log('Parsed active:', active.toString()); + const humanOutput = (output as any).toHuman(); - return { - owner: owner, - total, - active, - unlocking: [], - }; - } else { - console.error('Insufficient hex data length:', ledgerHex.length); - return null; - } - } else if (optionDiscriminant === '00') { - console.log('Option is None - no balance data'); - return null; - } else { - console.error('Unknown Option discriminant:', optionDiscriminant); - return null; - } - } catch (parseError) { - console.error('Error parsing raw data:', parseError); - return null; - } - } else { - console.error('Smart contract query failed - not OK result:', result); - if (result && (result as any).isErr) { - console.error('Error details:', (result as any).asErr); - } + if (humanOutput.Err || !humanOutput.Ok) { return null; } - } catch (error) { - console.error('Error getting balance:', error); - } - return null; - } - - /** - * Gets client balances in a DDC cluster with pagination. - * - * @param fromIndex - Start index for pagination - * @param limit - Limit on the number of records - * @returns Promise that resolves to an array of balances - * - * @example - * ```typescript - * const balances = await contract.getBalances(0, 10); - * console.log(balances); - * ``` - */ - async getBalances(fromIndex: number, limit: number): Promise { - try { - const { result } = await this.contract.query['ddcBalancesFetcher::getBalances']( - 'anyone', // caller doesn't matter for queries - { gasLimit: this.defaultGasLimit }, - fromIndex, - limit, - ); - if (result && (result as any).isOk) { - const balances = (result as any).asOk; - if (Array.isArray(balances)) { - return balances.map((data: any) => ({ - owner: data.owner?.toString() || '', - total: BigInt(data.total?.toString() || '0'), - active: BigInt(data.active?.toString() || '0'), - unlocking: - data.unlocking?.map((chunk: any) => ({ - value: BigInt(chunk.value?.toString() || '0'), - block: Number(chunk.block) || 0, - })) || [], - })); - } + const optionLedger = humanOutput.Ok; + if (!optionLedger) { + console.log('No ledger data found (Option::None)'); + return null; } + + const ledgerData = optionLedger; + + return { + owner: ledgerData.owner || owner, + total: this.toBigIntSafe(ledgerData.total), + active: this.toBigIntSafe(ledgerData.active), + unlocking: (ledgerData.unlocking || []).map((chunk: any) => ({ + value: this.toBigIntSafe(chunk.value), + block: Number(chunk.block) || 0, + })), + }; } catch (error) { - console.error('Error getting balances:', error); + console.error('Error getting balance:', error); + return null; } - return []; } /** @@ -293,5 +181,4 @@ export class CustomerDepositContract { ); return tx as unknown as Sendable; } - } diff --git a/packages/ddc-client/src/DdcClient.ts b/packages/ddc-client/src/DdcClient.ts index 21c28bef..ded5cb2f 100644 --- a/packages/ddc-client/src/DdcClient.ts +++ b/packages/ddc-client/src/DdcClient.ts @@ -37,10 +37,6 @@ export type DdcClientConfig = Omit & customerDepositContractAddress: string; }; -type DepositBalanceOptions = { - allowExtra?: boolean; -}; - /** * `DdcClient` is a class that provides methods to interact with the DDC. * @@ -152,9 +148,7 @@ export class DdcClient { /** * Deposits a specified amount of tokens to the account for a specific cluster. The account must have enough tokens to cover the deposit. * - * @param clusterId - The ID of the cluster to deposit tokens for. * @param amount - The amount of tokens to deposit. - * @param options - Additional options for the deposit. * * @returns A promise that resolves to the transaction hash of the deposit. * @@ -168,7 +162,7 @@ export class DdcClient { * console.log(txHash); * ``` * */ - async depositBalance(clusterId: ClusterId, amount: bigint, options: DepositBalanceOptions = {}) { + async depositBalance(amount: bigint) { this.logger.info('Depositing balance %s to %s using smart contract', amount, this.signer.address); const tx = this.customerDepositContract.deposit(amount); const result = await this.blockchain.send(tx, { account: this.signer }); @@ -212,7 +206,6 @@ export class DdcClient { /** * Retrieves the current active deposit of the account for a specific cluster. * - * @param clusterId - The ID of the cluster to get deposit for. * @param accountId - Optional account ID. If not provided, uses the signer's address. * * @returns A promise that resolves to the current active deposit of the account. @@ -220,13 +213,12 @@ export class DdcClient { * @example * * ```typescript - * const clusterId: ClusterId = '0x...'; * const deposit = await ddcClient.getDeposit(clusterId); * * console.log(deposit); * ``` * */ - async getDeposit(clusterId: ClusterId, accountId?: AccountId) { + async getDeposit(accountId?: AccountId) { const targetAccountId = accountId || this.signer.address; this.logger.info('Getting the account deposit %s using smart contract', targetAccountId); @@ -298,7 +290,7 @@ export class DdcClient { * console.log('Unlocking chunks:', ledger?.unlocking); * ``` */ - async getLedger(clusterId?: ClusterId, accountId?: AccountId): Promise { + async getLedger(accountId?: AccountId): Promise { const targetAccountId = accountId || this.signer.address; this.logger.info('Getting ledger information for account %s', targetAccountId); From 49e9bc827bf1ddc128f9c7cb18d01230693b1108 Mon Sep 17 00:00:00 2001 From: antonmazhuto Date: Thu, 14 Aug 2025 17:00:31 +0300 Subject: [PATCH 07/13] fixed playground --- playground/src/Playground.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playground/src/Playground.tsx b/playground/src/Playground.tsx index ff2d22f5..c6853cfa 100644 --- a/playground/src/Playground.tsx +++ b/playground/src/Playground.tsx @@ -298,7 +298,7 @@ export const Playground = () => { try { setInProgress(true); - await client!.depositBalance(currentClusterId as ClusterId, BigInt(extraDeposit) * CERE); + await client!.depositBalance(BigInt(extraDeposit) * CERE); const updatedDeposit = await client!.getDeposit(currentClusterId as ClusterId); setDeposit(blockchain!.formatBalance(updatedDeposit, false)); setStep(step + 1); From ba940b522bf0bed93637aa0bf3b5a8f6c099d4df Mon Sep 17 00:00:00 2001 From: antonmazhuto Date: Thu, 14 Aug 2025 18:58:55 +0300 Subject: [PATCH 08/13] Release v2.16.0 --- examples/cli/package.json | 4 +- examples/node/package.json | 6 +- examples/node/smart-contract-usage/README.md | 139 ++++++++++++++++++ examples/node/smart-contract-usage/index.ts | 86 +++++++++++ .../node/smart-contract-usage/package.json | 26 ++++ lerna.json | 2 +- package-lock.json | 58 ++++---- packages/blockchain/package.json | 2 +- packages/changelog-preset/package.json | 2 +- packages/cli/package.json | 6 +- packages/ddc-client/package.json | 8 +- packages/ddc/package.json | 4 +- packages/eslint-config/package.json | 2 +- packages/file-storage/package.json | 6 +- packages/typedoc-config/package.json | 2 +- playground/package.json | 6 +- tests/package.json | 10 +- 17 files changed, 310 insertions(+), 59 deletions(-) create mode 100644 examples/node/smart-contract-usage/README.md create mode 100644 examples/node/smart-contract-usage/index.ts create mode 100644 examples/node/smart-contract-usage/package.json diff --git a/examples/cli/package.json b/examples/cli/package.json index 47623e2e..1f84da04 100644 --- a/examples/cli/package.json +++ b/examples/cli/package.json @@ -1,8 +1,8 @@ { "name": "@cere-ddc-sdk/cli-examples", - "version": "2.15.0", + "version": "2.16.0", "private": true, "dependencies": { - "@cere-ddc-sdk/cli": "2.15.0" + "@cere-ddc-sdk/cli": "2.16.0" } } diff --git a/examples/node/package.json b/examples/node/package.json index c3559480..e2c2e8fe 100644 --- a/examples/node/package.json +++ b/examples/node/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/node-examples", - "version": "2.15.0", + "version": "2.16.0", "private": true, "type": "module", "scripts": { @@ -14,8 +14,8 @@ "example:8": "ts-node --esm ./8-sudo-batch-remove-buckets/index.ts" }, "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc-client": "2.15.0", + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc-client": "2.16.0", "@types/json-bigint": "^1.0.4", "json-bigint": "^1.0.0", "ts-node": "^10.9.2" diff --git a/examples/node/smart-contract-usage/README.md b/examples/node/smart-contract-usage/README.md new file mode 100644 index 00000000..bb3d3b9f --- /dev/null +++ b/examples/node/smart-contract-usage/README.md @@ -0,0 +1,139 @@ +# DDC Client со смарт-контрактами + +Этот пример демонстрирует использование DDC Client с новой архитектурой на основе смарт-контрактов customer deposit. + +## Обзор изменений + +### Что изменилось + +1. **Смарт-контракты вместо палетов**: Все операции с депозитами выполняются через смарт-контракт +2. **Встроенные адреса контрактов**: Адреса включены в стандартные пресеты (DEVNET, TESTNET, MAINNET) +3. **Новый метод**: `getLedger()` для получения расширенной информации о балансе +4. **Улучшенные события**: Смарт-контракт эмитирует детализированные события + +### Что НЕ изменилось + +- Все публичные методы DdcClient остались неизменными +- Сигнатуры методов не изменились +- Существующий код работает без изменений (если использует стандартные пресеты) + +## Использование + +### Создание клиента + +```typescript +import { DdcClient } from '@cere-ddc-sdk/ddc-client'; +import { DEVNET } from '@cere-ddc-sdk/ddc'; + +// Создание клиента со встроенным адресом смарт-контракта +const client = await DdcClient.create('//Alice', DEVNET); +``` + +### Кастомная конфигурация + +```typescript +// Если нужен собственный адрес смарт-контракта +const client = await DdcClient.create('//Alice', { + ...DEVNET, + customerDepositContractAddress: 'CUSTOM_CONTRACT_ADDRESS' +}); +``` + +### Использование расширенных возможностей + +```typescript +// Новый метод для получения полной информации о балансе +const ledger = await client.getLedger(); +if (ledger) { + console.log('Active balance:', ledger.active); + console.log('Total balance:', ledger.total); + console.log('Unlocking chunks:', ledger.unlocking); +} +``` + +## Примеры операций + +### Базовые операции с депозитами + +```typescript +const clusterId = '0x01...'; // ID кластера +const amount = 1000n; // Сумма в tokens + +// Депозит средств +await client.depositBalance(clusterId, amount); + +// Депозит для другого пользователя +await client.depositBalanceFor(targetAddress, clusterId, amount); + +// Получение текущего депозита +const deposit = await client.getDeposit(clusterId); + +// Разблокировка средств +await client.unlockDeposit(clusterId, amount); + +// Вывод разблокированных средств +await client.withdrawUnlockedDeposit(clusterId); +``` + +### Расширенная информация о балансе + +```typescript +// Получение полной информации о депозите +const ledger = await client.getLedger(); +if (ledger) { + console.log('Owner:', ledger.owner); + console.log('Total balance:', ledger.total); + console.log('Active balance:', ledger.active); + console.log('Unlocking chunks:', ledger.unlocking); +} +``` + +## События смарт-контракта + +Смарт-контракт customer deposit эмитирует следующие события для мониторинга операций: + +| Событие | Описание | Поля | +|---------|----------|------| +| `DdcBalanceDeposited` | Депозит средств | `cluster_id`, `owner_id`, `amount` | +| `DdcBalanceUnlocked` | Разблокировка средств | `cluster_id`, `owner_id`, `amount` | +| `DdcBalanceWithdrawn` | Вывод средств | `cluster_id`, `owner_id`, `amount` | +| `DdcBalanceCharged` | Списание (DAC payouts) | `cluster_id`, `owner_id`, `charged`, `expected` | + +### Интерфейсы смарт-контракта + +- **DdcBalancesFetcher**: Получение информации о балансах +- **DdcBalancesDepositor**: Операции с депозитами +- **DdcPayoutsPayer**: Списания для DAC payouts + +## Запуск примера + +```bash +cd examples/node/smart-contract-usage +npm install +npm start +``` + +## Тестирование + +Пример демонстрирует работу DDC Client с архитектурой смарт-контрактов. При отсутствии развернутого контракта по указанному адресу, будут показаны соответствующие ошибки. + +## Развертывание на продакшн + +1. Убедитесь что смарт-контракт customer deposit развернут в вашей сети +2. Получите адрес контракта для каждого кластера +3. Обновите конфигурацию DdcClient (если используете кастомный адрес) +4. Протестируйте все операции с депозитами +5. Настройте мониторинг событий смарт-контракта + +## Кастомные смарт-контракты + +Если вы используете собственный адрес смарт-контракта: + +```typescript +const client = await DdcClient.create('//Alice', { + ...DEVNET, + customerDepositContractAddress: 'YOUR_CUSTOM_CONTRACT_ADDRESS' +}); +``` + +Убедитесь, что контракт реализует все необходимые интерфейсы (`DdcBalancesFetcher`, `DdcBalancesDepositor`, `DdcPayoutsPayer`). \ No newline at end of file diff --git a/examples/node/smart-contract-usage/index.ts b/examples/node/smart-contract-usage/index.ts new file mode 100644 index 00000000..48e414fd --- /dev/null +++ b/examples/node/smart-contract-usage/index.ts @@ -0,0 +1,86 @@ +import { DdcClient } from '@cere-ddc-sdk/ddc-client'; +import { DEVNET } from '@cere-ddc-sdk/ddc'; +import { Blockchain } from '@cere-ddc-sdk/blockchain'; + +async function main() { + console.log('🚀 Пример использования DDC Client со смарт-контрактами'); + + // === СОЗДАНИЕ КЛИЕНТА === + console.log('\n🔥 Создание DDC Client со смарт-контрактом:'); + + // DdcClient теперь работает только со смарт-контрактами + // Адрес контракта включен в пресеты по умолчанию + const blockchain = await Blockchain.connect({ wsEndpoint: DEVNET.blockchain }); + const client = await DdcClient.create('//Alice', { + ...DEVNET, + blockchain, + customerDepositContractAddress: DEVNET.customerDepositContractAddress || '', + }); + + try { + // Получение баланса аккаунта + const balance = await client.getBalance(); + console.log('Баланс аккаунта:', balance.toString()); + + // Получение депозита из смарт-контракта + const clusterId = '0x01000000000000000000000000000000000000000000000000000000000000000000000000000000'; + const deposit = await client.getDeposit(clusterId); + console.log('Депозит в смарт-контракте:', deposit.toString()); + + // Получение полной информации о балансе (ledger) + const ledger = await client.getLedger(clusterId); + if (ledger) { + console.log('\n📊 Полная информация о балансе:'); + console.log(' - Владелец:', ledger.owner); + console.log(' - Общая сумма:', ledger.total.toString()); + console.log(' - Активная сумма:', ledger.active.toString()); + console.log(' - Разблокировка:', ledger.unlocking.length, 'chunk(s)'); + + ledger.unlocking.forEach((chunk, index) => { + console.log(` Chunk ${index + 1}: ${chunk.value.toString()} tokens at block ${chunk.block}`); + }); + } else { + console.log('Нет данных о балансе в смарт-контракте'); + } + + // === ПРИМЕРЫ ОПЕРАЦИЙ === + console.log('\n💰 Примеры операций со смарт-контрактом:'); + + // Депозит средств + console.log('1. Депозит 1000 tokens...'); + const depositTx = await client.depositBalance(clusterId, 1000n); + console.log('Транзакция депозита:', depositTx.txHash); + + // Депозит для другого пользователя + console.log('2. Депозит для другого пользователя...'); + const targetAddress = '5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY'; + const depositForTx = await client.depositBalanceFor(targetAddress, clusterId, 500n); + console.log('Транзакция депозита для другого:', depositForTx.txHash); + + // Разблокировка средств + console.log('3. Разблокировка 100 tokens...'); + const unlockTx = await client.unlockDeposit(clusterId, 100n); + console.log('Транзакция разблокировки:', unlockTx.txHash); + + // Вывод разблокированных средств (после периода разблокировки) + console.log('4. Вывод разблокированных средств...'); + const withdrawTx = await client.withdrawUnlockedDeposit(clusterId); + console.log('Транзакция вывода:', withdrawTx.txHash); + } catch (error: any) { + console.log('Ошибка при работе со смарт-контрактом:', error.message); + console.log('Убедитесь что смарт-контракт развернут по указанному адресу'); + } + + console.log('\n✅ Все операции выполнены успешно!'); + console.log('\n📖 Особенности работы со смарт-контрактами:'); + console.log('1. Все операции с депозитами теперь выполняются через смарт-контракт'); + console.log('2. Адрес контракта включен в стандартные пресеты DEVNET, TESTNET, MAINNET'); + console.log('3. Метод getLedger() предоставляет расширенную информацию о балансе'); + console.log('4. События смарт-контракта логируются для мониторинга операций'); + console.log('5. Смарт-контракт поддерживает все необходимые интерфейсы для DDC'); +} + +main().catch((error) => { + console.error('Ошибка:', error); + process.exit(1); +}); diff --git a/examples/node/smart-contract-usage/package.json b/examples/node/smart-contract-usage/package.json new file mode 100644 index 00000000..cfc5e386 --- /dev/null +++ b/examples/node/smart-contract-usage/package.json @@ -0,0 +1,26 @@ +{ + "name": "smart-contract-usage-example", + "version": "1.0.0", + "description": "Example of using DDC Client with smart contracts", + "main": "index.ts", + "scripts": { + "start": "ts-node index.ts", + "dev": "ts-node --watch index.ts" + }, + "dependencies": { + "@cere-ddc-sdk/ddc-client": "workspace:*", + "@cere-ddc-sdk/ddc": "workspace:*", + "@cere-ddc-sdk/blockchain": "workspace:*" + }, + "devDependencies": { + "ts-node": "^10.9.1", + "typescript": "^5.0.0" + }, + "keywords": [ + "cere", + "ddc", + "smart-contract", + "customer-deposit", + "blockchain" + ] +} diff --git a/lerna.json b/lerna.json index e884c578..555c2087 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "2.15.0", + "version": "2.16.0", "command": { "publish": { "directory": "{workspaceRoot}/{projectRoot}/package" diff --git a/package-lock.json b/package-lock.json index cca0b7e1..2feeb487 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,17 +38,17 @@ }, "examples/cli": { "name": "@cere-ddc-sdk/cli-examples", - "version": "2.15.0", + "version": "2.16.0", "dependencies": { - "@cere-ddc-sdk/cli": "2.15.0" + "@cere-ddc-sdk/cli": "2.16.0" } }, "examples/node": { "name": "@cere-ddc-sdk/node-examples", - "version": "2.15.0", + "version": "2.16.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc-client": "2.15.0", + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc-client": "2.16.0", "@types/json-bigint": "^1.0.4", "json-bigint": "^1.0.0", "ts-node": "^10.9.2" @@ -23143,7 +23143,7 @@ }, "packages/blockchain": { "name": "@cere-ddc-sdk/blockchain", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { "@cere/embed-wallet-inject": "^0.20.1", @@ -23477,7 +23477,7 @@ }, "packages/changelog-preset": { "name": "@cere-ddc-sdk/conventional-changelog-changelog-preset", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { "conventional-changelog-conventionalcommits": "^7.0.2" @@ -23485,11 +23485,11 @@ }, "packages/cli": { "name": "@cere-ddc-sdk/cli", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/ddc": "2.15.0", - "@cere-ddc-sdk/ddc-client": "2.15.0", + "@cere-ddc-sdk/ddc": "2.16.0", + "@cere-ddc-sdk/ddc-client": "2.16.0", "@polkadot/util-crypto": "^13.3.1", "@types/yargs": "^17.0.32", "yargs": "^17.7.2" @@ -23503,10 +23503,10 @@ }, "packages/ddc": { "name": "@cere-ddc-sdk/ddc", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", + "@cere-ddc-sdk/blockchain": "2.16.0", "@grpc/grpc-js": "^1.9.13", "@protobuf-ts/grpc-transport": "^2.9.3", "@protobuf-ts/runtime": "^2.9.3", @@ -23535,12 +23535,12 @@ }, "packages/ddc-client": { "name": "@cere-ddc-sdk/ddc-client", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc": "2.15.0", - "@cere-ddc-sdk/file-storage": "2.15.0" + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc": "2.16.0", + "@cere-ddc-sdk/file-storage": "2.16.0" } }, "packages/ddc/node_modules/buffer": { @@ -23567,7 +23567,7 @@ }, "packages/eslint-config": { "name": "@cere-ddc-sdk/eslint-config", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { "@typescript-eslint/eslint-plugin": "^6.16.0", @@ -23584,16 +23584,16 @@ }, "packages/file-storage": { "name": "@cere-ddc-sdk/file-storage", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc": "2.15.0" + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc": "2.16.0" } }, "packages/typedoc-config": { "name": "@cere-ddc-sdk/typedoc-config", - "version": "2.15.0", + "version": "2.16.0", "license": "Apache-2.0", "dependencies": { "typedoc-plugin-markdown": "^3.17.1" @@ -23604,10 +23604,10 @@ }, "playground": { "name": "@cere-ddc-sdk/playground", - "version": "2.15.0", + "version": "2.16.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc-client": "2.15.0", + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc-client": "2.16.0", "@cere/embed-wallet": "^0.20.1", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", @@ -23631,12 +23631,12 @@ }, "tests": { "name": "@cere-ddc-sdk/tests", - "version": "2.15.0", + "version": "2.16.0", "dependencies": { - "@cere-ddc-sdk/blockchain": "2.15.0", - "@cere-ddc-sdk/ddc": "2.15.0", - "@cere-ddc-sdk/ddc-client": "2.15.0", - "@cere-ddc-sdk/file-storage": "2.15.0", + "@cere-ddc-sdk/blockchain": "2.16.0", + "@cere-ddc-sdk/ddc": "2.16.0", + "@cere-ddc-sdk/ddc-client": "2.16.0", + "@cere-ddc-sdk/file-storage": "2.16.0", "@types/jest": "^29.5.11", "internal-ip": "6.2.0", "jest": "^29.7.0", diff --git a/packages/blockchain/package.json b/packages/blockchain/package.json index 87468700..e80b5c4f 100644 --- a/packages/blockchain/package.json +++ b/packages/blockchain/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/blockchain", - "version": "2.15.0", + "version": "2.16.0", "description": "Cere Blockchain client", "type": "module", "main": "dist/index.cjs", diff --git a/packages/changelog-preset/package.json b/packages/changelog-preset/package.json index 4c4896f3..e4915b78 100644 --- a/packages/changelog-preset/package.json +++ b/packages/changelog-preset/package.json @@ -1,6 +1,6 @@ { "name": "@cere-ddc-sdk/conventional-changelog-changelog-preset", - "version": "2.15.0", + "version": "2.16.0", "private": true, "author": "Cere Network Date: Thu, 14 Aug 2025 19:02:20 +0300 Subject: [PATCH 09/13] fix cli --- packages/cli/src/deposit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/deposit.ts b/packages/cli/src/deposit.ts index 66bb51f0..17898774 100644 --- a/packages/cli/src/deposit.ts +++ b/packages/cli/src/deposit.ts @@ -9,7 +9,7 @@ export type DepositOptions = { }; export const deposit = async (client: DdcClient, amount: number, options: DepositOptions) => { - await client.depositBalance(options.clusterId, BigInt(amount * CERE), options); + await client.depositBalance(BigInt(amount * CERE)); const totalBalance = await client.getDeposit(options.clusterId); return Number(totalBalance / BigInt(CERE)); From 7c346318c3b4c542e32c9aaec2fb9a281db95079 Mon Sep 17 00:00:00 2001 From: antonmazhuto Date: Thu, 14 Aug 2025 19:06:26 +0300 Subject: [PATCH 10/13] fix tests --- tests/specs/DdcClient.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/specs/DdcClient.spec.ts b/tests/specs/DdcClient.spec.ts index 28d3f153..cedb38cc 100644 --- a/tests/specs/DdcClient.spec.ts +++ b/tests/specs/DdcClient.spec.ts @@ -205,7 +205,7 @@ describe('DDC Client', () => { test('Deposit balance', async () => { const toDeposit = 10n * CERE; const prevDeposit = await client.getDeposit(clusterId); - await client.depositBalance(clusterId, toDeposit); + await client.depositBalance(toDeposit); const nextDeposit = await client.getDeposit(clusterId); expect(nextDeposit - prevDeposit).toEqual(toDeposit); From 3004425cca941b3511bf1702668353a7de3df0db Mon Sep 17 00:00:00 2001 From: antonmazhuto Date: Thu, 14 Aug 2025 23:41:29 +0300 Subject: [PATCH 11/13] fix tests --- .../blockchain/src/CustomerDepositContract.ts | 45 +++++++++++-------- packages/ddc-client/src/DdcClient.ts | 21 +++------ tests/setup/environment/blockchain.ts | 1 - 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/packages/blockchain/src/CustomerDepositContract.ts b/packages/blockchain/src/CustomerDepositContract.ts index c34d4b18..a42ab452 100644 --- a/packages/blockchain/src/CustomerDepositContract.ts +++ b/packages/blockchain/src/CustomerDepositContract.ts @@ -33,6 +33,12 @@ export class CustomerDepositContract { }); } + private ensureConnected(): void { + if (!this.apiPromise.isConnected) { + throw new Error('API must be connected to a chain before using CustomerDepositContract methods'); + } + } + private toBigIntSafe(value: string | number | bigint): bigint { if (typeof value === 'string') { value = value.replace(/[^\d-]/g, ''); @@ -47,6 +53,8 @@ export class CustomerDepositContract { * @returns Promise that resolves to balance information or null if the balance is not found */ async getBalance(owner: AccountId): Promise { + this.ensureConnected(); + try { const { result, output } = await this.contract.query['ddcBalancesFetcher::getBalance']( owner, @@ -100,6 +108,8 @@ export class CustomerDepositContract { * ``` */ deposit(value: bigint): Sendable { + this.ensureConnected(); + const tx = this.contract.tx['ddcBalancesDepositor::deposit']({ gasLimit: this.defaultGasLimit, storageDepositLimit: null, @@ -111,25 +121,25 @@ export class CustomerDepositContract { /** * Tops up the deposit balance for a specific owner on behalf of the faucet. * - * @param clusterId - Cluster ID for the deposit * @param owner - Account owner address to top up * @param value - Amount to deposit * @returns Transaction to execute * * @example * ```typescript - * const tx = contract.depositFor('0x...', '5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMae2Qu', 100n); + * const tx = contract.depositFor('5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMae2Qu', 100n); * const result = await blockchain.send(tx, { account: signer }); * ``` */ - depositFor(clusterId: string, owner: AccountId, value: bigint): Sendable { + depositFor(owner: AccountId, value: bigint): Sendable { + this.ensureConnected(); + const tx = this.contract.tx['ddcBalancesDepositor::depositFor']( { gasLimit: this.defaultGasLimit, storageDepositLimit: null, + value, }, - clusterId, - value, owner, ); return tx as unknown as Sendable; @@ -138,23 +148,23 @@ export class CustomerDepositContract { /** * Initiates unlocking of the deposit balance on behalf of the owner. * - * @param clusterId - Cluster ID to unlock the deposit * @param value - Amount to unlock * @returns Transaction to execute * * @example * ```typescript - * const tx = contract.unlockDeposit('0x...', 50n); + * const tx = contract.unlockDeposit(50n); * const result = await blockchain.send(tx, { account: signer }); * ``` */ - unlockDeposit(clusterId: string, value: bigint): Sendable { + unlockDeposit(value: bigint): Sendable { + this.ensureConnected(); + const tx = this.contract.tx['ddcBalancesDepositor::unlockDeposit']( { gasLimit: this.defaultGasLimit, storageDepositLimit: null, }, - clusterId, value, ); return tx as unknown as Sendable; @@ -167,18 +177,17 @@ export class CustomerDepositContract { * * @example * ```typescript - * const tx = contract.withdrawUnlocked('0x...'); + * const tx = contract.withdrawUnlocked(); * const result = await blockchain.send(tx, { account: signer }); * ``` */ - withdrawUnlocked(clusterId: string): Sendable { - const tx = this.contract.tx['ddcBalancesDepositor::withdrawUnlocked']( - { - gasLimit: this.defaultGasLimit, - storageDepositLimit: null, - }, - clusterId, - ); + withdrawUnlocked(): Sendable { + this.ensureConnected(); + + const tx = this.contract.tx['ddcBalancesDepositor::withdrawUnlocked']({ + gasLimit: this.defaultGasLimit, + storageDepositLimit: null, + }); return tx as unknown as Sendable; } } diff --git a/packages/ddc-client/src/DdcClient.ts b/packages/ddc-client/src/DdcClient.ts index ded5cb2f..c0a2bd14 100644 --- a/packages/ddc-client/src/DdcClient.ts +++ b/packages/ddc-client/src/DdcClient.ts @@ -181,7 +181,6 @@ export class DdcClient { * This allows depositing funds on behalf of another address. * * @param targetAddress - The target address to deposit funds for. - * @param clusterId - The ID of the cluster to deposit tokens for. * @param amount - The amount of tokens to deposit. * * @returns A promise that resolves to the transaction hash of the deposit. @@ -190,16 +189,15 @@ export class DdcClient { * * ```typescript * const targetAddress = '5D5PhZQNJzcJXVBxwJxZcsutjKPqUPydrvpu6HeiBfMae2Qu'; - * const clusterId: ClusterId = '0x...'; * const amount = 100n; - * const txHash = await ddcClient.depositBalanceFor(targetAddress, clusterId, amount); + * const txHash = await ddcClient.depositBalanceFor(targetAddress, amount); * * console.log(txHash); * ``` * */ - async depositBalanceFor(targetAddress: AccountId, clusterId: ClusterId, amount: bigint) { + async depositBalanceFor(targetAddress: AccountId, amount: bigint) { this.logger.info('Depositing balance %s for %s using smart contract', amount, targetAddress); - const tx = this.customerDepositContract.depositFor(clusterId, targetAddress, amount); + const tx = this.customerDepositContract.depositFor(targetAddress, amount); return this.blockchain.send(tx, { account: this.signer }); } @@ -232,7 +230,6 @@ export class DdcClient { /** * Unlocks deposit funds from the account for the specified cluster. * - * @param clusterId - The ID of the cluster. * @param amount - The amount to unlock. * * @returns A promise that resolves to the transaction hash. @@ -240,38 +237,34 @@ export class DdcClient { * @example * * ```typescript - * const clusterId: ClusterId = '0x...'; * const amount = 100n; * const txHash = await ddcClient.unlockDeposit(clusterId, amount); * * console.log(txHash); * ``` * */ - async unlockDeposit(clusterId: ClusterId, amount: bigint) { + async unlockDeposit(amount: bigint) { this.logger.info('Unlocking deposit %s using smart contract', amount); - const tx = this.customerDepositContract.unlockDeposit(clusterId, amount); + const tx = this.customerDepositContract.unlockDeposit(amount); return this.blockchain.send(tx, { account: this.signer }); } /** * Withdraws unlocked funds from the account for the specified cluster. * - * @param clusterId - The ID of the cluster. - * * @returns A promise that resolves to the transaction hash. * * @example * * ```typescript - * const clusterId: ClusterId = '0x...'; * const txHash = await ddcClient.withdrawUnlockedDeposit(clusterId); * * console.log(txHash); * ``` * */ - async withdrawUnlockedDeposit(clusterId: ClusterId) { + async withdrawUnlockedDeposit() { this.logger.info('Withdrawing unlocked deposit using smart contract'); - const tx = this.customerDepositContract.withdrawUnlocked(clusterId); + const tx = this.customerDepositContract.withdrawUnlocked(); return this.blockchain.send(tx, { account: this.signer }); } diff --git a/tests/setup/environment/blockchain.ts b/tests/setup/environment/blockchain.ts index 6b8d445f..b2bccab9 100644 --- a/tests/setup/environment/blockchain.ts +++ b/tests/setup/environment/blockchain.ts @@ -166,7 +166,6 @@ export const setupBlockchain = async () => { console.time('Create buckets'); const bucketsSendResult = await blockchain.batchAllSend( [ - blockchain.ddcCustomers.deposit(clusterId, 100n * CERE), blockchain.ddcCustomers.createBucket(clusterId, { isPublic: true }), // 1n - public bucket blockchain.ddcCustomers.createBucket(clusterId, { isPublic: false }), // 2n - private bucket ], From 9526d31dd68cc3b44a3766ec2f925f67c4126815 Mon Sep 17 00:00:00 2001 From: antonmazhuto Date: Fri, 15 Aug 2025 00:06:52 +0300 Subject: [PATCH 12/13] fix tests --- tests/helpers/constants.ts | 2 +- tests/setup/environment/blockchain.ts | 45 ++++++++++++++++++++------- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/tests/helpers/constants.ts b/tests/helpers/constants.ts index 5b01d3e7..84f27df9 100644 --- a/tests/helpers/constants.ts +++ b/tests/helpers/constants.ts @@ -5,6 +5,6 @@ export const DDC_BLOCK_SIZE = 16 * 1024; export const ROOT_USER_SEED = 'hybrid label reunion only dawn maze asset draft cousin height flock nation'; export const ROOT_ACCOUNT_TYPE = 'sr25519'; export const BLOCKCHAIN_MAX_BLOCK_WEIGHT = 2_000_000_000_000; -export const STORAGE_NODE_MAX_STARTUP_TIME = 60_000; +export const STORAGE_NODE_MAX_STARTUP_TIME = 120_000; export const BLOCKCHAIN_NODE_MAX_STARTUP_TIME = 30_000; export const DDC_CLUSTER_STAKE = 100_000; // CERE tokens diff --git a/tests/setup/environment/blockchain.ts b/tests/setup/environment/blockchain.ts index b2bccab9..d5c72bbe 100644 --- a/tests/setup/environment/blockchain.ts +++ b/tests/setup/environment/blockchain.ts @@ -16,6 +16,7 @@ import { getHostIP, getStorageNodes, BLOCKCHAIN_NODE_MAX_STARTUP_TIME, + ROOT_USER_SEED, } from '../../helpers'; export type BlockchainConfig = BlockchainState & { @@ -79,7 +80,7 @@ export const stopBlockchain = async () => { }; export const setupBlockchain = async () => { - console.group('Setup pallets'); + console.group('Setup blockchain with smart contracts'); console.time('Done'); await cryptoWaitReady(); @@ -163,16 +164,38 @@ export const setupBlockchain = async () => { ); console.timeEnd('Add nodes to cluster'); - console.time('Create buckets'); - const bucketsSendResult = await blockchain.batchAllSend( - [ - blockchain.ddcCustomers.createBucket(clusterId, { isPublic: true }), // 1n - public bucket - blockchain.ddcCustomers.createBucket(clusterId, { isPublic: false }), // 2n - private bucket - ], - { account: rootAccount }, - ); - const createdBucketIds = blockchain.ddcCustomers.extractCreatedBucketIds(bucketsSendResult.events); - console.timeEnd('Create buckets'); + // Setup customer with smart contract + console.time('Setup customer with smart contract'); + const CUSTOMER_DEPOSIT_CONTRACT_ADDRESS = '6TZJb1s7PMa9UcHnjickVtiNG2JjYN6wNYU3CTMvji1VxTMY'; + const customerDepositContract = blockchain.getCustomerDepositContract(CUSTOMER_DEPOSIT_CONTRACT_ADDRESS); + + // Make a deposit for the customer (100 CERE) + const depositTx = customerDepositContract.deposit(100n * CERE); + await blockchain.send(depositTx, { account: rootAccount }); + console.timeEnd('Setup customer with smart contract'); + + // Create buckets through DDC Client (which uses smart contracts) + console.time('Create buckets through DDC Client'); + const { DdcClient } = await import('@cere-ddc-sdk/ddc-client'); + const { UriSigner } = await import('@cere-ddc-sdk/blockchain'); + + const signer = new UriSigner(ROOT_USER_SEED); + await signer.isReady(); + + const ddcClient = await DdcClient.create(signer, { + blockchain: 'ws://localhost:9944', + customerDepositContractAddress: CUSTOMER_DEPOSIT_CONTRACT_ADDRESS, + logLevel: 'debug', + nodes: [], + }); + + // Create buckets through client + const publicBucket = await ddcClient.createBucket(clusterId, { isPublic: true }); + const privateBucket = await ddcClient.createBucket(clusterId, { isPublic: false }); + const createdBucketIds = [publicBucket, privateBucket]; + + await ddcClient.disconnect(); + console.timeEnd('Create buckets through DDC Client'); console.timeEnd('Done'); console.groupEnd(); From f5a4a51388d892ee8caa9ed3c863972f7a743b94 Mon Sep 17 00:00:00 2001 From: antonmazhuto Date: Fri, 15 Aug 2025 13:31:15 +0300 Subject: [PATCH 13/13] fix --- examples/node/smart-contract-usage/README.md | 139 ------------------ examples/node/smart-contract-usage/index.ts | 86 ----------- .../node/smart-contract-usage/package.json | 26 ---- 3 files changed, 251 deletions(-) delete mode 100644 examples/node/smart-contract-usage/README.md delete mode 100644 examples/node/smart-contract-usage/index.ts delete mode 100644 examples/node/smart-contract-usage/package.json diff --git a/examples/node/smart-contract-usage/README.md b/examples/node/smart-contract-usage/README.md deleted file mode 100644 index bb3d3b9f..00000000 --- a/examples/node/smart-contract-usage/README.md +++ /dev/null @@ -1,139 +0,0 @@ -# DDC Client со смарт-контрактами - -Этот пример демонстрирует использование DDC Client с новой архитектурой на основе смарт-контрактов customer deposit. - -## Обзор изменений - -### Что изменилось - -1. **Смарт-контракты вместо палетов**: Все операции с депозитами выполняются через смарт-контракт -2. **Встроенные адреса контрактов**: Адреса включены в стандартные пресеты (DEVNET, TESTNET, MAINNET) -3. **Новый метод**: `getLedger()` для получения расширенной информации о балансе -4. **Улучшенные события**: Смарт-контракт эмитирует детализированные события - -### Что НЕ изменилось - -- Все публичные методы DdcClient остались неизменными -- Сигнатуры методов не изменились -- Существующий код работает без изменений (если использует стандартные пресеты) - -## Использование - -### Создание клиента - -```typescript -import { DdcClient } from '@cere-ddc-sdk/ddc-client'; -import { DEVNET } from '@cere-ddc-sdk/ddc'; - -// Создание клиента со встроенным адресом смарт-контракта -const client = await DdcClient.create('//Alice', DEVNET); -``` - -### Кастомная конфигурация - -```typescript -// Если нужен собственный адрес смарт-контракта -const client = await DdcClient.create('//Alice', { - ...DEVNET, - customerDepositContractAddress: 'CUSTOM_CONTRACT_ADDRESS' -}); -``` - -### Использование расширенных возможностей - -```typescript -// Новый метод для получения полной информации о балансе -const ledger = await client.getLedger(); -if (ledger) { - console.log('Active balance:', ledger.active); - console.log('Total balance:', ledger.total); - console.log('Unlocking chunks:', ledger.unlocking); -} -``` - -## Примеры операций - -### Базовые операции с депозитами - -```typescript -const clusterId = '0x01...'; // ID кластера -const amount = 1000n; // Сумма в tokens - -// Депозит средств -await client.depositBalance(clusterId, amount); - -// Депозит для другого пользователя -await client.depositBalanceFor(targetAddress, clusterId, amount); - -// Получение текущего депозита -const deposit = await client.getDeposit(clusterId); - -// Разблокировка средств -await client.unlockDeposit(clusterId, amount); - -// Вывод разблокированных средств -await client.withdrawUnlockedDeposit(clusterId); -``` - -### Расширенная информация о балансе - -```typescript -// Получение полной информации о депозите -const ledger = await client.getLedger(); -if (ledger) { - console.log('Owner:', ledger.owner); - console.log('Total balance:', ledger.total); - console.log('Active balance:', ledger.active); - console.log('Unlocking chunks:', ledger.unlocking); -} -``` - -## События смарт-контракта - -Смарт-контракт customer deposit эмитирует следующие события для мониторинга операций: - -| Событие | Описание | Поля | -|---------|----------|------| -| `DdcBalanceDeposited` | Депозит средств | `cluster_id`, `owner_id`, `amount` | -| `DdcBalanceUnlocked` | Разблокировка средств | `cluster_id`, `owner_id`, `amount` | -| `DdcBalanceWithdrawn` | Вывод средств | `cluster_id`, `owner_id`, `amount` | -| `DdcBalanceCharged` | Списание (DAC payouts) | `cluster_id`, `owner_id`, `charged`, `expected` | - -### Интерфейсы смарт-контракта - -- **DdcBalancesFetcher**: Получение информации о балансах -- **DdcBalancesDepositor**: Операции с депозитами -- **DdcPayoutsPayer**: Списания для DAC payouts - -## Запуск примера - -```bash -cd examples/node/smart-contract-usage -npm install -npm start -``` - -## Тестирование - -Пример демонстрирует работу DDC Client с архитектурой смарт-контрактов. При отсутствии развернутого контракта по указанному адресу, будут показаны соответствующие ошибки. - -## Развертывание на продакшн - -1. Убедитесь что смарт-контракт customer deposit развернут в вашей сети -2. Получите адрес контракта для каждого кластера -3. Обновите конфигурацию DdcClient (если используете кастомный адрес) -4. Протестируйте все операции с депозитами -5. Настройте мониторинг событий смарт-контракта - -## Кастомные смарт-контракты - -Если вы используете собственный адрес смарт-контракта: - -```typescript -const client = await DdcClient.create('//Alice', { - ...DEVNET, - customerDepositContractAddress: 'YOUR_CUSTOM_CONTRACT_ADDRESS' -}); -``` - -Убедитесь, что контракт реализует все необходимые интерфейсы (`DdcBalancesFetcher`, `DdcBalancesDepositor`, `DdcPayoutsPayer`). \ No newline at end of file diff --git a/examples/node/smart-contract-usage/index.ts b/examples/node/smart-contract-usage/index.ts deleted file mode 100644 index 48e414fd..00000000 --- a/examples/node/smart-contract-usage/index.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { DdcClient } from '@cere-ddc-sdk/ddc-client'; -import { DEVNET } from '@cere-ddc-sdk/ddc'; -import { Blockchain } from '@cere-ddc-sdk/blockchain'; - -async function main() { - console.log('🚀 Пример использования DDC Client со смарт-контрактами'); - - // === СОЗДАНИЕ КЛИЕНТА === - console.log('\n🔥 Создание DDC Client со смарт-контрактом:'); - - // DdcClient теперь работает только со смарт-контрактами - // Адрес контракта включен в пресеты по умолчанию - const blockchain = await Blockchain.connect({ wsEndpoint: DEVNET.blockchain }); - const client = await DdcClient.create('//Alice', { - ...DEVNET, - blockchain, - customerDepositContractAddress: DEVNET.customerDepositContractAddress || '', - }); - - try { - // Получение баланса аккаунта - const balance = await client.getBalance(); - console.log('Баланс аккаунта:', balance.toString()); - - // Получение депозита из смарт-контракта - const clusterId = '0x01000000000000000000000000000000000000000000000000000000000000000000000000000000'; - const deposit = await client.getDeposit(clusterId); - console.log('Депозит в смарт-контракте:', deposit.toString()); - - // Получение полной информации о балансе (ledger) - const ledger = await client.getLedger(clusterId); - if (ledger) { - console.log('\n📊 Полная информация о балансе:'); - console.log(' - Владелец:', ledger.owner); - console.log(' - Общая сумма:', ledger.total.toString()); - console.log(' - Активная сумма:', ledger.active.toString()); - console.log(' - Разблокировка:', ledger.unlocking.length, 'chunk(s)'); - - ledger.unlocking.forEach((chunk, index) => { - console.log(` Chunk ${index + 1}: ${chunk.value.toString()} tokens at block ${chunk.block}`); - }); - } else { - console.log('Нет данных о балансе в смарт-контракте'); - } - - // === ПРИМЕРЫ ОПЕРАЦИЙ === - console.log('\n💰 Примеры операций со смарт-контрактом:'); - - // Депозит средств - console.log('1. Депозит 1000 tokens...'); - const depositTx = await client.depositBalance(clusterId, 1000n); - console.log('Транзакция депозита:', depositTx.txHash); - - // Депозит для другого пользователя - console.log('2. Депозит для другого пользователя...'); - const targetAddress = '5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY'; - const depositForTx = await client.depositBalanceFor(targetAddress, clusterId, 500n); - console.log('Транзакция депозита для другого:', depositForTx.txHash); - - // Разблокировка средств - console.log('3. Разблокировка 100 tokens...'); - const unlockTx = await client.unlockDeposit(clusterId, 100n); - console.log('Транзакция разблокировки:', unlockTx.txHash); - - // Вывод разблокированных средств (после периода разблокировки) - console.log('4. Вывод разблокированных средств...'); - const withdrawTx = await client.withdrawUnlockedDeposit(clusterId); - console.log('Транзакция вывода:', withdrawTx.txHash); - } catch (error: any) { - console.log('Ошибка при работе со смарт-контрактом:', error.message); - console.log('Убедитесь что смарт-контракт развернут по указанному адресу'); - } - - console.log('\n✅ Все операции выполнены успешно!'); - console.log('\n📖 Особенности работы со смарт-контрактами:'); - console.log('1. Все операции с депозитами теперь выполняются через смарт-контракт'); - console.log('2. Адрес контракта включен в стандартные пресеты DEVNET, TESTNET, MAINNET'); - console.log('3. Метод getLedger() предоставляет расширенную информацию о балансе'); - console.log('4. События смарт-контракта логируются для мониторинга операций'); - console.log('5. Смарт-контракт поддерживает все необходимые интерфейсы для DDC'); -} - -main().catch((error) => { - console.error('Ошибка:', error); - process.exit(1); -}); diff --git a/examples/node/smart-contract-usage/package.json b/examples/node/smart-contract-usage/package.json deleted file mode 100644 index cfc5e386..00000000 --- a/examples/node/smart-contract-usage/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "smart-contract-usage-example", - "version": "1.0.0", - "description": "Example of using DDC Client with smart contracts", - "main": "index.ts", - "scripts": { - "start": "ts-node index.ts", - "dev": "ts-node --watch index.ts" - }, - "dependencies": { - "@cere-ddc-sdk/ddc-client": "workspace:*", - "@cere-ddc-sdk/ddc": "workspace:*", - "@cere-ddc-sdk/blockchain": "workspace:*" - }, - "devDependencies": { - "ts-node": "^10.9.1", - "typescript": "^5.0.0" - }, - "keywords": [ - "cere", - "ddc", - "smart-contract", - "customer-deposit", - "blockchain" - ] -}