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

refactor: use const Principal for default faucet principal #3482

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
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
1 change: 0 additions & 1 deletion src/dfx/src/commands/canister/delete.rs
Original file line number Diff line number Diff line change
@@ -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

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
@@ -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)]
@@ -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() {
@@ -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
@@ -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]);