Skip to content

Latest commit

 

History

History
353 lines (158 loc) · 11 KB

account.md

File metadata and controls

353 lines (158 loc) · 11 KB

Module 0x3::account

Resource Account

Resource representing an account.

struct Account has store, key

Resource ResourceAccount

ResourceAccount can only be stored under address, not in other structs.

struct ResourceAccount has key

Struct SignerCapability

SignerCapability can only be stored in other structs, not under address. So that the capability is always controlled by contracts, not by some EOA.

struct SignerCapability has store

Constants

const MAX_U64: u128 = 18446744073709551615;

const CONTRACT_ACCOUNT_AUTH_KEY_PLACEHOLDER: vector<u8> = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];

Account already exists

const ErrorAccountAlreadyExists: u64 = 1;

Resource Account can't derive resource account

Account does not exist

const ErrorAccountNotExist: u64 = 2;

Cannot create account because address is reserved

const ErrorAddressReseved: u64 = 5;

Address to create is not a valid reserved address for Rooch framework

An attempt to create a resource account on an account that has a committed transaction

Sequence number exceeds the maximum value for a u64

const ErrorSequenceNumberTooBig: u64 = 3;

Scheme identifier used when hashing an account's address together with a seed to derive the address (not the authentication key) of a resource account. This is an abuse of the notion of a scheme identifier which, for now, serves to domain separate hashes used to derive resource account addresses from hashes used to derive authentication keys. Without such separation, an adversary could create (and get a signer for) a resource account whose address matches an existing address of a MultiEd25519 wallet.

const ZERO_AUTH_KEY: vector<u8> = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

Function create_account_entry

A entry function to create an account under new_address

public entry fun create_account_entry(ctx: &mut context::Context, new_address: address)

Function create_account

Publishes a new Account resource under new_address. A signer representing new_address is returned. This way, the caller of this function can publish additional resources under new_address.

public(friend) fun create_account(ctx: &mut context::Context, new_address: address): signer

Function create_framework_reserved_account

create the account for system reserved addresses

Function sequence_number

Return the current sequence number at addr

public fun sequence_number(ctx: &context::Context, addr: address): u64

Function sequence_number_for_sender

Function increment_sequence_number

public(friend) fun increment_sequence_number(ctx: &mut context::Context)

Function signer_address

public fun signer_address(cap: &account::SignerCapability): address

Function is_resource_account

public fun is_resource_account(ctx: &context::Context, addr: address): bool

Function exists_at

public fun exists_at(ctx: &context::Context, addr: address): bool

Function create_signer

public(friend) fun create_signer(addr: address): signer

Function create_resource_account

A resource account is used to manage resources independent of an account managed by a user. In Rooch a resource account is created based upon the sha3 256 of the source's address and additional seed data. A resource account can only be created once

Function create_resource_address

This is a helper function to compute resource addresses. Computation of the address involves the use of a cryptographic hash operation and should be use thoughtfully.

public fun create_resource_address(source: &address, seed: vector<u8>): address

Function create_signer_with_capability

Function get_signer_capability_address

public fun get_signer_capability_address(capability: &account::SignerCapability): address