Skip to content

Commit

Permalink
chore: simplify blockchains integration (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejVukosav authored Dec 20, 2024
1 parent fe7933a commit ef0151a
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 168 deletions.
60 changes: 3 additions & 57 deletions docs/02-getting-started/02-build-from-source.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: build-from-source
title: Build From Source
---

import InitNode from '../shared/node-init-source.mdx';

## Setup For Contributors

If you want to contribute to the Calimero framework or customize its
Expand Down Expand Up @@ -86,63 +88,7 @@ minutes but can vary depending on your internet connection.

#### 1. Initialize node

<Tabs
defaultValue="near"
groupId="protocol"
values={[
{label: 'NEAR', value: 'near'},
{label: 'Starknet', value: 'starknet'},
{label: 'ICP', value: 'icp'},
]}>

<TabItem value="near">
```bash title="Terminal"
cargo run -p merod -- --node-name node1 init --server-port 2428 --swarm-port 2528
```
</TabItem>
<TabItem value="starknet">
```bash title="Terminal"
cargo run -p merod -- --node-name node1 init --server-port 2428 --swarm-port 2528 --protocol starknet
```
</TabItem>
<TabItem value="icp">
```bash title="Terminal"
cargo run -p merod -- --node-name node1 init --server-port 2428 --swarm-port 2528 --protocol icp
```
</TabItem>
</Tabs>

:::tip

A `--protocol` flag defines protocol for the node contexts.

:::

Node configuration file contains protocol defined metada. Node file is located
under `data` folder.

<Tabs
defaultValue="near"
groupId="protocol"
values={[
{label: 'NEAR', value: 'near'},
{label: 'Starknet', value: 'starknet'},
{label: 'ICP', value: 'icp'},
]}>

<TabItem value="near">
![NearConfig](/init/near-config.png)

</TabItem>
<TabItem value="starknet">
![SnConfig](/init/sn-config.png)

</TabItem>
<TabItem value="icp">
![ICPConfig](/init/icp-config.png)

</TabItem>
</Tabs>
<InitNode />

#### 2. Run node

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
id: blockchain-integrations
title: Blockchain Integrations
id: blockchains-integration
title: Blockchains Integration
---

import InitNode from '../shared/node-init-binary.mdx';

# Blockchain Integrations

Calimero offers integration with multiple blockchain protocols, allowing users
Expand All @@ -16,7 +18,7 @@ Calimero currently supports the following blockchain protocols:
- Starknet
- Internet Computer (ICP)

<div style={{ display: 'flex', justifyContent: 'center' }}>
<div style={{ display: 'flex', justifyContent: 'center'}}>

```mermaid
graph TD
Expand Down Expand Up @@ -130,7 +132,7 @@ context.
Each context has its own Proxy Contract instance which is deployed during the
context creation.

<div style={{display: 'flex', justifyContent: 'center'}}>
<div style={{display: 'flex', justifyContent: 'center' ,margin: '2rem'}}>

```mermaid
graph TD
Expand All @@ -143,6 +145,9 @@ D -->|No| F[Store Vote Count]

</div>

Tutorial on how to use proxy contract functionalities is available in
[tutorials section](../../tutorials/proxy-contract-interaction)

### Deployment of Contracts

#### Context Contract
Expand All @@ -153,7 +158,7 @@ Context Contract is predeployed on each blockchain by the Calimero team.

Proxy Contract is deployed during the context creation.

<div style={{display: 'flex', justifyContent: 'center'}}>
<div style={{display: 'flex', justifyContent: 'center', margin: '2rem'}}>

```mermaid
graph TD
Expand All @@ -164,12 +169,24 @@ C -->|Unique Instance| D[Context-specific Proxy]

</div>

:::info

Proxy Contract is deployed on the same blockchain as the Context Contract.

:::

:::warning

Users are responsible for funding the Proxy Contract.

:::

### Example Application

We have an example application that connects to Calimero Proxy Contract and
allows creating proposals, voting on them, and executing the approved proposals.

<div style={{display: 'flex', justifyContent: 'center'}}>
<div style={{display: 'flex', justifyContent: 'center', margin: '2rem' }}>
```mermaid
graph TD
A[Application] -->|Connects to| B[Calimero Proxy Contract]
Expand All @@ -184,5 +201,12 @@ F -->|No| I[Store Vote Count]
```
</div>

Application code can be found
[here](https://github.com/calimero-network/demo-blockchain-integrations).
Application showcases all the actions that can be done on the Proxy Contract.

To create context on specific blockchain user will need to add the --protocol
when initializing the node

<InitNode />

Full source code is available in our GitHub
[repository](https://github.com/calimero-network/demo-blockchain-integrations).

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 2 additions & 1 deletion docs/05-developer-tools/01-CLI/01-merod.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ title: Merod

import MerodInstallation from '../../shared/install-merod.mdx';

Merod is a command-line tool that allows you to initialize, configure and run Calimero nodes.
Merod is a command-line tool that allows you to initialize, configure and run
Calimero nodes.

<details>
<summary>Installation</summary>
Expand Down
17 changes: 9 additions & 8 deletions docs/05-developer-tools/01-CLI/02-meroctl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ title: Meroctl

import MeroctlInstallation from '../../shared/install-meroctl.mdx';

Meroctl is a command-line tool that enables you to interact with your Calimero node directly from the shell.
Meroctl is a command-line tool that enables you to interact with your Calimero
node directly from the shell.

<details>
<summary>Installation</summary>
Expand Down Expand Up @@ -64,13 +65,13 @@ your nodes private key.

### Examples:

| **Command** | **Description** |
| ------------------------------------------------------------------------------------- | --------------------------------------- |
| `meroctl --node-name <NAME> app <COMMAND>` | Command for managing applications |
| `meroctl --node-name <NAME> context <COMMAND>` | Command for managing contexts |
| `meroctl --node-name <NAME> identity <COMMAND>` | Command for managing identities |
| `meroctl --node-name <NAME> proxy <COMMAND>` | Command for managing proxy contract |
| `meroctl --node-name <NAME> call [OPTIONS] --as <EXECUTOR> <CONTEXT_ID> <METHOD>` | Executing read and write RPC calls |
| **Command** | **Description** |
| --------------------------------------------------------------------------------- | ----------------------------------- |
| `meroctl --node-name <NAME> app <COMMAND>` | Command for managing applications |
| `meroctl --node-name <NAME> context <COMMAND>` | Command for managing contexts |
| `meroctl --node-name <NAME> identity <COMMAND>` | Command for managing identities |
| `meroctl --node-name <NAME> proxy <COMMAND>` | Command for managing proxy contract |
| `meroctl --node-name <NAME> call [OPTIONS] --as <EXECUTOR> <CONTEXT_ID> <METHOD>` | Executing read and write RPC calls |

### Manage Applications

Expand Down
2 changes: 1 addition & 1 deletion docs/06-tutorials/00-overview.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: overview
title: Tutorials
title: Overview
---

Welcome to the Tutorials section of the Calimero Network documentation! Here,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Proxy Contract Interaction Guide
---
id: proxy-contract-interaction
title: Blockchain interaction with Proxy Contract
---

## Overview

Expand All @@ -8,6 +11,13 @@ proposal-based system. The integration consists of:
1. Backend Application (Rust)
2. Frontend Application (TypeScript/React)

:::tip

More info on blockchain integrations can be found in the
[Blockchains Integration](../core-concepts/blockchains-integration) section.

:::

## Backend Implementation

The backend contract handles proposal creation and management. Here's the core
Expand Down
63 changes: 63 additions & 0 deletions docs/shared/node-init-binary.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs
defaultValue="near"
groupId="protocol"
values={[
{label: 'NEAR', value: 'near'},
{label: 'Starknet', value: 'starknet'},
{label: 'ICP', value: 'icp'},
]}>

<TabItem value="near">
```bash title="Terminal"
merod --node-name node1 init --server-port 2428 --swarm-port 2528
```
</TabItem>
<TabItem value="starknet">
```bash title="Terminal"
merod --node-name node1 init --server-port 2428 --swarm-port 2528 --protocol starknet
```
</TabItem>
<TabItem value="icp">
```bash title="Terminal"
merod --node-name node1 init --server-port 2428 --swarm-port 2528 --protocol icp
```
</TabItem>

</Tabs>

:::tip

A `--protocol` flag defines which chain will be used in the node context. NEAR
is default protocol so it doesn't need to be specified. List of supported
protocols can be found in the
[Blockchains integration](../core-concepts/blockchains-integration)

:::

Node configuration file contains protocol defined metada.

<Tabs
defaultValue="near"
groupId="protocol"
values={[
{label: 'NEAR', value: 'near'},
{label: 'Starknet', value: 'starknet'},
{label: 'ICP', value: 'icp'},
]}>

<TabItem value="near">
![NearConfig](/init/near-config.png)

</TabItem>
<TabItem value="starknet">
![SnConfig](/init/sn-config.png)

</TabItem>
<TabItem value="icp">
![ICPConfig](/init/icp-config.png)

</TabItem>
</Tabs>
Loading

0 comments on commit ef0151a

Please sign in to comment.