From d2afee393d98d2119ff22a141aa82ab8e419cb85 Mon Sep 17 00:00:00 2001 From: Matej Vukosav Date: Sat, 21 Dec 2024 00:55:33 +1100 Subject: [PATCH] chore: simplify context creation (#80) --- .../02-build-from-source.mdx | 11 +- docs/06-tutorials/02-create-context.mdx | 104 ++++++------------ .../shared/context-create-admin-dashboard.mdx | 13 +++ docs/shared/context-create-binary.mdx | 10 ++ .../shared/context-create-interactive-cli.mdx | 30 +++++ docs/shared/node-run-binary.mdx | 9 ++ docs/shared/node-run-source.mdx | 9 ++ 7 files changed, 104 insertions(+), 82 deletions(-) create mode 100644 docs/shared/context-create-admin-dashboard.mdx create mode 100644 docs/shared/context-create-binary.mdx create mode 100644 docs/shared/context-create-interactive-cli.mdx create mode 100644 docs/shared/node-run-binary.mdx create mode 100644 docs/shared/node-run-source.mdx diff --git a/docs/02-getting-started/02-build-from-source.mdx b/docs/02-getting-started/02-build-from-source.mdx index 53a5447b..fe90b6db 100644 --- a/docs/02-getting-started/02-build-from-source.mdx +++ b/docs/02-getting-started/02-build-from-source.mdx @@ -4,6 +4,7 @@ title: Build From Source --- import InitNode from '../shared/node-init-source.mdx'; +import RunNode from '../shared/node-run-source.mdx'; ## Setup For Contributors @@ -92,15 +93,7 @@ minutes but can vary depending on your internet connection. #### 2. Run node -```bash title="Terminal" -cargo run -p merod -- --node-name node1 run -``` - -Wait for a few moments and node logs should appear. - -![Node running](/setup/node-running.png) - -When you see something like this that means that node is now ready for use. + diff --git a/docs/06-tutorials/02-create-context.mdx b/docs/06-tutorials/02-create-context.mdx index 2633913c..ac377aed 100644 --- a/docs/06-tutorials/02-create-context.mdx +++ b/docs/06-tutorials/02-create-context.mdx @@ -3,87 +3,45 @@ id: create-context title: Create Context --- -## Create a context using the Admin Dashboard +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; -1. Navigate to the "Contexts" tab and click the "Start New Context" button. -2. Use the "Browse" button to select an application from the list. -3. Choose the "Template Application" option. -4. Press "Start" to initiate the context creation process with the selected - application. +import ContextCreateBinary from '../shared/context-create-binary.mdx'; +import ContextCreateInteractiveCli from '../shared/context-create-interactive-cli.mdx'; +import ContextCreateAdminDashboard from '../shared/context-create-admin-dashboard.mdx'; +import InitNode from '../shared/node-init-binary.mdx'; +import RunNode from '../shared/node-run-binary.mdx'; -Visit [Admin Dashboard Page](../../developer-tools/apps/admin-dashboard) to view -detailed instructions with images. +### Initialize node -After the context is created, you will be redirected to the context dashboard. -Keep this page open as you will need the Context ID later. + -## Create context using interactive CLI +### Run node -After you have start the node following -[instructions](../../getting-started/setup), interactive CLI will be available -within the same terminal. + -![Interactive CLI](/cli/0-interactive-cli.png) +### Create a New Context -> **NOTE**: You can see available commands in terminal: call, peers, pool, gc, -> context, application. In this example we will be using commands for `context` -> and `application`. + -### Step 1: Install the Application + + + -Run the following command to install the application: + + + -```bash -application install url {url} {metadata} -``` + + + + -> **NOTE**: metadata example: - -```bash -'{"contractAppId": ""}' -``` - -You can find the application `URL` and `contractAppId` by opening Application -Details from Applications section of the Admin Dashboard. - -You can also install an app that you have available locally with `file`: - -```bash -application install file {path/to/file} -``` - -![Application details](/admin-dashboard/application-details-for-context-creation.png) - -`contractApplicationId` is the id of application stored in the contract. Value -is optional but if provided, it enables Admin Dashboard to extract and display -the application metadata. - -```bash title="Example" -application install url https://blobby-public.euw3.prod.gcp.calimero.network/bafkreihl5o6etrnpy7dlgixz3onbfb3og4dll2yqsqaebqakuldk6e2qya '{"contractAppId": "980265ba072119a9074e429dea477e1c084a94e8d9f645c0158680e6942fb99e"}' -| Downloading application.. -│ Installed application: Ahe2vLWLgswJARv5LsafXp7uJyb2Ba9GjzUSeLc71gUF -``` - -![Application install](/cli/1-install-app.png) - -### Step 2: Create a New Context - -Conext can be created from the -[Admin Dashboard Page](../../developer-tools/apps/admin-dashboard) or with -interactive CLI. - -After the application is successfully installed, you can create a new context -with the installed application using this command: - -```bash -context create {applicationId} -``` - -```bash title="Example" -context create Ahe2vLWLgswJARv5LsafXp7uJyb2Ba9GjzUSeLc71gUF -2024-10-07T11:55:36.658396Z INFO calimero_context: Subscribed to context context_id=567C5Gg4mxHMPKy2wLJ4uvb3DHsbcpVDYUsuAWgTPgXn -Created context 567C5Gg4mxHMPKy2wLJ4uvb3DHsbcpVDYUsuAWgTPgXn with -identity DaSkad6DK7f6fUhjz1CvNW7L4TkWZmWqAcwysZHG3Xs5 -``` - -![Create context](/cli/2-create-context.png) +You have now create a new context. Next step is to invite users to join your +context. Continue with [invitations and joinings](./invitations-and-joinings). diff --git a/docs/shared/context-create-admin-dashboard.mdx b/docs/shared/context-create-admin-dashboard.mdx new file mode 100644 index 00000000..76f4137b --- /dev/null +++ b/docs/shared/context-create-admin-dashboard.mdx @@ -0,0 +1,13 @@ +## Create a context using the Admin Dashboard + +1. Navigate to the "Contexts" tab and click the "Start New Context" button. +2. Use the "Browse" button to select an application from the list. +3. Choose application. +4. Press "Start" to initiate the context creation process with the selected + application. + +Visit [Admin Dashboard Page](../../developer-tools/apps/admin-dashboard) to view +detailed instructions with images. + +After the context is created, you will be redirected to the context dashboard. +Keep this page open as you will need the Context ID later. diff --git a/docs/shared/context-create-binary.mdx b/docs/shared/context-create-binary.mdx new file mode 100644 index 00000000..addb5795 --- /dev/null +++ b/docs/shared/context-create-binary.mdx @@ -0,0 +1,10 @@ +```bash title="Terminal" +meroctl --node-name node1 context create --watch +``` + +:::tip + +`--watch` flag enables watching for changes of wasm files and updating context +with the new version. + +::: diff --git a/docs/shared/context-create-interactive-cli.mdx b/docs/shared/context-create-interactive-cli.mdx new file mode 100644 index 00000000..6049a7dc --- /dev/null +++ b/docs/shared/context-create-interactive-cli.mdx @@ -0,0 +1,30 @@ +### Install the Application + +Run the following command to install the application: + +```bash title="Node Terminal" +application install url {url} {metadata} +``` + +:::note metadata example: + +```bash +'{"contractAppId": ""}' +``` + +::: + +### Create a New Context + +```bash title="Node Terminal" +context create {applicationId} +``` + +```bash title="Output" +context create Ahe2vLWLgswJARv5LsafXp7uJyb2Ba9GjzUSeLc71gUF +2024-10-07T11:55:36.658396Z INFO calimero_context: Subscribed to context context_id=567C5Gg4mxHMPKy2wLJ4uvb3DHsbcpVDYUsuAWgTPgXn +Created context 567C5Gg4mxHMPKy2wLJ4uvb3DHsbcpVDYUsuAWgTPgXn with +identity DaSkad6DK7f6fUhjz1CvNW7L4TkWZmWqAcwysZHG3Xs5 +``` + +![Create context](/cli/2-create-context.png) diff --git a/docs/shared/node-run-binary.mdx b/docs/shared/node-run-binary.mdx new file mode 100644 index 00000000..46fddbe4 --- /dev/null +++ b/docs/shared/node-run-binary.mdx @@ -0,0 +1,9 @@ +```bash title="Terminal" +merod --node-name node1 run +``` + +Wait for a few moments and node logs should appear. + +![Node running](/setup/node-running.png) + +When you see something like this that means that node is now ready for use. diff --git a/docs/shared/node-run-source.mdx b/docs/shared/node-run-source.mdx new file mode 100644 index 00000000..7e59db86 --- /dev/null +++ b/docs/shared/node-run-source.mdx @@ -0,0 +1,9 @@ +```bash title="Terminal" +cargo run -p merod -- --node-name node1 run +``` + +Wait for a few moments and node logs should appear. + +![Node running](/setup/node-running.png) + +When you see something like this that means that node is now ready for use.