Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# UNRELEASED

### feat!: enable cycles ledger support unconditionally

### feat: add `dfx schema --for extension-manifest`

The schema command can now output the schema for extension.json files.
Expand Down
15 changes: 0 additions & 15 deletions e2e/tests-dfx/cycles-ledger.bash
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,6 @@ current_time_nanoseconds() {
}

@test "top-up and deposit-cycles" {
# shellcheck disable=SC2030,SC2031
export DFX_CYCLES_LEDGER_SUPPORT_ENABLE=1

start_and_install_nns

dfx_new
Expand Down Expand Up @@ -561,9 +558,6 @@ current_time_nanoseconds() {
}

@test "canister creation" {
# shellcheck disable=SC2030,SC2031
export DFX_CYCLES_LEDGER_SUPPORT_ENABLE=1

start_and_install_nns

dfx_new temporary
Expand Down Expand Up @@ -645,9 +639,6 @@ current_time_nanoseconds() {
}

@test "canister deletion" {
# shellcheck disable=SC2030,SC2031
export DFX_CYCLES_LEDGER_SUPPORT_ENABLE=1

start_and_install_nns

dfx_new temporary
Expand Down Expand Up @@ -721,9 +712,6 @@ current_time_nanoseconds() {
}

@test "create canister on specific subnet" {
# shellcheck disable=SC2030,SC2031
export DFX_CYCLES_LEDGER_SUPPORT_ENABLE=1

start_and_install_nns

dfx_new temporary
Expand Down Expand Up @@ -762,9 +750,6 @@ current_time_nanoseconds() {

@test "automatically choose subnet" {
[[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: subnet range"
# shellcheck disable=SC2030,SC2031
export DFX_CYCLES_LEDGER_SUPPORT_ENABLE=1

dfx_start

REGISTRY="rwlgt-iiaaa-aaaaa-aaaaa-cai"
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests-dfx/wallet.bash
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ teardown() {
assert_command_fail dfx wallet balance
assert_match "No wallet configured"

assert_command dfx wallet redeem-faucet-coupon --faucet "$(dfx canister id faucet)" 'valid-coupon'
assert_command dfx wallet redeem-faucet-coupon --faucet "$(dfx canister id faucet)" 'valid-coupon' --yes
assert_match "Redeemed coupon valid-coupon for a new wallet"
assert_match "New wallet set."

Expand All @@ -240,7 +240,7 @@ teardown() {

unset DFX_DISABLE_AUTO_WALLET

assert_command dfx wallet redeem-faucet-coupon --faucet "$(dfx canister id faucet)" 'another-valid-coupon'
assert_command dfx wallet redeem-faucet-coupon --faucet "$(dfx canister id faucet)" 'another-valid-coupon' --yes
assert_match "Redeemed coupon code another-valid-coupon for 10.000 TC"

assert_command dfx wallet balance
Expand Down
7 changes: 2 additions & 5 deletions src/dfx/src/commands/canister/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use crate::lib::operations::canister;
use crate::lib::operations::canister::{
deposit_cycles, start_canister, stop_canister, update_settings,
};
use crate::lib::operations::cycles_ledger::{
cycles_ledger_enabled, wallet_deposit_to_cycles_ledger,
};
use crate::lib::operations::cycles_ledger::wallet_deposit_to_cycles_ledger;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::util::assets::wallet_wasm;
use crate::util::blob_from_arguments;
Expand Down Expand Up @@ -138,7 +136,7 @@ async fn delete_canister(
// If there is no wallet, then do not attempt to withdraw the cycles.
match wallet_canister_id(network, &identity_name)? {
Some(canister_id) => WithdrawTarget::Canister { canister_id },
None if cycles_ledger_enabled() => {
None => {
let Some(my_principal) = env.get_selected_identity_principal()
else {
bail!("Identity has no principal attached")
Expand All @@ -150,7 +148,6 @@ async fn delete_canister(
},
}
}
_ => WithdrawTarget::NoWithdrawal,
}
}
},
Expand Down
9 changes: 2 additions & 7 deletions src/dfx/src/commands/canister/deposit_cycles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::time::{SystemTime, UNIX_EPOCH};
use crate::lib::error::DfxResult;
use crate::lib::identity::wallet::get_or_create_wallet_canister;
use crate::lib::operations::canister;
use crate::lib::operations::cycles_ledger::cycles_ledger_enabled;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::lib::{environment::Environment, operations::cycles_ledger};
use crate::util::clap::parsers::{cycle_amount_parser, icrc_subaccount_parser};
Expand Down Expand Up @@ -57,10 +56,6 @@ async fn deposit_cycles(

match call_sender {
CallSender::SelectedId => {
if !cycles_ledger_enabled() {
// should be unreachable
bail!("No wallet configured");
}
cycles_ledger::withdraw(
env.get_agent(),
env.get_logger(),
Expand Down Expand Up @@ -111,12 +106,12 @@ pub async fn exec(
call_sender = &proxy_sender;
}
Err(err) => {
if cycles_ledger_enabled() && matches!(err, crate::lib::identity::wallet::GetOrCreateWalletCanisterError::NoWalletConfigured { .. }) {
if matches!(err, crate::lib::identity::wallet::GetOrCreateWalletCanisterError::NoWalletConfigured { .. }) {
debug!(env.get_logger(), "No wallet configured");
} else {
bail!(err)
}
},
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/dfx/src/commands/wallet/redeem_faucet_coupon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::lib::diagnosis::DiagnosedError;
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::identity::wallet::set_wallet_id;
use crate::lib::operations::cycles_ledger::cycles_ledger_enabled;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::util::{format_as_trillions, pretty_thousand_separators};
use anyhow::{anyhow, bail, Context};
Expand Down Expand Up @@ -74,7 +73,7 @@ pub async fn exec(env: &dyn Environment, opts: RedeemFaucetCouponOpts) -> DfxRes
}
// identity has no wallet yet - faucet will provide one
_ => {
if cycles_ledger_enabled() && !opts.yes {
if !opts.yes {
ask_for_consent("`dfx cycles` is now recommended instead of `dfx wallet`. Are you sure you want to create a new cycles wallet anyway?")?;
}
let identity = env
Expand Down
1 change: 0 additions & 1 deletion src/dfx/src/lib/cycles_ledger_types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO(FI-1022): Import types from cycles ledger crate once available

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket was closed without action. There will be no such crate

pub mod create_canister;
pub mod deposit;
pub mod withdraw;
14 changes: 6 additions & 8 deletions src/dfx/src/lib/operations/canister/create_canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::lib::ic_attributes::CanisterSettings as DfxCanisterSettings;
use crate::lib::identity::wallet::{get_or_create_wallet_canister, GetOrCreateWalletCanisterError};
use crate::lib::ledger_types::MAINNET_CYCLE_MINTER_CANISTER_ID;
use crate::lib::operations::canister::motoko_playground::reserve_canister_with_playground;
use crate::lib::operations::cycles_ledger::{create_with_cycles_ledger, cycles_ledger_enabled};
use crate::lib::operations::cycles_ledger::create_with_cycles_ledger;
use crate::util::clap::subnet_selection_opt::SubnetSelectionType;
use anyhow::{anyhow, bail, Context};
use candid::Principal;
Expand Down Expand Up @@ -138,12 +138,10 @@ The command line value will be used.",
{
Ok(wallet) => CallSender::Wallet(*wallet.canister_id_()),
Err(err) => {
if cycles_ledger_enabled()
&& matches!(
err,
GetOrCreateWalletCanisterError::NoWalletConfigured { .. }
)
{
if matches!(
err,
GetOrCreateWalletCanisterError::NoWalletConfigured { .. }
) {
debug!(env.get_logger(), "No wallet configured.");
*call_sender
} else {
Expand All @@ -158,7 +156,7 @@ The command line value will be used.",
CallSender::SelectedId => {
let auto_wallet_disabled = std::env::var("DFX_DISABLE_AUTO_WALLET").is_ok();
let ic_network = env.get_network_descriptor().is_ic;
if cycles_ledger_enabled() && (ic_network || auto_wallet_disabled) {
if ic_network || auto_wallet_disabled {
create_with_cycles_ledger(
env,
agent,
Expand Down
5 changes: 0 additions & 5 deletions src/dfx/src/lib/operations/cycles_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ use icrc_ledger_types::icrc2::approve::ApproveError;
use icrc_ledger_types::icrc2::transfer_from::TransferFromError;
use slog::{info, Logger};

/// Cycles ledger feature flag to turn off behavior that would be confusing while cycles ledger is not out of beta yet.
pub fn cycles_ledger_enabled() -> bool {
std::env::var("DFX_CYCLES_LEDGER_SUPPORT_ENABLE").is_ok()
}

const ICRC1_BALANCE_OF_METHOD: &str = "icrc1_balance_of";
const ICRC1_TRANSFER_METHOD: &str = "icrc1_transfer";
const ICRC2_APPROVE_METHOD: &str = "icrc2_approve";
Expand Down