Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat change protocol flag calling position #1039

Merged
merged 19 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: added protocol to context ls command, added options for --proto…
…col flag in --help
alenmestrov committed Jan 16, 2025

Verified

This commit was signed with the committer’s verified signature.
commit f6e32c38b4579b50c019dd4a173d18a9d7040779
25 changes: 17 additions & 8 deletions crates/node/src/interactive_cli/context.rs
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ use calimero_primitives::context::{ContextId, ContextInvitationPayload};
use calimero_primitives::hash::Hash;
use calimero_primitives::identity::{PrivateKey, PublicKey};
use calimero_store::key::ContextMeta as ContextMetaKey;
use calimero_store::key::ContextConfig as ContextConfigKey;
use clap::{Parser, Subcommand};
use eyre::Result;
use owo_colors::OwoColorize;
@@ -31,7 +32,7 @@ enum Commands {
/// The seed for the context (to derive a deterministic context ID)
#[clap(long = "seed")]
context_seed: Option<Hash>,
/// The protocol to use for the context
/// The protocol to use for the context - possible values: near|starknet|icp
#[clap(long)]
protocol: String,
},
@@ -79,22 +80,30 @@ impl ContextCommand {
match self.command {
Commands::Ls => {
println!(
"{ind} {c1:44} | {c2:44} | Root Hash",
"{ind} {c1:44} | {c2:44} | {c3:44} | Protocol",
c1 = "Context ID",
c2 = "Application ID",
c3 = "Root Hash"
);

let handle = node.store.handle();

for (k, v) in handle.iter::<ContextMetaKey>()?.entries() {
let (k, v) = (k?, v?);
let (cx, app_id, last_tx) =
(k.context_id(), v.application.application_id(), v.root_hash);
let context_id = k.context_id();

// Get the config for this context
let protocol = handle
.get(&ContextConfigKey::new(context_id))?
.expect("Context config must exist with protocol")
.protocol;

let entry = format!(
"{c1:44} | {c2:44} | {c3}",
c1 = cx,
c2 = app_id,
c3 = Hash::from(last_tx)
"{c1:44} | {c2:44} | {c3:20} | {c4}",
miraclx marked this conversation as resolved.
Show resolved Hide resolved
c1 = context_id,
c2 = v.application.application_id(),
c3 = Hash::from(v.root_hash),
c4 = protocol
);
for line in entry.lines() {
println!("{ind} {}", line.cyan());
2 changes: 1 addition & 1 deletion node-ui/src/hooks/useIcp.tsx
Original file line number Diff line number Diff line change
@@ -322,7 +322,7 @@ export function useIcp(): useIcpReturn {
});

// Wait for II to say it's ready
const readyPromise = new Promise<MessageEvent>((resolve, reject) => {
const readyPromise = new Promise<MessageEvent>((resolve) => {
const readyHandler = (e: MessageEvent) => {
// Only process messages from II
if (e.origin !== iiUrl.origin) {