From e1ec251d5d4065dd00b37491012229feb82872a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Nicolas?= Date: Mon, 5 Sep 2022 12:53:16 +0200 Subject: [PATCH 1/2] prepare-v0.5.2: bump version, revert to correct name of the dev SDK --- bucket/Cargo.toml | 2 +- ddc_nft_registry/Cargo.toml | 2 +- sdk/package.json | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bucket/Cargo.toml b/bucket/Cargo.toml index 4a02b606..3a352914 100755 --- a/bucket/Cargo.toml +++ b/bucket/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ddc_bucket" -version = "0.5.1" +version = "0.5.2" authors = ["Aurélien Nicolas "] edition = "2021" description = "DDC v2 Smart Contracts -- Orchestrate the network around clusters and buckets" diff --git a/ddc_nft_registry/Cargo.toml b/ddc_nft_registry/Cargo.toml index 10f2bd81..4d5738ed 100755 --- a/ddc_nft_registry/Cargo.toml +++ b/ddc_nft_registry/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ddc_nft_registry" -version = "0.1.0" +version = "0.5.2" authors = ["Aurélien Nicolas ", "Anton Volk "] edition = "2021" diff --git a/sdk/package.json b/sdk/package.json index e3104df9..bd464f23 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,7 @@ { - "name": "@cere-ddc-sdk/smart-contract", - "version": "0.5.1", + "name": "@cere/ddc-contracts-sdk", + "description": "This is an SDK to work with DDC smart contracts, mainly for development and admin purposes. For apps, see https://github.com/Cerebellum-Network/cere-ddc-sdk-js", + "version": "0.5.2", "main": "src/index.js", "license": "Apache-2.0", "dependencies": { From 99c10446a28c3e04a39afcffa2e7dd20a198c0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Nicolas?= Date: Mon, 5 Sep 2022 13:14:52 +0200 Subject: [PATCH 2/2] prepare-v0.5.2 --- README.md | 7 +- sdk/src/abi/ddc_bucket.json | 320 +++++++++++++++++++++++++----- sdk/src/abi/ddc_nft_registry.json | 4 +- sdk/src/deployments.js | 8 +- 4 files changed, 286 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 42be6a65..797c0874 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,10 @@ cargo contract build --release --manifest-path ddc_nft_registry/Cargo.toml cp target/ink/ddc_bucket/metadata.json sdk/src/abi/ddc_bucket.json && cp target/ink/ddc_nft_registry/metadata.json sdk/src/abi/ddc_nft_registry.json ``` -- Use the script [deploy.js](deploy.js) to deploy the contracts. -- Update the [SDK default contracts](sdk/src/deployments.js). -- Publish the JS SDK (this requires an `NPM_TOKEN`): `cd sdk && npm publish` +- Use the script [deploy.js](deploy.js) or the [Explorer](https://explorer.cere.network/) to deploy the contracts. +- Update the [Admin SDK default contracts](sdk/src/deployments.js). +- Publish the Admin SDK (this requires an `NPM_TOKEN`): `cd sdk && npm publish` +- Similarly, update the [DDC SDK](https://github.com/Cerebellum-Network/cere-ddc-sdk-js) for apps. - Regenerate the documentation, then sync [docs.cere.network](https://github.com/Cerebellum-Network/docs.cere.network/blob/main/ddc/protocols/smart-contract-api.md): ```bash ABI_PATH=target/ink/ddc_bucket/metadata.json node ink-doc-gen diff --git a/sdk/src/abi/ddc_bucket.json b/sdk/src/abi/ddc_bucket.json index dbf50730..625bc97c 100644 --- a/sdk/src/abi/ddc_bucket.json +++ b/sdk/src/abi/ddc_bucket.json @@ -1,22 +1,28 @@ { "metadataVersion": "0.1.0", "source": { - "hash": "0x5e690c8fd199cbf15e7f27bf1b510235aaf5d2bfebc776f72b77f04e03c1ad3b", + "hash": "0xabfb40d2f3cd9742bdd462002e4b8629c375e941ba5d6a059e20b33e23871cec", "language": "ink! 3.0.0-rc4", - "compiler": "rustc 1.63.0-nightly" + "compiler": "rustc 1.59.0-nightly" }, "contract": { "name": "ddc_bucket", - "version": "0.5.0", + "version": "0.5.2", "authors": [ "Aurélien Nicolas " - ] + ], + "description": "DDC v2 Smart Contracts -- Orchestrate the network around clusters and buckets", + "license": "Apache-2.0" }, "spec": { "constructors": [ { "args": [], - "docs": [], + "docs": [ + "Create a new contract.", + "", + "The caller will be admin of the contract." + ], "name": [ "new" ], @@ -50,7 +56,9 @@ } } ], - "docs": [], + "docs": [ + " A bucket was created. The given account is its first owner and payer of resources." + ], "name": "BucketCreated" }, { @@ -89,7 +97,9 @@ } } ], - "docs": [], + "docs": [ + " Some amount of resources of a cluster were allocated to a bucket." + ], "name": "BucketAllocated" }, { @@ -117,7 +127,9 @@ } } ], - "docs": [], + "docs": [ + " The due costs of a bucket was settled from the bucket payer to the cluster." + ], "name": "BucketSettlePayment" }, { @@ -156,7 +168,9 @@ } } ], - "docs": [], + "docs": [ + " A new cluster was created." + ], "name": "ClusterCreated" }, { @@ -195,7 +209,9 @@ } } ], - "docs": [], + "docs": [ + " A vnode was re-assigned to new node." + ], "name": "ClusterNodeReplaced" }, { @@ -223,7 +239,9 @@ } } ], - "docs": [], + "docs": [ + " Some resources were reserved for the cluster from the nodes." + ], "name": "ClusterReserveResource" }, { @@ -251,7 +269,9 @@ } } ], - "docs": [], + "docs": [ + " The share of revenues of a cluster for a provider was distributed." + ], "name": "ClusterDistributeRevenues" }, { @@ -301,7 +321,9 @@ } } ], - "docs": [], + "docs": [ + " A node was created. The given account is its owner and recipient of revenues." + ], "name": "NodeCreated" }, { @@ -329,7 +351,9 @@ } } ], - "docs": [], + "docs": [ + " Tokens were deposited on an account." + ], "name": "Deposit" }, { @@ -357,7 +381,9 @@ } } ], - "docs": [], + "docs": [ + " A permission was granted to the account." + ], "name": "GrantPermission" }, { @@ -385,7 +411,9 @@ } } ], - "docs": [], + "docs": [ + " A permission was revoked from the account." + ], "name": "RevokePermission" } ], @@ -411,7 +439,15 @@ } } ], - "docs": [], + "docs": [ + " Create a new bucket and return its `bucket_id`.", + "", + " The caller will be its first owner and payer of resources.", + "", + " `bucket_params` is configuration used by clients and nodes. See the [data structure of BucketParams](https://docs.cere.network/ddc/protocols/contract-params-schema)", + "", + " The bucket can be connected to a single cluster (currently). Allocate cluster resources with the function `bucket_alloc_into_cluster`" + ], "mutates": true, "name": [ "bucket_create" @@ -446,7 +482,11 @@ } } ], - "docs": [], + "docs": [ + " Allocate some resources of a cluster to a bucket.", + "", + " The amount of resources is given per vnode (total resources will be `resource` times the number of vnodes)." + ], "mutates": true, "name": [ "bucket_alloc_into_cluster" @@ -470,7 +510,9 @@ } } ], - "docs": [], + "docs": [ + " Settle the due costs of a bucket from its payer account to the cluster account." + ], "mutates": true, "name": [ "bucket_settle_payment" @@ -500,7 +542,11 @@ } } ], - "docs": [], + "docs": [ + " Change the `bucket_params`, which is configuration used by clients and nodes.", + "", + " See the [data structure of BucketParams](https://docs.cere.network/ddc/protocols/contract-params-schema)" + ], "mutates": true, "name": [ "bucket_change_params" @@ -521,7 +567,9 @@ } } ], - "docs": [], + "docs": [ + " Get the current status of a bucket." + ], "mutates": false, "name": [ "bucket_get" @@ -565,7 +613,14 @@ } } ], - "docs": [], + "docs": [ + " Iterate through all buckets.", + "", + " The algorithm for paging is: start with `offset = 1` and `limit = 20`. The function returns a `(results, max_id)`. Call again with `offset += limit`, until `offset >= max_id`.", + " The optimal `limit` depends on the size of params.", + "", + " The results can be filtered by owner. Note that paging must still be completed fully." + ], "mutates": false, "name": [ "bucket_list" @@ -580,7 +635,7 @@ { "args": [ { - "name": "manager", + "name": "_unused", "type": { "displayName": [ "AccountId" @@ -616,7 +671,15 @@ } } ], - "docs": [], + "docs": [ + " Create a new cluster and return its `cluster_id`.", + "", + " The caller will be its first manager.", + "", + " The cluster is split in a number of vnodes. The vnodes are assigned to the given physical nodes in a round-robin. Only nodes of providers that trust the cluster manager can be used (see `node_trust_manager`). The assignment can be changed with the function `cluster_replace_node`.", + "", + " `cluster_params` is configuration used by clients and nodes. In particular, this describes the semantics of vnodes. See the [data structure of ClusterParams](https://docs.cere.network/ddc/protocols/contract-params-schema)" + ], "mutates": true, "name": [ "cluster_create" @@ -624,7 +687,7 @@ "payable": true, "returnType": { "displayName": [ - "NodeId" + "ClusterId" ], "type": 1 }, @@ -651,7 +714,11 @@ } } ], - "docs": [], + "docs": [ + " As manager, reserve more resources for the cluster from the free capacity of nodes.", + "", + " The amount of resources is given per vnode (total resources will be `resource` times the number of vnodes)." + ], "mutates": true, "name": [ "cluster_reserve_resource" @@ -693,7 +760,11 @@ } } ], - "docs": [], + "docs": [ + " As manager, re-assign a vnode to another physical node.", + "", + " The cluster manager can only use nodes of providers that trust him (see `node_trust_manager`), or any nodes if he is also SuperAdmin." + ], "mutates": true, "name": [ "cluster_replace_node" @@ -717,7 +788,9 @@ } } ], - "docs": [], + "docs": [ + " Trigger the distribution of revenues from the cluster to the providers." + ], "mutates": true, "name": [ "cluster_distribute_revenues" @@ -747,7 +820,11 @@ } } ], - "docs": [], + "docs": [ + " Change the `cluster_params`, which is configuration used by clients and nodes.", + "", + " See the [data structure of ClusterParams](https://docs.cere.network/ddc/protocols/contract-params-schema)" + ], "mutates": true, "name": [ "cluster_change_params" @@ -768,7 +845,9 @@ } } ], - "docs": [], + "docs": [ + " Get the current status of a cluster." + ], "mutates": false, "name": [ "cluster_get" @@ -812,7 +891,14 @@ } } ], - "docs": [], + "docs": [ + " Iterate through all clusters.", + "", + " The algorithm for paging is: start with `offset = 1` and `limit = 20`. The function returns a `(results, max_id)`. Call again with `offset += limit`, until `offset >= max_id`.", + " The optimal `limit` depends on the size of params.", + "", + " The results can be filtered by manager. Note that paging must still be completed fully." + ], "mutates": false, "name": [ "cluster_list" @@ -836,7 +922,9 @@ } } ], - "docs": [], + "docs": [ + " As node provider, authorize a cluster manager to use his nodes." + ], "mutates": true, "name": [ "node_trust_manager" @@ -857,7 +945,9 @@ } } ], - "docs": [], + "docs": [ + " As node provider, revoke the authorization of a cluster manager to use his nodes." + ], "mutates": true, "name": [ "node_distrust_manager" @@ -896,7 +986,13 @@ } } ], - "docs": [], + "docs": [ + " Create a new node and return its `node_id`.", + "", + " The caller will be its owner.", + "", + " `node_params` is configuration used by clients and nodes. In particular, this contains the URL to the service. See the [data structure of NodeParams](https://docs.cere.network/ddc/protocols/contract-params-schema)" + ], "mutates": true, "name": [ "node_create" @@ -931,7 +1027,11 @@ } } ], - "docs": [], + "docs": [ + " Change the `node_params`, which is configuration used by clients and nodes.", + "", + " See the [data structure of NodeParams](https://docs.cere.network/ddc/protocols/contract-params-schema)" + ], "mutates": true, "name": [ "node_change_params" @@ -952,7 +1052,9 @@ } } ], - "docs": [], + "docs": [ + " Get the current status of a node." + ], "mutates": false, "name": [ "node_get" @@ -996,7 +1098,14 @@ } } ], - "docs": [], + "docs": [ + " Iterate through all nodes.", + "", + " The algorithm for paging is: start with `offset = 1` and `limit = 20`. The function returns a `(results, max_id)`. Call again with `offset += limit`, until `offset >= max_id`.", + " The optimal `limit` depends on the size of params.", + "", + " The results can be filtered by owner. Note that paging must still be completed fully." + ], "mutates": false, "name": [ "node_list" @@ -1010,7 +1119,10 @@ }, { "args": [], - "docs": [], + "docs": [ + " As user, deposit tokens on the account of the caller from the transaction value. This deposit", + " can be used to pay for the services to buckets of the account." + ], "mutates": true, "name": [ "account_deposit" @@ -1034,7 +1146,9 @@ } } ], - "docs": [], + "docs": [ + " Get the current status of an account." + ], "mutates": false, "name": [ "account_get" @@ -1050,7 +1164,9 @@ }, { "args": [], - "docs": [], + "docs": [ + " Get the current conversion rate between the native currency and an external currency (USD)." + ], "mutates": false, "name": [ "account_get_usd_per_cere" @@ -1076,7 +1192,11 @@ } } ], - "docs": [], + "docs": [ + " As price oracle, set the current conversion rate between the native currency and an external currency (USD).", + "", + " This requires the permission SetExchangeRate or SuperAdmin." + ], "mutates": true, "name": [ "account_set_usd_per_cere" @@ -1106,7 +1226,10 @@ } } ], - "docs": [], + "docs": [ + " Check whether the given account has the given permission currently,", + " or the SuperAdmin permission." + ], "mutates": false, "name": [ "has_permission" @@ -1141,7 +1264,9 @@ } } ], - "docs": [], + "docs": [ + " As SuperAdmin, grant any permission to any account." + ], "mutates": true, "name": [ "admin_grant_permission" @@ -1171,7 +1296,9 @@ } } ], - "docs": [], + "docs": [ + " As SuperAdmin, revoke any permission to any account." + ], "mutates": true, "name": [ "admin_revoke_permission" @@ -1192,7 +1319,11 @@ } } ], - "docs": [], + "docs": [ + " As SuperAdmin, withdraw the funds held in custody in this contract.", + "", + " This is a temporary measure to allow migrating the funds to a new version of the contract." + ], "mutates": true, "name": [ "admin_withdraw" @@ -1200,6 +1331,29 @@ "payable": false, "returnType": null, "selector": "0x2f6e0868" + }, + { + "args": [ + { + "name": "config", + "type": { + "displayName": [ + "FeeConfig" + ], + "type": 43 + } + } + ], + "docs": [ + " As SuperAdmin, set the network and cluster fee configuration." + ], + "mutates": true, + "name": [ + "admin_set_fee_config" + ], + "payable": false, + "returnType": null, + "selector": "0x00d441e7" } ] }, @@ -1659,6 +1813,51 @@ } }, "name": "perms" + }, + { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "cell": { + "key": "0x0500000008000000000000000000000000000000000000000000000000000000", + "ty": 8 + } + }, + "name": "network_fee_bp" + }, + { + "layout": { + "cell": { + "key": "0x0600000008000000000000000000000000000000000000000000000000000000", + "ty": 3 + } + }, + "name": "network_fee_destination" + }, + { + "layout": { + "cell": { + "key": "0x0700000008000000000000000000000000000000000000000000000000000000", + "ty": 8 + } + }, + "name": "cluster_management_fee_bp" + } + ] + } + }, + "name": null + } + ] + } + }, + "name": "network_fee" } ] } @@ -2575,6 +2774,35 @@ "entity", "Permission" ] + }, + { + "def": { + "composite": { + "fields": [ + { + "name": "network_fee_bp", + "type": 8, + "typeName": "BasisPoints" + }, + { + "name": "network_fee_destination", + "type": 3, + "typeName": "AccountId" + }, + { + "name": "cluster_management_fee_bp", + "type": 8, + "typeName": "BasisPoints" + } + ] + } + }, + "path": [ + "ddc_bucket", + "ddc_bucket", + "network_fee", + "FeeConfig" + ] } ] -} +} \ No newline at end of file diff --git a/sdk/src/abi/ddc_nft_registry.json b/sdk/src/abi/ddc_nft_registry.json index 9ecd775f..574a6e35 100644 --- a/sdk/src/abi/ddc_nft_registry.json +++ b/sdk/src/abi/ddc_nft_registry.json @@ -1,13 +1,13 @@ { "metadataVersion": "0.1.0", "source": { - "hash": "0x85213c9200bdf87bc86d0f333fbe504daa7c31810c6625c15e9007b12eee7caa", + "hash": "0x9700fb034126e4e649c8ecbc74eea11a49905b9518b0e7aa6bce735c1bb816bc", "language": "ink! 3.0.0-rc4", "compiler": "rustc 1.59.0-nightly" }, "contract": { "name": "ddc_nft_registry", - "version": "0.1.0", + "version": "0.5.2", "authors": [ "Aurélien Nicolas ", "Anton Volk " diff --git a/sdk/src/deployments.js b/sdk/src/deployments.js index f86f3595..55c1de15 100644 --- a/sdk/src/deployments.js +++ b/sdk/src/deployments.js @@ -5,9 +5,13 @@ const {registerContract} = require("./contractRegistry.js"); const ddc_bucket_abi = require("./abi/ddc_bucket.json"); function init() { - registerABI("ddc_bucket", ddc_bucket_abi, "0x5e690c8fd199cbf15e7f27bf1b510235aaf5d2bfebc776f72b77f04e03c1ad3b"); + registerABI("ddc_bucket", ddc_bucket_abi, "0xabfb40d2f3cd9742bdd462002e4b8629c375e941ba5d6a059e20b33e23871cec"); - registerContract("ddc_bucket", "Cere Testnet", "5DTZfAcmZctJodfa4W88BW5QXVBxT4v7UEax91HZCArTih6U"); + // DDC DEVNET ADMIN: 5Fq4A47kApWUKP9CXZqbKvHMotQD5f4qeivLBM9CjZ1Da3GA + registerContract("ddc_bucket", "Cere Devnet", "5EShbAjEMgwxrxM4MkE9tZYKd9du9LrW6F7wwin43UqgHZEV"); + + // DDC TESTNET ADMIN: 5G27k5NH5p7qMDGuxkctUXAPw2HEf3Ef23TSByUAMomWb6U6 + registerContract("ddc_bucket", "Cere Testnet", "5D3yQXckkLAy7H7m37hVQdyYjXWtKs637pFFECD5hvB8YPaF"); }