Skip to content

Commit

Permalink
refactor: use const Principal for default faucet principal
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswanson-dfinity committed Dec 19, 2023
1 parent 1b12092 commit 74695c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/dfx/src/commands/canister/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use num_traits::cast::ToPrimitive;
use slog::info;
use std::convert::TryFrom;

#[allow(deprecated)]
const DANK_PRINCIPAL: Principal =
Principal::from_slice(&[0, 0, 0, 0, 0, 0xe0, 1, 0x11, 0x01, 0x01]); // Principal: aanaa-xaaaa-aaaah-aaeiq-cai

Expand Down
18 changes: 16 additions & 2 deletions src/dfx/src/commands/wallet/redeem_faucet_coupon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use candid::{encode_args, Decode, Principal};
use clap::Parser;
use slog::{info, warn};

const DEFAULT_FAUCET_PRINCIPAL: &str = "fg7gi-vyaaa-aaaal-qadca-cai";
pub const DEFAULT_FAUCET_PRINCIPAL: Principal =
Principal::from_slice(&[0, 0, 0, 0, 1, 112, 0, 196, 1, 1]);

/// Redeem a code at the cycles faucet.
#[derive(Parser)]
Expand All @@ -31,7 +32,7 @@ pub async fn exec(env: &dyn Environment, opts: RedeemFaucetCouponOpts) -> DfxRes
Principal::from_text(&alternative_faucet)
.or_else(|_| canister_id_store.get(&alternative_faucet))?
} else {
Principal::from_text(DEFAULT_FAUCET_PRINCIPAL).unwrap()
DEFAULT_FAUCET_PRINCIPAL
};
let agent = env.get_agent();
if fetch_root_key_if_needed(env).await.is_err() {
Expand Down Expand Up @@ -101,3 +102,16 @@ pub async fn exec(env: &dyn Environment, opts: RedeemFaucetCouponOpts) -> DfxRes
}
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_faucet_canister_id() {
assert_eq!(
DEFAULT_FAUCET_PRINCIPAL,
Principal::from_text("fg7gi-vyaaa-aaaal-qadca-cai").unwrap()
);
}
}
2 changes: 0 additions & 2 deletions src/dfx/src/lib/ledger_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ use serde::{Deserialize, Serialize};
use std::fmt;

/// Id of the ledger canister on the IC.
#[allow(deprecated)]
pub const MAINNET_LEDGER_CANISTER_ID: Principal =
Principal::from_slice(&[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x01]);

#[allow(deprecated)]
pub const MAINNET_CYCLE_MINTER_CANISTER_ID: Principal =
Principal::from_slice(&[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x01]);

Expand Down

0 comments on commit 74695c9

Please sign in to comment.