Skip to content

Commit

Permalink
feat(blockchain): Add support for new Cluster Governance blockchain A…
Browse files Browse the repository at this point in the history
…PI (#251)
  • Loading branch information
skambalin authored Jun 7, 2024
1 parent aa653c3 commit 9c15746
Show file tree
Hide file tree
Showing 13 changed files with 709 additions and 108 deletions.
21 changes: 21 additions & 0 deletions packages/blockchain/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

## Pallets

- [DDCClustersGovPallet](classes/DDCClustersGovPallet.md)
- [DDCClustersPallet](classes/DDCClustersPallet.md)
- [DDCCustomersPallet](classes/DDCCustomersPallet.md)
- [DDCNodesPallet](classes/DDCNodesPallet.md)
Expand All @@ -21,3 +22,23 @@
- [Signer](classes/Signer.md)
- [UriSigner](classes/UriSigner.md)
- [Web3Signer](classes/Web3Signer.md)

## Type Aliases

### ClusterGovernmentParams

Ƭ **ClusterGovernmentParams**: `ClusterProtocolParams`

**`Deprecated`**

Use ClusterProtocolParams instead.

___

### ClusterProps

Ƭ **ClusterProps**: `ClusterParams`

**`Deprecated`**

Use ClusterParams instead.
8 changes: 8 additions & 0 deletions packages/blockchain/docs/classes/Blockchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ The DDC Clusters pallet.

___

### ddcClustersGov

`Readonly` **ddcClustersGov**: [`DDCClustersGovPallet`](DDCClustersGovPallet.md)

The DDC Cluster government pallet.

___

### ddcCustomers

`Readonly` **ddcCustomers**: [`DDCCustomersPallet`](DDCCustomersPallet.md)
Expand Down
204 changes: 204 additions & 0 deletions packages/blockchain/docs/classes/DDCClustersGovPallet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
[@cere-ddc-sdk/blockchain](../README.md) / DDCClustersGovPallet

# Class: DDCClustersGovPallet

This class provides methods to interact with the DDC Cluster Goverment pallet on the blockchain.

**`Example`**

```typescript
const clusterId = '0x...';
const protocolParams = { ... };
const member = ClusterMember.ClusterManager;

const tx = blockchain.ddcClusterGov.proposeUpdateClusterProtocol(clusterId, protocolParams, member);

await blockchain.send(tx, { account });
```

## Methods

### closeProposal

**closeProposal**(`clusterId`, `member`, `nodePublicKey?`): `Sendable`

This method allows to retract a local proposal within a cluster. Only the proposal's author can submit it.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `clusterId` | \`0x$\{string}\` | The ID of the cluster. |
| `member` | `ClusterMember` | The member who is retracting the proposal. |
| `nodePublicKey?` | `string` | The public key of the node provider. Needed in case the member is ClusterMember.NodeProvider. |

#### Returns

`Sendable`

An extrinsic to retract the proposal.

**`Example`**

```typescript
const clusterId = '0x...';
const member = ClusterMember.ClusterManager;

const tx = blockchain.ddcClusterGov.retractProposal(clusterId, member);

await blockchain.send(tx, { account });
```

___

### proposeActivateClusterProtocol

**proposeActivateClusterProtocol**(`clusterId`, `protocolParams`): `Sendable`

Creates a local proposal within a cluster, intended to activate the cluster in the network with specific protocol parameters such as validators, treasury fees, and pricing for stored and streamed bytes.
Only cluster members, namely the cluster manager and node providers, have voting rights on this proposal.
Furthermore, only the cluster manager has the authority to create this type of proposal.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `clusterId` | \`0x$\{string}\` | The ID of the cluster. |
| `protocolParams` | `ClusterProtocolParams` | - |

#### Returns

`Sendable`

___

### proposeUpdateClusterProtocol

**proposeUpdateClusterProtocol**(`clusterId`, `protocolParams`, `member`, `nodePublicKey?`): `Sendable`

Creates a local proposal within a cluster, intended to update protocol parameters (like validators, treasury fee, pricing for stored and streamed bytes, etc.) of a previously activated cluster in the network.
Only cluster members, such as the cluster manager and node providers, can vote on this type of proposal.
Any cluster member has the ability to create this type of proposal.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `clusterId` | \`0x$\{string}\` | The ID of the cluster. |
| `protocolParams` | `ClusterProtocolParams` | The new protocol parameters. |
| `member` | `ClusterMember` | The member who is creating the proposal. |
| `nodePublicKey?` | `string` | The public key of the node provider. Needed in case the member is ClusterMember.NodeProvider. |

#### Returns

`Sendable`

An extrinsic to propose the update of the cluster protocol.

**`Example`**

```typescript
const clusterId = '0x...';
const protocolParams = { ... };
const member = ClusterMember.ClusterManager;

const tx = blockchain.ddcClusterGov.proposeUpdateClusterProtocol(clusterId, protocolParams, member);

await blockchain.send(tx, { account });
```

___

### refundSubmissionDeposit

**refundSubmissionDeposit**(`referendaIndex`): `Sendable`

Refunds the submission deposit made by the proposal's author when creating a local proposal.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `referendaIndex` | `number` | The index of the referendum. |

#### Returns

`Sendable`

An extrinsic to refund the submission deposit.

**`Example`**

```typescript
const referendaIndex = 0;
const tx = blockchain.ddcClusterGov.refundSubmissionDeposit(referendaIndex);

await blockchain.send(tx, { account });
```

___

### retractProposal

**retractProposal**(`clusterId`): `Sendable`

Closes a local proposal within a cluster. If the required approval threshold is met, it will automatically initiate a public referendum in the OpenGov.
Here, any CERE token holder can vote on the cluster's proposal, thereby influencing the network's economics.
If the required approval threshold is not met, the local (internal) proposal will be withdrawn without initiating a public referendum.
Any cluster member can close the proposal once the approval threshold or expiration time is reached.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `clusterId` | \`0x$\{string}\` | The ID of the cluster. |

#### Returns

`Sendable`

An extrinsic to retract the proposal.

**`Example`**

```typescript
const clusterId = '0x...';
const tx = blockchain.ddcClusterGov.retractProposal(clusterId);

await blockchain.send(tx, { account });
```

___

### voteProposal

**voteProposal**(`clusterId`, `approve`, `member`, `nodePublicKey?`): `Sendable`

Votes for a local proposal within a cluster. Only cluster members, such as the cluster manager and node providers, are permitted to vote.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `clusterId` | \`0x$\{string}\` | The ID of the cluster. |
| `approve` | `boolean` | Whether to approve the proposal. |
| `member` | `ClusterMember` | The member who is voting. |
| `nodePublicKey?` | `string` | The public key of the node provider. Needed in case the member is ClusterMember.NodeProvider. |

#### Returns

`Sendable`

An extrinsic to vote on the proposal.

**`Example`**

```typescript
const clusterId = '0x...';
const approve = true;
const member = ClusterMember.ClusterManager;

const tx = blockchain.ddcClusterGov.voteProposal(clusterId, approve, member);

await blockchain.send(tx, { account });
```
30 changes: 14 additions & 16 deletions packages/blockchain/docs/classes/DDCClustersPallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ console.log(clusters);

### addStorageNodeToCluster

**addStorageNodeToCluster**(`clusterId`, `storageNodePublicKey`): `Sendable`
**addStorageNodeToCluster**(`clusterId`, `storageNodePublicKey`, `nodeKind`): `Sendable`

Adds a storage node to a cluster.

Expand All @@ -26,6 +26,7 @@ Adds a storage node to a cluster.
| :------ | :------ | :------ |
| `clusterId` | \`0x$\{string}\` | The ID of the cluster. |
| `storageNodePublicKey` | `string` | The public key of the storage node. |
| `nodeKind` | `ClusterNodeKind` | - |

#### Returns

Expand All @@ -39,7 +40,7 @@ An extrinsic to add the storage node to the cluster.
const clusterId = '0x...';
const storageNodePublicKey = '0x...';

const tx = blockchain.ddcClustersPallet.addStorageNodeToCluster(clusterId, storageNodePublicKey);
const tx = blockchain.ddcClustersPallet.addStorageNodeToCluster(clusterId, storageNodePublicKey, ClusterNodeKind.Genesis);

await blockchain.send(tx, { account });
```
Expand Down Expand Up @@ -79,7 +80,7 @@ ___

### createCluster

**createCluster**(`clusterId`, `clusterManagerId`, `clusterReserveId`, `clusterProps`, `clusterGovernmentParams`): `Sendable`
**createCluster**(`clusterId`, `clusterReserveId`, `clusterParams`, `clusterGovernmentParams`): `Sendable`

Creates a new cluster.

Expand All @@ -88,10 +89,9 @@ Creates a new cluster.
| Name | Type | Description |
| :------ | :------ | :------ |
| `clusterId` | \`0x$\{string}\` | The ID of the cluster. |
| `clusterManagerId` | `string` | The ID of the cluster manager. |
| `clusterReserveId` | `string` | The ID of the cluster reserve. |
| `clusterProps` | `Partial`\<`ClusterProps`\> | The properties of the cluster. |
| `clusterGovernmentParams` | `ClusterGovernmentParams` | The government parameters of the cluster. |
| `clusterParams` | `Partial`\<`ClusterParams`\> | The properties of the cluster. |
| `clusterGovernmentParams` | `ClusterProtocolParams` | The government parameters of the cluster. |

#### Returns

Expand All @@ -103,16 +103,14 @@ An extrinsic to create the cluster.

```typescript
const clusterId = '0x...';
const clusterManagerId = '0x...';
const clusterReserveId = '0x...';
const clusterProps = { ... };
const clusterParams = { ... };
const clusterGovernmentParams = { ... };

const tx = blockchain.ddcClustersPallet.createCluster(
clusterId,
clusterManagerId,
clusterReserveId,
clusterProps,
clusterParams,
clusterGovernmentParams
);

Expand Down Expand Up @@ -181,7 +179,7 @@ ___

### getClusterGovernmentParams

**getClusterGovernmentParams**(`clusterId`): `Promise`\<`undefined` \| `ClusterGovernmentParams`\>
**getClusterGovernmentParams**(`clusterId`): `Promise`\<`undefined` \| `ClusterProtocolParams`\>

Gets the government parameters of a cluster.

Expand All @@ -193,7 +191,7 @@ Gets the government parameters of a cluster.

#### Returns

`Promise`\<`undefined` \| `ClusterGovernmentParams`\>
`Promise`\<`undefined` \| `ClusterProtocolParams`\>

A promise that resolves to the government parameters of the cluster.

Expand Down Expand Up @@ -264,7 +262,7 @@ ___

### setClusterParams

**setClusterParams**(`clusterId`, `clusterProps`): `Sendable`
**setClusterParams**(`clusterId`, `clusterParams`): `Sendable`

Sets the properties of a cluster.

Expand All @@ -273,7 +271,7 @@ Sets the properties of a cluster.
| Name | Type | Description |
| :------ | :------ | :------ |
| `clusterId` | \`0x$\{string}\` | The ID of the cluster. |
| `clusterProps` | `Partial`\<`ClusterProps`\> | The properties of the cluster. |
| `clusterParams` | `Partial`\<`ClusterParams`\> | The properties of the cluster. |

#### Returns

Expand All @@ -285,9 +283,9 @@ An extrinsic to set the cluster properties.

```typescript
const clusterId = '0x...';
const clusterProps = { ... };
const clusterParams = { ... };

const tx = blockchain.ddcClustersPallet.setClusterParams(clusterId, clusterProps);
const tx = blockchain.ddcClustersPallet.setClusterParams(clusterId, clusterParams);

await blockchain.send(tx, { account });
```
Loading

0 comments on commit 9c15746

Please sign in to comment.