Skip to content

Latest commit

 

History

History
380 lines (174 loc) · 12.1 KB

account.md

File metadata and controls

380 lines (174 loc) · 12.1 KB

Module 0x2::account

Resource Account

Account is part of the StorageAbstraction It is also used to store the account's resources

struct Account has key

Constants

const MAX_U64: u128 = 18446744073709551615;

Account already exists

const ErrorAccountAlreadyExists: u64 = 1;

Cannot create account because address is reserved

const ErrorAddressReserved: u64 = 3;

Address to create is not a valid reserved address

The resource with the given type already exists

The resource with the given type not exists

const ErrorResourceNotExists: u64 = 6;

Sequence number exceeds the maximum value for a u64

const ErrorSequenceNumberTooBig: u64 = 2;

Function create_account_by_system

Create a new account for the given address, only callable by the system account

public fun create_account_by_system(system: &signer, new_address: address): signer

Function create_account

Create an Account Object with a generated address

Function sequence_number

Return the current sequence number at addr

public fun sequence_number(addr: address): u64

Function increment_sequence_number_for_system

public fun increment_sequence_number_for_system(system: &signer, sender: address)

Function exists_at

public fun exists_at(addr: address): bool

Function create_signer_for_system

public fun create_signer_for_system(system: &signer, addr: address): signer

Function create_signer_with_account

Create a signer with mutable Object

Function account_object_id

Function account_borrow_resource

Function account_borrow_mut_resource

#[private_generics(#[T])]
public fun account_borrow_mut_resource<T: key>(self: &mut object::Object<account::Account>): &mut T

Function account_move_resource_to

#[private_generics(#[T])]
public fun account_move_resource_to<T: key>(self: &mut object::Object<account::Account>, resource: T)

Function account_move_resource_from

#[private_generics(#[T])]
public fun account_move_resource_from<T: key>(self: &mut object::Object<account::Account>): T

Function account_exists_resource

public fun account_exists_resource<T: key>(self: &object::Object<account::Account>): bool

Function destroy_account

Destroy the account object

Function borrow_account

Function borrow_mut_account

Function borrow_resource

Borrow a resource from the account's storage This function equates to borrow_global<T>(address) instruction in Move But we remove the restriction of the caller must be the module of T

public fun borrow_resource<T: key>(account: address): &T

Function borrow_mut_resource

Borrow a mut resource from the account's storage This function equates to borrow_global_mut<T>(address) instruction in Move

#[private_generics(#[T])]
public fun borrow_mut_resource<T: key>(account: address): &mut T

Function move_resource_to

Move a resource to the account's resource object This function equates to move_to<T>(&signer, resource) instruction in Move

#[private_generics(#[T])]
public fun move_resource_to<T: key>(account: &signer, resource: T)

Function move_resource_from

Move a resource from the account's storage This function equates to move_from<T>(address) instruction in Move

#[private_generics(#[T])]
public fun move_resource_from<T: key>(account: address): T

Function exists_resource

Check if the account has a resource of the given type This function equates to exists<T>(address) instruction in Move But we remove the restriction of the caller must be the module of T

public fun exists_resource<T: key>(account: address): bool