Skip to content

Commit

Permalink
Command line option to specify the check in memo
Browse files Browse the repository at this point in the history
  • Loading branch information
yanliu38 committed Dec 7, 2024
1 parent edf12f5 commit dad3759
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cli/src/argparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ pub fn parse_args() -> clap::ArgMatches {
.action(ArgAction::Set)
.num_args(1),
)
.arg(
Arg::new("check-in-memo")
.long("check-in-memo")
.help("Provide the given memo value for the check-in")
.action(ArgAction::Set)
)
.arg(
Arg::new("check-in-nonce")
.long("check-in-nonce")
Expand Down
9 changes: 7 additions & 2 deletions cli/src/ledger_canister_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ impl LedgerCanister {
Decode!(response.as_slice(), ResultString).map_err(|e| e.to_string())?
}

pub async fn node_provider_check_in(&self, key: &[u8], value: &[u8]) -> Result<String, String> {
let args = Encode!(&key, &value).map_err(|e| e.to_string())?;
pub async fn node_provider_check_in(
&self,
key: &[u8],
memo: &String,
nonce_crypto_sig: &[u8],
) -> Result<String, String> {
let args = Encode!(&key, &memo, &nonce_crypto_sig).map_err(|e| e.to_string())?;
let response = self.call_update("node_provider_check_in", &args).await?;
Decode!(response.as_slice(), ResultString).map_err(|e| e.to_string())?
}
Expand Down
14 changes: 13 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,23 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
nonce_string,
nonce_bytes.len()
);
let check_in_memo = match arg_matches
.get_one::<String>("check-in-memo")
.cloned()
{
Some(memo) => memo,
None => {
println!("No memo specified, did you know that you can specify one? Try out --check-in-memo");
String::new()
}
};
let nonce_crypto_signature = dcc_ident.sign(nonce_bytes.as_ref())?;
let result = ledger_canister(ic_auth)
.await?
.node_provider_check_in(
&dcc_ident.to_bytes_verifying(),
&dcc_ident.sign(&nonce_bytes)?.to_bytes(),
&check_in_memo,
&nonce_crypto_signature.to_bytes(),
)
.await
.map_err(|e| format!("Check-in failed: {}", e))?;
Expand Down

0 comments on commit dad3759

Please sign in to comment.