Skip to content

Commit

Permalink
chore: cycles are now u128 instead of u64 (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
sesi200 authored Mar 7, 2022
1 parent a78e8e9 commit 784c460
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Secp256k1 identity now checks if a curve actually uses the secp256k1 parameters. It cannot be used to load non-secp256k1 identities anymore.

Data type of `cycles` changed to `u128` (was `u64`).

## [0.12.1] - 2022-02-09

Renamed BatchOperationKind._Clear to Clear for compatibility with the certified assets canister.
Expand Down
4 changes: 2 additions & 2 deletions ic-utils/src/interfaces/management_canister/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct CreateCanisterBuilder<'agent, 'canister: 'agent, T> {
memory_allocation: Option<Result<MemoryAllocation, AgentError>>,
freezing_threshold: Option<Result<FreezingThreshold, AgentError>>,
is_provisional_create: bool,
amount: Option<u64>,
amount: Option<u128>,
}

impl<'agent, 'canister: 'agent, T> CreateCanisterBuilder<'agent, 'canister, T> {
Expand All @@ -72,7 +72,7 @@ impl<'agent, 'canister: 'agent, T> CreateCanisterBuilder<'agent, 'canister, T> {
/// Cycles added to this call via ic0.call_cycles_add are returned to the caller.
/// This method is only available in local development instances, and will be removed in the future.
#[allow(clippy::wrong_self_convention)]
pub fn as_provisional_create_with_amount(self, amount: Option<u64>) -> Self {
pub fn as_provisional_create_with_amount(self, amount: Option<u128>) -> Self {
Self {
is_provisional_create: true,
amount,
Expand Down
4 changes: 2 additions & 2 deletions ref-tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub fn get_wallet_wasm_from_env() -> Vec<u8> {

pub async fn create_wallet_canister(
agent: &Agent,
cycles: Option<u64>,
cycles: Option<u128>,
) -> Result<Principal, Box<dyn Error>> {
let canister_wasm = get_wallet_wasm_from_env();

Expand Down Expand Up @@ -198,7 +198,7 @@ where
})
}

pub fn with_wallet_canister<F, R>(cycles: Option<u64>, f: F)
pub fn with_wallet_canister<F, R>(cycles: Option<u128>, f: F)
where
R: Future<Output = Result<(), Box<dyn Error>>>,
F: FnOnce(Agent, Principal) -> R,
Expand Down
4 changes: 2 additions & 2 deletions ref-tests/tests/ic-ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ mod management_canister {

// cycle balance should be amount specified to
// provisional_create_canister_with_cycles call
let amount: u64 = 1 << 40; // 1099511627776
let amount: u128 = 1 << 40; // 1099511627776
let (canister_id_2,) = ic00
.create_canister()
.as_provisional_create_with_amount(Some(amount))
Expand Down Expand Up @@ -813,7 +813,7 @@ mod extras {

let (canister_id,) = ic00
.create_canister()
.as_provisional_create_with_amount(Some(20_000_000_000_000_u64))
.as_provisional_create_with_amount(Some(20_000_000_000_000_u128))
.with_compute_allocation(1_u64)
.with_memory_allocation(1024 * 1024_u64)
.with_freezing_threshold(1_000_000_u64)
Expand Down

0 comments on commit 784c460

Please sign in to comment.