faiss_index.bin.documents•245 kB
�� ]�(}�(�id��
url.move_0��path��docs/move_files/sui/url.move��chunk_index�K �content��)File: sui/url.move
Move Module: sui::url�� file_type��move�u}�(h�
url.move_1�hhhKh�TFile: sui/url.move
Module: sui::url
Dependencies:
use std::ascii::{Self, String};
�h �move�u}�(h�
url.move_2�hhhKh�yFile: sui/url.move
Module: sui::url
Function: new_unsafe
public fun new_unsafe(url: String): Url {
Url { url }�h �move�u}�(h�
url.move_3�hhhKh��File: sui/url.move
Module: sui::url
Function: new_unsafe_from_bytes
public fun new_unsafe_from_bytes(bytes: vector<u8>): Url {
let url = ascii::string(bytes);
Url { url }�h �move�u}�(h�
url.move_4�hhhKh�{File: sui/url.move
Module: sui::url
Function: inner_url
public fun inner_url(self: &Url): String{
self.url
}�h �move�u}�(h�
url.move_5�hhhKh��File: sui/url.move
Module: sui::url
Function: update
public fun update(self: &mut Url, url: String) {
self.url = url;
}�h �move�u}�(h�package.move_0�h� docs/move_files/sui/package.move�hK h�1File: sui/package.move
Move Module: sui::package�h �move�u}�(h�package.move_1�hh!hKhX File: sui/package.move
Module: sui::package
Dependencies:
use sui::object::{Self, ID, UID};
use sui::tx_context::{TxContext, sender};
use std::ascii::String;
use std::type_name;
use sui::types;
use there is already a pending upgrade in the transaction.
/// Otherwise guaranteed to be the latest version of any given
/// package.
public fun upgrade_package(cap: &UpgradeCap): ID {
cap.package
}
/// The most recent version of the package, increments by one for each
/// successfully applied upgrade.
public fun version(cap: &UpgradeCap): u64 {
cap.version
}
/// The most permissive kind of upgrade currently supported by this
/// `cap`.
public fun upgrade_policy(cap: &UpgradeCap): u8 {
cap.policy
}
/// The package that this ticket is authorized to upgrade
public fun ticket_package(ticket: &UpgradeTicket): ID {
ticket.package
}
/// The kind of upgrade that this ticket authorizes.
public fun ticket_policy(ticket: &UpgradeTicket): u8 {
ticket.policy
}
/// ID of the `UpgradeCap` that this `receipt` should be used to
/// update.
public fun receipt_cap(receipt: &UpgradeReceipt): ID {
receipt.cap
}
/// ID of the package that was upgraded to: the latest version of
/// the package, as of the upgrade represented by this `receipt`.
public fun receipt_package(receipt: &UpgradeReceipt): ID {
receipt.package
}
/// A hash of the package contents for the new version of the
/// package. This ticket only authorizes an upgrade to a package
/// that matches this digest. A package's contents are identified
/// by two things:
///
/// - modules: [[u8]] a list of the package's module contents
/// - deps: [[u8;
�h �move�u}�(h�package.move_2�hh!hKhX� File: sui/package.move
Module: sui::package
Struct: UpgradeTicket
/// (Immutable) ID of the `UpgradeCap` this originated from.
cap: ID,
/// (Immutable) ID of the package that can be upgraded.
package: ID,
/// (Immutable) The policy regarding what kind of upgrade this ticket
/// permits.
policy: u8,
/// (Immutable) SHA256 digest of the bytecode and transitive
/// dependencies that will be used in the upgrade.
digest: vector<u8>,�h �move�u}�(h�package.move_3�hh!hKh��File: sui/package.move
Module: sui::package
Struct: UpgradeReceipt
/// (Immutable) ID of the `UpgradeCap` this originated from.
cap: ID,
/// (Immutable) ID of the package after it was upgraded.
package: ID,�h �move�u}�(h�package.move_4�hh!hKhX� File: sui/package.move
Module: sui::package
Function: claim
public fun claim<OTW: drop>(otw: OTW, ctx: &mut TxContext): Publisher {
assert!(types::is_one_time_witness(&otw), ENotOneTimeWitness);
let type = type_name::get_with_original_ids<OTW>();
Publisher {
id: object::new(ctx),
package: type_name::get_address(&type),
module_name: type_name::get_module(&type),
}�h �move�u}�(h�package.move_5�hh!hKh��File: sui/package.move
Module: sui::package
Function: claim_and_keep
public fun claim_and_keep<OTW: drop>(otw: OTW, ctx: &mut TxContext) {
sui::transfer::public_transfer(claim(otw, ctx), sender(ctx))
}�h �move�u}�(h�package.move_6�hh!hKh��File: sui/package.move
Module: sui::package
Function: burn_publisher
public fun burn_publisher(self: Publisher) {
let Publisher { id, package: _, module_name: _ }�h �move�u}�(h�package.move_7�hh!hKh��File: sui/package.move
Module: sui::package
Function: from_package
public fun from_package<T>(self: &Publisher): bool {
let type = type_name::get_with_original_ids<T>();
(type_name::get_address(&type) == self.package)
}�h �move�u}�(h�package.move_8�hh!hKhX3 File: sui/package.move
Module: sui::package
Function: from_module
public fun from_module<T>(self: &Publisher): bool {
let type = type_name::get_with_original_ids<T>();
(type_name::get_address(&type) == self.package)
&& (type_name::get_module(&type) == self.module_name)
}�h �move�u}�(h�package.move_9�hh!hK h��File: sui/package.move
Module: sui::package
Function: published_module
public fun published_module(self: &Publisher): &String {
&self.module_name
}�h �move�u}�(h�package.move_10�hh!hK
h��File: sui/package.move
Module: sui::package
Function: published_package
public fun published_package(self: &Publisher): &String {
&self.package
}�h �move�u}�(h�package.move_11�hh!hKh��File: sui/package.move
Module: sui::package
Function: upgrade_package
public fun upgrade_package(cap: &UpgradeCap): ID {
cap.package
}�h �move�u}�(h�package.move_12�hh!hKh��File: sui/package.move
Module: sui::package
Function: version
public fun version(cap: &UpgradeCap): u64 {
cap.version
}�h �move�u}�(h�package.move_13�hh!hK
h��File: sui/package.move
Module: sui::package
Function: upgrade_policy
public fun upgrade_policy(cap: &UpgradeCap): u8 {
cap.policy
}�h �move�u}�(h�package.move_14�hh!hKh��File: sui/package.move
Module: sui::package
Function: ticket_package
public fun ticket_package(ticket: &UpgradeTicket): ID {
ticket.package
}�h �move�u}�(h�package.move_15�hh!hKh��File: sui/package.move
Module: sui::package
Function: ticket_policy
public fun ticket_policy(ticket: &UpgradeTicket): u8 {
ticket.policy
}�h �move�u}�(h�package.move_16�hh!hKh��File: sui/package.move
Module: sui::package
Function: receipt_cap
public fun receipt_cap(receipt: &UpgradeReceipt): ID {
receipt.cap
}�h �move�u}�(h�package.move_17�hh!hKh��File: sui/package.move
Module: sui::package
Function: receipt_package
public fun receipt_package(receipt: &UpgradeReceipt): ID {
receipt.package
}�h �move�u}�(h�package.move_18�hh!hKh��File: sui/package.move
Module: sui::package
Function: ticket_digest
public fun ticket_digest(ticket: &UpgradeTicket): &vector<u8> {
&ticket.digest
}�h �move�u}�(h�package.move_19�hh!hKh�|File: sui/package.move
Module: sui::package
Function: compatible_policy
public fun compatible_policy(): u8 { COMPATIBLE }�h �move�u}�(h�package.move_20�hh!hKh�vFile: sui/package.move
Module: sui::package
Function: additive_policy
public fun additive_policy(): u8 { ADDITIVE }�h �move�u}�(h�package.move_21�hh!hKh�vFile: sui/package.move
Module: sui::package
Function: dep_only_policy
public fun dep_only_policy(): u8 { DEP_ONLY }�h �move�u}�(h�package.move_22�hh!hKh��File: sui/package.move
Module: sui::package
Function: only_additive_upgrades
fun only_additive_upgrades(cap: &mut UpgradeCap) {
restrict(cap, ADDITIVE)
}�h �move�u}�(h�package.move_23�hh!hKh��File: sui/package.move
Module: sui::package
Function: only_dep_upgrades
fun only_dep_upgrades(cap: &mut UpgradeCap) {
restrict(cap, DEP_ONLY)
}�h �move�u}�(h�package.move_24�hh!hKh��File: sui/package.move
Module: sui::package
Function: make_immutable
fun make_immutable(cap: UpgradeCap) {
let UpgradeCap { id, package: _, version: _, policy: _ }�h �move�u}�(h�package.move_25�hh!hKhX: File: sui/package.move
Module: sui::package
Function: authorize_upgrade
public fun authorize_upgrade(
cap: &mut UpgradeCap,
policy: u8,
digest: vector<u8>
): UpgradeTicket {
let id_zero = object::id_from_address(@0x0);
assert!(cap.package != id_zero, EAlreadyAuthorized);
assert!(policy >= cap.policy, ETooPermissive);
let package = cap.package;
cap.package = id_zero;
UpgradeTicket {
cap: object::id(cap),
package,
policy,
digest,
}�h �move�u}�(h�package.move_26�hh!hKh��File: sui/package.move
Module: sui::package
Function: commit_upgrade
public fun commit_upgrade(
cap: &mut UpgradeCap,
receipt: UpgradeReceipt,
) {
let UpgradeReceipt { cap: cap_id, package }�h �move�u}�(h�package.move_27�hh!hKhXv File: sui/package.move
Module: sui::package
Function: test_claim
public fun test_claim<OTW: drop>(_: OTW, ctx: &mut TxContext): Publisher {
let type = type_name::get_with_original_ids<OTW>();
Publisher {
id: object::new(ctx),
package: type_name::get_address(&type),
module_name: type_name::get_module(&type),
}�h �move�u}�(h�package.move_28�hh!hKhX File: sui/package.move
Module: sui::package
Function: test_publish
public fun test_publish(package: ID, ctx: &mut TxContext): UpgradeCap {
UpgradeCap {
id: object::new(ctx),
package,
version: 1,
policy: COMPATIBLE,
}�h �move�u}�(h�package.move_29�hh!hKh��File: sui/package.move
Module: sui::package
Function: test_upgrade
public fun test_upgrade(ticket: UpgradeTicket): UpgradeReceipt {
let UpgradeTicket { cap, package, policy: _, digest: _ }�h �move�u}�(h�package.move_30�hh!hKh��File: sui/package.move
Module: sui::package
Function: restrict
fun restrict(cap: &mut UpgradeCap, policy: u8) {
assert!(cap.policy <= policy, ETooPermissive);
cap.policy = policy;
}�h �move�u}�(h�
borrow.move_0�h�docs/move_files/sui/borrow.move�hK h�/File: sui/borrow.move
Move Module: sui::borrow�h �move�u}�(h�
borrow.move_1�hh�hKhX8 File: sui/borrow.move
Module: sui::borrow
Dependencies:
use it and put back in the end. Hot-potato `Borrow` makes
/// sure the object is returned and was not swapped for another one.
module sui::borrow {
use sui::object::{Self, ID};
use std::option::{Self, Option};
use sui::tx_context::{Self, TxContext};
�h �move�u}�(h�
borrow.move_2�hh�hKh�QFile: sui/borrow.move
Module: sui::borrow
Struct: Borrow
ref: address, obj: ID�h �move�u}�(h�
borrow.move_3�hh�hKhX File: sui/borrow.move
Module: sui::borrow
Function: new
public fun new<T: key + store>(value: T, ctx: &mut TxContext): Referent<T> {
Referent {
id: tx_context::fresh_object_address(ctx),
value: option::some(value)
}�h �move�u}�(h�
borrow.move_4�hh�hKhX3 File: sui/borrow.move
Module: sui::borrow
Function: borrow
public fun borrow<T: key + store>(self: &mut Referent<T>): (T, Borrow) {
let value = option::extract(&mut self.value);
let id = object::id(&value);
(value, Borrow {
ref: self.id,
obj: id
}�h �move�u}�(h�
borrow.move_5�hh�hKh��File: sui/borrow.move
Module: sui::borrow
Function: put_back
public fun put_back<T: key + store>(self: &mut Referent<T>, value: T, borrow: Borrow) {
let Borrow { ref, obj }�h �move�u}�(h�
borrow.move_6�hh�hKh��File: sui/borrow.move
Module: sui::borrow
Function: destroy
public fun destroy<T: key + store>(self: Referent<T>): T {
let Referent { id: _, value }�h �move�u}�(h�
borrow.move_7�hh�hKh��File: sui/borrow.move
Module: sui::borrow
Function: test_borrow
fun test_borrow() {
let ctx = &mut sui::tx_context::dummy();
let ref = new(Test { id: object::new(ctx) }�h �move�u}�(h�
borrow.move_8�hh�hKh��File: sui/borrow.move
Module: sui::borrow
Function: test_object_swap
fun test_object_swap() {
let ctx = &mut sui::tx_context::dummy();
let ref_1 = new(Test { id: object::new(ctx) }�h �move�u}�(h�
borrow.move_9�hh�hK h��File: sui/borrow.move
Module: sui::borrow
Function: test_borrow_fail
fun test_borrow_fail() {
let ctx = &mut sui::tx_context::dummy();
let ref_1 = new(Test { id: object::new(ctx) }�h �move�u}�(h�entry_funs.move_0�h�#docs/move_files/sui/entry_funs.move�hK h�6File: sui/entry_funs.move
Move Module: unknown_module�h �move�u}�(h�multi_index_test.move_0�h�)docs/move_files/sui/multi_index_test.move�hK h�4File: sui/multi_index_test.move
Move Module: 0x1::m�h �move�u}�(h�multi_index_test.move_1�hh�hKh��File: sui/multi_index_test.move
Module: 0x1::m
Function: f
fun f() {
x[];
x[1, f()];
x[1, 2, 3];
}�h �move�u}�(h�mut_space.move_0�h�"docs/move_files/sui/mut_space.move�hK h�5File: sui/mut_space.move
Move Module: unknown_module�h �move�u}�(h�mut_space.move_1�hh�hKh�DFile: sui/mut_space.move
Module: unknown_module
Struct: S
f: u64,�h �move�u}�(h�mut_space.move_2�hh�hKh��File: sui/mut_space.move
Module: unknown_module
Function: foo
public fun foo(x: & mut S): & mut u64 {
& mut x.f;
&
mut x.f
}�h �move�u}�(h�labels1.move_0�h� docs/move_files/sui/labels1.move�hK h�,File: sui/labels1.move
Move Module: 0x42::M�h �move�u}�(h�labels1.move_1�hh�hKh�LFile: sui/labels1.move
Module: 0x42::M
Function: bar
fun bar(): u64 { 0 }�h �move�u}�(h�labels1.move_2�hh�hKh�yFile: sui/labels1.move
Module: 0x42::M
Function: t
fun t(): u64 { 'r: {
// loop
1 + 'a: loop { foo() }�h �move�u}�(h�match_at_binders1.move_0�h�*docs/move_files/sui/match_at_binders1.move�hK h�6File: sui/match_at_binders1.move
Move Module: 0x42::m�h �move�u}�(h�match_at_binders1.move_1�hh�hKh��File: sui/match_at_binders1.move
Module: 0x42::m
Function: test_04
fun test_04<T: drop>(x: Maybe<T>, other: Maybe<T>): Maybe<T> {
match (x) {
(x @ Maybe::Nothing) | (x @ Maybe::Just(_)) => other,
}�h �move�u}�(h�native_structs.move_0�h�'docs/move_files/sui/native_structs.move�hK h�2File: sui/native_structs.move
Move Module: s::foo�h �move�u}�(h�priority_queue.move_0�h�'docs/move_files/sui/priority_queue.move�hK h�?File: sui/priority_queue.move
Move Module: sui::priority_queue�h �move�u}�(h�priority_queue.move_1�hh�hKhX� File: sui/priority_queue.move
Module: sui::priority_queue
Dependencies:
use std::vector;
use of the incorrect usage
// of `remove`, and the resulting new root and its two children appear to satisfy the heap invariant
// so we stop max-heapifying there, while the rest of the tree is all messed up because of the shift.
let priorities = vector[8, 7, 3, 6, 2, 1, 0, 5, 4];
�h �move�u}�(h�priority_queue.move_2�hh�hKhX� File: sui/priority_queue.move
Module: sui::priority_queue
Function: new
public fun new<T: drop>(entries: vector<Entry<T>>) : PriorityQueue<T> {
let len = vector::length(&entries);
let i = len / 2;
// Max heapify from the first node that is a parent (node at len / 2).
while (i > 0) {
i = i - 1;
max_heapify_recursive(&mut entries, len, i);
}�h �move�u}�(h�priority_queue.move_3�hh�hKhXu File: sui/priority_queue.move
Module: sui::priority_queue
Function: pop_max
public fun pop_max<T: drop>(pq: &mut PriorityQueue<T>) : (u64, T) {
let len = vector::length(&pq.entries);
assert!(len > 0, EPopFromEmptyHeap);
// Swap the max element with the last element in the entries and remove the max element.
let Entry { priority, value }�h �move�u}�(h�priority_queue.move_4�hh�hKh��File: sui/priority_queue.move
Module: sui::priority_queue
Function: insert
public fun insert<T: drop>(pq: &mut PriorityQueue<T>, priority: u64, value: T) {
vector::push_back(&mut pq.entries, Entry { priority, value}�h �move�u}�(h�priority_queue.move_5�hh�hKh��File: sui/priority_queue.move
Module: sui::priority_queue
Function: new_entry
public fun new_entry<T: drop>(priority: u64, value: T): Entry<T> {
Entry { priority, value }�h �move�u}�(h�priority_queue.move_6�hh�hKhX� File: sui/priority_queue.move
Module: sui::priority_queue
Function: create_entries
public fun create_entries<T: drop>(p: vector<u64>, v: vector<T>): vector<Entry<T>> {
let len = vector::length(&p);
assert!(vector::length(&v) == len, 0);
let res = vector::empty();
let i = 0;
while (i < len) {
let priority = vector::remove(&mut p, 0);
let value = vector::remove(&mut v, 0);
vector::push_back(&mut res, Entry { priority, value }�h �move�u}�(h�priority_queue.move_7�hh�hKh��File: sui/priority_queue.move
Module: sui::priority_queue
Function: restore_heap_recursive
fun restore_heap_recursive<T: drop>(v: &mut vector<Entry<T>>, i: u64) {
if (i == 0) {
return
}�h �move�u}�(h�priority_queue.move_8�hh�hKh��File: sui/priority_queue.move
Module: sui::priority_queue
Function: max_heapify_recursive
fun max_heapify_recursive<T: drop>(v: &mut vector<Entry<T>>, len: u64, i: u64) {
if (len == 0) {
return
}�h �move�u}�(h�priority_queue.move_9�hh�hK hXi File: sui/priority_queue.move
Module: sui::priority_queue
Function: priorities
public fun priorities<T: drop>(pq: &PriorityQueue<T>): vector<u64> {
let res = vector[];
let i = 0;
while (i < vector::length(&pq.entries)) {
vector::push_back(&mut res, vector::borrow(&pq.entries, i).priority);
i = i +1;
}�h �move�u}�(h�priority_queue.move_10�hh�hK
hX@ File: sui/priority_queue.move
Module: sui::priority_queue
Function: test_pq
fun test_pq() {
let h = new(create_entries(vector[3,1,4,2,5,2], vector[10, 20, 30, 40, 50, 60]));
check_pop_max(&mut h, 5, 50);
check_pop_max(&mut h, 4, 30);
check_pop_max(&mut h, 3, 10);
insert(&mut h, 7, 70);
check_pop_max(&mut h, 7, 70);
check_pop_max(&mut h, 2, 40);
insert(&mut h, 0, 80);
check_pop_max(&mut h, 2, 60);
check_pop_max(&mut h, 1, 20);
check_pop_max(&mut h, 0, 80);
let h = new(create_entries(vector[5,3,1,2,4], vector[10, 20, 30, 40, 50]));
check_pop_max(&mut h, 5, 10);
check_pop_max(&mut h, 4, 50);
check_pop_max(&mut h, 3, 20);
check_pop_max(&mut h, 2, 40);
check_pop_max(&mut h, 1, 30);
}�h �move�u}�(h�priority_queue.move_11�hh�hKhX� File: sui/priority_queue.move
Module: sui::priority_queue
Function: test_swap_remove_edge_case
fun test_swap_remove_edge_case() {
// This test would fail if `remove` is used incorrectly instead of `swap_remove` in `pop_max`.
// It's hard to characterize exactly under what condition this bug is triggered but roughly
// it happens when the entire tree vector is shifted left by one because of the incorrect usage
// of `remove`, and the resulting new root and its two children appear to satisfy the heap invariant
// so we stop max-heapifying there, while the rest of the tree is all messed up because of the shift.
let priorities = vector[8, 7, 3, 6, 2, 1, 0, 5, 4];
let values = vector[0, 0, 0, 0, 0, 0, 0, 0, 0];
let h = new(create_entries(priorities, values));
check_pop_max(&mut h, 8, 0);
check_pop_max(&mut h, 7, 0);
check_pop_max(&mut h, 6, 0);
check_pop_max(&mut h, 5, 0);
check_pop_max(&mut h, 4, 0);
check_pop_max(&mut h, 3, 0);
check_pop_max(&mut h, 2, 0);
check_pop_max(&mut h, 1, 0);
check_pop_max(&mut h, 0, 0);
}�h �move�u}�(h�priority_queue.move_12�hh�hKhXC File: sui/priority_queue.move
Module: sui::priority_queue
Function: check_pop_max
fun check_pop_max(h: &mut PriorityQueue<u64>, expected_priority: u64, expected_value: u64) {
let (priority, value) = pop_max(h);
assert!(priority == expected_priority, 0);
assert!(value == expected_value, 0);
}�h �move�u}�(�id��
url.move_0��path��docs/move_files/sui/url.move��chunk_index�K �content��)File: sui/url.move
Move Module: sui::url�� file_type��move�u}�(j1 �
url.move_1�j3 j4 j5 Kj6 �TFile: sui/url.move
Module: sui::url
Dependencies:
use std::ascii::{Self, String};
�j8 �move�u}�(j1 �
url.move_2�j3 j4 j5 Kj6 �yFile: sui/url.move
Module: sui::url
Function: new_unsafe
public fun new_unsafe(url: String): Url {
Url { url }�j8 �move�u}�(j1 �
url.move_3�j3 j4 j5 Kj6 ��File: sui/url.move
Module: sui::url
Function: new_unsafe_from_bytes
public fun new_unsafe_from_bytes(bytes: vector<u8>): Url {
let url = ascii::string(bytes);
Url { url }�j8 �move�u}�(j1 �
url.move_4�j3 j4 j5 Kj6 �{File: sui/url.move
Module: sui::url
Function: inner_url
public fun inner_url(self: &Url): String{
self.url
}�j8 �move�u}�(j1 �
url.move_5�j3 j4 j5 Kj6 ��File: sui/url.move
Module: sui::url
Function: update
public fun update(self: &mut Url, url: String) {
self.url = url;
}�j8 �move�u}�(j1 �package.move_0�j3 � docs/move_files/sui/package.move�j5 K j6 �1File: sui/package.move
Move Module: sui::package�j8 �move�u}�(j1 �package.move_1�j3 jP j5 Kj6 X File: sui/package.move
Module: sui::package
Dependencies:
use sui::object::{Self, ID, UID};
use sui::tx_context::{TxContext, sender};
use std::ascii::String;
use std::type_name;
use sui::types;
use there is already a pending upgrade in the transaction.
/// Otherwise guaranteed to be the latest version of any given
/// package.
public fun upgrade_package(cap: &UpgradeCap): ID {
cap.package
}
/// The most recent version of the package, increments by one for each
/// successfully applied upgrade.
public fun version(cap: &UpgradeCap): u64 {
cap.version
}
/// The most permissive kind of upgrade currently supported by this
/// `cap`.
public fun upgrade_policy(cap: &UpgradeCap): u8 {
cap.policy
}
/// The package that this ticket is authorized to upgrade
public fun ticket_package(ticket: &UpgradeTicket): ID {
ticket.package
}
/// The kind of upgrade that this ticket authorizes.
public fun ticket_policy(ticket: &UpgradeTicket): u8 {
ticket.policy
}
/// ID of the `UpgradeCap` that this `receipt` should be used to
/// update.
public fun receipt_cap(receipt: &UpgradeReceipt): ID {
receipt.cap
}
/// ID of the package that was upgraded to: the latest version of
/// the package, as of the upgrade represented by this `receipt`.
public fun receipt_package(receipt: &UpgradeReceipt): ID {
receipt.package
}
/// A hash of the package contents for the new version of the
/// package. This ticket only authorizes an upgrade to a package
/// that matches this digest. A package's contents are identified
/// by two things:
///
/// - modules: [[u8]] a list of the package's module contents
/// - deps: [[u8;
�j8 �move�u}�(j1 �package.move_2�j3 jP j5 Kj6 X� File: sui/package.move
Module: sui::package
Struct: UpgradeTicket
/// (Immutable) ID of the `UpgradeCap` this originated from.
cap: ID,
/// (Immutable) ID of the package that can be upgraded.
package: ID,
/// (Immutable) The policy regarding what kind of upgrade this ticket
/// permits.
policy: u8,
/// (Immutable) SHA256 digest of the bytecode and transitive
/// dependencies that will be used in the upgrade.
digest: vector<u8>,�j8 �move�u}�(j1 �package.move_3�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Struct: UpgradeReceipt
/// (Immutable) ID of the `UpgradeCap` this originated from.
cap: ID,
/// (Immutable) ID of the package after it was upgraded.
package: ID,�j8 �move�u}�(j1 �package.move_4�j3 jP j5 Kj6 X� File: sui/package.move
Module: sui::package
Function: claim
public fun claim<OTW: drop>(otw: OTW, ctx: &mut TxContext): Publisher {
assert!(types::is_one_time_witness(&otw), ENotOneTimeWitness);
let type = type_name::get_with_original_ids<OTW>();
Publisher {
id: object::new(ctx),
package: type_name::get_address(&type),
module_name: type_name::get_module(&type),
}�j8 �move�u}�(j1 �package.move_5�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: claim_and_keep
public fun claim_and_keep<OTW: drop>(otw: OTW, ctx: &mut TxContext) {
sui::transfer::public_transfer(claim(otw, ctx), sender(ctx))
}�j8 �move�u}�(j1 �package.move_6�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: burn_publisher
public fun burn_publisher(self: Publisher) {
let Publisher { id, package: _, module_name: _ }�j8 �move�u}�(j1 �package.move_7�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: from_package
public fun from_package<T>(self: &Publisher): bool {
let type = type_name::get_with_original_ids<T>();
(type_name::get_address(&type) == self.package)
}�j8 �move�u}�(j1 �package.move_8�j3 jP j5 Kj6 X3 File: sui/package.move
Module: sui::package
Function: from_module
public fun from_module<T>(self: &Publisher): bool {
let type = type_name::get_with_original_ids<T>();
(type_name::get_address(&type) == self.package)
&& (type_name::get_module(&type) == self.module_name)
}�j8 �move�u}�(j1 �package.move_9�j3 jP j5 K j6 ��File: sui/package.move
Module: sui::package
Function: published_module
public fun published_module(self: &Publisher): &String {
&self.module_name
}�j8 �move�u}�(j1 �package.move_10�j3 jP j5 K
j6 ��File: sui/package.move
Module: sui::package
Function: published_package
public fun published_package(self: &Publisher): &String {
&self.package
}�j8 �move�u}�(j1 �package.move_11�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: upgrade_package
public fun upgrade_package(cap: &UpgradeCap): ID {
cap.package
}�j8 �move�u}�(j1 �package.move_12�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: version
public fun version(cap: &UpgradeCap): u64 {
cap.version
}�j8 �move�u}�(j1 �package.move_13�j3 jP j5 K
j6 ��File: sui/package.move
Module: sui::package
Function: upgrade_policy
public fun upgrade_policy(cap: &UpgradeCap): u8 {
cap.policy
}�j8 �move�u}�(j1 �package.move_14�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: ticket_package
public fun ticket_package(ticket: &UpgradeTicket): ID {
ticket.package
}�j8 �move�u}�(j1 �package.move_15�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: ticket_policy
public fun ticket_policy(ticket: &UpgradeTicket): u8 {
ticket.policy
}�j8 �move�u}�(j1 �package.move_16�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: receipt_cap
public fun receipt_cap(receipt: &UpgradeReceipt): ID {
receipt.cap
}�j8 �move�u}�(j1 �package.move_17�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: receipt_package
public fun receipt_package(receipt: &UpgradeReceipt): ID {
receipt.package
}�j8 �move�u}�(j1 �package.move_18�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: ticket_digest
public fun ticket_digest(ticket: &UpgradeTicket): &vector<u8> {
&ticket.digest
}�j8 �move�u}�(j1 �package.move_19�j3 jP j5 Kj6 �|File: sui/package.move
Module: sui::package
Function: compatible_policy
public fun compatible_policy(): u8 { COMPATIBLE }�j8 �move�u}�(j1 �package.move_20�j3 jP j5 Kj6 �vFile: sui/package.move
Module: sui::package
Function: additive_policy
public fun additive_policy(): u8 { ADDITIVE }�j8 �move�u}�(j1 �package.move_21�j3 jP j5 Kj6 �vFile: sui/package.move
Module: sui::package
Function: dep_only_policy
public fun dep_only_policy(): u8 { DEP_ONLY }�j8 �move�u}�(j1 �package.move_22�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: only_additive_upgrades
fun only_additive_upgrades(cap: &mut UpgradeCap) {
restrict(cap, ADDITIVE)
}�j8 �move�u}�(j1 �package.move_23�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: only_dep_upgrades
fun only_dep_upgrades(cap: &mut UpgradeCap) {
restrict(cap, DEP_ONLY)
}�j8 �move�u}�(j1 �package.move_24�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: make_immutable
fun make_immutable(cap: UpgradeCap) {
let UpgradeCap { id, package: _, version: _, policy: _ }�j8 �move�u}�(j1 �package.move_25�j3 jP j5 Kj6 X: File: sui/package.move
Module: sui::package
Function: authorize_upgrade
public fun authorize_upgrade(
cap: &mut UpgradeCap,
policy: u8,
digest: vector<u8>
): UpgradeTicket {
let id_zero = object::id_from_address(@0x0);
assert!(cap.package != id_zero, EAlreadyAuthorized);
assert!(policy >= cap.policy, ETooPermissive);
let package = cap.package;
cap.package = id_zero;
UpgradeTicket {
cap: object::id(cap),
package,
policy,
digest,
}�j8 �move�u}�(j1 �package.move_26�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: commit_upgrade
public fun commit_upgrade(
cap: &mut UpgradeCap,
receipt: UpgradeReceipt,
) {
let UpgradeReceipt { cap: cap_id, package }�j8 �move�u}�(j1 �package.move_27�j3 jP j5 Kj6 Xv File: sui/package.move
Module: sui::package
Function: test_claim
public fun test_claim<OTW: drop>(_: OTW, ctx: &mut TxContext): Publisher {
let type = type_name::get_with_original_ids<OTW>();
Publisher {
id: object::new(ctx),
package: type_name::get_address(&type),
module_name: type_name::get_module(&type),
}�j8 �move�u}�(j1 �package.move_28�j3 jP j5 Kj6 X File: sui/package.move
Module: sui::package
Function: test_publish
public fun test_publish(package: ID, ctx: &mut TxContext): UpgradeCap {
UpgradeCap {
id: object::new(ctx),
package,
version: 1,
policy: COMPATIBLE,
}�j8 �move�u}�(j1 �package.move_29�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: test_upgrade
public fun test_upgrade(ticket: UpgradeTicket): UpgradeReceipt {
let UpgradeTicket { cap, package, policy: _, digest: _ }�j8 �move�u}�(j1 �package.move_30�j3 jP j5 Kj6 ��File: sui/package.move
Module: sui::package
Function: restrict
fun restrict(cap: &mut UpgradeCap, policy: u8) {
assert!(cap.policy <= policy, ETooPermissive);
cap.policy = policy;
}�j8 �move�u}�(j1 �
borrow.move_0�j3 �docs/move_files/sui/borrow.move�j5 K j6 �/File: sui/borrow.move
Move Module: sui::borrow�j8 �move�u}�(j1 �
borrow.move_1�j3 j� j5 Kj6 X8 File: sui/borrow.move
Module: sui::borrow
Dependencies:
use it and put back in the end. Hot-potato `Borrow` makes
/// sure the object is returned and was not swapped for another one.
module sui::borrow {
use sui::object::{Self, ID};
use std::option::{Self, Option};
use sui::tx_context::{Self, TxContext};
�j8 �move�u}�(j1 �
borrow.move_2�j3 j� j5 Kj6 �QFile: sui/borrow.move
Module: sui::borrow
Struct: Borrow
ref: address, obj: ID�j8 �move�u}�(j1 �
borrow.move_3�j3 j� j5 Kj6 X File: sui/borrow.move
Module: sui::borrow
Function: new
public fun new<T: key + store>(value: T, ctx: &mut TxContext): Referent<T> {
Referent {
id: tx_context::fresh_object_address(ctx),
value: option::some(value)
}�j8 �move�u}�(j1 �
borrow.move_4�j3 j� j5 Kj6 X3 File: sui/borrow.move
Module: sui::borrow
Function: borrow
public fun borrow<T: key + store>(self: &mut Referent<T>): (T, Borrow) {
let value = option::extract(&mut self.value);
let id = object::id(&value);
(value, Borrow {
ref: self.id,
obj: id
}�j8 �move�u}�(j1 �
borrow.move_5�j3 j� j5 Kj6 ��File: sui/borrow.move
Module: sui::borrow
Function: put_back
public fun put_back<T: key + store>(self: &mut Referent<T>, value: T, borrow: Borrow) {
let Borrow { ref, obj }�j8 �move�u}�(j1 �
borrow.move_6�j3 j� j5 Kj6 ��File: sui/borrow.move
Module: sui::borrow
Function: destroy
public fun destroy<T: key + store>(self: Referent<T>): T {
let Referent { id: _, value }�j8 �move�u}�(j1 �
borrow.move_7�j3 j� j5 Kj6 ��File: sui/borrow.move
Module: sui::borrow
Function: test_borrow
fun test_borrow() {
let ctx = &mut sui::tx_context::dummy();
let ref = new(Test { id: object::new(ctx) }�j8 �move�u}�(j1 �
borrow.move_8�j3 j� j5 Kj6 ��File: sui/borrow.move
Module: sui::borrow
Function: test_object_swap
fun test_object_swap() {
let ctx = &mut sui::tx_context::dummy();
let ref_1 = new(Test { id: object::new(ctx) }�j8 �move�u}�(j1 �
borrow.move_9�j3 j� j5 K j6 ��File: sui/borrow.move
Module: sui::borrow
Function: test_borrow_fail
fun test_borrow_fail() {
let ctx = &mut sui::tx_context::dummy();
let ref_1 = new(Test { id: object::new(ctx) }�j8 �move�u}�(j1 �entry_funs.move_0�j3 �#docs/move_files/sui/entry_funs.move�j5 K j6 �6File: sui/entry_funs.move
Move Module: unknown_module�j8 �move�u}�(j1 �multi_index_test.move_0�j3 �)docs/move_files/sui/multi_index_test.move�j5 K j6 �4File: sui/multi_index_test.move
Move Module: 0x1::m�j8 �move�u}�(j1 �multi_index_test.move_1�j3 j� j5 Kj6 ��File: sui/multi_index_test.move
Module: 0x1::m
Function: f
fun f() {
x[];
x[1, f()];
x[1, 2, 3];
}�j8 �move�u}�(j1 �mut_space.move_0�j3 �"docs/move_files/sui/mut_space.move�j5 K j6 �5File: sui/mut_space.move
Move Module: unknown_module�j8 �move�u}�(j1 �mut_space.move_1�j3 j j5 Kj6 �DFile: sui/mut_space.move
Module: unknown_module
Struct: S
f: u64,�j8 �move�u}�(j1 �mut_space.move_2�j3 j j5 Kj6 ��File: sui/mut_space.move
Module: unknown_module
Function: foo
public fun foo(x: & mut S): & mut u64 {
& mut x.f;
&
mut x.f
}�j8 �move�u}�(j1 �labels1.move_0�j3 � docs/move_files/sui/labels1.move�j5 K j6 �,File: sui/labels1.move
Move Module: 0x42::M�j8 �move�u}�(j1 �labels1.move_1�j3 j j5 Kj6 �LFile: sui/labels1.move
Module: 0x42::M
Function: bar
fun bar(): u64 { 0 }�j8 �move�u}�(j1 �labels1.move_2�j3 j j5 Kj6 �yFile: sui/labels1.move
Module: 0x42::M
Function: t
fun t(): u64 { 'r: {
// loop
1 + 'a: loop { foo() }�j8 �move�u}�(j1 �match_at_binders1.move_0�j3 �*docs/move_files/sui/match_at_binders1.move�j5 K j6 �6File: sui/match_at_binders1.move
Move Module: 0x42::m�j8 �move�u}�(j1 �match_at_binders1.move_1�j3 j j5 Kj6 ��File: sui/match_at_binders1.move
Module: 0x42::m
Function: test_04
fun test_04<T: drop>(x: Maybe<T>, other: Maybe<T>): Maybe<T> {
match (x) {
(x @ Maybe::Nothing) | (x @ Maybe::Just(_)) => other,
}�j8 �move�u}�(j1 �native_structs.move_0�j3 �'docs/move_files/sui/native_structs.move�j5 K j6 �2File: sui/native_structs.move
Move Module: s::foo�j8 �move�u}�(j1 �
macros.move_0�j3 �docs/move_files/sui/macros.move�j5 K j6 �HFile: sui/macros.move
Module: unknown_module
Header Comments:
/// This�j8 �move�u}�(j1 �
macros.move_1�j3 j, j5 Kj6 �2File: sui/macros.move
Move Module: unknown_module�j8 �move�u}�(j1 �
macros.move_2�j3 j, j5 Kj6 X File: sui/macros.move
Module: unknown_module
Dependencies:
use std::string::String;
use of this, we need to check if `i > stop` and return early--instead of letting the
// loop bound handle it, like in the `range_do` macro.
if (i > stop) return;
�j8 �move�u}�(j1 �
macros.move_3�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: num_max
fun num_max<$T>($x: $T, $y: $T): $T {
let x = $x;
let y = $y;
if (x > y) x
else y
}�j8 �move�u}�(j1 �
macros.move_4�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: num_min
fun num_min<$T>($x: $T, $y: $T): $T {
let x = $x;
let y = $y;
if (x < y) x
else y
}�j8 �move�u}�(j1 �
macros.move_5�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: num_diff
fun num_diff<$T>($x: $T, $y: $T): $T {
let x = $x;
let y = $y;
if (x > y) x - y
else y - x
}�j8 �move�u}�(j1 �
macros.move_6�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: num_divide_and_round_up
fun num_divide_and_round_up<$T>($x: $T, $y: $T): $T {
let x = $x;
let y = $y;
if (x % y == 0) x / y
else x / y + 1
}�j8 �move�u}�(j1 �
macros.move_7�j3 j, j5 Kj6 XH File: sui/macros.move
Module: unknown_module
Function: num_pow
fun num_pow($base: _, $exponent: u8): _ {
let mut base = $base;
let mut exponent = $exponent;
let mut res = 1;
while (exponent >= 1) {
if (exponent % 2 == 0) {
base = base * base;
exponent = exponent / 2;
}�j8 �move�u}�(j1 �
macros.move_8�j3 j, j5 Kj6 Xc File: sui/macros.move
Module: unknown_module
Function: num_sqrt
fun num_sqrt<$T, $U>($x: $T, $bitsize: u8): $T {
let x = $x;
let mut bit = (1: $U) << $bitsize;
let mut res = (0: $U);
let mut x = x as $U;
while (bit != 0) {
if (x >= res + bit) {
x = x - (res + bit);
res = (res >> 1) + bit;
}�j8 �move�u}�(j1 �
macros.move_9�j3 j, j5 K j6 ��File: sui/macros.move
Module: unknown_module
Function: num_to_string
fun num_to_string($x: _): String {
let mut x = $x;
if (x == 0) {
return b"0".to_string()
}�j8 �move�u}�(j1 �macros.move_10�j3 j, j5 K
j6 ��File: sui/macros.move
Module: unknown_module
Function: range_do
fun range_do<$T, $R: drop>($start: $T, $stop: $T, $f: |$T| -> $R) {
let mut i = $start;
let stop = $stop;
while (i < stop) {
$f(i);
i = i + 1;
}�j8 �move�u}�(j1 �macros.move_11�j3 j, j5 Kj6 XU File: sui/macros.move
Module: unknown_module
Function: range_do_eq
fun range_do_eq<$T, $R: drop>($start: $T, $stop: $T, $f: |$T| -> $R) {
let mut i = $start;
let stop = $stop;
// we check `i >= stop` inside the loop instead of `i <= stop` as `while` condition to avoid
// incrementing `i` past the MAX integer value.
// Because of this, we need to check if `i > stop` and return early--instead of letting the
// loop bound handle it, like in the `range_do` macro.
if (i > stop) return;
loop {
$f(i);
if (i >= stop) break;
i = i + 1;
}�j8 �move�u}�(j1 �macros.move_12�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: do
fun do<$T, $R: drop>($stop: $T, $f: |$T| -> $R) {
range_do!(0, $stop, $f)
}�j8 �move�u}�(j1 �macros.move_13�j3 j, j5 K
j6 ��File: sui/macros.move
Module: unknown_module
Function: do_eq
fun do_eq<$T, $R: drop>($stop: $T, $f: |$T| -> $R) {
range_do_eq!(0, $stop, $f)
}�j8 �move�u}�(j1 �macros.move_14�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: try_as_u8
fun try_as_u8($x: _): Option<u8> {
let x = $x;
if (x > 0xFF) option::none()
else option::some(x as u8)
}�j8 �move�u}�(j1 �macros.move_15�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: try_as_u16
fun try_as_u16($x: _): Option<u16> {
let x = $x;
if (x > 0xFFFF) option::none()
else option::some(x as u16)
}�j8 �move�u}�(j1 �macros.move_16�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: try_as_u32
fun try_as_u32($x: _): Option<u32> {
let x = $x;
if (x > 0xFFFF_FFFF) option::none()
else option::some(x as u32)
}�j8 �move�u}�(j1 �macros.move_17�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: try_as_u64
fun try_as_u64($x: _): Option<u64> {
let x = $x;
if (x > 0xFFFF_FFFF_FFFF_FFFF) option::none()
else option::some(x as u64)
}�j8 �move�u}�(j1 �macros.move_18�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: try_as_u128
fun try_as_u128($x: _): Option<u128> {
let x = $x;
if (x > 0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF) option::none()
else option::some(x as u128)
}�j8 �move�u}�(j1 �macros.move_19�j3 j, j5 Kj6 X� File: sui/macros.move
Module: unknown_module
Function: uq_from_quotient
fun uq_from_quotient<$T, $U>(
$numerator: $T,
$denominator: $T,
$max_t: $T,
$t_bits: u8,
$fractional_bits: u8,
$abort_denominator: _,
$abort_quotient_too_small: _,
$abort_quotient_too_large: _,
): $T {
let numerator = $numerator;
let denominator = $denominator;
if (denominator == 0) $abort_denominator;
// Scale the numerator to have `$t_bits` fractional bits and the denominator to have
// `$t_bits - $fractional_bits` fractional bits, so that the quotient will have
// `$fractional_bits` fractional bits.
let scaled_numerator = numerator as $U << $t_bits;
let scaled_denominator = denominator as $U << ($t_bits - $fractional_bits);
let quotient = scaled_numerator / scaled_denominator;
// The quotient can only be zero if the numerator is also zero.
if (quotient == 0 && numerator != 0) $abort_quotient_too_small;
// Return the quotient as a fixed-point number. We first need to check whether the cast
// can succeed.
if (quotient > $max_t as $U) $abort_quotient_too_large;
quotient as $T
}�j8 �move�u}�(j1 �macros.move_20�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: uq_from_int
fun uq_from_int<$T, $U>($integer: $T, $fractional_bits: u8): $U {
($integer as $U) << $fractional_bits
}�j8 �move�u}�(j1 �macros.move_21�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: uq_add
fun uq_add<$T, $U>($a: $T, $b: $T, $max_t: $T, $abort_overflow: _): $T {
let sum = $a as $U + ($b as $U);
if (sum > $max_t as $U) $abort_overflow;
sum as $T
}�j8 �move�u}�(j1 �macros.move_22�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: uq_sub
fun uq_sub<$T>($a: $T, $b: $T, $abort_overflow: _): $T {
let a = $a;
let b = $b;
if (a < b) $abort_overflow;
a - b
}�j8 �move�u}�(j1 �macros.move_23�j3 j, j5 Kj6 ��File: sui/macros.move
Module: unknown_module
Function: uq_to_int
fun uq_to_int<$T, $U>($a: $U, $fractional_bits: u8): $T {
($a >> $fractional_bits) as $T
}�j8 �move�u}�(j1 �macros.move_24�j3 j, j5 Kj6 X File: sui/macros.move
Module: unknown_module
Function: uq_int_mul
fun uq_int_mul<$T, $U>(
$val: $T,
$multiplier: $T,
$max_t: $T,
$fractional_bits: u8,
$abort_overflow: _,
): $T {
// The product of two `$T` bit values has the same number of bits as `$U`, so perform the
// multiplication with `$U` types and keep the full `$U` bit product
// to avoid losing accuracy.
let unscaled_product = $val as $U * ($multiplier as $U);
// The unscaled product has `$fractional_bits` fractional bits (from the multiplier)
// so rescale it by shifting away the low bits.
let product = unscaled_product >> $fractional_bits;
// Check whether the value is too large.
if (product > $max_t as $U) $abort_overflow;
product as $T
}�j8 �move�u}�(j1 �macros.move_25�j3 j, j5 Kj6 X� File: sui/macros.move
Module: unknown_module
Function: uq_int_div
fun uq_int_div<$T, $U>(
$val: $T,
$divisor: $T,
$max_t: $T,
$fractional_bits: u8,
$abort_division_by_zero: _,
$abort_overflow: _,
): $T {
let val = $val;
let divisor = $divisor;
// Check for division by zero.
if (divisor == 0) $abort_division_by_zero;
// First convert to $U to increase the number of bits to the next integer size
// and then shift left to add `$fractional_bits` fractional zero bits to the dividend.
let scaled_value = val as $U << $fractional_bits;
let quotient = scaled_value / (divisor as $U);
// Check whether the value is too large.
if (quotient > $max_t as $U) $abort_overflow;
quotient as $T
}�j8 �move�u}�(j1 �priority_queue.move_0�j3 �'docs/move_files/sui/priority_queue.move�j5 K j6 �?File: sui/priority_queue.move
Move Module: sui::priority_queue�j8 �move�u}�(j1 �priority_queue.move_1�j3 j� j5 Kj6 X� File: sui/priority_queue.move
Module: sui::priority_queue
Dependencies:
use std::vector;
use of the incorrect usage
// of `remove`, and the resulting new root and its two children appear to satisfy the heap invariant
// so we stop max-heapifying there, while the rest of the tree is all messed up because of the shift.
let priorities = vector[8, 7, 3, 6, 2, 1, 0, 5, 4];
�j8 �move�u}�(j1 �priority_queue.move_2�j3 j� j5 Kj6 X� File: sui/priority_queue.move
Module: sui::priority_queue
Function: new
public fun new<T: drop>(entries: vector<Entry<T>>) : PriorityQueue<T> {
let len = vector::length(&entries);
let i = len / 2;
// Max heapify from the first node that is a parent (node at len / 2).
while (i > 0) {
i = i - 1;
max_heapify_recursive(&mut entries, len, i);
}�j8 �move�u}�(j1 �priority_queue.move_3�j3 j� j5 Kj6 Xu File: sui/priority_queue.move
Module: sui::priority_queue
Function: pop_max
public fun pop_max<T: drop>(pq: &mut PriorityQueue<T>) : (u64, T) {
let len = vector::length(&pq.entries);
assert!(len > 0, EPopFromEmptyHeap);
// Swap the max element with the last element in the entries and remove the max element.
let Entry { priority, value }�j8 �move�u}�(j1 �priority_queue.move_4�j3 j� j5 Kj6 ��File: sui/priority_queue.move
Module: sui::priority_queue
Function: insert
public fun insert<T: drop>(pq: &mut PriorityQueue<T>, priority: u64, value: T) {
vector::push_back(&mut pq.entries, Entry { priority, value}�j8 �move�u}�(j1 �priority_queue.move_5�j3 j� j5 Kj6 ��File: sui/priority_queue.move
Module: sui::priority_queue
Function: new_entry
public fun new_entry<T: drop>(priority: u64, value: T): Entry<T> {
Entry { priority, value }�j8 �move�u}�(j1 �priority_queue.move_6�j3 j� j5 Kj6 X� File: sui/priority_queue.move
Module: sui::priority_queue
Function: create_entries
public fun create_entries<T: drop>(p: vector<u64>, v: vector<T>): vector<Entry<T>> {
let len = vector::length(&p);
assert!(vector::length(&v) == len, 0);
let res = vector::empty();
let i = 0;
while (i < len) {
let priority = vector::remove(&mut p, 0);
let value = vector::remove(&mut v, 0);
vector::push_back(&mut res, Entry { priority, value }�j8 �move�u}�(j1 �priority_queue.move_7�j3 j� j5 Kj6 ��File: sui/priority_queue.move
Module: sui::priority_queue
Function: restore_heap_recursive
fun restore_heap_recursive<T: drop>(v: &mut vector<Entry<T>>, i: u64) {
if (i == 0) {
return
}�j8 �move�u}�(j1 �priority_queue.move_8�j3 j� j5 Kj6 ��File: sui/priority_queue.move
Module: sui::priority_queue
Function: max_heapify_recursive
fun max_heapify_recursive<T: drop>(v: &mut vector<Entry<T>>, len: u64, i: u64) {
if (len == 0) {
return
}�j8 �move�u}�(j1 �priority_queue.move_9�j3 j� j5 K j6 Xi File: sui/priority_queue.move
Module: sui::priority_queue
Function: priorities
public fun priorities<T: drop>(pq: &PriorityQueue<T>): vector<u64> {
let res = vector[];
let i = 0;
while (i < vector::length(&pq.entries)) {
vector::push_back(&mut res, vector::borrow(&pq.entries, i).priority);
i = i +1;
}�j8 �move�u}�(j1 �priority_queue.move_10�j3 j� j5 K
j6 X@ File: sui/priority_queue.move
Module: sui::priority_queue
Function: test_pq
fun test_pq() {
let h = new(create_entries(vector[3,1,4,2,5,2], vector[10, 20, 30, 40, 50, 60]));
check_pop_max(&mut h, 5, 50);
check_pop_max(&mut h, 4, 30);
check_pop_max(&mut h, 3, 10);
insert(&mut h, 7, 70);
check_pop_max(&mut h, 7, 70);
check_pop_max(&mut h, 2, 40);
insert(&mut h, 0, 80);
check_pop_max(&mut h, 2, 60);
check_pop_max(&mut h, 1, 20);
check_pop_max(&mut h, 0, 80);
let h = new(create_entries(vector[5,3,1,2,4], vector[10, 20, 30, 40, 50]));
check_pop_max(&mut h, 5, 10);
check_pop_max(&mut h, 4, 50);
check_pop_max(&mut h, 3, 20);
check_pop_max(&mut h, 2, 40);
check_pop_max(&mut h, 1, 30);
}�j8 �move�u}�(j1 �priority_queue.move_11�j3 j� j5 Kj6 X� File: sui/priority_queue.move
Module: sui::priority_queue
Function: test_swap_remove_edge_case
fun test_swap_remove_edge_case() {
// This test would fail if `remove` is used incorrectly instead of `swap_remove` in `pop_max`.
// It's hard to characterize exactly under what condition this bug is triggered but roughly
// it happens when the entire tree vector is shifted left by one because of the incorrect usage
// of `remove`, and the resulting new root and its two children appear to satisfy the heap invariant
// so we stop max-heapifying there, while the rest of the tree is all messed up because of the shift.
let priorities = vector[8, 7, 3, 6, 2, 1, 0, 5, 4];
let values = vector[0, 0, 0, 0, 0, 0, 0, 0, 0];
let h = new(create_entries(priorities, values));
check_pop_max(&mut h, 8, 0);
check_pop_max(&mut h, 7, 0);
check_pop_max(&mut h, 6, 0);
check_pop_max(&mut h, 5, 0);
check_pop_max(&mut h, 4, 0);
check_pop_max(&mut h, 3, 0);
check_pop_max(&mut h, 2, 0);
check_pop_max(&mut h, 1, 0);
check_pop_max(&mut h, 0, 0);
}�j8 �move�u}�(j1 �priority_queue.move_12�j3 j� j5 Kj6 XC File: sui/priority_queue.move
Module: sui::priority_queue
Function: check_pop_max
fun check_pop_max(h: &mut PriorityQueue<u64>, expected_priority: u64, expected_value: u64) {
let (priority, value) = pop_max(h);
assert!(priority == expected_priority, 0);
assert!(value == expected_value, 0);
}�j8 �move�u}�(j1 �unit_test.move_0�j3 �"docs/move_files/sui/unit_test.move�j5 K j6 �5File: sui/unit_test.move
Move Module: unknown_module�j8 �move�u}�(j1 �unit_test.move_1�j3 j� j5 Kj6 ��File: sui/unit_test.move
Module: unknown_module
Dependencies:
use a linking failure if an attempt is made to publish a
/// test module in a VM that isn't in unit test mode.
public native fun poison();
�j8 �move�u}�(j1 �unit_test.move_2�j3 j� j5 Kj6 ��File: sui/unit_test.move
Module: unknown_module
Function: assert_eq
fun assert_eq<$T: drop>($t1: $T, $t2: $T) {
let t1 = $t1;
let t2 = $t2;
assert_ref_eq!(&t1, &t2)
}�j8 �move�u}�(j1 �unit_test.move_3�j3 j� j5 Kj6 X� File: sui/unit_test.move
Module: unknown_module
Function: assert_ref_eq
fun assert_ref_eq<$T>($t1: &$T, $t2: &$T) {
let t1 = $t1;
let t2 = $t2;
let res = t1 == t2;
if (!res) {
std::debug::print(&b"Assertion failed:".to_string());
std::debug::print(t1);
std::debug::print(&b"!=".to_string());
std::debug::print(t2);
assert!(false);
}�j8 �move�u}�(j1 �
string.move_0�j3 �docs/move_files/sui/string.move�j5 K j6 �PFile: sui/string.move
Module: unknown_module
Header Comments:
/// The `string`�j8 �move�u}�(j1 �
string.move_1�j3 j� j5 Kj6 �2File: sui/string.move
Move Module: unknown_module�j8 �move�u}�(j1 �
string.move_2�j3 j� j5 Kj6 �MFile: sui/string.move
Module: unknown_module
Dependencies:
use std::ascii;
�j8 �move�u}�(j1 �
string.move_3�j3 j� j5 Kj6 ��File: sui/string.move
Module: unknown_module
Function: utf8
public fun utf8(bytes: vector<u8>): String {
assert!(internal_check_utf8(&bytes), EInvalidUTF8);
String { bytes }�j8 �move�u}�(j1 �
string.move_4�j3 j� j5 Kj6 ��File: sui/string.move
Module: unknown_module
Function: from_ascii
public fun from_ascii(s: ascii::String): String {
String { bytes: s.into_bytes() }�j8 �move�u}�(j1 �
string.move_5�j3 j� j5 Kj6 ��File: sui/string.move
Module: unknown_module
Function: to_ascii
public fun to_ascii(s: String): ascii::String {
let String { bytes }�j8 �move�u}�(j1 �
string.move_6�j3 j� j5 Kj6 ��File: sui/string.move
Module: unknown_module
Function: try_utf8
public fun try_utf8(bytes: vector<u8>): Option<String> {
if (internal_check_utf8(&bytes)) option::some(String { bytes }�j8 �move�u}�(j1 �
string.move_7�j3 j� j5 Kj6 ��File: sui/string.move
Module: unknown_module
Function: as_bytes
public fun as_bytes(s: &String): &vector<u8> {
&s.bytes
}�j8 �move�u}�(j1 �
string.move_8�j3 j� j5 Kj6 ��File: sui/string.move
Module: unknown_module
Function: into_bytes
public fun into_bytes(s: String): vector<u8> {
let String { bytes }�j8 �move�u}�(j1 �
string.move_9�j3 j� j5 K j6 ��File: sui/string.move
Module: unknown_module
Function: is_empty
public fun is_empty(s: &String): bool {
s.bytes.is_empty()
}�j8 �move�u}�(j1 �string.move_10�j3 j� j5 K
j6 �|File: sui/string.move
Module: unknown_module
Function: length
public fun length(s: &String): u64 {
s.bytes.length()
}�j8 �move�u}�(j1 �string.move_11�j3 j� j5 Kj6 ��File: sui/string.move
Module: unknown_module
Function: append
public fun append(s: &mut String, r: String) {
s.bytes.append(r.bytes)
}�j8 �move�u}�(j1 �string.move_12�j3 j� j5 Kj6 ��File: sui/string.move
Module: unknown_module
Function: append_utf8
public fun append_utf8(s: &mut String, bytes: vector<u8>) {
s.append(utf8(bytes))
}�j8 �move�u}�(j1 �string.move_13�j3 j� j5 K
j6 X� File: sui/string.move
Module: unknown_module
Function: insert
public fun insert(s: &mut String, at: u64, o: String) {
let bytes = &s.bytes;
assert!(at <= bytes.length() && internal_is_char_boundary(bytes, at), EInvalidIndex);
let l = s.length();
let mut front = s.substring(0, at);
let end = s.substring(at, l);
front.append(o);
front.append(end);
*s = front;
}�j8 �move�u}�(j1 �string.move_14�j3 j� j5 Kj6 X� File: sui/string.move
Module: unknown_module
Function: substring
public fun substring(s: &String, i: u64, j: u64): String {
let bytes = &s.bytes;
let l = bytes.length();
assert!(
j <= l &&
i <= j &&
internal_is_char_boundary(bytes, i) &&
internal_is_char_boundary(bytes, j),
EInvalidIndex,
);
String { bytes: internal_sub_string(bytes, i, j) }�j8 �move�u}�(j1 �string.move_15�j3 j� j5 Kj6 ��File: sui/string.move
Module: unknown_module
Function: index_of
public fun index_of(s: &String, r: &String): u64 {
internal_index_of(&s.bytes, &r.bytes)
}�j8 �move�u}�(j1 �string.move_16�j3 j� j5 Kj6 X� File: sui/string.move
Module: unknown_module
Function: internal_check_utf8
fun internal_check_utf8(v: &vector<u8>): bool;
native fun internal_is_char_boundary(v: &vector<u8>, i: u64): bool;
native fun internal_sub_string(v: &vector<u8>, i: u64, j: u64): vector<u8>;
native fun internal_index_of(v: &vector<u8>, r: &vector<u8>): u64;
// === Deprecated ===
#[deprecated(note = b"Use `std::string::as_bytes` instead.")]
public fun bytes(s: &String): &vector<u8> { s.as_bytes() }�j8 �move�u}�(j1 �string.move_17�j3 j� j5 Kj6 ��File: sui/string.move
Module: unknown_module
Function: sub_string
public fun sub_string(s: &String, i: u64, j: u64): String {
s.substring(i, j)
}�j8 �move�u}�(j1 �address.move_0�j3 � docs/move_files/sui/address.move�j5 K j6 �3File: sui/address.move
Move Module: unknown_module�j8 �move�u}�(j1 �address.move_1�j3 j$ j5 Kj6 �eFile: sui/address.move
Module: unknown_module
Function: length
public fun length(): u64 {
32
}�j8 �move�u}�(j1 �u256.move_0�j3 �docs/move_files/sui/u256.move�j5 K j6 �0File: sui/u256.move
Move Module: unknown_module�j8 �move�u}�(j1 �u256.move_1�j3 j- j5 Kj6 �TFile: sui/u256.move
Module: unknown_module
Dependencies:
use std::string::String;
�j8 �move�u}�(j1 �u256.move_2�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: bitwise_not
public fun bitwise_not(x: u256): u256 {
x ^ max_value!()
}�j8 �move�u}�(j1 �u256.move_3�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: max
public fun max(x: u256, y: u256): u256 {
std::macros::num_max!(x, y)
}�j8 �move�u}�(j1 �u256.move_4�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: min
public fun min(x: u256, y: u256): u256 {
std::macros::num_min!(x, y)
}�j8 �move�u}�(j1 �u256.move_5�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: diff
public fun diff(x: u256, y: u256): u256 {
std::macros::num_diff!(x, y)
}�j8 �move�u}�(j1 �u256.move_6�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: divide_and_round_up
public fun divide_and_round_up(x: u256, y: u256): u256 {
std::macros::num_divide_and_round_up!(x, y)
}�j8 �move�u}�(j1 �u256.move_7�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: pow
public fun pow(base: u256, exponent: u8): u256 {
std::macros::num_pow!(base, exponent)
}�j8 �move�u}�(j1 �u256.move_8�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: try_as_u8
public fun try_as_u8(x: u256): Option<u8> {
std::macros::try_as_u8!(x)
}�j8 �move�u}�(j1 �u256.move_9�j3 j- j5 K j6 ��File: sui/u256.move
Module: unknown_module
Function: try_as_u16
public fun try_as_u16(x: u256): Option<u16> {
std::macros::try_as_u16!(x)
}�j8 �move�u}�(j1 �u256.move_10�j3 j- j5 K
j6 ��File: sui/u256.move
Module: unknown_module
Function: try_as_u32
public fun try_as_u32(x: u256): Option<u32> {
std::macros::try_as_u32!(x)
}�j8 �move�u}�(j1 �u256.move_11�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: try_as_u64
public fun try_as_u64(x: u256): Option<u64> {
std::macros::try_as_u64!(x)
}�j8 �move�u}�(j1 �u256.move_12�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: try_as_u128
public fun try_as_u128(x: u256): Option<u128> {
std::macros::try_as_u128!(x)
}�j8 �move�u}�(j1 �u256.move_13�j3 j- j5 K
j6 ��File: sui/u256.move
Module: unknown_module
Function: to_string
public fun to_string(x: u256): String {
std::macros::num_to_string!(x)
}�j8 �move�u}�(j1 �u256.move_14�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: max_value
fun max_value(): u256 {
0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF
}�j8 �move�u}�(j1 �u256.move_15�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: range_do
fun range_do<$R: drop>($start: u256, $stop: u256, $f: |u256| -> $R) {
std::macros::range_do!($start, $stop, $f)
}�j8 �move�u}�(j1 �u256.move_16�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: range_do_eq
fun range_do_eq<$R: drop>($start: u256, $stop: u256, $f: |u256| -> $R) {
std::macros::range_do_eq!($start, $stop, $f)
}�j8 �move�u}�(j1 �u256.move_17�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: do
fun do<$R: drop>($stop: u256, $f: |u256| -> $R) {
std::macros::do!($stop, $f)
}�j8 �move�u}�(j1 �u256.move_18�j3 j- j5 Kj6 ��File: sui/u256.move
Module: unknown_module
Function: do_eq
fun do_eq<$R: drop>($stop: u256, $f: |u256| -> $R) {
std::macros::do_eq!($stop, $f)
}�j8 �move�u}�(j1 �u128.move_0�j3 �docs/move_files/sui/u128.move�j5 K j6 �0File: sui/u128.move
Move Module: unknown_module�j8 �move�u}�(j1 �u128.move_1�j3 jz j5 Kj6 X_ File: sui/u128.move
Module: unknown_module
Dependencies:
use std::string::String;
use higher values or temporarily multiply the
/// value by some bigger number. Ideally if this is a square of 10 or 100.
///
/// Example:
/// ```
/// math::sqrt(8) => 2;
use this value as if it was 2.82;
use sqrt(10000)).
///
///
/// math::sqrt(8 * 1000000) => 2828;
�j8 �move�u}�(j1 �u128.move_2�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: bitwise_not
public fun bitwise_not(x: u128): u128 {
x ^ max_value!()
}�j8 �move�u}�(j1 �u128.move_3�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: max
public fun max(x: u128, y: u128): u128 {
std::macros::num_max!(x, y)
}�j8 �move�u}�(j1 �u128.move_4�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: min
public fun min(x: u128, y: u128): u128 {
std::macros::num_min!(x, y)
}�j8 �move�u}�(j1 �u128.move_5�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: diff
public fun diff(x: u128, y: u128): u128 {
std::macros::num_diff!(x, y)
}�j8 �move�u}�(j1 �u128.move_6�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: divide_and_round_up
public fun divide_and_round_up(x: u128, y: u128): u128 {
std::macros::num_divide_and_round_up!(x, y)
}�j8 �move�u}�(j1 �u128.move_7�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: pow
public fun pow(base: u128, exponent: u8): u128 {
std::macros::num_pow!(base, exponent)
}�j8 �move�u}�(j1 �u128.move_8�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: sqrt
public fun sqrt(x: u128): u128 {
std::macros::num_sqrt!<u128, u256>(x, 128)
}�j8 �move�u}�(j1 �u128.move_9�j3 jz j5 K j6 ��File: sui/u128.move
Module: unknown_module
Function: try_as_u8
public fun try_as_u8(x: u128): Option<u8> {
std::macros::try_as_u8!(x)
}�j8 �move�u}�(j1 �u128.move_10�j3 jz j5 K
j6 ��File: sui/u128.move
Module: unknown_module
Function: try_as_u16
public fun try_as_u16(x: u128): Option<u16> {
std::macros::try_as_u16!(x)
}�j8 �move�u}�(j1 �u128.move_11�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: try_as_u32
public fun try_as_u32(x: u128): Option<u32> {
std::macros::try_as_u32!(x)
}�j8 �move�u}�(j1 �u128.move_12�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: try_as_u64
public fun try_as_u64(x: u128): Option<u64> {
std::macros::try_as_u64!(x)
}�j8 �move�u}�(j1 �u128.move_13�j3 jz j5 K
j6 ��File: sui/u128.move
Module: unknown_module
Function: to_string
public fun to_string(x: u128): String {
std::macros::num_to_string!(x)
}�j8 �move�u}�(j1 �u128.move_14�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: max_value
fun max_value(): u128 {
0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF
}�j8 �move�u� }�(j1 �u128.move_15�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: range_do
fun range_do<$R: drop>($start: u128, $stop: u128, $f: |u128| -> $R) {
std::macros::range_do!($start, $stop, $f)
}�j8 �move�u}�(j1 �u128.move_16�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: range_do_eq
fun range_do_eq<$R: drop>($start: u128, $stop: u128, $f: |u128| -> $R) {
std::macros::range_do_eq!($start, $stop, $f)
}�j8 �move�u}�(j1 �u128.move_17�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: do
fun do<$R: drop>($stop: u128, $f: |u128| -> $R) {
std::macros::do!($stop, $f)
}�j8 �move�u}�(j1 �u128.move_18�j3 jz j5 Kj6 ��File: sui/u128.move
Module: unknown_module
Function: do_eq
fun do_eq<$R: drop>($stop: u128, $f: |u128| -> $R) {
std::macros::do_eq!($stop, $f)
}�j8 �move�u}�(j1 �
bcs.move_0�j3 �docs/move_files/sui/bcs.move�j5 K j6 ��File: sui/bcs.move
Module: unknown_module
Header Comments:
/// Serialization). BCS is the binary encoding for Move resources and other non-�j8 �move�u}�(j1 �
bcs.move_1�j3 j� j5 Kj6 �/File: sui/bcs.move
Move Module: unknown_module�j8 �move�u}�(j1 �hash.move_0�j3 �docs/move_files/sui/hash.move�j5 K j6 �WFile: sui/hash.move
Module: unknown_module
Header Comments:
/// The functions in this�j8 �move�u}�(j1 �hash.move_1�j3 j� j5 Kj6 �0File: sui/hash.move
Move Module: unknown_module�j8 �move�u}�(j1 �
option.move_0�j3 �docs/move_files/sui/option.move�j5 K j6 �HFile: sui/option.move
Module: unknown_module
Header Comments:
/// This�j8 �move�u}�(j1 �
option.move_1�j3 j� j5 Kj6 �2File: sui/option.move
Move Module: unknown_module�j8 �move�u}�(j1 �
option.move_2�j3 j� j5 Kj6 XV File: sui/option.move
Module: unknown_module
Dependencies:
use Move bytecode does not have ADTs.
public struct Option<Element> has copy, drop, store {
vec: vector<Element>,
}
/// The `Option` is in an invalid state for the operation attempted.
/// The `Option` is `Some` while it should be `None`.
const EOPTION_IS_SET: u64 = 0x40000;
�j8 �move�u}�(j1 �
option.move_3�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: none
public fun none<Element>(): Option<Element> {
Option { vec: vector::empty() }�j8 �move�u}�(j1 �
option.move_4�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: some
public fun some<Element>(e: Element): Option<Element> {
Option { vec: vector::singleton(e) }�j8 �move�u}�(j1 �
option.move_5�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: is_none
public fun is_none<Element>(t: &Option<Element>): bool {
t.vec.is_empty()
}�j8 �move�u}�(j1 �
option.move_6�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: is_some
public fun is_some<Element>(t: &Option<Element>): bool {
!t.vec.is_empty()
}�j8 �move�u}�(j1 �
option.move_7�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: contains
public fun contains<Element>(t: &Option<Element>, e_ref: &Element): bool {
t.vec.contains(e_ref)
}�j8 �move�u}�(j1 �
option.move_8�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: borrow
public fun borrow<Element>(t: &Option<Element>): &Element {
assert!(t.is_some(), EOPTION_NOT_SET);
&t.vec[0]
}�j8 �move�u}�(j1 �
option.move_9�j3 j� j5 K j6 X File: sui/option.move
Module: unknown_module
Function: borrow_with_default
public fun borrow_with_default<Element>(t: &Option<Element>, default_ref: &Element): &Element {
let vec_ref = &t.vec;
if (vec_ref.is_empty()) default_ref
else &vec_ref[0]
}�j8 �move�u}�(j1 �option.move_10�j3 j� j5 K
j6 X File: sui/option.move
Module: unknown_module
Function: get_with_default
public fun get_with_default<Element: copy + drop>(t: &Option<Element>, default: Element): Element {
let vec_ref = &t.vec;
if (vec_ref.is_empty()) default
else vec_ref[0]
}�j8 �move�u}�(j1 �option.move_11�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: fill
public fun fill<Element>(t: &mut Option<Element>, e: Element) {
let vec_ref = &mut t.vec;
if (vec_ref.is_empty()) vec_ref.push_back(e)
else abort EOPTION_IS_SET
}�j8 �move�u}�(j1 �option.move_12�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: extract
public fun extract<Element>(t: &mut Option<Element>): Element {
assert!(t.is_some(), EOPTION_NOT_SET);
t.vec.pop_back()
}�j8 �move�u}�(j1 �option.move_13�j3 j� j5 K
j6 ��File: sui/option.move
Module: unknown_module
Function: borrow_mut
public fun borrow_mut<Element>(t: &mut Option<Element>): &mut Element {
assert!(t.is_some(), EOPTION_NOT_SET);
&mut t.vec[0]
}�j8 �move�u}�(j1 �option.move_14�j3 j� j5 Kj6 X" File: sui/option.move
Module: unknown_module
Function: swap
public fun swap<Element>(t: &mut Option<Element>, e: Element): Element {
assert!(t.is_some(), EOPTION_NOT_SET);
let vec_ref = &mut t.vec;
let old_value = vec_ref.pop_back();
vec_ref.push_back(e);
old_value
}�j8 �move�u}�(j1 �option.move_15�j3 j� j5 Kj6 X= File: sui/option.move
Module: unknown_module
Function: swap_or_fill
public fun swap_or_fill<Element>(t: &mut Option<Element>, e: Element): Option<Element> {
let vec_ref = &mut t.vec;
let old_value = if (vec_ref.is_empty()) none()
else some(vec_ref.pop_back());
vec_ref.push_back(e);
old_value
}�j8 �move�u}�(j1 �option.move_16�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: destroy_with_default
public fun destroy_with_default<Element: drop>(t: Option<Element>, default: Element): Element {
let Option { mut vec }�j8 �move�u}�(j1 �option.move_17�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: destroy_some
public fun destroy_some<Element>(t: Option<Element>): Element {
assert!(t.is_some(), EOPTION_NOT_SET);
let Option { mut vec }�j8 �move�u}�(j1 �option.move_18�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: destroy_none
public fun destroy_none<Element>(t: Option<Element>) {
assert!(t.is_none(), EOPTION_IS_SET);
let Option { vec }�j8 �move�u}�(j1 �option.move_19�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: to_vec
public fun to_vec<Element>(t: Option<Element>): vector<Element> {
let Option { vec }�j8 �move�u}�(j1 �option.move_20�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: destroy
fun destroy<$T, $R: drop>($o: Option<$T>, $f: |$T| -> $R) {
let o = $o;
o.do!($f);
}�j8 �move�u}�(j1 �option.move_21�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: do
fun do<$T, $R: drop>($o: Option<$T>, $f: |$T| -> $R) {
let o = $o;
if (o.is_some()) { $f(o.destroy_some()); }�j8 �move�u}�(j1 �option.move_22�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: do_ref
fun do_ref<$T, $R: drop>($o: &Option<$T>, $f: |&$T| -> $R) {
let o = $o;
if (o.is_some()) { $f(o.borrow()); }�j8 �move�u}�(j1 �option.move_23�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: do_mut
fun do_mut<$T, $R: drop>($o: &mut Option<$T>, $f: |&mut $T| -> $R) {
let o = $o;
if (o.is_some()) { $f(o.borrow_mut()); }�j8 �move�u}�(j1 �option.move_24�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: or
fun or<$T>($o: Option<$T>, $default: Option<$T>): Option<$T> {
let o = $o;
if (o.is_some()) {
o
}�j8 �move�u}�(j1 �option.move_25�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: and
fun and<$T, $U>($o: Option<$T>, $f: |$T| -> Option<$U>): Option<$U> {
let o = $o;
if (o.is_some()) {
$f(o.destroy_some())
}�j8 �move�u}�(j1 �option.move_26�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: and_ref
fun and_ref<$T, $U>($o: &Option<$T>, $f: |&$T| -> Option<$U>): Option<$U> {
let o = $o;
if (o.is_some()) $f(o.borrow())
else none()
}�j8 �move�u}�(j1 �option.move_27�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: map
fun map<$T, $U>($o: Option<$T>, $f: |$T| -> $U): Option<$U> {
let o = $o;
if (o.is_some()) {
some($f(o.destroy_some()))
}�j8 �move�u}�(j1 �option.move_28�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: map_ref
fun map_ref<$T, $U>($o: &Option<$T>, $f: |&$T| -> $U): Option<$U> {
let o = $o;
if (o.is_some()) some($f(o.borrow()))
else none()
}�j8 �move�u}�(j1 �option.move_29�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: filter
fun filter<$T: drop>($o: Option<$T>, $f: |&$T| -> bool): Option<$T> {
let o = $o;
if (o.is_some() && $f(o.borrow())) o
else none()
}�j8 �move�u}�(j1 �option.move_30�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: is_some_and
fun is_some_and<$T>($o: &Option<$T>, $f: |&$T| -> bool): bool {
let o = $o;
o.is_some() && $f(o.borrow())
}�j8 �move�u}�(j1 �option.move_31�j3 j� j5 Kj6 ��File: sui/option.move
Module: unknown_module
Function: destroy_or
fun destroy_or<$T>($o: Option<$T>, $default: $T): $T {
let o = $o;
if (o.is_some()) {
o.destroy_some()
}�j8 �move�u}�(j1 �bit_vector.move_0�j3 �#docs/move_files/sui/bit_vector.move�j5 K j6 �6File: sui/bit_vector.move
Move Module: unknown_module�j8 �move�u}�(j1 �bit_vector.move_1�j3 jZ j5 Kj6 X_ File: sui/bit_vector.move
Module: unknown_module
Function: new
public fun new(length: u64): BitVector {
assert!(length > 0, ELENGTH);
assert!(length < MAX_SIZE, ELENGTH);
let mut counter = 0;
let mut bit_field = vector::empty();
while (counter < length) {
bit_field.push_back(false);
counter = counter + 1;
}�j8 �move�u}�(j1 �bit_vector.move_2�j3 jZ j5 Kj6 ��File: sui/bit_vector.move
Module: unknown_module
Function: set
public fun set(bitvector: &mut BitVector, bit_index: u64) {
assert!(bit_index < bitvector.bit_field.length(), EINDEX);
let x = &mut bitvector.bit_field[bit_index];
*x = true;
}�j8 �move�u}�(j1 �bit_vector.move_3�j3 jZ j5 Kj6 X File: sui/bit_vector.move
Module: unknown_module
Function: unset
public fun unset(bitvector: &mut BitVector, bit_index: u64) {
assert!(bit_index < bitvector.bit_field.length(), EINDEX);
let x = &mut bitvector.bit_field[bit_index];
*x = false;
}�j8 �move�u}�(j1 �bit_vector.move_4�j3 jZ j5 Kj6 X File: sui/bit_vector.move
Module: unknown_module
Function: shift_left
public fun shift_left(bitvector: &mut BitVector, amount: u64) {
if (amount >= bitvector.length) {
let len = bitvector.bit_field.length();
let mut i = 0;
while (i < len) {
let elem = &mut bitvector.bit_field[i];
*elem = false;
i = i + 1;
}�j8 �move�u}�(j1 �bit_vector.move_5�j3 jZ j5 Kj6 ��File: sui/bit_vector.move
Module: unknown_module
Function: is_index_set
public fun is_index_set(bitvector: &BitVector, bit_index: u64): bool {
assert!(bit_index < bitvector.bit_field.length(), EINDEX);
bitvector.bit_field[bit_index]
}�j8 �move�u}�(j1 �bit_vector.move_6�j3 jZ j5 Kj6 ��File: sui/bit_vector.move
Module: unknown_module
Function: length
public fun length(bitvector: &BitVector): u64 {
bitvector.bit_field.length()
}�j8 �move�u}�(j1 �bit_vector.move_7�j3 jZ j5 Kj6 X� File: sui/bit_vector.move
Module: unknown_module
Function: longest_set_sequence_starting_at
public fun longest_set_sequence_starting_at(bitvector: &BitVector, start_index: u64): u64 {
assert!(start_index < bitvector.length, EINDEX);
let mut index = start_index;
// Find the greatest index in the vector such that all indices less than it are set.
while (index < bitvector.length) {
if (!bitvector.is_index_set(index)) break;
index = index + 1;
}�j8 �move�u}�(j1 �bit_vector.move_8�j3 jZ j5 Kj6 �uFile: sui/bit_vector.move
Module: unknown_module
Function: word_size
public fun word_size(): u64 {
WORD_SIZE
}�j8 �move�u}�(�id��package.move_0��path��docs/move_files/package.move��chunk_index�K �content��-File: package.move
Move Module: sui::package�� file_type��move�u}�(j~ �package.move_1�j� j� j� Kj� X File: package.move
Module: sui::package
Dependencies:
use sui::object::{Self, ID, UID};
use sui::tx_context::{TxContext, sender};
use std::ascii::String;
use std::type_name;
use sui::types;
use there is already a pending upgrade in the transaction.
/// Otherwise guaranteed to be the latest version of any given
/// package.
public fun upgrade_package(cap: &UpgradeCap): ID {
cap.package
}
/// The most recent version of the package, increments by one for each
/// successfully applied upgrade.
public fun version(cap: &UpgradeCap): u64 {
cap.version
}
/// The most permissive kind of upgrade currently supported by this
/// `cap`.
public fun upgrade_policy(cap: &UpgradeCap): u8 {
cap.policy
}
/// The package that this ticket is authorized to upgrade
public fun ticket_package(ticket: &UpgradeTicket): ID {
ticket.package
}
/// The kind of upgrade that this ticket authorizes.
public fun ticket_policy(ticket: &UpgradeTicket): u8 {
ticket.policy
}
/// ID of the `UpgradeCap` that this `receipt` should be used to
/// update.
public fun receipt_cap(receipt: &UpgradeReceipt): ID {
receipt.cap
}
/// ID of the package that was upgraded to: the latest version of
/// the package, as of the upgrade represented by this `receipt`.
public fun receipt_package(receipt: &UpgradeReceipt): ID {
receipt.package
}
/// A hash of the package contents for the new version of the
/// package. This ticket only authorizes an upgrade to a package
/// that matches this digest. A package's contents are identified
/// by two things:
///
/// - modules: [[u8]] a list of the package's module contents
/// - deps: [[u8;
�j� �move�u}�(j~ �package.move_2�j� j� j� Kj� X� File: package.move
Module: sui::package
Struct: UpgradeTicket
/// (Immutable) ID of the `UpgradeCap` this originated from.
cap: ID,
/// (Immutable) ID of the package that can be upgraded.
package: ID,
/// (Immutable) The policy regarding what kind of upgrade this ticket
/// permits.
policy: u8,
/// (Immutable) SHA256 digest of the bytecode and transitive
/// dependencies that will be used in the upgrade.
digest: vector<u8>,�j� �move�u}�(j~ �package.move_3�j� j� j� Kj� ��File: package.move
Module: sui::package
Struct: UpgradeReceipt
/// (Immutable) ID of the `UpgradeCap` this originated from.
cap: ID,
/// (Immutable) ID of the package after it was upgraded.
package: ID,�j� �move�u}�(j~ �package.move_4�j� j� j� Kj� X� File: package.move
Module: sui::package
Function: claim
public fun claim<OTW: drop>(otw: OTW, ctx: &mut TxContext): Publisher {
assert!(types::is_one_time_witness(&otw), ENotOneTimeWitness);
let type = type_name::get_with_original_ids<OTW>();
Publisher {
id: object::new(ctx),
package: type_name::get_address(&type),
module_name: type_name::get_module(&type),
}�j� �move�u}�(j~ �package.move_5�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: claim_and_keep
public fun claim_and_keep<OTW: drop>(otw: OTW, ctx: &mut TxContext) {
sui::transfer::public_transfer(claim(otw, ctx), sender(ctx))
}�j� �move�u}�(j~ �package.move_6�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: burn_publisher
public fun burn_publisher(self: Publisher) {
let Publisher { id, package: _, module_name: _ }�j� �move�u}�(j~ �package.move_7�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: from_package
public fun from_package<T>(self: &Publisher): bool {
let type = type_name::get_with_original_ids<T>();
(type_name::get_address(&type) == self.package)
}�j� �move�u}�(j~ �package.move_8�j� j� j� Kj� X/ File: package.move
Module: sui::package
Function: from_module
public fun from_module<T>(self: &Publisher): bool {
let type = type_name::get_with_original_ids<T>();
(type_name::get_address(&type) == self.package)
&& (type_name::get_module(&type) == self.module_name)
}�j� �move�u}�(j~ �package.move_9�j� j� j� K j� ��File: package.move
Module: sui::package
Function: published_module
public fun published_module(self: &Publisher): &String {
&self.module_name
}�j� �move�u}�(j~ �package.move_10�j� j� j� K
j� ��File: package.move
Module: sui::package
Function: published_package
public fun published_package(self: &Publisher): &String {
&self.package
}�j� �move�u}�(j~ �package.move_11�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: upgrade_package
public fun upgrade_package(cap: &UpgradeCap): ID {
cap.package
}�j� �move�u}�(j~ �package.move_12�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: version
public fun version(cap: &UpgradeCap): u64 {
cap.version
}�j� �move�u}�(j~ �package.move_13�j� j� j� K
j� ��File: package.move
Module: sui::package
Function: upgrade_policy
public fun upgrade_policy(cap: &UpgradeCap): u8 {
cap.policy
}�j� �move�u}�(j~ �package.move_14�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: ticket_package
public fun ticket_package(ticket: &UpgradeTicket): ID {
ticket.package
}�j� �move�u}�(j~ �package.move_15�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: ticket_policy
public fun ticket_policy(ticket: &UpgradeTicket): u8 {
ticket.policy
}�j� �move�u}�(j~ �package.move_16�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: receipt_cap
public fun receipt_cap(receipt: &UpgradeReceipt): ID {
receipt.cap
}�j� �move�u}�(j~ �package.move_17�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: receipt_package
public fun receipt_package(receipt: &UpgradeReceipt): ID {
receipt.package
}�j� �move�u}�(j~ �package.move_18�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: ticket_digest
public fun ticket_digest(ticket: &UpgradeTicket): &vector<u8> {
&ticket.digest
}�j� �move�u}�(j~ �package.move_19�j� j� j� Kj� �xFile: package.move
Module: sui::package
Function: compatible_policy
public fun compatible_policy(): u8 { COMPATIBLE }�j� �move�u}�(j~ �package.move_20�j� j� j� Kj� �rFile: package.move
Module: sui::package
Function: additive_policy
public fun additive_policy(): u8 { ADDITIVE }�j� �move�u}�(j~ �package.move_21�j� j� j� Kj� �rFile: package.move
Module: sui::package
Function: dep_only_policy
public fun dep_only_policy(): u8 { DEP_ONLY }�j� �move�u}�(j~ �package.move_22�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: only_additive_upgrades
fun only_additive_upgrades(cap: &mut UpgradeCap) {
restrict(cap, ADDITIVE)
}�j� �move�u}�(j~ �package.move_23�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: only_dep_upgrades
fun only_dep_upgrades(cap: &mut UpgradeCap) {
restrict(cap, DEP_ONLY)
}�j� �move�u}�(j~ �package.move_24�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: make_immutable
fun make_immutable(cap: UpgradeCap) {
let UpgradeCap { id, package: _, version: _, policy: _ }�j� �move�u}�(j~ �package.move_25�j� j� j� Kj� X6 File: package.move
Module: sui::package
Function: authorize_upgrade
public fun authorize_upgrade(
cap: &mut UpgradeCap,
policy: u8,
digest: vector<u8>
): UpgradeTicket {
let id_zero = object::id_from_address(@0x0);
assert!(cap.package != id_zero, EAlreadyAuthorized);
assert!(policy >= cap.policy, ETooPermissive);
let package = cap.package;
cap.package = id_zero;
UpgradeTicket {
cap: object::id(cap),
package,
policy,
digest,
}�j� �move�u}�(j~ �package.move_26�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: commit_upgrade
public fun commit_upgrade(
cap: &mut UpgradeCap,
receipt: UpgradeReceipt,
) {
let UpgradeReceipt { cap: cap_id, package }�j� �move�u}�(j~ �package.move_27�j� j� j� Kj� Xr File: package.move
Module: sui::package
Function: test_claim
public fun test_claim<OTW: drop>(_: OTW, ctx: &mut TxContext): Publisher {
let type = type_name::get_with_original_ids<OTW>();
Publisher {
id: object::new(ctx),
package: type_name::get_address(&type),
module_name: type_name::get_module(&type),
}�j� �move�u}�(j~ �package.move_28�j� j� j� Kj� X File: package.move
Module: sui::package
Function: test_publish
public fun test_publish(package: ID, ctx: &mut TxContext): UpgradeCap {
UpgradeCap {
id: object::new(ctx),
package,
version: 1,
policy: COMPATIBLE,
}�j� �move�u}�(j~ �package.move_29�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: test_upgrade
public fun test_upgrade(ticket: UpgradeTicket): UpgradeReceipt {
let UpgradeTicket { cap, package, policy: _, digest: _ }�j� �move�u}�(j~ �package.move_30�j� j� j� Kj� ��File: package.move
Module: sui::package
Function: restrict
fun restrict(cap: &mut UpgradeCap, policy: u8) {
assert!(cap.policy <= policy, ETooPermissive);
cap.policy = policy;
}�j� �move�u}�(j~ �
borrow.move_0�j� �docs/move_files/borrow.move�j� K j� �+File: borrow.move
Move Module: sui::borrow�j� �move�u}�(j~ �
borrow.move_1�j� j j� Kj� X4 File: borrow.move
Module: sui::borrow
Dependencies:
use it and put back in the end. Hot-potato `Borrow` makes
/// sure the object is returned and was not swapped for another one.
module sui::borrow {
use sui::object::{Self, ID};
use std::option::{Self, Option};
use sui::tx_context::{Self, TxContext};
�j� �move�u}�(j~ �
borrow.move_2�j� j j� Kj� �MFile: borrow.move
Module: sui::borrow
Struct: Borrow
ref: address, obj: ID�j� �move�u}�(j~ �
borrow.move_3�j� j j� Kj� ��File: borrow.move
Module: sui::borrow
Function: new
public fun new<T: key + store>(value: T, ctx: &mut TxContext): Referent<T> {
Referent {
id: tx_context::fresh_object_address(ctx),
value: option::some(value)
}�j� �move�u}�(j~ �
borrow.move_4�j� j j� Kj� X/ File: borrow.move
Module: sui::borrow
Function: borrow
public fun borrow<T: key + store>(self: &mut Referent<T>): (T, Borrow) {
let value = option::extract(&mut self.value);
let id = object::id(&value);
(value, Borrow {
ref: self.id,
obj: id
}�j� �move�u}�(j~ �
borrow.move_5�j� j j� Kj� ��File: borrow.move
Module: sui::borrow
Function: put_back
public fun put_back<T: key + store>(self: &mut Referent<T>, value: T, borrow: Borrow) {
let Borrow { ref, obj }�j� �move�u}�(j~ �
borrow.move_6�j� j j� Kj� ��File: borrow.move
Module: sui::borrow
Function: destroy
public fun destroy<T: key + store>(self: Referent<T>): T {
let Referent { id: _, value }�j� �move�u}�(j~ �
borrow.move_7�j� j j� Kj� ��File: borrow.move
Module: sui::borrow
Function: test_borrow
fun test_borrow() {
let ctx = &mut sui::tx_context::dummy();
let ref = new(Test { id: object::new(ctx) }�j� �move�u}�(j~ �
borrow.move_8�j� j j� Kj� ��File: borrow.move
Module: sui::borrow
Function: test_object_swap
fun test_object_swap() {
let ctx = &mut sui::tx_context::dummy();
let ref_1 = new(Test { id: object::new(ctx) }�j� �move�u}�(j~ �
borrow.move_9�j� j j� K j� ��File: borrow.move
Module: sui::borrow
Function: test_borrow_fail
fun test_borrow_fail() {
let ctx = &mut sui::tx_context::dummy();
let ref_1 = new(Test { id: object::new(ctx) }�j� �move�u}�(j~ �
object.move_0�j� �docs/move_files/object.move�j� K j� �+File: object.move
Move Module: sui::object�j� �move�u}�(j~ �
object.move_1�j� j* j� Kj� X� File: object.move
Module: sui::object
Dependencies:
use std::bcs;
use sui::address;
use sui::tx_context::{Self, TxContext};
use there can be multiple values of type `ID`
/// with the same underlying bytes. For example, `object::id(&obj)` can be called as many times
/// as you want for a given `obj`, and each `ID` value will be identical.
struct ID has copy, drop, store {
// We use `address` instead of `vector<u8>` here because `address` has a more
// compact serialization. `address` is serialized as a BCS fixed-length sequence,
// which saves us the length prefix we would pay for if this were `vector<u8>`.
// See https://github.com/diem/bcs#fixed-and-variable-length-sequences.
bytes: address
}
/// Globally unique IDs that define an object's ID in storage. Any Sui Object, that is a struct
/// with the `key` ability, must have `id: UID` as its first field.
/// These are globally unique in the sense that no two values of type `UID` are ever equal, in
/// other words for any two values `id1: UID` and `id2: UID`, `id1` != `id2`.
/// This is a privileged type that can only be derived from a `TxContext`.
/// `UID` doesn't have the `drop` ability, so deleting a `UID` requires a call to `delete`.
struct UID has store {
id: ID,
}
// === id ===
/// Get the raw bytes of a `ID`
public fun id_to_bytes(id: &ID): vector<u8> {
bcs::to_bytes(&id.bytes)
}
/// Get the inner bytes of `id` as an address.
public fun id_to_address(id: &ID): address {
id.bytes
}
/// Make an `ID` from raw bytes.
public fun id_from_bytes(bytes: vector<u8>): ID {
id_from_address(address::from_bytes(bytes))
}
/// Make an `ID` from an address.
public fun id_from_address(bytes: address): ID {
ID { bytes }
}
// === uid ===
#[allow(unused_function)]
/// Create the `UID` for the singleton `SuiSystemState` object.
/// This should only be called once from `sui_system`.
fun sui_system_state(ctx: &TxContext): UID {
assert!(tx_context::sender(ctx) == @0x0, ENotSystemAddress);
use Sui has an extra bytecode verifier pass that forces every struct with
/// the `key` ability to have a distinguished `UID` field.
/// Cannot be made public as the access to `UID` for a given object must be privileged, and
/// restrictable in the object's module.
native fun borrow_uid<T: key>(obj: &T): &UID;
�j� �move�u}�(j~ �
object.move_2�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: id_to_bytes
public fun id_to_bytes(id: &ID): vector<u8> {
bcs::to_bytes(&id.bytes)
}�j� �move�u}�(j~ �
object.move_3�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: id_to_address
public fun id_to_address(id: &ID): address {
id.bytes
}�j� �move�u}�(j~ �
object.move_4�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: id_from_bytes
public fun id_from_bytes(bytes: vector<u8>): ID {
id_from_address(address::from_bytes(bytes))
}�j� �move�u}�(j~ �
object.move_5�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: id_from_address
public fun id_from_address(bytes: address): ID {
ID { bytes }�j� �move�u}�(j~ �
object.move_6�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: sui_system_state
fun sui_system_state(ctx: &TxContext): UID {
assert!(tx_context::sender(ctx) == @0x0, ENotSystemAddress);
UID {
id: ID { bytes: SUI_SYSTEM_STATE_OBJECT_ID }�j� �move�u}�(j~ �
object.move_7�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: clock
fun clock(): UID {
UID {
id: ID { bytes: SUI_CLOCK_OBJECT_ID }�j� �move�u}�(j~ �
object.move_8�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: authenticator_state
fun authenticator_state(): UID {
UID {
id: ID { bytes: SUI_AUTHENTICATOR_STATE_ID }�j� �move�u}�(j~ �
object.move_9�j� j* j� K j� ��File: object.move
Module: sui::object
Function: randomness_state
fun randomness_state(): UID {
UID {
id: ID { bytes: SUI_RANDOM_ID }�j� �move�u}�(j~ �object.move_10�j� j* j� K
j� �File: object.move
Module: sui::object
Function: uid_as_inner
public fun uid_as_inner(uid: &UID): &ID {
&uid.id
}�j� �move�u}�(j~ �object.move_11�j� j* j� Kj� �}File: object.move
Module: sui::object
Function: uid_to_inner
public fun uid_to_inner(uid: &UID): ID {
uid.id
}�j� �move�u}�(j~ �object.move_12�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: uid_to_bytes
public fun uid_to_bytes(uid: &UID): vector<u8> {
bcs::to_bytes(&uid.id.bytes)
}�j� �move�u}�(j~ �object.move_13�j� j* j� K
j� ��File: object.move
Module: sui::object
Function: uid_to_address
public fun uid_to_address(uid: &UID): address {
uid.id.bytes
}�j� �move�u}�(j~ �object.move_14�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: new
public fun new(ctx: &mut TxContext): UID {
UID {
id: ID { bytes: tx_context::fresh_object_address(ctx) }�j� �move�u}�(j~ �object.move_15�j� j* j� Kj� �yFile: object.move
Module: sui::object
Function: delete
public fun delete(id: UID) {
let UID { id: ID { bytes }�j� �move�u}�(j~ �object.move_16�j� j* j� Kj� �{File: object.move
Module: sui::object
Function: id
public fun id<T: key>(obj: &T): ID {
borrow_uid(obj).id
}�j� �move�u}�(j~ �object.move_17�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: borrow_id
public fun borrow_id<T: key>(obj: &T): &ID {
&borrow_uid(obj).id
}�j� �move�u}�(j~ �object.move_18�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: id_bytes
public fun id_bytes<T: key>(obj: &T): vector<u8> {
bcs::to_bytes(&borrow_uid(obj).id)
}�j� �move�u}�(j~ �object.move_19�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: id_address
public fun id_address<T: key>(obj: &T): address {
borrow_uid(obj).id.bytes
}�j� �move�u}�(j~ �object.move_20�j� j* j� Kj� X/ File: object.move
Module: sui::object
Function: borrow_uid
fun borrow_uid<T: key>(obj: &T): &UID;
/// Generate a new UID specifically used for creating a UID from a hash
public(friend) fun new_uid_from_hash(bytes: address): UID {
record_new_uid(bytes);
UID { id: ID { bytes }�j� �move�u}�(j~ �object.move_21�j� j* j� Kj� ��File: object.move
Module: sui::object
Function: last_created
public fun last_created(ctx: &TxContext): ID {
ID { bytes: tx_context::last_created_object_id(ctx) }�j� �move�u}�(j~ �address.move_0�j� �docs/move_files/address.move�j� K j� �-File: address.move
Move Module: sui::address�j� �move�u}�(j~ �address.move_1�j� j� j� Kj� �uFile: address.move
Module: sui::address
Dependencies:
use sui::hex;
use std::ascii;
use std::bcs;
use std::string;
�j� �move�u}�(j~ �address.move_2�j� j� j� Kj� X( File: address.move
Module: sui::address
Function: to_u256
fun to_u256(a: address): u256;
spec to_u256 {
pragma opaque;
// TODO: stub to be replaced by actual abort conditions if any
aborts_if [abstract] true;
// TODO: specify actual function behavior
}�j� �move�u}�(j~ �address.move_3�j� j� j� Kj� X. File: address.move
Module: sui::address
Function: from_u256
fun from_u256(n: u256): address;
spec from_u256 {
pragma opaque;
// TODO: stub to be replaced by actual abort conditions if any
aborts_if [abstract] true;
// TODO: specify actual function behavior
}�j� �move�u}�(j~ �address.move_4�j� j� j� Kj� X; File: address.move
Module: sui::address
Function: from_bytes
fun from_bytes(bytes: vector<u8>): address;
spec from_bytes {
pragma opaque;
// TODO: stub to be replaced by actual abort conditions if any
aborts_if [abstract] true;
// TODO: specify actual function behavior
}�j� �move�u}�(j~ �address.move_5�j� j� j� Kj� ��File: address.move
Module: sui::address
Function: to_bytes
public fun to_bytes(a: address): vector<u8> {
bcs::to_bytes(&a)
}�j� �move�u}�(j~ �address.move_6�j� j� j� Kj� ��File: address.move
Module: sui::address
Function: to_ascii_string
public fun to_ascii_string(a: address): ascii::String {
ascii::string(hex::encode(to_bytes(a)))
}�j� �move�u}�(j~ �address.move_7�j� j� j� Kj� ��File: address.move
Module: sui::address
Function: to_string
public fun to_string(a: address): string::String {
string::from_ascii(to_ascii_string(a))
}�j� �move�u}�(j~ �address.move_8�j� j� j� Kj� �kFile: address.move
Module: sui::address
Function: length
public fun length(): u64 {
LENGTH
}�j� �move�u}�(j~ �address.move_9�j� j� j� K j� �cFile: address.move
Module: sui::address
Function: max
public fun max(): u256 {
MAX
}�j� �move�u}�(j~ �
bag.move_0�j� �docs/move_files/bag.move�j� K j� �%File: bag.move
Move Module: sui::bag�j� �move�u}�(j~ �
bag.move_1�j� j� j� Kj� ��File: bag.move
Module: sui::bag
Dependencies:
use sui::object::{Self, UID};
use sui::dynamic_field as field;
use sui::tx_context::TxContext;
�j� �move�u}�(j~ �
bag.move_2�j� j� j� Kj� ��File: bag.move
Module: sui::bag
Function: new
public fun new(ctx: &mut TxContext): Bag {
Bag {
id: object::new(ctx),
size: 0,
}�j� �move�u}�(j~ �
bag.move_3�j� j� j� Kj� ��File: bag.move
Module: sui::bag
Function: add
public fun add<K: copy + drop + store, V: store>(bag: &mut Bag, k: K, v: V) {
field::add(&mut bag.id, k, v);
bag.size = bag.size + 1;
}�j� �move�u}�(j~ �
bag.move_4�j� j� j� Kj� ��File: bag.move
Module: sui::bag
Function: borrow
public fun borrow<K: copy + drop + store, V: store>(bag: &Bag, k: K): &V {
field::borrow(&bag.id, k)
}�j� �move�u}�(j~ �
bag.move_5�j� j� j� Kj� ��File: bag.move
Module: sui::bag
Function: borrow_mut
public fun borrow_mut<K: copy + drop + store, V: store>(bag: &mut Bag, k: K): &mut V {
field::borrow_mut(&mut bag.id, k)
}�j� �move�u}�(j~ �
bag.move_6�j� j� j� Kj� ��File: bag.move
Module: sui::bag
Function: remove
public fun remove<K: copy + drop + store, V: store>(bag: &mut Bag, k: K): V {
let v = field::remove(&mut bag.id, k);
bag.size = bag.size - 1;
v
}�j� �move�u}�(j~ �
bag.move_7�j� j� j� Kj� ��File: bag.move
Module: sui::bag
Function: contains
public fun contains<K: copy + drop + store>(bag: &Bag, k: K): bool {
field::exists_<K>(&bag.id, k)
}�j� �move�u}�(j~ �
bag.move_8�j� j� j� Kj� ��File: bag.move
Module: sui::bag
Function: contains_with_type
public fun contains_with_type<K: copy + drop + store, V: store>(bag: &Bag, k: K): bool {
field::exists_with_type<K, V>(&bag.id, k)
}�j� �move�u}�(j~ �
bag.move_9�j� j� j� K j� �nFile: bag.move
Module: sui::bag
Function: length
public fun length(bag: &Bag): u64 {
bag.size
}�j� �move�u}�(j~ �bag.move_10�j� j� j� K
j� �xFile: bag.move
Module: sui::bag
Function: is_empty
public fun is_empty(bag: &Bag): bool {
bag.size == 0
}�j� �move�u}�(j~ �bag.move_11�j� j� j� Kj� �|File: bag.move
Module: sui::bag
Function: destroy_empty
public fun destroy_empty(bag: Bag) {
let Bag { id, size }�j� �move�u}�(j~ �
bcs.move_0�j� �docs/move_files/bcs.move�j� K j� �;File: bcs.move
Module: sui::bcs
Header Comments:
/// This�j� �move�u}�(j~ �
bcs.move_1�j� j� j� Kj� �%File: bcs.move
Move Module: sui::bcs�j� �move�u}�(j~ �
bcs.move_2�j� j� j� Kj� Xm File: bcs.move
Module: sui::bcs
Dependencies:
use sui::bcs::{Self, BCS};
use std::option::{Self, Option};
use std::vector as v;
use sui::address;
use std::bcs;
use of `vector::pop_back`.
struct BCS has store, copy, drop {
bytes: vector<u8>
}
/// Get BCS serialized bytes for any value.
/// Re-exports stdlib `bcs::to_bytes`.
public fun to_bytes<T>(value: &T): vector<u8> {
bcs::to_bytes(value)
}
/// Creates a new instance of BCS wrapper that holds inversed
/// bytes for better performance.
public fun new(bytes: vector<u8>): BCS {
v::reverse(&mut bytes);
�j� �move�u}�(j~ �
bcs.move_3�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: deserialize
fun deserialize(bytes: vector<u8>): (u8, u64, vector<u8>) {
/// use sui::bcs::{Self, BCS}�j� �move�u}�(j~ �
bcs.move_4�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: to_bytes
public fun to_bytes<T>(value: &T): vector<u8> {
bcs::to_bytes(value)
}�j� �move�u}�(j~ �
bcs.move_5�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: new
public fun new(bytes: vector<u8>): BCS {
v::reverse(&mut bytes);
BCS { bytes }�j� �move�u}�(j~ �
bcs.move_6�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: into_remainder_bytes
public fun into_remainder_bytes(bcs: BCS): vector<u8> {
let BCS { bytes }�j� �move�u}�(j~ �
bcs.move_7�j� j� j� Kj� Xu File: bcs.move
Module: sui::bcs
Function: peel_address
public fun peel_address(bcs: &mut BCS): address {
assert!(v::length(&bcs.bytes) >= address::length(), EOutOfRange);
let (addr_bytes, i) = (v::empty(), 0);
while (i < address::length()) {
v::push_back(&mut addr_bytes, v::pop_back(&mut bcs.bytes));
i = i + 1;
}�j� �move�u}�(j~ �
bcs.move_8�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: peel_bool
public fun peel_bool(bcs: &mut BCS): bool {
let value = peel_u8(bcs);
if (value == 0) {
false
}�j� �move�u}�(j~ �
bcs.move_9�j� j� j� K j� ��File: bcs.move
Module: sui::bcs
Function: peel_u8
public fun peel_u8(bcs: &mut BCS): u8 {
assert!(v::length(&bcs.bytes) >= 1, EOutOfRange);
v::pop_back(&mut bcs.bytes)
}�j� �move�u}�(j~ �bcs.move_10�j� j� j� K
j� X` File: bcs.move
Module: sui::bcs
Function: peel_u64
public fun peel_u64(bcs: &mut BCS): u64 {
assert!(v::length(&bcs.bytes) >= 8, EOutOfRange);
let (value, i) = (0u64, 0u8);
while (i < 64) {
let byte = (v::pop_back(&mut bcs.bytes) as u64);
value = value + (byte << i);
i = i + 8;
}�j� �move�u}�(j~ �bcs.move_11�j� j� j� Kj� Xg File: bcs.move
Module: sui::bcs
Function: peel_u128
public fun peel_u128(bcs: &mut BCS): u128 {
assert!(v::length(&bcs.bytes) >= 16, EOutOfRange);
let (value, i) = (0u128, 0u8);
while (i < 128) {
let byte = (v::pop_back(&mut bcs.bytes) as u128);
value = value + (byte << i);
i = i + 8;
}�j� �move�u}�(j~ �bcs.move_12�j� j� j� Kj� X� File: bcs.move
Module: sui::bcs
Function: peel_vec_length
public fun peel_vec_length(bcs: &mut BCS): u64 {
let (total, shift, len) = (0u64, 0, 0);
while (true) {
assert!(len <= 4, ELenOutOfRange);
let byte = (v::pop_back(&mut bcs.bytes) as u64);
len = len + 1;
total = total | ((byte & 0x7f) << shift);
if ((byte & 0x80) == 0) {
break
}�j� �move�u}�(j~ �bcs.move_13�j� j� j� K
j� X. File: bcs.move
Module: sui::bcs
Function: peel_vec_address
public fun peel_vec_address(bcs: &mut BCS): vector<address> {
let (len, i, res) = (peel_vec_length(bcs), 0, vector[]);
while (i < len) {
v::push_back(&mut res, peel_address(bcs));
i = i + 1;
}�j� �move�u}�(j~ �bcs.move_14�j� j� j� Kj� X" File: bcs.move
Module: sui::bcs
Function: peel_vec_bool
public fun peel_vec_bool(bcs: &mut BCS): vector<bool> {
let (len, i, res) = (peel_vec_length(bcs), 0, vector[]);
while (i < len) {
v::push_back(&mut res, peel_bool(bcs));
i = i + 1;
}�j� �move�u}�(j~ �bcs.move_15�j� j� j� Kj� X File: bcs.move
Module: sui::bcs
Function: peel_vec_u8
public fun peel_vec_u8(bcs: &mut BCS): vector<u8> {
let (len, i, res) = (peel_vec_length(bcs), 0, vector[]);
while (i < len) {
v::push_back(&mut res, peel_u8(bcs));
i = i + 1;
}�j� �move�u}�(j~ �bcs.move_16�j� j� j� Kj� X. File: bcs.move
Module: sui::bcs
Function: peel_vec_vec_u8
public fun peel_vec_vec_u8(bcs: &mut BCS): vector<vector<u8>> {
let (len, i, res) = (peel_vec_length(bcs), 0, vector[]);
while (i < len) {
v::push_back(&mut res, peel_vec_u8(bcs));
i = i + 1;
}�j� �move�u}�(j~ �bcs.move_17�j� j� j� Kj� X File: bcs.move
Module: sui::bcs
Function: peel_vec_u64
public fun peel_vec_u64(bcs: &mut BCS): vector<u64> {
let (len, i, res) = (peel_vec_length(bcs), 0, vector[]);
while (i < len) {
v::push_back(&mut res, peel_u64(bcs));
i = i + 1;
}�j� �move�u}�(j~ �bcs.move_18�j� j� j� Kj� X" File: bcs.move
Module: sui::bcs
Function: peel_vec_u128
public fun peel_vec_u128(bcs: &mut BCS): vector<u128> {
let (len, i, res) = (peel_vec_length(bcs), 0, vector[]);
while (i < len) {
v::push_back(&mut res, peel_u128(bcs));
i = i + 1;
}�j� �move�u}�(j~ �bcs.move_19�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: peel_option_address
public fun peel_option_address(bcs: &mut BCS): Option<address> {
if (peel_bool(bcs)) {
option::some(peel_address(bcs))
}�j� �move�u}�(j~ �bcs.move_20�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: peel_option_bool
public fun peel_option_bool(bcs: &mut BCS): Option<bool> {
if (peel_bool(bcs)) {
option::some(peel_bool(bcs))
}�j� �move�u}�(j~ �bcs.move_21�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: peel_option_u8
public fun peel_option_u8(bcs: &mut BCS): Option<u8> {
if (peel_bool(bcs)) {
option::some(peel_u8(bcs))
}�j� �move�u}�(j~ �bcs.move_22�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: peel_option_u64
public fun peel_option_u64(bcs: &mut BCS): Option<u64> {
if (peel_bool(bcs)) {
option::some(peel_u64(bcs))
}�j� �move�u}�(j~ �bcs.move_23�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: peel_option_u128
public fun peel_option_u128(bcs: &mut BCS): Option<u128> {
if (peel_bool(bcs)) {
option::some(peel_u128(bcs))
}�j� �move�u}�(j~ �bcs.move_24�j� j� j� Kj� X# File: bcs.move
Module: sui::bcs
Function: test_uleb_len_fail
fun test_uleb_len_fail() {
let value = vector[0xff, 0xff, 0xff, 0xff, 0xff];
let bytes = new(to_bytes(&value));
let _fail = peel_vec_length(&mut bytes);
abort 2 // TODO: make this test fail
}�j� �move�u}�(j~ �bcs.move_25�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: test_bool_fail
fun test_bool_fail() {
let bytes = new(to_bytes(&10u8));
let _fail = peel_bool(&mut bytes);
}�j� �move�u}�(j~ �bcs.move_26�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: test_option
fun test_option() {
{
let value = option::some(true);
let bytes = new(to_bytes(&value));
assert!(value == peel_option_bool(&mut bytes), 0);
}�j� �move�u}�(j~ �bcs.move_27�j� j� j� Kj� ��File: bcs.move
Module: sui::bcs
Function: test_bcs
fun test_bcs() {
{
let value = @0xC0FFEE;
let bytes = new(to_bytes(&value));
assert!(value == peel_address(&mut bytes), 0);
}�j� �move�u}�(j~ �table_vec.move_0�j� �docs/move_files/table_vec.move�j� K j� �1File: table_vec.move
Move Module: sui::table_vec�j� �move�u}�(j~ �table_vec.move_1�j� jN j� Kj� �{File: table_vec.move
Module: sui::table_vec
Dependencies:
use sui::table::{Self, Table};
use sui::tx_context::TxContext;
�j� �move�u}�(j~ �table_vec.move_2�j� jN j� Kj� ��File: table_vec.move
Module: sui::table_vec
Function: empty
public fun empty<Element: store>(ctx: &mut TxContext): TableVec<Element> {
TableVec {
contents: table::new(ctx)
}�j� �move�u}�(j~ �table_vec.move_3�j� jN j� Kj� ��File: table_vec.move
Module: sui::table_vec
Function: singleton
public fun singleton<Element: store>(e: Element, ctx: &mut TxContext): TableVec<Element> {
let mut t = empty(ctx);
push_back(&mut t, e);
t
}�j� �move�u}�(j~ �table_vec.move_4�j� jN j� Kj� ��File: table_vec.move
Module: sui::table_vec
Function: length
public fun length<Element: store>(t: &TableVec<Element>): u64 {
table::length(&t.contents)
}�j� �move�u}�(j~ �table_vec.move_5�j� jN j� Kj� ��File: table_vec.move
Module: sui::table_vec
Function: is_empty
public fun is_empty<Element: store>(t: &TableVec<Element>): bool {
length(t) == 0
}�j� �move�u}�(j~ �table_vec.move_6�j� jN j� Kj� ��File: table_vec.move
Module: sui::table_vec
Function: borrow
public fun borrow<Element: store>(t: &TableVec<Element>, i: u64): &Element {
assert!(length(t) > i, EIndexOutOfBound);
table::borrow(&t.contents, i)
}�j� �move�u}�(j~ �table_vec.move_7�j� jN j� Kj� ��File: table_vec.move
Module: sui::table_vec
Function: push_back
public fun push_back<Element: store>(t: &mut TableVec<Element>, e: Element) {
let key = length(t);
table::add(&mut t.contents, key, e);
}�j� �move�u}�(j~ �table_vec.move_8�j� jN j� Kj� X File: table_vec.move
Module: sui::table_vec
Function: borrow_mut
public fun borrow_mut<Element: store>(t: &mut TableVec<Element>, i: u64): &mut Element {
assert!(length(t) > i, EIndexOutOfBound);
table::borrow_mut(&mut t.contents, i)
}�j� �move�u}�(j~ �table_vec.move_9�j� jN j� K j� X File: table_vec.move
Module: sui::table_vec
Function: pop_back
public fun pop_back<Element: store>(t: &mut TableVec<Element>): Element {
let length = length(t);
assert!(length > 0, EIndexOutOfBound);
table::remove(&mut t.contents, length - 1)
}�j� �move�u}�(j~ �table_vec.move_10�j� jN j� K
j� ��File: table_vec.move
Module: sui::table_vec
Function: destroy_empty
public fun destroy_empty<Element: store>(t: TableVec<Element>) {
assert!(length(&t) == 0, ETableNonEmpty);
let TableVec { contents }�j� �move�u}�(j~ �table_vec.move_11�j� jN j� Kj� ��File: table_vec.move
Module: sui::table_vec
Function: drop
public fun drop<Element: drop + store>(t: TableVec<Element>) {
let TableVec { contents }�j� �move�u}�(j~ �table_vec.move_12�j� jN j� Kj� X
File: table_vec.move
Module: sui::table_vec
Function: swap
public fun swap<Element: store>(t: &mut TableVec<Element>, i: u64, j: u64) {
assert!(length(t) > i, EIndexOutOfBound);
assert!(length(t) > j, EIndexOutOfBound);
if (i == j) { return }�j� �move�u}�(j~ �table_vec.move_13�j� jN j� K
j� X) File: table_vec.move
Module: sui::table_vec
Function: swap_remove
public fun swap_remove<Element: store>(t: &mut TableVec<Element>, i: u64): Element {
assert!(length(t) > i, EIndexOutOfBound);
let last_idx = length(t) - 1;
swap(t, i, last_idx);
pop_back(t)
}�j� �move�u}�(j~ �table.move_0�j� �docs/move_files/table.move�j� K j� �)File: table.move
Move Module: sui::table�j� �move�u}�(j~ �table.move_1�j� j� j� Kj� ��File: table.move
Module: sui::table
Dependencies:
use sui::object::{Self, UID};
use sui::dynamic_field as field;
use sui::tx_context::TxContext;
�j� �move�u}�(j~ �table.move_2�j� j� j� Kj� ��File: table.move
Module: sui::table
Function: new
public fun new<K: copy + drop + store, V: store>(ctx: &mut TxContext): Table<K, V> {
Table {
id: object::new(ctx),
size: 0,
}�j� �move�u}�(j~ �table.move_3�j� j� j� Kj� ��File: table.move
Module: sui::table
Function: add
public fun add<K: copy + drop + store, V: store>(table: &mut Table<K, V>, k: K, v: V) {
field::add(&mut table.id, k, v);
table.size = table.size + 1;
}�j� �move�u}�(j~ �table.move_4�j� j� j� Kj� ��File: table.move
Module: sui::table
Function: borrow
public fun borrow<K: copy + drop + store, V: store>(table: &Table<K, V>, k: K): &V {
field::borrow(&table.id, k)
}�j� �move�u}�(j~ �table.move_5�j� j� j� Kj� ��File: table.move
Module: sui::table
Function: borrow_mut
public fun borrow_mut<K: copy + drop + store, V: store>(table: &mut Table<K, V>, k: K): &mut V {
field::borrow_mut(&mut table.id, k)
}�j� �move�u}�(j~ �table.move_6�j� j� j� Kj� ��File: table.move
Module: sui::table
Function: remove
public fun remove<K: copy + drop + store, V: store>(table: &mut Table<K, V>, k: K): V {
let v = field::remove(&mut table.id, k);
table.size = table.size - 1;
v
}�j� �move�u}�(j~ �table.move_7�j� j� j� Kj� ��File: table.move
Module: sui::table
Function: contains
public fun contains<K: copy + drop + store, V: store>(table: &Table<K, V>, k: K): bool {
field::exists_with_type<K, V>(&table.id, k)
}�j� �move�u}�(j~ �table.move_8�j� j� j� Kj� ��File: table.move
Module: sui::table
Function: length
public fun length<K: copy + drop + store, V: store>(table: &Table<K, V>): u64 {
table.size
}�j� �move�u}�(j~ �table.move_9�j� j� j� K j� ��File: table.move
Module: sui::table
Function: is_empty
public fun is_empty<K: copy + drop + store, V: store>(table: &Table<K, V>): bool {
table.size == 0
}�j� �move�u}�(j~ �
table.move_10�j� j� j� K
j� ��File: table.move
Module: sui::table
Function: destroy_empty
public fun destroy_empty<K: copy + drop + store, V: store>(table: Table<K, V>) {
let Table { id, size }�j� �move�u}�(j~ �
table.move_11�j� j� j� Kj� ��File: table.move
Module: sui::table
Function: drop
public fun drop<K: copy + drop + store, V: drop + store>(table: Table<K, V>) {
let Table { id, size: _ }�j� �move�u}�(j~ �
pay.move_0�j� �docs/move_files/pay.move�j� K j� �;File: pay.move
Module: sui::pay
Header Comments:
/// This�j� �move�u}�(j~ �
pay.move_1�j� j� j� Kj� �%File: pay.move
Move Module: sui::pay�j� �move�u}�(j~ �
pay.move_2�j� j� j� Kj� X� File: pay.move
Module: sui::pay
Dependencies:
use sui::tx_context::{Self, TxContext};
use sui::coin::{Self, Coin};
use sui::transfer;
use std::vector;
use we've drained the vector
vector::destroy_empty(coins)
}
/// Join a vector of `Coin` into a single object and transfer it to `receiver`.
public entry fun join_vec_and_transfer<T>(coins: vector<Coin<T>>, receiver: address) {
assert!(vector::length(&coins) > 0, ENoCoins);
�j� �move�u}�(j~ �
pay.move_3�j� j� j� Kj� ��File: pay.move
Module: sui::pay
Function: keep
public fun keep<T>(c: Coin<T>, ctx: &TxContext) {
transfer::public_transfer(c, tx_context::sender(ctx))
}�j� �move�u}�(j~ �
pay.move_4�j� j� j� Kj� ��File: pay.move
Module: sui::pay
Function: split
fun split<T>(
self: &mut Coin<T>, split_amount: u64, ctx: &mut TxContext
) {
keep(coin::split(self, split_amount, ctx), ctx)
}�j� �move�u}�(j~ �
pay.move_5�j� j� j� Kj� XU File: pay.move
Module: sui::pay
Function: split_vec
fun split_vec<T>(
self: &mut Coin<T>, split_amounts: vector<u64>, ctx: &mut TxContext
) {
let (i, len) = (0, vector::length(&split_amounts));
while (i < len) {
split(self, *vector::borrow(&split_amounts, i), ctx);
i = i + 1;
}�j� �move�u}�(j~ �
pay.move_6�j� j� j� Kj� X File: pay.move
Module: sui::pay
Function: split_and_transfer
fun split_and_transfer<T>(
c: &mut Coin<T>, amount: u64, recipient: address, ctx: &mut TxContext
) {
transfer::public_transfer(coin::split(c, amount, ctx), recipient)
}�j� �move�u}�(j~ �
pay.move_7�j� j� j� Kj� X� File: pay.move
Module: sui::pay
Function: divide_and_keep
fun divide_and_keep<T>(
self: &mut Coin<T>, n: u64, ctx: &mut TxContext
) {
let vec: vector<Coin<T>> = coin::divide_into_n(self, n, ctx);
let (i, len) = (0, vector::length(&vec));
while (i < len) {
transfer::public_transfer(vector::pop_back(&mut vec), tx_context::sender(ctx));
i = i + 1;
}�j� �move�u}�(j~ �
pay.move_8�j� j� j� Kj� ��File: pay.move
Module: sui::pay
Function: join
fun join<T>(self: &mut Coin<T>, coin: Coin<T>) {
coin::join(self, coin)
}�j� �move�u}�(j~ �
pay.move_9�j� j� j� K j� X: File: pay.move
Module: sui::pay
Function: join_vec
fun join_vec<T>(self: &mut Coin<T>, coins: vector<Coin<T>>) {
let (i, len) = (0, vector::length(&coins));
while (i < len) {
let coin = vector::pop_back(&mut coins);
coin::join(self, coin);
i = i + 1
}�j� �move�u}�(j~ �pay.move_10�j� j� j� K
j� XQ File: pay.move
Module: sui::pay
Function: join_vec_and_transfer
fun join_vec_and_transfer<T>(coins: vector<Coin<T>>, receiver: address) {
assert!(vector::length(&coins) > 0, ENoCoins);
let self = vector::pop_back(&mut coins);
join_vec(&mut self, coins);
transfer::public_transfer(self, receiver)
}�j� �move�u}�(j~ �coin.move_0�j� �docs/move_files/coin.move�j� K j� �'File: coin.move
Move Module: sui::coin�j� �move�u}�(j~ �coin.move_1�j� j� j� Kj� X File: coin.move
Module: sui::coin
Dependencies:
use std::string;
use std::ascii;
use std::option::{Self, Option};
use sui::balance::{Self, Balance, Supply};
use sui::tx_context::TxContext;
use sui::object::{Self, UID};
use sui::transfer;
use sui::url::{Self, Url};
use std::vector;
�j� �move�u}�(j~ �coin.move_2�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: total_supply
public fun total_supply<T>(cap: &TreasuryCap<T>): u64 {
balance::supply_value(&cap.total_supply)
}�j� �move�u}�(j~ �coin.move_3�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: treasury_into_supply
public fun treasury_into_supply<T>(treasury: TreasuryCap<T>): Supply<T> {
let TreasuryCap { id, total_supply }�j� �move�u}�(j~ �coin.move_4�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: supply_immut
public fun supply_immut<T>(treasury: &TreasuryCap<T>): &Supply<T> {
&treasury.total_supply
}�j� �move�u}�(j~ �coin.move_5�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: supply_mut
public fun supply_mut<T>(treasury: &mut TreasuryCap<T>): &mut Supply<T> {
&mut treasury.total_supply
}�j� �move�u}�(j~ �coin.move_6�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: value
public fun value<T>(self: &Coin<T>): u64 {
balance::value(&self.balance)
}�j� �move�u}�(j~ �coin.move_7�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: balance
public fun balance<T>(coin: &Coin<T>): &Balance<T> {
&coin.balance
}�j� �move�u}�(j~ �coin.move_8�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: balance_mut
public fun balance_mut<T>(coin: &mut Coin<T>): &mut Balance<T> {
&mut coin.balance
}�j� �move�u}�(j~ �coin.move_9�j� j� j� K j� ��File: coin.move
Module: sui::coin
Function: from_balance
public fun from_balance<T>(balance: Balance<T>, ctx: &mut TxContext): Coin<T> {
Coin { id: object::new(ctx), balance }�j� �move�u}�(j~ �coin.move_10�j� j� j� K
j� ��File: coin.move
Module: sui::coin
Function: into_balance
public fun into_balance<T>(coin: Coin<T>): Balance<T> {
let Coin { id, balance }�j� �move�u}�(j~ �coin.move_11�j� j� j� Kj� X
File: coin.move
Module: sui::coin
Function: take
public fun take<T>(
balance: &mut Balance<T>, value: u64, ctx: &mut TxContext,
): Coin<T> {
Coin {
id: object::new(ctx),
balance: balance::split(balance, value)
}�j� �move�u}�(j~ �coin.move_12�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: put
public fun put<T>(balance: &mut Balance<T>, coin: Coin<T>) {
balance::join(balance, into_balance(coin));
}�j� �move�u}�(j~ �coin.move_13�j� j� j� K
j� ��File: coin.move
Module: sui::coin
Function: join
fun join<T>(self: &mut Coin<T>, c: Coin<T>) {
let Coin { id, balance }�j� �move�u}�(j~ �coin.move_14�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: split
public fun split<T>(
self: &mut Coin<T>, split_amount: u64, ctx: &mut TxContext
): Coin<T> {
take(&mut self.balance, split_amount, ctx)
}�j� �move�u}�(j~ �coin.move_15�j� j� j� Kj� Xe File: coin.move
Module: sui::coin
Function: divide_into_n
public fun divide_into_n<T>(
self: &mut Coin<T>, n: u64, ctx: &mut TxContext
): vector<Coin<T>> {
assert!(n > 0, EInvalidArg);
assert!(n <= value(self), ENotEnough);
let vec = vector::empty<Coin<T>>();
let i = 0;
let split_amount = value(self) / n;
while ({
spec {
invariant i <= n-1;
invariant self.balance.value == old(self).balance.value - (i * split_amount);
invariant ctx.ids_created == old(ctx).ids_created + i;
}�j� �move�u}�(j~ �coin.move_16�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: zero
public fun zero<T>(ctx: &mut TxContext): Coin<T> {
Coin { id: object::new(ctx), balance: balance::zero() }�j� �move�u}�(j~ �coin.move_17�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: destroy_zero
public fun destroy_zero<T>(c: Coin<T>) {
let Coin { id, balance }�j� �move�u}�(j~ �coin.move_18�j� j� j� Kj� Xg File: coin.move
Module: sui::coin
Function: create_currency
public fun create_currency<T: drop>(
witness: T,
decimals: u8,
symbol: vector<u8>,
name: vector<u8>,
description: vector<u8>,
icon_url: Option<Url>,
ctx: &mut TxContext
): (TreasuryCap<T>, CoinMetadata<T>) {
// Make sure there's only one instance of the type T
assert!(sui::types::is_one_time_witness(&witness), EBadWitness);
(
TreasuryCap {
id: object::new(ctx),
total_supply: balance::create_supply(witness)
}�j� �move�u}�(j~ �coin.move_19�j� j� j� Kj� X" File: coin.move
Module: sui::coin
Function: mint
public fun mint<T>(
cap: &mut TreasuryCap<T>, value: u64, ctx: &mut TxContext,
): Coin<T> {
Coin {
id: object::new(ctx),
balance: balance::increase_supply(&mut cap.total_supply, value)
}�j� �move�u}�(j~ �coin.move_20�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: mint_balance
public fun mint_balance<T>(
cap: &mut TreasuryCap<T>, value: u64
): Balance<T> {
balance::increase_supply(&mut cap.total_supply, value)
}�j� �move�u}�(j~ �coin.move_21�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: burn
fun burn<T>(cap: &mut TreasuryCap<T>, c: Coin<T>): u64 {
let Coin { id, balance }�j� �move�u}�(j~ �coin.move_22�j� j� j� Kj� X File: coin.move
Module: sui::coin
Function: mint_and_transfer
fun mint_and_transfer<T>(
c: &mut TreasuryCap<T>, amount: u64, recipient: address, ctx: &mut TxContext
) {
transfer::public_transfer(mint(c, amount, ctx), recipient)
}�j� �move�u}�(j~ �coin.move_23�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: update_name
fun update_name<T>(
_treasury: &TreasuryCap<T>, metadata: &mut CoinMetadata<T>, name: string::String
) {
metadata.name = name;
}�j� �move�u}�(j~ �coin.move_24�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: update_symbol
fun update_symbol<T>(
_treasury: &TreasuryCap<T>, metadata: &mut CoinMetadata<T>, symbol: ascii::String
) {
metadata.symbol = symbol;
}�j� �move�u}�(j~ �coin.move_25�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: update_description
fun update_description<T>(
_treasury: &TreasuryCap<T>, metadata: &mut CoinMetadata<T>, description: string::String
) {
metadata.description = description;
}�j� �move�u}�(j~ �coin.move_26�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: update_icon_url
fun update_icon_url<T>(
_treasury: &TreasuryCap<T>, metadata: &mut CoinMetadata<T>, url: ascii::String
) {
metadata.icon_url = option::some(url::new_unsafe(url));
}�j� �move�u}�(j~ �coin.move_27�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: get_decimals
public fun get_decimals<T>(metadata: &CoinMetadata<T>): u8 {
metadata.decimals
}�j� �move�u}�(j~ �coin.move_28�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: get_name
public fun get_name<T>(metadata: &CoinMetadata<T>): string::String {
metadata.name
}�j� �move�u}�(j~ �coin.move_29�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: get_symbol
public fun get_symbol<T>(metadata: &CoinMetadata<T>): ascii::String {
metadata.symbol
}�j� �move�u}�(j~ �coin.move_30�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: get_description
public fun get_description<T>(metadata: &CoinMetadata<T>): string::String {
metadata.description
}�j� �move�u}�(j~ �coin.move_31�j� j� j� Kj� ��File: coin.move
Module: sui::coin
Function: get_icon_url
public fun get_icon_url<T>(metadata: &CoinMetadata<T>): Option<Url> {
metadata.icon_url
}�j� �move�u}�(j~ �coin.move_32�j� j� j� K j� ��File: coin.move
Module: sui::coin
Function: mint_for_testing
public fun mint_for_testing<T>(value: u64, ctx: &mut TxContext): Coin<T> {
Coin { id: object::new(ctx), balance: balance::create_for_testing(value) }�j� �move�u}�(j~ �coin.move_33�j� j� j� K!j� ��File: coin.move
Module: sui::coin
Function: burn_for_testing
public fun burn_for_testing<T>(coin: Coin<T>): u64 {
let Coin { id, balance }�� j� �move�u}�(j~ �coin.move_34�j� j� j� K"j� X2 File: coin.move
Module: sui::coin
Function: create_treasury_cap_for_testing
public fun create_treasury_cap_for_testing<T>(
ctx: &mut TxContext
): TreasuryCap<T> {
TreasuryCap {
id: object::new(ctx),
total_supply: balance::create_supply_for_testing()
}�j� �move�u}�(j~ �coin.move_35�j� j� j� K#j� ��File: coin.move
Module: sui::coin
Function: supply
public fun supply<T>(treasury: &mut TreasuryCap<T>): &Supply<T> {
&treasury.total_supply
}�j� �move�u}�(j~ �linked_table.move_0�j� �!docs/move_files/linked_table.move�j� K j� �7File: linked_table.move
Move Module: sui::linked_table�j� �move�u}�(j~ �linked_table.move_1�j� jv j� Kj� ��File: linked_table.move
Module: sui::linked_table
Dependencies:
use std::option::{Self, Option};
use sui::object::{Self, UID};
use sui::dynamic_field as field;
use sui::tx_context::TxContext;
�j� �move�u}�(j~ �linked_table.move_2�j� jv j� Kj� X8 File: linked_table.move
Module: sui::linked_table
Function: new
public fun new<K: copy + drop + store, V: store>(ctx: &mut TxContext): LinkedTable<K, V> {
LinkedTable {
id: object::new(ctx),
size: 0,
head: option::none(),
tail: option::none(),
}�j� �move�u}�(j~ �linked_table.move_3�j� jv j� Kj� ��File: linked_table.move
Module: sui::linked_table
Function: front
public fun front<K: copy + drop + store, V: store>(table: &LinkedTable<K, V>): &Option<K> {
&table.head
}�j� �move�u}�(j~ �linked_table.move_4�j� jv j� Kj� ��File: linked_table.move
Module: sui::linked_table
Function: back
public fun back<K: copy + drop + store, V: store>(table: &LinkedTable<K, V>): &Option<K> {
&table.tail
}�j� �move�u}�(j~ �linked_table.move_5�j� jv j� Kj� X� File: linked_table.move
Module: sui::linked_table
Function: push_front
public fun push_front<K: copy + drop + store, V: store>(
table: &mut LinkedTable<K, V>,
k: K,
value: V,
) {
let old_head = option::swap_or_fill(&mut table.head, k);
if (option::is_none(&table.tail)) option::fill(&mut table.tail, k);
let prev = option::none();
let next = if (option::is_some(&old_head)) {
let old_head_k = option::destroy_some(old_head);
field::borrow_mut<K, Node<K, V>>(&mut table.id, old_head_k).prev = option::some(k);
option::some(old_head_k)
}�j� �move�u}�(j~ �linked_table.move_6�j� jv j� Kj� X] File: linked_table.move
Module: sui::linked_table
Function: push_back
public fun push_back<K: copy + drop + store, V: store>(
table: &mut LinkedTable<K, V>,
k: K,
value: V,
) {
if (option::is_none(&table.head)) option::fill(&mut table.head, k);
let old_tail = option::swap_or_fill(&mut table.tail, k);
let prev = if (option::is_some(&old_tail)) {
let old_tail_k = option::destroy_some(old_tail);
field::borrow_mut<K, Node<K, V>>(&mut table.id, old_tail_k).next = option::some(k);
option::some(old_tail_k)
}�j� �move�u}�(j~ �linked_table.move_7�j� jv j� Kj� ��File: linked_table.move
Module: sui::linked_table
Function: borrow
public fun borrow<K: copy + drop + store, V: store>(table: &LinkedTable<K, V>, k: K): &V {
&field::borrow<K, Node<K, V>>(&table.id, k).value
}�j� �move�u}�(j~ �linked_table.move_8�j� jv j� Kj� X File: linked_table.move
Module: sui::linked_table
Function: borrow_mut
public fun borrow_mut<K: copy + drop + store, V: store>(
table: &mut LinkedTable<K, V>,
k: K,
): &mut V {
&mut field::borrow_mut<K, Node<K, V>>(&mut table.id, k).value
}�j� �move�u}�(j~ �linked_table.move_9�j� jv j� K j� ��File: linked_table.move
Module: sui::linked_table
Function: prev
public fun prev<K: copy + drop + store, V: store>(table: &LinkedTable<K, V>, k: K): &Option<K> {
&field::borrow<K, Node<K, V>>(&table.id, k).prev
}�j� �move�u}�(j~ �linked_table.move_10�j� jv j� K
j� ��File: linked_table.move
Module: sui::linked_table
Function: next
public fun next<K: copy + drop + store, V: store>(table: &LinkedTable<K, V>, k: K): &Option<K> {
&field::borrow<K, Node<K, V>>(&table.id, k).next
}�j� �move�u}�(j~ �linked_table.move_11�j� jv j� Kj� ��File: linked_table.move
Module: sui::linked_table
Function: remove
public fun remove<K: copy + drop + store, V: store>(table: &mut LinkedTable<K, V>, k: K): V {
let Node<K, V> { prev, next, value }�j� �move�u}�(j~ �linked_table.move_12�j� jv j� Kj� XA File: linked_table.move
Module: sui::linked_table
Function: pop_front
public fun pop_front<K: copy + drop + store, V: store>(table: &mut LinkedTable<K, V>): (K, V) {
assert!(option::is_some(&table.head), ETableIsEmpty);
let head = *option::borrow(&table.head);
(head, remove(table, head))
}�j� �move�u}�(j~ �linked_table.move_13�j� jv j� K
j� X? File: linked_table.move
Module: sui::linked_table
Function: pop_back
public fun pop_back<K: copy + drop + store, V: store>(table: &mut LinkedTable<K, V>): (K, V) {
assert!(option::is_some(&table.tail), ETableIsEmpty);
let tail = *option::borrow(&table.tail);
(tail, remove(table, tail))
}�j� �move�u}�(j~ �linked_table.move_14�j� jv j� Kj� ��File: linked_table.move
Module: sui::linked_table
Function: contains
public fun contains<K: copy + drop + store, V: store>(table: &LinkedTable<K, V>, k: K): bool {
field::exists_with_type<K, Node<K, V>>(&table.id, k)
}�j� �move�u}�(j~ �linked_table.move_15�j� jv j� Kj� ��File: linked_table.move
Module: sui::linked_table
Function: length
public fun length<K: copy + drop + store, V: store>(table: &LinkedTable<K, V>): u64 {
table.size
}�j� �move�u}�(j~ �linked_table.move_16�j� jv j� Kj� ��File: linked_table.move
Module: sui::linked_table
Function: is_empty
public fun is_empty<K: copy + drop + store, V: store>(table: &LinkedTable<K, V>): bool {
table.size == 0
}�j� �move�u}�(j~ �linked_table.move_17�j� jv j� Kj� ��File: linked_table.move
Module: sui::linked_table
Function: destroy_empty
public fun destroy_empty<K: copy + drop + store, V: store>(table: LinkedTable<K, V>) {
let LinkedTable { id, size, head: _, tail: _ }�j� �move�u}�(j~ �linked_table.move_18�j� jv j� Kj� ��File: linked_table.move
Module: sui::linked_table
Function: drop
public fun drop<K: copy + drop + store, V: drop + store>(table: LinkedTable<K, V>) {
let LinkedTable { id, size: _, head: _, tail: _ }�j� �move�u}�(j~ �
sui.move_0�j� �docs/move_files/sui.move�j� K j� �%File: sui.move
Move Module: sui::sui�j� �move�u}�(j~ �
sui.move_1�j� j� j� Kj� ��File: sui.move
Module: sui::sui
Dependencies:
use std::option;
use sui::tx_context::{Self, TxContext};
use sui::balance::{Self, Balance};
use sui::transfer;
use sui::coin;
�j� �move�u}�(j~ �
sui.move_2�j� j� j� Kj� X. File: sui.move
Module: sui::sui
Function: new
fun new(ctx: &mut TxContext): Balance<SUI> {
assert!(tx_context::sender(ctx) == @0x0, ENotSystemAddress);
assert!(tx_context::epoch(ctx) == 0, EAlreadyMinted);
let (treasury, metadata) = coin::create_currency(
SUI {}�j� �move�u}�(j~ �
sui.move_3�j� j� j� Kj� ��File: sui.move
Module: sui::sui
Function: transfer
fun transfer(c: coin::Coin<SUI>, recipient: address) {
transfer::public_transfer(c, recipient)
}�j� �move�u}�(j~ �clock.move_0�j� �docs/move_files/clock.move�j� K j� �)File: clock.move
Move Module: sui::clock�j� �move�u}�(j~ �clock.move_1�j� j� j� Kj� X� File: clock.move
Module: sui::clock
Dependencies:
use sui::object::{Self, UID};
use sui::transfer;
use sui::tx_context::{Self, TxContext};
use `Clock` as an
/// input parameter, unless it is passed by immutable reference.
struct Clock has key {
id: UID,
/// The clock's timestamp, which is set automatically by a
/// system transaction every time consensus commits a
/// schedule, or by `sui::clock::increment_for_testing` during
/// testing.
timestamp_ms: u64,
}
/// The `clock`'s current timestamp as a running total of
/// milliseconds since an arbitrary point in the past.
public fun timestamp_ms(clock: &Clock): u64 {
clock.timestamp_ms
}
#[allow(unused_function)]
/// Create and share the singleton Clock -- this function is
/// called exactly once, during genesis.
fun create(ctx: &TxContext) {
assert!(tx_context::sender(ctx) == @0x0, ENotSystemAddress);
�j� �move�u}�(j~ �clock.move_2�j� j� j� Kj� ��File: clock.move
Module: sui::clock
Function: timestamp_ms
public fun timestamp_ms(clock: &Clock): u64 {
clock.timestamp_ms
}�j� �move�u}�(j~ �clock.move_3�j� j� j� Kj� X� File: clock.move
Module: sui::clock
Function: create
fun create(ctx: &TxContext) {
assert!(tx_context::sender(ctx) == @0x0, ENotSystemAddress);
transfer::share_object(Clock {
id: object::clock(),
// Initialised to zero, but set to a real timestamp by a
// system transaction before it can be witnessed by a move
// call.
timestamp_ms: 0,
}�j� �move�u}�(j~ �clock.move_4�j� j� j� Kj� X� File: clock.move
Module: sui::clock
Function: consensus_commit_prologue
fun consensus_commit_prologue(
clock: &mut Clock,
timestamp_ms: u64,
ctx: &TxContext,
) {
// Validator will make a special system call with sender set as 0x0.
assert!(tx_context::sender(ctx) == @0x0, ENotSystemAddress);
clock.timestamp_ms = timestamp_ms
}�j� �move�u}�(j~ �clock.move_5�j� j� j� Kj� ��File: clock.move
Module: sui::clock
Function: create_for_testing
public fun create_for_testing(ctx: &mut sui::tx_context::TxContext): Clock {
Clock {
id: object::new(ctx),
timestamp_ms: 0,
}�j� �move�u}�(j~ �clock.move_6�j� j� j� Kj� ��File: clock.move
Module: sui::clock
Function: share_for_testing
public fun share_for_testing(clock: Clock) {
transfer::share_object(clock)
}�j� �move�u}�(j~ �clock.move_7�j� j� j� Kj� ��File: clock.move
Module: sui::clock
Function: increment_for_testing
public fun increment_for_testing(clock: &mut Clock, tick: u64) {
clock.timestamp_ms = clock.timestamp_ms + tick;
}�j� �move�u}�(j~ �clock.move_8�j� j� j� Kj� ��File: clock.move
Module: sui::clock
Function: set_for_testing
public fun set_for_testing(clock: &mut Clock, timestamp_ms: u64) {
assert!(timestamp_ms >= clock.timestamp_ms, 0);
clock.timestamp_ms = timestamp_ms;
}�j� �move�u}�(j~ �clock.move_9�j� j� j� K j� ��File: clock.move
Module: sui::clock
Function: destroy_for_testing
public fun destroy_for_testing(clock: Clock) {
let Clock { id, timestamp_ms: _ }�j� �move�u}�(j~ �object_table.move_0�j� �!docs/move_files/object_table.move�j� K j� �7File: object_table.move
Move Module: sui::object_table�j� �move�u}�(j~ �object_table.move_1�j� j� j� Kj� ��File: object_table.move
Module: sui::object_table
Dependencies:
use std::option::Option;
use sui::object::{Self, ID, UID};
use sui::dynamic_object_field as ofield;
use sui::tx_context::TxContext;
�j� �move�u}�(j~ �object_table.move_2�j� j� j� Kj� ��File: object_table.move
Module: sui::object_table
Function: new
public fun new<K: copy + drop + store, V: key + store>(ctx: &mut TxContext): ObjectTable<K, V> {
ObjectTable {
id: object::new(ctx),
size: 0,
}�j� �move�u}�(j~ �object_table.move_3�j� j� j� Kj� ��File: object_table.move
Module: sui::object_table
Function: add
public fun add<K: copy + drop + store, V: key + store>(table: &mut ObjectTable<K, V>, k: K, v: V) {
ofield::add(&mut table.id, k, v);
table.size = table.size + 1;
}�j� �move�u}�(j~ �object_table.move_4�j� j� j� Kj� ��File: object_table.move
Module: sui::object_table
Function: borrow
public fun borrow<K: copy + drop + store, V: key + store>(table: &ObjectTable<K, V>, k: K): &V {
ofield::borrow(&table.id, k)
}�j� �move�u}�(j~ �object_table.move_5�j� j� j� Kj� X File: object_table.move
Module: sui::object_table
Function: borrow_mut
public fun borrow_mut<K: copy + drop + store, V: key + store>(
table: &mut ObjectTable<K, V>,
k: K,
): &mut V {
ofield::borrow_mut(&mut table.id, k)
}�j� �move�u}�(j~ �object_table.move_6�j� j� j� Kj� X File: object_table.move
Module: sui::object_table
Function: remove
public fun remove<K: copy + drop + store, V: key + store>(table: &mut ObjectTable<K, V>, k: K): V {
let v = ofield::remove(&mut table.id, k);
table.size = table.size - 1;
v
}�j� �move�u}�(j~ �object_table.move_7�j� j� j� Kj� ��File: object_table.move
Module: sui::object_table
Function: contains
public fun contains<K: copy + drop + store, V: key + store>(table: &ObjectTable<K, V>, k: K): bool {
ofield::exists_<K>(&table.id, k)
}�j� �move�u}�(j~ �object_table.move_8�j� j� j� Kj� ��File: object_table.move
Module: sui::object_table
Function: length
public fun length<K: copy + drop + store, V: key + store>(table: &ObjectTable<K, V>): u64 {
table.size
}�j� �move�u}�(j~ �object_table.move_9�j� j� j� K j� ��File: object_table.move
Module: sui::object_table
Function: is_empty
public fun is_empty<K: copy + drop + store, V: key + store>(table: &ObjectTable<K, V>): bool {
table.size == 0
}�j� �move�u}�(j~ �object_table.move_10�j� j� j� K
j� ��File: object_table.move
Module: sui::object_table
Function: destroy_empty
public fun destroy_empty<K: copy + drop + store, V: key + store>(table: ObjectTable<K, V>) {
let ObjectTable { id, size }�j� �move�u}�(j~ �object_table.move_11�j� j� j� Kj� ��File: object_table.move
Module: sui::object_table
Function: value_id
public fun value_id<K: copy + drop + store, V: key + store>(
table: &ObjectTable<K, V>,
k: K,
): Option<ID> {
ofield::id(&table.id, k)
}�j� �move�u}�(j~ �balance.move_0�j� �docs/move_files/balance.move�j� K j� �>File: balance.move
Module: sui::balance
Header Comments:
///�j� �move�u}�(j~ �balance.move_1�j� j. j� Kj� �-File: balance.move
Move Module: sui::balance�j� �move�u}�(j~ �balance.move_2�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Dependencies:
use sui::tx_context::{Self, TxContext};
use sui::balance;
use sui::sui::SUI;
use sui::test_utils;
�j� �move�u}�(j~ �balance.move_3�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: value
public fun value<T>(self: &Balance<T>): u64 {
self.value
}�j� �move�u}�(j~ �balance.move_4�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: supply_value
public fun supply_value<T>(supply: &Supply<T>): u64 {
supply.value
}�j� �move�u}�(j~ �balance.move_5�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: create_supply
public fun create_supply<T: drop>(_: T): Supply<T> {
Supply { value: 0 }�j� �move�u}�(j~ �balance.move_6�j� j. j� Kj� X! File: balance.move
Module: sui::balance
Function: increase_supply
public fun increase_supply<T>(self: &mut Supply<T>, value: u64): Balance<T> {
assert!(value < (18446744073709551615u64 - self.value), EOverflow);
self.value = self.value + value;
Balance { value }�j� �move�u}�(j~ �balance.move_7�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: decrease_supply
public fun decrease_supply<T>(self: &mut Supply<T>, balance: Balance<T>): u64 {
let Balance { value }�j� �move�u}�(j~ �balance.move_8�j� j. j� Kj� �yFile: balance.move
Module: sui::balance
Function: zero
public fun zero<T>(): Balance<T> {
Balance { value: 0 }�j� �move�u}�(j~ �balance.move_9�j� j. j� K j� ��File: balance.move
Module: sui::balance
Function: join
public fun join<T>(self: &mut Balance<T>, balance: Balance<T>): u64 {
let Balance { value }�j� �move�u}�(j~ �balance.move_10�j� j. j� K
j� ��File: balance.move
Module: sui::balance
Function: split
public fun split<T>(self: &mut Balance<T>, value: u64): Balance<T> {
assert!(self.value >= value, ENotEnough);
self.value = self.value - value;
Balance { value }�j� �move�u}�(j~ �balance.move_11�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: withdraw_all
public fun withdraw_all<T>(self: &mut Balance<T>): Balance<T> {
let value = self.value;
split(self, value)
}�j� �move�u}�(j~ �balance.move_12�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: destroy_zero
public fun destroy_zero<T>(balance: Balance<T>) {
assert!(balance.value == 0, ENonZero);
let Balance { value: _ }�j� �move�u}�(j~ �balance.move_13�j� j. j� K
j� ��File: balance.move
Module: sui::balance
Function: create_staking_rewards
fun create_staking_rewards<T>(value: u64, ctx: &TxContext): Balance<T> {
assert!(tx_context::sender(ctx) == @0x0, ENotSystemAddress);
Balance { value }�j� �move�u}�(j~ �balance.move_14�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: destroy_storage_rebates
fun destroy_storage_rebates<T>(self: Balance<T>, ctx: &TxContext) {
assert!(tx_context::sender(ctx) == @0x0, ENotSystemAddress);
let Balance { value: _ }�j� �move�u}�(j~ �balance.move_15�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: destroy_supply
fun destroy_supply<T>(self: Supply<T>): u64 {
let Supply { value }�j� �move�u}�(j~ �balance.move_16�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: create_for_testing
public fun create_for_testing<T>(value: u64): Balance<T> {
Balance { value }�j� �move�u}�(j~ �balance.move_17�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: destroy_for_testing
public fun destroy_for_testing<T>(self: Balance<T>): u64 {
let Balance { value }�j� �move�u}�(j~ �balance.move_18�j� j. j� Kj� ��File: balance.move
Module: sui::balance
Function: create_supply_for_testing
public fun create_supply_for_testing<T>(): Supply<T> {
Supply { value: 0 }�j� �move�u}�(j~ �balance.move_19�j� j. j� Kj� X File: balance.move
Module: sui::balance
Function: test_balance
fun test_balance() {
let balance = balance::zero<SUI>();
let another = balance::create_for_testing(1000);
balance::join(&mut balance, another);
assert!(balance::value(&balance) == 1000, 0);
let balance1 = balance::split(&mut balance, 333);
let balance2 = balance::split(&mut balance, 333);
let balance3 = balance::split(&mut balance, 334);
balance::destroy_zero(balance);
assert!(balance::value(&balance1) == 333, 1);
assert!(balance::value(&balance2) == 333, 2);
assert!(balance::value(&balance3) == 334, 3);
test_utils::destroy(balance1);
test_utils::destroy(balance2);
test_utils::destroy(balance3);
}�j� �move�u}�(j~ �token.move_0�j� �docs/move_files/token.move�j� K j� �DFile: token.move
Module: sui::token
Header Comments:
/// The Token�j� �move�u}�(j~ �token.move_1�j� j j� Kj� �)File: token.move
Move Module: sui::token�j� �move�u}�(j~ �token.move_2�j� j j� Kj� X� File: token.move
Module: sui::token
Dependencies:
use std::vector;
use std::string::{Self, String};
use std::option::{Self, Option};
use std::type_name::{Self, TypeName};
use sui::tx_context::{Self, TxContext};
use sui::coin::{Self, Coin, TreasuryCap};
use sui::balance::{Self, Balance};
use sui::object::{Self, ID, UID};
use sui::vec_map::{Self, VecMap};
use sui::vec_set::{Self, VecSet};
use sui::dynamic_field as df;
use sui::transfer;
use it for authorization.
public fun new<T>(
_treasury_cap: &TreasuryCap<T>, ctx: &mut TxContext
): (TokenPolicy<T>, TokenPolicyCap<T>) {
let policy = TokenPolicy {
id: object::new(ctx),
spent_balance: balance::zero(),
rules: vec_map::empty()
};
use `confirm_request_mut`.
///
/// Aborts if:
/// - the action is not allowed (missing record in `rules`)
/// - action contains `spent_balance` (use `confirm_request_mut`)
/// - the `ActionRequest` does not meet the `TokenPolicy` rules for the action
public fun confirm_request<T>(
policy: &TokenPolicy<T>,
request: ActionRequest<T>,
_ctx: &mut TxContext
): (String, u64, address, Option<address>) {
assert!(option::is_none(&request.spent_balance), ECantConsumeBalance);
use in different actions.
///
/// - Rule witness guarantees that the `Config` is approved by the Rule.
/// - `TokenPolicyCap` guarantees that the `Config` setup is initiated by
/// the `TokenPolicy` owner.
public fun add_rule_config<T, Rule: drop, Config: store>(
_rule: Rule,
self: &mut TokenPolicy<T>,
cap: &TokenPolicyCap<T>,
config: Config,
_ctx: &mut TxContext
) {
assert!(object::id(self) == cap.for, ENotAuthorized);
�j� �move�u}�(j~ �token.move_3�j� j j� Kj� Xc File: token.move
Module: sui::token
Struct: ActionRequest
/// Name of the Action to look up in the Policy. Name can be one of the
/// default actions: `transfer`, `spend`, `to_coin`, `from_coin` or a
/// custom action.
name: String,
/// Amount is present in all of the txs
amount: u64,
/// Sender is a permanent field always
sender: address,
/// Recipient is only available in `transfer` action.
recipient: Option<address>,
/// The balance to be "spent" in the `TokenPolicy`, only available
/// in the `spend` action.
spent_balance: Option<Balance<T>>,
/// Collected approvals (stamps) from completed `Rules`. They're matched
/// against `TokenPolicy.rules` to determine if the request can be
/// confirmed.
approvals: VecSet<TypeName>,�j� �move�u}�(j~ �token.move_4�j� j j� Kj� XO File: token.move
Module: sui::token
Function: new
public fun new<T>(
_treasury_cap: &TreasuryCap<T>, ctx: &mut TxContext
): (TokenPolicy<T>, TokenPolicyCap<T>) {
let policy = TokenPolicy {
id: object::new(ctx),
spent_balance: balance::zero(),
rules: vec_map::empty()
}�j� �move�u}�(j~ �token.move_5�j� j j� Kj� ��File: token.move
Module: sui::token
Function: share_policy
public fun share_policy<T>(policy: TokenPolicy<T>) {
transfer::share_object(policy)
}�j� �move�u}�(j~ �token.move_6�j� j j� Kj� X� File: token.move
Module: sui::token
Function: transfer
public fun transfer<T>(
t: Token<T>, recipient: address, ctx: &mut TxContext
): ActionRequest<T> {
let amount = balance::value(&t.balance);
transfer::transfer(t, recipient);
new_request(
transfer_action(),
amount,
option::some(recipient),
option::none(),
ctx
)
}�j� �move�u}�(j~ �token.move_7�j� j j� Kj� ��File: token.move
Module: sui::token
Function: spend
public fun spend<T>(t: Token<T>, ctx: &mut TxContext): ActionRequest<T> {
let Token { id, balance }�j� �move�u}�(j~ �token.move_8�j� j j� Kj� ��File: token.move
Module: sui::token
Function: to_coin
public fun to_coin<T>(
t: Token<T>, ctx: &mut TxContext
): (Coin<T>, ActionRequest<T>) {
let Token { id, balance }�j� �move�u}�(j~ �token.move_9�j� j j� K j� XC File: token.move
Module: sui::token
Function: from_coin
public fun from_coin<T>(
coin: Coin<T>, ctx: &mut TxContext
): (Token<T>, ActionRequest<T>) {
let amount = coin::value(&coin);
let token = Token {
id: object::new(ctx),
balance: coin::into_balance(coin)
}�j� �move�u}�(j~ �
token.move_10�j� j j� K
j� ��File: token.move
Module: sui::token
Function: join
public fun join<T>(token: &mut Token<T>, another: Token<T>) {
let Token { id, balance }�j� �move�u}�(j~ �
token.move_11�j� j j� Kj� Xd File: token.move
Module: sui::token
Function: split
public fun split<T>(
token: &mut Token<T>, amount: u64, ctx: &mut TxContext
): Token<T> {
assert!(balance::value(&token.balance) >= amount, EBalanceTooLow);
Token {
id: object::new(ctx),
balance: balance::split(&mut token.balance, amount),
}�j� �move�u}�(j~ �
token.move_12�j� j j� Kj� ��File: token.move
Module: sui::token
Function: zero
public fun zero<T>(ctx: &mut TxContext): Token<T> {
Token {
id: object::new(ctx),
balance: balance::zero(),
}�j� �move�u}�(j~ �
token.move_13�j� j j� K
j� ��File: token.move
Module: sui::token
Function: destroy_zero
public fun destroy_zero<T>(token: Token<T>) {
let Token { id, balance }�j� �move�u}�(j~ �
token.move_14�j� j j� Kj� ��File: token.move
Module: sui::token
Function: keep
public fun keep<T>(token: Token<T>, ctx: &mut TxContext) {
transfer::transfer(token, tx_context::sender(ctx))
}�j� �move�u}�(j~ �
token.move_15�j� j j� Kj� X� File: token.move
Module: sui::token
Function: new_request
public fun new_request<T>(
name: String,
amount: u64,
recipient: Option<address>,
spent_balance: Option<Balance<T>>,
ctx: &TxContext
): ActionRequest<T> {
ActionRequest {
name,
amount,
recipient,
spent_balance,
sender: tx_context::sender(ctx),
approvals: vec_set::empty(),
}�j� �move�u}�(j~ �
token.move_16�j� j j� Kj� X File: token.move
Module: sui::token
Function: confirm_request
public fun confirm_request<T>(
policy: &TokenPolicy<T>,
request: ActionRequest<T>,
_ctx: &mut TxContext
): (String, u64, address, Option<address>) {
assert!(option::is_none(&request.spent_balance), ECantConsumeBalance);
assert!(vec_map::contains(&policy.rules, &request.name), EUnknownAction);
let ActionRequest {
name, approvals,
spent_balance,
amount, sender, recipient,
}�j� �move�u}�(j~ �
token.move_17�j� j j� Kj� XU File: token.move
Module: sui::token
Function: confirm_request_mut
public fun confirm_request_mut<T>(
policy: &mut TokenPolicy<T>,
request: ActionRequest<T>,
ctx: &mut TxContext
): (String, u64, address, Option<address>) {
assert!(vec_map::contains(&policy.rules, &request.name), EUnknownAction);
assert!(option::is_some(&request.spent_balance), EUseImmutableConfirm);
balance::join(
&mut policy.spent_balance,
option::extract(&mut request.spent_balance)
);
confirm_request(policy, request, ctx)
}�j� �move�u}�(j~ �
token.move_18�j� j j� Kj� X� File: token.move
Module: sui::token
Function: confirm_with_policy_cap
public fun confirm_with_policy_cap<T>(
_policy_cap: &TokenPolicyCap<T>,
request: ActionRequest<T>,
_ctx: &mut TxContext
): (String, u64, address, Option<address>) {
assert!(option::is_none(&request.spent_balance), ECantConsumeBalance);
let ActionRequest {
name, amount, sender, recipient, approvals: _, spent_balance
}�j� �move�u}�(j~ �
token.move_19�j� j j� Kj� X� File: token.move
Module: sui::token
Function: confirm_with_treasury_cap
public fun confirm_with_treasury_cap<T>(
treasury_cap: &mut TreasuryCap<T>,
request: ActionRequest<T>,
_ctx: &mut TxContext
): (String, u64, address, Option<address>) {
let ActionRequest {
name, amount, sender, recipient, approvals: _,
spent_balance
}�j� �move�u}�(j~ �
token.move_20�j� j j� Kj� ��File: token.move
Module: sui::token
Function: add_approval
public fun add_approval<T, W: drop>(
_t: W, request: &mut ActionRequest<T>, _ctx: &mut TxContext
) {
vec_set::insert(&mut request.approvals, type_name::get<W>())
}�j� �move�u}�(j~ �
token.move_21�j� j j� Kj� X� File: token.move
Module: sui::token
Function: add_rule_config
public fun add_rule_config<T, Rule: drop, Config: store>(
_rule: Rule,
self: &mut TokenPolicy<T>,
cap: &TokenPolicyCap<T>,
config: Config,
_ctx: &mut TxContext
) {
assert!(object::id(self) == cap.for, ENotAuthorized);
df::add(&mut self.id, key<Rule>(), config)
}�j� �move�u}�(j~ �
token.move_22�j� j j� Kj� X, File: token.move
Module: sui::token
Function: rule_config
public fun rule_config<T, Rule: drop, Config: store>(
_rule: Rule, self: &TokenPolicy<T>
): &Config {
assert!(has_rule_config_with_type<T, Rule, Config>(self), ENoConfig);
df::borrow(&self.id, key<Rule>())
}�j� �move�u}�(j~ �
token.move_23�j� j j� Kj� X� File: token.move
Module: sui::token
Function: rule_config_mut
public fun rule_config_mut<T, Rule: drop, Config: store>(
_rule: Rule, self: &mut TokenPolicy<T>, cap: &TokenPolicyCap<T>
): &mut Config {
assert!(has_rule_config_with_type<T, Rule, Config>(self), ENoConfig);
assert!(object::id(self) == cap.for, ENotAuthorized);
df::borrow_mut(&mut self.id, key<Rule>())
}�j� �move�u}�(j~ �
token.move_24�j� j j� Kj� X� File: token.move
Module: sui::token
Function: remove_rule_config
public fun remove_rule_config<T, Rule, Config: store>(
self: &mut TokenPolicy<T>,
cap: &TokenPolicyCap<T>,
_ctx: &mut TxContext
): Config {
assert!(has_rule_config_with_type<T, Rule, Config>(self), ENoConfig);
assert!(object::id(self) == cap.for, ENotAuthorized);
df::remove(&mut self.id, key<Rule>())
}�j� �move�u}�(j~ �
token.move_25�j� j j� Kj� ��File: token.move
Module: sui::token
Function: has_rule_config
public fun has_rule_config<T, Rule>(self: &TokenPolicy<T>): bool {
df::exists_<RuleKey<Rule>>(&self.id, key<Rule>())
}�j� �move�u}�(j~ �
token.move_26�j� j j� Kj� X File: token.move
Module: sui::token
Function: has_rule_config_with_type
public fun has_rule_config_with_type<T, Rule, Config: store>(
self: &TokenPolicy<T>
): bool {
df::exists_with_type<RuleKey<Rule>, Config>(&self.id, key<Rule>())
}�j� �move�u}�(j~ �
token.move_27�j� j j� Kj� XT File: token.move
Module: sui::token
Function: allow
public fun allow<T>(
self: &mut TokenPolicy<T>,
cap: &TokenPolicyCap<T>,
action: String,
_ctx: &mut TxContext
) {
assert!(object::id(self) == cap.for, ENotAuthorized);
vec_map::insert(&mut self.rules, action, vec_set::empty());
}�j� �move�u}�(j~ �
token.move_28�j� j j� Kj� XI File: token.move
Module: sui::token
Function: disallow
public fun disallow<T>(
self: &mut TokenPolicy<T>,
cap: &TokenPolicyCap<T>,
action: String,
_ctx: &mut TxContext
) {
assert!(object::id(self) == cap.for, ENotAuthorized);
vec_map::remove(&mut self.rules, &action);
}�j� �move�u}�(j~ �
token.move_29�j� j j� Kj� X� File: token.move
Module: sui::token
Function: add_rule_for_action
public fun add_rule_for_action<T, Rule: drop>(
self: &mut TokenPolicy<T>,
cap: &TokenPolicyCap<T>,
action: String,
ctx: &mut TxContext
) {
assert!(object::id(self) == cap.for, ENotAuthorized);
if (!vec_map::contains(&self.rules, &action)) {
allow(self, cap, action, ctx);
}�j� �move�u}�(j~ �
token.move_30�j� j j� Kj� X� File: token.move
Module: sui::token
Function: remove_rule_for_action
public fun remove_rule_for_action<T, Rule: drop>(
self: &mut TokenPolicy<T>,
cap: &TokenPolicyCap<T>,
action: String,
_ctx: &mut TxContext
) {
assert!(object::id(self) == cap.for, ENotAuthorized);
vec_set::remove(
vec_map::get_mut(&mut self.rules, &action),
&type_name::get<Rule>()
)
}�j� �move�u}�(j~ �
token.move_31�j� j j� Kj� X File: token.move
Module: sui::token
Function: mint
public fun mint<T>(
cap: &mut TreasuryCap<T>, amount: u64, ctx: &mut TxContext
): Token<T> {
let balance = balance::increase_supply(coin::supply_mut(cap), amount);
Token { id: object::new(ctx), balance }�j� �move�u}�(j~ �
token.move_32�j� j j� K j� ��File: token.move
Module: sui::token
Function: burn
public fun burn<T>(cap: &mut TreasuryCap<T>, token: Token<T>) {
let Token { id, balance }�j� �move�u}�(j~ �
token.move_33�j� j j� K!j� X� File: token.move
Module: sui::token
Function: flush
public fun flush<T>(
self: &mut TokenPolicy<T>,
cap: &mut TreasuryCap<T>,
_ctx: &mut TxContext
): u64 {
let amount = balance::value(&self.spent_balance);
let balance = balance::split(&mut self.spent_balance, amount);
balance::decrease_supply(coin::supply_mut(cap), balance)
}�j� �move�u}�(j~ �
token.move_34�j� j j� K"j� ��File: token.move
Module: sui::token
Function: is_allowed
public fun is_allowed<T>(self: &TokenPolicy<T>, action: &String): bool {
vec_map::contains(&self.rules, action)
}�j� �move�u}�(j~ �
token.move_35�j� j j� K#j� ��File: token.move
Module: sui::token
Function: rules
public fun rules<T>(
self: &TokenPolicy<T>, action: &String
): VecSet<TypeName> {
*vec_map::get(&self.rules, action)
}�j� �move�u}�(j~ �
token.move_36�j� j j� K$j� ��File: token.move
Module: sui::token
Function: spent_balance
public fun spent_balance<T>(self: &TokenPolicy<T>): u64 {
balance::value(&self.spent_balance)
}�j� �move�u}�(j~ �
token.move_37�j� j j� K%j� ��File: token.move
Module: sui::token
Function: value
public fun value<T>(t: &Token<T>): u64 {
balance::value(&t.balance)
}�j� �move�u}�(j~ �
token.move_38�j� j j� K&j� ��File: token.move
Module: sui::token
Function: transfer_action
public fun transfer_action(): String { string::utf8(TRANSFER) }�j� �move�u}�(j~ �
token.move_39�j� j j� K'j� �wFile: token.move
Module: sui::token
Function: spend_action
public fun spend_action(): String { string::utf8(SPEND) }�j� �move�u}�(j~ �
token.move_40�j� j j� K(j� �}File: token.move
Module: sui::token
Function: to_coin_action
public fun to_coin_action(): String { string::utf8(TO_COIN) }�j� �move�u}�(j~ �
token.move_41�j� j j� K)j� ��File: token.move
Module: sui::token
Function: from_coin_action
public fun from_coin_action(): String { string::utf8(FROM_COIN) }�j� �move�u}�(j~ �
token.move_42�j� j j� K*j� �{File: token.move
Module: sui::token
Function: action
public fun action<T>(self: &ActionRequest<T>): String { self.name }�j� �move�u}�(j~ �
token.move_43�j� j j� K+j� �zFile: token.move
Module: sui::token
Function: amount
public fun amount<T>(self: &ActionRequest<T>): u64 { self.amount }�j� �move�u}�(j~ �
token.move_44�j� j j� K,j� �~File: token.move
Module: sui::token
Function: sender
public fun sender<T>(self: &ActionRequest<T>): address { self.sender }�j� �move�u}�(j~ �
token.move_45�j� j j� K-j� ��File: token.move
Module: sui::token
Function: recipient
public fun recipient<T>(self: &ActionRequest<T>): Option<address> {
self.recipient
}�j� �move�u}�(j~ �
token.move_46�j� j j� K.j� ��File: token.move
Module: sui::token
Function: approvals
public fun approvals<T>(self: &ActionRequest<T>): VecSet<TypeName> {
self.approvals
}�j� �move�u}�(j~ �
token.move_47�j� j j� K/j� ��File: token.move
Module: sui::token
Function: spent
public fun spent<T>(self: &ActionRequest<T>): Option<u64> {
if (option::is_some(&self.spent_balance)) {
option::some(balance::value(option::borrow(&self.spent_balance)))
}�j� �move�u}�(j~ �
token.move_48�j� j j� K0j� �tFile: token.move
Module: sui::token
Function: key
fun key<Rule>(): RuleKey<Rule> { RuleKey { is_protected: true }�j� �move�u}�(j~ �
token.move_49�j� j j� K1j� XV File: token.move
Module: sui::token
Function: new_policy_for_testing
public fun new_policy_for_testing<T>(
ctx: &mut TxContext
): (TokenPolicy<T>, TokenPolicyCap<T>) {
let policy = TokenPolicy {
id: object::new(ctx),
rules: vec_map::empty(),
spent_balance: balance::zero(),
}�j� �move�u}�(j~ �
token.move_50�j� j j� K2j� ��File: token.move
Module: sui::token
Function: burn_policy_for_testing
public fun burn_policy_for_testing<T>(
policy: TokenPolicy<T>,
cap: TokenPolicyCap<T>
) {
let TokenPolicyCap { id: cap_id, for: _ }�j� �move�u}�(j~ �
token.move_51�j� j j� K3j� ��File: token.move
Module: sui::token
Function: mint_for_testing
public fun mint_for_testing<T>(amount: u64, ctx: &mut TxContext): Token<T> {
let balance = balance::create_for_testing(amount);
Token { id: object::new(ctx), balance }�j� �move�u}�(j~ �
token.move_52�j� j j� K4j� ��File: token.move
Module: sui::token
Function: burn_for_testing
public fun burn_for_testing<T>(token: Token<T>) {
let Token { id, balance }�j� �move�u}�(j~ �versioned.move_0�j� �docs/move_files/versioned.move�j� K j� �1File: versioned.move
Move Module: sui::versioned�j� �move�u}�(j~ �versioned.move_1�j� jT j� Kj� XP File: versioned.move
Module: sui::versioned
Dependencies:
use sui::object::{UID, ID};
use sui::tx_context::TxContext;
use sui::object;
use sui::dynamic_field;
use mutable reference even if it's a read-only API.
struct Versioned has key, store {
id: UID,
version: u64,
}
/// Represents a hot potato object generated when we take out the dynamic field.
/// This is to make sure that we always put a new value back.
struct VersionChangeCap {
versioned_id: ID,
old_version: u64,
}
/// Create a new Versioned object that contains a initial value of type `T` with an initial version.
public fun create<T: store>(init_version: u64, init_value: T, ctx: &mut TxContext): Versioned {
let self = Versioned {
id: object::new(ctx),
version: init_version,
};
use the capability returned
/// by calling remove_value_for_upgrade.
public fun upgrade<T: store>(self: &mut Versioned, new_version: u64, new_value: T, cap: VersionChangeCap) {
let VersionChangeCap { versioned_id, old_version } = cap;
�j� �move�u}�(j~ �versioned.move_2�j� jT j� Kj� �sFile: versioned.move
Module: sui::versioned
Struct: VersionChangeCap
versioned_id: ID,
old_version: u64,�j� �move�u}�(j~ �versioned.move_3�j� jT j� Kj� X
File: versioned.move
Module: sui::versioned
Function: create
public fun create<T: store>(init_version: u64, init_value: T, ctx: &mut TxContext): Versioned {
let self = Versioned {
id: object::new(ctx),
version: init_version,
}�j� �move�u}�(j~ �versioned.move_4�j� jT j� Kj� ��File: versioned.move
Module: sui::versioned
Function: version
public fun version(self: &Versioned): u64 {
self.version
}�j� �move�u}�(j~ �versioned.move_5�j� jT j� Kj� ��File: versioned.move
Module: sui::versioned
Function: load_value
public fun load_value<T: store>(self: &Versioned): &T {
dynamic_field::borrow(&self.id, self.version)
}�j� �move�u}�(j~ �versioned.move_6�j� jT j� Kj� ��File: versioned.move
Module: sui::versioned
Function: load_value_mut
public fun load_value_mut<T: store>(self: &mut Versioned): &mut T {
dynamic_field::borrow_mut(&mut self.id, self.version)
}�j� �move�u}�(j~ �versioned.move_7�j� jT j� Kj� X File: versioned.move
Module: sui::versioned
Function: remove_value_for_upgrade
public fun remove_value_for_upgrade<T: store>(self: &mut Versioned): (T, VersionChangeCap) {
(
dynamic_field::remove(&mut self.id, self.version),
VersionChangeCap {
versioned_id: object::id(self),
old_version: self.version,
}�j� �move�u}�(j~ �versioned.move_8�j� jT j� Kj� ��File: versioned.move
Module: sui::versioned
Function: upgrade
public fun upgrade<T: store>(self: &mut Versioned, new_version: u64, new_value: T, cap: VersionChangeCap) {
let VersionChangeCap { versioned_id, old_version }�j� �move�u}�(j~ �versioned.move_9�j� jT j� K j� ��File: versioned.move
Module: sui::versioned
Function: destroy
public fun destroy<T: store>(self: Versioned): T {
let Versioned { id, version }�j� �move�u}�(j~ �dynamic_field.move_0�j� �"docs/move_files/dynamic_field.move�j� K j� �9File: dynamic_field.move
Move Module: sui::dynamic_field�j� �move�u}�(j~ �dynamic_field.move_1�j� j} j� Kj� XO File: dynamic_field.move
Module: sui::dynamic_field
Dependencies:
use std::option::{Self, Option};
use sui::object::{Self, ID, UID};
use sui::prover;
use &mut UID in several spots for access control
object: &mut UID,
name: Name,
value: Value,
) {
let object_addr = object::uid_to_address(object);
�j� �move�u}�(j~ �dynamic_field.move_2�j� j} j� Kj� XC File: dynamic_field.move
Module: sui::dynamic_field
Function: add
public fun add<Name: copy + drop + store, Value: store>(
// we use &mut UID in several spots for access control
object: &mut UID,
name: Name,
value: Value,
) {
let object_addr = object::uid_to_address(object);
let hash = hash_type_and_key(object_addr, name);
assert!(!has_child_object(object_addr, hash), EFieldAlreadyExists);
let field = Field {
id: object::new_uid_from_hash(hash),
name,
value,
}�j� �move�u}�(j~ �dynamic_field.move_3�j� j} j� Kj� X� File: dynamic_field.move
Module: sui::dynamic_field
Function: borrow
public fun borrow<Name: copy + drop + store, Value: store>(
object: &UID,
name: Name,
): &Value {
let object_addr = object::uid_to_address(object);
let hash = hash_type_and_key(object_addr, name);
let field = borrow_child_object<Field<Name, Value>>(object, hash);
&field.value
}�j� �move�u}�(j~ �dynamic_field.move_4�j� j} j� Kj� X� File: dynamic_field.move
Module: sui::dynamic_field
Function: borrow_mut
public fun borrow_mut<Name: copy + drop + store, Value: store>(
object: &mut UID,
name: Name,
): &mut Value {
let object_addr = object::uid_to_address(object);
let hash = hash_type_and_key(object_addr, name);
let field = borrow_child_object_mut<Field<Name, Value>>(object, hash);
&mut field.value
}�j� �move�u}�(j~ �dynamic_field.move_5�j� j} j� Kj� X\ File: dynamic_field.move
Module: sui::dynamic_field
Function: remove
public fun remove<Name: copy + drop + store, Value: store>(
object: &mut UID,
name: Name,
): Value {
let object_addr = object::uid_to_address(object);
let hash = hash_type_and_key(object_addr, name);
let Field { id, name: _, value }�j� �move�u}�(j~ �dynamic_field.move_6�j� j} j� Kj� XT File: dynamic_field.move
Module: sui::dynamic_field
Function: exists_
public fun exists_<Name: copy + drop + store>(
object: &UID,
name: Name,
): bool {
let object_addr = object::uid_to_address(object);
let hash = hash_type_and_key(object_addr, name);
has_child_object(object_addr, hash)
}�j� �move�u}�(j~ �dynamic_field.move_7�j� j} j� Kj� X? File: dynamic_field.move
Module: sui::dynamic_field
Function: remove_if_exists
public fun remove_if_exists<Name: copy + drop + store, Value: store>(
object: &mut UID,
name: Name
): Option<Value> {
if (exists_<Name>(object, name)) {
option::some(remove(object, name))
}�j� �move�u}�(j~ �dynamic_field.move_8�j� j} j� Kj� X� File: dynamic_field.move
Module: sui::dynamic_field
Function: exists_with_type
public fun exists_with_type<Name: copy + drop + store, Value: store>(
object: &UID,
name: Name,
): bool {
let object_addr = object::uid_to_address(object);
let hash = hash_type_and_key(object_addr, name);
has_child_object_with_ty<Field<Name, Value>>(object_addr, hash)
}�j� �move�u}�(j~ �dynamic_field.move_9�j� j} j� K j� XU File: dynamic_field.move
Module: sui::dynamic_field
Function: field_info
fun field_info<Name: copy + drop + store>(
object: &UID,
name: Name,
): (&UID, address) {
let object_addr = object::uid_to_address(object);
let hash = hash_type_and_key(object_addr, name);
let Field { id, name: _, value }�j� �move�u}�(j~ �dynamic_field.move_10�j� j} j� K
j� Xe File: dynamic_field.move
Module: sui::dynamic_field
Function: field_info_mut
fun field_info_mut<Name: copy + drop + store>(
object: &mut UID,
name: Name,
): (&mut UID, address) {
let object_addr = object::uid_to_address(object);
let hash = hash_type_and_key(object_addr, name);
let Field { id, name: _, value }�j� �move�u}�(j~ �dynamic_field.move_11�j� j} j� Kj� Xx File: dynamic_field.move
Module: sui::dynamic_field
Function: hash_type_and_key
fun hash_type_and_key<K: copy + drop + store>(parent: address, k: K): address;
spec hash_type_and_key {
pragma opaque;
// TODO: stub to be replaced by actual abort conditions if any
aborts_if [abstract] true;
// TODO: specify actual function behavior
}�j� �move�u}�(j~ �dynamic_field.move_12�j� j} j� Kj� Xu File: dynamic_field.move
Module: sui::dynamic_field
Function: borrow_child_object
fun borrow_child_object<Child: key>(object: &UID, id: address): &Child;
spec borrow_child_object {
pragma opaque;
// TODO: stub to be replaced by actual abort conditions if any
aborts_if [abstract] true;
// TODO: specify actual function behavior
}�j� �move�u}�(j~ �dynamic_field.move_13�j� j} j� K
j� X� File: dynamic_field.move
Module: sui::dynamic_field
Function: borrow_child_object_mut
fun borrow_child_object_mut<Child: key>(object: &mut UID, id: address): &mut Child;
spec borrow_child_object_mut {
pragma opaque;
// TODO: stub to be replaced by actual abort conditions if any
aborts_if [abstract] true;
// TODO: specify actual function behavior
}�j� �move�u}�(j~ �dynamic_field.move_14�j� j} j� Kj� Xw File: dynamic_field.move
Module: sui::dynamic_field
Function: remove_child_object
fun remove_child_object<Child: key>(parent: address, id: address): Child;
spec remove_child_object {
pragma opaque;
// TODO: stub to be replaced by actual abort conditions if any
aborts_if [abstract] true;
// TODO: specify actual function behavior
}�j� �move�u}�(j~ �dynamic_field.move_15�j� j} j� Kj� Xa File: dynamic_field.move
Module: sui::dynamic_field
Function: has_child_object
fun has_child_object(parent: address, id: address): bool;
spec has_child_object {
pragma opaque;
// TODO: stub to be replaced by actual abort conditions if any
aborts_if [abstract] true;
// TODO: specify actual function behavior
}�j� �move�u}�(j~ �dynamic_field.move_16�j� j} j� Kj� X� File: dynamic_field.move
Module: sui::dynamic_field
Function: has_child_object_with_ty
fun has_child_object_with_ty<Child: key>(parent: address, id: address): bool;
spec has_child_object_with_ty {
pragma opaque;
// TODO: stub to be replaced by actual abort conditions if any
aborts_if [abstract] true;
// TODO: specify actual function behavior
}�j� �move�u}�(j~ �
prover.move_0�j� �docs/move_files/prover.move�j� K j� �+File: prover.move
Move Module: sui::prover�j� �move�u}�(j~ �
prover.move_1�j� j� j� Kj� �GFile: prover.move
Module: sui::prover
Dependencies:
use sui::object;
�j� �move�u}�(j~ �
prover.move_2�j� j� j� Kj� ��File: prover.move
Module: sui::prover
Function: owned
fun owned<T: key>(obj: T): bool {
let addr = object::id(obj).bytes;
exists<object::Ownership>(addr) &&
global<object::Ownership>(addr).status == OWNED
}�j� �move�u}�(j~ �
prover.move_3�j� j� j� Kj� X= File: prover.move
Module: sui::prover
Function: owned_by
fun owned_by<T: key>(obj: T, owner: address): bool {
let addr = object::id(obj).bytes;
exists<object::Ownership>(addr) &&
global<object::Ownership>(addr).status == OWNED &&
global<object::Ownership>(addr).owner == owner
}�j� �move�u}�(j~ �
prover.move_4�j� j� j� Kj� ��File: prover.move
Module: sui::prover
Function: shared
fun shared<T: key>(obj: T): bool {
let addr = object::id(obj).bytes;
exists<object::Ownership>(addr) &&
global<object::Ownership>(addr).status == SHARED
}�j� �move�u}�(j~ �
prover.move_5�j� j� j� Kj� ��File: prover.move
Module: sui::prover
Function: immutable
fun immutable<T: key>(obj: T): bool {
let addr = object::id(obj).bytes;
exists<object::Ownership>(addr) &&
global<object::Ownership>(addr).status == IMMUTABLE
}�j� �move�u}�(j~ �
prover.move_6�j� j� j� Kj� ��File: prover.move
Module: sui::prover
Function: has_field
fun has_field<T: key, K: copy + drop + store>(obj: T, name: K): bool {
let uid = object::borrow_uid(obj);
uid_has_field<K>(uid, name)
}�j� �move�u}�(j~ �
prover.move_7�j� j� j� Kj� ��File: prover.move
Module: sui::prover
Function: num_fields
fun num_fields<T: key, K: copy + drop + store>(obj: T): u64 {
let uid = object::borrow_uid(obj);
uid_num_fields<K>(uid)
}�j� �move�u}�(j~ �
prover.move_8�j� j� j� Kj� X7 File: prover.move
Module: sui::prover
Function: uid_has_field
fun uid_has_field<K: copy + drop + store>(uid: sui::object::UID, name: K): bool {
let addr = object::uid_to_address(uid);
exists<object::DynamicFields<K>>(addr) && contains(global<object::DynamicFields<K>>(addr).names, name)
}�j� �move�u}�(j~ �
prover.move_9�j� j� j� K j� X File: prover.move
Module: sui::prover
Function: uid_num_fields
fun uid_num_fields<K: copy + drop + store>(uid: sui::object::UID): u64 {
let addr = object::uid_to_address(uid);
if (!exists<object::DynamicFields<K>>(addr)) {
0
}�j� �move�u}�(j~ �transfer.move_0�j� �docs/move_files/transfer.move�j� K j� �/File: transfer.move
Move Module: sui::transfer�j� �move�u}�(j~ �transfer.move_1�j� j� j� Kj� X� File: transfer.move
Module: sui::transfer
Dependencies:
use sui::object::{Self, ID, UID};
use sui::prover;
use the `to_receive`
/// argument to receive and return the referenced owned object of type `T`.
/// This function has custom rules performed by the Sui Move bytecode verifier that ensures
/// that `T` is an object defined in the module where `receive` is invoked. Use
/// `public_receive` to receivne an object with `store` outside of its module.
public fun receive<T: key>(parent: &mut UID, to_receive: Receiving<T>): T {
let Receiving {
id,
version,
} = to_receive;
use the `to_receive`
/// argument to receive and return the referenced owned object of type `T`.
/// The object must have `store` to be received outside of its defining module.
public fun public_receive<T: key + store>(parent: &mut UID, to_receive: Receiving<T>): T {
let Receiving {
id,
version,
} = to_receive;
�j� �move�u}�(j~ �transfer.move_2�j� j� j� Kj� ��File: transfer.move
Module: sui::transfer
Function: transfer
public fun transfer<T: key>(obj: T, recipient: address) {
transfer_impl(obj, recipient)
}�j� �move�u}�(j~ �transfer.move_3�j� j� j� Kj� ��File: transfer.move
Module: sui::transfer
Function: public_transfer
public fun public_transfer<T: key + store>(obj: T, recipient: address) {
transfer_impl(obj, recipient)
}�j� �move�u}�(j~ �transfer.move_4�j� j� j� Kj� ��File: transfer.move
Module: sui::transfer
Function: freeze_object
public fun freeze_object<T: key>(obj: T) {
freeze_object_impl(obj)
}�j� �move�u}�(j~ �transfer.move_5�j� j� j� Kj� ��File: transfer.move
Module: sui::transfer
Function: public_freeze_object
public fun public_freeze_object<T: key + store>(obj: T) {
freeze_object_impl(obj)
}�j� �move�u}�(j~ �transfer.move_6�j� j� j� Kj� ��File: transfer.move
Module: sui::transfer
Function: share_object
public fun share_object<T: key>(obj: T) {
share_object_impl(obj)
}�j� �move�u}�(j~ �transfer.move_7�j� j� j� Kj� ��File: transfer.move
Module: sui::transfer
Function: public_share_object
public fun public_share_object<T: key + store>(obj: T) {
share_object_impl(obj)
}�j� �move�u}�(j~ �transfer.move_8�j� j� j� Kj� ��File: transfer.move
Module: sui::transfer
Function: receive
public fun receive<T: key>(parent: &mut UID, to_receive: Receiving<T>): T {
let Receiving {
id,
version,
}�j� �move�u}�(j~ �transfer.move_9�j� j� j� K j� ��File: transfer.move
Module: sui::transfer
Function: public_receive
public fun public_receive<T: key + store>(parent: &mut UID, to_receive: Receiving<T>): T {
let Receiving {
id,
version,
}�j� �move�u}�(j~ �transfer.move_10�j� j� j� K
j� ��File: transfer.move
Module: sui::transfer
Function: receiving_object_id
public fun receiving_object_id<T: key>(receiving: &Receiving<T>): ID {
receiving.id
}�j� �move�u}�(j~ �transfer.move_11�j� j� j� Kj� Xi File: transfer.move
Module: sui::transfer
Function: receive_impl
fun receive_impl<T: key>(parent: address, to_receive: object::ID, version: u64): T;
spec receive_impl {
pragma opaque;
// TODO: stub to be replaced by actual abort conditions if any
aborts_if [abstract] true;
// TODO: specify actual function behavior
}�j� �move�u}�(j~ �
url.move_0�j� �docs/move_files/sui/url.move�j� K j� �)File: sui/url.move
Move Module: sui::url�j� �move�u}�(j~ �
url.move_1�j� j
j� Kj� �TFile: sui/url.move
Module: sui::url
Dependencies:
use std::ascii::{Self, String};
�j� �move�u}�(j~ �
url.move_2�j� j
j� Kj� �yFile: sui/url.move
Module: sui::url
Function: new_unsafe
public fun new_unsafe(url: String): Url {
Url { url }�j� �move�u}�(j~ �
url.move_3�j� j
j� Kj� ��File: sui/url.move
Module: sui::url
Function: new_unsafe_from_bytes
public fun new_unsafe_from_bytes(bytes: vector<u8>): Url {
let url = ascii::string(bytes);
Url { url }�j� �move�u}�(j~ �
url.move_4�j� j
j� Kj� �{File: sui/url.move
Module: sui::url
Function: inner_url
public fun inner_url(self: &Url): String{
self.url
}�j� �move�u}�(j~ �
url.move_5�j� j
j� Kj� ��File: sui/url.move
Module: sui::url
Function: update
public fun update(self: &mut Url, url: String) {
self.url = url;
}�j� �move�u}�(j~ �package.move_0�j� � docs/move_files/sui/package.move�j� K j� �1File: sui/package.move
Move Module: sui::package�j� �move�u}�(j~ �package.move_1�j� j5
j� Kj� X File: sui/package.move
Module: sui::package
Dependencies:
use sui::object::{Self, ID, UID};
use sui::tx_context::{TxContext, sender};
use std::ascii::String;
use std::type_name;
use sui::types;
use there is already a pending upgrade in the transaction.
/// Otherwise guaranteed to be the latest version of any given
/// package.
public fun upgrade_package(cap: &UpgradeCap): ID {
cap.package
}
/// The most recent version of the package, increments by one for each
/// successfully applied upgrade.
public fun version(cap: &UpgradeCap): u64 {
cap.version
}
/// The most permissive kind of upgrade currently supported by this
/// `cap`.
public fun upgrade_policy(cap: &UpgradeCap): u8 {
cap.policy
}
/// The package that this ticket is authorized to upgrade
public fun ticket_package(ticket: &UpgradeTicket): ID {
ticket.package
}
/// The kind of upgrade that this ticket authorizes.
public fun ticket_policy(ticket: &UpgradeTicket): u8 {
ticket.policy
}
/// ID of the `UpgradeCap` that this `receipt` should be used to
/// update.
public fun receipt_cap(receipt: &UpgradeReceipt): ID {
receipt.cap
}
/// ID of the package that was upgraded to: the latest version of
/// the package, as of the upgrade represented by this `receipt`.
public fun receipt_package(receipt: &UpgradeReceipt): ID {
receipt.package
}
/// A hash of the package contents for the new version of the
/// package. This ticket only authorizes an upgrade to a package
/// that matches this digest. A package's contents are identified
/// by two things:
///
/// - modules: [[u8]] a list of the package's module contents
/// - deps: [[u8;
�j� �move�u}�(j~ �package.move_2�j� j5
j� Kj� X� File: sui/package.move
Module: sui::package
Struct: UpgradeTicket
/// (Immutable) ID of the `UpgradeCap` this originated from.
cap: ID,
/// (Immutable) ID of the package that can be upgraded.
package: ID,
/// (Immutable) The policy regarding what kind of upgrade this ticket
/// permits.
policy: u8,
/// (Immutable) SHA256 digest of the bytecode and transitive
/// dependencies that will be used in the upgrade.
digest: vector<u8>,�j� �move�u}�(j~ �package.move_3�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Struct: UpgradeReceipt
/// (Immutable) ID of the `UpgradeCap` this originated from.
cap: ID,
/// (Immutable) ID of the package after it was upgraded.
package: ID,�j� �move�u}�(j~ �package.move_4�j� j5
j� Kj� X� File: sui/package.move
Module: sui::package
Function: claim
public fun claim<OTW: drop>(otw: OTW, ctx: &mut TxContext): Publisher {
assert!(types::is_one_time_witness(&otw), ENotOneTimeWitness);
let type = type_name::get_with_original_ids<OTW>();
Publisher {
id: object::new(ctx),
package: type_name::get_address(&type),
module_name: type_name::get_module(&type),
}�j� �move�u}�(j~ �package.move_5�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: claim_and_keep
public fun claim_and_keep<OTW: drop>(otw: OTW, ctx: &mut TxContext) {
sui::transfer::public_transfer(claim(otw, ctx), sender(ctx))
}�j� �move�u}�(j~ �package.move_6�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: burn_publisher
public fun burn_publisher(self: Publisher) {
let Publisher { id, package: _, module_name: _ }�j� �move�u}�(j~ �package.move_7�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: from_package
public fun from_package<T>(self: &Publisher): bool {
let type = type_name::get_with_original_ids<T>();
(type_name::get_address(&type) == self.package)
}�j� �move�u}�(j~ �package.move_8�j� j5
j� Kj� X3 File: sui/package.move
Module: sui::package
Function: from_module
public fun from_module<T>(self: &Publisher): bool {
let type = type_name::get_with_original_ids<T>();
(type_name::get_address(&type) == self.package)
&& (type_name::get_module(&type) == self.module_name)
}�j� �move�u}�(j~ �package.move_9�j� j5
j� K j� ��File: sui/package.move
Module: sui::package
Function: published_module
public fun published_module(self: &Publisher): &String {
&self.module_name
}�j� �move�u}�(j~ �package.move_10�j� j5
j� K
j� ��File: sui/package.move
Module: sui::package
Function: published_package
public fun published_package(self: &Publisher): &String {
&self.package
}�j� �move�u}�(j~ �package.move_11�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: upgrade_package
public fun upgrade_package(cap: &UpgradeCap): ID {
cap.package
}�j� �move�u}�(j~ �package.move_12�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: version
public fun version(cap: &UpgradeCap): u64 {
cap.version
}�j� �move�u}�(j~ �package.move_13�j� j5
j� K
j� ��File: sui/package.move
Module: sui::package
Function: upgrade_policy
public fun upgrade_policy(cap: &UpgradeCap): u8 {
cap.policy
}�j� �move�u}�(j~ �package.move_14�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: ticket_package
public fun ticket_package(ticket: &UpgradeTicket): ID {
ticket.package
}�j� �move�u}�(j~ �package.move_15�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: ticket_policy
public fun ticket_policy(ticket: &UpgradeTicket): u8 {
ticket.policy
}�j� �move�u}�(j~ �package.move_16�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: receipt_cap
public fun receipt_cap(receipt: &UpgradeReceipt): ID {
receipt.cap
}�j� �move�u}�(j~ �package.move_17�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: receipt_package
public fun receipt_package(receipt: &UpgradeReceipt): ID {
receipt.package
}�j� �move�u}�(j~ �package.move_18�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: ticket_digest
public fun ticket_digest(ticket: &UpgradeTicket): &vector<u8> {
&ticket.digest
}�j� �move�u}�(j~ �package.move_19�j� j5
j� Kj� �|File: sui/package.move
Module: sui::package
Function: compatible_policy
public fun compatible_policy(): u8 { COMPATIBLE }�j� �move�u}�(j~ �package.move_20�j� j5
j� Kj� �vFile: sui/package.move
Module: sui::package
Function: additive_policy
public fun additive_policy(): u8 { ADDITIVE }�j� �move�u}�(j~ �package.move_21�j� j5
j� Kj� �vFile: sui/package.move
Module: sui::package
Function: dep_only_policy
public fun dep_only_policy(): u8 { DEP_ONLY }�j� �move�u}�(j~ �package.move_22�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: only_additive_upgrades
fun only_additive_upgrades(cap: &mut UpgradeCap) {
restrict(cap, ADDITIVE)
}�j� �move�u}�(j~ �package.move_23�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: only_dep_upgrades
fun only_dep_upgrades(cap: &mut UpgradeCap) {
restrict(cap, DEP_ONLY)
}��� j� �move�u}�(j~ �package.move_24�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: make_immutable
fun make_immutable(cap: UpgradeCap) {
let UpgradeCap { id, package: _, version: _, policy: _ }�j� �move�u}�(j~ �package.move_25�j� j5
j� Kj� X: File: sui/package.move
Module: sui::package
Function: authorize_upgrade
public fun authorize_upgrade(
cap: &mut UpgradeCap,
policy: u8,
digest: vector<u8>
): UpgradeTicket {
let id_zero = object::id_from_address(@0x0);
assert!(cap.package != id_zero, EAlreadyAuthorized);
assert!(policy >= cap.policy, ETooPermissive);
let package = cap.package;
cap.package = id_zero;
UpgradeTicket {
cap: object::id(cap),
package,
policy,
digest,
}�j� �move�u}�(j~ �package.move_26�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: commit_upgrade
public fun commit_upgrade(
cap: &mut UpgradeCap,
receipt: UpgradeReceipt,
) {
let UpgradeReceipt { cap: cap_id, package }�j� �move�u}�(j~ �package.move_27�j� j5
j� Kj� Xv File: sui/package.move
Module: sui::package
Function: test_claim
public fun test_claim<OTW: drop>(_: OTW, ctx: &mut TxContext): Publisher {
let type = type_name::get_with_original_ids<OTW>();
Publisher {
id: object::new(ctx),
package: type_name::get_address(&type),
module_name: type_name::get_module(&type),
}�j� �move�u}�(j~ �package.move_28�j� j5
j� Kj� X File: sui/package.move
Module: sui::package
Function: test_publish
public fun test_publish(package: ID, ctx: &mut TxContext): UpgradeCap {
UpgradeCap {
id: object::new(ctx),
package,
version: 1,
policy: COMPATIBLE,
}�j� �move�u}�(j~ �package.move_29�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: test_upgrade
public fun test_upgrade(ticket: UpgradeTicket): UpgradeReceipt {
let UpgradeTicket { cap, package, policy: _, digest: _ }�j� �move�u}�(j~ �package.move_30�j� j5
j� Kj� ��File: sui/package.move
Module: sui::package
Function: restrict
fun restrict(cap: &mut UpgradeCap, policy: u8) {
assert!(cap.policy <= policy, ETooPermissive);
cap.policy = policy;
}�j� �move�u}�(j~ �
borrow.move_0�j� �docs/move_files/sui/borrow.move�j� K j� �/File: sui/borrow.move
Move Module: sui::borrow�j� �move�u}�(j~ �
borrow.move_1�j� j�
j� Kj� X8 File: sui/borrow.move
Module: sui::borrow
Dependencies:
use it and put back in the end. Hot-potato `Borrow` makes
/// sure the object is returned and was not swapped for another one.
module sui::borrow {
use sui::object::{Self, ID};
use std::option::{Self, Option};
use sui::tx_context::{Self, TxContext};
�j� �move�u}�(j~ �
borrow.move_2�j� j�
j� Kj� �QFile: sui/borrow.move
Module: sui::borrow
Struct: Borrow
ref: address, obj: ID�j� �move�u}�(j~ �
borrow.move_3�j� j�
j� Kj� X File: sui/borrow.move
Module: sui::borrow
Function: new
public fun new<T: key + store>(value: T, ctx: &mut TxContext): Referent<T> {
Referent {
id: tx_context::fresh_object_address(ctx),
value: option::some(value)
}�j� �move�u}�(j~ �
borrow.move_4�j� j�
j� Kj� X3 File: sui/borrow.move
Module: sui::borrow
Function: borrow
public fun borrow<T: key + store>(self: &mut Referent<T>): (T, Borrow) {
let value = option::extract(&mut self.value);
let id = object::id(&value);
(value, Borrow {
ref: self.id,
obj: id
}�j� �move�u}�(j~ �
borrow.move_5�j� j�
j� Kj� ��File: sui/borrow.move
Module: sui::borrow
Function: put_back
public fun put_back<T: key + store>(self: &mut Referent<T>, value: T, borrow: Borrow) {
let Borrow { ref, obj }�j� �move�u}�(j~ �
borrow.move_6�j� j�
j� Kj� ��File: sui/borrow.move
Module: sui::borrow
Function: destroy
public fun destroy<T: key + store>(self: Referent<T>): T {
let Referent { id: _, value }�j� �move�u}�(j~ �
borrow.move_7�j� j�
j� Kj� ��File: sui/borrow.move
Module: sui::borrow
Function: test_borrow
fun test_borrow() {
let ctx = &mut sui::tx_context::dummy();
let ref = new(Test { id: object::new(ctx) }�j� �move�u}�(j~ �
borrow.move_8�j� j�
j� Kj� ��File: sui/borrow.move
Module: sui::borrow
Function: test_object_swap
fun test_object_swap() {
let ctx = &mut sui::tx_context::dummy();
let ref_1 = new(Test { id: object::new(ctx) }�j� �move�u}�(j~ �
borrow.move_9�j� j�
j� K j� ��File: sui/borrow.move
Module: sui::borrow
Function: test_borrow_fail
fun test_borrow_fail() {
let ctx = &mut sui::tx_context::dummy();
let ref_1 = new(Test { id: object::new(ctx) }�j� �move�u}�(j~ �entry_funs.move_0�j� �#docs/move_files/sui/entry_funs.move�j� K j� �6File: sui/entry_funs.move
Move Module: unknown_module�j� �move�u}�(j~ �multi_index_test.move_0�j� �)docs/move_files/sui/multi_index_test.move�j� K j� �4File: sui/multi_index_test.move
Move Module: 0x1::m�j� �move�u}�(j~ �multi_index_test.move_1�j� j�
j� Kj� ��File: sui/multi_index_test.move
Module: 0x1::m
Function: f
fun f() {
x[];
x[1, f()];
x[1, 2, 3];
}�j� �move�u}�(j~ �mut_space.move_0�j� �"docs/move_files/sui/mut_space.move�j� K j� �5File: sui/mut_space.move
Move Module: unknown_module�j� �move�u}�(j~ �mut_space.move_1�j� j�
j� Kj� �DFile: sui/mut_space.move
Module: unknown_module
Struct: S
f: u64,�j� �move�u}�(j~ �mut_space.move_2�j� j�
j� Kj� ��File: sui/mut_space.move
Module: unknown_module
Function: foo
public fun foo(x: & mut S): & mut u64 {
& mut x.f;
&
mut x.f
}�j� �move�u}�(j~ �labels1.move_0�j� � docs/move_files/sui/labels1.move�j� K j� �,File: sui/labels1.move
Move Module: 0x42::M�j� �move�u}�(j~ �labels1.move_1�j� j�
j� Kj� �LFile: sui/labels1.move
Module: 0x42::M
Function: bar
fun bar(): u64 { 0 }�j� �move�u}�(j~ �labels1.move_2�j� j�
j� Kj� �yFile: sui/labels1.move
Module: 0x42::M
Function: t
fun t(): u64 { 'r: {
// loop
1 + 'a: loop { foo() }�j� �move�u}�(j~ �match_at_binders1.move_0�j� �*docs/move_files/sui/match_at_binders1.move�j� K j� �6File: sui/match_at_binders1.move
Move Module: 0x42::m�j� �move�u}�(j~ �match_at_binders1.move_1�j� j j� Kj� ��File: sui/match_at_binders1.move
Module: 0x42::m
Function: test_04
fun test_04<T: drop>(x: Maybe<T>, other: Maybe<T>): Maybe<T> {
match (x) {
(x @ Maybe::Nothing) | (x @ Maybe::Just(_)) => other,
}�j� �move�u}�(j~ �native_structs.move_0�j� �'docs/move_files/sui/native_structs.move�j� K j� �2File: sui/native_structs.move
Move Module: s::foo�j� �move�u}�(j~ �
macros.move_0�j� �docs/move_files/sui/macros.move�j� K j� �HFile: sui/macros.move
Module: unknown_module
Header Comments:
/// This�j� �move�u}�(j~ �
macros.move_1�j� j j� Kj� �2File: sui/macros.move
Move Module: unknown_module�j� �move�u}�(j~ �
macros.move_2�j� j j� Kj� X File: sui/macros.move
Module: unknown_module
Dependencies:
use std::string::String;
use of this, we need to check if `i > stop` and return early--instead of letting the
// loop bound handle it, like in the `range_do` macro.
if (i > stop) return;
�j� �move�u}�(j~ �
macros.move_3�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: num_max
fun num_max<$T>($x: $T, $y: $T): $T {
let x = $x;
let y = $y;
if (x > y) x
else y
}�j� �move�u}�(j~ �
macros.move_4�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: num_min
fun num_min<$T>($x: $T, $y: $T): $T {
let x = $x;
let y = $y;
if (x < y) x
else y
}�j� �move�u}�(j~ �
macros.move_5�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: num_diff
fun num_diff<$T>($x: $T, $y: $T): $T {
let x = $x;
let y = $y;
if (x > y) x - y
else y - x
}�j� �move�u}�(j~ �
macros.move_6�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: num_divide_and_round_up
fun num_divide_and_round_up<$T>($x: $T, $y: $T): $T {
let x = $x;
let y = $y;
if (x % y == 0) x / y
else x / y + 1
}�j� �move�u}�(j~ �
macros.move_7�j� j j� Kj� XH File: sui/macros.move
Module: unknown_module
Function: num_pow
fun num_pow($base: _, $exponent: u8): _ {
let mut base = $base;
let mut exponent = $exponent;
let mut res = 1;
while (exponent >= 1) {
if (exponent % 2 == 0) {
base = base * base;
exponent = exponent / 2;
}�j� �move�u}�(j~ �
macros.move_8�j� j j� Kj� Xc File: sui/macros.move
Module: unknown_module
Function: num_sqrt
fun num_sqrt<$T, $U>($x: $T, $bitsize: u8): $T {
let x = $x;
let mut bit = (1: $U) << $bitsize;
let mut res = (0: $U);
let mut x = x as $U;
while (bit != 0) {
if (x >= res + bit) {
x = x - (res + bit);
res = (res >> 1) + bit;
}�j� �move�u}�(j~ �
macros.move_9�j� j j� K j� ��File: sui/macros.move
Module: unknown_module
Function: num_to_string
fun num_to_string($x: _): String {
let mut x = $x;
if (x == 0) {
return b"0".to_string()
}�j� �move�u}�(j~ �macros.move_10�j� j j� K
j� ��File: sui/macros.move
Module: unknown_module
Function: range_do
fun range_do<$T, $R: drop>($start: $T, $stop: $T, $f: |$T| -> $R) {
let mut i = $start;
let stop = $stop;
while (i < stop) {
$f(i);
i = i + 1;
}�j� �move�u}�(j~ �macros.move_11�j� j j� Kj� XU File: sui/macros.move
Module: unknown_module
Function: range_do_eq
fun range_do_eq<$T, $R: drop>($start: $T, $stop: $T, $f: |$T| -> $R) {
let mut i = $start;
let stop = $stop;
// we check `i >= stop` inside the loop instead of `i <= stop` as `while` condition to avoid
// incrementing `i` past the MAX integer value.
// Because of this, we need to check if `i > stop` and return early--instead of letting the
// loop bound handle it, like in the `range_do` macro.
if (i > stop) return;
loop {
$f(i);
if (i >= stop) break;
i = i + 1;
}�j� �move�u}�(j~ �macros.move_12�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: do
fun do<$T, $R: drop>($stop: $T, $f: |$T| -> $R) {
range_do!(0, $stop, $f)
}�j� �move�u}�(j~ �macros.move_13�j� j j� K
j� ��File: sui/macros.move
Module: unknown_module
Function: do_eq
fun do_eq<$T, $R: drop>($stop: $T, $f: |$T| -> $R) {
range_do_eq!(0, $stop, $f)
}�j� �move�u}�(j~ �macros.move_14�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: try_as_u8
fun try_as_u8($x: _): Option<u8> {
let x = $x;
if (x > 0xFF) option::none()
else option::some(x as u8)
}�j� �move�u}�(j~ �macros.move_15�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: try_as_u16
fun try_as_u16($x: _): Option<u16> {
let x = $x;
if (x > 0xFFFF) option::none()
else option::some(x as u16)
}�j� �move�u}�(j~ �macros.move_16�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: try_as_u32
fun try_as_u32($x: _): Option<u32> {
let x = $x;
if (x > 0xFFFF_FFFF) option::none()
else option::some(x as u32)
}�j� �move�u}�(j~ �macros.move_17�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: try_as_u64
fun try_as_u64($x: _): Option<u64> {
let x = $x;
if (x > 0xFFFF_FFFF_FFFF_FFFF) option::none()
else option::some(x as u64)
}�j� �move�u}�(j~ �macros.move_18�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: try_as_u128
fun try_as_u128($x: _): Option<u128> {
let x = $x;
if (x > 0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF) option::none()
else option::some(x as u128)
}�j� �move�u}�(j~ �macros.move_19�j� j j� Kj� X� File: sui/macros.move
Module: unknown_module
Function: uq_from_quotient
fun uq_from_quotient<$T, $U>(
$numerator: $T,
$denominator: $T,
$max_t: $T,
$t_bits: u8,
$fractional_bits: u8,
$abort_denominator: _,
$abort_quotient_too_small: _,
$abort_quotient_too_large: _,
): $T {
let numerator = $numerator;
let denominator = $denominator;
if (denominator == 0) $abort_denominator;
// Scale the numerator to have `$t_bits` fractional bits and the denominator to have
// `$t_bits - $fractional_bits` fractional bits, so that the quotient will have
// `$fractional_bits` fractional bits.
let scaled_numerator = numerator as $U << $t_bits;
let scaled_denominator = denominator as $U << ($t_bits - $fractional_bits);
let quotient = scaled_numerator / scaled_denominator;
// The quotient can only be zero if the numerator is also zero.
if (quotient == 0 && numerator != 0) $abort_quotient_too_small;
// Return the quotient as a fixed-point number. We first need to check whether the cast
// can succeed.
if (quotient > $max_t as $U) $abort_quotient_too_large;
quotient as $T
}�j� �move�u}�(j~ �macros.move_20�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: uq_from_int
fun uq_from_int<$T, $U>($integer: $T, $fractional_bits: u8): $U {
($integer as $U) << $fractional_bits
}�j� �move�u}�(j~ �macros.move_21�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: uq_add
fun uq_add<$T, $U>($a: $T, $b: $T, $max_t: $T, $abort_overflow: _): $T {
let sum = $a as $U + ($b as $U);
if (sum > $max_t as $U) $abort_overflow;
sum as $T
}�j� �move�u}�(j~ �macros.move_22�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: uq_sub
fun uq_sub<$T>($a: $T, $b: $T, $abort_overflow: _): $T {
let a = $a;
let b = $b;
if (a < b) $abort_overflow;
a - b
}�j� �move�u}�(j~ �macros.move_23�j� j j� Kj� ��File: sui/macros.move
Module: unknown_module
Function: uq_to_int
fun uq_to_int<$T, $U>($a: $U, $fractional_bits: u8): $T {
($a >> $fractional_bits) as $T
}�j� �move�u}�(j~ �macros.move_24�j� j j� Kj� X File: sui/macros.move
Module: unknown_module
Function: uq_int_mul
fun uq_int_mul<$T, $U>(
$val: $T,
$multiplier: $T,
$max_t: $T,
$fractional_bits: u8,
$abort_overflow: _,
): $T {
// The product of two `$T` bit values has the same number of bits as `$U`, so perform the
// multiplication with `$U` types and keep the full `$U` bit product
// to avoid losing accuracy.
let unscaled_product = $val as $U * ($multiplier as $U);
// The unscaled product has `$fractional_bits` fractional bits (from the multiplier)
// so rescale it by shifting away the low bits.
let product = unscaled_product >> $fractional_bits;
// Check whether the value is too large.
if (product > $max_t as $U) $abort_overflow;
product as $T
}�j� �move�u}�(j~ �macros.move_25�j� j j� Kj� X� File: sui/macros.move
Module: unknown_module
Function: uq_int_div
fun uq_int_div<$T, $U>(
$val: $T,
$divisor: $T,
$max_t: $T,
$fractional_bits: u8,
$abort_division_by_zero: _,
$abort_overflow: _,
): $T {
let val = $val;
let divisor = $divisor;
// Check for division by zero.
if (divisor == 0) $abort_division_by_zero;
// First convert to $U to increase the number of bits to the next integer size
// and then shift left to add `$fractional_bits` fractional zero bits to the dividend.
let scaled_value = val as $U << $fractional_bits;
let quotient = scaled_value / (divisor as $U);
// Check whether the value is too large.
if (quotient > $max_t as $U) $abort_overflow;
quotient as $T
}�j� �move�u}�(j~ �priority_queue.move_0�j� �'docs/move_files/sui/priority_queue.move�j� K j� �?File: sui/priority_queue.move
Move Module: sui::priority_queue�j� �move�u}�(j~ �priority_queue.move_1�j� jz j� Kj� X� File: sui/priority_queue.move
Module: sui::priority_queue
Dependencies:
use std::vector;
use of the incorrect usage
// of `remove`, and the resulting new root and its two children appear to satisfy the heap invariant
// so we stop max-heapifying there, while the rest of the tree is all messed up because of the shift.
let priorities = vector[8, 7, 3, 6, 2, 1, 0, 5, 4];
�j� �move�u}�(j~ �priority_queue.move_2�j� jz j� Kj� X� File: sui/priority_queue.move
Module: sui::priority_queue
Function: new
public fun new<T: drop>(entries: vector<Entry<T>>) : PriorityQueue<T> {
let len = vector::length(&entries);
let i = len / 2;
// Max heapify from the first node that is a parent (node at len / 2).
while (i > 0) {
i = i - 1;
max_heapify_recursive(&mut entries, len, i);
}�j� �move�u}�(j~ �priority_queue.move_3�j� jz j� Kj� Xu File: sui/priority_queue.move
Module: sui::priority_queue
Function: pop_max
public fun pop_max<T: drop>(pq: &mut PriorityQueue<T>) : (u64, T) {
let len = vector::length(&pq.entries);
assert!(len > 0, EPopFromEmptyHeap);
// Swap the max element with the last element in the entries and remove the max element.
let Entry { priority, value }�j� �move�u}�(j~ �priority_queue.move_4�j� jz j� Kj� ��File: sui/priority_queue.move
Module: sui::priority_queue
Function: insert
public fun insert<T: drop>(pq: &mut PriorityQueue<T>, priority: u64, value: T) {
vector::push_back(&mut pq.entries, Entry { priority, value}�j� �move�u}�(j~ �priority_queue.move_5�j� jz j� Kj� ��File: sui/priority_queue.move
Module: sui::priority_queue
Function: new_entry
public fun new_entry<T: drop>(priority: u64, value: T): Entry<T> {
Entry { priority, value }�j� �move�u}�(j~ �priority_queue.move_6�j� jz j� Kj� X� File: sui/priority_queue.move
Module: sui::priority_queue
Function: create_entries
public fun create_entries<T: drop>(p: vector<u64>, v: vector<T>): vector<Entry<T>> {
let len = vector::length(&p);
assert!(vector::length(&v) == len, 0);
let res = vector::empty();
let i = 0;
while (i < len) {
let priority = vector::remove(&mut p, 0);
let value = vector::remove(&mut v, 0);
vector::push_back(&mut res, Entry { priority, value }�j� �move�u}�(j~ �priority_queue.move_7�j� jz j� Kj� ��File: sui/priority_queue.move
Module: sui::priority_queue
Function: restore_heap_recursive
fun restore_heap_recursive<T: drop>(v: &mut vector<Entry<T>>, i: u64) {
if (i == 0) {
return
}�j� �move�u}�(j~ �priority_queue.move_8�j� jz j� Kj� ��File: sui/priority_queue.move
Module: sui::priority_queue
Function: max_heapify_recursive
fun max_heapify_recursive<T: drop>(v: &mut vector<Entry<T>>, len: u64, i: u64) {
if (len == 0) {
return
}�j� �move�u}�(j~ �priority_queue.move_9�j� jz j� K j� Xi File: sui/priority_queue.move
Module: sui::priority_queue
Function: priorities
public fun priorities<T: drop>(pq: &PriorityQueue<T>): vector<u64> {
let res = vector[];
let i = 0;
while (i < vector::length(&pq.entries)) {
vector::push_back(&mut res, vector::borrow(&pq.entries, i).priority);
i = i +1;
}�j� �move�u}�(j~ �priority_queue.move_10�j� jz j� K
j� X@ File: sui/priority_queue.move
Module: sui::priority_queue
Function: test_pq
fun test_pq() {
let h = new(create_entries(vector[3,1,4,2,5,2], vector[10, 20, 30, 40, 50, 60]));
check_pop_max(&mut h, 5, 50);
check_pop_max(&mut h, 4, 30);
check_pop_max(&mut h, 3, 10);
insert(&mut h, 7, 70);
check_pop_max(&mut h, 7, 70);
check_pop_max(&mut h, 2, 40);
insert(&mut h, 0, 80);
check_pop_max(&mut h, 2, 60);
check_pop_max(&mut h, 1, 20);
check_pop_max(&mut h, 0, 80);
let h = new(create_entries(vector[5,3,1,2,4], vector[10, 20, 30, 40, 50]));
check_pop_max(&mut h, 5, 10);
check_pop_max(&mut h, 4, 50);
check_pop_max(&mut h, 3, 20);
check_pop_max(&mut h, 2, 40);
check_pop_max(&mut h, 1, 30);
}�j� �move�u}�(j~ �priority_queue.move_11�j� jz j� Kj� X� File: sui/priority_queue.move
Module: sui::priority_queue
Function: test_swap_remove_edge_case
fun test_swap_remove_edge_case() {
// This test would fail if `remove` is used incorrectly instead of `swap_remove` in `pop_max`.
// It's hard to characterize exactly under what condition this bug is triggered but roughly
// it happens when the entire tree vector is shifted left by one because of the incorrect usage
// of `remove`, and the resulting new root and its two children appear to satisfy the heap invariant
// so we stop max-heapifying there, while the rest of the tree is all messed up because of the shift.
let priorities = vector[8, 7, 3, 6, 2, 1, 0, 5, 4];
let values = vector[0, 0, 0, 0, 0, 0, 0, 0, 0];
let h = new(create_entries(priorities, values));
check_pop_max(&mut h, 8, 0);
check_pop_max(&mut h, 7, 0);
check_pop_max(&mut h, 6, 0);
check_pop_max(&mut h, 5, 0);
check_pop_max(&mut h, 4, 0);
check_pop_max(&mut h, 3, 0);
check_pop_max(&mut h, 2, 0);
check_pop_max(&mut h, 1, 0);
check_pop_max(&mut h, 0, 0);
}�j� �move�u}�(j~ �priority_queue.move_12�j� jz j� Kj� XC File: sui/priority_queue.move
Module: sui::priority_queue
Function: check_pop_max
fun check_pop_max(h: &mut PriorityQueue<u64>, expected_priority: u64, expected_value: u64) {
let (priority, value) = pop_max(h);
assert!(priority == expected_priority, 0);
assert!(value == expected_value, 0);
}�j� �move�u}�(j~ �unit_test.move_0�j� �"docs/move_files/sui/unit_test.move�j� K j� �5File: sui/unit_test.move
Move Module: unknown_module�j� �move�u}�(j~ �unit_test.move_1�j� j� j� Kj� ��File: sui/unit_test.move
Module: unknown_module
Dependencies:
use a linking failure if an attempt is made to publish a
/// test module in a VM that isn't in unit test mode.
public native fun poison();
�j� �move�u}�(j~ �unit_test.move_2�j� j� j� Kj� ��File: sui/unit_test.move
Module: unknown_module
Function: assert_eq
fun assert_eq<$T: drop>($t1: $T, $t2: $T) {
let t1 = $t1;
let t2 = $t2;
assert_ref_eq!(&t1, &t2)
}�j� �move�u}�(j~ �unit_test.move_3�j� j� j� Kj� X� File: sui/unit_test.move
Module: unknown_module
Function: assert_ref_eq
fun assert_ref_eq<$T>($t1: &$T, $t2: &$T) {
let t1 = $t1;
let t2 = $t2;
let res = t1 == t2;
if (!res) {
std::debug::print(&b"Assertion failed:".to_string());
std::debug::print(t1);
std::debug::print(&b"!=".to_string());
std::debug::print(t2);
assert!(false);
}�j� �move�u}�(j~ �
string.move_0�j� �docs/move_files/sui/string.move�j� K j� �PFile: sui/string.move
Module: unknown_module
Header Comments:
/// The `string`�j� �move�u}�(j~ �
string.move_1�j� j� j� Kj� �2File: sui/string.move
Move Module: unknown_module�j� �move�u}�(j~ �
string.move_2�j� j� j� Kj� �MFile: sui/string.move
Module: unknown_module
Dependencies:
use std::ascii;
�j� �move�u}�(j~ �
string.move_3�j� j� j� Kj� ��File: sui/string.move
Module: unknown_module
Function: utf8
public fun utf8(bytes: vector<u8>): String {
assert!(internal_check_utf8(&bytes), EInvalidUTF8);
String { bytes }�j� �move�u}�(j~ �
string.move_4�j� j� j� Kj� ��File: sui/string.move
Module: unknown_module
Function: from_ascii
public fun from_ascii(s: ascii::String): String {
String { bytes: s.into_bytes() }�j� �move�u}�(j~ �
string.move_5�j� j� j� Kj� ��File: sui/string.move
Module: unknown_module
Function: to_ascii
public fun to_ascii(s: String): ascii::String {
let String { bytes }�j� �move�u}�(j~ �
string.move_6�j� j� j� Kj� ��File: sui/string.move
Module: unknown_module
Function: try_utf8
public fun try_utf8(bytes: vector<u8>): Option<String> {
if (internal_check_utf8(&bytes)) option::some(String { bytes }�j� �move�u}�(j~ �
string.move_7�j� j� j� Kj� ��File: sui/string.move
Module: unknown_module
Function: as_bytes
public fun as_bytes(s: &String): &vector<u8> {
&s.bytes
}�j� �move�u}�(j~ �
string.move_8�j� j� j� Kj� ��File: sui/string.move
Module: unknown_module
Function: into_bytes
public fun into_bytes(s: String): vector<u8> {
let String { bytes }�j� �move�u}�(j~ �
string.move_9�j� j� j� K j� ��File: sui/string.move
Module: unknown_module
Function: is_empty
public fun is_empty(s: &String): bool {
s.bytes.is_empty()
}�j� �move�u}�(j~ �string.move_10�j� j� j� K
j� �|File: sui/string.move
Module: unknown_module
Function: length
public fun length(s: &String): u64 {
s.bytes.length()
}�j� �move�u}�(j~ �string.move_11�j� j� j� Kj� ��File: sui/string.move
Module: unknown_module
Function: append
public fun append(s: &mut String, r: String) {
s.bytes.append(r.bytes)
}�j� �move�u}�(j~ �string.move_12�j� j� j� Kj� ��File: sui/string.move
Module: unknown_module
Function: append_utf8
public fun append_utf8(s: &mut String, bytes: vector<u8>) {
s.append(utf8(bytes))
}�j� �move�u}�(j~ �string.move_13�j� j� j� K
j� X� File: sui/string.move
Module: unknown_module
Function: insert
public fun insert(s: &mut String, at: u64, o: String) {
let bytes = &s.bytes;
assert!(at <= bytes.length() && internal_is_char_boundary(bytes, at), EInvalidIndex);
let l = s.length();
let mut front = s.substring(0, at);
let end = s.substring(at, l);
front.append(o);
front.append(end);
*s = front;
}�j� �move�u}�(j~ �string.move_14�j� j� j� Kj� X� File: sui/string.move
Module: unknown_module
Function: substring
public fun substring(s: &String, i: u64, j: u64): String {
let bytes = &s.bytes;
let l = bytes.length();
assert!(
j <= l &&
i <= j &&
internal_is_char_boundary(bytes, i) &&
internal_is_char_boundary(bytes, j),
EInvalidIndex,
);
String { bytes: internal_sub_string(bytes, i, j) }�j� �move�u}�(j~ �string.move_15�j� j� j� Kj� ��File: sui/string.move
Module: unknown_module
Function: index_of
public fun index_of(s: &String, r: &String): u64 {
internal_index_of(&s.bytes, &r.bytes)
}�j� �move�u}�(j~ �string.move_16�j� j� j� Kj� X� File: sui/string.move
Module: unknown_module
Function: internal_check_utf8
fun internal_check_utf8(v: &vector<u8>): bool;
native fun internal_is_char_boundary(v: &vector<u8>, i: u64): bool;
native fun internal_sub_string(v: &vector<u8>, i: u64, j: u64): vector<u8>;
native fun internal_index_of(v: &vector<u8>, r: &vector<u8>): u64;
// === Deprecated ===
#[deprecated(note = b"Use `std::string::as_bytes` instead.")]
public fun bytes(s: &String): &vector<u8> { s.as_bytes() }�j� �move�u}�(j~ �string.move_17�j� j� j� Kj� ��File: sui/string.move
Module: unknown_module
Function: sub_string
public fun sub_string(s: &String, i: u64, j: u64): String {
s.substring(i, j)
}�j� �move�u}�(j~ �address.move_0�j� � docs/move_files/sui/address.move�j� K j� �3File: sui/address.move
Move Module: unknown_module�j� �move�u}�(j~ �address.move_1�j� j j� Kj� �eFile: sui/address.move
Module: unknown_module
Function: length
public fun length(): u64 {
32
}�j� �move�u}�(j~ �u256.move_0�j� �docs/move_files/sui/u256.move�j� K j� �0File: sui/u256.move
Move Module: unknown_module�j� �move�u}�(j~ �u256.move_1�j� j j� Kj� �TFile: sui/u256.move
Module: unknown_module
Dependencies:
use std::string::String;
�j� �move�u}�(j~ �u256.move_2�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: bitwise_not
public fun bitwise_not(x: u256): u256 {
x ^ max_value!()
}�j� �move�u}�(j~ �u256.move_3�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: max
public fun max(x: u256, y: u256): u256 {
std::macros::num_max!(x, y)
}�j� �move�u}�(j~ �u256.move_4�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: min
public fun min(x: u256, y: u256): u256 {
std::macros::num_min!(x, y)
}�j� �move�u}�(j~ �u256.move_5�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: diff
public fun diff(x: u256, y: u256): u256 {
std::macros::num_diff!(x, y)
}�j� �move�u}�(j~ �u256.move_6�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: divide_and_round_up
public fun divide_and_round_up(x: u256, y: u256): u256 {
std::macros::num_divide_and_round_up!(x, y)
}�j� �move�u}�(j~ �u256.move_7�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: pow
public fun pow(base: u256, exponent: u8): u256 {
std::macros::num_pow!(base, exponent)
}�j� �move�u}�(j~ �u256.move_8�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: try_as_u8
public fun try_as_u8(x: u256): Option<u8> {
std::macros::try_as_u8!(x)
}�j� �move�u}�(j~ �u256.move_9�j� j j� K j� ��File: sui/u256.move
Module: unknown_module
Function: try_as_u16
public fun try_as_u16(x: u256): Option<u16> {
std::macros::try_as_u16!(x)
}�j� �move�u}�(j~ �u256.move_10�j� j j� K
j� ��File: sui/u256.move
Module: unknown_module
Function: try_as_u32
public fun try_as_u32(x: u256): Option<u32> {
std::macros::try_as_u32!(x)
}�j� �move�u}�(j~ �u256.move_11�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: try_as_u64
public fun try_as_u64(x: u256): Option<u64> {
std::macros::try_as_u64!(x)
}�j� �move�u}�(j~ �u256.move_12�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: try_as_u128
public fun try_as_u128(x: u256): Option<u128> {
std::macros::try_as_u128!(x)
}�j� �move�u}�(j~ �u256.move_13�j� j j� K
j� ��File: sui/u256.move
Module: unknown_module
Function: to_string
public fun to_string(x: u256): String {
std::macros::num_to_string!(x)
}�j� �move�u}�(j~ �u256.move_14�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: max_value
fun max_value(): u256 {
0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF
}�j� �move�u}�(j~ �u256.move_15�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: range_do
fun range_do<$R: drop>($start: u256, $stop: u256, $f: |u256| -> $R) {
std::macros::range_do!($start, $stop, $f)
}�j� �move�u}�(j~ �u256.move_16�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: range_do_eq
fun range_do_eq<$R: drop>($start: u256, $stop: u256, $f: |u256| -> $R) {
std::macros::range_do_eq!($start, $stop, $f)
}�j� �move�u}�(j~ �u256.move_17�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: do
fun do<$R: drop>($stop: u256, $f: |u256| -> $R) {
std::macros::do!($stop, $f)
}�j� �move�u}�(j~ �u256.move_18�j� j j� Kj� ��File: sui/u256.move
Module: unknown_module
Function: do_eq
fun do_eq<$R: drop>($stop: u256, $f: |u256| -> $R) {
std::macros::do_eq!($stop, $f)
}�j� �move�u}�(j~ �u128.move_0�j� �docs/move_files/sui/u128.move�j� K j� �0File: sui/u128.move
Move Module: unknown_module�j� �move�u}�(j~ �u128.move_1�j� j_ j� Kj� X_ File: sui/u128.move
Module: unknown_module
Dependencies:
use std::string::String;
use higher values or temporarily multiply the
/// value by some bigger number. Ideally if this is a square of 10 or 100.
///
/// Example:
/// ```
/// math::sqrt(8) => 2;
use this value as if it was 2.82;
use sqrt(10000)).
///
///
/// math::sqrt(8 * 1000000) => 2828;
�j� �move�u}�(j~ �u128.move_2�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: bitwise_not
public fun bitwise_not(x: u128): u128 {
x ^ max_value!()
}�j� �move�u}�(j~ �u128.move_3�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: max
public fun max(x: u128, y: u128): u128 {
std::macros::num_max!(x, y)
}�j� �move�u}�(j~ �u128.move_4�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: min
public fun min(x: u128, y: u128): u128 {
std::macros::num_min!(x, y)
}�j� �move�u}�(j~ �u128.move_5�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: diff
public fun diff(x: u128, y: u128): u128 {
std::macros::num_diff!(x, y)
}�j� �move�u}�(j~ �u128.move_6�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: divide_and_round_up
public fun divide_and_round_up(x: u128, y: u128): u128 {
std::macros::num_divide_and_round_up!(x, y)
}�j� �move�u}�(j~ �u128.move_7�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: pow
public fun pow(base: u128, exponent: u8): u128 {
std::macros::num_pow!(base, exponent)
}�j� �move�u}�(j~ �u128.move_8�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: sqrt
public fun sqrt(x: u128): u128 {
std::macros::num_sqrt!<u128, u256>(x, 128)
}�j� �move�u}�(j~ �u128.move_9�j� j_ j� K j� ��File: sui/u128.move
Module: unknown_module
Function: try_as_u8
public fun try_as_u8(x: u128): Option<u8> {
std::macros::try_as_u8!(x)
}�j� �move�u}�(j~ �u128.move_10�j� j_ j� K
j� ��File: sui/u128.move
Module: unknown_module
Function: try_as_u16
public fun try_as_u16(x: u128): Option<u16> {
std::macros::try_as_u16!(x)
}�j� �move�u}�(j~ �u128.move_11�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: try_as_u32
public fun try_as_u32(x: u128): Option<u32> {
std::macros::try_as_u32!(x)
}�j� �move�u}�(j~ �u128.move_12�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: try_as_u64
public fun try_as_u64(x: u128): Option<u64> {
std::macros::try_as_u64!(x)
}�j� �move�u}�(j~ �u128.move_13�j� j_ j� K
j� ��File: sui/u128.move
Module: unknown_module
Function: to_string
public fun to_string(x: u128): String {
std::macros::num_to_string!(x)
}�j� �move�u}�(j~ �u128.move_14�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: max_value
fun max_value(): u128 {
0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF
}�j� �move�u}�(j~ �u128.move_15�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: range_do
fun range_do<$R: drop>($start: u128, $stop: u128, $f: |u128| -> $R) {
std::macros::range_do!($start, $stop, $f)
}�j� �move�u}�(j~ �u128.move_16�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: range_do_eq
fun range_do_eq<$R: drop>($start: u128, $stop: u128, $f: |u128| -> $R) {
std::macros::range_do_eq!($start, $stop, $f)
}�j� �move�u}�(j~ �u128.move_17�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: do
fun do<$R: drop>($stop: u128, $f: |u128| -> $R) {
std::macros::do!($stop, $f)
}�j� �move�u}�(j~ �u128.move_18�j� j_ j� Kj� ��File: sui/u128.move
Module: unknown_module
Function: do_eq
fun do_eq<$R: drop>($stop: u128, $f: |u128| -> $R) {
std::macros::do_eq!($stop, $f)
}�j� �move�u}�(j~ �
bcs.move_0�j� �docs/move_files/sui/bcs.move�j� K j� ��File: sui/bcs.move
Module: unknown_module
Header Comments:
/// Serialization). BCS is the binary encoding for Move resources and other non-�j� �move�u}�(j~ �
bcs.move_1�j� j� j� Kj� �/File: sui/bcs.move
Move Module: unknown_module�j� �move�u}�(j~ �hash.move_0�j� �docs/move_files/sui/hash.move�j� K j� �WFile: sui/hash.move
Module: unknown_module
Header Comments:
/// The functions in this�j� �move�u}�(j~ �hash.move_1�j� j� j� Kj� �0File: sui/hash.move
Move Module: unknown_module�j� �move�u}�(j~ �
option.move_0�j� �docs/move_files/sui/option.move�j� K j� �HFile: sui/option.move
Module: unknown_module
Header Comments:
/// This�j� �move�u}�(j~ �
option.move_1�j� j� j� Kj� �2File: sui/option.move
Move Module: unknown_module�j� �move�u}�(j~ �
option.move_2�j� j� j� Kj� XV File: sui/option.move
Module: unknown_module
Dependencies:
use Move bytecode does not have ADTs.
public struct Option<Element> has copy, drop, store {
vec: vector<Element>,
}
/// The `Option` is in an invalid state for the operation attempted.
/// The `Option` is `Some` while it should be `None`.
const EOPTION_IS_SET: u64 = 0x40000;
�j� �move�u}�(j~ �
option.move_3�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: none
public fun none<Element>(): Option<Element> {
Option { vec: vector::empty() }�j� �move�u}�(j~ �
option.move_4�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: some
public fun some<Element>(e: Element): Option<Element> {
Option { vec: vector::singleton(e) }�j� �move�u}�(j~ �
option.move_5�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: is_none
public fun is_none<Element>(t: &Option<Element>): bool {
t.vec.is_empty()
}�j� �move�u}�(j~ �
option.move_6�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: is_some
public fun is_some<Element>(t: &Option<Element>): bool {
!t.vec.is_empty()
}�j� �move�u}�(j~ �
option.move_7�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: contains
public fun contains<Element>(t: &Option<Element>, e_ref: &Element): bool {
t.vec.contains(e_ref)
}�j� �move�u}�(j~ �
option.move_8�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: borrow
public fun borrow<Element>(t: &Option<Element>): &Element {
assert!(t.is_some(), EOPTION_NOT_SET);
&t.vec[0]
}�j� �move�u}�(j~ �
option.move_9�j� j� j� K j� X File: sui/option.move
Module: unknown_module
Function: borrow_with_default
public fun borrow_with_default<Element>(t: &Option<Element>, default_ref: &Element): &Element {
let vec_ref = &t.vec;
if (vec_ref.is_empty()) default_ref
else &vec_ref[0]
}�j� �move�u}�(j~ �option.move_10�j� j� j� K
j� X File: sui/option.move
Module: unknown_module
Function: get_with_default
public fun get_with_default<Element: copy + drop>(t: &Option<Element>, default: Element): Element {
let vec_ref = &t.vec;
if (vec_ref.is_empty()) default
else vec_ref[0]
}�j� �move�u}�(j~ �option.move_11�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: fill
public fun fill<Element>(t: &mut Option<Element>, e: Element) {
let vec_ref = &mut t.vec;
if (vec_ref.is_empty()) vec_ref.push_back(e)
else abort EOPTION_IS_SET
}�j� �move�u}�(j~ �option.move_12�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: extract
public fun extract<Element>(t: &mut Option<Element>): Element {
assert!(t.is_some(), EOPTION_NOT_SET);
t.vec.pop_back()
}�j� �move�u}�(j~ �option.move_13�j� j� j� K
j� ��File: sui/option.move
Module: unknown_module
Function: borrow_mut
public fun borrow_mut<Element>(t: &mut Option<Element>): &mut Element {
assert!(t.is_some(), EOPTION_NOT_SET);
&mut t.vec[0]
}�j� �move�u}�(j~ �option.move_14�j� j� j� Kj� X" File: sui/option.move
Module: unknown_module
Function: swap
public fun swap<Element>(t: &mut Option<Element>, e: Element): Element {
assert!(t.is_some(), EOPTION_NOT_SET);
let vec_ref = &mut t.vec;
let old_value = vec_ref.pop_back();
vec_ref.push_back(e);
old_value
}�j� �move�u}�(j~ �option.move_15�j� j� j� Kj� X= File: sui/option.move
Module: unknown_module
Function: swap_or_fill
public fun swap_or_fill<Element>(t: &mut Option<Element>, e: Element): Option<Element> {
let vec_ref = &mut t.vec;
let old_value = if (vec_ref.is_empty()) none()
else some(vec_ref.pop_back());
vec_ref.push_back(e);
old_value
}�j� �move�u}�(j~ �option.move_16�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: destroy_with_default
public fun destroy_with_default<Element: drop>(t: Option<Element>, default: Element): Element {
let Option { mut vec }�j� �move�u}�(j~ �option.move_17�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: destroy_some
public fun destroy_some<Element>(t: Option<Element>): Element {
assert!(t.is_some(), EOPTION_NOT_SET);
let Option { mut vec }�j� �move�u}�(j~ �option.move_18�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: destroy_none
public fun destroy_none<Element>(t: Option<Element>) {
assert!(t.is_none(), EOPTION_IS_SET);
let Option { vec }�j� �move�u}�(j~ �option.move_19�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: to_vec
public fun to_vec<Element>(t: Option<Element>): vector<Element> {
let Option { vec }�j� �move�u}�(j~ �option.move_20�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: destroy
fun destroy<$T, $R: drop>($o: Option<$T>, $f: |$T| -> $R) {
let o = $o;
o.do!($f);
}�j� �move�u}�(j~ �option.move_21�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: do
fun do<$T, $R: drop>($o: Option<$T>, $f: |$T| -> $R) {
let o = $o;
if (o.is_some()) { $f(o.destroy_some()); }�j� �move�u}�(j~ �option.move_22�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: do_ref
fun do_ref<$T, $R: drop>($o: &Option<$T>, $f: |&$T| -> $R) {
let o = $o;
if (o.is_some()) { $f(o.borrow()); }�j� �move�u}�(j~ �option.move_23�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: do_mut
fun do_mut<$T, $R: drop>($o: &mut Option<$T>, $f: |&mut $T| -> $R) {
let o = $o;
if (o.is_some()) { $f(o.borrow_mut()); }�j� �move�u}�(j~ �option.move_24�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: or
fun or<$T>($o: Option<$T>, $default: Option<$T>): Option<$T> {
let o = $o;
if (o.is_some()) {
o
}�j� �move�u}�(j~ �option.move_25�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: and
fun and<$T, $U>($o: Option<$T>, $f: |$T| -> Option<$U>): Option<$U> {
let o = $o;
if (o.is_some()) {
$f(o.destroy_some())
}�j� �move�u}�(j~ �option.move_26�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: and_ref
fun and_ref<$T, $U>($o: &Option<$T>, $f: |&$T| -> Option<$U>): Option<$U> {
let o = $o;
if (o.is_some()) $f(o.borrow())
else none()
}�j� �move�u}�(j~ �option.move_27�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: map
fun map<$T, $U>($o: Option<$T>, $f: |$T| -> $U): Option<$U> {
let o = $o;
if (o.is_some()) {
some($f(o.destroy_some()))
}�j� �move�u}�(j~ �option.move_28�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: map_ref
fun map_ref<$T, $U>($o: &Option<$T>, $f: |&$T| -> $U): Option<$U> {
let o = $o;
if (o.is_some()) some($f(o.borrow()))
else none()
}�j� �move�u}�(j~ �option.move_29�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: filter
fun filter<$T: drop>($o: Option<$T>, $f: |&$T| -> bool): Option<$T> {
let o = $o;
if (o.is_some() && $f(o.borrow())) o
else none()
}�j� �move�u}�(j~ �option.move_30�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: is_some_and
fun is_some_and<$T>($o: &Option<$T>, $f: |&$T| -> bool): bool {
let o = $o;
o.is_some() && $f(o.borrow())
}�j� �move�u}�(j~ �option.move_31�j� j� j� Kj� ��File: sui/option.move
Module: unknown_module
Function: destroy_or
fun destroy_or<$T>($o: Option<$T>, $default: $T): $T {
let o = $o;
if (o.is_some()) {
o.destroy_some()
}�j� �move�u}�(j~ �bit_vector.move_0�j� �#docs/move_files/sui/bit_vector.move�j� K j� �6File: sui/bit_vector.move
Move Module: unknown_module�j� �move�u}�(j~ �bit_vector.move_1�j� j?
j� Kj� X_ File: sui/bit_vector.move
Module: unknown_module
Function: new
public fun new(length: u64): BitVector {
assert!(length > 0, ELENGTH);
assert!(length < MAX_SIZE, ELENGTH);
let mut counter = 0;
let mut bit_field = vector::empty();
while (counter < length) {
bit_field.push_back(false);
counter = counter + 1;
}�j� �move�u}�(j~ �bit_vector.move_2�j� j?
j� Kj� ��File: sui/bit_vector.move
Module: unknown_module
Function: set
public fun set(bitvector: &mut BitVector, bit_index: u64) {
assert!(bit_index < bitvector.bit_field.length(), EINDEX);
let x = &mut bitvector.bit_field[bit_index];
*x = true;
}�j� �move�u}�(j~ �bit_vector.move_3�j� j?
j� Kj� X File: sui/bit_vector.move
Module: unknown_module
Function: unset
public fun unset(bitvector: &mut BitVector, bit_index: u64) {
assert!(bit_index < bitvector.bit_field.length(), EINDEX);
let x = &mut bitvector.bit_field[bit_index];
*x = false;
}�j� �move�u}�(j~ �bit_vector.move_4�j� j?
j� Kj� X File: sui/bit_vector.move
Module: unknown_module
Function: shift_left
public fun shift_left(bitvector: &mut BitVector, amount: u64) {
if (amount >= bitvector.length) {
let len = bitvector.bit_field.length();
let mut i = 0;
while (i < len) {
let elem = &mut bitvector.bit_field[i];
*elem = false;
i = i + 1;
}�j� �move�u}�(j~ �bit_vector.move_5�j� j?
j� Kj� ��File: sui/bit_vector.move
Module: unknown_module
Function: is_index_set
public fun is_index_set(bitvector: &BitVector, bit_index: u64): bool {
assert!(bit_index < bitvector.bit_field.length(), EINDEX);
bitvector.bit_field[bit_index]
}�j� �move�u}�(j~ �bit_vector.move_6�j� j?
j� Kj� ��File: sui/bit_vector.move
Module: unknown_module
Function: length
public fun length(bitvector: &BitVector): u64 {
bitvector.bit_field.length()
}�j� �move�u}�(j~ �bit_vector.move_7�j� j?
j� Kj� X� File: sui/bit_vector.move
Module: unknown_module
Function: longest_set_sequence_starting_at
public fun longest_set_sequence_starting_at(bitvector: &BitVector, start_index: u64): u64 {
assert!(start_index < bitvector.length, EINDEX);
let mut index = start_index;
// Find the greatest index in the vector such that all indices less than it are set.
while (index < bitvector.length) {
if (!bitvector.is_index_set(index)) break;
index = index + 1;
}�j� �move�u}�(j~ �bit_vector.move_8�j� j?
j� Kj� �uFile: sui/bit_vector.move
Module: unknown_module
Function: word_size
public fun word_size(): u64 {
WORD_SIZE
}�j� �move�ue.