Module sui::accumulator
- Struct AccumulatorRoot
- Struct U128
- Struct Key
- Constants
- Function create
- Function root_id
- Function root_id_mut
- Function accumulator_u128_exists
- Function accumulator_u128_read
- Function create_u128
- Function destroy_u128
- Function update_u128
- Function is_zero_u128
- Function accumulator_key
- Function accumulator_address
- Function root_has_accumulator
- Function root_add_accumulator
- Function root_borrow_accumulator_mut
- Function root_borrow_accumulator
- Function root_remove_accumulator
- Function emit_deposit_event
- Function emit_withdraw_event
use std::ascii;
use std::bcs;
use std::option;
use std::string;
use std::vector;
use sui::address;
use sui::dynamic_field;
use sui::hex;
use sui::object;
use sui::party;
use sui::transfer;
use sui::tx_context;
use sui::vec_map;
Struct AccumulatorRoot
public struct AccumulatorRoot has key
Click to open
Fields
- id: sui::object::UID
Struct U128
Storage for 128-bit accumulator values.
Currently only used to represent the sum of 64 bit values (such as Balance<T>).
The additional bits are necessary to prevent overflow, as it would take 2^64 deposits of U64_MAX
to cause an overflow.
public struct U128 has store
Click to open
Fields
- value: u128
Struct Key
Key is used only for computing the field id of accumulator objects. T is the type of the accumulated value, e.g. Balance<SUI>
public struct Key<phantom T> has copy, drop, store
Click to open
Fields
- address: address
Constants
const ENotSystemAddress: u64 = 0;
Function create
fun create(ctx: &sui::tx_context::TxContext)
Function root_id
public(package) fun root_id(accumulator_root: &sui::accumulator::AccumulatorRoot): &sui::object::UID
Function root_id_mut
public(package) fun root_id_mut(accumulator_root: &mut sui::accumulator::AccumulatorRoot): &mut sui::object::UID
Function accumulator_u128_exists
public(package) fun accumulator_u128_exists<T>(root: &sui::accumulator::AccumulatorRoot, address: address): bool
Function accumulator_u128_read
public(package) fun accumulator_u128_read<T>(root: &sui::accumulator::AccumulatorRoot, address: address): u128
Function create_u128
public(package) fun create_u128(value: u128): sui::accumulator::U128
Function destroy_u128
public(package) fun destroy_u128(u128: sui::accumulator::U128)
Function update_u128
public(package) fun update_u128(u128: &mut sui::accumulator::U128, merge: u128, split: u128)
Function is_zero_u128
public(package) fun is_zero_u128(u128: &sui::accumulator::U128): bool
Function accumulator_key
public(package) fun accumulator_key<T>(address: address): sui::accumulator::Key<T>
Function accumulator_address
public(package) fun accumulator_address<T>(address: address): address
Function root_has_accumulator
Balance object methods
public(package) fun root_has_accumulator<K, V: store>(accumulator_root: &sui::accumulator::AccumulatorRoot, name: sui::accumulator::Key<K>): bool
Function root_add_accumulator
public(package) fun root_add_accumulator<K, V: store>(accumulator_root: &mut sui::accumulator::AccumulatorRoot, name: sui::accumulator::Key<K>, value: V)
Function root_borrow_accumulator_mut
public(package) fun root_borrow_accumulator_mut<K, V: store>(accumulator_root: &mut sui::accumulator::AccumulatorRoot, name: sui::accumulator::Key<K>): &mut V
Function root_borrow_accumulator
public(package) fun root_borrow_accumulator<K, V: store>(accumulator_root: &sui::accumulator::AccumulatorRoot, name: sui::accumulator::Key<K>): &V
Function root_remove_accumulator
public(package) fun root_remove_accumulator<K, V: store>(accumulator_root: &mut sui::accumulator::AccumulatorRoot, name: sui::accumulator::Key<K>): V
Function emit_deposit_event
public(package) fun emit_deposit_event<T>(accumulator: address, recipient: address, amount: u64)
Function emit_withdraw_event
public(package) fun emit_withdraw_event<T>(accumulator: address, owner: address, amount: u64)