Skip to content

Commit dad3759

Browse files
committed
Command line option to specify the check in memo
1 parent edf12f5 commit dad3759

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

cli/src/argparse.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ pub fn parse_args() -> clap::ArgMatches {
115115
.action(ArgAction::Set)
116116
.num_args(1),
117117
)
118+
.arg(
119+
Arg::new("check-in-memo")
120+
.long("check-in-memo")
121+
.help("Provide the given memo value for the check-in")
122+
.action(ArgAction::Set)
123+
)
118124
.arg(
119125
Arg::new("check-in-nonce")
120126
.long("check-in-nonce")

cli/src/ledger_canister_client.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,13 @@ impl LedgerCanister {
9696
Decode!(response.as_slice(), ResultString).map_err(|e| e.to_string())?
9797
}
9898

99-
pub async fn node_provider_check_in(&self, key: &[u8], value: &[u8]) -> Result<String, String> {
100-
let args = Encode!(&key, &value).map_err(|e| e.to_string())?;
99+
pub async fn node_provider_check_in(
100+
&self,
101+
key: &[u8],
102+
memo: &String,
103+
nonce_crypto_sig: &[u8],
104+
) -> Result<String, String> {
105+
let args = Encode!(&key, &memo, &nonce_crypto_sig).map_err(|e| e.to_string())?;
101106
let response = self.call_update("node_provider_check_in", &args).await?;
102107
Decode!(response.as_slice(), ResultString).map_err(|e| e.to_string())?
103108
}

cli/src/main.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,23 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
228228
nonce_string,
229229
nonce_bytes.len()
230230
);
231+
let check_in_memo = match arg_matches
232+
.get_one::<String>("check-in-memo")
233+
.cloned()
234+
{
235+
Some(memo) => memo,
236+
None => {
237+
println!("No memo specified, did you know that you can specify one? Try out --check-in-memo");
238+
String::new()
239+
}
240+
};
241+
let nonce_crypto_signature = dcc_ident.sign(nonce_bytes.as_ref())?;
231242
let result = ledger_canister(ic_auth)
232243
.await?
233244
.node_provider_check_in(
234245
&dcc_ident.to_bytes_verifying(),
235-
&dcc_ident.sign(&nonce_bytes)?.to_bytes(),
246+
&check_in_memo,
247+
&nonce_crypto_signature.to_bytes(),
236248
)
237249
.await
238250
.map_err(|e| format!("Check-in failed: {}", e))?;

0 commit comments

Comments
 (0)