Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
7 changes: 0 additions & 7 deletions integration_tests/src/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ pub fn default_get_deposit_address_args() -> GetDepositAddressArgs {
}
}

pub fn default_update_balance_args() -> cksol_types::UpdateBalanceArgs {
cksol_types::UpdateBalanceArgs {
owner: None,
subaccount: None,
}
}

pub fn default_process_deposit_args() -> ProcessDepositArgs {
ProcessDepositArgs {
owner: None,
Expand Down
17 changes: 4 additions & 13 deletions integration_tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cksol_int_tests::{
DEFAULT_CALLER_ACCOUNT, DEFAULT_CALLER_DEPOSIT_ADDRESS, DEPOSIT_AMOUNT,
EXPECTED_MINT_AMOUNT, MockBuilder, SharedMockHttpOutcalls,
default_get_deposit_address_args, default_process_deposit_args,
default_update_balance_args, deposit_transaction_signature,
deposit_transaction_signature,
},
};
use cksol_types::{
Expand Down Expand Up @@ -1045,20 +1045,14 @@ mod update_balance_tests {
for account in &accounts {
let result = minter
.update_balance(UpdateBalanceArgs {
owner: Some(account.owner),
subaccount: account.subaccount,
})
.await;
assert_eq!(result, Ok(()));
}

// Calling again for an already-monitored account is idempotent — no new event
let result = minter
.update_balance(UpdateBalanceArgs {
owner: None,
subaccount: None,
})
.await;
let result = minter.update_balance(UpdateBalanceArgs::default()).await;
assert_eq!(result, Ok(()));

// Exactly one StartedMonitoringAccount event per account, no duplicates
Expand Down Expand Up @@ -1107,10 +1101,7 @@ mod anonymous_caller_tests {

// `update_balance` endpoint
let result = minter
.try_update_balance(UpdateBalanceArgs {
owner,
subaccount: None,
})
.try_update_balance(UpdateBalanceArgs::default())
.await;
assert_matches!(result, Err(s) => s.contains("the owner must be non-anonymous"));

Expand Down Expand Up @@ -1308,7 +1299,7 @@ mod automated_deposit_flow_tests {
DEFAULT_CALLER_DEPOSIT_ADDRESS
);
minter
.update_balance(default_update_balance_args())
.update_balance(UpdateBalanceArgs::default())
.await
.expect("update_balance should succeed");

Expand Down
9 changes: 3 additions & 6 deletions libs/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,11 @@ pub enum ProcessDepositError {
}

/// Arguments for a request to the `update_balance` ckSOL minter endpoint.
#[derive(Clone, Eq, PartialEq, Debug, CandidType, Deserialize, Serialize)]
#[derive(Clone, Eq, PartialEq, Debug, Default, CandidType, Deserialize, Serialize)]
pub struct UpdateBalanceArgs {
/// The principal to register for automated deposit monitoring.
///
/// If not set, defaults to the caller's principal.
/// The resolved owner must be a non-anonymous principal.
pub owner: Option<Principal>,
/// The subaccount to register for automated deposit monitoring.
///
/// The owner is always the caller.
pub subaccount: Option<Subaccount>,
}

Expand Down
6 changes: 1 addition & 5 deletions minter/cksol_minter.did
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@ type ProcessDepositError = variant {

// Arguments for a request to the `update_balance` endpoint.
type UpdateBalanceArgs = record {
// If provided, register this principal's deposit address for monitoring.
//
// If not set, defaults to the caller's principal.
// The resolved owner must be a non-anonymous principal.
owner: opt principal;
// The subaccount to register for automated deposit monitoring.
// The owner is always the caller.
subaccount: opt blob;
};

Expand Down
2 changes: 1 addition & 1 deletion minter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn get_deposit_address(args: GetDepositAddressArgs) -> Address {

#[ic_cdk::update]
fn update_balance(args: UpdateBalanceArgs) -> Result<(), UpdateBalanceError> {
let account = assert_non_anonymous_account(args.owner, args.subaccount);
let account = assert_non_anonymous_account(None, args.subaccount);
cksol_minter::deposit::automatic::update_balance(&IcCanisterRuntime::new(), account)
}

Expand Down
Loading