Skip to content

Conversation

@mystenmark
Copy link
Contributor

No description provided.

@mystenmark mystenmark requested a review from a team as a code owner December 18, 2025 20:26
@mystenmark mystenmark temporarily deployed to sui-typescript-aws-kms-test-env December 18, 2025 20:26 — with GitHub Actions Inactive
@vercel
Copy link

vercel bot commented Dec 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
sui-docs Ready Ready Preview, Comment Dec 19, 2025 9:44pm
2 Skipped Deployments
Project Deployment Review Updated (UTC)
multisig-toolkit Ignored Ignored Preview Dec 19, 2025 9:44pm
sui-kiosk Ignored Ignored Preview Dec 19, 2025 9:44pm

Comment on lines 117 to 130
/// Read the balance of an address as of the beginning of the current consensus commit.
/// Can read either address-owned or object-owned balances.
public fun read_address_balance<T>(
root: &sui::accumulator::AccumulatorRoot,
address: address,
): u64 {
if (!root.u128_exists<Balance<T>>(address)) {
return 0
};
let val: u128 = root.u128_read<Balance<T>>(address);
let val = std::u128::min(std::u64::max_value!() as u128, val);
val as u64
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I will take a deeper look in a bit, but my initial reaction is that this should belong in funds_accumulator.
It can do something like

/// Where `U` is the underlying integer type of `T`
/// This avoids needing 6 different APIs for each type--each of which would need 
/// to assert the underlying integer type anyway
public fun read_funds_balance<T, U>(    
    root: &sui::accumulator::AccumulatorRoot,
    _: internal::Permit<T>,
    owner: address,
): U;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you get the max for an integer type parametrically? if not I'm not sure how much this will save.


/// Read the balance of an address as of the beginning of the current consensus commit.
/// Can read either address-owned or object-owned balances.
public fun read_address_balance<T>(
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be something like

Suggested change
public fun read_address_balance<T>(
public fun initial_funds_balance<T>(

initial might not be the right word but we need 4 distinct concepts

  • At the start of the transaction
  • deposits
  • withdrawals
  • current/net (initial + withdrawals - deposits)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about read_settled_address_balance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants