diff --git a/Cargo.lock b/Cargo.lock index e5c6c89299..937b773a28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10717,7 +10717,6 @@ dependencies = [ "move-compiler", "move-prover", "once_cell", - "rayon", "serde 1.0.136", "sha2 0.9.9", "simplelog", diff --git a/vm/stdlib/Cargo.toml b/vm/stdlib/Cargo.toml index f71cf9c3d5..ba8cfd4d1a 100644 --- a/vm/stdlib/Cargo.toml +++ b/vm/stdlib/Cargo.toml @@ -24,7 +24,6 @@ simplelog = "0.9.0" fs_extra = "1.2.0" clap = "2.33.3" serde = { version = "1.0.130", default-features = false } -rayon = "1.5.1" itertools = "0.10.3" tempfile = "3.2.0" starcoin-framework = { git = "https://github.com/starcoinorg/starcoin-framework", rev = "cf1deda180af40a8b3e26c0c7b548c4c290cd7e7" } diff --git a/vm/stdlib/compiled/latest/doc/Account.md b/vm/stdlib/compiled/latest/doc/Account.md deleted file mode 100644 index d88a4209fe..0000000000 --- a/vm/stdlib/compiled/latest/doc/Account.md +++ /dev/null @@ -1,3193 +0,0 @@ - - - -# Module `0x1::Account` - -The module for the account resource that governs every account - - -- [Resource `Account`](#0x1_Account_Account) -- [Resource `Balance`](#0x1_Account_Balance) -- [Struct `WithdrawCapability`](#0x1_Account_WithdrawCapability) -- [Struct `KeyRotationCapability`](#0x1_Account_KeyRotationCapability) -- [Struct `WithdrawEvent`](#0x1_Account_WithdrawEvent) -- [Struct `DepositEvent`](#0x1_Account_DepositEvent) -- [Struct `AcceptTokenEvent`](#0x1_Account_AcceptTokenEvent) -- [Resource `SignerDelegated`](#0x1_Account_SignerDelegated) -- [Struct `SignerCapability`](#0x1_Account_SignerCapability) -- [Resource `AutoAcceptToken`](#0x1_Account_AutoAcceptToken) -- [Constants](#@Constants_0) -- [Function `remove_signer_capability`](#0x1_Account_remove_signer_capability) -- [Function `create_signer_with_cap`](#0x1_Account_create_signer_with_cap) -- [Function `destroy_signer_cap`](#0x1_Account_destroy_signer_cap) -- [Function `signer_address`](#0x1_Account_signer_address) -- [Function `is_signer_delegated`](#0x1_Account_is_signer_delegated) -- [Function `create_genesis_account`](#0x1_Account_create_genesis_account) -- [Function `release_genesis_signer`](#0x1_Account_release_genesis_signer) -- [Function `create_account`](#0x1_Account_create_account) -- [Function `create_account_with_address`](#0x1_Account_create_account_with_address) -- [Function `make_account`](#0x1_Account_make_account) -- [Function `create_signer`](#0x1_Account_create_signer) -- [Function `create_account_with_initial_amount`](#0x1_Account_create_account_with_initial_amount) -- [Function `create_account_with_initial_amount_v2`](#0x1_Account_create_account_with_initial_amount_v2) -- [Function `deposit_to_self`](#0x1_Account_deposit_to_self) -- [Function `deposit`](#0x1_Account_deposit) -- [Function `deposit_with_metadata`](#0x1_Account_deposit_with_metadata) -- [Function `deposit_to_balance`](#0x1_Account_deposit_to_balance) -- [Function `withdraw_from_balance`](#0x1_Account_withdraw_from_balance) -- [Function `withdraw`](#0x1_Account_withdraw) -- [Function `withdraw_with_metadata`](#0x1_Account_withdraw_with_metadata) -- [Function `withdraw_with_capability`](#0x1_Account_withdraw_with_capability) -- [Function `withdraw_with_capability_and_metadata`](#0x1_Account_withdraw_with_capability_and_metadata) -- [Function `extract_withdraw_capability`](#0x1_Account_extract_withdraw_capability) -- [Function `restore_withdraw_capability`](#0x1_Account_restore_withdraw_capability) -- [Function `emit_account_withdraw_event`](#0x1_Account_emit_account_withdraw_event) -- [Function `emit_account_deposit_event`](#0x1_Account_emit_account_deposit_event) -- [Function `pay_from_capability`](#0x1_Account_pay_from_capability) -- [Function `pay_from_with_metadata`](#0x1_Account_pay_from_with_metadata) -- [Function `pay_from`](#0x1_Account_pay_from) -- [Function `rotate_authentication_key_with_capability`](#0x1_Account_rotate_authentication_key_with_capability) -- [Function `extract_key_rotation_capability`](#0x1_Account_extract_key_rotation_capability) -- [Function `restore_key_rotation_capability`](#0x1_Account_restore_key_rotation_capability) -- [Function `destroy_key_rotation_capability`](#0x1_Account_destroy_key_rotation_capability) -- [Function `rotate_authentication_key`](#0x1_Account_rotate_authentication_key) -- [Function `balance_for`](#0x1_Account_balance_for) -- [Function `balance`](#0x1_Account_balance) -- [Function `do_accept_token`](#0x1_Account_do_accept_token) -- [Function `accept_token`](#0x1_Account_accept_token) -- [Function `is_accepts_token`](#0x1_Account_is_accepts_token) -- [Function `is_accept_token`](#0x1_Account_is_accept_token) -- [Function `can_auto_accept_token`](#0x1_Account_can_auto_accept_token) -- [Function `set_auto_accept_token`](#0x1_Account_set_auto_accept_token) -- [Function `try_accept_token`](#0x1_Account_try_accept_token) -- [Function `sequence_number_for_account`](#0x1_Account_sequence_number_for_account) -- [Function `sequence_number`](#0x1_Account_sequence_number) -- [Function `authentication_key`](#0x1_Account_authentication_key) -- [Function `delegated_key_rotation_capability`](#0x1_Account_delegated_key_rotation_capability) -- [Function `delegated_withdraw_capability`](#0x1_Account_delegated_withdraw_capability) -- [Function `withdraw_capability_address`](#0x1_Account_withdraw_capability_address) -- [Function `key_rotation_capability_address`](#0x1_Account_key_rotation_capability_address) -- [Function `exists_at`](#0x1_Account_exists_at) -- [Function `is_dummy_auth_key`](#0x1_Account_is_dummy_auth_key) -- [Function `txn_prologue`](#0x1_Account_txn_prologue) -- [Function `txn_epilogue`](#0x1_Account_txn_epilogue) -- [Function `txn_epilogue_v2`](#0x1_Account_txn_epilogue_v2) -- [Specification](#@Specification_1) - - [Function `create_genesis_account`](#@Specification_1_create_genesis_account) - - [Function `release_genesis_signer`](#@Specification_1_release_genesis_signer) - - [Function `create_account`](#@Specification_1_create_account) - - [Function `create_account_with_address`](#@Specification_1_create_account_with_address) - - [Function `make_account`](#@Specification_1_make_account) - - [Function `create_account_with_initial_amount`](#@Specification_1_create_account_with_initial_amount) - - [Function `create_account_with_initial_amount_v2`](#@Specification_1_create_account_with_initial_amount_v2) - - [Function `deposit_to_self`](#@Specification_1_deposit_to_self) - - [Function `deposit`](#@Specification_1_deposit) - - [Function `deposit_with_metadata`](#@Specification_1_deposit_with_metadata) - - [Function `deposit_to_balance`](#@Specification_1_deposit_to_balance) - - [Function `withdraw_from_balance`](#@Specification_1_withdraw_from_balance) - - [Function `withdraw`](#@Specification_1_withdraw) - - [Function `withdraw_with_metadata`](#@Specification_1_withdraw_with_metadata) - - [Function `withdraw_with_capability`](#@Specification_1_withdraw_with_capability) - - [Function `withdraw_with_capability_and_metadata`](#@Specification_1_withdraw_with_capability_and_metadata) - - [Function `extract_withdraw_capability`](#@Specification_1_extract_withdraw_capability) - - [Function `restore_withdraw_capability`](#@Specification_1_restore_withdraw_capability) - - [Function `emit_account_withdraw_event`](#@Specification_1_emit_account_withdraw_event) - - [Function `emit_account_deposit_event`](#@Specification_1_emit_account_deposit_event) - - [Function `pay_from_capability`](#@Specification_1_pay_from_capability) - - [Function `pay_from_with_metadata`](#@Specification_1_pay_from_with_metadata) - - [Function `pay_from`](#@Specification_1_pay_from) - - [Function `rotate_authentication_key_with_capability`](#@Specification_1_rotate_authentication_key_with_capability) - - [Function `extract_key_rotation_capability`](#@Specification_1_extract_key_rotation_capability) - - [Function `restore_key_rotation_capability`](#@Specification_1_restore_key_rotation_capability) - - [Function `rotate_authentication_key`](#@Specification_1_rotate_authentication_key) - - [Function `balance_for`](#@Specification_1_balance_for) - - [Function `do_accept_token`](#@Specification_1_do_accept_token) - - [Function `accept_token`](#@Specification_1_accept_token) - - [Function `is_accepts_token`](#@Specification_1_is_accepts_token) - - [Function `is_accept_token`](#@Specification_1_is_accept_token) - - [Function `set_auto_accept_token`](#@Specification_1_set_auto_accept_token) - - [Function `try_accept_token`](#@Specification_1_try_accept_token) - - [Function `sequence_number`](#@Specification_1_sequence_number) - - [Function `authentication_key`](#@Specification_1_authentication_key) - - [Function `delegated_key_rotation_capability`](#@Specification_1_delegated_key_rotation_capability) - - [Function `delegated_withdraw_capability`](#@Specification_1_delegated_withdraw_capability) - - [Function `withdraw_capability_address`](#@Specification_1_withdraw_capability_address) - - [Function `key_rotation_capability_address`](#@Specification_1_key_rotation_capability_address) - - [Function `exists_at`](#@Specification_1_exists_at) - - [Function `txn_prologue`](#@Specification_1_txn_prologue) - - [Function `txn_epilogue`](#@Specification_1_txn_epilogue) - - [Function `txn_epilogue_v2`](#@Specification_1_txn_epilogue_v2) - - -
use 0x1::Authenticator;
-use 0x1::CoreAddresses;
-use 0x1::Errors;
-use 0x1::Event;
-use 0x1::Hash;
-use 0x1::Option;
-use 0x1::STC;
-use 0x1::Signer;
-use 0x1::Timestamp;
-use 0x1::Token;
-use 0x1::TransactionFee;
-use 0x1::Vector;
-
-
-
-
-
-
-## Resource `Account`
-
-Every account has a Account::Account resource
-
-
-struct Account has key
-
-
-
-
-authentication_key: vector<u8>
-withdrawal_capability: Option::Option<Account::WithdrawCapability>
-withdrawal_capability
allows whoever holds this capability
- to withdraw from the account. At the time of account creation
- this capability is stored in this option. It can later be
- "extracted" from this field via extract_withdraw_capability
,
- and can also be restored via restore_withdraw_capability
.
-key_rotation_capability: Option::Option<Account::KeyRotationCapability>
-key_rotation_capability
allows whoever holds this capability
- the ability to rotate the authentication key for the account. At
- the time of account creation this capability is stored in this
- option. It can later be "extracted" from this field via
- extract_key_rotation_capability
, and can also be restored via
- restore_key_rotation_capability
.
-withdraw_events: Event::EventHandle<Account::WithdrawEvent>
-deposit_events: Event::EventHandle<Account::DepositEvent>
-accept_token_events: Event::EventHandle<Account::AcceptTokenEvent>
-sequence_number: u64
-struct Balance<TokenType> has key
-
-
-
-
-token: Token::Token<TokenType>
-struct WithdrawCapability has store
-
-
-
-
-account_address: address
-struct KeyRotationCapability has store
-
-
-
-
-account_address: address
-struct WithdrawEvent has drop, store
-
-
-
-
-amount: u128
-token_code: Token::TokenCode
-metadata: vector<u8>
-struct DepositEvent has drop, store
-
-
-
-
-amount: u128
-token_code: Token::TokenCode
-metadata: vector<u8>
-struct AcceptTokenEvent has drop, store
-
-
-
-
-token_code: Token::TokenCode
-struct SignerDelegated has key
-
-
-
-
-dummy_field: bool
-struct SignerCapability has store
-
-
-
-
-addr: address
-struct AutoAcceptToken has key
-
-
-
-
-enable: bool
-const MAX_U64: u128 = 18446744073709551615;
-
-
-
-
-
-
-
-
-const EDEPRECATED_FUNCTION: u64 = 19;
-
-
-
-
-
-
-
-
-const EPROLOGUE_ACCOUNT_DOES_NOT_EXIST: u64 = 0;
-
-
-
-
-
-
-
-
-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];
-
-
-
-
-
-
-
-
-const DUMMY_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];
-
-
-
-
-
-
-
-
-const EADDRESS_AND_AUTH_KEY_MISMATCH: u64 = 105;
-
-
-
-
-
-
-
-
-const EADDRESS_PUBLIC_KEY_INCONSISTENT: u64 = 104;
-
-
-
-
-
-
-
-
-const EBAD_TRANSACTION_FEE_TOKEN: u64 = 18;
-
-
-
-
-
-
-
-
-const ECOIN_DEPOSIT_IS_ZERO: u64 = 15;
-
-
-
-
-
-
-
-
-const EINSUFFICIENT_BALANCE: u64 = 10;
-
-
-
-
-
-
-
-
-const EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED: u64 = 103;
-
-
-
-
-
-
-
-
-const EMALFORMED_AUTHENTICATION_KEY: u64 = 102;
-
-
-
-
-
-
-
-
-const EPROLOGUE_CANT_PAY_GAS_DEPOSIT: u64 = 4;
-
-
-
-
-
-
-
-
-const EPROLOGUE_INVALID_ACCOUNT_AUTH_KEY: u64 = 1;
-
-
-
-
-
-
-
-
-const EPROLOGUE_SEQUENCE_NUMBER_TOO_BIG: u64 = 9;
-
-
-
-
-
-
-
-
-const EPROLOGUE_SEQUENCE_NUMBER_TOO_NEW: u64 = 3;
-
-
-
-
-
-
-
-
-const EPROLOGUE_SEQUENCE_NUMBER_TOO_OLD: u64 = 2;
-
-
-
-
-
-
-
-
-const EPROLOGUE_SIGNER_ALREADY_DELEGATED: u64 = 200;
-
-
-
-
-
-
-
-
-const ERR_SIGNER_ALREADY_DELEGATED: u64 = 107;
-
-
-
-
-
-
-
-
-const ERR_TOKEN_NOT_ACCEPT: u64 = 106;
-
-
-
-
-
-
-
-
-const EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED: u64 = 101;
-
-
-
-
-
-
-## Function `remove_signer_capability`
-
-A one-way action, once SignerCapability is removed from signer, the address cannot send txns anymore.
-This function can only called once by signer.
-
-
-public fun remove_signer_capability(signer: &signer): Account::SignerCapability
-
-
-
-
-public fun remove_signer_capability(signer: &signer): SignerCapability
-acquires Account {
- let signer_addr = Signer::address_of(signer);
- assert!(!is_signer_delegated(signer_addr), Errors::invalid_state(ERR_SIGNER_ALREADY_DELEGATED));
-
- // set to account auth key to noop.
- {
- let key_rotation_capability = extract_key_rotation_capability(signer);
- rotate_authentication_key_with_capability(&key_rotation_capability, CONTRACT_ACCOUNT_AUTH_KEY_PLACEHOLDER);
- destroy_key_rotation_capability(key_rotation_capability);
- move_to(signer, SignerDelegated {});
- };
-
- let signer_cap = SignerCapability {addr: signer_addr };
- signer_cap
-}
-
-
-
-
-public fun create_signer_with_cap(cap: &Account::SignerCapability): signer
-
-
-
-
-public fun create_signer_with_cap(cap: &SignerCapability): signer {
- create_signer(cap.addr)
-}
-
-
-
-
-public fun destroy_signer_cap(cap: Account::SignerCapability)
-
-
-
-
-public fun destroy_signer_cap(cap: SignerCapability) {
- let SignerCapability {addr: _} = cap;
-}
-
-
-
-
-public fun signer_address(cap: &Account::SignerCapability): address
-
-
-
-
-public fun signer_address(cap: &SignerCapability): address {
- cap.addr
-}
-
-
-
-
-public fun is_signer_delegated(addr: address): bool
-
-
-
-
-public fun is_signer_delegated(addr: address): bool {
- exists<SignerDelegated>(addr)
-}
-
-
-
-
-new_account_address
and return signer.
-Genesis authentication_key is zero bytes.
-
-
-public fun create_genesis_account(new_account_address: address): signer
-
-
-
-
-public fun create_genesis_account(
- new_account_address: address,
-) :signer {
- Timestamp::assert_genesis();
- let new_account = create_signer(new_account_address);
- make_account(&new_account, DUMMY_AUTH_KEY);
- new_account
-}
-
-
-
-
-public fun release_genesis_signer(_genesis_account: signer)
-
-
-
-
-public fun release_genesis_signer(_genesis_account: signer){
-}
-
-
-
-
-public fun create_account<TokenType: store>(_authentication_key: vector<u8>): address
-
-
-
-
-public fun create_account<TokenType: store>(_authentication_key: vector<u8>): address {
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-fresh_address
with a balance of zero and empty auth key, the address as init auth key for check transaction.
-Creating an account at address StarcoinFramework will cause runtime failure as it is a
-reserved address for the MoveVM.
-
-
-public fun create_account_with_address<TokenType: store>(fresh_address: address)
-
-
-
-
-public fun create_account_with_address<TokenType: store>(fresh_address: address) acquires Account {
- let new_account = create_signer(fresh_address);
- make_account(&new_account, DUMMY_AUTH_KEY);
- // Make sure all account accept STC.
- if (!STC::is_stc<TokenType>()){
- do_accept_token<STC>(&new_account);
- };
- do_accept_token<TokenType>(&new_account);
-}
-
-
-
-
-fun make_account(new_account: &signer, authentication_key: vector<u8>)
-
-
-
-
-fun make_account(
- new_account: &signer,
- authentication_key: vector<u8>,
-) {
- assert!(Vector::length(&authentication_key) == 32, Errors::invalid_argument(EMALFORMED_AUTHENTICATION_KEY));
- let new_account_addr = Signer::address_of(new_account);
- Event::publish_generator(new_account);
- move_to(new_account, Account {
- authentication_key,
- withdrawal_capability: Option::some(
- WithdrawCapability {
- account_address: new_account_addr
- }),
- key_rotation_capability: Option::some(
- KeyRotationCapability {
- account_address: new_account_addr
- }),
- withdraw_events: Event::new_event_handle<WithdrawEvent>(new_account),
- deposit_events: Event::new_event_handle<DepositEvent>(new_account),
- accept_token_events: Event::new_event_handle<AcceptTokenEvent>(new_account),
- sequence_number: 0,
- });
- move_to(new_account, AutoAcceptToken{enable: true});
-}
-
-
-
-
-fun create_signer(addr: address): signer
-
-
-
-
-native fun create_signer(addr: address): signer;
-
-
-
-
-public(script) fun create_account_with_initial_amount<TokenType: store>(account: signer, fresh_address: address, _auth_key: vector<u8>, initial_amount: u128)
-
-
-
-
-public(script) fun create_account_with_initial_amount<TokenType: store>(account: signer, fresh_address: address, _auth_key: vector<u8>, initial_amount: u128)
-acquires Account, Balance, AutoAcceptToken {
- create_account_with_initial_amount_v2<TokenType>(account, fresh_address, initial_amount)
-}
-
-
-
-
-public(script) fun create_account_with_initial_amount_v2<TokenType: store>(account: signer, fresh_address: address, initial_amount: u128)
-
-
-
-
-public(script) fun create_account_with_initial_amount_v2<TokenType: store>(account: signer, fresh_address: address, initial_amount: u128)
-acquires Account, Balance, AutoAcceptToken {
- create_account_with_address<TokenType>(fresh_address);
- if (initial_amount > 0) {
- pay_from<TokenType>(&account, fresh_address, initial_amount);
- };
-}
-
-
-
-
-to_deposit
token into the self's account balance
-
-
-public fun deposit_to_self<TokenType: store>(account: &signer, to_deposit: Token::Token<TokenType>)
-
-
-
-
-public fun deposit_to_self<TokenType: store>(account: &signer, to_deposit: Token<TokenType>)
-acquires Account, Balance, AutoAcceptToken {
- let account_address = Signer::address_of(account);
- if (!is_accepts_token<TokenType>(account_address)){
- do_accept_token<TokenType>(account);
- };
- deposit(account_address, to_deposit);
-}
-
-
-
-
-to_deposit
token into the receiver
's account balance with the no metadata
-It's a reverse operation of withdraw
.
-
-
-public fun deposit<TokenType: store>(receiver: address, to_deposit: Token::Token<TokenType>)
-
-
-
-
-public fun deposit<TokenType: store>(
- receiver: address,
- to_deposit: Token<TokenType>,
-) acquires Account, Balance, AutoAcceptToken {
- deposit_with_metadata<TokenType>(receiver, to_deposit, x"")
-}
-
-
-
-
-to_deposit
token into the receiver
's account balance with the attached metadata
-It's a reverse operation of withdraw_with_metadata
.
-
-
-public fun deposit_with_metadata<TokenType: store>(receiver: address, to_deposit: Token::Token<TokenType>, metadata: vector<u8>)
-
-
-
-
-public fun deposit_with_metadata<TokenType: store>(
- receiver: address,
- to_deposit: Token<TokenType>,
- metadata: vector<u8>,
-) acquires Account, Balance, AutoAcceptToken {
- try_accept_token<TokenType>(receiver);
-
- let deposit_value = Token::value(&to_deposit);
- if (deposit_value > 0u128) {
- // Deposit the `to_deposit` token
- deposit_to_balance<TokenType>(borrow_global_mut<Balance<TokenType>>(receiver), to_deposit);
-
- // emit deposit event
- emit_account_deposit_event<TokenType>(receiver, deposit_value, metadata);
- } else {
- Token::destroy_zero(to_deposit);
- };
-}
-
-
-
-
-amount
to the given account balance
-
-
-fun deposit_to_balance<TokenType: store>(balance: &mut Account::Balance<TokenType>, token: Token::Token<TokenType>)
-
-
-
-
-fun deposit_to_balance<TokenType: store>(balance: &mut Balance<TokenType>, token: Token::Token<TokenType>) {
- Token::deposit(&mut balance.token, token)
-}
-
-
-
-
-amount
from the given account balance and return the withdrawn Tokenfun withdraw_from_balance<TokenType: store>(balance: &mut Account::Balance<TokenType>, amount: u128): Token::Token<TokenType>
-
-
-
-
-fun withdraw_from_balance<TokenType: store>(balance: &mut Balance<TokenType>, amount: u128): Token<TokenType>{
- Token::withdraw(&mut balance.token, amount)
-}
-
-
-
-
-amount
Tokenpublic fun withdraw<TokenType: store>(account: &signer, amount: u128): Token::Token<TokenType>
-
-
-
-
-public fun withdraw<TokenType: store>(account: &signer, amount: u128): Token<TokenType>
-acquires Account, Balance {
- withdraw_with_metadata<TokenType>(account, amount, x"")
-}
-
-
-
-
-amount
tokens from signer
with given metadata
.
-
-
-public fun withdraw_with_metadata<TokenType: store>(account: &signer, amount: u128, metadata: vector<u8>): Token::Token<TokenType>
-
-
-
-
-public fun withdraw_with_metadata<TokenType: store>(account: &signer, amount: u128, metadata: vector<u8>): Token<TokenType>
-acquires Account, Balance {
- let sender_addr = Signer::address_of(account);
- let sender_balance = borrow_global_mut<Balance<TokenType>>(sender_addr);
- // The sender_addr has delegated the privilege to withdraw from her account elsewhere--abort.
- assert!(!delegated_withdraw_capability(sender_addr), Errors::invalid_state(EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED));
- if (amount == 0){
- return Token::zero()
- };
- emit_account_withdraw_event<TokenType>(sender_addr, amount, metadata);
- // The sender_addr has retained her withdrawal privileges--proceed.
- withdraw_from_balance<TokenType>(sender_balance, amount)
-}
-
-
-
-
-amount
Tokenpublic fun withdraw_with_capability<TokenType: store>(cap: &Account::WithdrawCapability, amount: u128): Token::Token<TokenType>
-
-
-
-
-public fun withdraw_with_capability<TokenType: store>(
- cap: &WithdrawCapability, amount: u128
-): Token<TokenType> acquires Balance, Account {
- withdraw_with_capability_and_metadata<TokenType>(cap, amount, x"")
-}
-
-
-
-
-amount
Tokenpublic fun withdraw_with_capability_and_metadata<TokenType: store>(cap: &Account::WithdrawCapability, amount: u128, metadata: vector<u8>): Token::Token<TokenType>
-
-
-
-
-public fun withdraw_with_capability_and_metadata<TokenType: store>(
- cap: &WithdrawCapability, amount: u128, metadata: vector<u8>
-): Token<TokenType> acquires Balance, Account {
- let balance = borrow_global_mut<Balance<TokenType>>(cap.account_address);
- emit_account_withdraw_event<TokenType>(cap.account_address, amount, metadata);
- withdraw_from_balance<TokenType>(balance , amount)
-}
-
-
-
-
-public fun extract_withdraw_capability(sender: &signer): Account::WithdrawCapability
-
-
-
-
-public fun extract_withdraw_capability(
- sender: &signer
-): WithdrawCapability acquires Account {
- let sender_addr = Signer::address_of(sender);
- // Abort if we already extracted the unique withdraw capability for this account.
- assert!(!delegated_withdraw_capability(sender_addr), Errors::invalid_state(EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED));
- let account = borrow_global_mut<Account>(sender_addr);
- Option::extract(&mut account.withdrawal_capability)
-}
-
-
-
-
-public fun restore_withdraw_capability(cap: Account::WithdrawCapability)
-
-
-
-
-public fun restore_withdraw_capability(cap: WithdrawCapability)
- acquires Account {
- let account = borrow_global_mut<Account>(cap.account_address);
- Option::fill(&mut account.withdrawal_capability, cap)
-}
-
-
-
-
-fun emit_account_withdraw_event<TokenType: store>(account: address, amount: u128, metadata: vector<u8>)
-
-
-
-
-fun emit_account_withdraw_event<TokenType: store>(account: address, amount: u128, metadata: vector<u8>)
-acquires Account {
- // emit withdraw event
- let account = borrow_global_mut<Account>(account);
-
- Event::emit_event<WithdrawEvent>(&mut account.withdraw_events, WithdrawEvent {
- amount,
- token_code: Token::token_code<TokenType>(),
- metadata,
- });
-}
-
-
-
-
-fun emit_account_deposit_event<TokenType: store>(account: address, amount: u128, metadata: vector<u8>)
-
-
-
-
-fun emit_account_deposit_event<TokenType: store>(account: address, amount: u128, metadata: vector<u8>)
-acquires Account {
- // emit withdraw event
- let account = borrow_global_mut<Account>(account);
-
- Event::emit_event<DepositEvent>(&mut account.deposit_events, DepositEvent {
- amount,
- token_code: Token::token_code<TokenType>(),
- metadata,
- });
-}
-
-
-
-
-amount
Tokenpayee
's account balance. Creates the payee
account if it doesn't exist.
-
-
-public fun pay_from_capability<TokenType: store>(cap: &Account::WithdrawCapability, payee: address, amount: u128, metadata: vector<u8>)
-
-
-
-
-public fun pay_from_capability<TokenType: store>(
- cap: &WithdrawCapability,
- payee: address,
- amount: u128,
- metadata: vector<u8>,
-) acquires Account, Balance, AutoAcceptToken {
- let tokens = withdraw_with_capability_and_metadata<TokenType>(cap, amount, *&metadata);
- deposit_with_metadata<TokenType>(
- payee,
- tokens,
- metadata,
- );
-}
-
-
-
-
-amount
Tokenpayee
address with the
-attached metadata
Creates the payee
account if it does not exist
-
-
-public fun pay_from_with_metadata<TokenType: store>(account: &signer, payee: address, amount: u128, metadata: vector<u8>)
-
-
-
-
-public fun pay_from_with_metadata<TokenType: store>(
- account: &signer,
- payee: address,
- amount: u128,
- metadata: vector<u8>,
-) acquires Account, Balance, AutoAcceptToken {
- let tokens = withdraw_with_metadata<TokenType>(account, amount, *&metadata);
- deposit_with_metadata<TokenType>(
- payee,
- tokens,
- metadata,
- );
-}
-
-
-
-
-amount
Tokenpayee
address
-Creates the payee
account if it does not exist
-
-
-public fun pay_from<TokenType: store>(account: &signer, payee: address, amount: u128)
-
-
-
-
-public fun pay_from<TokenType: store>(
- account: &signer,
- payee: address,
- amount: u128
-) acquires Account, Balance, AutoAcceptToken {
- pay_from_with_metadata<TokenType>(account, payee, amount, x"");
-}
-
-
-
-
-public fun rotate_authentication_key_with_capability(cap: &Account::KeyRotationCapability, new_authentication_key: vector<u8>)
-
-
-
-
-public fun rotate_authentication_key_with_capability(
- cap: &KeyRotationCapability,
- new_authentication_key: vector<u8>,
-) acquires Account {
- let sender_account_resource = borrow_global_mut<Account>(cap.account_address);
- // Don't allow rotating to clearly invalid key
- assert!(Vector::length(&new_authentication_key) == 32, Errors::invalid_argument(EMALFORMED_AUTHENTICATION_KEY));
- sender_account_resource.authentication_key = new_authentication_key;
-}
-
-
-
-
-public fun extract_key_rotation_capability(account: &signer): Account::KeyRotationCapability
-
-
-
-
-public fun extract_key_rotation_capability(account: &signer): KeyRotationCapability
-acquires Account {
- let account_address = Signer::address_of(account);
- // Abort if we already extracted the unique key rotation capability for this account.
- assert!(!delegated_key_rotation_capability(account_address), Errors::invalid_state(EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED));
- let account = borrow_global_mut<Account>(account_address);
- Option::extract(&mut account.key_rotation_capability)
-}
-
-
-
-
-public fun restore_key_rotation_capability(cap: Account::KeyRotationCapability)
-
-
-
-
-public fun restore_key_rotation_capability(cap: KeyRotationCapability)
-acquires Account {
- let account = borrow_global_mut<Account>(cap.account_address);
- Option::fill(&mut account.key_rotation_capability, cap)
-}
-
-
-
-
-public fun destroy_key_rotation_capability(cap: Account::KeyRotationCapability)
-
-
-
-
-public fun destroy_key_rotation_capability(cap: KeyRotationCapability) {
- let KeyRotationCapability {account_address: _} = cap;
-}
-
-
-
-
-public(script) fun rotate_authentication_key(account: signer, new_key: vector<u8>)
-
-
-
-
-public(script) fun rotate_authentication_key(account: signer, new_key: vector<u8>) acquires Account {
- let key_rotation_capability = extract_key_rotation_capability(&account);
- rotate_authentication_key_with_capability(&key_rotation_capability, new_key);
- restore_key_rotation_capability(key_rotation_capability);
-}
-
-
-
-
-balance
for account
-
-
-fun balance_for<TokenType: store>(balance: &Account::Balance<TokenType>): u128
-
-
-
-
-fun balance_for<TokenType: store>(balance: &Balance<TokenType>): u128 {
- Token::value<TokenType>(&balance.token)
-}
-
-
-
-
-addr
.
-
-
-public fun balance<TokenType: store>(addr: address): u128
-
-
-
-
-public fun balance<TokenType: store>(addr: address): u128 acquires Balance {
- if (exists<Balance<TokenType>>(addr)) {
- balance_for(borrow_global<Balance<TokenType>>(addr))
- } else {
- 0u128
- }
-}
-
-
-
-
-Token
type to the sending account.
-
-
-public fun do_accept_token<TokenType: store>(account: &signer)
-
-
-
-
-public fun do_accept_token<TokenType: store>(account: &signer) acquires Account {
- move_to(account, Balance<TokenType>{ token: Token::zero<TokenType>() });
- let token_code = Token::token_code<TokenType>();
- // Load the sender's account
- let sender_account_ref = borrow_global_mut<Account>(Signer::address_of(account));
- // Log a sent event
- Event::emit_event<AcceptTokenEvent>(
- &mut sender_account_ref.accept_token_events,
- AcceptTokenEvent {
- token_code: token_code,
- },
- );
-}
-
-
-
-
-public(script) fun accept_token<TokenType: store>(account: signer)
-
-
-
-
-public(script) fun accept_token<TokenType: store>(account: signer) acquires Account {
- do_accept_token<TokenType>(&account);
-}
-
-
-
-
-public fun is_accepts_token<TokenType: store>(addr: address): bool
-
-
-
-
-public fun is_accepts_token<TokenType: store>(addr: address): bool acquires AutoAcceptToken {
- Self::is_accept_token<TokenType>(addr)
-}
-
-
-
-
-addr
accept Token
type tokens
-
-
-public fun is_accept_token<TokenType: store>(addr: address): bool
-
-
-
-
-public fun is_accept_token<TokenType: store>(addr: address): bool acquires AutoAcceptToken {
- if (can_auto_accept_token(addr)) {
- true
- } else {
- exists<Balance<TokenType>>(addr)
- }
-}
-
-
-
-
-public fun can_auto_accept_token(addr: address): bool
-
-
-
-
-public fun can_auto_accept_token(addr: address): bool acquires AutoAcceptToken {
- if (exists<AutoAcceptToken>(addr)) {
- borrow_global<AutoAcceptToken>(addr).enable
- } else {
- false
- }
-}
-
-
-
-
-public fun set_auto_accept_token(account: &signer, enable: bool)
-
-
-
-
-public fun set_auto_accept_token(account: &signer, enable: bool) acquires AutoAcceptToken {
- let addr = Signer::address_of(account);
- if (exists<AutoAcceptToken>(addr)) {
- let config = borrow_global_mut<AutoAcceptToken>(addr);
- config.enable = enable;
- } else {
- move_to(account, AutoAcceptToken{enable});
- };
-}
-
-
-
-
-addr
.
-
-
-fun try_accept_token<TokenType: store>(addr: address)
-
-
-
-
-fun try_accept_token<TokenType: store>(addr: address) acquires AutoAcceptToken, Account {
- if (!exists<Balance<TokenType>>(addr)) {
- if (can_auto_accept_token(addr)) {
- let signer = create_signer(addr);
- do_accept_token<TokenType>(&signer);
- }else{
- abort Errors::not_published(ERR_TOKEN_NOT_ACCEPT)
- }
- };
-}
-
-
-
-
-account
-
-
-fun sequence_number_for_account(account: &Account::Account): u64
-
-
-
-
-fun sequence_number_for_account(account: &Account): u64 {
- account.sequence_number
-}
-
-
-
-
-addr
-
-
-public fun sequence_number(addr: address): u64
-
-
-
-
-public fun sequence_number(addr: address): u64 acquires Account {
- sequence_number_for_account(borrow_global<Account>(addr))
-}
-
-
-
-
-public fun authentication_key(addr: address): vector<u8>
-
-
-
-
-public fun authentication_key(addr: address): vector<u8> acquires Account {
- *&borrow_global<Account>(addr).authentication_key
-}
-
-
-
-
-addr
has delegated its key rotation capability
-
-
-public fun delegated_key_rotation_capability(addr: address): bool
-
-
-
-
-public fun delegated_key_rotation_capability(addr: address): bool
-acquires Account {
- Option::is_none(&borrow_global<Account>(addr).key_rotation_capability)
-}
-
-
-
-
-addr
has delegated its withdraw capability
-
-
-public fun delegated_withdraw_capability(addr: address): bool
-
-
-
-
-public fun delegated_withdraw_capability(addr: address): bool
-acquires Account {
- Option::is_none(&borrow_global<Account>(addr).withdrawal_capability)
-}
-
-
-
-
-public fun withdraw_capability_address(cap: &Account::WithdrawCapability): &address
-
-
-
-
-public fun withdraw_capability_address(cap: &WithdrawCapability): &address {
- &cap.account_address
-}
-
-
-
-
-public fun key_rotation_capability_address(cap: &Account::KeyRotationCapability): &address
-
-
-
-
-public fun key_rotation_capability_address(cap: &KeyRotationCapability): &address {
- &cap.account_address
-}
-
-
-
-
-check_addr
-
-
-public fun exists_at(check_addr: address): bool
-
-
-
-
-public fun exists_at(check_addr: address): bool {
- exists<Account>(check_addr)
-}
-
-
-
-
-fun is_dummy_auth_key(account: &Account::Account): bool
-
-
-
-
-fun is_dummy_auth_key(account: &Account): bool {
- *&account.authentication_key == DUMMY_AUTH_KEY
-}
-
-
-
-
-public fun txn_prologue<TokenType: store>(account: &signer, txn_sender: address, txn_sequence_number: u64, txn_authentication_key_preimage: vector<u8>, txn_gas_price: u64, txn_max_gas_units: u64)
-
-
-
-
-public fun txn_prologue<TokenType: store>(
- account: &signer,
- txn_sender: address,
- txn_sequence_number: u64,
- txn_authentication_key_preimage: vector<u8>,
- txn_gas_price: u64,
- txn_max_gas_units: u64,
-) acquires Account, Balance {
- CoreAddresses::assert_genesis_address(account);
-
- // Verify that the transaction sender's account exists
- assert!(exists_at(txn_sender), Errors::requires_address(EPROLOGUE_ACCOUNT_DOES_NOT_EXIST));
- // Verify the account has not delegate its signer cap.
- assert!(!is_signer_delegated(txn_sender), Errors::invalid_state(EPROLOGUE_SIGNER_ALREADY_DELEGATED));
-
- // Load the transaction sender's account
- let sender_account = borrow_global_mut<Account>(txn_sender);
-
- if (is_dummy_auth_key(sender_account)){
- // if sender's auth key is empty, use address as auth key for check transaction.
- assert!(
- Authenticator::derived_address(Hash::sha3_256(txn_authentication_key_preimage)) == txn_sender,
- Errors::invalid_argument(EPROLOGUE_INVALID_ACCOUNT_AUTH_KEY)
- );
- }else{
- // Check that the hash of the transaction's public key matches the account's auth key
- assert!(
- Hash::sha3_256(txn_authentication_key_preimage) == *&sender_account.authentication_key,
- Errors::invalid_argument(EPROLOGUE_INVALID_ACCOUNT_AUTH_KEY)
- );
- };
-
- // Check that the account has enough balance for all of the gas
- assert!(
- (txn_gas_price as u128) * (txn_max_gas_units as u128) <= MAX_U64,
- Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT),
- );
- let max_transaction_fee = txn_gas_price * txn_max_gas_units;
- if (max_transaction_fee > 0) {
- assert!(
- STC::is_stc<TokenType>(),
- Errors::invalid_argument(EBAD_TRANSACTION_FEE_TOKEN)
- );
-
- let balance_amount = balance<TokenType>(txn_sender);
- assert!(balance_amount >= (max_transaction_fee as u128), Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT));
-
- assert!(
- (txn_sequence_number as u128) < MAX_U64,
- Errors::limit_exceeded(EPROLOGUE_SEQUENCE_NUMBER_TOO_BIG)
- );
- };
-
- // Check that the transaction sequence number matches the sequence number of the account
- assert!(txn_sequence_number >= sender_account.sequence_number, Errors::invalid_argument(EPROLOGUE_SEQUENCE_NUMBER_TOO_OLD));
- assert!(txn_sequence_number == sender_account.sequence_number, Errors::invalid_argument(EPROLOGUE_SEQUENCE_NUMBER_TOO_NEW));
-}
-
-
-
-
-public fun txn_epilogue<TokenType: store>(account: &signer, txn_sender: address, txn_sequence_number: u64, txn_gas_price: u64, txn_max_gas_units: u64, gas_units_remaining: u64)
-
-
-
-
-public fun txn_epilogue<TokenType: store>(
- account: &signer,
- txn_sender: address,
- txn_sequence_number: u64,
- txn_gas_price: u64,
- txn_max_gas_units: u64,
- gas_units_remaining: u64,
-) acquires Account, Balance {
- txn_epilogue_v2<TokenType>(account, txn_sender, txn_sequence_number, Vector::empty(), txn_gas_price, txn_max_gas_units, gas_units_remaining)
-}
-
-
-
-
-public fun txn_epilogue_v2<TokenType: store>(account: &signer, txn_sender: address, txn_sequence_number: u64, txn_authentication_key_preimage: vector<u8>, txn_gas_price: u64, txn_max_gas_units: u64, gas_units_remaining: u64)
-
-
-
-
-public fun txn_epilogue_v2<TokenType: store>(
- account: &signer,
- txn_sender: address,
- txn_sequence_number: u64,
- txn_authentication_key_preimage: vector<u8>,
- txn_gas_price: u64,
- txn_max_gas_units: u64,
- gas_units_remaining: u64,
-) acquires Account, Balance {
- CoreAddresses::assert_genesis_address(account);
-
- // Load the transaction sender's account and balance resources
- let sender_account = borrow_global_mut<Account>(txn_sender);
- let sender_balance = borrow_global_mut<Balance<TokenType>>(txn_sender);
-
- // Charge for gas
- let transaction_fee_amount =(txn_gas_price * (txn_max_gas_units - gas_units_remaining) as u128);
- assert!(
- balance_for(sender_balance) >= transaction_fee_amount,
- Errors::limit_exceeded(EINSUFFICIENT_BALANCE)
- );
-
- // Bump the sequence number
- sender_account.sequence_number = txn_sequence_number + 1;
- // Set auth key when user send transaction first.
- if (is_dummy_auth_key(sender_account) && !Vector::is_empty(&txn_authentication_key_preimage)){
- sender_account.authentication_key = Hash::sha3_256(txn_authentication_key_preimage);
- };
- if (transaction_fee_amount > 0) {
- let transaction_fee = withdraw_from_balance(
- sender_balance,
- transaction_fee_amount
- );
- TransactionFee::pay_fee(transaction_fee);
- };
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `create_genesis_account`
-
-
-public fun create_genesis_account(new_account_address: address): signer
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if len(DUMMY_AUTH_KEY) != 32;
-aborts_if exists<Account>(new_account_address);
-
-
-
-
-
-
-### Function `release_genesis_signer`
-
-
-public fun release_genesis_signer(_genesis_account: signer)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `create_account`
-
-
-public fun create_account<TokenType: store>(_authentication_key: vector<u8>): address
-
-
-
-
-
-aborts_if true;
-
-
-
-
-
-
-### Function `create_account_with_address`
-
-
-public fun create_account_with_address<TokenType: store>(fresh_address: address)
-
-
-
-
-
-aborts_if exists<Account>(fresh_address);
-aborts_if Token::spec_token_code<TokenType>() != Token::spec_token_code<STC>() && exists<Balance<STC>>(fresh_address);
-aborts_if exists<Balance<TokenType>>(fresh_address);
-ensures exists_at(fresh_address);
-ensures exists<Balance<TokenType>>(fresh_address);
-
-
-
-
-
-
-### Function `make_account`
-
-
-fun make_account(new_account: &signer, authentication_key: vector<u8>)
-
-
-
-
-
-aborts_if len(authentication_key) != 32;
-aborts_if exists<Account>(Signer::address_of(new_account));
-aborts_if exists<AutoAcceptToken>(Signer::address_of(new_account));
-ensures exists_at(Signer::address_of(new_account));
-
-
-
-
-
-
-### Function `create_account_with_initial_amount`
-
-
-public(script) fun create_account_with_initial_amount<TokenType: store>(account: signer, fresh_address: address, _auth_key: vector<u8>, initial_amount: u128)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `create_account_with_initial_amount_v2`
-
-
-public(script) fun create_account_with_initial_amount_v2<TokenType: store>(account: signer, fresh_address: address, initial_amount: u128)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `deposit_to_self`
-
-
-public fun deposit_to_self<TokenType: store>(account: &signer, to_deposit: Token::Token<TokenType>)
-
-
-
-
-
-aborts_if to_deposit.value == 0;
-let is_accepts_token = exists<Balance<TokenType>>(Signer::address_of(account));
-aborts_if is_accepts_token && global<Balance<TokenType>>(Signer::address_of(account)).token.value + to_deposit.value > max_u128();
-aborts_if !exists<Account>(Signer::address_of(account));
-ensures exists<Balance<TokenType>>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `deposit`
-
-
-public fun deposit<TokenType: store>(receiver: address, to_deposit: Token::Token<TokenType>)
-
-
-
-
-
-include DepositWithMetadataAbortsIf<TokenType>;
-
-
-
-
-
-
-### Function `deposit_with_metadata`
-
-
-public fun deposit_with_metadata<TokenType: store>(receiver: address, to_deposit: Token::Token<TokenType>, metadata: vector<u8>)
-
-
-
-
-
-include DepositWithMetadataAbortsIf<TokenType>;
-ensures exists<Balance<TokenType>>(receiver);
-ensures old(global<Balance<TokenType>>(receiver)).token.value + to_deposit.value == global<Balance<TokenType>>(receiver).token.value;
-
-
-
-
-
-
-
-
-schema DepositWithMetadataAbortsIf<TokenType> {
- receiver: address;
- to_deposit: Token<TokenType>;
- aborts_if to_deposit.value == 0;
- aborts_if !exists<Account>(receiver);
- aborts_if !exists<Balance<TokenType>>(receiver);
- aborts_if global<Balance<TokenType>>(receiver).token.value + to_deposit.value > max_u128();
-}
-
-
-
-
-
-
-### Function `deposit_to_balance`
-
-
-fun deposit_to_balance<TokenType: store>(balance: &mut Account::Balance<TokenType>, token: Token::Token<TokenType>)
-
-
-
-
-
-aborts_if balance.token.value + token.value > MAX_U128;
-
-
-
-
-
-
-### Function `withdraw_from_balance`
-
-
-fun withdraw_from_balance<TokenType: store>(balance: &mut Account::Balance<TokenType>, amount: u128): Token::Token<TokenType>
-
-
-
-
-
-aborts_if balance.token.value < amount;
-
-
-
-
-
-
-### Function `withdraw`
-
-
-public fun withdraw<TokenType: store>(account: &signer, amount: u128): Token::Token<TokenType>
-
-
-
-
-
-aborts_if !exists<Balance<TokenType>>(Signer::address_of(account));
-aborts_if !exists<Account>(Signer::address_of(account));
-aborts_if global<Balance<TokenType>>(Signer::address_of(account)).token.value < amount;
-aborts_if Option::is_none(global<Account>(Signer::address_of(account)).withdrawal_capability);
-
-
-
-
-
-
-### Function `withdraw_with_metadata`
-
-
-public fun withdraw_with_metadata<TokenType: store>(account: &signer, amount: u128, metadata: vector<u8>): Token::Token<TokenType>
-
-
-
-
-
-aborts_if !exists<Balance<TokenType>>(Signer::address_of(account));
-aborts_if !exists<Account>(Signer::address_of(account));
-aborts_if global<Balance<TokenType>>(Signer::address_of(account)).token.value < amount;
-aborts_if Option::is_none(global<Account>(Signer::address_of(account)).withdrawal_capability);
-
-
-
-
-
-
-
-
-fun spec_withdraw<TokenType>(account: signer, amount: u128): Token<TokenType> {
- Token<TokenType> { value: amount }
-}
-
-
-
-
-
-
-### Function `withdraw_with_capability`
-
-
-public fun withdraw_with_capability<TokenType: store>(cap: &Account::WithdrawCapability, amount: u128): Token::Token<TokenType>
-
-
-
-
-
-aborts_if !exists<Balance<TokenType>>(cap.account_address);
-aborts_if !exists<Account>(cap.account_address);
-aborts_if global<Balance<TokenType>>(cap.account_address).token.value < amount;
-
-
-
-
-
-
-### Function `withdraw_with_capability_and_metadata`
-
-
-public fun withdraw_with_capability_and_metadata<TokenType: store>(cap: &Account::WithdrawCapability, amount: u128, metadata: vector<u8>): Token::Token<TokenType>
-
-
-
-
-
-aborts_if !exists<Balance<TokenType>>(cap.account_address);
-aborts_if !exists<Account>(cap.account_address);
-aborts_if global<Balance<TokenType>>(cap.account_address).token.value < amount;
-
-
-
-
-
-
-### Function `extract_withdraw_capability`
-
-
-public fun extract_withdraw_capability(sender: &signer): Account::WithdrawCapability
-
-
-
-
-
-aborts_if !exists<Account>(Signer::address_of(sender));
-aborts_if Option::is_none(global<Account>( Signer::address_of(sender)).withdrawal_capability);
-
-
-
-
-
-
-### Function `restore_withdraw_capability`
-
-
-public fun restore_withdraw_capability(cap: Account::WithdrawCapability)
-
-
-
-
-
-aborts_if Option::is_some(global<Account>(cap.account_address).withdrawal_capability);
-aborts_if !exists<Account>(cap.account_address);
-
-
-
-
-
-
-### Function `emit_account_withdraw_event`
-
-
-fun emit_account_withdraw_event<TokenType: store>(account: address, amount: u128, metadata: vector<u8>)
-
-
-
-
-
-aborts_if !exists<Account>(account);
-
-
-
-
-
-
-### Function `emit_account_deposit_event`
-
-
-fun emit_account_deposit_event<TokenType: store>(account: address, amount: u128, metadata: vector<u8>)
-
-
-
-
-
-aborts_if !exists<Account>(account);
-
-
-
-
-
-
-### Function `pay_from_capability`
-
-
-public fun pay_from_capability<TokenType: store>(cap: &Account::WithdrawCapability, payee: address, amount: u128, metadata: vector<u8>)
-
-
-
-
-
-aborts_if !exists<Balance<TokenType>>(cap.account_address);
-aborts_if !exists<Account>(cap.account_address);
-aborts_if global<Balance<TokenType>>(cap.account_address).token.value < amount;
-aborts_if amount == 0;
-aborts_if !exists<Account>(payee);
-aborts_if !exists<Balance<TokenType>>(payee);
-aborts_if cap.account_address != payee && global<Balance<TokenType>>(payee).token.value + amount > MAX_U128;
-
-
-
-
-
-
-### Function `pay_from_with_metadata`
-
-
-public fun pay_from_with_metadata<TokenType: store>(account: &signer, payee: address, amount: u128, metadata: vector<u8>)
-
-
-
-
-
-aborts_if !exists<Balance<TokenType>>(Signer::address_of(account));
-aborts_if !exists<Account>(Signer::address_of(account));
-aborts_if global<Balance<TokenType>>(Signer::address_of(account)).token.value < amount;
-aborts_if Option::is_none(global<Account>(Signer::address_of(account)).withdrawal_capability);
-aborts_if amount == 0;
-aborts_if !exists<Account>(payee);
-aborts_if !exists<Balance<TokenType>>(payee);
-aborts_if Signer::address_of(account) != payee && global<Balance<TokenType>>(payee).token.value + amount > max_u128();
-
-
-
-
-
-
-
-
-schema DepositWithPayerAndMetadataAbortsIf<TokenType> {
- payer: address;
- payee: address;
- to_deposit: Token<TokenType>;
- aborts_if to_deposit.value == 0;
- aborts_if !exists<Account>(payer);
- aborts_if !exists<Account>(payee);
- aborts_if !exists<Balance<TokenType>>(payee);
- aborts_if global<Balance<TokenType>>(payee).token.value + to_deposit.value > max_u128();
-}
-
-
-
-
-
-
-### Function `pay_from`
-
-
-public fun pay_from<TokenType: store>(account: &signer, payee: address, amount: u128)
-
-
-
-
-
-aborts_if !exists<Balance<TokenType>>(Signer::address_of(account));
-aborts_if !exists<Account>(Signer::address_of(account));
-aborts_if global<Balance<TokenType>>(Signer::address_of(account)).token.value < amount;
-aborts_if Option::is_none(global<Account>(Signer::address_of(account)).withdrawal_capability);
-aborts_if amount == 0;
-aborts_if !exists<Account>(payee);
-aborts_if !exists<Balance<TokenType>>(payee);
-aborts_if Signer::address_of(account) != payee && global<Balance<TokenType>>(payee).token.value + amount > max_u128();
-
-
-
-
-
-
-### Function `rotate_authentication_key_with_capability`
-
-
-public fun rotate_authentication_key_with_capability(cap: &Account::KeyRotationCapability, new_authentication_key: vector<u8>)
-
-
-
-
-
-aborts_if !exists<Account>(cap.account_address);
-aborts_if len(new_authentication_key) != 32;
-ensures global<Account>(cap.account_address).authentication_key == new_authentication_key;
-
-
-
-
-
-
-
-
-fun spec_rotate_authentication_key_with_capability(addr: address, new_authentication_key: vector<u8>): bool {
- global<Account>(addr).authentication_key == new_authentication_key
-}
-
-
-
-
-
-
-### Function `extract_key_rotation_capability`
-
-
-public fun extract_key_rotation_capability(account: &signer): Account::KeyRotationCapability
-
-
-
-
-
-aborts_if !exists<Account>(Signer::address_of(account));
-aborts_if Option::is_none(global<Account>(Signer::address_of(account)).key_rotation_capability);
-
-
-
-
-
-
-### Function `restore_key_rotation_capability`
-
-
-public fun restore_key_rotation_capability(cap: Account::KeyRotationCapability)
-
-
-
-
-
-aborts_if Option::is_some(global<Account>(cap.account_address).key_rotation_capability);
-aborts_if !exists<Account>(cap.account_address);
-
-
-
-
-
-
-### Function `rotate_authentication_key`
-
-
-public(script) fun rotate_authentication_key(account: signer, new_key: vector<u8>)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `balance_for`
-
-
-fun balance_for<TokenType: store>(balance: &Account::Balance<TokenType>): u128
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `do_accept_token`
-
-
-public fun do_accept_token<TokenType: store>(account: &signer)
-
-
-
-
-
-aborts_if exists<Balance<TokenType>>(Signer::address_of(account));
-aborts_if !exists<Account>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `accept_token`
-
-
-public(script) fun accept_token<TokenType: store>(account: signer)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `is_accepts_token`
-
-
-public fun is_accepts_token<TokenType: store>(addr: address): bool
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `is_accept_token`
-
-
-public fun is_accept_token<TokenType: store>(addr: address): bool
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `set_auto_accept_token`
-
-
-public fun set_auto_accept_token(account: &signer, enable: bool)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `try_accept_token`
-
-
-fun try_accept_token<TokenType: store>(addr: address)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `sequence_number`
-
-
-public fun sequence_number(addr: address): u64
-
-
-
-
-
-aborts_if !exists<Account>(addr);
-
-
-
-
-
-
-### Function `authentication_key`
-
-
-public fun authentication_key(addr: address): vector<u8>
-
-
-
-
-
-aborts_if !exists<Account>(addr);
-
-
-
-
-
-
-### Function `delegated_key_rotation_capability`
-
-
-public fun delegated_key_rotation_capability(addr: address): bool
-
-
-
-
-
-aborts_if !exists<Account>(addr);
-
-
-
-
-
-
-### Function `delegated_withdraw_capability`
-
-
-public fun delegated_withdraw_capability(addr: address): bool
-
-
-
-
-
-aborts_if !exists<Account>(addr);
-
-
-
-
-
-
-### Function `withdraw_capability_address`
-
-
-public fun withdraw_capability_address(cap: &Account::WithdrawCapability): &address
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `key_rotation_capability_address`
-
-
-public fun key_rotation_capability_address(cap: &Account::KeyRotationCapability): &address
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `exists_at`
-
-
-public fun exists_at(check_addr: address): bool
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `txn_prologue`
-
-
-public fun txn_prologue<TokenType: store>(account: &signer, txn_sender: address, txn_sequence_number: u64, txn_authentication_key_preimage: vector<u8>, txn_gas_price: u64, txn_max_gas_units: u64)
-
-
-
-
-
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if !exists<Account>(txn_sender);
-aborts_if global<Account>(txn_sender).authentication_key == DUMMY_AUTH_KEY && Authenticator::spec_derived_address(Hash::sha3_256(txn_authentication_key_preimage)) != txn_sender;
-aborts_if global<Account>(txn_sender).authentication_key != DUMMY_AUTH_KEY && Hash::sha3_256(txn_authentication_key_preimage) != global<Account>(txn_sender).authentication_key;
-aborts_if txn_gas_price * txn_max_gas_units > max_u64();
-aborts_if txn_gas_price * txn_max_gas_units > 0 && !exists<Balance<TokenType>>(txn_sender);
-aborts_if txn_gas_price * txn_max_gas_units > 0 && Token::spec_token_code<TokenType>() != Token::spec_token_code<STC>();
-aborts_if txn_gas_price * txn_max_gas_units > 0 && global<Balance<TokenType>>(txn_sender).token.value < txn_gas_price * txn_max_gas_units;
-aborts_if txn_gas_price * txn_max_gas_units > 0 && txn_sequence_number >= max_u64();
-aborts_if txn_sequence_number < global<Account>(txn_sender).sequence_number;
-aborts_if txn_sequence_number != global<Account>(txn_sender).sequence_number;
-
-
-
-
-
-
-### Function `txn_epilogue`
-
-
-public fun txn_epilogue<TokenType: store>(account: &signer, txn_sender: address, txn_sequence_number: u64, txn_gas_price: u64, txn_max_gas_units: u64, gas_units_remaining: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `txn_epilogue_v2`
-
-
-public fun txn_epilogue_v2<TokenType: store>(account: &signer, txn_sender: address, txn_sequence_number: u64, txn_authentication_key_preimage: vector<u8>, txn_gas_price: u64, txn_max_gas_units: u64, gas_units_remaining: u64)
-
-
-
-
-
-pragma verify = false;
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if !exists<Account>(txn_sender);
-aborts_if !exists<Balance<TokenType>>(txn_sender);
-aborts_if txn_max_gas_units < gas_units_remaining;
-let transaction_fee_amount = txn_gas_price * (txn_max_gas_units - gas_units_remaining);
-aborts_if transaction_fee_amount > max_u128();
-aborts_if global<Balance<TokenType>>(txn_sender).token.value < transaction_fee_amount;
-aborts_if txn_sequence_number + 1 > max_u64();
-aborts_if txn_gas_price * (txn_max_gas_units - gas_units_remaining) > 0 &&
- global<Balance<TokenType>>(txn_sender).token.value < txn_gas_price * (txn_max_gas_units - gas_units_remaining);
-aborts_if txn_gas_price * (txn_max_gas_units - gas_units_remaining) > 0 &&
- !exists<TransactionFee::TransactionFee<TokenType>>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if txn_gas_price * (txn_max_gas_units - gas_units_remaining) > 0 &&
- global<TransactionFee::TransactionFee<TokenType>>(CoreAddresses::SPEC_GENESIS_ADDRESS()).fee.value + txn_gas_price * (txn_max_gas_units - gas_units_remaining) > max_u128();
-
diff --git a/vm/stdlib/compiled/latest/doc/AccountScripts.md b/vm/stdlib/compiled/latest/doc/AccountScripts.md
deleted file mode 100644
index 622bc3b728..0000000000
--- a/vm/stdlib/compiled/latest/doc/AccountScripts.md
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-# Module `0x1::AccountScripts`
-
-
-
-- [Function `enable_auto_accept_token`](#0x1_AccountScripts_enable_auto_accept_token)
-- [Function `disable_auto_accept_token`](#0x1_AccountScripts_disable_auto_accept_token)
-
-
-use 0x1::Account;
-
-
-
-
-
-
-## Function `enable_auto_accept_token`
-
-Enable account's auto-accept-token feature.
-The script function is reenterable.
-
-
-public(script) fun enable_auto_accept_token(account: signer)
-
-
-
-
-public(script) fun enable_auto_accept_token(account: signer) {
- Account::set_auto_accept_token(&account, true);
-}
-
-
-
-
-public(script) fun disable_auto_accept_token(account: signer)
-
-
-
-
-public(script) fun disable_auto_accept_token(account: signer) {
- Account::set_auto_accept_token(&account, false);
-}
-
-
-
-
-use 0x1::BCS;
-use 0x1::Errors;
-use 0x1::Hash;
-use 0x1::Vector;
-
-
-
-
-
-
-## Struct `MultiEd25519PublicKey`
-
-A multi-ed25519 public key
-
-
-struct MultiEd25519PublicKey has copy, drop, store
-
-
-
-
-public_keys: vector<vector<u8>>
-threshold: u8
-const AUTHENTICATION_KEY_LENGTH: u64 = 32;
-
-
-
-
-
-
-
-
-const ED25519_SCHEME_ID: u8 = 0;
-
-
-
-
-
-
-Not enough keys were provided for the specified threshold when creating an MultiEd25519
key
-
-
-const ENOT_ENOUGH_KEYS_FOR_THRESHOLD: u64 = 103;
-
-
-
-
-
-
-Too many keys were provided for the specified threshold when creating an MultiEd25519
key
-
-
-const ENUM_KEYS_ABOVE_MAX_THRESHOLD: u64 = 104;
-
-
-
-
-
-
-
-
-const EWRONG_AUTHENTICATION_KEY_LENGTH: u64 = 101;
-
-
-
-
-
-
-Threshold provided was 0 which can't be used to create a MultiEd25519
key
-
-
-const EZERO_THRESHOLD: u64 = 102;
-
-
-
-
-
-
-Maximum number of keys allowed in a MultiEd25519 public/private key
-
-
-const MAX_MULTI_ED25519_KEYS: u64 = 32;
-
-
-
-
-
-
-
-
-const MULTI_ED25519_SCHEME_ID: u8 = 1;
-
-
-
-
-
-
-## Function `create_multi_ed25519`
-
-Create a a multisig policy from a vector of ed25519 public keys and a threshold.
-Note: this does *not* check uniqueness of keys. Repeated keys are convenient to
-encode weighted multisig policies. For example Alice AND 1 of Bob or Carol is
-public_key: {alice_key, alice_key, bob_key, carol_key}, threshold: 3
-Aborts if threshold is zero or bigger than the length of public_keys
.
-
-
-public fun create_multi_ed25519(public_keys: vector<vector<u8>>, threshold: u8): Authenticator::MultiEd25519PublicKey
-
-
-
-
-public fun create_multi_ed25519(
- public_keys: vector<vector<u8>>,
- threshold: u8
-): MultiEd25519PublicKey {
- // check threshold requirements
- let len = Vector::length(&public_keys);
- assert!(threshold != 0, Errors::invalid_argument(EZERO_THRESHOLD));
- assert!(
- (threshold as u64) <= len,
- Errors::invalid_argument(ENOT_ENOUGH_KEYS_FOR_THRESHOLD)
- );
- // the multied25519 signature scheme allows at most 32 keys
- assert!(
- len <= MAX_MULTI_ED25519_KEYS,
- Errors::invalid_argument(ENUM_KEYS_ABOVE_MAX_THRESHOLD)
- );
-
- MultiEd25519PublicKey { public_keys, threshold }
-}
-
-
-
-
-public_key
-
-
-public fun ed25519_authentication_key(public_key: vector<u8>): vector<u8>
-
-
-
-
-public fun ed25519_authentication_key(public_key: vector<u8>): vector<u8> {
- Vector::push_back(&mut public_key, ED25519_SCHEME_ID);
- Hash::sha3_256(public_key)
-}
-
-
-
-
-public fun derived_address(authentication_key: vector<u8>): address
-
-
-
-
-public fun derived_address(authentication_key: vector<u8>): address {
- assert!(Vector::length(&authentication_key) == AUTHENTICATION_KEY_LENGTH, Errors::invalid_argument(EWRONG_AUTHENTICATION_KEY_LENGTH));
- let address_bytes = Vector::empty<u8>();
-
- let i = 16;
- while (i < 32) {
- let b = *Vector::borrow(&authentication_key, i);
- Vector::push_back(&mut address_bytes, b);
- i = i + 1;
- };
-
- BCS::to_address(address_bytes)
-}
-
-
-
-
-k
-
-
-public fun multi_ed25519_authentication_key(k: &Authenticator::MultiEd25519PublicKey): vector<u8>
-
-
-
-
-public fun multi_ed25519_authentication_key(k: &MultiEd25519PublicKey): vector<u8> {
- let public_keys = &k.public_keys;
- let len = Vector::length(public_keys);
- let authentication_key_preimage = Vector::empty();
- let i = 0;
- while (i < len) {
- let public_key = *Vector::borrow(public_keys, i);
- Vector::append(
- &mut authentication_key_preimage,
- public_key
- );
- i = i + 1;
- };
- Vector::append(&mut authentication_key_preimage, BCS::to_bytes(&k.threshold));
- Vector::push_back(&mut authentication_key_preimage, MULTI_ED25519_SCHEME_ID);
- Hash::sha3_256(authentication_key_preimage)
-}
-
-
-
-
-k
-
-
-public fun public_keys(k: &Authenticator::MultiEd25519PublicKey): &vector<vector<u8>>
-
-
-
-
-public fun public_keys(k: &MultiEd25519PublicKey): &vector<vector<u8>> {
- &k.public_keys
-}
-
-
-
-
-k
-
-
-public fun threshold(k: &Authenticator::MultiEd25519PublicKey): u8
-
-
-
-
-public fun threshold(k: &MultiEd25519PublicKey): u8 {
- *&k.threshold
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `create_multi_ed25519`
-
-
-public fun create_multi_ed25519(public_keys: vector<vector<u8>>, threshold: u8): Authenticator::MultiEd25519PublicKey
-
-
-
-
-
-aborts_if threshold == 0;
-aborts_if threshold > Vector::length(public_keys);
-aborts_if Vector::length(public_keys) > 32;
-
-
-
-
-
-
-### Function `ed25519_authentication_key`
-
-
-public fun ed25519_authentication_key(public_key: vector<u8>): vector<u8>
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures [abstract] result == spec_ed25519_authentication_key(public_key);
-
-
-
-We use an uninterpreted function to represent the result of key construction. The actual value
-does not matter for the verification of callers.
-
-
-
-
-
-fun spec_ed25519_authentication_key(public_key: vector<u8>): vector<u8>;
-
-
-
-
-
-
-### Function `derived_address`
-
-
-public fun derived_address(authentication_key: vector<u8>): address
-
-
-
-
-
-pragma opaque = true;
-aborts_if len(authentication_key) != 32;
-ensures [abstract] result == spec_derived_address(authentication_key);
-
-
-
-We use an uninterpreted function to represent the result of derived address. The actual value
-does not matter for the verification of callers.
-
-
-
-
-
-fun spec_derived_address(authentication_key: vector<u8>): address;
-
-
-
-
-
-
-### Function `multi_ed25519_authentication_key`
-
-
-public fun multi_ed25519_authentication_key(k: &Authenticator::MultiEd25519PublicKey): vector<u8>
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `public_keys`
-
-
-public fun public_keys(k: &Authenticator::MultiEd25519PublicKey): &vector<vector<u8>>
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `threshold`
-
-
-public fun threshold(k: &Authenticator::MultiEd25519PublicKey): u8
-
-
-
-
-
-aborts_if false;
-
diff --git a/vm/stdlib/compiled/latest/doc/BCS.md b/vm/stdlib/compiled/latest/doc/BCS.md
deleted file mode 100644
index ec26e94f86..0000000000
--- a/vm/stdlib/compiled/latest/doc/BCS.md
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-# Module `0x1::BCS`
-
-Utility for converting a Move value to its binary representation in BCS (Diem Canonical
-Serialization). BCS is the binary encoding for Move resources and other non-module values
-published on-chain.
-
-
-- [Function `to_bytes`](#0x1_BCS_to_bytes)
-- [Function `to_address`](#0x1_BCS_to_address)
-- [Specification](#@Specification_0)
-
-
-
-
-
-
-
-
-## Function `to_bytes`
-
-Return the binary representation of v
in BCS (Starcoin Canonical Serialization) format
-
-
-public fun to_bytes<MoveValue: store>(v: &MoveValue): vector<u8>
-
-
-
-
-native public fun to_bytes<MoveValue: store>(v: &MoveValue): vector<u8>;
-
-
-
-
-public fun to_address(key_bytes: vector<u8>): address
-
-
-
-
-native public fun to_address(key_bytes: vector<u8>): address;
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-
-
-native fun serialize<MoveValue>(v: &MoveValue): vector<u8>;
-
diff --git a/vm/stdlib/compiled/latest/doc/Bitwise.md b/vm/stdlib/compiled/latest/doc/Bitwise.md
deleted file mode 100644
index 8fe17fdb5f..0000000000
--- a/vm/stdlib/compiled/latest/doc/Bitwise.md
+++ /dev/null
@@ -1,179 +0,0 @@
-
-
-
-# Module `0x1::BitOperators`
-
-Functions for bit operations.
-
-
-- [Function `and`](#0x1_BitOperators_and)
-- [Function `or`](#0x1_BitOperators_or)
-- [Function `xor`](#0x1_BitOperators_xor)
-- [Function `not`](#0x1_BitOperators_not)
-- [Function `lshift`](#0x1_BitOperators_lshift)
-- [Function `rshift`](#0x1_BitOperators_rshift)
-- [Specification](#@Specification_0)
-
-
-
-
-
-
-
-
-## Function `and`
-
-bit and: x & y
-
-
-public fun and(x: u64, y: u64): u64
-
-
-
-
-public fun and(x: u64, y: u64): u64 {
- (x & y as u64)
-}
-
-
-
-
-public fun or(x: u64, y: u64): u64
-
-
-
-
-public fun or(x: u64, y: u64): u64 {
- (x | y as u64)
-}
-
-
-
-
-public fun xor(x: u64, y: u64): u64
-
-
-
-
-public fun xor(x: u64, y: u64): u64 {
- (x ^ y as u64)
-}
-
-
-
-
-public fun not(x: u64): u64
-
-
-
-
-public fun not(x: u64): u64 {
- (x ^ 18446744073709551615u64 as u64)
-}
-
-
-
-
-public fun lshift(x: u64, n: u8): u64
-
-
-
-
-public fun lshift(x: u64, n: u8): u64 {
- (x << n as u64)
-}
-
-
-
-
-public fun rshift(x: u64, n: u8): u64
-
-
-
-
-public fun rshift(x: u64, n: u8): u64 {
- (x >> n as u64)
-}
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/Block.md b/vm/stdlib/compiled/latest/doc/Block.md
deleted file mode 100644
index a77127abff..0000000000
--- a/vm/stdlib/compiled/latest/doc/Block.md
+++ /dev/null
@@ -1,401 +0,0 @@
-
-
-
-# Module `0x1::Block`
-
-Block module provide metadata for generated blocks.
-
-
-- [Resource `BlockMetadata`](#0x1_Block_BlockMetadata)
-- [Struct `NewBlockEvent`](#0x1_Block_NewBlockEvent)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_Block_initialize)
-- [Function `get_current_block_number`](#0x1_Block_get_current_block_number)
-- [Function `get_parent_hash`](#0x1_Block_get_parent_hash)
-- [Function `get_current_author`](#0x1_Block_get_current_author)
-- [Function `process_block_metadata`](#0x1_Block_process_block_metadata)
-- [Specification](#@Specification_1)
- - [Function `initialize`](#@Specification_1_initialize)
- - [Function `get_current_block_number`](#@Specification_1_get_current_block_number)
- - [Function `get_parent_hash`](#@Specification_1_get_parent_hash)
- - [Function `get_current_author`](#@Specification_1_get_current_author)
- - [Function `process_block_metadata`](#@Specification_1_process_block_metadata)
-
-
-use 0x1::CoreAddresses;
-use 0x1::Errors;
-use 0x1::Event;
-use 0x1::Timestamp;
-
-
-
-
-
-
-## Resource `BlockMetadata`
-
-Block metadata struct.
-
-
-struct BlockMetadata has key
-
-
-
-
-number: u64
-parent_hash: vector<u8>
-author: address
-uncles: u64
-new_block_events: Event::EventHandle<Block::NewBlockEvent>
-struct NewBlockEvent has drop, store
-
-
-
-
-number: u64
-author: address
-timestamp: u64
-uncles: u64
-const EBLOCK_NUMBER_MISMATCH: u64 = 17;
-
-
-
-
-
-
-## Function `initialize`
-
-This can only be invoked by the GENESIS_ACCOUNT at genesis
-
-
-public fun initialize(account: &signer, parent_hash: vector<u8>)
-
-
-
-
-public fun initialize(account: &signer, parent_hash: vector<u8>) {
- Timestamp::assert_genesis();
- CoreAddresses::assert_genesis_address(account);
-
- move_to<BlockMetadata>(
- account,
- BlockMetadata {
- number: 0,
- parent_hash: parent_hash,
- author: CoreAddresses::GENESIS_ADDRESS(),
- uncles: 0,
- new_block_events: Event::new_event_handle<Self::NewBlockEvent>(account),
- });
-}
-
-
-
-
-public fun get_current_block_number(): u64
-
-
-
-
-public fun get_current_block_number(): u64 acquires BlockMetadata {
- borrow_global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).number
-}
-
-
-
-
-public fun get_parent_hash(): vector<u8>
-
-
-
-
-public fun get_parent_hash(): vector<u8> acquires BlockMetadata {
- *&borrow_global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).parent_hash
-}
-
-
-
-
-public fun get_current_author(): address
-
-
-
-
-public fun get_current_author(): address acquires BlockMetadata {
- borrow_global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).author
-}
-
-
-
-
-public fun process_block_metadata(account: &signer, parent_hash: vector<u8>, author: address, timestamp: u64, uncles: u64, number: u64)
-
-
-
-
-public fun process_block_metadata(account: &signer, parent_hash: vector<u8>,author: address, timestamp: u64, uncles:u64, number:u64) acquires BlockMetadata{
- CoreAddresses::assert_genesis_address(account);
-
- let block_metadata_ref = borrow_global_mut<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
- assert!(number == (block_metadata_ref.number + 1), Errors::invalid_argument(EBLOCK_NUMBER_MISMATCH));
- block_metadata_ref.number = number;
- block_metadata_ref.author= author;
- block_metadata_ref.parent_hash = parent_hash;
- block_metadata_ref.uncles = uncles;
-
- Event::emit_event<NewBlockEvent>(
- &mut block_metadata_ref.new_block_events,
- NewBlockEvent {
- number: number,
- author: author,
- timestamp: timestamp,
- uncles: uncles,
- }
- );
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, parent_hash: vector<u8>)
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if exists<BlockMetadata>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `get_current_block_number`
-
-
-public fun get_current_block_number(): u64
-
-
-
-
-
-aborts_if !exists<BlockMetadata>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `get_parent_hash`
-
-
-public fun get_parent_hash(): vector<u8>
-
-
-
-
-
-aborts_if !exists<BlockMetadata>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `get_current_author`
-
-
-public fun get_current_author(): address
-
-
-
-
-
-aborts_if !exists<BlockMetadata>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `process_block_metadata`
-
-
-public fun process_block_metadata(account: &signer, parent_hash: vector<u8>, author: address, timestamp: u64, uncles: u64, number: u64)
-
-
-
-
-
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if !exists<BlockMetadata>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if number != global<BlockMetadata>(CoreAddresses::SPEC_GENESIS_ADDRESS()).number + 1;
-
-
-
-
-
-
-
-
-schema AbortsIfBlockMetadataNotExist {
- aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
-}
-
diff --git a/vm/stdlib/compiled/latest/doc/BlockReward.md b/vm/stdlib/compiled/latest/doc/BlockReward.md
deleted file mode 100644
index 12ca0b1e74..0000000000
--- a/vm/stdlib/compiled/latest/doc/BlockReward.md
+++ /dev/null
@@ -1,407 +0,0 @@
-
-
-
-# Module `0x1::BlockReward`
-
-The module provide block rewarding calculation logic.
-
-
-- [Resource `RewardQueue`](#0x1_BlockReward_RewardQueue)
-- [Struct `RewardInfo`](#0x1_BlockReward_RewardInfo)
-- [Struct `BlockRewardEvent`](#0x1_BlockReward_BlockRewardEvent)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_BlockReward_initialize)
-- [Function `process_block_reward`](#0x1_BlockReward_process_block_reward)
-- [Specification](#@Specification_1)
- - [Function `initialize`](#@Specification_1_initialize)
- - [Function `process_block_reward`](#@Specification_1_process_block_reward)
-
-
-use 0x1::Account;
-use 0x1::CoreAddresses;
-use 0x1::Errors;
-use 0x1::Event;
-use 0x1::RewardConfig;
-use 0x1::STC;
-use 0x1::Timestamp;
-use 0x1::Token;
-use 0x1::Treasury;
-use 0x1::TreasuryWithdrawDaoProposal;
-use 0x1::Vector;
-
-
-
-
-
-
-## Resource `RewardQueue`
-
-Queue of rewards distributed to miners.
-
-
-struct RewardQueue has key
-
-
-
-
-reward_number: u64
-infos: vector<BlockReward::RewardInfo>
-reward_events: Event::EventHandle<BlockReward::BlockRewardEvent>
-struct RewardInfo has store
-
-
-
-
-number: u64
-reward: u128
-miner: address
-gas_fees: Token::Token<STC::STC>
-struct BlockRewardEvent has drop, store
-
-
-
-
-block_number: u64
-block_reward: u128
-gas_fees: u128
-miner: address
-const EAUTHOR_ADDRESS_AND_AUTH_KEY_MISMATCH: u64 = 105;
-
-
-
-
-
-
-
-
-const EAUTHOR_AUTH_KEY_IS_EMPTY: u64 = 101;
-
-
-
-
-
-
-
-
-const ECURRENT_NUMBER_IS_WRONG: u64 = 102;
-
-
-
-
-
-
-
-
-const EMINER_EXIST: u64 = 104;
-
-
-
-
-
-
-
-
-const EREWARD_NUMBER_IS_WRONG: u64 = 103;
-
-
-
-
-
-
-## Function `initialize`
-
-Initialize the module, should be called in genesis.
-
-
-public fun initialize(account: &signer, reward_delay: u64)
-
-
-
-
-public fun initialize(account: &signer, reward_delay: u64) {
- Timestamp::assert_genesis();
- CoreAddresses::assert_genesis_address(account);
-
- RewardConfig::initialize(account, reward_delay);
- move_to<RewardQueue>(account, RewardQueue {
- reward_number: 0,
- infos: Vector::empty(),
- reward_events: Event::new_event_handle<Self::BlockRewardEvent>(account),
- });
-}
-
-
-
-
-public fun process_block_reward(account: &signer, current_number: u64, current_reward: u128, current_author: address, _auth_key_vec: vector<u8>, previous_block_gas_fees: Token::Token<STC::STC>)
-
-
-
-
-public fun process_block_reward(account: &signer, current_number: u64, current_reward: u128,
- current_author: address, _auth_key_vec: vector<u8>,
- previous_block_gas_fees: Token::Token<STC>) acquires RewardQueue {
- CoreAddresses::assert_genesis_address(account);
- if (current_number == 0) {
- Token::destroy_zero(previous_block_gas_fees);
- return
- };
-
- let rewards = borrow_global_mut<RewardQueue>(CoreAddresses::GENESIS_ADDRESS());
- let len = Vector::length(&rewards.infos);
- assert!((current_number == (rewards.reward_number + len + 1)), Errors::invalid_argument(ECURRENT_NUMBER_IS_WRONG));
-
- // distribute gas fee to last block reward info.
- // if not last block reward info, the passed in gas fee must be zero.
- if (len == 0) {
- Token::destroy_zero(previous_block_gas_fees);
- } else {
- let reward_info = Vector::borrow_mut(&mut rewards.infos, len - 1);
- assert!(current_number == reward_info.number + 1, Errors::invalid_argument(ECURRENT_NUMBER_IS_WRONG));
- Token::deposit(&mut reward_info.gas_fees, previous_block_gas_fees);
- };
-
- let reward_delay = RewardConfig::reward_delay();
- if (len >= reward_delay) {//pay and remove
- let i = len;
- while (i > 0 && i >= reward_delay) {
- let RewardInfo { number: reward_block_number, reward: block_reward, gas_fees, miner } = Vector::remove(&mut rewards.infos, 0);
-
- let gas_fee_value = Token::value(&gas_fees);
- let total_reward = gas_fees;
- // add block reward to total.
- if (block_reward > 0) {
- // if no STC in Treasury, BlockReward will been 0.
- let treasury_balance = Treasury::balance<STC>();
- if (treasury_balance < block_reward) {
- block_reward = treasury_balance;
- };
- if (block_reward > 0) {
- let reward = TreasuryWithdrawDaoProposal::withdraw_for_block_reward<STC>(account, block_reward);
- Token::deposit(&mut total_reward, reward);
- };
- };
- // distribute total.
- if (Token::value(&total_reward) > 0) {
- Account::deposit<STC>(miner, total_reward);
- } else {
- Token::destroy_zero(total_reward);
- };
- // emit reward event.
- Event::emit_event<BlockRewardEvent>(
- &mut rewards.reward_events,
- BlockRewardEvent {
- block_number: reward_block_number,
- block_reward: block_reward,
- gas_fees: gas_fee_value,
- miner,
- }
- );
-
- rewards.reward_number = rewards.reward_number + 1;
- i = i - 1;
- }
- };
-
- if (!Account::exists_at(current_author)) {
- Account::create_account_with_address<STC>(current_author);
- };
- let current_info = RewardInfo {
- number: current_number,
- reward: current_reward,
- miner: current_author,
- gas_fees: Token::zero<STC>(),
- };
- Vector::push_back(&mut rewards.infos, current_info);
-
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, reward_delay: u64)
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-include Config::PublishNewConfigAbortsIf<RewardConfig::RewardConfig>;
-include Config::PublishNewConfigEnsures<RewardConfig::RewardConfig>;
-aborts_if exists<RewardQueue>(CoreAddresses::GENESIS_ADDRESS());
-ensures exists<RewardQueue>(CoreAddresses::GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `process_block_reward`
-
-
-public fun process_block_reward(account: &signer, current_number: u64, current_reward: u128, current_author: address, _auth_key_vec: vector<u8>, previous_block_gas_fees: Token::Token<STC::STC>)
-
-
-
-
-
-aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-aborts_if current_number == 0 && Token::value(previous_block_gas_fees) != 0;
-aborts_if current_number > 0 && !exists<RewardQueue>(CoreAddresses::GENESIS_ADDRESS());
-aborts_if current_number > 0 && (global<RewardQueue>(CoreAddresses::GENESIS_ADDRESS()).reward_number + Vector::length(global<RewardQueue>(CoreAddresses::GENESIS_ADDRESS()).infos) + 1) != current_number;
-aborts_if current_number > 0 && !exists<Config::Config<RewardConfig::RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());
-let reward_info_length = Vector::length(global<RewardQueue>(CoreAddresses::GENESIS_ADDRESS()).infos);
-aborts_if current_number > 0 && reward_info_length == 0 && Token::value(previous_block_gas_fees) != 0;
-aborts_if current_number > 0 && reward_info_length != 0 && Vector::borrow(global<RewardQueue>(CoreAddresses::GENESIS_ADDRESS()).infos, reward_info_length - 1).number != current_number - 1;
-aborts_if current_number > 0 && Vector::length(global<RewardQueue>(CoreAddresses::GENESIS_ADDRESS()).infos) >= global<Config::Config<RewardConfig::RewardConfig>>(CoreAddresses::GENESIS_ADDRESS()).payload.reward_delay
-&& (global<RewardQueue>(CoreAddresses::GENESIS_ADDRESS()).reward_number + 1) != Vector::borrow(global<RewardQueue>(CoreAddresses::GENESIS_ADDRESS()).infos, 0).number;
-aborts_if current_number > 0 && Vector::length(global<RewardQueue>(CoreAddresses::GENESIS_ADDRESS()).infos) >= global<Config::Config<RewardConfig::RewardConfig>>(CoreAddresses::GENESIS_ADDRESS()).payload.reward_delay
- && (global<RewardQueue>(CoreAddresses::GENESIS_ADDRESS()).reward_number + 1) > max_u64();
-aborts_if current_number > 0 && !Account::exists_at(current_author) ;
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/ChainId.md b/vm/stdlib/compiled/latest/doc/ChainId.md
deleted file mode 100644
index e3209c82e9..0000000000
--- a/vm/stdlib/compiled/latest/doc/ChainId.md
+++ /dev/null
@@ -1,465 +0,0 @@
-
-
-
-# Module `0x1::ChainId`
-
-The module provides chain id information.
-
-
-- [Resource `ChainId`](#0x1_ChainId_ChainId)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_ChainId_initialize)
-- [Function `get`](#0x1_ChainId_get)
-- [Function `is_dev`](#0x1_ChainId_is_dev)
-- [Function `is_test`](#0x1_ChainId_is_test)
-- [Function `is_halley`](#0x1_ChainId_is_halley)
-- [Function `is_proxima`](#0x1_ChainId_is_proxima)
-- [Function `is_barnard`](#0x1_ChainId_is_barnard)
-- [Function `is_main`](#0x1_ChainId_is_main)
-- [Specification](#@Specification_1)
- - [Function `initialize`](#@Specification_1_initialize)
- - [Function `get`](#@Specification_1_get)
- - [Function `is_dev`](#@Specification_1_is_dev)
- - [Function `is_test`](#@Specification_1_is_test)
- - [Function `is_halley`](#@Specification_1_is_halley)
- - [Function `is_proxima`](#@Specification_1_is_proxima)
- - [Function `is_barnard`](#@Specification_1_is_barnard)
- - [Function `is_main`](#@Specification_1_is_main)
-
-
-use 0x1::CoreAddresses;
-use 0x1::Timestamp;
-
-
-
-
-
-
-## Resource `ChainId`
-
-chain id data structure.
-
-
-struct ChainId has key
-
-
-
-
-id: u8
-const BARNARD_CHAIN_ID: u8 = 251;
-
-
-
-
-
-
-
-
-const DEV_CHAIN_ID: u8 = 254;
-
-
-
-
-
-
-
-
-const HALLEY_CHAIN_ID: u8 = 253;
-
-
-
-
-
-
-
-
-const MAIN_CHAIN_ID: u8 = 1;
-
-
-
-
-
-
-
-
-const PROXIMA_CHAIN_ID: u8 = 252;
-
-
-
-
-
-
-
-
-const TEST_CHAIN_ID: u8 = 255;
-
-
-
-
-
-
-## Function `initialize`
-
-Publish the chain ID under the genesis account
-
-
-public fun initialize(account: &signer, id: u8)
-
-
-
-
-public fun initialize(account: &signer, id: u8) {
- Timestamp::assert_genesis();
- CoreAddresses::assert_genesis_address(account);
- move_to(account, ChainId { id });
-}
-
-
-
-
-public fun get(): u8
-
-
-
-
-public fun get(): u8 acquires ChainId {
- borrow_global<ChainId>(CoreAddresses::GENESIS_ADDRESS()).id
-}
-
-
-
-
-public fun is_dev(): bool
-
-
-
-
-public fun is_dev(): bool acquires ChainId {
- get() == DEV_CHAIN_ID
-}
-
-
-
-
-public fun is_test(): bool
-
-
-
-
-public fun is_test(): bool acquires ChainId {
- get() == TEST_CHAIN_ID
-}
-
-
-
-
-public fun is_halley(): bool
-
-
-
-
-public fun is_halley(): bool acquires ChainId {
- get() == HALLEY_CHAIN_ID
-}
-
-
-
-
-public fun is_proxima(): bool
-
-
-
-
-public fun is_proxima(): bool acquires ChainId {
- get() == PROXIMA_CHAIN_ID
-}
-
-
-
-
-public fun is_barnard(): bool
-
-
-
-
-public fun is_barnard(): bool acquires ChainId {
- get() == BARNARD_CHAIN_ID
-}
-
-
-
-
-public fun is_main(): bool
-
-
-
-
-public fun is_main(): bool acquires ChainId {
- get() == MAIN_CHAIN_ID
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, id: u8)
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if exists<ChainId>(Signer::address_of(account));
-ensures exists<ChainId>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `get`
-
-
-public fun get(): u8
-
-
-
-
-
-aborts_if !exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `is_dev`
-
-
-public fun is_dev(): bool
-
-
-
-
-
-aborts_if !exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `is_test`
-
-
-public fun is_test(): bool
-
-
-
-
-
-aborts_if !exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `is_halley`
-
-
-public fun is_halley(): bool
-
-
-
-
-
-aborts_if !exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `is_proxima`
-
-
-public fun is_proxima(): bool
-
-
-
-
-
-aborts_if !exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `is_barnard`
-
-
-public fun is_barnard(): bool
-
-
-
-
-
-aborts_if !exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `is_main`
-
-
-public fun is_main(): bool
-
-
-
-
-
-aborts_if !exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
diff --git a/vm/stdlib/compiled/latest/doc/Collection.md b/vm/stdlib/compiled/latest/doc/Collection.md
deleted file mode 100644
index f3e53d8cfa..0000000000
--- a/vm/stdlib/compiled/latest/doc/Collection.md
+++ /dev/null
@@ -1,460 +0,0 @@
-
-
-
-# Module `0x1::Collection`
-
-Deprecated since @v3 please use Collection2
-Provide a account based vector for save resource.
-
-
-- [Struct `Collection`](#0x1_Collection_Collection)
-- [Resource `CollectionStore`](#0x1_Collection_CollectionStore)
-- [Constants](#@Constants_0)
-- [Function `borrow`](#0x1_Collection_borrow)
-- [Function `pop_back`](#0x1_Collection_pop_back)
-- [Function `exists_at`](#0x1_Collection_exists_at)
-- [Function `put`](#0x1_Collection_put)
-- [Function `take`](#0x1_Collection_take)
-- [Function `borrow_collection`](#0x1_Collection_borrow_collection)
-- [Function `return_collection`](#0x1_Collection_return_collection)
-- [Function `destroy_empty`](#0x1_Collection_destroy_empty)
-- [Specification](#@Specification_1)
- - [Function `exists_at`](#@Specification_1_exists_at)
- - [Function `put`](#@Specification_1_put)
- - [Function `take`](#@Specification_1_take)
- - [Function `borrow_collection`](#@Specification_1_borrow_collection)
- - [Function `return_collection`](#@Specification_1_return_collection)
- - [Function `destroy_empty`](#@Specification_1_destroy_empty)
-
-
-use 0x1::Errors;
-use 0x1::Option;
-use 0x1::Signer;
-use 0x1::Vector;
-
-
-
-
-
-
-## Struct `Collection`
-
-Collection in memory, can not drop & store.
-
-
-struct Collection<T>
-
-
-
-
-items: vector<T>
-owner: address
-struct CollectionStore<T: store> has key
-
-
-
-
-items: Option::Option<vector<T>>
-const EDEPRECATED_FUNCTION: u64 = 19;
-
-
-
-
-
-
-
-
-const ECOLLECTION_NOT_EXIST: u64 = 101;
-
-
-
-
-
-
-The operator require the collection owner.
-
-
-const ECOLLECTION_NOT_OWNER: u64 = 102;
-
-
-
-
-
-
-## Function `borrow`
-
-Acquire an immutable reference to the i
th element of the collection c
.
-Aborts if i
is out of bounds.
-
-
-public fun borrow<T>(c: &Collection::Collection<T>, i: u64): &T
-
-
-
-
-public fun borrow<T>(c: &Collection<T>, i: u64): &T{
- Vector::borrow(&c.items, i)
-}
-
-
-
-
-v
.
-Aborts if v
is empty.
-
-
-public fun pop_back<T>(account: &signer, c: &mut Collection::Collection<T>): T
-
-
-
-
-public fun pop_back<T>(account: &signer, c: &mut Collection<T>): T {
- assert!(Signer::address_of(account) == c.owner, Errors::requires_address(ECOLLECTION_NOT_OWNER));
- Vector::pop_back<T>(&mut c.items)
-}
-
-
-
-
-addr
-
-
-fun exists_at<T: store>(addr: address): bool
-
-
-
-
-fun exists_at<T: store>(addr: address): bool{
- exists<CollectionStore<T>>(addr)
-}
-
-
-
-
-public fun put<T: store>(_account: &signer, _item: T)
-
-
-
-
-public fun put<T: store>(_account: &signer, _item: T) {
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-public fun take<T: store>(account: &signer): T
-
-
-
-
-public fun take<T: store>(account: &signer): T acquires CollectionStore{
- let addr = Signer::address_of(account);
- let c = borrow_collection<T>(addr);
- let item = pop_back(account, &mut c);
- return_collection(c);
- item
-}
-
-
-
-
-addr
-
-
-public fun borrow_collection<T: store>(addr: address): Collection::Collection<T>
-
-
-
-
-public fun borrow_collection<T: store>(addr: address): Collection<T> acquires CollectionStore{
- assert!(exists_at<T>(addr), Errors::invalid_state(ECOLLECTION_NOT_EXIST));
- let c = borrow_global_mut<CollectionStore<T>>(addr);
- let items = Option::extract(&mut c.items);
- Collection{
- items,
- owner: addr
- }
-}
-
-
-
-
-public fun return_collection<T: store>(c: Collection::Collection<T>)
-
-
-
-
-public fun return_collection<T: store>(c: Collection<T>) acquires CollectionStore{
- let Collection{ items, owner } = c;
- if (Vector::is_empty(&items)) {
- let c = move_from<CollectionStore<T>>(owner);
- destroy_empty(c);
- Vector::destroy_empty(items);
- }else{
- let c = borrow_global_mut<CollectionStore<T>>(owner);
- Option::fill(&mut c.items, items);
- }
-}
-
-
-
-
-fun destroy_empty<T: store>(c: Collection::CollectionStore<T>)
-
-
-
-
-fun destroy_empty<T: store>(c: CollectionStore<T>){
- let CollectionStore{ items } = c;
- Option::destroy_none(items);
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = false;
-
-
-
-
-
-
-### Function `exists_at`
-
-
-fun exists_at<T: store>(addr: address): bool
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `put`
-
-
-public fun put<T: store>(_account: &signer, _item: T)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `take`
-
-
-public fun take<T: store>(account: &signer): T
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `borrow_collection`
-
-
-public fun borrow_collection<T: store>(addr: address): Collection::Collection<T>
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `return_collection`
-
-
-public fun return_collection<T: store>(c: Collection::Collection<T>)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `destroy_empty`
-
-
-fun destroy_empty<T: store>(c: Collection::CollectionStore<T>)
-
-
-
-
-
-aborts_if false;
-
diff --git a/vm/stdlib/compiled/latest/doc/Collection2.md b/vm/stdlib/compiled/latest/doc/Collection2.md
deleted file mode 100644
index 904e324ad2..0000000000
--- a/vm/stdlib/compiled/latest/doc/Collection2.md
+++ /dev/null
@@ -1,923 +0,0 @@
-
-
-
-# Module `0x1::Collection2`
-
-Provide a account based vector for save resource item.
-The resource in CollectionStore can borrowed by anyone, anyone can get immutable ref of item.
-and the owner of Collection can allow others to add item to Collection or get mut ref from Collection.git
-
-
-- [Struct `Collection`](#0x1_Collection2_Collection)
-- [Resource `CollectionStore`](#0x1_Collection2_CollectionStore)
-- [Constants](#@Constants_0)
-- [Function `length`](#0x1_Collection2_length)
-- [Function `borrow`](#0x1_Collection2_borrow)
-- [Function `push_back`](#0x1_Collection2_push_back)
-- [Function `borrow_mut`](#0x1_Collection2_borrow_mut)
-- [Function `pop_back`](#0x1_Collection2_pop_back)
-- [Function `remove`](#0x1_Collection2_remove)
-- [Function `append`](#0x1_Collection2_append)
-- [Function `append_all`](#0x1_Collection2_append_all)
-- [Function `exists_at`](#0x1_Collection2_exists_at)
-- [Function `is_accept`](#0x1_Collection2_is_accept)
-- [Function `accept`](#0x1_Collection2_accept)
-- [Function `put`](#0x1_Collection2_put)
-- [Function `put_all`](#0x1_Collection2_put_all)
-- [Function `take`](#0x1_Collection2_take)
-- [Function `create_collection`](#0x1_Collection2_create_collection)
-- [Function `length_of`](#0x1_Collection2_length_of)
-- [Function `borrow_collection`](#0x1_Collection2_borrow_collection)
-- [Function `return_collection`](#0x1_Collection2_return_collection)
-- [Function `destroy_collection`](#0x1_Collection2_destroy_collection)
-- [Function `destroy_empty`](#0x1_Collection2_destroy_empty)
-- [Specification](#@Specification_1)
- - [Function `length`](#@Specification_1_length)
- - [Function `exists_at`](#@Specification_1_exists_at)
- - [Function `put`](#@Specification_1_put)
- - [Function `put_all`](#@Specification_1_put_all)
- - [Function `take`](#@Specification_1_take)
- - [Function `borrow_collection`](#@Specification_1_borrow_collection)
- - [Function `return_collection`](#@Specification_1_return_collection)
- - [Function `destroy_collection`](#@Specification_1_destroy_collection)
- - [Function `destroy_empty`](#@Specification_1_destroy_empty)
-
-
-use 0x1::Errors;
-use 0x1::Option;
-use 0x1::Signer;
-use 0x1::Vector;
-
-
-
-
-
-
-## Struct `Collection`
-
-Collection in memory, can not drop & store.
-
-
-struct Collection<T>
-
-
-
-
-items: vector<T>
-owner: address
-can_put: bool
-can_mut: bool
-can_take: bool
-struct CollectionStore<T: store> has key
-
-
-
-
-items: Option::Option<vector<T>>
-anyone_can_put: bool
-anyone_can_mut: bool
-const ERR_COLLECTION_CAN_NOT_ADD: u64 = 102;
-
-
-
-
-
-
-The operator require the collection owner or collection set anyone_can_mut to true.
-
-
-const ERR_COLLECTION_CAN_NOT_MUT: u64 = 103;
-
-
-
-
-
-
-The operator require the collection owner
-
-
-const ERR_COLLECTION_CAN_NOT_TAKE: u64 = 104;
-
-
-
-
-
-
-
-
-const ERR_COLLECTION_INVALID_BORROW_STATE: u64 = 105;
-
-
-
-
-
-
-
-
-const ERR_COLLECTION_IS_NOT_EMPTY: u64 = 106;
-
-
-
-
-
-
-
-
-const ERR_COLLECTION_NOT_EXIST: u64 = 101;
-
-
-
-
-
-
-## Function `length`
-
-Return the length of the collection.
-
-
-public fun length<T>(c: &Collection2::Collection<T>): u64
-
-
-
-
-public fun length<T>(c: &Collection<T>): u64{
- Vector::length(&c.items)
-}
-
-
-
-
-i
th element of the collection c
.
-Aborts if i
is out of bounds.
-
-
-public fun borrow<T>(c: &Collection2::Collection<T>, i: u64): &T
-
-
-
-
-public fun borrow<T>(c: &Collection<T>, i: u64): &T{
- Vector::borrow(&c.items, i)
-}
-
-
-
-
-v
to the end of the collection c
.
-require owner of Collection.
-
-
-public fun push_back<T>(c: &mut Collection2::Collection<T>, t: T)
-
-
-
-
-public fun push_back<T>(c: &mut Collection<T>, t: T){
- assert!(c.can_put, Errors::requires_address(ERR_COLLECTION_CAN_NOT_ADD));
- Vector::push_back<T>(&mut c.items, t);
-}
-
-
-
-
-i
th item in the Collection c
.
-Aborts if i
is out of bounds.
-
-
-public fun borrow_mut<T>(c: &mut Collection2::Collection<T>, i: u64): &mut T
-
-
-
-
-public fun borrow_mut<T>(c: &mut Collection<T>, i: u64): &mut T{
- assert!(c.can_mut, Errors::requires_address(ERR_COLLECTION_CAN_NOT_MUT));
- Vector::borrow_mut<T>(&mut c.items, i)
-}
-
-
-
-
-v
.
-Aborts if v
is empty.
-
-
-public fun pop_back<T>(c: &mut Collection2::Collection<T>): T
-
-
-
-
-public fun pop_back<T>(c: &mut Collection<T>): T {
- assert!(c.can_take, Errors::requires_address(ERR_COLLECTION_CAN_NOT_TAKE));
- Vector::pop_back<T>(&mut c.items)
-}
-
-
-
-
-public fun remove<T>(c: &mut Collection2::Collection<T>, i: u64): T
-
-
-
-
-public fun remove<T>(c: &mut Collection<T>, i: u64): T{
- assert!(c.can_take, Errors::requires_address(ERR_COLLECTION_CAN_NOT_TAKE));
- Vector::remove<T>(&mut c.items, i)
-}
-
-
-
-
-public fun append<T>(c: &mut Collection2::Collection<T>, other: T)
-
-
-
-
-public fun append<T>(c: &mut Collection<T>, other: T) {
- assert!(c.can_put, Errors::requires_address(ERR_COLLECTION_CAN_NOT_ADD));
- Vector::append<T>(&mut c.items, Vector::singleton(other))
-}
-
-
-
-
-public fun append_all<T>(c: &mut Collection2::Collection<T>, other: vector<T>)
-
-
-
-
-public fun append_all<T>(c: &mut Collection<T>, other: vector<T>) {
- assert!(c.can_put, Errors::requires_address(ERR_COLLECTION_CAN_NOT_ADD));
- Vector::append<T>(&mut c.items, other)
-}
-
-
-
-
-addr
-
-
-public fun exists_at<T: store>(addr: address): bool
-
-
-
-
-public fun exists_at<T: store>(addr: address): bool{
- exists<CollectionStore<T>>(addr)
-}
-
-
-
-
-addr
is accept T and other can send T to addr
,
-it means exists a Collection of T at addr
and anyone_can_put of the Collection is true
-
-
-public fun is_accept<T: store>(addr: address): bool
-
-
-
-
-public fun is_accept<T: store>(addr: address): bool acquires CollectionStore {
- if (!exists<CollectionStore<T>>(addr)){
- return false
- };
- let cs = borrow_global<CollectionStore<T>>(addr);
- cs.anyone_can_put
-}
-
-
-
-
-public fun accept<T: store>(signer: &signer)
-
-
-
-
-public fun accept<T: store>(signer: &signer) acquires CollectionStore {
- let addr = Signer::address_of(signer);
- if (!exists<CollectionStore<T>>(addr)){
- Self::create_collection<T>(signer, true, false);
- };
- let cs = borrow_global_mut<CollectionStore<T>>(addr);
- if (!cs.anyone_can_put) {
- cs.anyone_can_put = true;
- }
-}
-
-
-
-
-to_addr
's Collection of T
-put = borrow_collectionpublic fun put<T: store>(signer: &signer, owner: address, item: T)
-
-
-
-
-public fun put<T: store>(signer: &signer, owner: address, item: T) acquires CollectionStore{
- let c = Self::borrow_collection(signer, owner);
- Self::append(&mut c, item);
- Self::return_collection(c);
-}
-
-
-
-
-public fun put_all<T: store>(signer: &signer, owner: address, items: vector<T>)
-
-
-
-
-public fun put_all<T: store>(signer: &signer, owner: address, items: vector<T>) acquires CollectionStore{
- let c = Self::borrow_collection(signer, owner);
- Self::append_all(&mut c, items);
- Self::return_collection(c);
-}
-
-
-
-
-public fun take<T: store>(signer: &signer): T
-
-
-
-
-public fun take<T: store>(signer: &signer): T acquires CollectionStore{
- let addr = Signer::address_of(signer);
- let c = borrow_collection<T>(signer, addr);
- let item = pop_back(&mut c);
- return_collection(c);
- item
-}
-
-
-
-
-public fun create_collection<T: store>(signer: &signer, anyone_can_put: bool, anyone_can_mut: bool)
-
-
-
-
-public fun create_collection<T:store>(signer: &signer, anyone_can_put: bool, anyone_can_mut: bool) {
- move_to(signer, CollectionStore<T>{items: Option::some(Vector::empty<T>()), anyone_can_put, anyone_can_mut})
-}
-
-
-
-
-owner
, if collection do not exist, return 0.
-
-
-public fun length_of<T: store>(owner: address): u64
-
-
-
-
-public fun length_of<T: store>(owner: address) : u64 acquires CollectionStore{
- if (exists_at<T>(owner)){
- let cs = borrow_global_mut<CollectionStore<T>>(owner);
- //if items is None, indicate it is borrowed
- assert!(!Option::is_none(&cs.items), Errors::invalid_state(ERR_COLLECTION_INVALID_BORROW_STATE));
- let items = Option::borrow(&cs.items);
- Vector::length(items)
- }else{
- 0
- }
-}
-
-
-
-
-owner
, auto detected the collection's can_put|can_mut|can_take by the sender
and Collection config.
-
-
-public fun borrow_collection<T: store>(sender: &signer, owner: address): Collection2::Collection<T>
-
-
-
-
-public fun borrow_collection<T: store>(sender: &signer, owner: address): Collection<T> acquires CollectionStore{
- assert!(exists_at<T>(owner), Errors::invalid_state(ERR_COLLECTION_NOT_EXIST));
- let cs = borrow_global_mut<CollectionStore<T>>(owner);
- //if items is None, indicate it is borrowed
- assert!(!Option::is_none(&cs.items), Errors::invalid_state(ERR_COLLECTION_INVALID_BORROW_STATE));
- let items = Option::extract(&mut cs.items);
- let is_owner = owner == Signer::address_of(sender);
- let can_put = cs.anyone_can_put || is_owner;
- let can_mut = cs.anyone_can_mut || is_owner;
- let can_take = is_owner;
- Collection{
- items,
- owner,
- can_put,
- can_mut,
- can_take,
- }
-}
-
-
-
-
-public fun return_collection<T: store>(c: Collection2::Collection<T>)
-
-
-
-
-public fun return_collection<T: store>(c: Collection<T>) acquires CollectionStore{
- let Collection{ items, owner, can_put:_, can_mut:_, can_take:_ } = c;
- let cs = borrow_global_mut<CollectionStore<T>>(owner);
- assert!(Option::is_none(&cs.items), Errors::invalid_state(ERR_COLLECTION_INVALID_BORROW_STATE));
- Option::fill(&mut cs.items, items);
-}
-
-
-
-
-public fun destroy_collection<T: store>(signer: &signer)
-
-
-
-
-public fun destroy_collection<T: store>(signer: &signer) acquires CollectionStore{
- let c = move_from<CollectionStore<T>>(Signer::address_of(signer));
- destroy_empty(c);
-}
-
-
-
-
-fun destroy_empty<T: store>(c: Collection2::CollectionStore<T>)
-
-
-
-
-fun destroy_empty<T: store>(c: CollectionStore<T>){
- let CollectionStore{ items, anyone_can_put:_, anyone_can_mut:_,} = c;
- if (Option::is_some(&items)) {
- let item_vec = Option::extract(&mut items);
- assert!(Vector::is_empty(&item_vec), Errors::invalid_state(ERR_COLLECTION_IS_NOT_EMPTY));
- Vector::destroy_empty(item_vec);
- Option::destroy_none(items);
- }else{
- Option::destroy_none(items);
- }
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = false;
-
-
-
-
-
-
-### Function `length`
-
-
-public fun length<T>(c: &Collection2::Collection<T>): u64
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `exists_at`
-
-
-public fun exists_at<T: store>(addr: address): bool
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `put`
-
-
-public fun put<T: store>(signer: &signer, owner: address, item: T)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `put_all`
-
-
-public fun put_all<T: store>(signer: &signer, owner: address, items: vector<T>)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `take`
-
-
-public fun take<T: store>(signer: &signer): T
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `borrow_collection`
-
-
-public fun borrow_collection<T: store>(sender: &signer, owner: address): Collection2::Collection<T>
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `return_collection`
-
-
-public fun return_collection<T: store>(c: Collection2::Collection<T>)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `destroy_collection`
-
-
-public fun destroy_collection<T: store>(signer: &signer)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `destroy_empty`
-
-
-fun destroy_empty<T: store>(c: Collection2::CollectionStore<T>)
-
-
-
-
-
-aborts_if false;
-
diff --git a/vm/stdlib/compiled/latest/doc/Compare.md b/vm/stdlib/compiled/latest/doc/Compare.md
deleted file mode 100644
index 4bed5511d3..0000000000
--- a/vm/stdlib/compiled/latest/doc/Compare.md
+++ /dev/null
@@ -1,283 +0,0 @@
-
-
-
-# Module `0x1::Compare`
-
-
-
-- [Constants](#@Constants_0)
-- [Function `cmp_bcs_bytes`](#0x1_Compare_cmp_bcs_bytes)
-- [Function `cmp_bytes`](#0x1_Compare_cmp_bytes)
-- [Function `cmp_u8`](#0x1_Compare_cmp_u8)
-- [Function `cmp_u64`](#0x1_Compare_cmp_u64)
-- [Specification](#@Specification_1)
- - [Function `cmp_bcs_bytes`](#@Specification_1_cmp_bcs_bytes)
- - [Function `cmp_bytes`](#@Specification_1_cmp_bytes)
- - [Function `cmp_u8`](#@Specification_1_cmp_u8)
- - [Function `cmp_u64`](#@Specification_1_cmp_u64)
-
-
-use 0x1::Vector;
-
-
-
-
-
-
-## Constants
-
-
-
-
-
-
-const EQUAL: u8 = 0;
-
-
-
-
-
-
-
-
-const GREATER_THAN: u8 = 2;
-
-
-
-
-
-
-
-
-const LESS_THAN: u8 = 1;
-
-
-
-
-
-
-## Function `cmp_bcs_bytes`
-
-Compare v1
and v2
using
-(1) byte-by-byte comparison from right to left until we reach the end of the shorter vector,
-then
-(2) vector length to break ties.
-Returns either EQUAL
(0u8), LESS_THAN
(1u8), or GREATER_THAN
(2u8).
-This function is designed to compare BCS (Starcoin Canonical Serialization)-encoded values
-(i.e., vectors produced by BCS::to_bytes
). A typical client will call
-Compare::cmp_bcs_bytes(BCS::to_bytes(&t1), BCS::to_bytes(&t2))
. The comparison provides the
-following guarantees w.r.t the original values t1 and t2:
-- cmp_bcs_bytes(bcs_ext(t1), bcs_ext(t2)) == LESS_THAN
iff cmp_bcs_bytes(t2, t1) == GREATER_THAN
-- Compare::cmp<T>(t1, t2) == EQUAL
iff t1 == t2
and (similarly)
-Compare::cmp<T>(t1, t2) != EQUAL
iff t1 != t2
, where ==
and !=
denote the Move
-bytecode operations for polymorphic equality.
-- for all primitive types T
with <
and >
comparison operators exposed in Move bytecode
-(u8
, u64
, u128
), we have
-compare_bcs_bytes(bcs_ext(t1), bcs_ext(t2)) == LESS_THAN
iff t1 < t2
and (similarly)
-compare_bcs_bytes(bcs_ext(t1), bcs_ext(t2)) == LESS_THAN
iff t1 > t2
.
-For all other types, the order is whatever the BCS encoding of the type and the comparison
-strategy above gives you. One case where the order might be surprising is the address
type.
-CoreAddresses are 16 byte hex values that BCS encodes with the identity function. The right to
-left, byte-by-byte comparison means that (for example)
-compare_bcs_bytes(bcs_ext(0x01), bcs_ext(0x10)) == LESS_THAN
(as you'd expect), but
-compare_bcs_bytes(bcs_ext(0x100), bcs_ext(0x001)) == LESS_THAN
(as you probably wouldn't expect).
-Keep this in mind when using this function to compare addresses.
-
-
-public fun cmp_bcs_bytes(v1: &vector<u8>, v2: &vector<u8>): u8
-
-
-
-
-public fun cmp_bcs_bytes(v1: &vector<u8>, v2: &vector<u8>): u8 {
- let i1 = Vector::length(v1);
- let i2 = Vector::length(v2);
- let len_cmp = cmp_u64(i1, i2);
-
- // BCS uses little endian encoding for all integer types, so we choose to compare from left
- // to right. Going right to left would make the behavior of Compare.cmp diverge from the
- // bytecode operators < and > on integer values (which would be confusing).
- while (i1 > 0 && i2 > 0) {
- i1 = i1 - 1;
- i2 = i2 - 1;
- let elem_cmp = cmp_u8(*Vector::borrow(v1, i1), *Vector::borrow(v2, i2));
- if (elem_cmp != 0) return elem_cmp
- // else, compare next element
- };
- // all compared elements equal; use length comparison to break the tie
- len_cmp
-}
-
-
-
-
-public fun cmp_bytes(v1: &vector<u8>, v2: &vector<u8>): u8
-
-
-
-
-public fun cmp_bytes(v1: &vector<u8>, v2: &vector<u8>): u8 {
- let l1 = Vector::length(v1);
- let l2 = Vector::length(v2);
- let len_cmp = cmp_u64(l1, l2);
- let i1 = 0;
- let i2 = 0;
- while (i1 < l1 && i2 < l2) {
- let elem_cmp = cmp_u8(*Vector::borrow(v1, i1), *Vector::borrow(v2, i2));
- if (elem_cmp != 0) {
- return elem_cmp
- };
- // else, compare next element
- i1 = i1 + 1;
- i2 = i2 + 1;
- };
- // all compared elements equal; use length comparison to break the tie
- len_cmp
-}
-
-
-
-
-fun cmp_u8(i1: u8, i2: u8): u8
-
-
-
-
-fun cmp_u8(i1: u8, i2: u8): u8 {
- if (i1 == i2) EQUAL
- else if (i1 < i2) LESS_THAN
- else GREATER_THAN
-}
-
-
-
-
-fun cmp_u64(i1: u64, i2: u64): u8
-
-
-
-
-fun cmp_u64(i1: u64, i2: u64): u8 {
- if (i1 == i2) EQUAL
- else if (i1 < i2) LESS_THAN
- else GREATER_THAN
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `cmp_bcs_bytes`
-
-
-public fun cmp_bcs_bytes(v1: &vector<u8>, v2: &vector<u8>): u8
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `cmp_bytes`
-
-
-public fun cmp_bytes(v1: &vector<u8>, v2: &vector<u8>): u8
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `cmp_u8`
-
-
-fun cmp_u8(i1: u8, i2: u8): u8
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `cmp_u64`
-
-
-fun cmp_u64(i1: u64, i2: u64): u8
-
-
-
-
-
-aborts_if false;
-
diff --git a/vm/stdlib/compiled/latest/doc/Config.md b/vm/stdlib/compiled/latest/doc/Config.md
deleted file mode 100644
index 1b288add60..0000000000
--- a/vm/stdlib/compiled/latest/doc/Config.md
+++ /dev/null
@@ -1,770 +0,0 @@
-
-
-
-# Module `0x1::Config`
-
-The module provides a general implmentation of configuration for onchain contracts.
-
-
-- [Resource `Config`](#0x1_Config_Config)
-- [Struct `ModifyConfigCapability`](#0x1_Config_ModifyConfigCapability)
-- [Resource `ModifyConfigCapabilityHolder`](#0x1_Config_ModifyConfigCapabilityHolder)
-- [Struct `ConfigChangeEvent`](#0x1_Config_ConfigChangeEvent)
-- [Constants](#@Constants_0)
-- [Function `get_by_address`](#0x1_Config_get_by_address)
-- [Function `config_exist_by_address`](#0x1_Config_config_exist_by_address)
-- [Function `set`](#0x1_Config_set)
-- [Function `set_with_capability`](#0x1_Config_set_with_capability)
-- [Function `publish_new_config_with_capability`](#0x1_Config_publish_new_config_with_capability)
-- [Function `publish_new_config`](#0x1_Config_publish_new_config)
-- [Function `extract_modify_config_capability`](#0x1_Config_extract_modify_config_capability)
-- [Function `restore_modify_config_capability`](#0x1_Config_restore_modify_config_capability)
-- [Function `destroy_modify_config_capability`](#0x1_Config_destroy_modify_config_capability)
-- [Function `account_address`](#0x1_Config_account_address)
-- [Function `emit_config_change_event`](#0x1_Config_emit_config_change_event)
-- [Specification](#@Specification_1)
- - [Function `get_by_address`](#@Specification_1_get_by_address)
- - [Function `config_exist_by_address`](#@Specification_1_config_exist_by_address)
- - [Function `set`](#@Specification_1_set)
- - [Function `set_with_capability`](#@Specification_1_set_with_capability)
- - [Function `publish_new_config_with_capability`](#@Specification_1_publish_new_config_with_capability)
- - [Function `publish_new_config`](#@Specification_1_publish_new_config)
- - [Function `extract_modify_config_capability`](#@Specification_1_extract_modify_config_capability)
- - [Function `restore_modify_config_capability`](#@Specification_1_restore_modify_config_capability)
- - [Function `destroy_modify_config_capability`](#@Specification_1_destroy_modify_config_capability)
- - [Function `account_address`](#@Specification_1_account_address)
- - [Function `emit_config_change_event`](#@Specification_1_emit_config_change_event)
-
-
-use 0x1::Errors;
-use 0x1::Event;
-use 0x1::Option;
-use 0x1::Signer;
-
-
-
-
-
-
-## Resource `Config`
-
-A generic singleton resource that holds a value of a specific type.
-
-
-struct Config<ConfigValue: copy, drop, store> has key
-
-
-
-
-payload: ConfigValue
-struct ModifyConfigCapability<ConfigValue: copy, drop, store> has store
-
-
-
-
-account_address: address
-events: Event::EventHandle<Config::ConfigChangeEvent<ConfigValue>>
-struct ModifyConfigCapabilityHolder<ConfigValue: copy, drop, store> has store, key
-
-
-
-
-cap: Option::Option<Config::ModifyConfigCapability<ConfigValue>>
-struct ConfigChangeEvent<ConfigValue: copy, drop, store> has drop, store
-
-
-
-
-account_address: address
-value: ConfigValue
-const ECAPABILITY_HOLDER_NOT_EXISTS: u64 = 101;
-
-
-
-
-
-
-
-
-const ECONFIG_VALUE_DOES_NOT_EXIST: u64 = 13;
-
-
-
-
-
-
-## Function `get_by_address`
-
-Get a copy of ConfigValue
value stored under addr
.
-
-
-public fun get_by_address<ConfigValue: copy, drop, store>(addr: address): ConfigValue
-
-
-
-
-public fun get_by_address<ConfigValue: copy + drop + store>(addr: address): ConfigValue acquires Config {
- assert!(exists<Config<ConfigValue>>(addr), Errors::invalid_state(ECONFIG_VALUE_DOES_NOT_EXIST));
- *&borrow_global<Config<ConfigValue>>(addr).payload
-}
-
-
-
-
-ConfigValue
type exists under addr
.
-
-
-public fun config_exist_by_address<ConfigValue: copy, drop, store>(addr: address): bool
-
-
-
-
-public fun config_exist_by_address<ConfigValue: copy + drop + store>(addr: address): bool {
- exists<Config<ConfigValue>>(addr)
-}
-
-
-
-
-public fun set<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue)
-
-
-
-
-public fun set<ConfigValue: copy + drop + store>(account: &signer, payload: ConfigValue) acquires Config,ModifyConfigCapabilityHolder{
- let signer_address = Signer::address_of(account);
- assert!(exists<ModifyConfigCapabilityHolder<ConfigValue>>(signer_address), Errors::requires_capability(ECAPABILITY_HOLDER_NOT_EXISTS));
- let cap_holder = borrow_global_mut<ModifyConfigCapabilityHolder<ConfigValue>>(signer_address);
- assert!(Option::is_some(&cap_holder.cap), Errors::requires_capability(ECAPABILITY_HOLDER_NOT_EXISTS));
- set_with_capability(Option::borrow_mut(&mut cap_holder.cap), payload)
-}
-
-
-
-
-public fun set_with_capability<ConfigValue: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<ConfigValue>, payload: ConfigValue)
-
-
-
-
-public fun set_with_capability<ConfigValue: copy + drop + store>(cap: &mut ModifyConfigCapability<ConfigValue>, payload: ConfigValue) acquires Config{
- let addr = cap.account_address;
- assert!(exists<Config<ConfigValue>>(addr), Errors::invalid_state(ECONFIG_VALUE_DOES_NOT_EXIST));
- let config = borrow_global_mut<Config<ConfigValue>>(addr);
- config.payload = copy payload;
- emit_config_change_event(cap, payload);
-}
-
-
-
-
-public fun publish_new_config_with_capability<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue): Config::ModifyConfigCapability<ConfigValue>
-
-
-
-
-public fun publish_new_config_with_capability<ConfigValue: copy + drop + store>(
- account: &signer,
- payload: ConfigValue,
-): ModifyConfigCapability<ConfigValue> acquires ModifyConfigCapabilityHolder{
- publish_new_config<ConfigValue>(account, payload);
- extract_modify_config_capability<ConfigValue>(account)
-}
-
-
-
-
-public fun publish_new_config<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue)
-
-
-
-
-public fun publish_new_config<ConfigValue: copy + drop + store>(account: &signer, payload: ConfigValue) {
- move_to(account, Config<ConfigValue>{ payload });
- let cap = ModifyConfigCapability<ConfigValue> {account_address: Signer::address_of(account), events: Event::new_event_handle<ConfigChangeEvent<ConfigValue>>(account)};
- move_to(account, ModifyConfigCapabilityHolder{cap: Option::some(cap)});
-}
-
-
-
-
-public fun extract_modify_config_capability<ConfigValue: copy, drop, store>(account: &signer): Config::ModifyConfigCapability<ConfigValue>
-
-
-
-
-public fun extract_modify_config_capability<ConfigValue: copy + drop + store>(account: &signer): ModifyConfigCapability<ConfigValue> acquires ModifyConfigCapabilityHolder{
- let signer_address = Signer::address_of(account);
- assert!(exists<ModifyConfigCapabilityHolder<ConfigValue>>(signer_address), Errors::requires_capability(ECAPABILITY_HOLDER_NOT_EXISTS));
- let cap_holder = borrow_global_mut<ModifyConfigCapabilityHolder<ConfigValue>>(signer_address);
- Option::extract(&mut cap_holder.cap)
-}
-
-
-
-
-public fun restore_modify_config_capability<ConfigValue: copy, drop, store>(cap: Config::ModifyConfigCapability<ConfigValue>)
-
-
-
-
-public fun restore_modify_config_capability<ConfigValue: copy + drop + store>(cap: ModifyConfigCapability<ConfigValue>) acquires ModifyConfigCapabilityHolder{
- let cap_holder = borrow_global_mut<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address);
- Option::fill(&mut cap_holder.cap, cap);
-}
-
-
-
-
-public fun destroy_modify_config_capability<ConfigValue: copy, drop, store>(cap: Config::ModifyConfigCapability<ConfigValue>)
-
-
-
-
-public fun destroy_modify_config_capability<ConfigValue: copy + drop + store>(cap: ModifyConfigCapability<ConfigValue>) {
- let ModifyConfigCapability{account_address:_, events} = cap;
- Event::destroy_handle(events)
-}
-
-
-
-
-public fun account_address<ConfigValue: copy, drop, store>(cap: &Config::ModifyConfigCapability<ConfigValue>): address
-
-
-
-
-public fun account_address<ConfigValue: copy + drop + store>(cap: &ModifyConfigCapability<ConfigValue>): address {
- cap.account_address
-}
-
-
-
-
-fun emit_config_change_event<ConfigValue: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<ConfigValue>, value: ConfigValue)
-
-
-
-
-fun emit_config_change_event<ConfigValue: copy + drop + store>(cap: &mut ModifyConfigCapability<ConfigValue>, value: ConfigValue) {
- Event::emit_event<ConfigChangeEvent<ConfigValue>>(
- &mut cap.events,
- ConfigChangeEvent {
- account_address: cap.account_address,
- value: value,
- },
- );
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-
-
-fun spec_get<ConfigValue>(addr: address): ConfigValue {
- global<Config<ConfigValue>>(addr).payload
-}
-
-
-
-
-
-
-### Function `get_by_address`
-
-
-public fun get_by_address<ConfigValue: copy, drop, store>(addr: address): ConfigValue
-
-
-
-
-
-aborts_if !exists<Config<ConfigValue>>(addr);
-ensures exists<Config<ConfigValue>>(addr);
-
-
-
-
-
-
-### Function `config_exist_by_address`
-
-
-public fun config_exist_by_address<ConfigValue: copy, drop, store>(addr: address): bool
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `set`
-
-
-public fun set<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue)
-
-
-
-
-
-pragma verify = false;
-aborts_if !exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-aborts_if !Option::is_some<ModifyConfigCapability<ConfigValue>>(spec_cap<ConfigValue>(Signer::address_of(account)));
-aborts_if !exists<Config<ConfigValue>>(Option::borrow<ModifyConfigCapability<ConfigValue>>(spec_cap<ConfigValue>(Signer::address_of(account))).account_address);
-ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-
-
-
-
-
-
-
-
-fun spec_cap<ConfigValue>(addr: address): Option<ModifyConfigCapability<ConfigValue>> {
- global<ModifyConfigCapabilityHolder<ConfigValue>>(addr).cap
-}
-
-
-
-
-
-
-### Function `set_with_capability`
-
-
-public fun set_with_capability<ConfigValue: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<ConfigValue>, payload: ConfigValue)
-
-
-
-
-
-aborts_if !exists<Config<ConfigValue>>(cap.account_address);
-ensures exists<Config<ConfigValue>>(cap.account_address);
-
-
-
-
-
-
-### Function `publish_new_config_with_capability`
-
-
-public fun publish_new_config_with_capability<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue): Config::ModifyConfigCapability<ConfigValue>
-
-
-
-
-
-aborts_if exists<Config<ConfigValue>>(Signer::address_of(account));
-aborts_if exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-ensures exists<Config<ConfigValue>>(Signer::address_of(account));
-ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `publish_new_config`
-
-
-public fun publish_new_config<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue)
-
-
-
-
-
-aborts_if exists<Config<ConfigValue>>(Signer::address_of(account));
-aborts_if exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-ensures exists<Config<ConfigValue>>(Signer::address_of(account));
-ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-
-
-
-
-
-
-
-
-schema PublishNewConfigAbortsIf<ConfigValue> {
- account: signer;
- aborts_if exists<Config<ConfigValue>>(Signer::address_of(account));
- aborts_if exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-}
-
-
-
-
-
-
-
-
-schema AbortsIfConfigNotExist<ConfigValue> {
- addr: address;
- aborts_if !exists<Config<ConfigValue>>(addr);
-}
-
-
-
-
-
-
-
-
-schema AbortsIfConfigOrCapabilityNotExist<ConfigValue> {
- addr: address;
- aborts_if !exists<Config<ConfigValue>>(addr);
- aborts_if !exists<ModifyConfigCapabilityHolder<ConfigValue>>(addr);
-}
-
-
-
-
-
-
-
-
-schema PublishNewConfigEnsures<ConfigValue> {
- account: signer;
- ensures exists<Config<ConfigValue>>(Signer::address_of(account));
- ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-}
-
-
-
-
-
-
-### Function `extract_modify_config_capability`
-
-
-public fun extract_modify_config_capability<ConfigValue: copy, drop, store>(account: &signer): Config::ModifyConfigCapability<ConfigValue>
-
-
-
-
-
-include AbortsIfCapNotExist<ConfigValue>{account: Signer::address_of(account)};
-ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-ensures Option::is_none<ModifyConfigCapability<ConfigValue>>(global<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account)).cap);
-
-
-
-
-
-
-### Function `restore_modify_config_capability`
-
-
-public fun restore_modify_config_capability<ConfigValue: copy, drop, store>(cap: Config::ModifyConfigCapability<ConfigValue>)
-
-
-
-
-
-aborts_if !exists<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address);
-aborts_if Option::is_some<ModifyConfigCapability<ConfigValue>>(global<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address).cap);
-ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address);
-ensures Option::is_some<ModifyConfigCapability<ConfigValue>>(global<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address).cap);
-
-
-
-
-
-
-### Function `destroy_modify_config_capability`
-
-
-public fun destroy_modify_config_capability<ConfigValue: copy, drop, store>(cap: Config::ModifyConfigCapability<ConfigValue>)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `account_address`
-
-
-public fun account_address<ConfigValue: copy, drop, store>(cap: &Config::ModifyConfigCapability<ConfigValue>): address
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `emit_config_change_event`
-
-
-fun emit_config_change_event<ConfigValue: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<ConfigValue>, value: ConfigValue)
-
-
-
-
-
-aborts_if false;
-
diff --git a/vm/stdlib/compiled/latest/doc/ConsensusConfig.md b/vm/stdlib/compiled/latest/doc/ConsensusConfig.md
deleted file mode 100644
index 7d97a17756..0000000000
--- a/vm/stdlib/compiled/latest/doc/ConsensusConfig.md
+++ /dev/null
@@ -1,725 +0,0 @@
-
-
-
-# Module `0x1::ConsensusConfig`
-
-The module provide configuration of consensus parameters.
-
-
-- [Struct `ConsensusConfig`](#0x1_ConsensusConfig_ConsensusConfig)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_ConsensusConfig_initialize)
-- [Function `new_consensus_config`](#0x1_ConsensusConfig_new_consensus_config)
-- [Function `get_config`](#0x1_ConsensusConfig_get_config)
-- [Function `uncle_rate_target`](#0x1_ConsensusConfig_uncle_rate_target)
-- [Function `base_block_time_target`](#0x1_ConsensusConfig_base_block_time_target)
-- [Function `base_reward_per_block`](#0x1_ConsensusConfig_base_reward_per_block)
-- [Function `epoch_block_count`](#0x1_ConsensusConfig_epoch_block_count)
-- [Function `base_block_difficulty_window`](#0x1_ConsensusConfig_base_block_difficulty_window)
-- [Function `base_reward_per_uncle_percent`](#0x1_ConsensusConfig_base_reward_per_uncle_percent)
-- [Function `min_block_time_target`](#0x1_ConsensusConfig_min_block_time_target)
-- [Function `max_block_time_target`](#0x1_ConsensusConfig_max_block_time_target)
-- [Function `base_max_uncles_per_block`](#0x1_ConsensusConfig_base_max_uncles_per_block)
-- [Function `base_block_gas_limit`](#0x1_ConsensusConfig_base_block_gas_limit)
-- [Function `strategy`](#0x1_ConsensusConfig_strategy)
-- [Function `compute_reward_per_block`](#0x1_ConsensusConfig_compute_reward_per_block)
-- [Function `do_compute_reward_per_block`](#0x1_ConsensusConfig_do_compute_reward_per_block)
-- [Specification](#@Specification_1)
- - [Function `initialize`](#@Specification_1_initialize)
- - [Function `new_consensus_config`](#@Specification_1_new_consensus_config)
- - [Function `get_config`](#@Specification_1_get_config)
- - [Function `compute_reward_per_block`](#@Specification_1_compute_reward_per_block)
- - [Function `do_compute_reward_per_block`](#@Specification_1_do_compute_reward_per_block)
-
-
-use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::Errors;
-use 0x1::Math;
-use 0x1::Timestamp;
-
-
-
-
-
-
-## Struct `ConsensusConfig`
-
-consensus configurations.
-
-
-struct ConsensusConfig has copy, drop, store
-
-
-
-
-uncle_rate_target: u64
-base_block_time_target: u64
-base_reward_per_block: u128
-base_reward_per_uncle_percent: u64
-base_reward_per_block
to reward a uncle block
-epoch_block_count: u64
-base_block_difficulty_window: u64
-min_block_time_target: u64
-max_block_time_target: u64
-base_max_uncles_per_block: u64
-base_block_gas_limit: u64
-strategy: u8
-const EINVALID_ARGUMENT: u64 = 18;
-
-
-
-
-
-
-## Function `initialize`
-
-Initialization of the module.
-
-
-public fun initialize(account: &signer, uncle_rate_target: u64, epoch_block_count: u64, base_block_time_target: u64, base_block_difficulty_window: u64, base_reward_per_block: u128, base_reward_per_uncle_percent: u64, min_block_time_target: u64, max_block_time_target: u64, base_max_uncles_per_block: u64, base_block_gas_limit: u64, strategy: u8)
-
-
-
-
-public fun initialize(
- account: &signer,
- uncle_rate_target: u64,
- epoch_block_count: u64,
- base_block_time_target: u64,
- base_block_difficulty_window: u64,
- base_reward_per_block: u128,
- base_reward_per_uncle_percent: u64,
- min_block_time_target: u64,
- max_block_time_target: u64,
- base_max_uncles_per_block: u64,
- base_block_gas_limit: u64,
- strategy: u8,
-) {
- Timestamp::assert_genesis();
- CoreAddresses::assert_genesis_address(account);
-
- Config::publish_new_config<Self::ConsensusConfig>(
- account,
- new_consensus_config(
- uncle_rate_target,
- base_block_time_target,
- base_reward_per_block,
- base_reward_per_uncle_percent,
- epoch_block_count,
- base_block_difficulty_window,
- min_block_time_target,
- max_block_time_target,
- base_max_uncles_per_block,
- base_block_gas_limit,
- strategy,
- ),
- );
-}
-
-
-
-
-public fun new_consensus_config(uncle_rate_target: u64, base_block_time_target: u64, base_reward_per_block: u128, base_reward_per_uncle_percent: u64, epoch_block_count: u64, base_block_difficulty_window: u64, min_block_time_target: u64, max_block_time_target: u64, base_max_uncles_per_block: u64, base_block_gas_limit: u64, strategy: u8): ConsensusConfig::ConsensusConfig
-
-
-
-
-public fun new_consensus_config(uncle_rate_target: u64,
- base_block_time_target: u64,
- base_reward_per_block: u128,
- base_reward_per_uncle_percent: u64,
- epoch_block_count: u64,
- base_block_difficulty_window: u64,
- min_block_time_target: u64,
- max_block_time_target: u64,
- base_max_uncles_per_block: u64,
- base_block_gas_limit: u64,
- strategy: u8,): ConsensusConfig {
- assert!(uncle_rate_target > 0, Errors::invalid_argument(EINVALID_ARGUMENT));
- assert!(base_block_time_target > 0, Errors::invalid_argument(EINVALID_ARGUMENT));
- assert!(base_reward_per_block > 0, Errors::invalid_argument(EINVALID_ARGUMENT));
- assert!(epoch_block_count > 0, Errors::invalid_argument(EINVALID_ARGUMENT));
- assert!(base_block_difficulty_window > 0, Errors::invalid_argument(EINVALID_ARGUMENT));
- // base_reward_per_uncle_percent can been zero.
- assert!(min_block_time_target > 0, Errors::invalid_argument(EINVALID_ARGUMENT));
- assert!(max_block_time_target >= min_block_time_target, Errors::invalid_argument(EINVALID_ARGUMENT));
-
- ConsensusConfig {
- uncle_rate_target,
- base_block_time_target,
- base_reward_per_block,
- epoch_block_count,
- base_block_difficulty_window,
- base_reward_per_uncle_percent,
- min_block_time_target,
- max_block_time_target,
- base_max_uncles_per_block,
- base_block_gas_limit,
- strategy,
- }
-}
-
-
-
-
-public fun get_config(): ConsensusConfig::ConsensusConfig
-
-
-
-
-public fun get_config(): ConsensusConfig {
- Config::get_by_address<ConsensusConfig>(CoreAddresses::GENESIS_ADDRESS())
-}
-
-
-
-
-public fun uncle_rate_target(config: &ConsensusConfig::ConsensusConfig): u64
-
-
-
-
-public fun uncle_rate_target(config: &ConsensusConfig): u64 {
- config.uncle_rate_target
-}
-
-
-
-
-public fun base_block_time_target(config: &ConsensusConfig::ConsensusConfig): u64
-
-
-
-
-public fun base_block_time_target(config: &ConsensusConfig): u64 {
- config.base_block_time_target
-}
-
-
-
-
-public fun base_reward_per_block(config: &ConsensusConfig::ConsensusConfig): u128
-
-
-
-
-public fun base_reward_per_block(config: &ConsensusConfig): u128 {
- config.base_reward_per_block
-}
-
-
-
-
-public fun epoch_block_count(config: &ConsensusConfig::ConsensusConfig): u64
-
-
-
-
-public fun epoch_block_count(config: &ConsensusConfig): u64 {
- config.epoch_block_count
-}
-
-
-
-
-public fun base_block_difficulty_window(config: &ConsensusConfig::ConsensusConfig): u64
-
-
-
-
-public fun base_block_difficulty_window(config: &ConsensusConfig): u64 {
- config.base_block_difficulty_window
-}
-
-
-
-
-public fun base_reward_per_uncle_percent(config: &ConsensusConfig::ConsensusConfig): u64
-
-
-
-
-public fun base_reward_per_uncle_percent(config: &ConsensusConfig): u64 {
- config.base_reward_per_uncle_percent
-}
-
-
-
-
-public fun min_block_time_target(config: &ConsensusConfig::ConsensusConfig): u64
-
-
-
-
-public fun min_block_time_target(config: &ConsensusConfig): u64 {
- config.min_block_time_target
-}
-
-
-
-
-public fun max_block_time_target(config: &ConsensusConfig::ConsensusConfig): u64
-
-
-
-
-public fun max_block_time_target(config: &ConsensusConfig): u64 {
- config.max_block_time_target
-}
-
-
-
-
-public fun base_max_uncles_per_block(config: &ConsensusConfig::ConsensusConfig): u64
-
-
-
-
-public fun base_max_uncles_per_block(config: &ConsensusConfig): u64 {
- config.base_max_uncles_per_block
-}
-
-
-
-
-public fun base_block_gas_limit(config: &ConsensusConfig::ConsensusConfig): u64
-
-
-
-
-public fun base_block_gas_limit(config: &ConsensusConfig): u64 {
- config.base_block_gas_limit
-}
-
-
-
-
-public fun strategy(config: &ConsensusConfig::ConsensusConfig): u8
-
-
-
-
-public fun strategy(config: &ConsensusConfig): u8 {
- config.strategy
-}
-
-
-
-
-new_epoch_block_time_target
.
-
-
-public fun compute_reward_per_block(new_epoch_block_time_target: u64): u128
-
-
-
-
-public fun compute_reward_per_block(new_epoch_block_time_target: u64): u128 {
- let config = get_config();
- do_compute_reward_per_block(&config, new_epoch_block_time_target)
-}
-
-
-
-
-new_epoch_block_time_target
, and the consensus config.
-
-
-public fun do_compute_reward_per_block(config: &ConsensusConfig::ConsensusConfig, new_epoch_block_time_target: u64): u128
-
-
-
-
-public fun do_compute_reward_per_block(config: &ConsensusConfig, new_epoch_block_time_target: u64): u128 {
- Math::mul_div(config.base_reward_per_block, (new_epoch_block_time_target as u128), (config.base_block_time_target as u128))
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, uncle_rate_target: u64, epoch_block_count: u64, base_block_time_target: u64, base_block_difficulty_window: u64, base_reward_per_block: u128, base_reward_per_uncle_percent: u64, min_block_time_target: u64, max_block_time_target: u64, base_max_uncles_per_block: u64, base_block_gas_limit: u64, strategy: u8)
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if uncle_rate_target == 0;
-aborts_if epoch_block_count == 0;
-aborts_if base_reward_per_block == 0;
-aborts_if base_block_time_target == 0;
-aborts_if base_block_difficulty_window == 0;
-aborts_if min_block_time_target == 0;
-aborts_if max_block_time_target < min_block_time_target;
-include Config::PublishNewConfigAbortsIf<ConsensusConfig>;
-include Config::PublishNewConfigEnsures<ConsensusConfig>;
-
-
-
-
-
-
-### Function `new_consensus_config`
-
-
-public fun new_consensus_config(uncle_rate_target: u64, base_block_time_target: u64, base_reward_per_block: u128, base_reward_per_uncle_percent: u64, epoch_block_count: u64, base_block_difficulty_window: u64, min_block_time_target: u64, max_block_time_target: u64, base_max_uncles_per_block: u64, base_block_gas_limit: u64, strategy: u8): ConsensusConfig::ConsensusConfig
-
-
-
-
-
-aborts_if uncle_rate_target == 0;
-aborts_if epoch_block_count == 0;
-aborts_if base_reward_per_block == 0;
-aborts_if base_block_time_target == 0;
-aborts_if base_block_difficulty_window == 0;
-aborts_if min_block_time_target == 0;
-aborts_if max_block_time_target < min_block_time_target;
-
-
-
-
-
-
-### Function `get_config`
-
-
-public fun get_config(): ConsensusConfig::ConsensusConfig
-
-
-
-
-
-aborts_if !exists<Config::Config<ConsensusConfig>>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-
-
-fun spec_get_config(): ConsensusConfig {
- global<Config::Config<ConsensusConfig>>(CoreAddresses::SPEC_GENESIS_ADDRESS()).payload
-}
-
-
-
-
-
-
-### Function `compute_reward_per_block`
-
-
-public fun compute_reward_per_block(new_epoch_block_time_target: u64): u128
-
-
-
-
-
-aborts_if !exists<Config::Config<ConsensusConfig>>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-include Math::MulDivAbortsIf{x: spec_get_config().base_reward_per_block, y: new_epoch_block_time_target, z: spec_get_config().base_block_time_target};
-
-
-
-
-
-
-### Function `do_compute_reward_per_block`
-
-
-public fun do_compute_reward_per_block(config: &ConsensusConfig::ConsensusConfig, new_epoch_block_time_target: u64): u128
-
-
-
-
-
-include Math::MulDivAbortsIf{x: config.base_reward_per_block, y: new_epoch_block_time_target, z: config.base_block_time_target};
-
diff --git a/vm/stdlib/compiled/latest/doc/ConsensusStrategy.md b/vm/stdlib/compiled/latest/doc/ConsensusStrategy.md
deleted file mode 100644
index c7562701ca..0000000000
--- a/vm/stdlib/compiled/latest/doc/ConsensusStrategy.md
+++ /dev/null
@@ -1,153 +0,0 @@
-
-
-
-# Module `0x1::ConsensusStrategy`
-
-The module provides the information of current consensus strategy.
-
-
-- [Struct `ConsensusStrategy`](#0x1_ConsensusStrategy_ConsensusStrategy)
-- [Function `initialize`](#0x1_ConsensusStrategy_initialize)
-- [Function `get`](#0x1_ConsensusStrategy_get)
-- [Specification](#@Specification_0)
- - [Function `initialize`](#@Specification_0_initialize)
- - [Function `get`](#@Specification_0_get)
-
-
-use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::Timestamp;
-
-
-
-
-
-
-## Struct `ConsensusStrategy`
-
-ConsensusStrategy data.
-
-
-struct ConsensusStrategy has copy, drop, store
-
-
-
-
-value: u8
-public fun initialize(account: &signer, consensus_strategy: u8)
-
-
-
-
-public fun initialize(account: &signer, consensus_strategy: u8) {
- Timestamp::assert_genesis();
- CoreAddresses::assert_genesis_address(account);
- let cap = Config::publish_new_config_with_capability<ConsensusStrategy>(
- account,
- ConsensusStrategy { value:consensus_strategy }
- );
- //destroy the cap, so ConsensusStrategy can not been change.
- Config::destroy_modify_config_capability(cap);
-}
-
-
-
-
-public fun get(): u8
-
-
-
-
-public fun get(): u8 {
- Config::get_by_address<ConsensusStrategy>(CoreAddresses::GENESIS_ADDRESS()).value
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, consensus_strategy: u8)
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if exists<Config::Config<ConsensusStrategy>>(Signer::address_of(account));
-aborts_if exists<Config::ModifyConfigCapabilityHolder<ConsensusStrategy>>(Signer::address_of(account));
-ensures exists<Config::Config<ConsensusStrategy>>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `get`
-
-
-public fun get(): u8
-
-
-
-
-
-aborts_if !exists<Config::Config<ConsensusStrategy>>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
diff --git a/vm/stdlib/compiled/latest/doc/CoreAddresses.md b/vm/stdlib/compiled/latest/doc/CoreAddresses.md
deleted file mode 100644
index b6026d9c60..0000000000
--- a/vm/stdlib/compiled/latest/doc/CoreAddresses.md
+++ /dev/null
@@ -1,218 +0,0 @@
-
-
-
-# Module `0x1::CoreAddresses`
-
-The module provide addresses used in stdlib.
-
-
-- [Constants](#@Constants_0)
-- [Function `GENESIS_ADDRESS`](#0x1_CoreAddresses_GENESIS_ADDRESS)
-- [Function `assert_genesis_address`](#0x1_CoreAddresses_assert_genesis_address)
-- [Function `ASSOCIATION_ROOT_ADDRESS`](#0x1_CoreAddresses_ASSOCIATION_ROOT_ADDRESS)
-- [Function `VM_RESERVED_ADDRESS`](#0x1_CoreAddresses_VM_RESERVED_ADDRESS)
-- [Specification](#@Specification_1)
- - [Function `assert_genesis_address`](#@Specification_1_assert_genesis_address)
-
-
-use 0x1::Errors;
-use 0x1::Signer;
-
-
-
-
-
-
-## Constants
-
-
-
-
-
-
-const ENOT_GENESIS_ACCOUNT: u64 = 11;
-
-
-
-
-
-
-## Function `GENESIS_ADDRESS`
-
-The address of the genesis
-
-
-public fun GENESIS_ADDRESS(): address
-
-
-
-
-public fun GENESIS_ADDRESS(): address {
- @0x1
-}
-
-
-
-
-public fun assert_genesis_address(account: &signer)
-
-
-
-
-public fun assert_genesis_address(account: &signer) {
- assert!(Signer::address_of(account) == GENESIS_ADDRESS(), Errors::requires_address(ENOT_GENESIS_ACCOUNT))
-}
-
-
-
-
-public fun ASSOCIATION_ROOT_ADDRESS(): address
-
-
-
-
-public fun ASSOCIATION_ROOT_ADDRESS(): address {
- @0xA550C18
-}
-
-
-
-
-0x0
address since there
-is no signer for the transaction.
-
-
-public fun VM_RESERVED_ADDRESS(): address
-
-
-
-
-public fun VM_RESERVED_ADDRESS(): address {
- @0x0
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-Specification version of Self::GENESIS_ACCOUNT
.
-
-
-
-
-
-fun SPEC_GENESIS_ADDRESS(): address {
- @0x1
-}
-
-
-
-Specification version of Self::ASSOCIATION_ROOT_ADDRESS
.
-
-
-
-
-
-fun SPEC_ASSOCIATION_ROOT_ADDRESS(): address {
- @0xA550C18
-}
-
-
-
-Specification version of Self::VM_RESERVED_ADDRESS
.
-
-
-
-
-
-fun SPEC_VM_RESERVED_ADDRESS(): address {
- @0x0
-}
-
-
-
-
-
-
-### Function `assert_genesis_address`
-
-
-public fun assert_genesis_address(account: &signer)
-
-
-
-
-
-pragma opaque;
-include AbortsIfNotGenesisAddress;
-
-
-
-Specifies that a function aborts if the account does not have the Diem root address.
-
-
-
-
-
-schema AbortsIfNotGenesisAddress {
- account: signer;
- aborts_if Signer::address_of(account) != SPEC_GENESIS_ADDRESS();
-}
-
diff --git a/vm/stdlib/compiled/latest/doc/Dao.md b/vm/stdlib/compiled/latest/doc/Dao.md
deleted file mode 100644
index 6f1133824a..0000000000
--- a/vm/stdlib/compiled/latest/doc/Dao.md
+++ /dev/null
@@ -1,2478 +0,0 @@
-
-
-
-# Module `0x1::Dao`
-
-
-
-- [Resource `DaoGlobalInfo`](#0x1_Dao_DaoGlobalInfo)
-- [Struct `DaoConfig`](#0x1_Dao_DaoConfig)
-- [Struct `ProposalCreatedEvent`](#0x1_Dao_ProposalCreatedEvent)
-- [Struct `VoteChangedEvent`](#0x1_Dao_VoteChangedEvent)
-- [Resource `Proposal`](#0x1_Dao_Proposal)
-- [Resource `Vote`](#0x1_Dao_Vote)
-- [Constants](#@Constants_0)
-- [Function `plugin`](#0x1_Dao_plugin)
-- [Function `new_dao_config`](#0x1_Dao_new_dao_config)
-- [Function `propose`](#0x1_Dao_propose)
-- [Function `cast_vote`](#0x1_Dao_cast_vote)
-- [Function `do_cast_vote`](#0x1_Dao_do_cast_vote)
-- [Function `change_vote`](#0x1_Dao_change_vote)
-- [Function `do_flip_vote`](#0x1_Dao_do_flip_vote)
-- [Function `revoke_vote`](#0x1_Dao_revoke_vote)
-- [Function `do_revoke_vote`](#0x1_Dao_do_revoke_vote)
-- [Function `unstake_votes`](#0x1_Dao_unstake_votes)
-- [Function `queue_proposal_action`](#0x1_Dao_queue_proposal_action)
-- [Function `extract_proposal_action`](#0x1_Dao_extract_proposal_action)
-- [Function `destroy_terminated_proposal`](#0x1_Dao_destroy_terminated_proposal)
-- [Function `proposal_exists`](#0x1_Dao_proposal_exists)
-- [Function `proposal_state`](#0x1_Dao_proposal_state)
-- [Function `do_proposal_state`](#0x1_Dao_do_proposal_state)
-- [Function `proposal_info`](#0x1_Dao_proposal_info)
-- [Function `vote_of`](#0x1_Dao_vote_of)
-- [Function `has_vote`](#0x1_Dao_has_vote)
-- [Function `generate_next_proposal_id`](#0x1_Dao_generate_next_proposal_id)
-- [Function `voting_delay`](#0x1_Dao_voting_delay)
-- [Function `voting_period`](#0x1_Dao_voting_period)
-- [Function `quorum_votes`](#0x1_Dao_quorum_votes)
-- [Function `voting_quorum_rate`](#0x1_Dao_voting_quorum_rate)
-- [Function `min_action_delay`](#0x1_Dao_min_action_delay)
-- [Function `get_config`](#0x1_Dao_get_config)
-- [Function `modify_dao_config`](#0x1_Dao_modify_dao_config)
-- [Function `set_voting_delay`](#0x1_Dao_set_voting_delay)
-- [Function `set_voting_period`](#0x1_Dao_set_voting_period)
-- [Function `set_voting_quorum_rate`](#0x1_Dao_set_voting_quorum_rate)
-- [Function `set_min_action_delay`](#0x1_Dao_set_min_action_delay)
-- [Specification](#@Specification_1)
- - [Struct `DaoConfig`](#@Specification_1_DaoConfig)
- - [Function `plugin`](#@Specification_1_plugin)
- - [Function `new_dao_config`](#@Specification_1_new_dao_config)
- - [Function `propose`](#@Specification_1_propose)
- - [Function `cast_vote`](#@Specification_1_cast_vote)
- - [Function `do_cast_vote`](#@Specification_1_do_cast_vote)
- - [Function `change_vote`](#@Specification_1_change_vote)
- - [Function `do_flip_vote`](#@Specification_1_do_flip_vote)
- - [Function `revoke_vote`](#@Specification_1_revoke_vote)
- - [Function `do_revoke_vote`](#@Specification_1_do_revoke_vote)
- - [Function `unstake_votes`](#@Specification_1_unstake_votes)
- - [Function `queue_proposal_action`](#@Specification_1_queue_proposal_action)
- - [Function `extract_proposal_action`](#@Specification_1_extract_proposal_action)
- - [Function `destroy_terminated_proposal`](#@Specification_1_destroy_terminated_proposal)
- - [Function `proposal_exists`](#@Specification_1_proposal_exists)
- - [Function `proposal_state`](#@Specification_1_proposal_state)
- - [Function `proposal_info`](#@Specification_1_proposal_info)
- - [Function `vote_of`](#@Specification_1_vote_of)
- - [Function `generate_next_proposal_id`](#@Specification_1_generate_next_proposal_id)
- - [Function `voting_delay`](#@Specification_1_voting_delay)
- - [Function `voting_period`](#@Specification_1_voting_period)
- - [Function `quorum_votes`](#@Specification_1_quorum_votes)
- - [Function `voting_quorum_rate`](#@Specification_1_voting_quorum_rate)
- - [Function `min_action_delay`](#@Specification_1_min_action_delay)
- - [Function `get_config`](#@Specification_1_get_config)
- - [Function `modify_dao_config`](#@Specification_1_modify_dao_config)
- - [Function `set_voting_delay`](#@Specification_1_set_voting_delay)
- - [Function `set_voting_period`](#@Specification_1_set_voting_period)
- - [Function `set_voting_quorum_rate`](#@Specification_1_set_voting_quorum_rate)
- - [Function `set_min_action_delay`](#@Specification_1_set_min_action_delay)
-
-
-use 0x1::Config;
-use 0x1::Errors;
-use 0x1::Event;
-use 0x1::Option;
-use 0x1::Signer;
-use 0x1::Timestamp;
-use 0x1::Token;
-use 0x1::Treasury;
-
-
-
-
-
-
-## Resource `DaoGlobalInfo`
-
-global DAO info of the specified token type Token
.
-
-
-struct DaoGlobalInfo<Token: store> has key
-
-
-
-
-next_proposal_id: u64
-proposal_create_event: Event::EventHandle<Dao::ProposalCreatedEvent>
-vote_changed_event: Event::EventHandle<Dao::VoteChangedEvent>
-Token
's DAO.
-
-
-struct DaoConfig<TokenT: copy, drop, store> has copy, drop, store
-
-
-
-
-voting_delay: u64
-voting_period: u64
-voting_quorum_rate: u8
-min_action_delay: u64
-struct ProposalCreatedEvent has drop, store
-
-
-
-
-proposal_id: u64
-proposer: address
-struct VoteChangedEvent has drop, store
-
-
-
-
-proposal_id: u64
-voter: address
-proposer: address
-agree: bool
-vote: u128
-struct Proposal<Token: store, Action: store> has key
-
-
-
-
-id: u64
-proposer: address
-start_time: u64
-end_time: u64
-for_votes: u128
-against_votes: u128
-eta: u64
-action_delay: u64
-quorum_votes: u128
-action: Option::Option<Action>
-struct Vote<TokenT: store> has key
-
-
-
-
-proposer: address
-proposer
.
-id: u64
-stake: Token::Token<TokenT>
-agree: bool
-const ERR_NOT_AUTHORIZED: u64 = 1401;
-
-
-
-
-
-
-
-
-const ACTIVE: u8 = 2;
-
-
-
-
-
-
-
-
-const AGREED: u8 = 4;
-
-
-
-
-
-
-
-
-const DEFEATED: u8 = 3;
-
-
-
-
-
-
-
-
-const ERR_ACTION_DELAY_TOO_SMALL: u64 = 1402;
-
-
-
-
-
-
-
-
-const ERR_ACTION_MUST_EXIST: u64 = 1409;
-
-
-
-
-
-
-
-
-const ERR_CONFIG_PARAM_INVALID: u64 = 1407;
-
-
-
-
-
-
-
-
-const ERR_PROPOSAL_ID_MISMATCH: u64 = 1404;
-
-
-
-
-
-
-
-
-const ERR_PROPOSAL_STATE_INVALID: u64 = 1403;
-
-
-
-
-
-
-
-
-const ERR_PROPOSER_MISMATCH: u64 = 1405;
-
-
-
-
-
-
-
-
-const ERR_QUORUM_RATE_INVALID: u64 = 1406;
-
-
-
-
-
-
-
-
-const ERR_VOTED_OTHERS_ALREADY: u64 = 1410;
-
-
-
-
-
-
-
-
-const ERR_VOTE_STATE_MISMATCH: u64 = 1408;
-
-
-
-
-
-
-
-
-const EXECUTABLE: u8 = 6;
-
-
-
-
-
-
-
-
-const EXTRACTED: u8 = 7;
-
-
-
-
-
-
-Proposal state
-
-
-const PENDING: u8 = 1;
-
-
-
-
-
-
-
-
-const QUEUED: u8 = 5;
-
-
-
-
-
-
-## Function `plugin`
-
-plugin function, can only be called by token issuer.
-Any token who wants to has gov functionality
-can optin this module by call this register function
.
-
-
-public fun plugin<TokenT: copy, drop, store>(signer: &signer, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64)
-
-
-
-
-public fun plugin<TokenT: copy + drop + store>(
- signer: &signer,
- voting_delay: u64,
- voting_period: u64,
- voting_quorum_rate: u8,
- min_action_delay: u64,
-) {
- let token_issuer = Token::token_address<TokenT>();
- assert!(Signer::address_of(signer) == token_issuer, Errors::requires_address(ERR_NOT_AUTHORIZED));
- // let proposal_id = ProposalId {next: 0};
- let gov_info = DaoGlobalInfo<TokenT> {
- next_proposal_id: 0,
- proposal_create_event: Event::new_event_handle<ProposalCreatedEvent>(signer),
- vote_changed_event: Event::new_event_handle<VoteChangedEvent>(signer),
- };
- move_to(signer, gov_info);
- let config = new_dao_config<TokenT>(
- voting_delay,
- voting_period,
- voting_quorum_rate,
- min_action_delay,
- );
- Config::publish_new_config(signer, config);
-}
-
-
-
-
-public fun new_dao_config<TokenT: copy, drop, store>(voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64): Dao::DaoConfig<TokenT>
-
-
-
-
-public fun new_dao_config<TokenT: copy + drop + store>(
- voting_delay: u64,
- voting_period: u64,
- voting_quorum_rate: u8,
- min_action_delay: u64,
-): DaoConfig<TokenT> {
- assert!(voting_delay > 0, Errors::invalid_argument(ERR_CONFIG_PARAM_INVALID));
- assert!(voting_period > 0, Errors::invalid_argument(ERR_CONFIG_PARAM_INVALID));
- assert!(voting_quorum_rate > 0 && voting_quorum_rate <= 100, Errors::invalid_argument(ERR_CONFIG_PARAM_INVALID));
- assert!(min_action_delay > 0, Errors::invalid_argument(ERR_CONFIG_PARAM_INVALID));
- DaoConfig { voting_delay, voting_period, voting_quorum_rate, min_action_delay }
-}
-
-
-
-
-action
: the actual action to execute.
-action_delay
: the delay to execute after the proposal is agreed
-
-
-public fun propose<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, action: ActionT, action_delay: u64)
-
-
-
-
-public fun propose<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- signer: &signer,
- action: ActionT,
- action_delay: u64,
-) acquires DaoGlobalInfo {
- if (action_delay == 0) {
- action_delay = min_action_delay<TokenT>();
- } else {
- assert!(action_delay >= min_action_delay<TokenT>(), Errors::invalid_argument(ERR_ACTION_DELAY_TOO_SMALL));
- };
- let proposal_id = generate_next_proposal_id<TokenT>();
- let proposer = Signer::address_of(signer);
- let start_time = Timestamp::now_milliseconds() + voting_delay<TokenT>();
- let quorum_votes = quorum_votes<TokenT>();
- let proposal = Proposal<TokenT, ActionT> {
- id: proposal_id,
- proposer,
- start_time,
- end_time: start_time + voting_period<TokenT>(),
- for_votes: 0,
- against_votes: 0,
- eta: 0,
- action_delay,
- quorum_votes: quorum_votes,
- action: Option::some(action),
- };
- move_to(signer, proposal);
- // emit event
- let gov_info = borrow_global_mut<DaoGlobalInfo<TokenT>>(Token::token_address<TokenT>());
- Event::emit_event(
- &mut gov_info.proposal_create_event,
- ProposalCreatedEvent { proposal_id, proposer },
- );
-}
-
-
-
-
-public fun cast_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64, stake: Token::Token<TokenT>, agree: bool)
-
-
-
-
-public fun cast_vote<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- signer: &signer,
- proposer_address: address,
- proposal_id: u64,
- stake: Token::Token<TokenT>,
- agree: bool,
-) acquires Proposal, DaoGlobalInfo, Vote {
- {
- let state = proposal_state<TokenT, ActionT>(proposer_address, proposal_id);
- // only when proposal is active, use can cast vote.
- assert!(state == ACTIVE, Errors::invalid_state(ERR_PROPOSAL_STATE_INVALID));
- };
- let proposal = borrow_global_mut<Proposal<TokenT, ActionT>>(proposer_address);
- assert!(proposal.id == proposal_id, Errors::invalid_argument(ERR_PROPOSAL_ID_MISMATCH));
- let sender = Signer::address_of(signer);
- let total_voted = if (exists<Vote<TokenT>>(sender)) {
- let my_vote = borrow_global_mut<Vote<TokenT>>(sender);
- assert!(my_vote.id == proposal_id, Errors::invalid_argument(ERR_VOTED_OTHERS_ALREADY));
- assert!(my_vote.agree == agree, Errors::invalid_state(ERR_VOTE_STATE_MISMATCH));
-
- do_cast_vote(proposal, my_vote, stake);
- Token::value(&my_vote.stake)
- } else {
- let my_vote = Vote<TokenT> {
- proposer: proposer_address,
- id: proposal_id,
- stake: Token::zero(),
- agree,
- };
- do_cast_vote(proposal, &mut my_vote, stake);
- let total_voted = Token::value(&my_vote.stake);
- move_to(signer, my_vote);
- total_voted
- };
-
- // emit event
- let gov_info = borrow_global_mut<DaoGlobalInfo<TokenT>>(Token::token_address<TokenT>());
- Event::emit_event(
- &mut gov_info.vote_changed_event,
- VoteChangedEvent {
- proposal_id,
- proposer: proposer_address,
- voter: sender,
- agree,
- vote: total_voted,
- },
- );
-}
-
-
-
-
-fun do_cast_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposal: &mut Dao::Proposal<TokenT, ActionT>, vote: &mut Dao::Vote<TokenT>, stake: Token::Token<TokenT>)
-
-
-
-
-fun do_cast_vote<TokenT: copy + drop + store, ActionT: copy + drop + store>(proposal: &mut Proposal<TokenT, ActionT>, vote: &mut Vote<TokenT>, stake: Token::Token<TokenT>) {
- let stake_value = Token::value(&stake);
- Token::deposit(&mut vote.stake, stake);
- if (vote.agree) {
- proposal.for_votes = proposal.for_votes + stake_value;
- } else {
- proposal.against_votes = proposal.against_votes + stake_value;
- };
-}
-
-
-
-
-public fun change_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64, agree: bool)
-
-
-
-
-public fun change_vote<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- signer: &signer,
- proposer_address: address,
- proposal_id: u64,
- agree: bool,
-) acquires Proposal, DaoGlobalInfo, Vote {
- {
- let state = proposal_state<TokenT, ActionT>(proposer_address, proposal_id);
- // only when proposal is active, user can change vote.
- assert!(state == ACTIVE, Errors::invalid_state(ERR_PROPOSAL_STATE_INVALID));
- };
- let proposal = borrow_global_mut<Proposal<TokenT, ActionT>>(proposer_address);
- assert!(proposal.id == proposal_id, Errors::invalid_argument(ERR_PROPOSAL_ID_MISMATCH));
- let my_vote = borrow_global_mut<Vote<TokenT>>(Signer::address_of(signer));
- {
- assert!(my_vote.proposer == proposer_address, Errors::invalid_argument(ERR_PROPOSER_MISMATCH));
- assert!(my_vote.id == proposal_id, Errors::invalid_argument(ERR_VOTED_OTHERS_ALREADY));
- };
-
- // flip the vote
- if (my_vote.agree != agree) {
- let total_voted = do_flip_vote(my_vote, proposal);
- // emit event
- let gov_info = borrow_global_mut<DaoGlobalInfo<TokenT>>(Token::token_address<TokenT>());
- Event::emit_event(
- &mut gov_info.vote_changed_event,
- VoteChangedEvent {
- proposal_id,
- proposer: proposer_address,
- voter: Signer::address_of(signer),
- agree,
- vote: total_voted,
- },
- );
- };
-}
-
-
-
-
-fun do_flip_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(my_vote: &mut Dao::Vote<TokenT>, proposal: &mut Dao::Proposal<TokenT, ActionT>): u128
-
-
-
-
-fun do_flip_vote<TokenT: copy + drop + store, ActionT: copy + drop + store>(my_vote: &mut Vote<TokenT>, proposal: &mut Proposal<TokenT, ActionT>): u128 {
- my_vote.agree = !my_vote.agree;
- let total_voted = Token::value(&my_vote.stake);
- if (my_vote.agree) {
- proposal.for_votes = proposal.for_votes + total_voted;
- proposal.against_votes = proposal.against_votes - total_voted;
- } else {
- proposal.for_votes = proposal.for_votes - total_voted;
- proposal.against_votes = proposal.against_votes + total_voted;
- };
- total_voted
-}
-
-
-
-
-proposal_id
of proposer_address
.
-
-
-public fun revoke_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64, voting_power: u128): Token::Token<TokenT>
-
-
-
-
-public fun revoke_vote<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- signer: &signer,
- proposer_address: address,
- proposal_id: u64,
- voting_power: u128,
-): Token::Token<TokenT> acquires Proposal, Vote, DaoGlobalInfo {
- {
- let state = proposal_state<TokenT, ActionT>(proposer_address, proposal_id);
- // only when proposal is active, user can revoke vote.
- assert!(state == ACTIVE, Errors::invalid_state(ERR_PROPOSAL_STATE_INVALID));
- };
- // get proposal
- let proposal = borrow_global_mut<Proposal<TokenT, ActionT>>(proposer_address);
-
- // get vote
- let my_vote = move_from<Vote<TokenT>>(Signer::address_of(signer));
- {
- assert!(my_vote.proposer == proposer_address, Errors::invalid_argument(ERR_PROPOSER_MISMATCH));
- assert!(my_vote.id == proposal_id, Errors::invalid_argument(ERR_VOTED_OTHERS_ALREADY));
- };
- // revoke vote on proposal
- let reverted_stake =do_revoke_vote(proposal, &mut my_vote, voting_power);
- // emit vote changed event
- let gov_info = borrow_global_mut<DaoGlobalInfo<TokenT>>(Token::token_address<TokenT>());
- Event::emit_event(
- &mut gov_info.vote_changed_event,
- VoteChangedEvent {
- proposal_id,
- proposer: proposer_address,
- voter: Signer::address_of(signer),
- agree: my_vote.agree,
- vote: Token::value(&my_vote.stake),
- },
- );
-
- // if user has no stake, destroy his vote. resolve https://github.com/starcoinorg/starcoin/issues/2925.
- if (Token::value(&my_vote.stake) == 0u128) {
- let Vote {stake, proposer: _, id: _, agree: _} = my_vote;
- Token::destroy_zero(stake);
- } else {
- move_to(signer, my_vote);
- };
-
- reverted_stake
-}
-
-
-
-
-fun do_revoke_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposal: &mut Dao::Proposal<TokenT, ActionT>, vote: &mut Dao::Vote<TokenT>, to_revoke: u128): Token::Token<TokenT>
-
-
-
-
-fun do_revoke_vote<TokenT: copy + drop + store, ActionT: copy + drop + store>(proposal: &mut Proposal<TokenT, ActionT>, vote: &mut Vote<TokenT>, to_revoke: u128): Token::Token<TokenT> {
- spec {
- assume vote.stake.value >= to_revoke;
- };
- let reverted_stake = Token::withdraw(&mut vote.stake, to_revoke);
- if (vote.agree) {
- proposal.for_votes = proposal.for_votes - to_revoke;
- } else {
- proposal.against_votes = proposal.against_votes - to_revoke;
- };
- spec {
- assert Token::value(reverted_stake) == to_revoke;
- };
- reverted_stake
-}
-
-
-
-
-public fun unstake_votes<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64): Token::Token<TokenT>
-
-
-
-
-public fun unstake_votes<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- signer: &signer,
- proposer_address: address,
- proposal_id: u64,
-): Token::Token<TokenT> acquires Proposal, Vote {
- // only check state when proposal exists.
- // because proposal can be destroyed after it ends in DEFEATED or EXTRACTED state.
- if (proposal_exists<TokenT, ActionT>(proposer_address, proposal_id)) {
- let state = proposal_state<TokenT, ActionT>(proposer_address, proposal_id);
- // Only after vote period end, user can unstake his votes.
- assert!(state > ACTIVE, Errors::invalid_state(ERR_PROPOSAL_STATE_INVALID));
- };
- let Vote { proposer, id, stake, agree: _ } = move_from<Vote<TokenT>>(
- Signer::address_of(signer),
- );
- // these checks are still required.
- assert!(proposer == proposer_address, Errors::requires_address(ERR_PROPOSER_MISMATCH));
- assert!(id == proposal_id, Errors::invalid_argument(ERR_VOTED_OTHERS_ALREADY));
- stake
-}
-
-
-
-
-public(script) fun queue_proposal_action<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-public(script) fun queue_proposal_action<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- proposer_address: address,
- proposal_id: u64,
-) acquires Proposal {
- // Only agreed proposal can be submitted.
- assert!(
- proposal_state<TokenT, ActionT>(proposer_address, proposal_id) == AGREED,
- Errors::invalid_state(ERR_PROPOSAL_STATE_INVALID)
- );
- let proposal = borrow_global_mut<Proposal<TokenT, ActionT>>(proposer_address);
- proposal.eta = Timestamp::now_milliseconds() + proposal.action_delay;
-}
-
-
-
-
-public fun extract_proposal_action<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64): ActionT
-
-
-
-
-public fun extract_proposal_action<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- proposer_address: address,
- proposal_id: u64,
-): ActionT acquires Proposal {
- // Only executable proposal's action can be extracted.
- assert!(
- proposal_state<TokenT, ActionT>(proposer_address, proposal_id) == EXECUTABLE,
- Errors::invalid_state(ERR_PROPOSAL_STATE_INVALID),
- );
- let proposal = borrow_global_mut<Proposal<TokenT, ActionT>>(proposer_address);
- let action: ActionT = Option::extract(&mut proposal.action);
- action
-}
-
-
-
-
-public(script) fun destroy_terminated_proposal<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-public(script) fun destroy_terminated_proposal<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- proposer_address: address,
- proposal_id: u64,
-) acquires Proposal {
- let proposal_state = proposal_state<TokenT, ActionT>(proposer_address, proposal_id);
- assert!(
- proposal_state == DEFEATED || proposal_state == EXTRACTED,
- Errors::invalid_state(ERR_PROPOSAL_STATE_INVALID),
- );
- let Proposal {
- id: _,
- proposer: _,
- start_time: _,
- end_time: _,
- for_votes: _,
- against_votes: _,
- eta: _,
- action_delay: _,
- quorum_votes: _,
- action,
- } = move_from<Proposal<TokenT, ActionT>>(proposer_address);
- if (proposal_state == DEFEATED) {
- let _ = Option::extract(&mut action);
- };
- Option::destroy_none(action);
-}
-
-
-
-
-proposer_address
with id proposal_id
.
-
-
-public fun proposal_exists<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64): bool
-
-
-
-
-public fun proposal_exists<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- proposer_address: address,
- proposal_id: u64,
-): bool acquires Proposal {
- if (exists<Proposal<TokenT, ActionT>>(proposer_address)) {
- let proposal = borrow_global<Proposal<TokenT, ActionT>>(proposer_address);
- return proposal.id == proposal_id
- };
- false
-}
-
-
-
-
-public fun proposal_state<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64): u8
-
-
-
-
-public fun proposal_state<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- proposer_address: address,
- proposal_id: u64,
-): u8 acquires Proposal {
- let proposal = borrow_global<Proposal<TokenT, ActionT>>(proposer_address);
- assert!(proposal.id == proposal_id, Errors::invalid_argument(ERR_PROPOSAL_ID_MISMATCH));
- let current_time = Timestamp::now_milliseconds();
- do_proposal_state(proposal, current_time)
-}
-
-
-
-
-fun do_proposal_state<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposal: &Dao::Proposal<TokenT, ActionT>, current_time: u64): u8
-
-
-
-
-fun do_proposal_state<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- proposal: &Proposal<TokenT, ActionT>,
- current_time: u64,
-): u8 {
- if (current_time < proposal.start_time) {
- // Pending
- PENDING
- } else if (current_time <= proposal.end_time) {
- // Active
- ACTIVE
- } else if (proposal.for_votes <= proposal.against_votes ||
- proposal.for_votes < proposal.quorum_votes) {
- // Defeated
- DEFEATED
- } else if (proposal.eta == 0) {
- // Agreed.
- AGREED
- } else if (current_time < proposal.eta) {
- // Queued, waiting to execute
- QUEUED
- } else if (Option::is_some(&proposal.action)) {
- EXECUTABLE
- } else {
- EXTRACTED
- }
-}
-
-
-
-
-public fun proposal_info<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address): (u64, u64, u64, u128, u128)
-
-
-
-
-public fun proposal_info<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- proposer_address: address,
-): (u64, u64, u64, u128, u128) acquires Proposal {
- let proposal = borrow_global<Proposal<TokenT, ActionT>>(proposer_address);
- (proposal.id, proposal.start_time, proposal.end_time, proposal.for_votes, proposal.against_votes)
-}
-
-
-
-
-proposal_id
of proposer_address
.
-
-
-public fun vote_of<TokenT: copy, drop, store>(voter: address, proposer_address: address, proposal_id: u64): (bool, u128)
-
-
-
-
-public fun vote_of<TokenT: copy + drop + store>(
- voter: address,
- proposer_address: address,
- proposal_id: u64,
-): (bool, u128) acquires Vote {
- let vote = borrow_global<Vote<TokenT>>(voter);
- assert!(vote.proposer == proposer_address, Errors::requires_address(ERR_PROPOSER_MISMATCH));
- assert!(vote.id == proposal_id, Errors::invalid_argument(ERR_VOTED_OTHERS_ALREADY));
- (vote.agree, Token::value(&vote.stake))
-}
-
-
-
-
-proposal_id
of proposer_address
.
-
-
-public fun has_vote<TokenT: copy, drop, store>(voter: address, proposer_address: address, proposal_id: u64): bool
-
-
-
-
-public fun has_vote<TokenT: copy + drop + store>(
- voter: address,
- proposer_address: address,
- proposal_id: u64,
-): bool acquires Vote {
- if (!exists<Vote<TokenT>>(voter)) {
- return false
- };
-
- let vote = borrow_global<Vote<TokenT>>(voter);
- vote.proposer == proposer_address && vote.id == proposal_id
-}
-
-
-
-
-fun generate_next_proposal_id<TokenT: store>(): u64
-
-
-
-
-fun generate_next_proposal_id<TokenT: store>(): u64 acquires DaoGlobalInfo {
- let gov_info = borrow_global_mut<DaoGlobalInfo<TokenT>>(Token::token_address<TokenT>());
- let proposal_id = gov_info.next_proposal_id;
- gov_info.next_proposal_id = proposal_id + 1;
- proposal_id
-}
-
-
-
-
-public fun voting_delay<TokenT: copy, drop, store>(): u64
-
-
-
-
-public fun voting_delay<TokenT: copy + drop + store>(): u64 {
- get_config<TokenT>().voting_delay
-}
-
-
-
-
-public fun voting_period<TokenT: copy, drop, store>(): u64
-
-
-
-
-public fun voting_period<TokenT: copy + drop + store>(): u64 {
- get_config<TokenT>().voting_period
-}
-
-
-
-
-public fun quorum_votes<TokenT: copy, drop, store>(): u128
-
-
-
-
-public fun quorum_votes<TokenT: copy + drop + store>(): u128 {
- let market_cap = Token::market_cap<TokenT>();
- let balance_in_treasury = Treasury::balance<TokenT>();
- let supply = market_cap - balance_in_treasury;
- let rate = voting_quorum_rate<TokenT>();
- let rate = (rate as u128);
- supply * rate / 100
-}
-
-
-
-
-public fun voting_quorum_rate<TokenT: copy, drop, store>(): u8
-
-
-
-
-public fun voting_quorum_rate<TokenT: copy + drop + store>(): u8 {
- get_config<TokenT>().voting_quorum_rate
-}
-
-
-
-
-public fun min_action_delay<TokenT: copy, drop, store>(): u64
-
-
-
-
-public fun min_action_delay<TokenT: copy + drop + store>(): u64 {
- get_config<TokenT>().min_action_delay
-}
-
-
-
-
-fun get_config<TokenT: copy, drop, store>(): Dao::DaoConfig<TokenT>
-
-
-
-
-fun get_config<TokenT: copy + drop + store>(): DaoConfig<TokenT> {
- let token_issuer = Token::token_address<TokenT>();
- Config::get_by_address<DaoConfig<TokenT>>(token_issuer)
-}
-
-
-
-
-public fun modify_dao_config<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64)
-
-
-
-
-public fun modify_dao_config<TokenT: copy + drop + store>(
- cap: &mut Config::ModifyConfigCapability<DaoConfig<TokenT>>,
- voting_delay: u64,
- voting_period: u64,
- voting_quorum_rate: u8,
- min_action_delay: u64,
-) {
- assert!(Config::account_address(cap) == Token::token_address<TokenT>(), Errors::invalid_argument(ERR_NOT_AUTHORIZED));
- let config = get_config<TokenT>();
- if (voting_period > 0) {
- config.voting_period = voting_period;
- };
- if (voting_delay > 0) {
- config.voting_delay = voting_delay;
- };
- if (voting_quorum_rate > 0) {
- assert!(voting_quorum_rate <= 100, Errors::invalid_argument(ERR_QUORUM_RATE_INVALID));
- config.voting_quorum_rate = voting_quorum_rate;
- };
- if (min_action_delay > 0) {
- config.min_action_delay = min_action_delay;
- };
- Config::set_with_capability<DaoConfig<TokenT>>(cap, config);
-}
-
-
-
-
-public fun set_voting_delay<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
-
-
-
-
-public fun set_voting_delay<TokenT: copy + drop + store>(
- cap: &mut Config::ModifyConfigCapability<DaoConfig<TokenT>>,
- value: u64,
-) {
- assert!(Config::account_address(cap) == Token::token_address<TokenT>(), Errors::invalid_argument(ERR_NOT_AUTHORIZED));
- assert!(value > 0, Errors::invalid_argument(ERR_CONFIG_PARAM_INVALID));
- let config = get_config<TokenT>();
- config.voting_delay = value;
- Config::set_with_capability<DaoConfig<TokenT>>(cap, config);
-}
-
-
-
-
-public fun set_voting_period<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
-
-
-
-
-public fun set_voting_period<TokenT: copy + drop + store>(
- cap: &mut Config::ModifyConfigCapability<DaoConfig<TokenT>>,
- value: u64,
-) {
- assert!(Config::account_address(cap) == Token::token_address<TokenT>(), Errors::invalid_argument(ERR_NOT_AUTHORIZED));
- assert!(value > 0, Errors::invalid_argument(ERR_CONFIG_PARAM_INVALID));
- let config = get_config<TokenT>();
- config.voting_period = value;
- Config::set_with_capability<DaoConfig<TokenT>>(cap, config);
-}
-
-
-
-
-public fun set_voting_quorum_rate<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u8)
-
-
-
-
-public fun set_voting_quorum_rate<TokenT: copy + drop + store>(
- cap: &mut Config::ModifyConfigCapability<DaoConfig<TokenT>>,
- value: u8,
-) {
- assert!(Config::account_address(cap) == Token::token_address<TokenT>(), Errors::invalid_argument(ERR_NOT_AUTHORIZED));
- assert!(value <= 100 && value > 0, Errors::invalid_argument(ERR_QUORUM_RATE_INVALID));
- let config = get_config<TokenT>();
- config.voting_quorum_rate = value;
- Config::set_with_capability<DaoConfig<TokenT>>(cap, config);
-}
-
-
-
-
-public fun set_min_action_delay<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
-
-
-
-
-public fun set_min_action_delay<TokenT: copy + drop + store>(
- cap: &mut Config::ModifyConfigCapability<DaoConfig<TokenT>>,
- value: u64,
-) {
- assert!(Config::account_address(cap) == Token::token_address<TokenT>(), Errors::invalid_argument(ERR_NOT_AUTHORIZED));
- assert!(value > 0, Errors::invalid_argument(ERR_CONFIG_PARAM_INVALID));
- let config = get_config<TokenT>();
- config.min_action_delay = value;
- Config::set_with_capability<DaoConfig<TokenT>>(cap, config);
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_partial = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Struct `DaoConfig`
-
-
-struct DaoConfig<TokenT: copy, drop, store> has copy, drop, store
-
-
-
-
-voting_delay: u64
-voting_period: u64
-voting_quorum_rate: u8
-min_action_delay: u64
-invariant voting_quorum_rate > 0 && voting_quorum_rate <= 100;
-invariant voting_delay > 0;
-invariant voting_period > 0;
-invariant min_action_delay > 0;
-
-
-
-
-
-
-### Function `plugin`
-
-
-public fun plugin<TokenT: copy, drop, store>(signer: &signer, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64)
-
-
-
-
-
-aborts_if voting_delay == 0;
-aborts_if voting_period == 0;
-aborts_if voting_quorum_rate == 0 || voting_quorum_rate > 100;
-aborts_if min_action_delay == 0;
-let sender = Signer::address_of(signer);
-aborts_if sender != Token::SPEC_TOKEN_TEST_ADDRESS();
-aborts_if exists<DaoGlobalInfo<TokenT>>(sender);
-aborts_if exists<Config::Config<DaoConfig<TokenT>>>(sender);
-aborts_if exists<Config::ModifyConfigCapabilityHolder<DaoConfig<TokenT>>>(sender);
-
-
-
-
-
-
-
-
-schema RequirePluginDao<TokenT> {
- let token_addr = Token::SPEC_TOKEN_TEST_ADDRESS();
- aborts_if !exists<DaoGlobalInfo<TokenT>>(token_addr);
- aborts_if !exists<Config::Config<DaoConfig<TokenT>>>(token_addr);
-}
-
-
-
-
-
-
-
-
-schema AbortIfDaoInfoNotExist<TokenT> {
- let token_addr = Token::SPEC_TOKEN_TEST_ADDRESS();
- aborts_if !exists<DaoGlobalInfo<TokenT>>(token_addr);
-}
-
-
-
-
-
-
-
-
-schema AbortIfDaoConfigNotExist<TokenT> {
- let token_addr = Token::SPEC_TOKEN_TEST_ADDRESS();
- aborts_if !exists<Config::Config<DaoConfig<TokenT>>>(token_addr);
-}
-
-
-
-
-
-
-
-
-schema AbortIfTimestampNotExist {
- aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-}
-
-
-
-
-
-apply
- AbortIfDaoInfoNotExist<TokenT>
-to
- generate_next_proposal_id<TokenT>;
-apply
- AbortIfDaoConfigNotExist<TokenT>
-to
- get_config<TokenT>,
- voting_delay<TokenT>,
- voting_period<TokenT>,
- voting_quorum_rate<TokenT>,
- min_action_delay<TokenT>,
- quorum_votes<TokenT>;
-
-
-
-
-
-
-### Function `new_dao_config`
-
-
-public fun new_dao_config<TokenT: copy, drop, store>(voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64): Dao::DaoConfig<TokenT>
-
-
-
-
-
-aborts_if voting_delay == 0;
-aborts_if voting_period == 0;
-aborts_if voting_quorum_rate == 0 || voting_quorum_rate > 100;
-aborts_if min_action_delay == 0;
-
-
-
-
-
-
-### Function `propose`
-
-
-public fun propose<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, action: ActionT, action_delay: u64)
-
-
-
-
-
-pragma addition_overflow_unchecked;
-include AbortIfDaoConfigNotExist<TokenT>;
-include AbortIfDaoInfoNotExist<TokenT>;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if action_delay > 0 && action_delay < spec_dao_config<TokenT>().min_action_delay;
-include CheckQuorumVotes<TokenT>;
-let sender = Signer::address_of(signer);
-aborts_if exists<Proposal<TokenT, ActionT>>(sender);
-modifies global<DaoGlobalInfo<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-ensures exists<Proposal<TokenT, ActionT>>(sender);
-
-
-
-
-
-
-### Function `cast_vote`
-
-
-public fun cast_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64, stake: Token::Token<TokenT>, agree: bool)
-
-
-
-
-
-pragma addition_overflow_unchecked = true;
-include AbortIfDaoInfoNotExist<TokenT>;
-let expected_states = vec(ACTIVE);
-include CheckProposalStates<TokenT, ActionT> {expected_states};
-let sender = Signer::address_of(signer);
-let vote_exists = exists<Vote<TokenT>>(sender);
-include vote_exists ==> CheckVoteOnCast<TokenT, ActionT> {
- voter: sender,
- proposal_id: proposal_id,
- agree: agree,
- stake_value: stake.value,
-};
-modifies global<Proposal<TokenT, ActionT>>(proposer_address);
-ensures !vote_exists ==> global<Vote<TokenT>>(sender).stake.value == stake.value;
-
-
-
-
-
-
-### Function `do_cast_vote`
-
-
-fun do_cast_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposal: &mut Dao::Proposal<TokenT, ActionT>, vote: &mut Dao::Vote<TokenT>, stake: Token::Token<TokenT>)
-
-
-
-
-
-pragma addition_overflow_unchecked = true;
-aborts_if vote.stake.value + stake.value > MAX_U128;
-ensures vote.stake.value == old(vote).stake.value + stake.value;
-ensures vote.agree ==> old(proposal).for_votes + stake.value == proposal.for_votes;
-ensures vote.agree ==> old(proposal).against_votes == proposal.against_votes;
-ensures !vote.agree ==> old(proposal).against_votes + stake.value == proposal.against_votes;
-ensures !vote.agree ==> old(proposal).for_votes == proposal.for_votes;
-
-
-
-
-
-
-### Function `change_vote`
-
-
-public fun change_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64, agree: bool)
-
-
-
-
-
-let expected_states = vec(ACTIVE);
-include CheckProposalStates<TokenT, ActionT>{expected_states};
-let sender = Signer::address_of(signer);
-aborts_if !exists<Vote<TokenT>>(sender);
-let vote = global<Vote<TokenT>>(sender);
-include CheckVoteOnProposal<TokenT>{vote, proposer_address, proposal_id};
-include vote.agree != agree ==> CheckChangeVote<TokenT, ActionT>{vote, proposer_address};
-ensures vote.agree != agree ==> vote.agree == agree;
-
-
-
-
-
-
-### Function `do_flip_vote`
-
-
-fun do_flip_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(my_vote: &mut Dao::Vote<TokenT>, proposal: &mut Dao::Proposal<TokenT, ActionT>): u128
-
-
-
-
-
-include CheckFlipVote<TokenT, ActionT>;
-ensures my_vote.agree == !old(my_vote).agree;
-
-
-
-
-
-
-### Function `revoke_vote`
-
-
-public fun revoke_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64, voting_power: u128): Token::Token<TokenT>
-
-
-
-
-
-include AbortIfDaoInfoNotExist<TokenT>;
-let expected_states = vec(ACTIVE);
-include CheckProposalStates<TokenT, ActionT> {expected_states};
-let sender = Signer::address_of(signer);
-aborts_if !exists<Vote<TokenT>>(sender);
-let vote = global<Vote<TokenT>>(sender);
-include CheckVoteOnProposal<TokenT> {vote, proposer_address, proposal_id};
-include CheckRevokeVote<TokenT, ActionT> {
- vote,
- proposal: global<Proposal<TokenT, ActionT>>(proposer_address),
- to_revoke: voting_power,
-};
-modifies global<Vote<TokenT>>(sender);
-modifies global<Proposal<TokenT, ActionT>>(proposer_address);
-modifies global<DaoGlobalInfo<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-ensures global<Vote<TokenT>>(sender).stake.value + result.value == old(global<Vote<TokenT>>(sender)).stake.value;
-ensures result.value == voting_power;
-
-
-
-
-
-
-### Function `do_revoke_vote`
-
-
-fun do_revoke_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposal: &mut Dao::Proposal<TokenT, ActionT>, vote: &mut Dao::Vote<TokenT>, to_revoke: u128): Token::Token<TokenT>
-
-
-
-
-
-include CheckRevokeVote<TokenT, ActionT>;
-ensures vote.agree ==> old(proposal).for_votes == proposal.for_votes + to_revoke;
-ensures !vote.agree ==> old(proposal).against_votes == proposal.against_votes + to_revoke;
-ensures result.value == to_revoke;
-
-
-
-
-
-
-### Function `unstake_votes`
-
-
-public fun unstake_votes<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64): Token::Token<TokenT>
-
-
-
-
-
-let expected_states = vec(DEFEATED);
-let expected_states1 = concat(expected_states,vec(AGREED));
-let expected_states2 = concat(expected_states1,vec(QUEUED));
-let expected_states3 = concat(expected_states2,vec(EXECUTABLE));
-let expected_states4 = concat(expected_states3,vec(EXTRACTED));
-aborts_if expected_states4[0] != DEFEATED;
-aborts_if expected_states4[1] != AGREED;
-aborts_if expected_states4[2] != QUEUED;
-aborts_if expected_states4[3] != EXECUTABLE;
-aborts_if expected_states4[4] != EXTRACTED;
-include spec_proposal_exists<TokenT, ActionT>(proposer_address, proposal_id) ==>
- CheckProposalStates<TokenT, ActionT>{expected_states: expected_states4};
-let sender = Signer::address_of(signer);
-aborts_if !exists<Vote<TokenT>>(sender);
-let vote = global<Vote<TokenT>>(sender);
-include CheckVoteOnProposal<TokenT>{vote, proposer_address, proposal_id};
-ensures !exists<Vote<TokenT>>(sender);
-ensures result.value == old(vote).stake.value;
-
-
-
-
-
-
-### Function `queue_proposal_action`
-
-
-public(script) fun queue_proposal_action<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-
-let expected_states = vec(AGREED);
-include CheckProposalStates<TokenT, ActionT>{expected_states};
-let proposal = global<Proposal<TokenT, ActionT>>(proposer_address);
-aborts_if Timestamp::spec_now_millseconds() + proposal.action_delay > MAX_U64;
-ensures proposal.eta >= Timestamp::spec_now_millseconds();
-
-
-
-
-
-
-### Function `extract_proposal_action`
-
-
-public fun extract_proposal_action<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64): ActionT
-
-
-
-
-
-pragma aborts_if_is_partial = false;
-let expected_states = vec(EXECUTABLE);
-include CheckProposalStates<TokenT, ActionT>{expected_states};
-modifies global<Proposal<TokenT, ActionT>>(proposer_address);
-ensures Option::is_none(global<Proposal<TokenT, ActionT>>(proposer_address).action);
-
-
-
-
-
-
-### Function `destroy_terminated_proposal`
-
-
-public(script) fun destroy_terminated_proposal<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-
-let expected_states = concat(vec(DEFEATED), vec(EXTRACTED));
-aborts_if len(expected_states) != 2;
-aborts_if expected_states[0] != DEFEATED;
-aborts_if expected_states[1] != EXTRACTED;
-aborts_if !exists<Proposal<TokenT, ActionT>>(proposer_address);
-let proposal = global<Proposal<TokenT, ActionT>>(proposer_address);
-aborts_if proposal.id != proposal_id;
-include AbortIfTimestampNotExist;
-let current_time = Timestamp::spec_now_millseconds();
-let state = do_proposal_state(proposal, current_time);
-aborts_if (forall s in expected_states : s != state);
-aborts_if state == DEFEATED && Option::is_none(global<Proposal<TokenT, ActionT>>(proposer_address).action);
-aborts_if state == EXTRACTED && Option::is_some(global<Proposal<TokenT, ActionT>>(proposer_address).action);
-modifies global<Proposal<TokenT, ActionT>>(proposer_address);
-
-
-
-
-
-
-### Function `proposal_exists`
-
-
-public fun proposal_exists<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64): bool
-
-
-
-
-
-ensures exists<Proposal<TokenT, ActionT>>(proposer_address) &&
- borrow_global<Proposal<TokenT, ActionT>>(proposer_address).id == proposal_id ==>
- result;
-
-
-
-
-
-
-
-
-fun spec_proposal_exists<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- proposer_address: address,
- proposal_id: u64,
-): bool {
- if (exists<Proposal<TokenT, ActionT>>(proposer_address)) {
- let proposal = global<Proposal<TokenT, ActionT>>(proposer_address);
- proposal.id == proposal_id
- } else {
- false
- }
-}
-
-
-
-
-
-
-### Function `proposal_state`
-
-
-public fun proposal_state<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64): u8
-
-
-
-
-
-include AbortIfTimestampNotExist;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if !exists<Proposal<TokenT, ActionT>>(proposer_address);
-let proposal = global<Proposal<TokenT, ActionT>>(proposer_address);
-aborts_if proposal.id != proposal_id;
-
-
-
-
-
-
-### Function `proposal_info`
-
-
-public fun proposal_info<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address): (u64, u64, u64, u128, u128)
-
-
-
-
-
-aborts_if !exists<Proposal<TokenT, ActionT>>(proposer_address);
-
-
-
-
-
-
-### Function `vote_of`
-
-
-public fun vote_of<TokenT: copy, drop, store>(voter: address, proposer_address: address, proposal_id: u64): (bool, u128)
-
-
-
-
-
-aborts_if !exists<Vote<TokenT>>(voter);
-let vote = global<Vote<TokenT>>(voter);
-include CheckVoteOnProposal<TokenT>{vote, proposer_address, proposal_id};
-
-
-
-
-
-
-### Function `generate_next_proposal_id`
-
-
-fun generate_next_proposal_id<TokenT: store>(): u64
-
-
-
-
-
-pragma addition_overflow_unchecked;
-modifies global<DaoGlobalInfo<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-ensures
- global<DaoGlobalInfo<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS()).next_proposal_id ==
- old(global<DaoGlobalInfo<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS()).next_proposal_id) + 1;
-ensures result == old(global<DaoGlobalInfo<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS()).next_proposal_id);
-
-
-
-
-
-
-### Function `voting_delay`
-
-
-public fun voting_delay<TokenT: copy, drop, store>(): u64
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `voting_period`
-
-
-public fun voting_period<TokenT: copy, drop, store>(): u64
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `quorum_votes`
-
-
-public fun quorum_votes<TokenT: copy, drop, store>(): u128
-
-
-
-
-
-include CheckQuorumVotes<TokenT>;
-
-
-
-
-
-
-
-
-fun spec_quorum_votes<TokenT: copy + drop + store>(): u128 {
- let supply = Token::spec_abstract_total_value<TokenT>() - Treasury::spec_balance<TokenT>();
- supply * spec_dao_config<TokenT>().voting_quorum_rate / 100
-}
-
-
-
-
-
-
-### Function `voting_quorum_rate`
-
-
-public fun voting_quorum_rate<TokenT: copy, drop, store>(): u8
-
-
-
-
-
-aborts_if false;
-ensures result == global<Config::Config<DaoConfig<TokenT>>>((Token::SPEC_TOKEN_TEST_ADDRESS())).payload.voting_quorum_rate;
-
-
-
-
-
-
-### Function `min_action_delay`
-
-
-public fun min_action_delay<TokenT: copy, drop, store>(): u64
-
-
-
-
-
-aborts_if false;
-ensures result == spec_dao_config<TokenT>().min_action_delay;
-
-
-
-
-
-
-### Function `get_config`
-
-
-fun get_config<TokenT: copy, drop, store>(): Dao::DaoConfig<TokenT>
-
-
-
-
-
-aborts_if false;
-ensures result == global<Config::Config<DaoConfig<TokenT>>>((Token::SPEC_TOKEN_TEST_ADDRESS())).payload;
-
-
-
-
-
-
-
-
-fun spec_dao_config<TokenT: copy + drop + store>(): DaoConfig<TokenT> {
- global<Config::Config<DaoConfig<TokenT>>>((Token::SPEC_TOKEN_TEST_ADDRESS())).payload
-}
-
-
-
-
-
-
-
-
-schema CheckModifyConfigWithCap<TokenT> {
- cap: Config::ModifyConfigCapability<DaoConfig<TokenT>>;
- aborts_if cap.account_address != Token::SPEC_TOKEN_TEST_ADDRESS();
- aborts_if !exists<Config::Config<DaoConfig<TokenT>>>(cap.account_address);
-}
-
-
-
-
-
-
-### Function `modify_dao_config`
-
-
-public fun modify_dao_config<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64)
-
-
-
-
-
-include CheckModifyConfigWithCap<TokenT>;
-aborts_if voting_quorum_rate > 0 && voting_quorum_rate > 100;
-
-
-
-
-
-
-### Function `set_voting_delay`
-
-
-public fun set_voting_delay<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
-
-
-
-
-
-include CheckModifyConfigWithCap<TokenT>;
-aborts_if value == 0;
-
-
-
-
-
-
-### Function `set_voting_period`
-
-
-public fun set_voting_period<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
-
-
-
-
-
-include CheckModifyConfigWithCap<TokenT>;
-aborts_if value == 0;
-
-
-
-
-
-
-### Function `set_voting_quorum_rate`
-
-
-public fun set_voting_quorum_rate<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u8)
-
-
-
-
-
-aborts_if !(value > 0 && value <= 100);
-include CheckModifyConfigWithCap<TokenT>;
-
-
-
-
-
-
-### Function `set_min_action_delay`
-
-
-public fun set_min_action_delay<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
-
-
-
-
-
-aborts_if value == 0;
-include CheckModifyConfigWithCap<TokenT>;
-
diff --git a/vm/stdlib/compiled/latest/doc/DaoVoteScripts.md b/vm/stdlib/compiled/latest/doc/DaoVoteScripts.md
deleted file mode 100644
index a7aba4818b..0000000000
--- a/vm/stdlib/compiled/latest/doc/DaoVoteScripts.md
+++ /dev/null
@@ -1,197 +0,0 @@
-
-
-
-# Module `0x1::DaoVoteScripts`
-
-
-
-- [Function `cast_vote`](#0x1_DaoVoteScripts_cast_vote)
-- [Function `revoke_vote`](#0x1_DaoVoteScripts_revoke_vote)
-- [Function `flip_vote`](#0x1_DaoVoteScripts_flip_vote)
-- [Function `revoke_vote_of_power`](#0x1_DaoVoteScripts_revoke_vote_of_power)
-- [Function `unstake_vote`](#0x1_DaoVoteScripts_unstake_vote)
-- [Specification](#@Specification_0)
-
-
-use 0x1::Account;
-use 0x1::Dao;
-use 0x1::Signer;
-use 0x1::Token;
-
-
-
-
-
-
-## Function `cast_vote`
-
-
-
-public(script) fun cast_vote<Token: copy, drop, store, ActionT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64, agree: bool, votes: u128)
-
-
-
-
-public ( script ) fun cast_vote<Token: copy + drop + store, ActionT: copy + drop + store>(
- signer: signer,
- proposer_address: address,
- proposal_id: u64,
- agree: bool,
- votes: u128,
-) {
- let sender = Signer::address_of(&signer);
- if (Dao::has_vote<Token>(sender, proposer_address, proposal_id)) {
- // if already voted, and vote is not same as the current cast, change the existing vote.
- // resolve https://github.com/starcoinorg/starcoin/issues/2925.
- let (agree_voted, _) = Dao::vote_of<Token>(sender, proposer_address, proposal_id);
- if (agree_voted != agree) {
- Dao::change_vote<Token, ActionT>(&signer, proposer_address, proposal_id, agree);
- }
- };
-
- let votes = Account::withdraw<Token>(&signer, votes);
- Dao::cast_vote<Token, ActionT>(&signer, proposer_address, proposal_id, votes, agree);
-}
-
-
-
-
-public(script) fun revoke_vote<Token: copy, drop, store, Action: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
-
-
-
-
-public ( script ) fun revoke_vote<Token: copy + drop + store, Action: copy + drop + store>(
- signer: signer,
- proposer_address: address,
- proposal_id: u64,
-) {
- let sender = Signer::address_of(&signer);
- let (_, power) = Dao::vote_of<Token>(sender, proposer_address, proposal_id);
- let my_token = Dao::revoke_vote<Token, Action>(&signer, proposer_address, proposal_id, power);
- Account::deposit(sender, my_token);
-}
-
-
-
-
-public(script) fun flip_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
-
-
-
-
-public(script) fun flip_vote<TokenT: copy + drop + store, ActionT: copy + drop + store>(
- signer: signer,
- proposer_address: address,
- proposal_id: u64,
-) {
- let (agree, _) = Dao::vote_of<TokenT>(Signer::address_of(&signer), proposer_address, proposal_id);
- Dao::change_vote<TokenT, ActionT>(&signer, proposer_address, proposal_id, !agree);
-}
-
-
-
-
-public(script) fun revoke_vote_of_power<Token: copy, drop, store, Action: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64, power: u128)
-
-
-
-
-public ( script ) fun revoke_vote_of_power<Token: copy + drop + store, Action: copy + drop + store>(
- signer: signer,
- proposer_address: address,
- proposal_id: u64,
- power: u128,
-) {
- let sender = Signer::address_of(&signer);
- let my_token = Dao::revoke_vote<Token, Action>(&signer, proposer_address, proposal_id, power);
- Account::deposit(sender, my_token);
-}
-
-
-
-
-public(script) fun unstake_vote<Token: copy, drop, store, Action: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
-
-
-
-
-public ( script ) fun unstake_vote<Token: copy + drop + store, Action: copy + drop + store>(
- signer: signer,
- proposer_address: address,
- proposal_id: u64,
-) {
- let my_token = Dao::unstake_votes<Token, Action>(&signer, proposer_address, proposal_id);
- Account::deposit(Signer::address_of(&signer), my_token);
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_partial = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/vm/stdlib/compiled/latest/doc/Debug.md b/vm/stdlib/compiled/latest/doc/Debug.md
deleted file mode 100644
index d2b11d674b..0000000000
--- a/vm/stdlib/compiled/latest/doc/Debug.md
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-# Module `0x1::Debug`
-
-The module provide debug print for Move.
-
-
-- [Function `print`](#0x1_Debug_print)
-- [Function `print_stack_trace`](#0x1_Debug_print_stack_trace)
-- [Specification](#@Specification_0)
-
-
-
-
-
-
-
-
-## Function `print`
-
-Print data of Type T
.
-
-
-public fun print<T: store>(x: &T)
-
-
-
-
-native public fun print<T: store>(x: &T);
-
-
-
-
-public fun print_stack_trace()
-
-
-
-
-native public fun print_stack_trace();
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/vm/stdlib/compiled/latest/doc/DummyToken.md b/vm/stdlib/compiled/latest/doc/DummyToken.md
deleted file mode 100644
index 3582759c78..0000000000
--- a/vm/stdlib/compiled/latest/doc/DummyToken.md
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-# Module `0x1::DummyTokenScripts`
-
-
-
-- [Function `mint`](#0x1_DummyTokenScripts_mint)
-
-
-use 0x1::Account;
-use 0x1::DummyToken;
-use 0x1::Signer;
-use 0x1::Token;
-
-
-
-
-
-
-## Function `mint`
-
-
-
-public(script) fun mint(sender: signer, amount: u128)
-
-
-
-
-public(script) fun mint(sender: signer, amount: u128){
- let token = DummyToken::mint(&sender, amount);
- let sender_addr = Signer::address_of(&sender);
- if(Account::is_accept_token<DummyToken>(sender_addr)){
- Account::do_accept_token<DummyToken>(&sender);
- };
- Account::deposit(sender_addr, token);
-}
-
-
-
-
-
-
-
-
-
-
-## Function `empty_script`
-
-
-
-public(script) fun empty_script()
-
-
-
-
-public(script) fun empty_script() {
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_partial = false;
-pragma aborts_if_is_strict = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/Epoch.md b/vm/stdlib/compiled/latest/doc/Epoch.md
deleted file mode 100644
index c223161353..0000000000
--- a/vm/stdlib/compiled/latest/doc/Epoch.md
+++ /dev/null
@@ -1,1121 +0,0 @@
-
-
-
-# Module `0x1::Epoch`
-
-The module provide epoch functionality for starcoin.
-
-
-- [Resource `Epoch`](#0x1_Epoch_Epoch)
-- [Struct `NewEpochEvent`](#0x1_Epoch_NewEpochEvent)
-- [Resource `EpochData`](#0x1_Epoch_EpochData)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_Epoch_initialize)
-- [Function `compute_next_block_time_target`](#0x1_Epoch_compute_next_block_time_target)
-- [Function `adjust_epoch`](#0x1_Epoch_adjust_epoch)
-- [Function `adjust_gas_limit`](#0x1_Epoch_adjust_gas_limit)
-- [Function `compute_gas_limit`](#0x1_Epoch_compute_gas_limit)
-- [Function `in_or_decrease_gas_limit`](#0x1_Epoch_in_or_decrease_gas_limit)
-- [Function `update_epoch_data`](#0x1_Epoch_update_epoch_data)
-- [Function `emit_epoch_event`](#0x1_Epoch_emit_epoch_event)
-- [Function `start_time`](#0x1_Epoch_start_time)
-- [Function `uncles`](#0x1_Epoch_uncles)
-- [Function `total_gas`](#0x1_Epoch_total_gas)
-- [Function `block_gas_limit`](#0x1_Epoch_block_gas_limit)
-- [Function `start_block_number`](#0x1_Epoch_start_block_number)
-- [Function `end_block_number`](#0x1_Epoch_end_block_number)
-- [Function `number`](#0x1_Epoch_number)
-- [Function `block_time_target`](#0x1_Epoch_block_time_target)
-- [Specification](#@Specification_1)
- - [Function `initialize`](#@Specification_1_initialize)
- - [Function `compute_next_block_time_target`](#@Specification_1_compute_next_block_time_target)
- - [Function `adjust_epoch`](#@Specification_1_adjust_epoch)
- - [Function `adjust_gas_limit`](#@Specification_1_adjust_gas_limit)
- - [Function `compute_gas_limit`](#@Specification_1_compute_gas_limit)
- - [Function `in_or_decrease_gas_limit`](#@Specification_1_in_or_decrease_gas_limit)
- - [Function `update_epoch_data`](#@Specification_1_update_epoch_data)
- - [Function `emit_epoch_event`](#@Specification_1_emit_epoch_event)
- - [Function `start_time`](#@Specification_1_start_time)
- - [Function `uncles`](#@Specification_1_uncles)
- - [Function `total_gas`](#@Specification_1_total_gas)
- - [Function `block_gas_limit`](#@Specification_1_block_gas_limit)
- - [Function `start_block_number`](#@Specification_1_start_block_number)
- - [Function `end_block_number`](#@Specification_1_end_block_number)
- - [Function `number`](#@Specification_1_number)
- - [Function `block_time_target`](#@Specification_1_block_time_target)
-
-
-use 0x1::ConsensusConfig;
-use 0x1::CoreAddresses;
-use 0x1::Errors;
-use 0x1::Event;
-use 0x1::Math;
-use 0x1::Option;
-use 0x1::Timestamp;
-
-
-
-
-
-
-## Resource `Epoch`
-
-Current epoch info.
-
-
-struct Epoch has key
-
-
-
-
-number: u64
-start_time: u64
-start_block_number: u64
-end_block_number: u64
-block_time_target: u64
-reward_per_block: u128
-reward_per_uncle_percent: u64
-reward_per_block
to reward a uncle block in current epoch
-block_difficulty_window: u64
-max_uncles_per_block: u64
-block_gas_limit: u64
-strategy: u8
-new_epoch_events: Event::EventHandle<Epoch::NewEpochEvent>
-struct NewEpochEvent has drop, store
-
-
-
-
-number: u64
-start_time: u64
-start_block_number: u64
-end_block_number: u64
-block_time_target: u64
-reward_per_block: u128
-previous_epoch_total_reward: u128
-struct EpochData has key
-
-
-
-
-uncles: u64
-total_reward: u128
-total_gas: u128
-const EINVALID_UNCLES_COUNT: u64 = 101;
-
-
-
-
-
-
-
-
-const EUNREACHABLE: u64 = 19;
-
-
-
-
-
-
-
-
-const HUNDRED: u64 = 100;
-
-
-
-
-
-
-
-
-const THOUSAND: u64 = 1000;
-
-
-
-
-
-
-
-
-const THOUSAND_U128: u128 = 1000;
-
-
-
-
-
-
-## Function `initialize`
-
-Initialization of the module.
-
-
-public fun initialize(account: &signer)
-
-
-
-
-public fun initialize(
- account: &signer,
-) {
- Timestamp::assert_genesis();
- CoreAddresses::assert_genesis_address(account);
-
- let config = ConsensusConfig::get_config();
- move_to<Epoch>(
- account,
- Epoch {
- number: 0,
- start_time: Timestamp::now_milliseconds(),
- start_block_number: 0,
- end_block_number: ConsensusConfig::epoch_block_count(&config),
- block_time_target: ConsensusConfig::base_block_time_target(&config),
- reward_per_block: ConsensusConfig::base_reward_per_block(&config),
- reward_per_uncle_percent: ConsensusConfig::base_reward_per_uncle_percent(&config),
- block_difficulty_window: ConsensusConfig::base_block_difficulty_window(&config),
- max_uncles_per_block: ConsensusConfig::base_max_uncles_per_block(&config),
- block_gas_limit: ConsensusConfig::base_block_gas_limit(&config),
- strategy: ConsensusConfig::strategy(&config),
- new_epoch_events: Event::new_event_handle<NewEpochEvent>(account),
- },
- );
- move_to<EpochData>(account, EpochData { uncles: 0, total_reward: 0, total_gas: 0 });
-}
-
-
-
-
-public fun compute_next_block_time_target(config: &ConsensusConfig::ConsensusConfig, last_epoch_time_target: u64, epoch_start_time: u64, now_milli_second: u64, start_block_number: u64, end_block_number: u64, total_uncles: u64): u64
-
-
-
-
-public fun compute_next_block_time_target(config: &ConsensusConfig, last_epoch_time_target: u64, epoch_start_time: u64, now_milli_second: u64, start_block_number: u64, end_block_number: u64, total_uncles: u64): u64 {
- let total_time = now_milli_second - epoch_start_time;
- let blocks = end_block_number - start_block_number;
- let avg_block_time = total_time / blocks;
- let uncles_rate = total_uncles * THOUSAND / blocks;
- let new_epoch_block_time_target = (THOUSAND + uncles_rate) * avg_block_time /
- (ConsensusConfig::uncle_rate_target(config) + THOUSAND);
- if (new_epoch_block_time_target > last_epoch_time_target * 2) {
- new_epoch_block_time_target = last_epoch_time_target * 2;
- };
- if (new_epoch_block_time_target < last_epoch_time_target / 2) {
- new_epoch_block_time_target = last_epoch_time_target / 2;
- };
- let min_block_time_target = ConsensusConfig::min_block_time_target(config);
- let max_block_time_target = ConsensusConfig::max_block_time_target(config);
- if (new_epoch_block_time_target < min_block_time_target) {
- new_epoch_block_time_target = min_block_time_target;
- };
- if (new_epoch_block_time_target > max_block_time_target) {
- new_epoch_block_time_target = max_block_time_target;
- };
- new_epoch_block_time_target
-}
-
-
-
-
-public fun adjust_epoch(account: &signer, block_number: u64, timestamp: u64, uncles: u64, parent_gas_used: u64): u128
-
-
-
-
-public fun adjust_epoch(account: &signer, block_number: u64, timestamp: u64, uncles: u64, parent_gas_used:u64): u128
-acquires Epoch, EpochData {
- CoreAddresses::assert_genesis_address(account);
-
- let epoch_ref = borrow_global_mut<Epoch>(CoreAddresses::GENESIS_ADDRESS());
- assert!(epoch_ref.max_uncles_per_block >= uncles, Errors::invalid_argument(EINVALID_UNCLES_COUNT));
-
- let epoch_data = borrow_global_mut<EpochData>(CoreAddresses::GENESIS_ADDRESS());
- let (new_epoch, reward_per_block) = if (block_number < epoch_ref.end_block_number) {
- (false, epoch_ref.reward_per_block)
- } else if (block_number == epoch_ref.end_block_number) {
- //start a new epoch
- assert!(uncles == 0, Errors::invalid_argument(EINVALID_UNCLES_COUNT));
- // block time target unit is milli_seconds.
- let now_milli_seconds = timestamp;
-
- let config = ConsensusConfig::get_config();
- let last_epoch_time_target = epoch_ref.block_time_target;
- let new_epoch_block_time_target = compute_next_block_time_target(&config, last_epoch_time_target, epoch_ref.start_time, now_milli_seconds, epoch_ref.start_block_number, epoch_ref.end_block_number, epoch_data.uncles);
- let new_reward_per_block = ConsensusConfig::do_compute_reward_per_block(&config, new_epoch_block_time_target);
-
- //update epoch by adjust result or config, because ConsensusConfig may be updated.
- epoch_ref.number = epoch_ref.number + 1;
- epoch_ref.start_time = now_milli_seconds;
- epoch_ref.start_block_number = block_number;
- epoch_ref.end_block_number = block_number + ConsensusConfig::epoch_block_count(&config);
- epoch_ref.block_time_target = new_epoch_block_time_target;
- epoch_ref.reward_per_block = new_reward_per_block;
- epoch_ref.reward_per_uncle_percent = ConsensusConfig::base_reward_per_uncle_percent(&config);
- epoch_ref.block_difficulty_window = ConsensusConfig::base_block_difficulty_window(&config);
- epoch_ref.max_uncles_per_block = ConsensusConfig::base_max_uncles_per_block(&config);
- epoch_ref.strategy = ConsensusConfig::strategy(&config);
-
- epoch_data.uncles = 0;
- let last_epoch_total_gas = epoch_data.total_gas + (parent_gas_used as u128);
- adjust_gas_limit(&config, epoch_ref, last_epoch_time_target, new_epoch_block_time_target, last_epoch_total_gas);
- emit_epoch_event(epoch_ref, epoch_data.total_reward);
- (true, new_reward_per_block)
- } else {
- //This should never happened.
- abort EUNREACHABLE
- };
- let reward = reward_per_block +
- reward_per_block * (epoch_ref.reward_per_uncle_percent as u128) * (uncles as u128) / (HUNDRED as u128);
- update_epoch_data(epoch_data, new_epoch, reward, uncles, parent_gas_used);
- reward
-}
-
-
-
-
-fun adjust_gas_limit(config: &ConsensusConfig::ConsensusConfig, epoch_ref: &mut Epoch::Epoch, last_epoch_time_target: u64, new_epoch_time_target: u64, last_epoch_total_gas: u128)
-
-
-
-
-fun adjust_gas_limit(config: &ConsensusConfig, epoch_ref: &mut Epoch, last_epoch_time_target: u64, new_epoch_time_target: u64, last_epoch_total_gas:u128) {
- let new_gas_limit = compute_gas_limit(config, last_epoch_time_target, new_epoch_time_target, epoch_ref.block_gas_limit, last_epoch_total_gas);
- if (Option::is_some(&new_gas_limit)) {
- epoch_ref.block_gas_limit = Option::destroy_some(new_gas_limit);
- }
-}
-
-
-
-
-public fun compute_gas_limit(config: &ConsensusConfig::ConsensusConfig, last_epoch_time_target: u64, new_epoch_time_target: u64, last_epoch_block_gas_limit: u64, last_epoch_total_gas: u128): Option::Option<u64>
-
-
-
-
-public fun compute_gas_limit(config: &ConsensusConfig, last_epoch_time_target: u64, new_epoch_time_target: u64, last_epoch_block_gas_limit: u64, last_epoch_total_gas: u128) : Option::Option<u64> {
- let epoch_block_count = (ConsensusConfig::epoch_block_count(config) as u128);
- let gas_limit_threshold = (last_epoch_total_gas >= Math::mul_div((last_epoch_block_gas_limit as u128) * epoch_block_count, (80 as u128), (HUNDRED as u128)));
- let new_gas_limit = Option::none<u64>();
-
- let min_block_time_target = ConsensusConfig::min_block_time_target(config);
- let max_block_time_target = ConsensusConfig::max_block_time_target(config);
- let base_block_gas_limit = ConsensusConfig::base_block_gas_limit(config);
- if (last_epoch_time_target == new_epoch_time_target) {
- if (new_epoch_time_target == min_block_time_target && gas_limit_threshold) {
- let increase_gas_limit = in_or_decrease_gas_limit(last_epoch_block_gas_limit, 110, base_block_gas_limit);
- new_gas_limit = Option::some(increase_gas_limit);
- } else if (new_epoch_time_target == max_block_time_target && !gas_limit_threshold) {
- let decrease_gas_limit = in_or_decrease_gas_limit(last_epoch_block_gas_limit, 90, base_block_gas_limit);
- new_gas_limit = Option::some(decrease_gas_limit);
- }
- };
-
- new_gas_limit
-}
-
-
-
-
-fun in_or_decrease_gas_limit(last_epoch_block_gas_limit: u64, percent: u64, min_block_gas_limit: u64): u64
-
-
-
-
-fun in_or_decrease_gas_limit(last_epoch_block_gas_limit: u64, percent: u64, min_block_gas_limit: u64): u64 {
- let tmp_gas_limit = Math::mul_div((last_epoch_block_gas_limit as u128), (percent as u128), (HUNDRED as u128));
- let new_gas_limit = if (tmp_gas_limit > (min_block_gas_limit as u128)) {
- (tmp_gas_limit as u64)
- } else {
- min_block_gas_limit
- };
-
- new_gas_limit
-}
-
-
-
-
-fun update_epoch_data(epoch_data: &mut Epoch::EpochData, new_epoch: bool, reward: u128, uncles: u64, parent_gas_used: u64)
-
-
-
-
-fun update_epoch_data(epoch_data: &mut EpochData, new_epoch: bool, reward: u128, uncles: u64, parent_gas_used:u64) {
- if (new_epoch) {
- epoch_data.total_reward = reward;
- epoch_data.uncles = uncles;
- epoch_data.total_gas = 0;
- } else {
- epoch_data.total_reward = epoch_data.total_reward + reward;
- epoch_data.uncles = epoch_data.uncles + uncles;
- epoch_data.total_gas = epoch_data.total_gas + (parent_gas_used as u128);
- }
-}
-
-
-
-
-fun emit_epoch_event(epoch_ref: &mut Epoch::Epoch, previous_epoch_total_reward: u128)
-
-
-
-
-fun emit_epoch_event(epoch_ref: &mut Epoch, previous_epoch_total_reward: u128) {
- Event::emit_event(
- &mut epoch_ref.new_epoch_events,
- NewEpochEvent {
- number: epoch_ref.number,
- start_time: epoch_ref.start_time,
- start_block_number: epoch_ref.start_block_number,
- end_block_number: epoch_ref.end_block_number,
- block_time_target: epoch_ref.block_time_target,
- reward_per_block: epoch_ref.reward_per_block,
- previous_epoch_total_reward,
- },
- );
-}
-
-
-
-
-public fun start_time(): u64
-
-
-
-
-public fun start_time(): u64 acquires Epoch {
- let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
- epoch_ref.start_time
-}
-
-
-
-
-public fun uncles(): u64
-
-
-
-
-public fun uncles(): u64 acquires EpochData {
- let epoch_data = borrow_global<EpochData>(CoreAddresses::GENESIS_ADDRESS());
- epoch_data.uncles
-}
-
-
-
-
-public fun total_gas(): u128
-
-
-
-
-public fun total_gas(): u128 acquires EpochData {
- let epoch_data = borrow_global<EpochData>(CoreAddresses::GENESIS_ADDRESS());
- epoch_data.total_gas
-}
-
-
-
-
-public fun block_gas_limit(): u64
-
-
-
-
-public fun block_gas_limit(): u64 acquires Epoch {
- let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
- epoch_ref.block_gas_limit
-}
-
-
-
-
-public fun start_block_number(): u64
-
-
-
-
-public fun start_block_number(): u64 acquires Epoch {
- let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
- epoch_ref.start_block_number
-}
-
-
-
-
-public fun end_block_number(): u64
-
-
-
-
-public fun end_block_number(): u64 acquires Epoch {
- let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
- epoch_ref.end_block_number
-}
-
-
-
-
-public fun number(): u64
-
-
-
-
-public fun number(): u64 acquires Epoch {
- let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
- epoch_ref.number
-}
-
-
-
-
-public fun block_time_target(): u64
-
-
-
-
-public fun block_time_target(): u64 acquires Epoch {
- let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
- epoch_ref.block_time_target
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer)
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if !exists<Config::Config<ConsensusConfig>>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if exists<Epoch>(Signer::address_of(account));
-aborts_if exists<EpochData>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `compute_next_block_time_target`
-
-
-public fun compute_next_block_time_target(config: &ConsensusConfig::ConsensusConfig, last_epoch_time_target: u64, epoch_start_time: u64, now_milli_second: u64, start_block_number: u64, end_block_number: u64, total_uncles: u64): u64
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `adjust_epoch`
-
-
-public fun adjust_epoch(account: &signer, block_number: u64, timestamp: u64, uncles: u64, parent_gas_used: u64): u128
-
-
-
-
-
-pragma verify = false;
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if !exists<Epoch>(Signer::address_of(account));
-aborts_if global<Epoch>(Signer::address_of(account)).max_uncles_per_block < uncles;
-aborts_if exists<EpochData>(Signer::address_of(account));
-aborts_if block_number == global<Epoch>(Signer::address_of(account)).end_block_number && uncles != 0;
-
-
-
-
-
-
-### Function `adjust_gas_limit`
-
-
-fun adjust_gas_limit(config: &ConsensusConfig::ConsensusConfig, epoch_ref: &mut Epoch::Epoch, last_epoch_time_target: u64, new_epoch_time_target: u64, last_epoch_total_gas: u128)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `compute_gas_limit`
-
-
-public fun compute_gas_limit(config: &ConsensusConfig::ConsensusConfig, last_epoch_time_target: u64, new_epoch_time_target: u64, last_epoch_block_gas_limit: u64, last_epoch_total_gas: u128): Option::Option<u64>
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `in_or_decrease_gas_limit`
-
-
-fun in_or_decrease_gas_limit(last_epoch_block_gas_limit: u64, percent: u64, min_block_gas_limit: u64): u64
-
-
-
-
-
-include Math::MulDivAbortsIf{x: last_epoch_block_gas_limit, y: percent, z: HUNDRED};
-aborts_if Math::spec_mul_div() > MAX_U64;
-
-
-
-
-
-
-### Function `update_epoch_data`
-
-
-fun update_epoch_data(epoch_data: &mut Epoch::EpochData, new_epoch: bool, reward: u128, uncles: u64, parent_gas_used: u64)
-
-
-
-
-
-aborts_if !new_epoch && epoch_data.total_reward + reward > MAX_U128;
-aborts_if !new_epoch && epoch_data.uncles + uncles > MAX_U64;
-aborts_if !new_epoch && epoch_data.total_gas + parent_gas_used > MAX_U128;
-
-
-
-
-
-
-### Function `emit_epoch_event`
-
-
-fun emit_epoch_event(epoch_ref: &mut Epoch::Epoch, previous_epoch_total_reward: u128)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `start_time`
-
-
-public fun start_time(): u64
-
-
-
-
-
-aborts_if !exists<Epoch>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `uncles`
-
-
-public fun uncles(): u64
-
-
-
-
-
-aborts_if !exists<EpochData>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `total_gas`
-
-
-public fun total_gas(): u128
-
-
-
-
-
-aborts_if !exists<EpochData>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `block_gas_limit`
-
-
-public fun block_gas_limit(): u64
-
-
-
-
-
-aborts_if !exists<Epoch>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `start_block_number`
-
-
-public fun start_block_number(): u64
-
-
-
-
-
-aborts_if !exists<Epoch>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `end_block_number`
-
-
-public fun end_block_number(): u64
-
-
-
-
-
-aborts_if !exists<Epoch>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `number`
-
-
-public fun number(): u64
-
-
-
-
-
-aborts_if !exists<Epoch>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `block_time_target`
-
-
-public fun block_time_target(): u64
-
-
-
-
-
-aborts_if !exists<Epoch>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
diff --git a/vm/stdlib/compiled/latest/doc/Errors.md b/vm/stdlib/compiled/latest/doc/Errors.md
deleted file mode 100644
index 510ccb6439..0000000000
--- a/vm/stdlib/compiled/latest/doc/Errors.md
+++ /dev/null
@@ -1,683 +0,0 @@
-
-
-
-# Module `0x1::Errors`
-
-Module defining error codes used in Move aborts throughout the framework.
-
-A u64
error code is constructed from two values:
-
-1. The *error category* which is encoded in the lower 8 bits of the code. Error categories are
-declared in this module and are globally unique across the Diem framework. There is a limited
-fixed set of predefined categories, and the framework is guaranteed to use those consistently.
-
-2. The *error reason* which is encoded in the remaining 56 bits of the code. The reason is a unique
-number relative to the module which raised the error and can be used to obtain more information about
-the error at hand. It is mostly used for diagnosis purposes. Error reasons may change over time as the
-framework evolves.
-
-Rules to declare or use *error reason*:
-1. error reason is declared as const in the user module
-2. error reason name must start with "E", for example, const EACCOUNT_DOES_NOT_EXIST = ...
-3. value less than 100 is reserved for general purpose and shared by all modules
-4. don't change general purpose error reason value, it's co-related with error code in starcoin vm
-5. self-defined error reason value must be large than 100
-6. error reason must be used together with error category
-
-
-- [Constants](#@Constants_0)
-- [Function `make`](#0x1_Errors_make)
-- [Function `invalid_state`](#0x1_Errors_invalid_state)
-- [Function `requires_address`](#0x1_Errors_requires_address)
-- [Function `requires_role`](#0x1_Errors_requires_role)
-- [Function `requires_capability`](#0x1_Errors_requires_capability)
-- [Function `not_published`](#0x1_Errors_not_published)
-- [Function `already_published`](#0x1_Errors_already_published)
-- [Function `invalid_argument`](#0x1_Errors_invalid_argument)
-- [Function `limit_exceeded`](#0x1_Errors_limit_exceeded)
-- [Function `internal`](#0x1_Errors_internal)
-- [Function `deprecated`](#0x1_Errors_deprecated)
-- [Function `custom`](#0x1_Errors_custom)
-- [Specification](#@Specification_1)
- - [Function `make`](#@Specification_1_make)
- - [Function `invalid_state`](#@Specification_1_invalid_state)
- - [Function `requires_address`](#@Specification_1_requires_address)
- - [Function `requires_role`](#@Specification_1_requires_role)
- - [Function `requires_capability`](#@Specification_1_requires_capability)
- - [Function `not_published`](#@Specification_1_not_published)
- - [Function `already_published`](#@Specification_1_already_published)
- - [Function `invalid_argument`](#@Specification_1_invalid_argument)
- - [Function `limit_exceeded`](#@Specification_1_limit_exceeded)
- - [Function `internal`](#@Specification_1_internal)
- - [Function `deprecated`](#@Specification_1_deprecated)
- - [Function `custom`](#@Specification_1_custom)
-
-
-
-
-
-
-
-
-## Constants
-
-
-
-
-Attempting to publish a resource that is already published. Example: calling an initialization function
-twice.
-
-
-const ALREADY_PUBLISHED: u8 = 6;
-
-
-
-
-
-
-A custom error category for extension points.
-
-
-const CUSTOM: u8 = 255;
-
-
-
-
-
-
-deprecated code
-
-
-const DEPRECATED: u8 = 11;
-
-
-
-
-
-
-An internal error (bug) has occurred.
-
-
-const INTERNAL: u8 = 10;
-
-
-
-
-
-
-An argument provided to an operation is invalid. Example: a signing key has the wrong format.
-
-
-const INVALID_ARGUMENT: u8 = 7;
-
-
-
-
-
-
-The system is in a state where the performed operation is not allowed. Example: call to a function only allowed
-in genesis
-
-
-const INVALID_STATE: u8 = 1;
-
-
-
-
-
-
-A limit on an amount, e.g. a currency, is exceeded. Example: withdrawal of money after account limits window
-is exhausted.
-
-
-const LIMIT_EXCEEDED: u8 = 8;
-
-
-
-
-
-
-A resource is required but not published. Example: access to non-existing resource.
-
-
-const NOT_PUBLISHED: u8 = 5;
-
-
-
-
-
-
-The signer of a transaction does not have the expected address for this operation. Example: a call to a function
-which publishes a resource under a particular address.
-
-
-const REQUIRES_ADDRESS: u8 = 2;
-
-
-
-
-
-
-The signer of a transaction does not have a required capability.
-
-
-const REQUIRES_CAPABILITY: u8 = 4;
-
-
-
-
-
-
-The signer of a transaction does not have the expected role for this operation. Example: a call to a function
-which requires the signer to have the role of treasury compliance.
-
-
-const REQUIRES_ROLE: u8 = 3;
-
-
-
-
-
-
-## Function `make`
-
-A function to create an error from from a category and a reason.
-
-
-fun make(category: u8, reason: u64): u64
-
-
-
-
-fun make(category: u8, reason: u64): u64 {
- (category as u64) + (reason << 8)
-}
-
-
-
-
-invalid_state
-
-
-public fun invalid_state(reason: u64): u64
-
-
-
-
-public fun invalid_state(reason: u64): u64 { make(INVALID_STATE, reason) }
-
-
-
-
-requires_address
.
-
-
-public fun requires_address(reason: u64): u64
-
-
-
-
-public fun requires_address(reason: u64): u64 { make(REQUIRES_ADDRESS, reason) }
-
-
-
-
-requires_role
.
-
-
-public fun requires_role(reason: u64): u64
-
-
-
-
-public fun requires_role(reason: u64): u64 { make(REQUIRES_ROLE, reason) }
-
-
-
-
-requires_capability
.
-
-
-public fun requires_capability(reason: u64): u64
-
-
-
-
-public fun requires_capability(reason: u64): u64 { make(REQUIRES_CAPABILITY, reason) }
-
-
-
-
-not_published
.
-
-
-public fun not_published(reason: u64): u64
-
-
-
-
-public fun not_published(reason: u64): u64 { make(NOT_PUBLISHED, reason) }
-
-
-
-
-already_published
.
-
-
-public fun already_published(reason: u64): u64
-
-
-
-
-public fun already_published(reason: u64): u64 { make(ALREADY_PUBLISHED, reason) }
-
-
-
-
-invalid_argument
.
-
-
-public fun invalid_argument(reason: u64): u64
-
-
-
-
-public fun invalid_argument(reason: u64): u64 { make(INVALID_ARGUMENT, reason) }
-
-
-
-
-limit_exceeded
.
-
-
-public fun limit_exceeded(reason: u64): u64
-
-
-
-
-public fun limit_exceeded(reason: u64): u64 { make(LIMIT_EXCEEDED, reason) }
-
-
-
-
-internal
.
-
-
-public fun internal(reason: u64): u64
-
-
-
-
-public fun internal(reason: u64): u64 { make(INTERNAL, reason) }
-
-
-
-
-deprecated
.
-
-
-public fun deprecated(reason: u64): u64
-
-
-
-
-public fun deprecated(reason: u64): u64 { make(DEPRECATED, reason) }
-
-
-
-
-custom
.
-
-
-public fun custom(reason: u64): u64
-
-
-
-
-public fun custom(reason: u64): u64 { make(CUSTOM, reason) }
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `make`
-
-
-fun make(category: u8, reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-pragma verify = false;
-aborts_if [abstract] false;
-ensures [abstract] result == category;
-
-
-
-
-
-
-### Function `invalid_state`
-
-
-public fun invalid_state(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == INVALID_STATE;
-
-
-
-
-
-
-### Function `requires_address`
-
-
-public fun requires_address(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == REQUIRES_ADDRESS;
-
-
-
-
-
-
-### Function `requires_role`
-
-
-public fun requires_role(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == REQUIRES_ROLE;
-
-
-
-
-
-
-### Function `requires_capability`
-
-
-public fun requires_capability(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == REQUIRES_CAPABILITY;
-
-
-
-
-
-
-### Function `not_published`
-
-
-public fun not_published(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == NOT_PUBLISHED;
-
-
-
-
-
-
-### Function `already_published`
-
-
-public fun already_published(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == ALREADY_PUBLISHED;
-
-
-
-
-
-
-### Function `invalid_argument`
-
-
-public fun invalid_argument(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == INVALID_ARGUMENT;
-
-
-
-
-
-
-### Function `limit_exceeded`
-
-
-public fun limit_exceeded(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == LIMIT_EXCEEDED;
-
-
-
-
-
-
-### Function `internal`
-
-
-public fun internal(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == INTERNAL;
-
-
-
-
-
-
-### Function `deprecated`
-
-
-public fun deprecated(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == DEPRECATED;
-
-
-
-
-
-
-### Function `custom`
-
-
-public fun custom(reason: u64): u64
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == CUSTOM;
-
diff --git a/vm/stdlib/compiled/latest/doc/Event.md b/vm/stdlib/compiled/latest/doc/Event.md
deleted file mode 100644
index 17c2dbac18..0000000000
--- a/vm/stdlib/compiled/latest/doc/Event.md
+++ /dev/null
@@ -1,300 +0,0 @@
-
-
-
-# Module `0x1::Event`
-
-The Event module defines an EventHandleGenerator
that is used to create
-EventHandle
s with unique GUIDs. It contains a counter for the number
-of EventHandle
s it generates. An EventHandle
is used to count the number of
-events emitted to a handle and emit events to the event store.
-
-
-- [Resource `EventHandleGenerator`](#0x1_Event_EventHandleGenerator)
-- [Struct `EventHandle`](#0x1_Event_EventHandle)
-- [Constants](#@Constants_0)
-- [Function `publish_generator`](#0x1_Event_publish_generator)
-- [Function `fresh_guid`](#0x1_Event_fresh_guid)
-- [Function `new_event_handle`](#0x1_Event_new_event_handle)
-- [Function `emit_event`](#0x1_Event_emit_event)
-- [Function `write_to_event_store`](#0x1_Event_write_to_event_store)
-- [Function `destroy_handle`](#0x1_Event_destroy_handle)
-- [Specification](#@Specification_1)
-
-
-use 0x1::BCS;
-use 0x1::Errors;
-use 0x1::Signer;
-use 0x1::Vector;
-
-
-
-
-
-
-## Resource `EventHandleGenerator`
-
-A resource representing the counter used to generate uniqueness under each account. There won't be destructor for
-this resource to guarantee the uniqueness of the generated handle.
-
-
-struct EventHandleGenerator has key
-
-
-
-
-counter: u64
-addr: address
-struct EventHandle<T: drop, store> has store
-
-
-
-
-counter: u64
-guid: vector<u8>
-const EEVENT_GENERATOR: u64 = 0;
-
-
-
-
-
-
-## Function `publish_generator`
-
-Publishs a new event handle generator.
-
-
-public fun publish_generator(account: &signer)
-
-
-
-
-public fun publish_generator(account: &signer) {
- let addr = Signer::address_of(account);
- assert!(!exists<EventHandleGenerator>(addr), Errors::already_published(EEVENT_GENERATOR));
- move_to(account, EventHandleGenerator{ counter: 0, addr })
-}
-
-
-
-
-fun fresh_guid(counter: &mut Event::EventHandleGenerator): vector<u8>
-
-
-
-
-fun fresh_guid(counter: &mut EventHandleGenerator): vector<u8> {
- let sender_bytes = BCS::to_bytes(&counter.addr);
- let count_bytes = BCS::to_bytes(&counter.counter);
- counter.counter = counter.counter + 1;
-
- // EventHandleGenerator goes first just in case we want to extend address in the future.
- Vector::append(&mut count_bytes, sender_bytes);
-
- count_bytes
-}
-
-
-
-
-sig
-
-
-public fun new_event_handle<T: drop, store>(account: &signer): Event::EventHandle<T>
-
-
-
-
-public fun new_event_handle<T: drop + store>(account: &signer): EventHandle<T>
-acquires EventHandleGenerator {
- let addr = Signer::address_of(account);
- assert!(exists<EventHandleGenerator>(addr), Errors::not_published(EEVENT_GENERATOR));
- EventHandle<T> {
- counter: 0,
- guid: fresh_guid(borrow_global_mut<EventHandleGenerator>(addr))
- }
-}
-
-
-
-
-msg
by using handle_ref
's key and counter.
-
-
-public fun emit_event<T: drop, store>(handle_ref: &mut Event::EventHandle<T>, msg: T)
-
-
-
-
-public fun emit_event<T: drop + store>(handle_ref: &mut EventHandle<T>, msg: T) {
- let guid = *&handle_ref.guid;
-
- write_to_event_store<T>(guid, handle_ref.counter, msg);
- handle_ref.counter = handle_ref.counter + 1;
-}
-
-
-
-
-fun write_to_event_store<T: drop, store>(guid: vector<u8>, count: u64, msg: T)
-
-
-
-
-native fun write_to_event_store<T: drop + store>(guid: vector<u8>, count: u64, msg: T);
-
-
-
-
-public fun destroy_handle<T: drop, store>(handle: Event::EventHandle<T>)
-
-
-
-
-public fun destroy_handle<T: drop + store>(handle: EventHandle<T>) {
- EventHandle<T> { counter: _, guid: _ } = handle;
-}
-
-
-
-
-pragma intrinsic = true;
-
diff --git a/vm/stdlib/compiled/latest/doc/FixedPoint32.md b/vm/stdlib/compiled/latest/doc/FixedPoint32.md
deleted file mode 100644
index cce36b4f68..0000000000
--- a/vm/stdlib/compiled/latest/doc/FixedPoint32.md
+++ /dev/null
@@ -1,391 +0,0 @@
-
-
-
-# Module `0x1::FixedPoint32`
-
-The module provide operations for FixedPoint32.
-
-
-- [Struct `FixedPoint32`](#0x1_FixedPoint32_FixedPoint32)
-- [Constants](#@Constants_0)
-- [Function `multiply_u64`](#0x1_FixedPoint32_multiply_u64)
-- [Function `divide_u64`](#0x1_FixedPoint32_divide_u64)
-- [Function `create_from_rational`](#0x1_FixedPoint32_create_from_rational)
-- [Function `create_from_raw_value`](#0x1_FixedPoint32_create_from_raw_value)
-- [Function `get_raw_value`](#0x1_FixedPoint32_get_raw_value)
-- [Specification](#@Specification_1)
- - [Function `multiply_u64`](#@Specification_1_multiply_u64)
- - [Function `divide_u64`](#@Specification_1_divide_u64)
- - [Function `create_from_rational`](#@Specification_1_create_from_rational)
-
-
-use 0x1::Errors;
-
-
-
-
-
-
-## Struct `FixedPoint32`
-
-Define a fixed-point numeric type with 32 fractional bits.
-This is just a u64 integer but it is wrapped in a struct to
-make a unique type.
-
-
-struct FixedPoint32 has copy, drop, store
-
-
-
-
-value: u64
-const MAX_U64: u128 = 18446744073709551615;
-
-
-
-
-
-
-The denominator provided was zero
-
-
-const EDENOMINATOR: u64 = 101;
-
-
-
-
-
-
-The quotient value would be too large to be held in a u64
-
-
-const EDIVISION: u64 = 102;
-
-
-
-
-
-
-A division by zero was encountered
-
-
-const EDIVISION_BY_ZERO: u64 = 104;
-
-
-
-
-
-
-The multiplied value would be too large to be held in a u64
-
-
-const EMULTIPLICATION: u64 = 103;
-
-
-
-
-
-
-The computed ratio when converting to a FixedPoint32
would be unrepresentable
-
-
-const ERATIO_OUT_OF_RANGE: u64 = 105;
-
-
-
-
-
-
-## Function `multiply_u64`
-
-Multiply a u64 integer by a fixed-point number, truncating any
-fractional part of the product. This will abort if the product
-overflows.
-
-
-public fun multiply_u64(val: u64, multiplier: FixedPoint32::FixedPoint32): u64
-
-
-
-
-public fun multiply_u64(val: u64, multiplier: FixedPoint32): u64 {
- // The product of two 64 bit values has 128 bits, so perform the
- // multiplication with u128 types and keep the full 128 bit product
- // to avoid losing accuracy.
- let unscaled_product = (val as u128) * (multiplier.value as u128);
- // The unscaled product has 32 fractional bits (from the multiplier)
- // so rescale it by shifting away the low bits.
- let product = unscaled_product >> 32;
- // Check whether the value is too large.
- assert!(product <= MAX_U64, Errors::limit_exceeded(EMULTIPLICATION));
- (product as u64)
-}
-
-
-
-
-public fun divide_u64(val: u64, divisor: FixedPoint32::FixedPoint32): u64
-
-
-
-
-public fun divide_u64(val: u64, divisor: FixedPoint32): u64 {
- // Check for division by zero.
- assert!(divisor.value != 0, Errors::invalid_argument(EDIVISION_BY_ZERO));
- // First convert to 128 bits and then shift left to
- // add 32 fractional zero bits to the dividend.
- let scaled_value = (val as u128) << 32;
- let quotient = scaled_value / (divisor.value as u128);
- // Check whether the value is too large.
- assert!(quotient <= MAX_U64, Errors::limit_exceeded(EDIVISION));
- // the value may be too large, which will cause the cast to fail
- // with an arithmetic error.
- (quotient as u64)
-}
-
-
-
-
-public fun create_from_rational(numerator: u64, denominator: u64): FixedPoint32::FixedPoint32
-
-
-
-
-public fun create_from_rational(numerator: u64, denominator: u64): FixedPoint32 {
- // If the denominator is zero, this will abort.
- // Scale the numerator to have 64 fractional bits and the denominator
- // to have 32 fractional bits, so that the quotient will have 32
- // fractional bits.
- let scaled_numerator = (numerator as u128) << 64;
- let scaled_denominator = (denominator as u128) << 32;
- assert!(scaled_denominator != 0, Errors::invalid_argument(EDENOMINATOR));
- let quotient = scaled_numerator / scaled_denominator;
- assert!(quotient != 0 || numerator == 0, Errors::invalid_argument(ERATIO_OUT_OF_RANGE));
- // Return the quotient as a fixed-point number. We first need to check whether the cast
- // can succeed.
- assert!(quotient <= MAX_U64, Errors::limit_exceeded(ERATIO_OUT_OF_RANGE));
- FixedPoint32 { value: (quotient as u64) }
-}
-
-
-
-
-public fun create_from_raw_value(value: u64): FixedPoint32::FixedPoint32
-
-
-
-
-public fun create_from_raw_value(value: u64): FixedPoint32 {
- FixedPoint32 { value }
-}
-
-
-
-
-public fun get_raw_value(num: FixedPoint32::FixedPoint32): u64
-
-
-
-
-public fun get_raw_value(num: FixedPoint32): u64 {
- num.value
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-Uninterpreted function for Self::multiply_u64
.
-
-
-
-
-
-fun spec_multiply_u64(val: u64, multiplier: FixedPoint32): u64;
-
-
-
-Uninterpreted function for Self::divide_u64
.
-
-
-
-
-
-fun spec_divide_u64(val: u64, divisor: FixedPoint32): u64;
-
-
-
-Uninterpreted function for Self::create_from_rational
.
-
-
-
-
-
-fun spec_create_from_rational(numerator: u64, denominator: u64): FixedPoint32;
-
-
-
-
-
-
-### Function `multiply_u64`
-
-
-public fun multiply_u64(val: u64, multiplier: FixedPoint32::FixedPoint32): u64
-
-
-
-
-Currently, we ignore the actual implementation of this function in verification
-and treat it as uninterpreted, which simplifies the verification problem significantly.
-This way we avoid the non-linear arithmetic problem presented by this function.
-
-Abstracting this and related functions is possible because the correctness of currency
-conversion (where FixedPoint32
is used for) is not relevant for the rest of the contract
-control flow, so we can assume some arbitrary (but fixed) behavior here.
-
-
-pragma opaque = true;
-pragma verify = false;
-ensures result == spec_multiply_u64(val, multiplier);
-
-
-
-
-
-
-### Function `divide_u64`
-
-
-public fun divide_u64(val: u64, divisor: FixedPoint32::FixedPoint32): u64
-
-
-
-
-See comment at Self::multiply_64
.
-
-
-pragma opaque = true;
-pragma verify = false;
-ensures result == spec_divide_u64(val, divisor);
-
-
-
-
-
-
-### Function `create_from_rational`
-
-
-public fun create_from_rational(numerator: u64, denominator: u64): FixedPoint32::FixedPoint32
-
-
-
-
-See comment at Self::multiply_64
.
-
-
-pragma opaque = true;
-pragma verify = false;
-ensures result == spec_create_from_rational(numerator, denominator);
-
diff --git a/vm/stdlib/compiled/latest/doc/Genesis.md b/vm/stdlib/compiled/latest/doc/Genesis.md
deleted file mode 100644
index c26a5fb8f7..0000000000
--- a/vm/stdlib/compiled/latest/doc/Genesis.md
+++ /dev/null
@@ -1,654 +0,0 @@
-
-
-
-# Module `0x1::Genesis`
-
-The module for init Genesis
-
-
-- [Function `initialize`](#0x1_Genesis_initialize)
-- [Function `initialize_v2`](#0x1_Genesis_initialize_v2)
-- [Function `do_initialize`](#0x1_Genesis_do_initialize)
-- [Function `initialize_for_unit_tests`](#0x1_Genesis_initialize_for_unit_tests)
-- [Specification](#@Specification_0)
-
-
-use 0x1::Account;
-use 0x1::Block;
-use 0x1::BlockReward;
-use 0x1::ChainId;
-use 0x1::Collection;
-use 0x1::Config;
-use 0x1::ConsensusConfig;
-use 0x1::ConsensusStrategy;
-use 0x1::CoreAddresses;
-use 0x1::DummyToken;
-use 0x1::Epoch;
-use 0x1::GenesisNFT;
-use 0x1::GenesisSignerCapability;
-use 0x1::Option;
-use 0x1::PackageTxnManager;
-use 0x1::STC;
-use 0x1::STCUSDOracle;
-use 0x1::Signer;
-use 0x1::StdlibUpgradeScripts;
-use 0x1::Timestamp;
-use 0x1::Token;
-use 0x1::TransactionFee;
-use 0x1::TransactionPublishOption;
-use 0x1::TransactionTimeoutConfig;
-use 0x1::Treasury;
-use 0x1::TreasuryWithdrawDaoProposal;
-use 0x1::VMConfig;
-use 0x1::Vector;
-use 0x1::Version;
-
-
-
-
-
-
-## Function `initialize`
-
-
-
-public(script) fun initialize(stdlib_version: u64, reward_delay: u64, pre_mine_stc_amount: u128, time_mint_stc_amount: u128, time_mint_stc_period: u64, parent_hash: vector<u8>, association_auth_key: vector<u8>, genesis_auth_key: vector<u8>, chain_id: u8, genesis_timestamp: u64, uncle_rate_target: u64, epoch_block_count: u64, base_block_time_target: u64, base_block_difficulty_window: u64, base_reward_per_block: u128, base_reward_per_uncle_percent: u64, min_block_time_target: u64, max_block_time_target: u64, base_max_uncles_per_block: u64, base_block_gas_limit: u64, strategy: u8, script_allowed: bool, module_publishing_allowed: bool, instruction_schedule: vector<u8>, native_schedule: vector<u8>, global_memory_per_byte_cost: u64, global_memory_per_byte_write_cost: u64, min_transaction_gas_units: u64, large_transaction_cutoff: u64, instrinsic_gas_per_byte: u64, maximum_number_of_gas_units: u64, min_price_per_gas_unit: u64, max_price_per_gas_unit: u64, max_transaction_size_in_bytes: u64, gas_unit_scaling_factor: u64, default_account_size: u64, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64, transaction_timeout: u64)
-
-
-
-
-public(script) fun initialize(
- stdlib_version: u64,
-
- // block reward config
- reward_delay: u64,
-
- pre_mine_stc_amount: u128,
- time_mint_stc_amount: u128,
- time_mint_stc_period: u64,
- parent_hash: vector<u8>,
- association_auth_key: vector<u8>,
- genesis_auth_key: vector<u8>,
- chain_id: u8,
- genesis_timestamp: u64,
-
- //consensus config
- uncle_rate_target: u64,
- epoch_block_count: u64,
- base_block_time_target: u64,
- base_block_difficulty_window: u64,
- base_reward_per_block: u128,
- base_reward_per_uncle_percent: u64,
- min_block_time_target: u64,
- max_block_time_target: u64,
- base_max_uncles_per_block: u64,
- base_block_gas_limit: u64,
- strategy: u8,
-
- //vm config
- script_allowed: bool,
- module_publishing_allowed: bool,
- instruction_schedule: vector<u8>,
- native_schedule: vector<u8>,
-
- //gas constants
- global_memory_per_byte_cost: u64,
- global_memory_per_byte_write_cost: u64,
- min_transaction_gas_units: u64,
- large_transaction_cutoff: u64,
- instrinsic_gas_per_byte: u64,
- maximum_number_of_gas_units: u64,
- min_price_per_gas_unit: u64,
- max_price_per_gas_unit: u64,
- max_transaction_size_in_bytes: u64,
- gas_unit_scaling_factor: u64,
- default_account_size: u64,
-
- // dao config
- voting_delay: u64,
- voting_period: u64,
- voting_quorum_rate: u8,
- min_action_delay: u64,
-
- // transaction timeout config
- transaction_timeout: u64,
-) {
- assert!(Timestamp::is_genesis(), 1);
- // create genesis account
- let genesis_account = Account::create_genesis_account(CoreAddresses::GENESIS_ADDRESS());
- //Init global time
- Timestamp::initialize(&genesis_account, genesis_timestamp);
- ChainId::initialize(&genesis_account, chain_id);
- ConsensusStrategy::initialize(&genesis_account, strategy);
- Block::initialize(&genesis_account, parent_hash);
- TransactionPublishOption::initialize(
- &genesis_account,
- script_allowed,
- module_publishing_allowed,
- );
- // init config
- VMConfig::initialize(
- &genesis_account,
- instruction_schedule,
- native_schedule,
- global_memory_per_byte_cost,
- global_memory_per_byte_write_cost,
- min_transaction_gas_units,
- large_transaction_cutoff,
- instrinsic_gas_per_byte,
- maximum_number_of_gas_units,
- min_price_per_gas_unit,
- max_price_per_gas_unit,
- max_transaction_size_in_bytes,
- gas_unit_scaling_factor,
- default_account_size,
- );
- TransactionTimeoutConfig::initialize(&genesis_account, transaction_timeout);
- ConsensusConfig::initialize(
- &genesis_account,
- uncle_rate_target,
- epoch_block_count,
- base_block_time_target,
- base_block_difficulty_window,
- base_reward_per_block,
- base_reward_per_uncle_percent,
- min_block_time_target,
- max_block_time_target,
- base_max_uncles_per_block,
- base_block_gas_limit,
- strategy,
- );
- Epoch::initialize(&genesis_account);
- BlockReward::initialize(&genesis_account, reward_delay);
- TransactionFee::initialize(&genesis_account);
- let association = Account::create_genesis_account(
- CoreAddresses::ASSOCIATION_ROOT_ADDRESS(),
- );
- Config::publish_new_config<Version::Version>(&genesis_account, Version::new_version(stdlib_version));
- // stdlib use two phase upgrade strategy.
- PackageTxnManager::update_module_upgrade_strategy(
- &genesis_account,
- PackageTxnManager::get_strategy_two_phase(),
- Option::some(0u64),
- );
- // stc should be initialized after genesis_account's module upgrade strategy set.
- {
- STC::initialize(&genesis_account, voting_delay, voting_period, voting_quorum_rate, min_action_delay);
- Account::do_accept_token<STC>(&genesis_account);
- DummyToken::initialize(&genesis_account);
- Account::do_accept_token<STC>(&association);
- };
- if (pre_mine_stc_amount > 0) {
- let stc = Token::mint<STC>(&genesis_account, pre_mine_stc_amount);
- Account::deposit(Signer::address_of(&association), stc);
- };
- if (time_mint_stc_amount > 0) {
- let cap = Token::remove_mint_capability<STC>(&genesis_account);
- let key = Token::issue_linear_mint_key<STC>(&cap, time_mint_stc_amount, time_mint_stc_period);
- Token::add_mint_capability(&genesis_account, cap);
- Collection::put(&association, key);
- };
- // only dev network set genesis auth key.
- if (!Vector::is_empty(&genesis_auth_key)) {
- let genesis_rotate_key_cap = Account::extract_key_rotation_capability(&genesis_account);
- Account::rotate_authentication_key_with_capability(&genesis_rotate_key_cap, genesis_auth_key);
- Account::restore_key_rotation_capability(genesis_rotate_key_cap);
- };
- let assoc_rotate_key_cap = Account::extract_key_rotation_capability(&association);
- Account::rotate_authentication_key_with_capability(&assoc_rotate_key_cap, association_auth_key);
- Account::restore_key_rotation_capability(assoc_rotate_key_cap);
- //Start time, Timestamp::is_genesis() will return false. this call should at the end of genesis init.
- Timestamp::set_time_has_started(&genesis_account);
- Account::release_genesis_signer(genesis_account);
- Account::release_genesis_signer(association);
-}
-
-
-
-
-public(script) fun initialize_v2(stdlib_version: u64, reward_delay: u64, total_stc_amount: u128, pre_mine_stc_amount: u128, time_mint_stc_amount: u128, time_mint_stc_period: u64, parent_hash: vector<u8>, association_auth_key: vector<u8>, genesis_auth_key: vector<u8>, chain_id: u8, genesis_timestamp: u64, uncle_rate_target: u64, epoch_block_count: u64, base_block_time_target: u64, base_block_difficulty_window: u64, base_reward_per_block: u128, base_reward_per_uncle_percent: u64, min_block_time_target: u64, max_block_time_target: u64, base_max_uncles_per_block: u64, base_block_gas_limit: u64, strategy: u8, script_allowed: bool, module_publishing_allowed: bool, instruction_schedule: vector<u8>, native_schedule: vector<u8>, global_memory_per_byte_cost: u64, global_memory_per_byte_write_cost: u64, min_transaction_gas_units: u64, large_transaction_cutoff: u64, instrinsic_gas_per_byte: u64, maximum_number_of_gas_units: u64, min_price_per_gas_unit: u64, max_price_per_gas_unit: u64, max_transaction_size_in_bytes: u64, gas_unit_scaling_factor: u64, default_account_size: u64, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64, transaction_timeout: u64)
-
-
-
-
-public(script) fun initialize_v2(
- stdlib_version: u64,
-
- // block reward and stc config
- reward_delay: u64,
- total_stc_amount: u128,
- pre_mine_stc_amount: u128,
- time_mint_stc_amount: u128,
- time_mint_stc_period: u64,
-
- parent_hash: vector<u8>,
- association_auth_key: vector<u8>,
- genesis_auth_key: vector<u8>,
- chain_id: u8,
- genesis_timestamp: u64,
-
- //consensus config
- uncle_rate_target: u64,
- epoch_block_count: u64,
- base_block_time_target: u64,
- base_block_difficulty_window: u64,
- base_reward_per_block: u128,
- base_reward_per_uncle_percent: u64,
- min_block_time_target: u64,
- max_block_time_target: u64,
- base_max_uncles_per_block: u64,
- base_block_gas_limit: u64,
- strategy: u8,
-
- //vm config
- script_allowed: bool,
- module_publishing_allowed: bool,
- instruction_schedule: vector<u8>,
- native_schedule: vector<u8>,
-
- //gas constants
- global_memory_per_byte_cost: u64,
- global_memory_per_byte_write_cost: u64,
- min_transaction_gas_units: u64,
- large_transaction_cutoff: u64,
- instrinsic_gas_per_byte: u64,
- maximum_number_of_gas_units: u64,
- min_price_per_gas_unit: u64,
- max_price_per_gas_unit: u64,
- max_transaction_size_in_bytes: u64,
- gas_unit_scaling_factor: u64,
- default_account_size: u64,
-
- // dao config
- voting_delay: u64,
- voting_period: u64,
- voting_quorum_rate: u8,
- min_action_delay: u64,
-
- // transaction timeout config
- transaction_timeout: u64,
-) {
- Self::do_initialize(
- stdlib_version,
- reward_delay,
- total_stc_amount,
- pre_mine_stc_amount,
- time_mint_stc_amount,
- time_mint_stc_period,
- parent_hash,
- association_auth_key,
- genesis_auth_key,
- chain_id,
- genesis_timestamp,
- uncle_rate_target,
- epoch_block_count,
- base_block_time_target,
- base_block_difficulty_window,
- base_reward_per_block,
- base_reward_per_uncle_percent,
- min_block_time_target,
- max_block_time_target,
- base_max_uncles_per_block,
- base_block_gas_limit,
- strategy,
- script_allowed,
- module_publishing_allowed,
- instruction_schedule,
- native_schedule,
- global_memory_per_byte_cost,
- global_memory_per_byte_write_cost,
- min_transaction_gas_units,
- large_transaction_cutoff,
- instrinsic_gas_per_byte,
- maximum_number_of_gas_units,
- min_price_per_gas_unit,
- max_price_per_gas_unit,
- max_transaction_size_in_bytes,
- gas_unit_scaling_factor,
- default_account_size,
- voting_delay,
- voting_period,
- voting_quorum_rate,
- min_action_delay,
- transaction_timeout,
- );
-}
-
-
-
-
-fun do_initialize(stdlib_version: u64, reward_delay: u64, total_stc_amount: u128, pre_mine_stc_amount: u128, time_mint_stc_amount: u128, time_mint_stc_period: u64, parent_hash: vector<u8>, association_auth_key: vector<u8>, genesis_auth_key: vector<u8>, chain_id: u8, genesis_timestamp: u64, uncle_rate_target: u64, epoch_block_count: u64, base_block_time_target: u64, base_block_difficulty_window: u64, base_reward_per_block: u128, base_reward_per_uncle_percent: u64, min_block_time_target: u64, max_block_time_target: u64, base_max_uncles_per_block: u64, base_block_gas_limit: u64, strategy: u8, script_allowed: bool, module_publishing_allowed: bool, instruction_schedule: vector<u8>, native_schedule: vector<u8>, global_memory_per_byte_cost: u64, global_memory_per_byte_write_cost: u64, min_transaction_gas_units: u64, large_transaction_cutoff: u64, instrinsic_gas_per_byte: u64, maximum_number_of_gas_units: u64, min_price_per_gas_unit: u64, max_price_per_gas_unit: u64, max_transaction_size_in_bytes: u64, gas_unit_scaling_factor: u64, default_account_size: u64, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64, transaction_timeout: u64)
-
-
-
-
-fun do_initialize(
- stdlib_version: u64,
-
- // block reward and stc config
- reward_delay: u64,
- total_stc_amount: u128,
- pre_mine_stc_amount: u128,
- time_mint_stc_amount: u128,
- time_mint_stc_period: u64,
-
- parent_hash: vector<u8>,
- association_auth_key: vector<u8>,
- genesis_auth_key: vector<u8>,
- chain_id: u8,
- genesis_timestamp: u64,
-
- //consensus config
- uncle_rate_target: u64,
- epoch_block_count: u64,
- base_block_time_target: u64,
- base_block_difficulty_window: u64,
- base_reward_per_block: u128,
- base_reward_per_uncle_percent: u64,
- min_block_time_target: u64,
- max_block_time_target: u64,
- base_max_uncles_per_block: u64,
- base_block_gas_limit: u64,
- strategy: u8,
-
- //vm config
- script_allowed: bool,
- module_publishing_allowed: bool,
- instruction_schedule: vector<u8>,
- native_schedule: vector<u8>,
-
- //gas constants
- global_memory_per_byte_cost: u64,
- global_memory_per_byte_write_cost: u64,
- min_transaction_gas_units: u64,
- large_transaction_cutoff: u64,
- instrinsic_gas_per_byte: u64,
- maximum_number_of_gas_units: u64,
- min_price_per_gas_unit: u64,
- max_price_per_gas_unit: u64,
- max_transaction_size_in_bytes: u64,
- gas_unit_scaling_factor: u64,
- default_account_size: u64,
-
- // dao config
- voting_delay: u64,
- voting_period: u64,
- voting_quorum_rate: u8,
- min_action_delay: u64,
-
- // transaction timeout config
- transaction_timeout: u64,
-){
- Timestamp::assert_genesis();
- // create genesis account
- let genesis_account = Account::create_genesis_account(CoreAddresses::GENESIS_ADDRESS());
- //Init global time
- Timestamp::initialize(&genesis_account, genesis_timestamp);
- ChainId::initialize(&genesis_account, chain_id);
- ConsensusStrategy::initialize(&genesis_account, strategy);
- Block::initialize(&genesis_account, parent_hash);
- TransactionPublishOption::initialize(
- &genesis_account,
- script_allowed,
- module_publishing_allowed,
- );
- // init config
- VMConfig::initialize(
- &genesis_account,
- instruction_schedule,
- native_schedule,
- global_memory_per_byte_cost,
- global_memory_per_byte_write_cost,
- min_transaction_gas_units,
- large_transaction_cutoff,
- instrinsic_gas_per_byte,
- maximum_number_of_gas_units,
- min_price_per_gas_unit,
- max_price_per_gas_unit,
- max_transaction_size_in_bytes,
- gas_unit_scaling_factor,
- default_account_size,
- );
- TransactionTimeoutConfig::initialize(&genesis_account, transaction_timeout);
- ConsensusConfig::initialize(
- &genesis_account,
- uncle_rate_target,
- epoch_block_count,
- base_block_time_target,
- base_block_difficulty_window,
- base_reward_per_block,
- base_reward_per_uncle_percent,
- min_block_time_target,
- max_block_time_target,
- base_max_uncles_per_block,
- base_block_gas_limit,
- strategy,
- );
- Epoch::initialize(&genesis_account);
- let association = Account::create_genesis_account(
- CoreAddresses::ASSOCIATION_ROOT_ADDRESS(),
- );
- Config::publish_new_config<Version::Version>(&genesis_account, Version::new_version(stdlib_version));
- // stdlib use two phase upgrade strategy.
- PackageTxnManager::update_module_upgrade_strategy(
- &genesis_account,
- PackageTxnManager::get_strategy_two_phase(),
- Option::some(0u64),
- );
- BlockReward::initialize(&genesis_account, reward_delay);
-
- // stc should be initialized after genesis_account's module upgrade strategy set and all on chain config init.
- let withdraw_cap = STC::initialize_v2(&genesis_account, total_stc_amount, voting_delay, voting_period, voting_quorum_rate, min_action_delay);
- Account::do_accept_token<STC>(&genesis_account);
- Account::do_accept_token<STC>(&association);
-
- DummyToken::initialize(&genesis_account);
-
- if (pre_mine_stc_amount > 0) {
- let stc = Treasury::withdraw_with_capability<STC>(&mut withdraw_cap, pre_mine_stc_amount);
- Account::deposit(Signer::address_of(&association), stc);
- };
- if (time_mint_stc_amount > 0) {
- let liner_withdraw_cap = Treasury::issue_linear_withdraw_capability<STC>(&mut withdraw_cap, time_mint_stc_amount, time_mint_stc_period);
- Treasury::add_linear_withdraw_capability(&association, liner_withdraw_cap);
- };
-
- // Lock the TreasuryWithdrawCapability to Dao
- TreasuryWithdrawDaoProposal::plugin(&genesis_account, withdraw_cap);
-
- TransactionFee::initialize(&genesis_account);
-
- // only test/dev network set genesis auth key.
- if (!Vector::is_empty(&genesis_auth_key)) {
- let genesis_rotate_key_cap = Account::extract_key_rotation_capability(&genesis_account);
- Account::rotate_authentication_key_with_capability(&genesis_rotate_key_cap, genesis_auth_key);
- Account::restore_key_rotation_capability(genesis_rotate_key_cap);
- };
-
- let assoc_rotate_key_cap = Account::extract_key_rotation_capability(&association);
- Account::rotate_authentication_key_with_capability(&assoc_rotate_key_cap, association_auth_key);
- Account::restore_key_rotation_capability(assoc_rotate_key_cap);
-
- // v5 -> v6
- {
- let cap = Account::remove_signer_capability(&genesis_account);
- GenesisSignerCapability::initialize(&genesis_account, cap);
- //register oracle
- STCUSDOracle::register(&genesis_account);
- let merkle_root = x"5969f0e8e19f8769276fb638e6060d5c02e40088f5fde70a6778dd69d659ee6d";
- let image = b"ipfs://QmSPcvcXgdtHHiVTAAarzTeubk5X3iWymPAoKBfiRFjPMY";
- GenesisNFT::initialize(&genesis_account, merkle_root, 1639u64, image);
- };
- StdlibUpgradeScripts::do_upgrade_from_v6_to_v7_with_language_version(&genesis_account, 4);
- //Start time, Timestamp::is_genesis() will return false. this call should at the end of genesis init.
- Timestamp::set_time_has_started(&genesis_account);
- Account::release_genesis_signer(genesis_account);
- Account::release_genesis_signer(association);
-}
-
-
-
-
-public fun initialize_for_unit_tests()
-
-
-
-
-public fun initialize_for_unit_tests(){
- let stdlib_version: u64 = 6;
- let reward_delay: u64 = 7;
- let total_stc_amount: u128 = 3185136000000000000u128;
- let pre_mine_stc_amount: u128 = 159256800000000000u128;
- let time_mint_stc_amount: u128 = (85043130u128 * 3u128 + 74213670u128 * 3u128)*1000000000u128;
- let time_mint_stc_period: u64 = 1000000000;
-
- let parent_hash: vector<u8> = x"0000000000000000000000000000000000000000000000000000000000000000";
- let association_auth_key: vector<u8> = x"0000000000000000000000000000000000000000000000000000000000000000";
- let genesis_auth_key: vector<u8> = x"0000000000000000000000000000000000000000000000000000000000000000";
- let chain_id: u8 = 255;
- let genesis_timestamp: u64 =0;
-
- //consensus config
- let uncle_rate_target: u64 = 80;
- let epoch_block_count: u64 = 240;
- let base_block_time_target: u64 = 10000;
- let base_block_difficulty_window: u64 = 24;
- let base_reward_per_block: u128 = 1000000000;
- let base_reward_per_uncle_percent: u64 = 10;
- let min_block_time_target: u64 = 1000;
- let max_block_time_target: u64 = 20000;
- let base_max_uncles_per_block: u64 = 2;
- let base_block_gas_limit: u64 = 500000000;
- let strategy: u8 = 0;
-
- //vm config
- let script_allowed: bool = true;
- let module_publishing_allowed: bool = true;
- //TODO init the gas table.
- let instruction_schedule: vector<u8> = Vector::empty();
- let native_schedule: vector<u8> = Vector::empty();
-
- //gas constants
- let global_memory_per_byte_cost: u64 = 1;
- let global_memory_per_byte_write_cost: u64 = 1;
- let min_transaction_gas_units: u64 = 1;
- let large_transaction_cutoff: u64 = 1;
- let instrinsic_gas_per_byte: u64 = 1;
- let maximum_number_of_gas_units: u64 = 1;
- let min_price_per_gas_unit: u64 = 1;
- let max_price_per_gas_unit: u64 = 10000;
- let max_transaction_size_in_bytes: u64 = 1024*1024;
- let gas_unit_scaling_factor: u64 = 1;
- let default_account_size: u64 = 600;
-
- // dao config
- let voting_delay: u64 = 1000;
- let voting_period: u64 = 6000;
- let voting_quorum_rate: u8 = 4;
- let min_action_delay: u64 = 1000;
-
- // transaction timeout config
- let transaction_timeout: u64 = 10000;
-
- Self::do_initialize(
- stdlib_version,
- reward_delay,
- total_stc_amount,
- pre_mine_stc_amount,
- time_mint_stc_amount,
- time_mint_stc_period,
- parent_hash,
- association_auth_key,
- genesis_auth_key,
- chain_id,
- genesis_timestamp,
- uncle_rate_target,
- epoch_block_count,
- base_block_time_target,
- base_block_difficulty_window,
- base_reward_per_block,
- base_reward_per_uncle_percent,
- min_block_time_target,
- max_block_time_target,
- base_max_uncles_per_block,
- base_block_gas_limit,
- strategy,
- script_allowed,
- module_publishing_allowed,
- instruction_schedule,
- native_schedule,
- global_memory_per_byte_cost,
- global_memory_per_byte_write_cost,
- min_transaction_gas_units,
- large_transaction_cutoff,
- instrinsic_gas_per_byte,
- maximum_number_of_gas_units,
- min_price_per_gas_unit,
- max_price_per_gas_unit,
- max_transaction_size_in_bytes,
- gas_unit_scaling_factor,
- default_account_size,
- voting_delay,
- voting_period,
- voting_quorum_rate,
- min_action_delay,
- transaction_timeout,
- );
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_partial = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/vm/stdlib/compiled/latest/doc/GenesisNFT.md b/vm/stdlib/compiled/latest/doc/GenesisNFT.md
deleted file mode 100644
index c0d9e13f75..0000000000
--- a/vm/stdlib/compiled/latest/doc/GenesisNFT.md
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-# Module `0x1::GenesisNFTScripts`
-
-
-
-- [Function `mint`](#0x1_GenesisNFTScripts_mint)
-- [Specification](#@Specification_0)
-
-
-use 0x1::GenesisNFT;
-
-
-
-
-
-
-## Function `mint`
-
-Mint a GenesisNFT
-
-
-public(script) fun mint(sender: signer, index: u64, merkle_proof: vector<vector<u8>>)
-
-
-
-
-public(script) fun mint(sender: signer, index: u64, merkle_proof:vector<vector<u8>>) {
- GenesisNFT::mint(&sender, index, merkle_proof);
-}
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/GenesisSignerCapability.md b/vm/stdlib/compiled/latest/doc/GenesisSignerCapability.md
deleted file mode 100644
index e3b42b6898..0000000000
--- a/vm/stdlib/compiled/latest/doc/GenesisSignerCapability.md
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
-# Module `0x1::GenesisSignerCapability`
-
-
-
-- [Resource `GenesisSignerCapability`](#0x1_GenesisSignerCapability_GenesisSignerCapability)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_GenesisSignerCapability_initialize)
-- [Function `get_genesis_signer`](#0x1_GenesisSignerCapability_get_genesis_signer)
-
-
-use 0x1::Account;
-use 0x1::CoreAddresses;
-use 0x1::Errors;
-
-
-
-
-
-
-## Resource `GenesisSignerCapability`
-
-
-
-struct GenesisSignerCapability has key
-
-
-
-
-cap: Account::SignerCapability
-const ENOT_GENESIS_ACCOUNT: u64 = 11;
-
-
-
-
-
-
-## Function `initialize`
-
-
-
-public(friend) fun initialize(signer: &signer, cap: Account::SignerCapability)
-
-
-
-
-public(friend) fun initialize(signer:&signer, cap: Account::SignerCapability) {
- CoreAddresses::assert_genesis_address(signer);
- assert!(Account::signer_address(&cap) == CoreAddresses::GENESIS_ADDRESS(), Errors::invalid_argument(ENOT_GENESIS_ACCOUNT));
- move_to(signer, GenesisSignerCapability{cap});
-}
-
-
-
-
-public(friend) fun get_genesis_signer(): signer
-
-
-
-
-public(friend) fun get_genesis_signer(): signer acquires GenesisSignerCapability {
- let cap = borrow_global<GenesisSignerCapability>(CoreAddresses::GENESIS_ADDRESS());
- Account::create_signer_with_cap(&cap.cap)
-}
-
-
-
-
-
-
-
-
-
-
-## Function `sha2_256`
-
-
-
-public fun sha2_256(data: vector<u8>): vector<u8>
-
-
-
-
-native public fun sha2_256(data: vector<u8>): vector<u8>;
-
-
-
-
-public fun sha3_256(data: vector<u8>): vector<u8>
-
-
-
-
-native public fun sha3_256(data: vector<u8>): vector<u8>;
-
-
-
-
-public fun keccak_256(data: vector<u8>): vector<u8>
-
-
-
-
-native public fun keccak_256(data: vector<u8>): vector<u8>;
-
-
-
-
-public fun ripemd160(data: vector<u8>): vector<u8>
-
-
-
-
-native public fun ripemd160(data: vector<u8>): vector<u8>;
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/vm/stdlib/compiled/latest/doc/LanguageVersion.md b/vm/stdlib/compiled/latest/doc/LanguageVersion.md
deleted file mode 100644
index 07565bad98..0000000000
--- a/vm/stdlib/compiled/latest/doc/LanguageVersion.md
+++ /dev/null
@@ -1,128 +0,0 @@
-
-
-
-# Module `0x1::LanguageVersion`
-
-
-
-- [Struct `LanguageVersion`](#0x1_LanguageVersion_LanguageVersion)
-- [Function `new`](#0x1_LanguageVersion_new)
-- [Function `version`](#0x1_LanguageVersion_version)
-- [Specification](#@Specification_0)
- - [Function `new`](#@Specification_0_new)
- - [Function `version`](#@Specification_0_version)
-
-
-
-
-
-
-
-
-## Struct `LanguageVersion`
-
-
-
-struct LanguageVersion has copy, drop, store
-
-
-
-
-major: u64
-public fun new(version: u64): LanguageVersion::LanguageVersion
-
-
-
-
-public fun new(version: u64): LanguageVersion {
- LanguageVersion {major: version}
-}
-
-
-
-
-public fun version(version: &LanguageVersion::LanguageVersion): u64
-
-
-
-
-public fun version(version: &LanguageVersion): u64 {
- version.major
-}
-
-
-
-
-public fun new(version: u64): LanguageVersion::LanguageVersion
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `version`
-
-
-public fun version(version: &LanguageVersion::LanguageVersion): u64
-
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/Math.md b/vm/stdlib/compiled/latest/doc/Math.md
deleted file mode 100644
index 0d15135e1f..0000000000
--- a/vm/stdlib/compiled/latest/doc/Math.md
+++ /dev/null
@@ -1,393 +0,0 @@
-
-
-
-# Module `0x1::Math`
-
-The module provide some improved math calculations.
-
-
-- [Constants](#@Constants_0)
-- [Function `u64_max`](#0x1_Math_u64_max)
-- [Function `u128_max`](#0x1_Math_u128_max)
-- [Function `sqrt`](#0x1_Math_sqrt)
-- [Function `pow`](#0x1_Math_pow)
-- [Function `mul_div`](#0x1_Math_mul_div)
-- [Function `sum`](#0x1_Math_sum)
-- [Function `avg`](#0x1_Math_avg)
-- [Specification](#@Specification_1)
- - [Function `sqrt`](#@Specification_1_sqrt)
- - [Function `pow`](#@Specification_1_pow)
- - [Function `mul_div`](#@Specification_1_mul_div)
-
-
-use 0x1::Vector;
-
-
-
-
-
-
-## Constants
-
-
-
-
-
-
-const U128_MAX: u128 = 340282366920938463463374607431768211455;
-
-
-
-
-
-
-
-
-const U64_MAX: u64 = 18446744073709551615;
-
-
-
-
-
-
-## Function `u64_max`
-
-u64::MAX
-
-
-public fun u64_max(): u64
-
-
-
-
-public fun u64_max(): u64 {
- U64_MAX
-}
-
-
-
-
-public fun u128_max(): u128
-
-
-
-
-public fun u128_max(): u128 {
- U128_MAX
-}
-
-
-
-
-public fun sqrt(y: u128): u64
-
-
-
-
-public fun sqrt(y: u128): u64 {
- if (y < 4) {
- if (y == 0) {
- 0u64
- } else {
- 1u64
- }
- } else {
- let z = y;
- let x = y / 2 + 1;
- while (x < z) {
- z = x;
- x = (y / x + x) / 2;
- };
- (z as u64)
- }
-}
-
-
-
-
-y
pow of x
.
-
-
-public fun pow(x: u64, y: u64): u128
-
-
-
-
-public fun pow(x: u64, y: u64): u128 {
- let result = 1u128;
- let z = y;
- let u = (x as u128);
- while (z > 0) {
- if (z % 2 == 1) {
- result = (u * result as u128);
- };
- u = (u * u as u128);
- z = z / 2;
- };
- result
-}
-
-
-
-
-public fun mul_div(x: u128, y: u128, z: u128): u128
-
-
-
-
-public fun mul_div(x: u128, y: u128, z: u128): u128 {
- if (y == z) {
- return x
- };
- if (x == z) {
- return y
- };
- let a = x / z;
- let b = x % z;
- //x = a * z + b;
- let c = y / z;
- let d = y % z;
- //y = c * z + d;
- a * c * z + a * d + b * c + b * d / z
-}
-
-
-
-
-public fun sum(nums: &vector<u128>): u128
-
-
-
-
-public fun sum(nums: &vector<u128>): u128 {
- let len = Vector::length(nums);
- let i = 0;
- let sum = 0;
- while (i < len){
- sum = sum + *Vector::borrow(nums, i);
- i = i + 1;
- };
- sum
-}
-
-
-
-
-public fun avg(nums: &vector<u128>): u128
-
-
-
-
-public fun avg(nums: &vector<u128>): u128{
- let len = Vector::length(nums);
- let sum = sum(nums);
- sum/(len as u128)
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `sqrt`
-
-
-public fun sqrt(y: u128): u64
-
-
-
-
-
-pragma opaque = true;
-pragma verify = false;
-aborts_if [abstract] false;
-ensures [abstract] result == spec_sqrt();
-
-
-
-We use an uninterpreted function to represent the result of sqrt. The actual value
-does not matter for the verification of callers.
-
-
-
-
-
-fun spec_sqrt(): u128;
-
-
-
-
-
-
-### Function `pow`
-
-
-public fun pow(x: u64, y: u64): u128
-
-
-
-
-
-pragma opaque = true;
-pragma verify = false;
-aborts_if [abstract] false;
-ensures [abstract] result == spec_pow();
-
-
-
-We use an uninterpreted function to represent the result of pow. The actual value
-does not matter for the verification of callers.
-
-
-
-
-
-fun spec_pow(): u128;
-
-
-
-
-
-
-### Function `mul_div`
-
-
-public fun mul_div(x: u128, y: u128, z: u128): u128
-
-
-
-
-
-pragma opaque = true;
-include MulDivAbortsIf;
-aborts_if [abstract] false;
-ensures [abstract] result == spec_mul_div();
-
-
-
-
-
-
-
-
-schema MulDivAbortsIf {
- x: u128;
- y: u128;
- z: u128;
- aborts_if y != z && x > z && z == 0;
- aborts_if y != z && x > z && z!=0 && x/z*y > MAX_U128;
- aborts_if y != z && x <= z && z == 0;
- aborts_if y != z && x <= z && x / z * (x % z) > MAX_U128;
- aborts_if y != z && x <= z && x / z * (x % z) * z > MAX_U128;
- aborts_if y != z && x <= z && x / z * (y % z) > MAX_U128;
- aborts_if y != z && x <= z && x / z * (x % z) * z + x / z * (y % z) > MAX_U128;
- aborts_if y != z && x <= z && x % z * (y / z) > MAX_U128;
- aborts_if y != z && x <= z && x % z * (y % z) > MAX_U128;
- aborts_if y != z && x <= z && x % z * (y % z) / z > MAX_U128;
- aborts_if y != z && x <= z && x / z * (x % z) * z + x / z * (y % z) + x % z * (y / z) > MAX_U128;
- aborts_if y != z && x <= z && x / z * (x % z) * z + x / z * (y % z) + x % z * (y / z) + x % z * (y % z) / z > MAX_U128;
-}
-
-
-
-
-
-
-
-
-fun spec_mul_div(): u128;
-
diff --git a/vm/stdlib/compiled/latest/doc/MerkleNFT.md b/vm/stdlib/compiled/latest/doc/MerkleNFT.md
deleted file mode 100644
index abb38d9d44..0000000000
--- a/vm/stdlib/compiled/latest/doc/MerkleNFT.md
+++ /dev/null
@@ -1,304 +0,0 @@
-
-
-
-# Module `0x1::MerkleNFTDistributor`
-
-
-
-- [Resource `MerkleNFTDistribution`](#0x1_MerkleNFTDistributor_MerkleNFTDistribution)
-- [Constants](#@Constants_0)
-- [Function `register`](#0x1_MerkleNFTDistributor_register)
-- [Function `mint_with_cap`](#0x1_MerkleNFTDistributor_mint_with_cap)
-- [Function `encode_leaf`](#0x1_MerkleNFTDistributor_encode_leaf)
-- [Function `set_minted_`](#0x1_MerkleNFTDistributor_set_minted_)
-- [Function `verify_proof`](#0x1_MerkleNFTDistributor_verify_proof)
-- [Function `is_minted`](#0x1_MerkleNFTDistributor_is_minted)
-- [Function `is_minted_`](#0x1_MerkleNFTDistributor_is_minted_)
-
-
-use 0x1::BCS;
-use 0x1::Errors;
-use 0x1::Hash;
-use 0x1::MerkleProof;
-use 0x1::NFT;
-use 0x1::Signer;
-use 0x1::Vector;
-
-
-
-
-
-
-## Resource `MerkleNFTDistribution`
-
-
-
-struct MerkleNFTDistribution<NFTMeta: copy, drop, store> has key
-
-
-
-
-merkle_root: vector<u8>
-claimed_bitmap: vector<u128>
-const ERR_NO_MINT_CAPABILITY: u64 = 1002;
-
-
-
-
-
-
-
-
-const ALREADY_MINTED: u64 = 1000;
-
-
-
-
-
-
-
-
-const INVALID_PROOF: u64 = 1001;
-
-
-
-
-
-
-## Function `register`
-
-
-
-public fun register<NFTMeta: copy, drop, store, Info: copy, drop, store>(signer: &signer, merkle_root: vector<u8>, leafs: u64, info: Info, meta: NFT::Metadata): NFT::MintCapability<NFTMeta>
-
-
-
-
-public fun register<NFTMeta: copy + store + drop, Info: copy + store + drop>(signer: &signer, merkle_root: vector<u8>, leafs: u64, info: Info, meta: Metadata): MintCapability<NFTMeta> {
- let bitmap_count = leafs / 128;
- if (bitmap_count * 128 < leafs) {
- bitmap_count = bitmap_count + 1;
- };
- let claimed_bitmap = Vector::empty();
- let j = 0;
- while (j < bitmap_count) {
- Vector::push_back( &mut claimed_bitmap, 0u128);
- j = j + 1;
- };
- let distribution = MerkleNFTDistribution<NFTMeta>{
- merkle_root,
- claimed_bitmap
- };
- NFT::register<NFTMeta, Info>(signer, info, meta);
- move_to(signer, distribution);
- NFT::remove_mint_capability<NFTMeta>(signer)
-}
-
-
-
-
-public fun mint_with_cap<NFTMeta: copy, drop, store, NFTBody: store, Info: copy, drop, store>(sender: &signer, cap: &mut NFT::MintCapability<NFTMeta>, creator: address, index: u64, base_meta: NFT::Metadata, type_meta: NFTMeta, body: NFTBody, merkle_proof: vector<vector<u8>>): NFT::NFT<NFTMeta, NFTBody>
-
-
-
-
-public fun mint_with_cap<NFTMeta: copy + store + drop, NFTBody: store, Info: copy + store + drop>(sender: &signer, cap:&mut MintCapability<NFTMeta>, creator: address, index: u64, base_meta: Metadata, type_meta: NFTMeta, body: NFTBody, merkle_proof:vector<vector<u8>>): NFT<NFTMeta, NFTBody>
- acquires MerkleNFTDistribution {
- let addr = Signer::address_of(sender);
- let distribution = borrow_global_mut<MerkleNFTDistribution<NFTMeta>>(creator);
- let minted = is_minted_<NFTMeta>(distribution, index);
- assert!(!minted, Errors::custom(ALREADY_MINTED));
- let leaf_data = encode_leaf(&index, &addr);
- let verified = MerkleProof::verify(&merkle_proof, &distribution.merkle_root, Hash::sha3_256(leaf_data));
- assert!(verified, Errors::custom(INVALID_PROOF));
- set_minted_(distribution, index);
- let nft = NFT::mint_with_cap<NFTMeta, NFTBody, Info>(creator, cap, base_meta, type_meta, body);
- return nft
- }
-
-
-
-
-fun encode_leaf(index: &u64, account: &address): vector<u8>
-
-
-
-
-fun encode_leaf(index: &u64, account: &address): vector<u8> {
- let leaf = Vector::empty();
- Vector::append(&mut leaf, BCS::to_bytes(index));
- Vector::append(&mut leaf, BCS::to_bytes(account));
- leaf
-}
-
-
-
-
-fun set_minted_<NFTMeta: copy, drop, store>(distribution: &mut MerkleNFTDistributor::MerkleNFTDistribution<NFTMeta>, index: u64)
-
-
-
-
-fun set_minted_<NFTMeta: copy + store + drop>(distribution: &mut MerkleNFTDistribution<NFTMeta>, index: u64) {
- let claimed_word_index = index / 128;
- let claimed_bit_index = ((index % 128) as u8);
- let word = Vector::borrow_mut(&mut distribution.claimed_bitmap, claimed_word_index);
- // word | (1 << bit_index)
- let mask = 1u128 << claimed_bit_index;
- *word = (*word | mask);
-}
-
-
-
-
-public fun verify_proof<NFTMeta: copy, drop, store>(account: address, creator: address, index: u64, merkle_proof: vector<vector<u8>>): bool
-
-
-
-
-public fun verify_proof<NFTMeta: copy + store + drop>(account: address, creator: address, index: u64, merkle_proof:vector<vector<u8>>): bool
- acquires MerkleNFTDistribution {
- let distribution = borrow_global_mut<MerkleNFTDistribution<NFTMeta>>(creator);
- let leaf_data = encode_leaf(&index, &account);
- MerkleProof::verify(&merkle_proof, &distribution.merkle_root, Hash::sha3_256(leaf_data))
- }
-
-
-
-
-public fun is_minted<NFTMeta: copy, drop, store>(creator: address, index: u64): bool
-
-
-
-
-public fun is_minted<NFTMeta: copy + store + drop>(creator: address, index: u64): bool
- acquires MerkleNFTDistribution {
- let distribution = borrow_global_mut<MerkleNFTDistribution<NFTMeta>>(creator);
- is_minted_<NFTMeta>(distribution, index)
- }
-
-
-
-
-fun is_minted_<NFTMeta: copy, drop, store>(distribution: &MerkleNFTDistributor::MerkleNFTDistribution<NFTMeta>, index: u64): bool
-
-
-
-
-fun is_minted_<NFTMeta: copy + store + drop>(distribution: &MerkleNFTDistribution<NFTMeta>, index: u64): bool {
- let claimed_word_index = index / 128;
- let claimed_bit_index = ((index % 128) as u8);
- let word = Vector::borrow( &distribution.claimed_bitmap, claimed_word_index);
- let mask = 1u128 << claimed_bit_index;
- (*word & mask) == mask
-}
-
-
-
-
-use 0x1::Account;
-use 0x1::Dao;
-use 0x1::Errors;
-use 0x1::Signer;
-use 0x1::Token;
-
-
-
-
-
-
-## Resource `WrappedMintCapability`
-
-A wrapper of Token MintCapability.
-
-
-struct WrappedMintCapability<TokenType> has key
-
-
-
-
-cap: Token::MintCapability<TokenType>
-struct MintToken has copy, drop, store
-
-
-
-
-receiver: address
-amount: u128
-const ERR_NOT_AUTHORIZED: u64 = 401;
-
-
-
-
-
-
-## Function `plugin`
-
-Plugin method of the module.
-Should be called by token issuer.
-
-
-public fun plugin<TokenT: store>(signer: &signer)
-
-
-
-
-public fun plugin<TokenT: store>(signer: &signer) {
- let token_issuer = Token::token_address<TokenT>();
- assert!(Signer::address_of(signer) == token_issuer, Errors::requires_address(ERR_NOT_AUTHORIZED));
- let mint_cap = Token::remove_mint_capability<TokenT>(signer);
- move_to(signer, WrappedMintCapability { cap: mint_cap });
-}
-
-
-
-
-public fun propose_mint_to<TokenT: copy, drop, store>(signer: &signer, receiver: address, amount: u128, exec_delay: u64)
-
-
-
-
-public fun propose_mint_to<TokenT: copy + drop + store>(signer: &signer, receiver: address, amount: u128, exec_delay: u64) {
- Dao::propose<TokenT, MintToken>(
- signer,
- MintToken { receiver, amount },
- exec_delay,
- );
-}
-
-
-
-
-public fun execute_mint_proposal<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-public fun execute_mint_proposal<TokenT: copy + drop + store>(
- proposer_address: address,
- proposal_id: u64,
-) acquires WrappedMintCapability {
- let MintToken { receiver, amount } = Dao::extract_proposal_action<TokenT, MintToken>(
- proposer_address,
- proposal_id,
- );
- let cap = borrow_global<WrappedMintCapability<TokenT>>(Token::token_address<TokenT>());
- let tokens = Token::mint_with_capability<TokenT>(&cap.cap, amount);
- Account::deposit(receiver, tokens);
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict;
-pragma aborts_if_is_partial;
-
-
-
-
-
-
-### Function `plugin`
-
-
-public fun plugin<TokenT: store>(signer: &signer)
-
-
-
-
-
-pragma aborts_if_is_partial = false;
-let sender = Signer::address_of(signer);
-aborts_if sender != Token::SPEC_TOKEN_TEST_ADDRESS();
-aborts_if !exists<Token::MintCapability<TokenT>>(sender);
-aborts_if exists<WrappedMintCapability<TokenT>>(sender);
-ensures !exists<Token::MintCapability<TokenT>>(sender);
-ensures exists<WrappedMintCapability<TokenT>>(sender);
-
-
-
-
-
-
-### Function `propose_mint_to`
-
-
-public fun propose_mint_to<TokenT: copy, drop, store>(signer: &signer, receiver: address, amount: u128, exec_delay: u64)
-
-
-
-
-
-pragma aborts_if_is_partial = false;
-include Dao::AbortIfDaoConfigNotExist<TokenT>;
-include Dao::AbortIfDaoInfoNotExist<TokenT>;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if exec_delay > 0 && exec_delay < Dao::spec_dao_config<TokenT>().min_action_delay;
-include Dao::CheckQuorumVotes<TokenT>;
-let sender = Signer::address_of(signer);
-aborts_if exists<Dao::Proposal<TokenT, MintToken>>(sender);
-
-
-
-
-
-
-### Function `execute_mint_proposal`
-
-
-public fun execute_mint_proposal<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-
-pragma aborts_if_is_partial = true;
-let expected_states = vec<u8>(6);
-include Dao::CheckProposalStates<TokenT, MintToken>{expected_states};
-let proposal = global<Dao::Proposal<TokenT, MintToken>>(proposer_address);
-aborts_if Option::is_none(proposal.action);
-aborts_if !exists<WrappedMintCapability<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-
diff --git a/vm/stdlib/compiled/latest/doc/MintScripts.md b/vm/stdlib/compiled/latest/doc/MintScripts.md
deleted file mode 100644
index dbbdd845dd..0000000000
--- a/vm/stdlib/compiled/latest/doc/MintScripts.md
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-# Module `0x1::MintScripts`
-
-
-
-
-
-
diff --git a/vm/stdlib/compiled/latest/doc/ModifyDaoConfigProposal.md b/vm/stdlib/compiled/latest/doc/ModifyDaoConfigProposal.md
deleted file mode 100644
index 378917cfb3..0000000000
--- a/vm/stdlib/compiled/latest/doc/ModifyDaoConfigProposal.md
+++ /dev/null
@@ -1,315 +0,0 @@
-
-
-
-# Module `0x1::ModifyDaoConfigProposal`
-
-A proposal module which is used to modify Token's DAO configuration.
-
-
-- [Resource `DaoConfigModifyCapability`](#0x1_ModifyDaoConfigProposal_DaoConfigModifyCapability)
-- [Struct `DaoConfigUpdate`](#0x1_ModifyDaoConfigProposal_DaoConfigUpdate)
-- [Constants](#@Constants_0)
-- [Function `plugin`](#0x1_ModifyDaoConfigProposal_plugin)
-- [Function `propose`](#0x1_ModifyDaoConfigProposal_propose)
-- [Function `execute`](#0x1_ModifyDaoConfigProposal_execute)
-- [Specification](#@Specification_1)
- - [Function `plugin`](#@Specification_1_plugin)
- - [Function `propose`](#@Specification_1_propose)
- - [Function `execute`](#@Specification_1_execute)
-
-
-use 0x1::Config;
-use 0x1::Dao;
-use 0x1::Errors;
-use 0x1::Signer;
-use 0x1::Token;
-
-
-
-
-
-
-## Resource `DaoConfigModifyCapability`
-
-A wrapper of Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>
.
-
-
-struct DaoConfigModifyCapability<TokenT: copy, drop, store> has key
-
-
-
-
-cap: Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>
-0
, that means the proposal want to update.
-
-
-struct DaoConfigUpdate has copy, drop, store
-
-
-
-
-voting_delay: u64
-voting_period: u64
-voting_quorum_rate: u8
-min_action_delay: u64
-const ERR_NOT_AUTHORIZED: u64 = 401;
-
-
-
-
-
-
-
-
-const ERR_QUORUM_RATE_INVALID: u64 = 402;
-
-
-
-
-
-
-## Function `plugin`
-
-Plugin method of the module.
-Should be called by token issuer.
-
-
-public fun plugin<TokenT: copy, drop, store>(signer: &signer)
-
-
-
-
-public fun plugin<TokenT: copy + drop + store>(signer: &signer) {
- let token_issuer = Token::token_address<TokenT>();
- assert!(Signer::address_of(signer) == token_issuer, Errors::requires_address(ERR_NOT_AUTHORIZED));
- let dao_config_modify_cap = Config::extract_modify_config_capability<
- Dao::DaoConfig<TokenT>,
- >(signer);
- assert!(Config::account_address(&dao_config_modify_cap) == token_issuer, Errors::requires_address(ERR_NOT_AUTHORIZED));
- let cap = DaoConfigModifyCapability { cap: dao_config_modify_cap };
- move_to(signer, cap);
-}
-
-
-
-
-public(script) fun propose<TokenT: copy, drop, store>(signer: signer, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64, exec_delay: u64)
-
-
-
-
-public(script) fun propose<TokenT: copy + drop + store>(
- signer: signer,
- voting_delay: u64,
- voting_period: u64,
- voting_quorum_rate: u8,
- min_action_delay: u64,
- exec_delay: u64,
-) {
- assert!(voting_quorum_rate <= 100, Errors::invalid_argument(ERR_QUORUM_RATE_INVALID));
- let action = DaoConfigUpdate {
- voting_delay,
- voting_period,
- voting_quorum_rate,
- min_action_delay,
- };
- Dao::propose<TokenT, DaoConfigUpdate>(&signer, action, exec_delay);
-}
-
-
-
-
-public(script) fun execute<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-public(script) fun execute<TokenT: copy + drop + store>(proposer_address: address, proposal_id: u64)
-acquires DaoConfigModifyCapability {
- let DaoConfigUpdate {
- voting_delay,
- voting_period,
- voting_quorum_rate,
- min_action_delay,
- } = Dao::extract_proposal_action<TokenT, DaoConfigUpdate>(proposer_address, proposal_id);
- let cap = borrow_global_mut<DaoConfigModifyCapability<TokenT>>(
- Token::token_address<TokenT>(),
- );
- Dao::modify_dao_config(
- &mut cap.cap,
- voting_delay,
- voting_period,
- voting_quorum_rate,
- min_action_delay,
- );
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict;
-pragma aborts_if_is_partial;
-
-
-
-
-
-
-### Function `plugin`
-
-
-public fun plugin<TokenT: copy, drop, store>(signer: &signer)
-
-
-
-
-
-pragma aborts_if_is_partial = false;
-let sender = Signer::address_of(signer);
-aborts_if sender != Token::SPEC_TOKEN_TEST_ADDRESS();
-include Config::AbortsIfCapNotExist<Dao::DaoConfig<TokenT>>{account: sender};
-let config_cap = Config::spec_cap<Dao::DaoConfig<TokenT>>(sender);
-aborts_if Option::is_none(config_cap);
-aborts_if Option::borrow(config_cap).account_address != sender;
-aborts_if exists<DaoConfigModifyCapability<TokenT>>(sender);
-ensures exists<DaoConfigModifyCapability<TokenT>>(sender);
-
-
-
-
-
-
-### Function `propose`
-
-
-public(script) fun propose<TokenT: copy, drop, store>(signer: signer, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64, exec_delay: u64)
-
-
-
-
-
-pragma aborts_if_is_partial = false;
-aborts_if voting_quorum_rate > 100;
-include Dao::AbortIfDaoConfigNotExist<TokenT>;
-include Dao::AbortIfDaoInfoNotExist<TokenT>;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if exec_delay > 0 && exec_delay < Dao::spec_dao_config<TokenT>().min_action_delay;
-include Dao::CheckQuorumVotes<TokenT>;
-let sender = Signer::address_of(signer);
-aborts_if exists<Dao::Proposal<TokenT, DaoConfigUpdate>>(sender);
-
-
-
-
-
-
-### Function `execute`
-
-
-public(script) fun execute<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-
-pragma aborts_if_is_partial = true;
-aborts_if !exists<DaoConfigModifyCapability<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-
diff --git a/vm/stdlib/compiled/latest/doc/ModuleUpgradeScripts.md b/vm/stdlib/compiled/latest/doc/ModuleUpgradeScripts.md
deleted file mode 100644
index aad9f6febf..0000000000
--- a/vm/stdlib/compiled/latest/doc/ModuleUpgradeScripts.md
+++ /dev/null
@@ -1,275 +0,0 @@
-
-
-
-# Module `0x1::ModuleUpgradeScripts`
-
-
-
-- [Function `propose_module_upgrade_v2`](#0x1_ModuleUpgradeScripts_propose_module_upgrade_v2)
-- [Function `update_module_upgrade_strategy`](#0x1_ModuleUpgradeScripts_update_module_upgrade_strategy)
-- [Function `submit_module_upgrade_plan`](#0x1_ModuleUpgradeScripts_submit_module_upgrade_plan)
-- [Function `execute_module_upgrade_plan_propose`](#0x1_ModuleUpgradeScripts_execute_module_upgrade_plan_propose)
-- [Function `submit_upgrade_plan`](#0x1_ModuleUpgradeScripts_submit_upgrade_plan)
-- [Function `cancel_upgrade_plan`](#0x1_ModuleUpgradeScripts_cancel_upgrade_plan)
-- [Specification](#@Specification_0)
- - [Function `execute_module_upgrade_plan_propose`](#@Specification_0_execute_module_upgrade_plan_propose)
- - [Function `submit_upgrade_plan`](#@Specification_0_submit_upgrade_plan)
- - [Function `cancel_upgrade_plan`](#@Specification_0_cancel_upgrade_plan)
-
-
-use 0x1::Config;
-use 0x1::Option;
-use 0x1::PackageTxnManager;
-use 0x1::Signer;
-use 0x1::UpgradeModuleDaoProposal;
-use 0x1::Version;
-
-
-
-
-
-
-## Function `propose_module_upgrade_v2`
-
-
-
-public(script) fun propose_module_upgrade_v2<Token: copy, drop, store>(signer: signer, module_address: address, package_hash: vector<u8>, version: u64, exec_delay: u64, enforced: bool)
-
-
-
-
-public(script) fun propose_module_upgrade_v2<Token: copy + drop + store>(
- signer: signer,
- module_address: address,
- package_hash: vector<u8>,
- version: u64,
- exec_delay: u64,
- enforced: bool,
-) {
- UpgradeModuleDaoProposal::propose_module_upgrade_v2<Token>(
- &signer,
- module_address,
- package_hash,
- version,
- exec_delay,
- enforced
- );
-}
-
-
-
-
-sender
's module upgrade strategy to strategy
-
-
-public(script) fun update_module_upgrade_strategy(sender: signer, strategy: u8)
-
-
-
-
-public(script) fun update_module_upgrade_strategy(
- sender: signer,
- strategy: u8,
-) {
- // 1. check version
- if (strategy == PackageTxnManager::get_strategy_two_phase()) {
- if (!Config::config_exist_by_address<Version::Version>(Signer::address_of(&sender))) {
- Config::publish_new_config<Version::Version>(&sender, Version::new_version(1));
- }
- };
-
- // 2. update strategy
- PackageTxnManager::update_module_upgrade_strategy(
- &sender,
- strategy,
- Option::none<u64>(),
- );
-}
-
-
-
-
-public(script) fun submit_module_upgrade_plan<Token: copy, drop, store>(sender: signer, proposer_address: address, proposal_id: u64)
-
-
-
-
-public(script) fun submit_module_upgrade_plan<Token: copy + drop + store>(
- sender: signer,
- proposer_address: address,
- proposal_id: u64,
-) {
- Self::execute_module_upgrade_plan_propose<Token>(sender, proposer_address, proposal_id);
-}
-
-
-
-
-public(script) fun execute_module_upgrade_plan_propose<Token: copy, drop, store>(_sender: signer, proposer_address: address, proposal_id: u64)
-
-
-
-
-public(script) fun execute_module_upgrade_plan_propose<Token: copy + drop + store>(
- _sender: signer,
- proposer_address: address,
- proposal_id: u64,
-) {
- UpgradeModuleDaoProposal::submit_module_upgrade_plan<Token>(proposer_address, proposal_id);
-}
-
-
-
-
-sender
's module upgrade plan must been PackageTxnManager::STRATEGY_TWO_PHASE and have UpgradePlanCapability
-
-
-public(script) fun submit_upgrade_plan(sender: signer, package_hash: vector<u8>, version: u64, enforced: bool)
-
-
-
-
-public(script) fun submit_upgrade_plan(sender: signer, package_hash: vector<u8>, version:u64, enforced: bool) {
- PackageTxnManager::submit_upgrade_plan_v2(&sender, package_hash, version, enforced);
-}
-
-
-
-
-sender
must have UpgradePlanCapability
.
-
-
-public(script) fun cancel_upgrade_plan(signer: signer)
-
-
-
-
-public(script) fun cancel_upgrade_plan(
- signer: signer,
-) {
- PackageTxnManager::cancel_upgrade_plan(&signer);
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_partial = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `execute_module_upgrade_plan_propose`
-
-
-public(script) fun execute_module_upgrade_plan_propose<Token: copy, drop, store>(_sender: signer, proposer_address: address, proposal_id: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `submit_upgrade_plan`
-
-
-public(script) fun submit_upgrade_plan(sender: signer, package_hash: vector<u8>, version: u64, enforced: bool)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `cancel_upgrade_plan`
-
-
-public(script) fun cancel_upgrade_plan(signer: signer)
-
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/NFT.md b/vm/stdlib/compiled/latest/doc/NFT.md
deleted file mode 100644
index 818b57c869..0000000000
--- a/vm/stdlib/compiled/latest/doc/NFT.md
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-# Module `0x1::NFTGalleryScripts`
-
-
-
-- [Function `accept`](#0x1_NFTGalleryScripts_accept)
-- [Function `transfer`](#0x1_NFTGalleryScripts_transfer)
-- [Specification](#@Specification_0)
-
-
-use 0x1::NFTGallery;
-
-
-
-
-
-
-## Function `accept`
-
-Init a NFTGallery for accept NFTpublic(script) fun accept<NFTMeta: copy, drop, store, NFTBody: store>(sender: signer)
-
-
-
-
-public(script) fun accept<NFTMeta: copy + store + drop, NFTBody: store>(sender: signer) {
- NFTGallery::accept<NFTMeta, NFTBody>(&sender);
-}
-
-
-
-
-id
from sender
to receiver
-
-
-public(script) fun transfer<NFTMeta: copy, drop, store, NFTBody: store>(sender: signer, id: u64, receiver: address)
-
-
-
-
-public(script) fun transfer<NFTMeta: copy + store + drop, NFTBody: store>(sender: signer, id: u64, receiver: address) {
- NFTGallery::transfer<NFTMeta, NFTBody>(&sender, id, receiver);
-}
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/Offer.md b/vm/stdlib/compiled/latest/doc/Offer.md
deleted file mode 100644
index f9475a7221..0000000000
--- a/vm/stdlib/compiled/latest/doc/Offer.md
+++ /dev/null
@@ -1,330 +0,0 @@
-
-
-
-# Module `0x1::Offer`
-
-
-
-- [Resource `Offer`](#0x1_Offer_Offer)
-- [Constants](#@Constants_0)
-- [Function `create`](#0x1_Offer_create)
-- [Function `redeem`](#0x1_Offer_redeem)
-- [Function `exists_at`](#0x1_Offer_exists_at)
-- [Function `address_of`](#0x1_Offer_address_of)
-- [Function `take_offer`](#0x1_Offer_take_offer)
-- [Specification](#@Specification_1)
- - [Function `create`](#@Specification_1_create)
- - [Function `redeem`](#@Specification_1_redeem)
- - [Function `exists_at`](#@Specification_1_exists_at)
- - [Function `address_of`](#@Specification_1_address_of)
- - [Function `take_offer`](#@Specification_1_take_offer)
-
-
-use 0x1::Collection2;
-use 0x1::Errors;
-use 0x1::Signer;
-use 0x1::Timestamp;
-
-
-
-
-
-
-## Resource `Offer`
-
-A wrapper around value offered
that can be claimed by the address stored in for
when after lock time.
-
-
-struct Offer<Offered> has key
-
-
-
-
-offered: Offered
-for: address
-time_lock: u64
-const EOFFER_DNE_FOR_ACCOUNT: u64 = 101;
-
-
-
-
-
-
-Offer is not unlocked yet.
-
-
-const EOFFER_NOT_UNLOCKED: u64 = 102;
-
-
-
-
-
-
-## Function `create`
-
-Publish a value of type Offered
under the sender's account. The value can be claimed by
-either the for
address or the transaction sender.
-
-
-public fun create<Offered: store>(account: &signer, offered: Offered, for: address, lock_period: u64)
-
-
-
-
-public fun create<Offered: store>(account: &signer, offered: Offered, for: address, lock_period: u64) {
- let time_lock = Timestamp::now_seconds() + lock_period;
- //TODO should support multi Offer?
- move_to(account, Offer<Offered> { offered, for, time_lock });
-}
-
-
-
-
-Offered
published at offer_address
.
-Only succeeds if the sender is the intended recipient stored in for
or the original
-publisher offer_address
, and now >= time_lock
-Also fails if no such value exists.
-
-
-public fun redeem<Offered: store>(account: &signer, offer_address: address): Offered
-
-
-
-
-public fun redeem<Offered: store>(account: &signer, offer_address: address): Offered acquires Offer {
- let Offer<Offered> { offered, for, time_lock } = move_from<Offer<Offered>>(offer_address);
- let sender = Signer::address_of(account);
- let now = Timestamp::now_seconds();
- assert!(sender == for || sender == offer_address, Errors::invalid_argument(EOFFER_DNE_FOR_ACCOUNT));
- assert!(now >= time_lock, Errors::not_published(EOFFER_NOT_UNLOCKED));
- offered
-}
-
-
-
-
-Offered
exists at offer_address
.
-
-
-public fun exists_at<Offered: store>(offer_address: address): bool
-
-
-
-
-public fun exists_at<Offered: store>(offer_address: address): bool {
- exists<Offer<Offered>>(offer_address)
-}
-
-
-
-
-Offered
type stored at offer_address
.
-Fails if no such Offer
exists.
-
-
-public fun address_of<Offered: store>(offer_address: address): address
-
-
-
-
-public fun address_of<Offered: store>(offer_address: address): address acquires Offer {
- borrow_global<Offer<Offered>>(offer_address).for
-}
-
-
-
-
-public(script) fun take_offer<Offered: store>(signer: signer, offer_address: address)
-
-
-
-
-public(script) fun take_offer<Offered: store>(
- signer: signer,
- offer_address: address,
-) acquires Offer {
- let offered = redeem<Offered>(&signer, offer_address);
- Collection2::put(&signer, Signer::address_of(&signer), offered);
-}
-
-
-
-
-pragma verify = true;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `create`
-
-
-public fun create<Offered: store>(account: &signer, offered: Offered, for: address, lock_period: u64)
-
-
-
-
-
-include Timestamp::AbortsIfTimestampNotExists;
-aborts_if Timestamp::now_seconds() + lock_period > max_u64();
-aborts_if exists<Offer<Offered>>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `redeem`
-
-
-public fun redeem<Offered: store>(account: &signer, offer_address: address): Offered
-
-
-
-
-
-aborts_if !exists<Offer<Offered>>(offer_address);
-aborts_if Signer::address_of(account) != global<Offer<Offered>>(offer_address).for && Signer::address_of(account) != offer_address;
-aborts_if Timestamp::now_seconds() < global<Offer<Offered>>(offer_address).time_lock;
-include Timestamp::AbortsIfTimestampNotExists;
-
-
-
-
-
-
-### Function `exists_at`
-
-
-public fun exists_at<Offered: store>(offer_address: address): bool
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `address_of`
-
-
-public fun address_of<Offered: store>(offer_address: address): address
-
-
-
-
-
-aborts_if !exists<Offer<Offered>>(offer_address);
-
-
-
-
-
-
-### Function `take_offer`
-
-
-public(script) fun take_offer<Offered: store>(signer: signer, offer_address: address)
-
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/OnChainConfigDao.md b/vm/stdlib/compiled/latest/doc/OnChainConfigDao.md
deleted file mode 100644
index 2b8e950745..0000000000
--- a/vm/stdlib/compiled/latest/doc/OnChainConfigDao.md
+++ /dev/null
@@ -1,272 +0,0 @@
-
-
-
-# Module `0x1::OnChainConfigDao`
-
-OnChainConfigDao is a DAO proposal for modify onchain configuration.
-
-
-- [Resource `WrappedConfigModifyCapability`](#0x1_OnChainConfigDao_WrappedConfigModifyCapability)
-- [Struct `OnChainConfigUpdate`](#0x1_OnChainConfigDao_OnChainConfigUpdate)
-- [Constants](#@Constants_0)
-- [Function `plugin`](#0x1_OnChainConfigDao_plugin)
-- [Function `propose_update`](#0x1_OnChainConfigDao_propose_update)
-- [Function `execute`](#0x1_OnChainConfigDao_execute)
-- [Specification](#@Specification_1)
- - [Function `plugin`](#@Specification_1_plugin)
- - [Function `propose_update`](#@Specification_1_propose_update)
- - [Function `execute`](#@Specification_1_execute)
-
-
-use 0x1::Config;
-use 0x1::Dao;
-use 0x1::Errors;
-use 0x1::Signer;
-use 0x1::Token;
-
-
-
-
-
-
-## Resource `WrappedConfigModifyCapability`
-
-A wrapper of Config::ModifyConfigCapability<ConfigT>
.
-
-
-struct WrappedConfigModifyCapability<TokenT, ConfigT: copy, drop, store> has key
-
-
-
-
-cap: Config::ModifyConfigCapability<ConfigT>
-struct OnChainConfigUpdate<ConfigT: copy, drop, store> has copy, drop, store
-
-
-
-
-value: ConfigT
-const ERR_NOT_AUTHORIZED: u64 = 401;
-
-
-
-
-
-
-## Function `plugin`
-
-Plugin method of the module.
-Should be called by token issuer.
-
-
-public fun plugin<TokenT: copy, drop, store, ConfigT: copy, drop, store>(signer: &signer)
-
-
-
-
-public fun plugin<TokenT: copy + drop + store, ConfigT: copy + drop + store>(signer: &signer) {
- let token_issuer = Token::token_address<TokenT>();
- assert!(Signer::address_of(signer) == token_issuer, Errors::requires_address(ERR_NOT_AUTHORIZED));
- let config_modify_cap = Config::extract_modify_config_capability<ConfigT>(signer);
- let cap = WrappedConfigModifyCapability<TokenT, ConfigT> { cap: config_modify_cap };
- move_to(signer, cap);
-}
-
-
-
-
-public fun propose_update<TokenT: copy, drop, store, ConfigT: copy, drop, store>(signer: &signer, new_config: ConfigT, exec_delay: u64)
-
-
-
-
-public fun propose_update<TokenT: copy + drop + store, ConfigT: copy + drop + store>(
- signer: &signer,
- new_config: ConfigT,
- exec_delay: u64,
-) {
- Dao::propose<TokenT, OnChainConfigUpdate<ConfigT>>(
- signer,
- OnChainConfigUpdate { value: new_config },
- exec_delay,
- );
-}
-
-
-
-
-proposal_id
under proposal_address
is
-the kind of this proposal module.
-
-
-public fun execute<TokenT: copy, drop, store, ConfigT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-public fun execute<TokenT: copy + drop + store, ConfigT: copy + drop + store>(
- proposer_address: address,
- proposal_id: u64,
-) acquires WrappedConfigModifyCapability {
- let OnChainConfigUpdate { value } = Dao::extract_proposal_action<
- TokenT,
- OnChainConfigUpdate<ConfigT>,
- >(proposer_address, proposal_id);
- let cap = borrow_global_mut<WrappedConfigModifyCapability<TokenT, ConfigT>>(
- Token::token_address<TokenT>(),
- );
- Config::set_with_capability(&mut cap.cap, value);
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict;
-pragma aborts_if_is_partial;
-
-
-
-
-
-
-### Function `plugin`
-
-
-public fun plugin<TokenT: copy, drop, store, ConfigT: copy, drop, store>(signer: &signer)
-
-
-
-
-
-pragma aborts_if_is_partial = false;
-let sender = Signer::address_of(signer);
-aborts_if sender != Token::SPEC_TOKEN_TEST_ADDRESS();
-include Config::AbortsIfCapNotExist<ConfigT>{account: sender};
-aborts_if exists<WrappedConfigModifyCapability<TokenT, ConfigT>>(sender);
-ensures exists<WrappedConfigModifyCapability<TokenT, ConfigT>>(sender);
-
-
-
-
-
-
-### Function `propose_update`
-
-
-public fun propose_update<TokenT: copy, drop, store, ConfigT: copy, drop, store>(signer: &signer, new_config: ConfigT, exec_delay: u64)
-
-
-
-
-
-pragma aborts_if_is_partial = false;
-include Dao::AbortIfDaoConfigNotExist<TokenT>;
-include Dao::AbortIfDaoInfoNotExist<TokenT>;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if exec_delay > 0 && exec_delay < Dao::spec_dao_config<TokenT>().min_action_delay;
-include Dao::CheckQuorumVotes<TokenT>;
-let sender = Signer::address_of(signer);
-aborts_if exists<Dao::Proposal<TokenT, OnChainConfigUpdate<ConfigT>>>(sender);
-
-
-
-
-
-
-### Function `execute`
-
-
-public fun execute<TokenT: copy, drop, store, ConfigT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-
-pragma aborts_if_is_partial = true;
-let expected_states = vec<u8>(6);
-include Dao::CheckProposalStates<TokenT, OnChainConfigUpdate<ConfigT>>{expected_states};
-aborts_if !exists<WrappedConfigModifyCapability<TokenT, ConfigT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-
diff --git a/vm/stdlib/compiled/latest/doc/OnChainConfigScripts.md b/vm/stdlib/compiled/latest/doc/OnChainConfigScripts.md
deleted file mode 100644
index d711a56594..0000000000
--- a/vm/stdlib/compiled/latest/doc/OnChainConfigScripts.md
+++ /dev/null
@@ -1,422 +0,0 @@
-
-
-
-# Module `0x1::OnChainConfigScripts`
-
-
-
-- [Function `propose_update_consensus_config`](#0x1_OnChainConfigScripts_propose_update_consensus_config)
-- [Function `propose_update_reward_config`](#0x1_OnChainConfigScripts_propose_update_reward_config)
-- [Function `propose_update_txn_publish_option`](#0x1_OnChainConfigScripts_propose_update_txn_publish_option)
-- [Function `propose_update_txn_timeout_config`](#0x1_OnChainConfigScripts_propose_update_txn_timeout_config)
-- [Function `propose_update_vm_config`](#0x1_OnChainConfigScripts_propose_update_vm_config)
-- [Function `propose_update_move_language_version`](#0x1_OnChainConfigScripts_propose_update_move_language_version)
-- [Function `execute_on_chain_config_proposal`](#0x1_OnChainConfigScripts_execute_on_chain_config_proposal)
-- [Function `execute_on_chain_config_proposal_v2`](#0x1_OnChainConfigScripts_execute_on_chain_config_proposal_v2)
-- [Specification](#@Specification_0)
- - [Function `propose_update_consensus_config`](#@Specification_0_propose_update_consensus_config)
- - [Function `propose_update_reward_config`](#@Specification_0_propose_update_reward_config)
- - [Function `propose_update_txn_publish_option`](#@Specification_0_propose_update_txn_publish_option)
- - [Function `propose_update_txn_timeout_config`](#@Specification_0_propose_update_txn_timeout_config)
- - [Function `propose_update_vm_config`](#@Specification_0_propose_update_vm_config)
- - [Function `propose_update_move_language_version`](#@Specification_0_propose_update_move_language_version)
- - [Function `execute_on_chain_config_proposal`](#@Specification_0_execute_on_chain_config_proposal)
- - [Function `execute_on_chain_config_proposal_v2`](#@Specification_0_execute_on_chain_config_proposal_v2)
-
-
-use 0x1::ConsensusConfig;
-use 0x1::LanguageVersion;
-use 0x1::OnChainConfigDao;
-use 0x1::RewardConfig;
-use 0x1::STC;
-use 0x1::Signer;
-use 0x1::TransactionPublishOption;
-use 0x1::TransactionTimeoutConfig;
-use 0x1::VMConfig;
-
-
-
-
-
-
-## Function `propose_update_consensus_config`
-
-
-
-public(script) fun propose_update_consensus_config(account: signer, uncle_rate_target: u64, base_block_time_target: u64, base_reward_per_block: u128, base_reward_per_uncle_percent: u64, epoch_block_count: u64, base_block_difficulty_window: u64, min_block_time_target: u64, max_block_time_target: u64, base_max_uncles_per_block: u64, base_block_gas_limit: u64, strategy: u8, exec_delay: u64)
-
-
-
-
-public ( script ) fun propose_update_consensus_config(account: signer,
- uncle_rate_target: u64,
- base_block_time_target: u64,
- base_reward_per_block: u128,
- base_reward_per_uncle_percent: u64,
- epoch_block_count: u64,
- base_block_difficulty_window: u64,
- min_block_time_target: u64,
- max_block_time_target: u64,
- base_max_uncles_per_block: u64,
- base_block_gas_limit: u64,
- strategy: u8,
- exec_delay: u64) {
- let consensus_config = ConsensusConfig::new_consensus_config(uncle_rate_target,
- base_block_time_target,
- base_reward_per_block,
- base_reward_per_uncle_percent,
- epoch_block_count,
- base_block_difficulty_window,
- min_block_time_target,
- max_block_time_target,
- base_max_uncles_per_block,
- base_block_gas_limit,
- strategy);
- OnChainConfigDao::propose_update<STC::STC, ConsensusConfig::ConsensusConfig>(&account, consensus_config, exec_delay);
-}
-
-
-
-
-public(script) fun propose_update_reward_config(account: signer, reward_delay: u64, exec_delay: u64)
-
-
-
-
-public ( script ) fun propose_update_reward_config(account: signer,
- reward_delay: u64,
- exec_delay: u64) {
- let reward_config = RewardConfig::new_reward_config(reward_delay);
- OnChainConfigDao::propose_update<STC::STC, RewardConfig::RewardConfig>(&account, reward_config, exec_delay);
-}
-
-
-
-
-public(script) fun propose_update_txn_publish_option(account: signer, script_allowed: bool, module_publishing_allowed: bool, exec_delay: u64)
-
-
-
-
-public ( script ) fun propose_update_txn_publish_option(account: signer,
- script_allowed: bool,
- module_publishing_allowed: bool,
- exec_delay: u64) {
- let txn_publish_option = TransactionPublishOption::new_transaction_publish_option(script_allowed, module_publishing_allowed);
- OnChainConfigDao::propose_update<STC::STC, TransactionPublishOption::TransactionPublishOption>(&account, txn_publish_option, exec_delay);
-}
-
-
-
-
-public(script) fun propose_update_txn_timeout_config(account: signer, duration_seconds: u64, exec_delay: u64)
-
-
-
-
-public ( script ) fun propose_update_txn_timeout_config(account: signer,
- duration_seconds: u64,
- exec_delay: u64) {
- let txn_timeout_config = TransactionTimeoutConfig::new_transaction_timeout_config(duration_seconds);
- OnChainConfigDao::propose_update<STC::STC, TransactionTimeoutConfig::TransactionTimeoutConfig>(&account, txn_timeout_config, exec_delay);
-}
-
-
-
-
-public(script) fun propose_update_vm_config(account: signer, instruction_schedule: vector<u8>, native_schedule: vector<u8>, global_memory_per_byte_cost: u64, global_memory_per_byte_write_cost: u64, min_transaction_gas_units: u64, large_transaction_cutoff: u64, instrinsic_gas_per_byte: u64, maximum_number_of_gas_units: u64, min_price_per_gas_unit: u64, max_price_per_gas_unit: u64, max_transaction_size_in_bytes: u64, gas_unit_scaling_factor: u64, default_account_size: u64, exec_delay: u64)
-
-
-
-
-public ( script ) fun propose_update_vm_config(account: signer,
- instruction_schedule: vector<u8>,
- native_schedule: vector<u8>,
- global_memory_per_byte_cost: u64,
- global_memory_per_byte_write_cost: u64,
- min_transaction_gas_units: u64,
- large_transaction_cutoff: u64,
- instrinsic_gas_per_byte: u64,
- maximum_number_of_gas_units: u64,
- min_price_per_gas_unit: u64,
- max_price_per_gas_unit: u64,
- max_transaction_size_in_bytes: u64,
- gas_unit_scaling_factor: u64,
- default_account_size: u64,
- exec_delay: u64, ) {
- let vm_config = VMConfig::new_vm_config(instruction_schedule,
- native_schedule,
- global_memory_per_byte_cost,
- global_memory_per_byte_write_cost,
- min_transaction_gas_units,
- large_transaction_cutoff,
- instrinsic_gas_per_byte,
- maximum_number_of_gas_units,
- min_price_per_gas_unit,
- max_price_per_gas_unit,
- max_transaction_size_in_bytes,
- gas_unit_scaling_factor,
- default_account_size);
- OnChainConfigDao::propose_update<STC::STC, VMConfig::VMConfig>(&account, vm_config, exec_delay);
-}
-
-
-
-
-public(script) fun propose_update_move_language_version(account: signer, new_version: u64, exec_delay: u64)
-
-
-
-
-public(script) fun propose_update_move_language_version(account: signer, new_version: u64, exec_delay: u64) {
- let lang_version = LanguageVersion::new(new_version);
- OnChainConfigDao::propose_update<STC::STC, LanguageVersion::LanguageVersion>(&account, lang_version, exec_delay);
-}
-
-
-
-
-public(script) fun execute_on_chain_config_proposal<ConfigT: copy, drop, store>(account: signer, proposal_id: u64)
-
-
-
-
-public ( script ) fun execute_on_chain_config_proposal<ConfigT: copy + drop + store>(account: signer, proposal_id: u64) {
- OnChainConfigDao::execute<STC::STC, ConfigT>(Signer::address_of(&account), proposal_id);
-}
-
-
-
-
-public(script) fun execute_on_chain_config_proposal_v2<TokenType: copy, drop, store, ConfigT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-public(script) fun execute_on_chain_config_proposal_v2<TokenType: copy + drop + store, ConfigT: copy + drop + store>(proposer_address: address, proposal_id: u64) {
- OnChainConfigDao::execute<TokenType, ConfigT>(proposer_address, proposal_id);
-}
-
-
-
-
-public(script) fun propose_update_consensus_config(account: signer, uncle_rate_target: u64, base_block_time_target: u64, base_reward_per_block: u128, base_reward_per_uncle_percent: u64, epoch_block_count: u64, base_block_difficulty_window: u64, min_block_time_target: u64, max_block_time_target: u64, base_max_uncles_per_block: u64, base_block_gas_limit: u64, strategy: u8, exec_delay: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `propose_update_reward_config`
-
-
-public(script) fun propose_update_reward_config(account: signer, reward_delay: u64, exec_delay: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `propose_update_txn_publish_option`
-
-
-public(script) fun propose_update_txn_publish_option(account: signer, script_allowed: bool, module_publishing_allowed: bool, exec_delay: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `propose_update_txn_timeout_config`
-
-
-public(script) fun propose_update_txn_timeout_config(account: signer, duration_seconds: u64, exec_delay: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `propose_update_vm_config`
-
-
-public(script) fun propose_update_vm_config(account: signer, instruction_schedule: vector<u8>, native_schedule: vector<u8>, global_memory_per_byte_cost: u64, global_memory_per_byte_write_cost: u64, min_transaction_gas_units: u64, large_transaction_cutoff: u64, instrinsic_gas_per_byte: u64, maximum_number_of_gas_units: u64, min_price_per_gas_unit: u64, max_price_per_gas_unit: u64, max_transaction_size_in_bytes: u64, gas_unit_scaling_factor: u64, default_account_size: u64, exec_delay: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `propose_update_move_language_version`
-
-
-public(script) fun propose_update_move_language_version(account: signer, new_version: u64, exec_delay: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `execute_on_chain_config_proposal`
-
-
-public(script) fun execute_on_chain_config_proposal<ConfigT: copy, drop, store>(account: signer, proposal_id: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `execute_on_chain_config_proposal_v2`
-
-
-public(script) fun execute_on_chain_config_proposal_v2<TokenType: copy, drop, store, ConfigT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/Option.md b/vm/stdlib/compiled/latest/doc/Option.md
deleted file mode 100644
index 5e77798db5..0000000000
--- a/vm/stdlib/compiled/latest/doc/Option.md
+++ /dev/null
@@ -1,877 +0,0 @@
-
-
-
-# Module `0x1::Option`
-
-This module defines the Option type and its methods to represent and handle an optional value.
-
-
-- [Struct `Option`](#0x1_Option_Option)
-- [Constants](#@Constants_0)
-- [Function `none`](#0x1_Option_none)
-- [Function `some`](#0x1_Option_some)
-- [Function `is_none`](#0x1_Option_is_none)
-- [Function `is_some`](#0x1_Option_is_some)
-- [Function `contains`](#0x1_Option_contains)
-- [Function `borrow`](#0x1_Option_borrow)
-- [Function `borrow_with_default`](#0x1_Option_borrow_with_default)
-- [Function `get_with_default`](#0x1_Option_get_with_default)
-- [Function `fill`](#0x1_Option_fill)
-- [Function `extract`](#0x1_Option_extract)
-- [Function `borrow_mut`](#0x1_Option_borrow_mut)
-- [Function `swap`](#0x1_Option_swap)
-- [Function `destroy_with_default`](#0x1_Option_destroy_with_default)
-- [Function `destroy_some`](#0x1_Option_destroy_some)
-- [Function `destroy_none`](#0x1_Option_destroy_none)
-- [Specification](#@Specification_1)
- - [Helper Schema](#@Helper_Schema_2)
- - [Struct `Option`](#@Specification_1_Option)
- - [Function `none`](#@Specification_1_none)
- - [Function `some`](#@Specification_1_some)
- - [Function `is_none`](#@Specification_1_is_none)
- - [Function `is_some`](#@Specification_1_is_some)
- - [Function `contains`](#@Specification_1_contains)
- - [Function `borrow`](#@Specification_1_borrow)
- - [Function `borrow_with_default`](#@Specification_1_borrow_with_default)
- - [Function `get_with_default`](#@Specification_1_get_with_default)
- - [Function `fill`](#@Specification_1_fill)
- - [Function `extract`](#@Specification_1_extract)
- - [Function `borrow_mut`](#@Specification_1_borrow_mut)
- - [Function `swap`](#@Specification_1_swap)
- - [Function `destroy_with_default`](#@Specification_1_destroy_with_default)
- - [Function `destroy_some`](#@Specification_1_destroy_some)
- - [Function `destroy_none`](#@Specification_1_destroy_none)
-
-
-use 0x1::Errors;
-use 0x1::Vector;
-
-
-
-
-
-
-## Struct `Option`
-
-Abstraction of a value that may or may not be present. Implemented with a vector of size
-zero or one because Move bytecode does not have ADTs.
-
-
-struct Option<Element> has copy, drop, store
-
-
-
-
-vec: vector<Element>
-Option
is in an invalid state for the operation attempted.
-The Option
is Some
while it should be None
.
-
-
-const EOPTION_IS_SET: u64 = 0;
-
-
-
-
-
-
-The Option
is in an invalid state for the operation attempted.
-The Option
is None
while it should be Some
.
-
-
-const EOPTION_NOT_SET: u64 = 1;
-
-
-
-
-
-
-## Function `none`
-
-Return an empty Option
-
-
-public fun none<Element>(): Option::Option<Element>
-
-
-
-
-public fun none<Element>(): Option<Element> {
- Option { vec: Vector::empty() }
-}
-
-
-
-
-Option
containing e
-
-
-public fun some<Element>(e: Element): Option::Option<Element>
-
-
-
-
-public fun some<Element>(e: Element): Option<Element> {
- Option { vec: Vector::singleton(e) }
-}
-
-
-
-
-t
does not hold a value
-
-
-public fun is_none<Element>(t: &Option::Option<Element>): bool
-
-
-
-
-public fun is_none<Element>(t: &Option<Element>): bool {
- Vector::is_empty(&t.vec)
-}
-
-
-
-
-t
holds a value
-
-
-public fun is_some<Element>(t: &Option::Option<Element>): bool
-
-
-
-
-public fun is_some<Element>(t: &Option<Element>): bool {
- !Vector::is_empty(&t.vec)
-}
-
-
-
-
-t
is equal to e_ref
-Always returns false
if t
does not hold a value
-
-
-public fun contains<Element>(t: &Option::Option<Element>, e_ref: &Element): bool
-
-
-
-
-public fun contains<Element>(t: &Option<Element>, e_ref: &Element): bool {
- Vector::contains(&t.vec, e_ref)
-}
-
-
-
-
-t
-Aborts if t
does not hold a value
-
-
-public fun borrow<Element>(t: &Option::Option<Element>): &Element
-
-
-
-
-public fun borrow<Element>(t: &Option<Element>): &Element {
- assert!(is_some(t), Errors::invalid_argument(EOPTION_NOT_SET));
- Vector::borrow(&t.vec, 0)
-}
-
-
-
-
-t
if it holds one
-Return default_ref
if t
does not hold a value
-
-
-public fun borrow_with_default<Element>(t: &Option::Option<Element>, default_ref: &Element): &Element
-
-
-
-
-public fun borrow_with_default<Element>(t: &Option<Element>, default_ref: &Element): &Element {
- let vec_ref = &t.vec;
- if (Vector::is_empty(vec_ref)) default_ref
- else Vector::borrow(vec_ref, 0)
-}
-
-
-
-
-t
if it holds one
-Return default
if t
does not hold a value
-
-
-public fun get_with_default<Element: copy, drop>(t: &Option::Option<Element>, default: Element): Element
-
-
-
-
-public fun get_with_default<Element: copy + drop>(
- t: &Option<Element>,
- default: Element,
-): Element {
- let vec_ref = &t.vec;
- if (Vector::is_empty(vec_ref)) default
- else *Vector::borrow(vec_ref, 0)
-}
-
-
-
-
-t
to a some option by adding e
.
-Aborts if t
already holds a value
-
-
-public fun fill<Element>(t: &mut Option::Option<Element>, e: Element)
-
-
-
-
-public fun fill<Element>(t: &mut Option<Element>, e: Element) {
- let vec_ref = &mut t.vec;
- if (Vector::is_empty(vec_ref)) Vector::push_back(vec_ref, e)
- else abort Errors::invalid_argument(EOPTION_IS_SET)
-}
-
-
-
-
-some
option to a none
by removing and returning the value stored inside t
-Aborts if t
does not hold a value
-
-
-public fun extract<Element>(t: &mut Option::Option<Element>): Element
-
-
-
-
-public fun extract<Element>(t: &mut Option<Element>): Element {
- assert!(is_some(t), Errors::invalid_argument(EOPTION_NOT_SET));
- Vector::pop_back(&mut t.vec)
-}
-
-
-
-
-t
-Aborts if t
does not hold a value
-
-
-public fun borrow_mut<Element>(t: &mut Option::Option<Element>): &mut Element
-
-
-
-
-public fun borrow_mut<Element>(t: &mut Option<Element>): &mut Element {
- assert!(is_some(t), Errors::invalid_argument(EOPTION_NOT_SET));
- Vector::borrow_mut(&mut t.vec, 0)
-}
-
-
-
-
-t
with e
and return the old value
-Aborts if t
does not hold a value
-
-
-public fun swap<Element>(t: &mut Option::Option<Element>, e: Element): Element
-
-
-
-
-public fun swap<Element>(t: &mut Option<Element>, e: Element): Element {
- assert!(is_some(t), Errors::invalid_argument(EOPTION_NOT_SET));
- let vec_ref = &mut t.vec;
- let old_value = Vector::pop_back(vec_ref);
- Vector::push_back(vec_ref, e);
- old_value
-}
-
-
-
-
-t.
If t
holds a value, return it. Returns default
otherwise
-
-
-public fun destroy_with_default<Element: drop>(t: Option::Option<Element>, default: Element): Element
-
-
-
-
-public fun destroy_with_default<Element: drop>(t: Option<Element>, default: Element): Element {
- let Option { vec } = t;
- if (Vector::is_empty(&mut vec)) default
- else Vector::pop_back(&mut vec)
-}
-
-
-
-
-t
and return its contents
-Aborts if t
does not hold a value
-
-
-public fun destroy_some<Element>(t: Option::Option<Element>): Element
-
-
-
-
-public fun destroy_some<Element>(t: Option<Element>): Element {
- assert!(is_some(&t), Errors::invalid_argument(EOPTION_NOT_SET));
- let Option { vec } = t;
- let elem = Vector::pop_back(&mut vec);
- Vector::destroy_empty(vec);
- elem
-}
-
-
-
-
-t
-Aborts if t
holds a value
-
-
-public fun destroy_none<Element>(t: Option::Option<Element>)
-
-
-
-
-public fun destroy_none<Element>(t: Option<Element>) {
- assert!(is_none(&t), Errors::invalid_argument(EOPTION_IS_SET));
- let Option { vec } = t;
- Vector::destroy_empty(vec)
-}
-
-
-
-
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Helper Schema
-
-
-
-
-
-
-schema AbortsIfNone<Element> {
- t: Option<Element>;
- aborts_if is_none(t) with Errors::INVALID_ARGUMENT;
-}
-
-
-
-
-
-
-### Struct `Option`
-
-
-struct Option<Element> has copy, drop, store
-
-
-
-
-vec: vector<Element>
-invariant len(vec) <= 1;
-
-
-
-
-
-
-### Function `none`
-
-
-public fun none<Element>(): Option::Option<Element>
-
-
-
-
-
-pragma opaque;
-aborts_if false;
-ensures result == spec_none<Element>();
-
-
-
-
-
-
-
-
-fun spec_none<Element>(): Option<Element> {
- Option{ vec: vec() }
-}
-
-
-
-
-
-
-### Function `some`
-
-
-public fun some<Element>(e: Element): Option::Option<Element>
-
-
-
-
-
-pragma opaque;
-aborts_if false;
-ensures result == spec_some(e);
-
-
-
-
-
-
-
-
-fun spec_some<Element>(e: Element): Option<Element> {
- Option{ vec: vec(e) }
-}
-
-
-
-
-
-
-### Function `is_none`
-
-
-public fun is_none<Element>(t: &Option::Option<Element>): bool
-
-
-
-
-
-pragma opaque;
-aborts_if false;
-ensures result == is_none(t);
-
-
-
-
-
-
-### Function `is_some`
-
-
-public fun is_some<Element>(t: &Option::Option<Element>): bool
-
-
-
-
-
-pragma opaque;
-aborts_if false;
-ensures result == is_some(t);
-
-
-
-
-
-
-### Function `contains`
-
-
-public fun contains<Element>(t: &Option::Option<Element>, e_ref: &Element): bool
-
-
-
-
-
-pragma opaque;
-aborts_if false;
-ensures result == spec_contains(t, e_ref);
-
-
-
-
-
-
-
-
-fun spec_contains<Element>(t: Option<Element>, e: Element): bool {
- is_some(t) && borrow(t) == e
-}
-
-
-
-
-
-
-### Function `borrow`
-
-
-public fun borrow<Element>(t: &Option::Option<Element>): &Element
-
-
-
-
-
-pragma opaque;
-include AbortsIfNone<Element>;
-ensures result == borrow(t);
-
-
-
-
-
-
-### Function `borrow_with_default`
-
-
-public fun borrow_with_default<Element>(t: &Option::Option<Element>, default_ref: &Element): &Element
-
-
-
-
-
-pragma opaque;
-aborts_if false;
-ensures result == (if (is_some(t)) borrow(t) else default_ref);
-
-
-
-
-
-
-### Function `get_with_default`
-
-
-public fun get_with_default<Element: copy, drop>(t: &Option::Option<Element>, default: Element): Element
-
-
-
-
-
-pragma opaque;
-aborts_if false;
-ensures result == (if (is_some(t)) borrow(t) else default);
-
-
-
-
-
-
-### Function `fill`
-
-
-public fun fill<Element>(t: &mut Option::Option<Element>, e: Element)
-
-
-
-
-
-pragma opaque;
-aborts_if is_some(t) with Errors::INVALID_ARGUMENT;
-ensures is_some(t);
-ensures borrow(t) == e;
-
-
-
-
-
-
-### Function `extract`
-
-
-public fun extract<Element>(t: &mut Option::Option<Element>): Element
-
-
-
-
-
-pragma opaque;
-include AbortsIfNone<Element>;
-ensures result == borrow(old(t));
-ensures is_none(t);
-
-
-
-
-
-
-### Function `borrow_mut`
-
-
-public fun borrow_mut<Element>(t: &mut Option::Option<Element>): &mut Element
-
-
-
-
-
-pragma opaque;
-include AbortsIfNone<Element>;
-ensures result == borrow(t);
-
-
-
-
-
-
-### Function `swap`
-
-
-public fun swap<Element>(t: &mut Option::Option<Element>, e: Element): Element
-
-
-
-
-
-pragma opaque;
-include AbortsIfNone<Element>;
-ensures result == borrow(old(t));
-ensures is_some(t);
-ensures borrow(t) == e;
-
-
-
-
-
-
-### Function `destroy_with_default`
-
-
-public fun destroy_with_default<Element: drop>(t: Option::Option<Element>, default: Element): Element
-
-
-
-
-
-pragma opaque;
-aborts_if false;
-ensures result == (if (is_some(t)) borrow(t) else default);
-
-
-
-
-
-
-### Function `destroy_some`
-
-
-public fun destroy_some<Element>(t: Option::Option<Element>): Element
-
-
-
-
-
-pragma opaque;
-include AbortsIfNone<Element>;
-ensures result == borrow(t);
-
-
-
-
-
-
-### Function `destroy_none`
-
-
-public fun destroy_none<Element>(t: Option::Option<Element>)
-
-
-
-
-
-pragma opaque;
-aborts_if is_some(t) with Errors::INVALID_ARGUMENT;
-
diff --git a/vm/stdlib/compiled/latest/doc/Oracle.md b/vm/stdlib/compiled/latest/doc/Oracle.md
deleted file mode 100644
index e2f92fa4e0..0000000000
--- a/vm/stdlib/compiled/latest/doc/Oracle.md
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-# Module `0x1::PriceOracleScripts`
-
-
-
-- [Function `register_oracle`](#0x1_PriceOracleScripts_register_oracle)
-- [Function `init_data_source`](#0x1_PriceOracleScripts_init_data_source)
-- [Function `update`](#0x1_PriceOracleScripts_update)
-
-
-use 0x1::PriceOracle;
-
-
-
-
-
-
-## Function `register_oracle`
-
-
-
-public(script) fun register_oracle<OracleT: copy, drop, store>(sender: signer, precision: u8)
-
-
-
-
-public(script) fun register_oracle<OracleT: copy+store+drop>(sender: signer, precision: u8){
- PriceOracle::register_oracle<OracleT>(&sender, precision)
-}
-
-
-
-
-public(script) fun init_data_source<OracleT: copy, drop, store>(sender: signer, init_value: u128)
-
-
-
-
-public(script) fun init_data_source<OracleT: copy+store+drop>(sender: signer, init_value: u128){
- PriceOracle::init_data_source<OracleT>(&sender, init_value);
-}
-
-
-
-
-public(script) fun update<OracleT: copy, drop, store>(sender: signer, value: u128)
-
-
-
-
-public(script) fun update<OracleT: copy+store+drop>(sender: signer, value: u128){
- PriceOracle::update<OracleT>(&sender, value);
-}
-
-
-
-
-use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::Errors;
-use 0x1::Event;
-use 0x1::Option;
-use 0x1::Signer;
-use 0x1::Timestamp;
-use 0x1::Version;
-
-
-
-
-
-
-## Struct `UpgradePlan`
-
-module upgrade plan
-
-
-struct UpgradePlan has copy, drop, store
-
-
-
-
-package_hash: vector<u8>
-active_after_time: u64
-version: u64
-struct UpgradePlanCapability has store, key
-
-
-
-
-account_address: address
-struct UpgradePlanV2 has copy, drop, store
-
-
-
-
-package_hash: vector<u8>
-active_after_time: u64
-version: u64
-enforced: bool
-struct ModuleUpgradeStrategy has store, key
-
-
-
-
-strategy: u8
-struct TwoPhaseUpgrade has key
-
-
-
-
-config: PackageTxnManager::TwoPhaseUpgradeConfig
-plan: Option::Option<PackageTxnManager::UpgradePlan>
-version_cap: Config::ModifyConfigCapability<Version::Version>
-upgrade_event: Event::EventHandle<PackageTxnManager::UpgradeEvent>
-struct TwoPhaseUpgradeConfig has copy, drop, store
-
-
-
-
-min_time_limit: u64
-struct TwoPhaseUpgradeV2 has key
-
-
-
-
-config: PackageTxnManager::TwoPhaseUpgradeConfig
-plan: Option::Option<PackageTxnManager::UpgradePlanV2>
-version_cap: Config::ModifyConfigCapability<Version::Version>
-upgrade_event: Event::EventHandle<PackageTxnManager::UpgradeEvent>
-struct UpgradeEvent has drop, store
-
-
-
-
-package_address: address
-package_hash: vector<u8>
-version: u64
-const DEFAULT_MIN_TIME_LIMIT: u64 = 86400000;
-
-
-
-
-
-
-
-
-const EACTIVE_TIME_INCORRECT: u64 = 104;
-
-
-
-
-
-
-
-
-const EPACKAGE_HASH_INCORRECT: u64 = 103;
-
-
-
-
-
-
-
-
-const ESENDER_AND_PACKAGE_ADDRESS_MISMATCH: u64 = 109;
-
-
-
-
-
-
-
-
-const ESTRATEGY_FREEZED: u64 = 105;
-
-
-
-
-
-
-
-
-const ESTRATEGY_INCORRECT: u64 = 106;
-
-
-
-
-
-
-
-
-const ESTRATEGY_NOT_TWO_PHASE: u64 = 107;
-
-
-
-
-
-
-
-
-const EUNKNOWN_STRATEGY: u64 = 108;
-
-
-
-
-
-
-
-
-const EUPGRADE_PLAN_IS_NONE: u64 = 102;
-
-
-
-
-
-
-
-
-const STRATEGY_ARBITRARY: u8 = 0;
-
-
-
-
-
-
-
-
-const STRATEGY_FREEZE: u8 = 3;
-
-
-
-
-
-
-
-
-const STRATEGY_NEW_MODULE: u8 = 2;
-
-
-
-
-
-
-
-
-const STRATEGY_TWO_PHASE: u8 = 1;
-
-
-
-
-
-
-## Function `get_strategy_arbitrary`
-
-arbitary stragegy
-
-
-public fun get_strategy_arbitrary(): u8
-
-
-
-
-public fun get_strategy_arbitrary(): u8 { STRATEGY_ARBITRARY }
-
-
-
-
-public fun get_strategy_two_phase(): u8
-
-
-
-
-public fun get_strategy_two_phase(): u8 { STRATEGY_TWO_PHASE }
-
-
-
-
-public fun get_strategy_new_module(): u8
-
-
-
-
-public fun get_strategy_new_module(): u8 { STRATEGY_NEW_MODULE }
-
-
-
-
-public fun get_strategy_freeze(): u8
-
-
-
-
-public fun get_strategy_freeze(): u8 { STRATEGY_FREEZE }
-
-
-
-
-public fun get_default_min_time_limit(): u64
-
-
-
-
-public fun get_default_min_time_limit(): u64 { DEFAULT_MIN_TIME_LIMIT }
-
-
-
-
-public fun update_module_upgrade_strategy(account: &signer, strategy: u8, min_time: Option::Option<u64>)
-
-
-
-
-public fun update_module_upgrade_strategy(account: &signer, strategy: u8, min_time: Option<u64>) acquires ModuleUpgradeStrategy, TwoPhaseUpgrade, TwoPhaseUpgradeV2, UpgradePlanCapability{
- assert!(strategy == STRATEGY_ARBITRARY || strategy == STRATEGY_TWO_PHASE || strategy == STRATEGY_NEW_MODULE || strategy == STRATEGY_FREEZE, Errors::invalid_argument(EUNKNOWN_STRATEGY));
- let account_address = Signer::address_of(account);
- let previous_strategy = get_module_upgrade_strategy(account_address);
- assert!(strategy > previous_strategy, Errors::invalid_argument(ESTRATEGY_INCORRECT));
- if (exists<ModuleUpgradeStrategy>(account_address)) {
- borrow_global_mut<ModuleUpgradeStrategy>(account_address).strategy = strategy;
- }else{
- move_to(account, ModuleUpgradeStrategy{ strategy: strategy});
- };
- if (strategy == STRATEGY_TWO_PHASE){
- let version_cap = Config::extract_modify_config_capability<Version::Version>(account);
- let min_time_limit = Option::get_with_default(&min_time, DEFAULT_MIN_TIME_LIMIT);
- move_to(account, UpgradePlanCapability{ account_address: account_address});
- move_to(account, TwoPhaseUpgradeV2{
- config: TwoPhaseUpgradeConfig{min_time_limit: min_time_limit},
- plan: Option::none<UpgradePlanV2>(),
- version_cap: version_cap,
- upgrade_event: Event::new_event_handle<Self::UpgradeEvent>(account)}
- );
- };
- //clean two phase upgrade resource
- if (previous_strategy == STRATEGY_TWO_PHASE){
- if (exists<TwoPhaseUpgrade>(account_address)) {
- let tpu = move_from<TwoPhaseUpgrade>(account_address);
- let TwoPhaseUpgrade{plan:_, version_cap, upgrade_event, config: _} = tpu;
- Event::destroy_handle<Self::UpgradeEvent>(upgrade_event);
- Config::destroy_modify_config_capability<Version::Version>(version_cap);
- };
- if (exists<TwoPhaseUpgradeV2>(account_address)) {
- let tpu = move_from<TwoPhaseUpgradeV2>(account_address);
- let TwoPhaseUpgradeV2{plan:_, version_cap, upgrade_event, config: _} = tpu;
- Event::destroy_handle<Self::UpgradeEvent>(upgrade_event);
- Config::destroy_modify_config_capability<Version::Version>(version_cap);
- };
- // UpgradePlanCapability may be extracted
- if (exists<UpgradePlanCapability>(account_address)) {
- let cap = move_from<UpgradePlanCapability>(account_address);
- destroy_upgrade_plan_cap(cap);
- };
- };
-}
-
-
-
-
-public fun account_address(cap: &PackageTxnManager::UpgradePlanCapability): address
-
-
-
-
-public fun account_address(cap: &UpgradePlanCapability): address {
- cap.account_address
-}
-
-
-
-
-public fun destroy_upgrade_plan_cap(cap: PackageTxnManager::UpgradePlanCapability)
-
-
-
-
-public fun destroy_upgrade_plan_cap(cap: UpgradePlanCapability){
- let UpgradePlanCapability{account_address:_} = cap;
-}
-
-
-
-
-signer
.
-
-
-public fun extract_submit_upgrade_plan_cap(account: &signer): PackageTxnManager::UpgradePlanCapability
-
-
-
-
-public fun extract_submit_upgrade_plan_cap(account: &signer): UpgradePlanCapability acquires ModuleUpgradeStrategy, UpgradePlanCapability{
- let account_address = Signer::address_of(account);
- assert!(get_module_upgrade_strategy(account_address) == STRATEGY_TWO_PHASE, Errors::invalid_argument(ESTRATEGY_NOT_TWO_PHASE));
- move_from<UpgradePlanCapability>(account_address)
-}
-
-
-
-
-public(script) fun convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2(account: signer, package_address: address)
-
-
-
-
-public(script) fun convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2(account: signer, package_address: address) acquires TwoPhaseUpgrade {
- let account_address = Signer::address_of(&account);
- // sender should be package owner
- assert!(account_address == package_address, Errors::requires_address(ESENDER_AND_PACKAGE_ADDRESS_MISMATCH));
- let tpu = move_from<TwoPhaseUpgrade>(account_address);
- let TwoPhaseUpgrade{config, plan, version_cap, upgrade_event} = tpu;
- if (Option::is_some(&plan)) {
- let old_plan = Option::borrow(&plan);
- move_to(&account, TwoPhaseUpgradeV2{
- config: config,
- plan: Option::some(UpgradePlanV2 {
- package_hash: *&old_plan.package_hash,
- active_after_time: old_plan.active_after_time,
- version: old_plan.version,
- enforced: false }),
- version_cap: version_cap,
- upgrade_event: upgrade_event
- });
- } else {
- move_to(&account, TwoPhaseUpgradeV2{
- config: config,
- plan: Option::none<UpgradePlanV2>(),
- version_cap: version_cap,
- upgrade_event: upgrade_event
- });
- };
-}
-
-
-
-
-public fun submit_upgrade_plan_v2(account: &signer, package_hash: vector<u8>, version: u64, enforced: bool)
-
-
-
-
-public fun submit_upgrade_plan_v2(account: &signer, package_hash: vector<u8>, version:u64, enforced: bool) acquires TwoPhaseUpgradeV2,UpgradePlanCapability,ModuleUpgradeStrategy{
- let account_address = Signer::address_of(account);
- let cap = borrow_global<UpgradePlanCapability>(account_address);
- submit_upgrade_plan_with_cap_v2(cap, package_hash, version, enforced);
-}
-
-
-
-
-public fun submit_upgrade_plan_with_cap_v2(cap: &PackageTxnManager::UpgradePlanCapability, package_hash: vector<u8>, version: u64, enforced: bool)
-
-
-
-
-public fun submit_upgrade_plan_with_cap_v2(cap: &UpgradePlanCapability, package_hash: vector<u8>, version: u64, enforced: bool) acquires TwoPhaseUpgradeV2,ModuleUpgradeStrategy{
- let package_address = cap.account_address;
- assert!(get_module_upgrade_strategy(package_address) == STRATEGY_TWO_PHASE, Errors::invalid_argument(ESTRATEGY_NOT_TWO_PHASE));
- let tpu = borrow_global_mut<TwoPhaseUpgradeV2>(package_address);
- let active_after_time = Timestamp::now_milliseconds() + tpu.config.min_time_limit;
- tpu.plan = Option::some(UpgradePlanV2 { package_hash, active_after_time, version, enforced });
-}
-
-
-
-
-public fun cancel_upgrade_plan(account: &signer)
-
-
-
-
-public fun cancel_upgrade_plan(account: &signer) acquires TwoPhaseUpgradeV2,UpgradePlanCapability,ModuleUpgradeStrategy{
- let account_address = Signer::address_of(account);
- let cap = borrow_global<UpgradePlanCapability>(account_address);
- cancel_upgrade_plan_with_cap(cap);
-}
-
-
-
-
-public fun cancel_upgrade_plan_with_cap(cap: &PackageTxnManager::UpgradePlanCapability)
-
-
-
-
-public fun cancel_upgrade_plan_with_cap(cap: &UpgradePlanCapability) acquires TwoPhaseUpgradeV2,ModuleUpgradeStrategy{
- let package_address = cap.account_address;
- assert!(get_module_upgrade_strategy(package_address) == STRATEGY_TWO_PHASE, Errors::invalid_argument(ESTRATEGY_NOT_TWO_PHASE));
- let tpu = borrow_global_mut<TwoPhaseUpgradeV2>(package_address);
- assert!(Option::is_some(&tpu.plan), Errors::invalid_state(EUPGRADE_PLAN_IS_NONE));
- tpu.plan = Option::none<UpgradePlanV2>();
-}
-
-
-
-
-public fun get_module_upgrade_strategy(module_address: address): u8
-
-
-
-
-public fun get_module_upgrade_strategy(module_address: address): u8 acquires ModuleUpgradeStrategy {
- if (exists<ModuleUpgradeStrategy>(module_address)) {
- borrow_global<ModuleUpgradeStrategy>(module_address).strategy
- }else{
- 0
- }
-}
-
-
-
-
-public fun get_upgrade_plan(_module_address: address): Option::Option<PackageTxnManager::UpgradePlan>
-
-
-
-
-public fun get_upgrade_plan(_module_address: address): Option<UpgradePlan> {
- // DEPRECATED_CODE
- Option::none<UpgradePlan>()
-}
-
-
-
-
-public fun get_upgrade_plan_v2(module_address: address): Option::Option<PackageTxnManager::UpgradePlanV2>
-
-
-
-
-public fun get_upgrade_plan_v2(module_address: address): Option<UpgradePlanV2> acquires TwoPhaseUpgradeV2 {
- if (exists<TwoPhaseUpgradeV2>(module_address)) {
- *&borrow_global<TwoPhaseUpgradeV2>(module_address).plan
- } else {
- Option::none<UpgradePlanV2>()
- }
-}
-
-
-
-
-public fun check_package_txn(package_address: address, package_hash: vector<u8>)
-
-
-
-
-public fun check_package_txn(package_address: address, package_hash: vector<u8>) acquires TwoPhaseUpgradeV2, ModuleUpgradeStrategy{
- let strategy = get_module_upgrade_strategy(package_address);
- if (strategy == STRATEGY_ARBITRARY){
- //do nothing
- }else if(strategy == STRATEGY_TWO_PHASE){
- let plan_opt = get_upgrade_plan_v2(package_address);
- assert!(Option::is_some(&plan_opt), Errors::invalid_argument(EUPGRADE_PLAN_IS_NONE));
- let plan = Option::borrow(&plan_opt);
- assert!(*&plan.package_hash == package_hash, Errors::invalid_argument(EPACKAGE_HASH_INCORRECT));
- assert!(plan.active_after_time <= Timestamp::now_milliseconds(), Errors::invalid_argument(EACTIVE_TIME_INCORRECT));
- }else if(strategy == STRATEGY_NEW_MODULE){
- //do check at VM runtime.
- }else if(strategy == STRATEGY_FREEZE){
- abort(ESTRATEGY_FREEZED)
- };
-}
-
-
-
-
-public fun check_package_txn_v2(txn_sender: address, package_address: address, package_hash: vector<u8>)
-
-
-
-
-public fun check_package_txn_v2(txn_sender: address, package_address: address, package_hash: vector<u8>) acquires TwoPhaseUpgradeV2, ModuleUpgradeStrategy{
- let strategy = get_module_upgrade_strategy(package_address);
- if (strategy == STRATEGY_ARBITRARY){
- assert!(txn_sender == package_address, Errors::requires_address(ESENDER_AND_PACKAGE_ADDRESS_MISMATCH));
- }else if(strategy == STRATEGY_TWO_PHASE){
- let plan_opt = get_upgrade_plan_v2(package_address);
- assert!(Option::is_some(&plan_opt), Errors::invalid_argument(EUPGRADE_PLAN_IS_NONE));
- let plan = Option::borrow(&plan_opt);
- assert!(*&plan.package_hash == package_hash, Errors::invalid_argument(EPACKAGE_HASH_INCORRECT));
- assert!(plan.active_after_time <= Timestamp::now_milliseconds(), Errors::invalid_argument(EACTIVE_TIME_INCORRECT));
- }else if(strategy == STRATEGY_NEW_MODULE){
- //do check at VM runtime.
- assert!(txn_sender == package_address, Errors::requires_address(ESENDER_AND_PACKAGE_ADDRESS_MISMATCH));
- }else if(strategy == STRATEGY_FREEZE){
- abort(ESTRATEGY_FREEZED)
- };
-}
-
-
-
-
-fun finish_upgrade_plan(package_address: address)
-
-
-
-
-fun finish_upgrade_plan(package_address: address) acquires TwoPhaseUpgradeV2 {
- let tpu = borrow_global_mut<TwoPhaseUpgradeV2>(package_address);
- if (Option::is_some(&tpu.plan)) {
- let plan = Option::borrow(&tpu.plan);
- Config::set_with_capability<Version::Version>(&mut tpu.version_cap, Version::new_version(plan.version));
- Event::emit_event<Self::UpgradeEvent>(&mut tpu.upgrade_event, UpgradeEvent {
- package_address: package_address,
- package_hash: *&plan.package_hash,
- version: plan.version});
- };
- tpu.plan = Option::none<UpgradePlanV2>();
-}
-
-
-
-
-public fun package_txn_prologue(account: &signer, package_address: address, package_hash: vector<u8>)
-
-
-
-
-public fun package_txn_prologue(account: &signer, package_address: address, package_hash: vector<u8>) acquires TwoPhaseUpgradeV2, ModuleUpgradeStrategy {
- // Can only be invoked by genesis account
- CoreAddresses::assert_genesis_address(account);
- check_package_txn(package_address, package_hash);
-}
-
-
-
-
-public fun package_txn_prologue_v2(account: &signer, txn_sender: address, package_address: address, package_hash: vector<u8>)
-
-
-
-
-public fun package_txn_prologue_v2(account: &signer, txn_sender: address, package_address: address, package_hash: vector<u8>) acquires TwoPhaseUpgradeV2, ModuleUpgradeStrategy {
- // Can only be invoked by genesis account
- CoreAddresses::assert_genesis_address(account);
- check_package_txn_v2(txn_sender, package_address, package_hash);
-}
-
-
-
-
-public fun package_txn_epilogue(account: &signer, _txn_sender: address, package_address: address, success: bool)
-
-
-
-
-public fun package_txn_epilogue(account: &signer, _txn_sender: address, package_address: address, success: bool) acquires TwoPhaseUpgradeV2, ModuleUpgradeStrategy {
- // Can only be invoked by genesis account
- CoreAddresses::assert_genesis_address(account);
- let strategy = get_module_upgrade_strategy(package_address);
- if(strategy == STRATEGY_TWO_PHASE){
- if (success) {
- finish_upgrade_plan(package_address);
- };
- };
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `update_module_upgrade_strategy`
-
-
-public fun update_module_upgrade_strategy(account: &signer, strategy: u8, min_time: Option::Option<u64>)
-
-
-
-
-
-pragma verify = false;
-aborts_if strategy != 0 && strategy != 1 && strategy != 2 && strategy != 3;
-aborts_if exists<ModuleUpgradeStrategy>(Signer::address_of(account)) && strategy <= global<ModuleUpgradeStrategy>(Signer::address_of(account)).strategy;
-aborts_if !exists<ModuleUpgradeStrategy>(Signer::address_of(account)) && strategy == 0;
-aborts_if strategy == 1 && exists<UpgradePlanCapability>(Signer::address_of(account));
-aborts_if strategy == 1 && !exists<Config::ModifyConfigCapabilityHolder<Version::Version>>(Signer::address_of(account));
-let holder = global<Config::ModifyConfigCapabilityHolder<Version::Version>>(Signer::address_of(account));
-aborts_if strategy == 1 && Option::is_none<Config::ModifyConfigCapability<Version::Version>>(holder.cap);
-aborts_if strategy == 1 && exists<TwoPhaseUpgrade>(Signer::address_of(account));
-aborts_if exists<ModuleUpgradeStrategy>(Signer::address_of(account)) && global<ModuleUpgradeStrategy>(Signer::address_of(account)).strategy == 1
- && !exists<TwoPhaseUpgrade>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `destroy_upgrade_plan_cap`
-
-
-public fun destroy_upgrade_plan_cap(cap: PackageTxnManager::UpgradePlanCapability)
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `extract_submit_upgrade_plan_cap`
-
-
-public fun extract_submit_upgrade_plan_cap(account: &signer): PackageTxnManager::UpgradePlanCapability
-
-
-
-
-
-aborts_if !exists<ModuleUpgradeStrategy>(Signer::address_of(account));
-aborts_if global<ModuleUpgradeStrategy>(Signer::address_of(account)).strategy != 1;
-aborts_if !exists<UpgradePlanCapability>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2`
-
-
-public(script) fun convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2(account: signer, package_address: address)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `submit_upgrade_plan_v2`
-
-
-public fun submit_upgrade_plan_v2(account: &signer, package_hash: vector<u8>, version: u64, enforced: bool)
-
-
-
-
-
-pragma verify = false;
-aborts_if !exists<UpgradePlanCapability>(Signer::address_of(account));
-include SubmitUpgradePlanWithCapAbortsIf{account: global<UpgradePlanCapability>(Signer::address_of(account)).account_address};
-ensures Option::is_some(global<TwoPhaseUpgrade>(global<UpgradePlanCapability>(Signer::address_of(account)).account_address).plan);
-
-
-
-
-
-
-### Function `submit_upgrade_plan_with_cap_v2`
-
-
-public fun submit_upgrade_plan_with_cap_v2(cap: &PackageTxnManager::UpgradePlanCapability, package_hash: vector<u8>, version: u64, enforced: bool)
-
-
-
-
-
-pragma verify = false;
-include SubmitUpgradePlanWithCapAbortsIf{account: cap.account_address};
-ensures Option::is_some(global<TwoPhaseUpgrade>(cap.account_address).plan);
-
-
-
-
-
-
-
-
-schema SubmitUpgradePlanWithCapAbortsIf {
- account: address;
- aborts_if !exists<ModuleUpgradeStrategy>(account);
- aborts_if global<ModuleUpgradeStrategy>(account).strategy != 1;
- aborts_if !exists<TwoPhaseUpgrade>(account);
- aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
- aborts_if Timestamp::now_milliseconds() + global<TwoPhaseUpgrade>(account).config.min_time_limit > max_u64();
-}
-
-
-
-
-
-
-### Function `cancel_upgrade_plan`
-
-
-public fun cancel_upgrade_plan(account: &signer)
-
-
-
-
-
-aborts_if !exists<UpgradePlanCapability>(Signer::address_of(account));
-include CancelUpgradePlanWithCapAbortsIf{account: global<UpgradePlanCapability>(Signer::address_of(account)).account_address};
-ensures Option::is_none(global<TwoPhaseUpgrade>(global<UpgradePlanCapability>(Signer::address_of(account)).account_address).plan);
-
-
-
-
-
-
-### Function `cancel_upgrade_plan_with_cap`
-
-
-public fun cancel_upgrade_plan_with_cap(cap: &PackageTxnManager::UpgradePlanCapability)
-
-
-
-
-
-include CancelUpgradePlanWithCapAbortsIf{account: cap.account_address};
-ensures Option::is_none(global<TwoPhaseUpgrade>(cap.account_address).plan);
-
-
-
-
-
-
-
-
-schema CancelUpgradePlanWithCapAbortsIf {
- account: address;
- aborts_if !exists<ModuleUpgradeStrategy>(account);
- aborts_if global<ModuleUpgradeStrategy>(account).strategy != 1;
- aborts_if !exists<TwoPhaseUpgrade>(account);
- aborts_if !Option::is_some(global<TwoPhaseUpgrade>(account).plan);
-}
-
-
-
-
-
-
-### Function `get_module_upgrade_strategy`
-
-
-public fun get_module_upgrade_strategy(module_address: address): u8
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-
-
-fun spec_get_module_upgrade_strategy(module_address: address): u8 {
- if (exists<ModuleUpgradeStrategy>(module_address)) {
- global<ModuleUpgradeStrategy>(module_address).strategy
- }else{
- 0
- }
-}
-
-
-
-
-
-
-### Function `get_upgrade_plan`
-
-
-public fun get_upgrade_plan(_module_address: address): Option::Option<PackageTxnManager::UpgradePlan>
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `get_upgrade_plan_v2`
-
-
-public fun get_upgrade_plan_v2(module_address: address): Option::Option<PackageTxnManager::UpgradePlanV2>
-
-
-
-
-
-pragma verify = false;
-aborts_if false;
-
-
-
-
-
-
-
-
-fun spec_get_upgrade_plan_v2(module_address: address): Option<UpgradePlan> {
- if (exists<TwoPhaseUpgrade>(module_address)) {
- global<TwoPhaseUpgrade>(module_address).plan
- }else{
- Option::spec_none<UpgradePlan>()
- }
-}
-
-
-
-
-
-
-### Function `check_package_txn`
-
-
-public fun check_package_txn(package_address: address, package_hash: vector<u8>)
-
-
-
-
-
-pragma verify = false;
-include CheckPackageTxnAbortsIf;
-
-
-
-
-
-
-### Function `finish_upgrade_plan`
-
-
-fun finish_upgrade_plan(package_address: address)
-
-
-
-
-
-pragma verify = false;
-aborts_if !exists<TwoPhaseUpgrade>(package_address);
-let tpu = global<TwoPhaseUpgrade>(package_address);
-aborts_if Option::is_some(tpu.plan) && !exists<Config::Config<Version::Version>>(tpu.version_cap.account_address);
-
-
-
-
-
-
-### Function `package_txn_prologue`
-
-
-public fun package_txn_prologue(account: &signer, package_address: address, package_hash: vector<u8>)
-
-
-
-
-
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-include CheckPackageTxnAbortsIf{};
-
-
-
-
-
-
-### Function `package_txn_epilogue`
-
-
-public fun package_txn_epilogue(account: &signer, _txn_sender: address, package_address: address, success: bool)
-
-
-
-
-
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if spec_get_module_upgrade_strategy(package_address) == 1
- && success && !exists<TwoPhaseUpgrade>(package_address);
-aborts_if spec_get_module_upgrade_strategy(package_address) == 1
- && success && Option::is_some(global<TwoPhaseUpgrade>(package_address).plan)
- && !exists<Config::Config<Version::Version>>(global<TwoPhaseUpgrade>(package_address).version_cap.account_address);
-
diff --git a/vm/stdlib/compiled/latest/doc/RewardConfig.md b/vm/stdlib/compiled/latest/doc/RewardConfig.md
deleted file mode 100644
index 88f6f1e0eb..0000000000
--- a/vm/stdlib/compiled/latest/doc/RewardConfig.md
+++ /dev/null
@@ -1,260 +0,0 @@
-
-
-
-# Module `0x1::RewardConfig`
-
-The module provide configuration for block reward.
-
-
-- [Struct `RewardConfig`](#0x1_RewardConfig_RewardConfig)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_RewardConfig_initialize)
-- [Function `new_reward_config`](#0x1_RewardConfig_new_reward_config)
-- [Function `get_reward_config`](#0x1_RewardConfig_get_reward_config)
-- [Function `reward_delay`](#0x1_RewardConfig_reward_delay)
-- [Specification](#@Specification_1)
- - [Function `initialize`](#@Specification_1_initialize)
- - [Function `new_reward_config`](#@Specification_1_new_reward_config)
- - [Function `get_reward_config`](#@Specification_1_get_reward_config)
- - [Function `reward_delay`](#@Specification_1_reward_delay)
-
-
-use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::Timestamp;
-
-
-
-
-
-
-## Struct `RewardConfig`
-
-Reward configuration
-
-
-struct RewardConfig has copy, drop, store
-
-
-
-
-reward_delay: u64
-const EINVALID_ARGUMENT: u64 = 18;
-
-
-
-
-
-
-## Function `initialize`
-
-Module initialization.
-
-
-public fun initialize(account: &signer, reward_delay: u64)
-
-
-
-
-public fun initialize(account: &signer, reward_delay: u64) {
- Timestamp::assert_genesis();
- CoreAddresses::assert_genesis_address(account);
-
- Config::publish_new_config<Self::RewardConfig>(
- account,
- new_reward_config(reward_delay)
- );
-}
-
-
-
-
-public fun new_reward_config(reward_delay: u64): RewardConfig::RewardConfig
-
-
-
-
-public fun new_reward_config(reward_delay: u64) : RewardConfig {
- RewardConfig {reward_delay: reward_delay}
-}
-
-
-
-
-public fun get_reward_config(): RewardConfig::RewardConfig
-
-
-
-
-public fun get_reward_config(): RewardConfig {
- Config::get_by_address<RewardConfig>(CoreAddresses::GENESIS_ADDRESS())
-}
-
-
-
-
-public fun reward_delay(): u64
-
-
-
-
-public fun reward_delay() :u64 {
- let reward_config = get_reward_config();
- reward_config.reward_delay
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, reward_delay: u64)
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-aborts_if exists<Config::Config<RewardConfig>>(Signer::address_of(account));
-include Config::PublishNewConfigAbortsIf<RewardConfig>;
-include Config::PublishNewConfigEnsures<RewardConfig>;
-
-
-
-
-
-
-### Function `new_reward_config`
-
-
-public fun new_reward_config(reward_delay: u64): RewardConfig::RewardConfig
-
-
-
-
-
-
-
-### Function `get_reward_config`
-
-
-public fun get_reward_config(): RewardConfig::RewardConfig
-
-
-
-
-
-include GetRewardConfigAbortsIf;
-
-
-
-
-
-
-
-
-schema GetRewardConfigAbortsIf {
- aborts_if !exists<Config::Config<RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());
-}
-
-
-
-
-
-
-### Function `reward_delay`
-
-
-public fun reward_delay(): u64
-
-
-
-
-
-aborts_if !exists<Config::Config<RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());
-
diff --git a/vm/stdlib/compiled/latest/doc/SIPs.md b/vm/stdlib/compiled/latest/doc/SIPs.md
deleted file mode 100644
index b466bfe706..0000000000
--- a/vm/stdlib/compiled/latest/doc/SIPs.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-# Module `0x1::SIP_3`
-
-https://github.com/starcoinorg/SIPs/tree/master/sip-3
-
-
-
-
-
diff --git a/vm/stdlib/compiled/latest/doc/STC.md b/vm/stdlib/compiled/latest/doc/STC.md
deleted file mode 100644
index 97af84e68b..0000000000
--- a/vm/stdlib/compiled/latest/doc/STC.md
+++ /dev/null
@@ -1,432 +0,0 @@
-
-
-
-# Module `0x1::STC`
-
-STC is the token of Starcoin blockchain.
-It uses apis defined in the Token
module.
-
-
-- [Struct `STC`](#0x1_STC_STC)
-- [Resource `SharedBurnCapability`](#0x1_STC_SharedBurnCapability)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_STC_initialize)
-- [Function `upgrade_from_v1_to_v2`](#0x1_STC_upgrade_from_v1_to_v2)
-- [Function `initialize_v2`](#0x1_STC_initialize_v2)
-- [Function `is_stc`](#0x1_STC_is_stc)
-- [Function `burn`](#0x1_STC_burn)
-- [Function `token_address`](#0x1_STC_token_address)
-- [Specification](#@Specification_1)
- - [Function `initialize`](#@Specification_1_initialize)
- - [Function `upgrade_from_v1_to_v2`](#@Specification_1_upgrade_from_v1_to_v2)
- - [Function `initialize_v2`](#@Specification_1_initialize_v2)
- - [Function `is_stc`](#@Specification_1_is_stc)
- - [Function `burn`](#@Specification_1_burn)
- - [Function `token_address`](#@Specification_1_token_address)
-
-
-use 0x1::ConsensusConfig;
-use 0x1::CoreAddresses;
-use 0x1::Dao;
-use 0x1::ModifyDaoConfigProposal;
-use 0x1::OnChainConfigDao;
-use 0x1::PackageTxnManager;
-use 0x1::RewardConfig;
-use 0x1::Token;
-use 0x1::TransactionPublishOption;
-use 0x1::TransactionTimeoutConfig;
-use 0x1::Treasury;
-use 0x1::UpgradeModuleDaoProposal;
-use 0x1::VMConfig;
-
-
-
-
-
-
-## Struct `STC`
-
-STC token marker.
-
-
-struct STC has copy, drop, store
-
-
-
-
-dummy_field: bool
-struct SharedBurnCapability has store, key
-
-
-
-
-cap: Token::BurnCapability<STC::STC>
-const PRECISION: u8 = 9;
-
-
-
-
-
-
-## Function `initialize`
-
-STC initialization.
-
-
-public fun initialize(account: &signer, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64)
-
-
-
-
-public fun initialize(
- account: &signer,
- voting_delay: u64,
- voting_period: u64,
- voting_quorum_rate: u8,
- min_action_delay: u64,
-) {
- Token::register_token<STC>(account, PRECISION);
- let burn_cap = Token::remove_burn_capability<STC>(account);
- move_to(account, SharedBurnCapability { cap: burn_cap });
- Dao::plugin<STC>(
- account,
- voting_delay,
- voting_period,
- voting_quorum_rate,
- min_action_delay,
- );
- ModifyDaoConfigProposal::plugin<STC>(account);
- let upgrade_plan_cap = PackageTxnManager::extract_submit_upgrade_plan_cap(account);
- UpgradeModuleDaoProposal::plugin<STC>(
- account,
- upgrade_plan_cap,
- );
- // the following configurations are gov-ed by Dao.
- OnChainConfigDao::plugin<STC, TransactionPublishOption::TransactionPublishOption>(account);
- OnChainConfigDao::plugin<STC, VMConfig::VMConfig>(account);
- OnChainConfigDao::plugin<STC, ConsensusConfig::ConsensusConfig>(account);
- OnChainConfigDao::plugin<STC, RewardConfig::RewardConfig>(account);
- OnChainConfigDao::plugin<STC, TransactionTimeoutConfig::TransactionTimeoutConfig>(account);
-}
-
-
-
-
-public fun upgrade_from_v1_to_v2(account: &signer, total_amount: u128): Treasury::WithdrawCapability<STC::STC>
-
-
-
-
-public fun upgrade_from_v1_to_v2(account: &signer,total_amount: u128,): Treasury::WithdrawCapability<STC> {
- CoreAddresses::assert_genesis_address(account);
-
- // Mint all stc, and destroy mint capability
- let total_stc = Token::mint<STC>(account, total_amount-Token::market_cap<STC>());
- let withdraw_cap = Treasury::initialize(account, total_stc);
- let mint_cap = Token::remove_mint_capability<STC>(account);
- Token::destroy_mint_capability(mint_cap);
- withdraw_cap
-}
-
-
-
-
-public fun initialize_v2(account: &signer, total_amount: u128, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64): Treasury::WithdrawCapability<STC::STC>
-
-
-
-
-public fun initialize_v2(
- account: &signer,
- total_amount: u128,
- voting_delay: u64,
- voting_period: u64,
- voting_quorum_rate: u8,
- min_action_delay: u64,
-): Treasury::WithdrawCapability<STC> {
- Token::register_token<STC>(account, PRECISION);
-
- // Mint all stc, and destroy mint capability
-
- let total_stc = Token::mint<STC>(account, total_amount);
- let withdraw_cap = Treasury::initialize(account, total_stc);
- let mint_cap = Token::remove_mint_capability<STC>(account);
- Token::destroy_mint_capability(mint_cap);
-
- let burn_cap = Token::remove_burn_capability<STC>(account);
- move_to(account, SharedBurnCapability { cap: burn_cap });
- Dao::plugin<STC>(
- account,
- voting_delay,
- voting_period,
- voting_quorum_rate,
- min_action_delay,
- );
- ModifyDaoConfigProposal::plugin<STC>(account);
- let upgrade_plan_cap = PackageTxnManager::extract_submit_upgrade_plan_cap(account);
- UpgradeModuleDaoProposal::plugin<STC>(
- account,
- upgrade_plan_cap,
- );
- // the following configurations are gov-ed by Dao.
- OnChainConfigDao::plugin<STC, TransactionPublishOption::TransactionPublishOption>(account);
- OnChainConfigDao::plugin<STC, VMConfig::VMConfig>(account);
- OnChainConfigDao::plugin<STC, ConsensusConfig::ConsensusConfig>(account);
- OnChainConfigDao::plugin<STC, RewardConfig::RewardConfig>(account);
- OnChainConfigDao::plugin<STC, TransactionTimeoutConfig::TransactionTimeoutConfig>(account);
- withdraw_cap
-}
-
-
-
-
-TokenType
is STC::STC
-
-
-public fun is_stc<TokenType: store>(): bool
-
-
-
-
-public fun is_stc<TokenType: store>(): bool {
- Token::is_same_token<STC, TokenType>()
-}
-
-
-
-
-public fun burn(token: Token::Token<STC::STC>)
-
-
-
-
-public fun burn(token: Token<STC>) acquires SharedBurnCapability {
- let cap = borrow_global<SharedBurnCapability>(token_address());
- Token::burn_with_capability(&cap.cap, token);
-}
-
-
-
-
-public fun token_address(): address
-
-
-
-
-public fun token_address(): address {
- Token::token_address<STC>()
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64)
-
-
-
-
-
-include Token::RegisterTokenAbortsIf<STC>{precision: PRECISION};
-
-
-
-
-
-
-### Function `upgrade_from_v1_to_v2`
-
-
-public fun upgrade_from_v1_to_v2(account: &signer, total_amount: u128): Treasury::WithdrawCapability<STC::STC>
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `initialize_v2`
-
-
-public fun initialize_v2(account: &signer, total_amount: u128, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64): Treasury::WithdrawCapability<STC::STC>
-
-
-
-
-
-include Token::RegisterTokenAbortsIf<STC>{precision: PRECISION};
-
-
-
-
-
-
-### Function `is_stc`
-
-
-public fun is_stc<TokenType: store>(): bool
-
-
-
-
-
-
-
-### Function `burn`
-
-
-public fun burn(token: Token::Token<STC::STC>)
-
-
-
-
-
-aborts_if Token::spec_abstract_total_value<STC>() - token.value < 0;
-aborts_if !exists<SharedBurnCapability>(Token::SPEC_TOKEN_TEST_ADDRESS());
-
-
-
-
-
-
-### Function `token_address`
-
-
-public fun token_address(): address
-
diff --git a/vm/stdlib/compiled/latest/doc/SharedEd25519PublicKey.md b/vm/stdlib/compiled/latest/doc/SharedEd25519PublicKey.md
deleted file mode 100644
index a362ef284e..0000000000
--- a/vm/stdlib/compiled/latest/doc/SharedEd25519PublicKey.md
+++ /dev/null
@@ -1,334 +0,0 @@
-
-
-
-# Module `0x1::SharedEd25519PublicKey`
-
-Each address that holds a SharedEd25519PublicKey
resource can rotate the public key stored in
-this resource, but the account's authentication key will be updated in lockstep. This ensures
-that the two keys always stay in sync.
-
-
-- [Resource `SharedEd25519PublicKey`](#0x1_SharedEd25519PublicKey_SharedEd25519PublicKey)
-- [Constants](#@Constants_0)
-- [Function `publish`](#0x1_SharedEd25519PublicKey_publish)
-- [Function `rotate_key_`](#0x1_SharedEd25519PublicKey_rotate_key_)
-- [Function `rotate_key`](#0x1_SharedEd25519PublicKey_rotate_key)
-- [Function `key`](#0x1_SharedEd25519PublicKey_key)
-- [Function `exists_at`](#0x1_SharedEd25519PublicKey_exists_at)
-- [Specification](#@Specification_1)
- - [Function `publish`](#@Specification_1_publish)
- - [Function `rotate_key_`](#@Specification_1_rotate_key_)
- - [Function `rotate_key`](#@Specification_1_rotate_key)
- - [Function `key`](#@Specification_1_key)
- - [Function `exists_at`](#@Specification_1_exists_at)
-
-
-use 0x1::Account;
-use 0x1::Authenticator;
-use 0x1::Errors;
-use 0x1::Signature;
-use 0x1::Signer;
-
-
-
-
-
-
-## Resource `SharedEd25519PublicKey`
-
-A resource that forces the account associated with rotation_cap
to use a ed25519
-authentication key derived from key
-
-
-struct SharedEd25519PublicKey has key
-
-
-
-
-key: vector<u8>
-rotation_cap: Account::KeyRotationCapability
-key
-const EMALFORMED_PUBLIC_KEY: u64 = 101;
-
-
-
-
-
-
-## Function `publish`
-
-(1) Rotate the authentication key of the sender to key
-(2) Publish a resource containing a 32-byte ed25519 public key and the rotation capability
-of the sender under the account
's address.
-Aborts if the sender already has a SharedEd25519PublicKey
resource.
-Aborts if the length of new_public_key
is not 32.
-
-
-public fun publish(account: &signer, key: vector<u8>)
-
-
-
-
-public fun publish(account: &signer, key: vector<u8>) {
- let t = SharedEd25519PublicKey {
- key: x"",
- rotation_cap: Account::extract_key_rotation_capability(account)
- };
- rotate_key_(&mut t, key);
- move_to(account, t);
-}
-
-
-
-
-fun rotate_key_(shared_key: &mut SharedEd25519PublicKey::SharedEd25519PublicKey, new_public_key: vector<u8>)
-
-
-
-
-fun rotate_key_(shared_key: &mut SharedEd25519PublicKey, new_public_key: vector<u8>) {
- // Cryptographic check of public key validity
- assert!(
- Signature::ed25519_validate_pubkey(copy new_public_key),
- Errors::invalid_argument(EMALFORMED_PUBLIC_KEY)
- );
- Account::rotate_authentication_key_with_capability(
- &shared_key.rotation_cap,
- Authenticator::ed25519_authentication_key(copy new_public_key)
- );
- shared_key.key = new_public_key;
-}
-
-
-
-
-account
's SharedEd25519PublicKey
resource to
-new_public_key
-(2) rotate the authentication key using the capability stored in the account
's
-SharedEd25519PublicKey
to a new value derived from new_public_key
-Aborts if the sender does not have a SharedEd25519PublicKey
resource.
-Aborts if the length of new_public_key
is not 32.
-
-
-public fun rotate_key(account: &signer, new_public_key: vector<u8>)
-
-
-
-
-public fun rotate_key(account: &signer, new_public_key: vector<u8>) acquires SharedEd25519PublicKey {
- rotate_key_(borrow_global_mut<SharedEd25519PublicKey>(Signer::address_of(account)), new_public_key);
-}
-
-
-
-
-addr
.
-Aborts if addr
does not hold a SharedEd25519PublicKey
resource.
-
-
-public fun key(addr: address): vector<u8>
-
-
-
-
-public fun key(addr: address): vector<u8> acquires SharedEd25519PublicKey {
- *&borrow_global<SharedEd25519PublicKey>(addr).key
-}
-
-
-
-
-addr
holds a SharedEd25519PublicKey
resource.
-
-
-public fun exists_at(addr: address): bool
-
-
-
-
-public fun exists_at(addr: address): bool {
- exists<SharedEd25519PublicKey>(addr)
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `publish`
-
-
-public fun publish(account: &signer, key: vector<u8>)
-
-
-
-
-
-aborts_if !exists<Account::Account>(Signer::address_of(account));
-aborts_if StarcoinFramework::Option::is_none(global<Account::Account>(Signer::address_of(account)).key_rotation_capability);
-aborts_if !exists<Account::Account>(
- StarcoinFramework::Option::borrow<Account::KeyRotationCapability>(
- global<Account::Account>(Signer::address_of(account))
- .key_rotation_capability
- ).account_address);
-aborts_if !Signature::ed25519_validate_pubkey(key);
-aborts_if exists<SharedEd25519PublicKey>(Signer::address_of(account));
-aborts_if len(Authenticator::spec_ed25519_authentication_key(key)) != 32;
-
-
-
-
-
-
-### Function `rotate_key_`
-
-
-fun rotate_key_(shared_key: &mut SharedEd25519PublicKey::SharedEd25519PublicKey, new_public_key: vector<u8>)
-
-
-
-
-
-aborts_if !exists<Account::Account>(shared_key.rotation_cap.account_address);
-aborts_if !Signature::ed25519_validate_pubkey(new_public_key);
-aborts_if len(Authenticator::spec_ed25519_authentication_key(new_public_key)) != 32;
-
-
-
-
-
-
-### Function `rotate_key`
-
-
-public fun rotate_key(account: &signer, new_public_key: vector<u8>)
-
-
-
-
-
-aborts_if !exists<SharedEd25519PublicKey>(Signer::address_of(account));
-aborts_if !exists<Account::Account>(global<SharedEd25519PublicKey>(Signer::address_of(account)).rotation_cap.account_address);
-aborts_if !Signature::ed25519_validate_pubkey(new_public_key);
-aborts_if len(Authenticator::spec_ed25519_authentication_key(new_public_key)) != 32;
-
-
-
-
-
-
-### Function `key`
-
-
-public fun key(addr: address): vector<u8>
-
-
-
-
-
-aborts_if !exists<SharedEd25519PublicKey>(addr);
-
-
-
-
-
-
-### Function `exists_at`
-
-
-public fun exists_at(addr: address): bool
-
-
-
-
-
-aborts_if false;
-
diff --git a/vm/stdlib/compiled/latest/doc/Signature.md b/vm/stdlib/compiled/latest/doc/Signature.md
deleted file mode 100644
index 5ed548973d..0000000000
--- a/vm/stdlib/compiled/latest/doc/Signature.md
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-# Module `0x1::Signature`
-
-Contains functions for [ed25519](https://en.wikipedia.org/wiki/EdDSA) digital signatures.
-
-
-- [Function `ed25519_validate_pubkey`](#0x1_Signature_ed25519_validate_pubkey)
-- [Function `ed25519_verify`](#0x1_Signature_ed25519_verify)
-- [Function `native_ecrecover`](#0x1_Signature_native_ecrecover)
-- [Function `ecrecover`](#0x1_Signature_ecrecover)
-- [Specification](#@Specification_0)
-
-
-use 0x1::EVMAddress;
-use 0x1::Option;
-use 0x1::Vector;
-
-
-
-
-
-
-## Function `ed25519_validate_pubkey`
-
-
-
-public fun ed25519_validate_pubkey(public_key: vector<u8>): bool
-
-
-
-
-native public fun ed25519_validate_pubkey(public_key: vector<u8>): bool;
-
-
-
-
-public fun ed25519_verify(signature: vector<u8>, public_key: vector<u8>, message: vector<u8>): bool
-
-
-
-
-native public fun ed25519_verify(signature: vector<u8>, public_key: vector<u8>, message: vector<u8>): bool;
-
-
-
-
-fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>
-
-
-
-
-native fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>;
-
-
-
-
-public fun ecrecover(hash: vector<u8>, signature: vector<u8>): Option::Option<EVMAddress::EVMAddress>
-
-
-
-
-public fun ecrecover(hash: vector<u8>, signature: vector<u8>):Option<EVMAddress>{
- let bytes = native_ecrecover(hash, signature);
- if (Vector::is_empty(&bytes)){
- Option::none<EVMAddress>()
- }else{
- Option::some(EVMAddress::new(bytes))
- }
-}
-
-
-
-
-pragma intrinsic = true;
-
diff --git a/vm/stdlib/compiled/latest/doc/SignedInteger64.md b/vm/stdlib/compiled/latest/doc/SignedInteger64.md
deleted file mode 100644
index 2a650d01b1..0000000000
--- a/vm/stdlib/compiled/latest/doc/SignedInteger64.md
+++ /dev/null
@@ -1,387 +0,0 @@
-
-
-
-# Module `0x1::SignedInteger64`
-
-Implementation of i64.
-
-
-- [Struct `SignedInteger64`](#0x1_SignedInteger64_SignedInteger64)
-- [Function `multiply_u64`](#0x1_SignedInteger64_multiply_u64)
-- [Function `divide_u64`](#0x1_SignedInteger64_divide_u64)
-- [Function `sub_u64`](#0x1_SignedInteger64_sub_u64)
-- [Function `add_u64`](#0x1_SignedInteger64_add_u64)
-- [Function `create_from_raw_value`](#0x1_SignedInteger64_create_from_raw_value)
-- [Function `get_value`](#0x1_SignedInteger64_get_value)
-- [Function `is_negative`](#0x1_SignedInteger64_is_negative)
-- [Specification](#@Specification_0)
- - [Function `multiply_u64`](#@Specification_0_multiply_u64)
- - [Function `divide_u64`](#@Specification_0_divide_u64)
- - [Function `sub_u64`](#@Specification_0_sub_u64)
- - [Function `add_u64`](#@Specification_0_add_u64)
- - [Function `create_from_raw_value`](#@Specification_0_create_from_raw_value)
- - [Function `get_value`](#@Specification_0_get_value)
- - [Function `is_negative`](#@Specification_0_is_negative)
-
-
-
-
-
-
-
-
-## Struct `SignedInteger64`
-
-Define a signed integer type with two 32 bits.
-
-
-struct SignedInteger64 has copy, drop, store
-
-
-
-
-value: u64
-is_negative: bool
-public fun multiply_u64(num: u64, multiplier: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
-
-
-
-public fun multiply_u64(num: u64, multiplier: SignedInteger64): SignedInteger64 {
- let product = multiplier.value * num;
- SignedInteger64 { value: (product as u64), is_negative: multiplier.is_negative }
-}
-
-
-
-
-public fun divide_u64(num: u64, divisor: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
-
-
-
-public fun divide_u64(num: u64, divisor: SignedInteger64): SignedInteger64 {
- let quotient = num / divisor.value;
- SignedInteger64 { value: (quotient as u64), is_negative: divisor.is_negative }
-}
-
-
-
-
-num - minus
-
-
-public fun sub_u64(num: u64, minus: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
-
-
-
-public fun sub_u64(num: u64, minus: SignedInteger64): SignedInteger64 {
- if (minus.is_negative) {
- let result = num + minus.value;
- SignedInteger64 { value: (result as u64), is_negative: false }
- } else {
- if (num > minus.value) {
- let result = num - minus.value;
- SignedInteger64 { value: (result as u64), is_negative: false }
- }else {
- let result = minus.value - num;
- SignedInteger64 { value: (result as u64), is_negative: true }
- }
- }
-}
-
-
-
-
-num + addend
-
-
-public fun add_u64(num: u64, addend: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
-
-
-
-public fun add_u64(num: u64, addend: SignedInteger64): SignedInteger64 {
- if (addend.is_negative) {
- if (num > addend.value) {
- let result = num - addend.value;
- SignedInteger64 { value: (result as u64), is_negative: false }
- }else {
- let result = addend.value - num;
- SignedInteger64 { value: (result as u64), is_negative: true }
- }
- } else {
- let result = num + addend.value;
- SignedInteger64 { value: (result as u64), is_negative: false }
- }
-}
-
-
-
-
-public fun create_from_raw_value(value: u64, is_negative: bool): SignedInteger64::SignedInteger64
-
-
-
-
-public fun create_from_raw_value(value: u64, is_negative: bool): SignedInteger64 {
- SignedInteger64 { value, is_negative }
-}
-
-
-
-
-public fun get_value(num: SignedInteger64::SignedInteger64): u64
-
-
-
-
-public fun get_value(num: SignedInteger64): u64 {
- num.value
-}
-
-
-
-
-public fun is_negative(num: SignedInteger64::SignedInteger64): bool
-
-
-
-
-public fun is_negative(num: SignedInteger64): bool {
- num.is_negative
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `multiply_u64`
-
-
-public fun multiply_u64(num: u64, multiplier: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
-
-
-
-
-aborts_if multiplier.value * num > max_u64();
-
-
-
-
-
-
-### Function `divide_u64`
-
-
-public fun divide_u64(num: u64, divisor: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
-
-
-
-
-aborts_if divisor.value == 0;
-
-
-
-
-
-
-### Function `sub_u64`
-
-
-public fun sub_u64(num: u64, minus: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
-
-
-
-
-aborts_if minus.is_negative && num + minus.value > max_u64();
-
-
-
-
-
-
-### Function `add_u64`
-
-
-public fun add_u64(num: u64, addend: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
-
-
-
-
-aborts_if !addend.is_negative && num + addend.value > max_u64();
-
-
-
-
-
-
-### Function `create_from_raw_value`
-
-
-public fun create_from_raw_value(value: u64, is_negative: bool): SignedInteger64::SignedInteger64
-
-
-
-
-
-aborts_if false;
-ensures result == SignedInteger64 { value, is_negative };
-
-
-
-
-
-
-### Function `get_value`
-
-
-public fun get_value(num: SignedInteger64::SignedInteger64): u64
-
-
-
-
-
-aborts_if false;
-ensures result == num.value;
-
-
-
-
-
-
-### Function `is_negative`
-
-
-public fun is_negative(num: SignedInteger64::SignedInteger64): bool
-
-
-
-
-
-aborts_if false;
-ensures result == num.is_negative;
-
diff --git a/vm/stdlib/compiled/latest/doc/Signer.md b/vm/stdlib/compiled/latest/doc/Signer.md
deleted file mode 100644
index be402e9a68..0000000000
--- a/vm/stdlib/compiled/latest/doc/Signer.md
+++ /dev/null
@@ -1,99 +0,0 @@
-
-
-
-# Module `0x1::Signer`
-
-Provide access methods for Signer.
-
-
-- [Function `borrow_address`](#0x1_Signer_borrow_address)
-- [Function `address_of`](#0x1_Signer_address_of)
-- [Specification](#@Specification_0)
- - [Function `address_of`](#@Specification_0_address_of)
-
-
-
-
-
-
-
-
-## Function `borrow_address`
-
-Borrows the address of the signer
-Conceptually, you can think of the signer
as being a resource struct wrapper around an
-address
-```
-resource struct Signer has key, store { addr: address }
-```
-borrow_address
borrows this inner field
-
-
-public fun borrow_address(s: &signer): &address
-
-
-
-
-native public fun borrow_address(s: &signer): &address;
-
-
-
-
-public fun address_of(s: &signer): address
-
-
-
-
-public fun address_of(s: &signer): address {
- *borrow_address(s)
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `address_of`
-
-
-public fun address_of(s: &signer): address
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures result == address_of(s);
-
diff --git a/vm/stdlib/compiled/latest/doc/StdlibUpgradeScripts.md b/vm/stdlib/compiled/latest/doc/StdlibUpgradeScripts.md
deleted file mode 100644
index a618e0a1aa..0000000000
--- a/vm/stdlib/compiled/latest/doc/StdlibUpgradeScripts.md
+++ /dev/null
@@ -1,306 +0,0 @@
-
-
-
-# Module `0x1::StdlibUpgradeScripts`
-
-The module for StdlibUpgrade init scripts
-
-
-- [Function `upgrade_from_v2_to_v3`](#0x1_StdlibUpgradeScripts_upgrade_from_v2_to_v3)
-- [Function `take_linear_withdraw_capability`](#0x1_StdlibUpgradeScripts_take_linear_withdraw_capability)
-- [Function `do_upgrade_from_v5_to_v6`](#0x1_StdlibUpgradeScripts_do_upgrade_from_v5_to_v6)
-- [Function `upgrade_from_v5_to_v6`](#0x1_StdlibUpgradeScripts_upgrade_from_v5_to_v6)
-- [Function `upgrade_from_v6_to_v7`](#0x1_StdlibUpgradeScripts_upgrade_from_v6_to_v7)
-- [Function `do_upgrade_from_v6_to_v7`](#0x1_StdlibUpgradeScripts_do_upgrade_from_v6_to_v7)
-- [Function `do_upgrade_from_v6_to_v7_with_language_version`](#0x1_StdlibUpgradeScripts_do_upgrade_from_v6_to_v7_with_language_version)
-- [Function `upgrade_from_v7_to_v8`](#0x1_StdlibUpgradeScripts_upgrade_from_v7_to_v8)
-- [Function `do_upgrade_from_v7_to_v8`](#0x1_StdlibUpgradeScripts_do_upgrade_from_v7_to_v8)
-- [Specification](#@Specification_0)
-
-
-use 0x1::Account;
-use 0x1::Collection;
-use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::GenesisNFT;
-use 0x1::GenesisSignerCapability;
-use 0x1::LanguageVersion;
-use 0x1::NFT;
-use 0x1::Offer;
-use 0x1::OnChainConfigDao;
-use 0x1::Oracle;
-use 0x1::STC;
-use 0x1::STCUSDOracle;
-use 0x1::Timestamp;
-use 0x1::Token;
-use 0x1::Treasury;
-use 0x1::TreasuryWithdrawDaoProposal;
-
-
-
-
-
-
-## Function `upgrade_from_v2_to_v3`
-
-Stdlib upgrade script from v2 to v3
-
-
-public(script) fun upgrade_from_v2_to_v3(account: signer, total_stc_amount: u128)
-
-
-
-
-public(script) fun upgrade_from_v2_to_v3(account: signer, total_stc_amount: u128 ) {
- CoreAddresses::assert_genesis_address(&account);
-
- let withdraw_cap = STC::upgrade_from_v1_to_v2(&account, total_stc_amount);
-
- let mint_keys = Collection::borrow_collection<LinearTimeMintKey<STC>>(CoreAddresses::ASSOCIATION_ROOT_ADDRESS());
- let mint_key = Collection::borrow(&mint_keys, 0);
- let (total, minted, start_time, period) = Token::read_linear_time_key(mint_key);
- Collection::return_collection(mint_keys);
-
- let now = Timestamp::now_seconds();
- let linear_withdraw_cap = Treasury::issue_linear_withdraw_capability(&mut withdraw_cap, total-minted, period - (now - start_time));
- // Lock the TreasuryWithdrawCapability to Dao
- TreasuryWithdrawDaoProposal::plugin(&account, withdraw_cap);
- // Give a LinearWithdrawCapability Offer to association, association need to take the offer, and destroy old LinearTimeMintKey.
- Offer::create(&account, linear_withdraw_cap, CoreAddresses::ASSOCIATION_ROOT_ADDRESS(), 0);
-}
-
-
-
-
-public(script) fun take_linear_withdraw_capability(signer: signer)
-
-
-
-
-public(script) fun take_linear_withdraw_capability(signer: signer){
- let offered = Offer::redeem<LinearWithdrawCapability<STC>>(&signer, CoreAddresses::GENESIS_ADDRESS());
- Treasury::add_linear_withdraw_capability(&signer, offered);
- let mint_key = Collection::take<LinearTimeMintKey<STC>>(&signer);
- Token::destroy_linear_time_key(mint_key);
-}
-
-
-
-
-public fun do_upgrade_from_v5_to_v6(sender: &signer)
-
-
-
-
-public fun do_upgrade_from_v5_to_v6(sender: &signer) {
- CoreAddresses::assert_genesis_address(sender);
- Oracle::initialize(sender);
- //register oracle
- STCUSDOracle::register(sender);
- NFT::initialize(sender);
- let merkle_root = x"5969f0e8e19f8769276fb638e6060d5c02e40088f5fde70a6778dd69d659ee6d";
- let image = b"ipfs://QmSPcvcXgdtHHiVTAAarzTeubk5X3iWymPAoKBfiRFjPMY";
- GenesisNFT::initialize(sender, merkle_root, 1639u64, image);
-}
-
-
-
-
-public(script) fun upgrade_from_v5_to_v6(sender: signer)
-
-
-
-
-public(script) fun upgrade_from_v5_to_v6(sender: signer) {
- Self::do_upgrade_from_v5_to_v6(&sender)
-}
-
-
-
-
-public(script) fun upgrade_from_v6_to_v7(sender: signer)
-
-
-
-
-public(script) fun upgrade_from_v6_to_v7(sender: signer) {
- Self::do_upgrade_from_v6_to_v7_with_language_version(&sender, 2);
-}
-
-
-
-
-do_upgrade_from_v6_to_v7_with_language_version
.
-
-
-public fun do_upgrade_from_v6_to_v7(sender: &signer)
-
-
-
-
-public fun do_upgrade_from_v6_to_v7(sender: &signer) {
- do_upgrade_from_v6_to_v7_with_language_version(sender, 2);
-}
-
-
-
-
-public fun do_upgrade_from_v6_to_v7_with_language_version(sender: &signer, language_version: u64)
-
-
-
-
-public fun do_upgrade_from_v6_to_v7_with_language_version(sender: &signer, language_version: u64) {
- // initialize the language version config.
- Config::publish_new_config(sender, LanguageVersion::new(language_version));
- // use STC Dao to upgrade onchain's move-language-version configuration.
- OnChainConfigDao::plugin<STC, LanguageVersion::LanguageVersion>(sender);
- // upgrade genesis NFT
- GenesisNFT::upgrade_to_nft_type_info_v2(sender);
-}
-
-
-
-
-public(script) fun upgrade_from_v7_to_v8(sender: signer)
-
-
-
-
-public(script) fun upgrade_from_v7_to_v8(sender: signer) {
- do_upgrade_from_v7_to_v8(&sender);
-}
-
-
-
-
-public fun do_upgrade_from_v7_to_v8(sender: &signer)
-
-
-
-
-public fun do_upgrade_from_v7_to_v8(sender: &signer) {
- {
- let cap = Oracle::extract_signer_cap(sender);
- GenesisSignerCapability::initialize(sender, cap);
- };
-
- {
- let cap = NFT::extract_signer_cap(sender);
- Account::destroy_signer_cap(cap);
- };
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/vm/stdlib/compiled/latest/doc/Timestamp.md b/vm/stdlib/compiled/latest/doc/Timestamp.md
deleted file mode 100644
index 6db6d682a4..0000000000
--- a/vm/stdlib/compiled/latest/doc/Timestamp.md
+++ /dev/null
@@ -1,496 +0,0 @@
-
-
-
-# Module `0x1::Timestamp`
-
-The module implements onchain timestamp oracle.
-Timestamp is updated on each block. It always steps forward, and never come backward.
-
-
-- [Resource `CurrentTimeMilliseconds`](#0x1_Timestamp_CurrentTimeMilliseconds)
-- [Resource `TimeHasStarted`](#0x1_Timestamp_TimeHasStarted)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_Timestamp_initialize)
-- [Function `update_global_time`](#0x1_Timestamp_update_global_time)
-- [Function `now_seconds`](#0x1_Timestamp_now_seconds)
-- [Function `now_milliseconds`](#0x1_Timestamp_now_milliseconds)
-- [Function `set_time_has_started`](#0x1_Timestamp_set_time_has_started)
-- [Function `is_genesis`](#0x1_Timestamp_is_genesis)
-- [Function `assert_genesis`](#0x1_Timestamp_assert_genesis)
-- [Specification](#@Specification_1)
- - [Function `initialize`](#@Specification_1_initialize)
- - [Function `update_global_time`](#@Specification_1_update_global_time)
- - [Function `now_seconds`](#@Specification_1_now_seconds)
- - [Function `now_milliseconds`](#@Specification_1_now_milliseconds)
- - [Function `set_time_has_started`](#@Specification_1_set_time_has_started)
- - [Function `is_genesis`](#@Specification_1_is_genesis)
- - [Function `assert_genesis`](#@Specification_1_assert_genesis)
-
-
-use 0x1::CoreAddresses;
-use 0x1::Errors;
-
-
-
-
-
-
-## Resource `CurrentTimeMilliseconds`
-
-
-
-struct CurrentTimeMilliseconds has key
-
-
-
-
-milliseconds: u64
-struct TimeHasStarted has key
-
-
-
-
-dummy_field: bool
-const EINVALID_TIMESTAMP: u64 = 14;
-
-
-
-
-
-
-
-
-const ENOT_GENESIS: u64 = 12;
-
-
-
-
-
-
-
-
-const ENOT_INITIALIZED: u64 = 101;
-
-
-
-
-
-
-Conversion factor between seconds and milliseconds
-
-
-const MILLI_CONVERSION_FACTOR: u64 = 1000;
-
-
-
-
-
-
-## Function `initialize`
-
-
-
-public fun initialize(account: &signer, genesis_timestamp: u64)
-
-
-
-
-public fun initialize(account: &signer, genesis_timestamp: u64) {
- // Only callable by the Genesis address
- CoreAddresses::assert_genesis_address(account);
- let milli_timer = CurrentTimeMilliseconds {milliseconds: genesis_timestamp};
- move_to<CurrentTimeMilliseconds>(account, milli_timer);
-}
-
-
-
-
-public fun update_global_time(account: &signer, timestamp: u64)
-
-
-
-
-public fun update_global_time(account: &signer, timestamp: u64) acquires CurrentTimeMilliseconds {
- CoreAddresses::assert_genesis_address(account);
- //Do not update time before time start.
- let global_milli_timer = borrow_global_mut<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
- assert!(timestamp > global_milli_timer.milliseconds, Errors::invalid_argument(EINVALID_TIMESTAMP));
- global_milli_timer.milliseconds = timestamp;
-}
-
-
-
-
-public fun now_seconds(): u64
-
-
-
-
-public fun now_seconds(): u64 acquires CurrentTimeMilliseconds {
- now_milliseconds() / MILLI_CONVERSION_FACTOR
-}
-
-
-
-
-public fun now_milliseconds(): u64
-
-
-
-
-public fun now_milliseconds(): u64 acquires CurrentTimeMilliseconds {
- borrow_global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds
-}
-
-
-
-
-public fun set_time_has_started(account: &signer)
-
-
-
-
-public fun set_time_has_started(account: &signer) {
- CoreAddresses::assert_genesis_address(account);
-
- // Current time must have been initialized.
- assert!(
- exists<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()),
- Errors::invalid_state(ENOT_INITIALIZED)
- );
- move_to(account, TimeHasStarted{});
-}
-
-
-
-
-public fun is_genesis(): bool
-
-
-
-
-public fun is_genesis(): bool {
- !exists<TimeHasStarted>(CoreAddresses::GENESIS_ADDRESS())
-}
-
-
-
-
-public fun assert_genesis()
-
-
-
-
-public fun assert_genesis() {
- assert!(is_genesis(), Errors::invalid_state(ENOT_GENESIS));
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, genesis_timestamp: u64)
-
-
-
-
-
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if exists<CurrentTimeMilliseconds>(Signer::address_of(account));
-ensures exists<CurrentTimeMilliseconds>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `update_global_time`
-
-
-public fun update_global_time(account: &signer, timestamp: u64)
-
-
-
-
-
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if !exists<CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if timestamp <= global<CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS()).milliseconds;
-ensures global<CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS()).milliseconds == timestamp;
-
-
-
-
-
-
-### Function `now_seconds`
-
-
-public fun now_seconds(): u64
-
-
-
-
-
-aborts_if !exists<CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-ensures result == now_milliseconds() / MILLI_CONVERSION_FACTOR;
-
-
-
-
-
-
-
-
-fun spec_now_seconds(): u64 {
- global<CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS()).milliseconds / MILLI_CONVERSION_FACTOR
-}
-
-
-
-
-
-
-### Function `now_milliseconds`
-
-
-public fun now_milliseconds(): u64
-
-
-
-
-
-aborts_if !exists<CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-ensures result == global<CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS()).milliseconds;
-
-
-
-
-
-
-
-
-fun spec_now_millseconds(): u64 {
- global<CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS()).milliseconds
-}
-
-
-
-
-
-
-### Function `set_time_has_started`
-
-
-public fun set_time_has_started(account: &signer)
-
-
-
-
-
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if !exists<CurrentTimeMilliseconds>(Signer::address_of(account));
-aborts_if exists<TimeHasStarted>(Signer::address_of(account));
-ensures exists<TimeHasStarted>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `is_genesis`
-
-
-public fun is_genesis(): bool
-
-
-
-
-
-aborts_if false;
-ensures result == !exists<TimeHasStarted>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `assert_genesis`
-
-
-public fun assert_genesis()
-
-
-
-
-
-pragma opaque = true;
-include AbortsIfNotGenesis;
-
-
-
-Helper schema to specify that a function aborts if not in genesis.
-
-
-
-
-
-schema AbortsIfNotGenesis {
- aborts_if !is_genesis();
-}
-
-
-
-
-
-
-
-
-schema AbortsIfTimestampNotExists {
- aborts_if !exists<CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-}
-
diff --git a/vm/stdlib/compiled/latest/doc/Token.md b/vm/stdlib/compiled/latest/doc/Token.md
deleted file mode 100644
index c49fde938f..0000000000
--- a/vm/stdlib/compiled/latest/doc/Token.md
+++ /dev/null
@@ -1,1941 +0,0 @@
-
-
-
-# Module `0x1::Token`
-
-Token implementation of Starcoin.
-
-
-- [Struct `Token`](#0x1_Token_Token)
-- [Struct `TokenCode`](#0x1_Token_TokenCode)
-- [Resource `MintCapability`](#0x1_Token_MintCapability)
-- [Resource `FixedTimeMintKey`](#0x1_Token_FixedTimeMintKey)
-- [Resource `LinearTimeMintKey`](#0x1_Token_LinearTimeMintKey)
-- [Resource `BurnCapability`](#0x1_Token_BurnCapability)
-- [Struct `MintEvent`](#0x1_Token_MintEvent)
-- [Struct `BurnEvent`](#0x1_Token_BurnEvent)
-- [Resource `TokenInfo`](#0x1_Token_TokenInfo)
-- [Constants](#@Constants_0)
-- [Function `register_token`](#0x1_Token_register_token)
-- [Function `remove_mint_capability`](#0x1_Token_remove_mint_capability)
-- [Function `add_mint_capability`](#0x1_Token_add_mint_capability)
-- [Function `destroy_mint_capability`](#0x1_Token_destroy_mint_capability)
-- [Function `remove_burn_capability`](#0x1_Token_remove_burn_capability)
-- [Function `add_burn_capability`](#0x1_Token_add_burn_capability)
-- [Function `destroy_burn_capability`](#0x1_Token_destroy_burn_capability)
-- [Function `mint`](#0x1_Token_mint)
-- [Function `mint_with_capability`](#0x1_Token_mint_with_capability)
-- [Function `do_mint`](#0x1_Token_do_mint)
-- [Function `issue_fixed_mint_key`](#0x1_Token_issue_fixed_mint_key)
-- [Function `issue_linear_mint_key`](#0x1_Token_issue_linear_mint_key)
-- [Function `destroy_linear_time_key`](#0x1_Token_destroy_linear_time_key)
-- [Function `read_linear_time_key`](#0x1_Token_read_linear_time_key)
-- [Function `burn`](#0x1_Token_burn)
-- [Function `burn_with_capability`](#0x1_Token_burn_with_capability)
-- [Function `zero`](#0x1_Token_zero)
-- [Function `value`](#0x1_Token_value)
-- [Function `split`](#0x1_Token_split)
-- [Function `withdraw`](#0x1_Token_withdraw)
-- [Function `join`](#0x1_Token_join)
-- [Function `deposit`](#0x1_Token_deposit)
-- [Function `destroy_zero`](#0x1_Token_destroy_zero)
-- [Function `scaling_factor`](#0x1_Token_scaling_factor)
-- [Function `market_cap`](#0x1_Token_market_cap)
-- [Function `is_registered_in`](#0x1_Token_is_registered_in)
-- [Function `is_same_token`](#0x1_Token_is_same_token)
-- [Function `token_address`](#0x1_Token_token_address)
-- [Function `token_code`](#0x1_Token_token_code)
-- [Function `name_of`](#0x1_Token_name_of)
-- [Function `name_of_token`](#0x1_Token_name_of_token)
-- [Specification](#@Specification_1)
- - [Function `register_token`](#@Specification_1_register_token)
- - [Function `remove_mint_capability`](#@Specification_1_remove_mint_capability)
- - [Function `add_mint_capability`](#@Specification_1_add_mint_capability)
- - [Function `destroy_mint_capability`](#@Specification_1_destroy_mint_capability)
- - [Function `remove_burn_capability`](#@Specification_1_remove_burn_capability)
- - [Function `add_burn_capability`](#@Specification_1_add_burn_capability)
- - [Function `destroy_burn_capability`](#@Specification_1_destroy_burn_capability)
- - [Function `mint`](#@Specification_1_mint)
- - [Function `mint_with_capability`](#@Specification_1_mint_with_capability)
- - [Function `do_mint`](#@Specification_1_do_mint)
- - [Function `issue_fixed_mint_key`](#@Specification_1_issue_fixed_mint_key)
- - [Function `issue_linear_mint_key`](#@Specification_1_issue_linear_mint_key)
- - [Function `burn`](#@Specification_1_burn)
- - [Function `burn_with_capability`](#@Specification_1_burn_with_capability)
- - [Function `zero`](#@Specification_1_zero)
- - [Function `value`](#@Specification_1_value)
- - [Function `split`](#@Specification_1_split)
- - [Function `withdraw`](#@Specification_1_withdraw)
- - [Function `join`](#@Specification_1_join)
- - [Function `deposit`](#@Specification_1_deposit)
- - [Function `destroy_zero`](#@Specification_1_destroy_zero)
- - [Function `scaling_factor`](#@Specification_1_scaling_factor)
- - [Function `market_cap`](#@Specification_1_market_cap)
- - [Function `is_registered_in`](#@Specification_1_is_registered_in)
- - [Function `is_same_token`](#@Specification_1_is_same_token)
- - [Function `token_address`](#@Specification_1_token_address)
- - [Function `token_code`](#@Specification_1_token_code)
- - [Function `name_of`](#@Specification_1_name_of)
- - [Function `name_of_token`](#@Specification_1_name_of_token)
-
-
-use 0x1::Errors;
-use 0x1::Event;
-use 0x1::Math;
-use 0x1::Signer;
-
-
-
-
-
-
-## Struct `Token`
-
-The token has a TokenType
color that tells us what token the
-value
inside represents.
-
-
-struct Token<TokenType> has store
-
-
-
-
-value: u128
-struct TokenCode has copy, drop, store
-
-
-
-
-addr: address
-module_name: vector<u8>
-name: vector<u8>
-TokenType
to be minted
-
-
-struct MintCapability<TokenType> has store, key
-
-
-
-
-dummy_field: bool
-struct FixedTimeMintKey<TokenType> has store, key
-
-
-
-
-total: u128
-end_time: u64
-struct LinearTimeMintKey<TokenType> has store, key
-
-
-
-
-total: u128
-minted: u128
-start_time: u64
-period: u64
-TokenType
to be burned.
-
-
-struct BurnCapability<TokenType> has store, key
-
-
-
-
-dummy_field: bool
-struct MintEvent has drop, store
-
-
-
-
-amount: u128
-token_code: Token::TokenCode
-struct BurnEvent has drop, store
-
-
-
-
-amount: u128
-token_code: Token::TokenCode
-struct TokenInfo<TokenType> has key
-
-
-
-
-total_value: u128
-TokenType
. Mutable.
-scaling_factor: u128
-Coin1
-mint_events: Event::EventHandle<Token::MintEvent>
-burn_events: Event::EventHandle<Token::BurnEvent>
-const EAMOUNT_EXCEEDS_COIN_VALUE: u64 = 102;
-
-
-
-
-
-
-
-
-const EDEPRECATED_FUNCTION: u64 = 19;
-
-
-
-
-
-
-
-
-const EDESTROY_KEY_NOT_EMPTY: u64 = 104;
-
-
-
-
-
-
-
-
-const EDESTROY_TOKEN_NON_ZERO: u64 = 16;
-
-
-
-
-
-
-
-
-const EEMPTY_KEY: u64 = 106;
-
-
-
-
-
-
-
-
-const EINVALID_ARGUMENT: u64 = 18;
-
-
-
-
-
-
-
-
-const EMINT_AMOUNT_EQUAL_ZERO: u64 = 109;
-
-
-
-
-
-
-
-
-const EMINT_KEY_TIME_LIMIT: u64 = 103;
-
-
-
-
-
-
-
-
-const EPERIOD_NEW: u64 = 108;
-
-
-
-
-
-
-
-
-const EPRECISION_TOO_LARGE: u64 = 105;
-
-
-
-
-
-
-
-
-const ESPLIT: u64 = 107;
-
-
-
-
-
-
-Token register's address should same as TokenType's address.
-
-
-const ETOKEN_REGISTER: u64 = 101;
-
-
-
-
-
-
-2^128 < 10**39
-
-
-const MAX_PRECISION: u8 = 38;
-
-
-
-
-
-
-## Function `register_token`
-
-Register the type TokenType
as a Token and got MintCapability and BurnCapability.
-
-
-public fun register_token<TokenType: store>(account: &signer, precision: u8)
-
-
-
-
-public fun register_token<TokenType: store>(
- account: &signer,
- precision: u8,
-) {
- assert!(precision <= MAX_PRECISION, Errors::invalid_argument(EPRECISION_TOO_LARGE));
- let scaling_factor = Math::pow(10, (precision as u64));
- let token_address = token_address<TokenType>();
- assert!(Signer::address_of(account) == token_address, Errors::requires_address(ETOKEN_REGISTER));
- move_to(account, MintCapability<TokenType> {});
- move_to(account, BurnCapability<TokenType> {});
- move_to(
- account,
- TokenInfo<TokenType> {
- total_value: 0,
- scaling_factor,
- mint_events: Event::new_event_handle<MintEvent>(account),
- burn_events: Event::new_event_handle<BurnEvent>(account),
- },
- );
-}
-
-
-
-
-signer
.
-
-
-public fun remove_mint_capability<TokenType: store>(signer: &signer): Token::MintCapability<TokenType>
-
-
-
-
-public fun remove_mint_capability<TokenType: store>(signer: &signer): MintCapability<TokenType>
-acquires MintCapability {
- move_from<MintCapability<TokenType>>(Signer::address_of(signer))
-}
-
-
-
-
-signer
.
-
-
-public fun add_mint_capability<TokenType: store>(signer: &signer, cap: Token::MintCapability<TokenType>)
-
-
-
-
-public fun add_mint_capability<TokenType: store>(signer: &signer, cap: MintCapability<TokenType>) {
- move_to(signer, cap)
-}
-
-
-
-
-public fun destroy_mint_capability<TokenType: store>(cap: Token::MintCapability<TokenType>)
-
-
-
-
-public fun destroy_mint_capability<TokenType: store>(cap: MintCapability<TokenType>) {
- let MintCapability<TokenType> { } = cap;
-}
-
-
-
-
-signer
.
-
-
-public fun remove_burn_capability<TokenType: store>(signer: &signer): Token::BurnCapability<TokenType>
-
-
-
-
-public fun remove_burn_capability<TokenType: store>(signer: &signer): BurnCapability<TokenType>
-acquires BurnCapability {
- move_from<BurnCapability<TokenType>>(Signer::address_of(signer))
-}
-
-
-
-
-signer
.
-
-
-public fun add_burn_capability<TokenType: store>(signer: &signer, cap: Token::BurnCapability<TokenType>)
-
-
-
-
-public fun add_burn_capability<TokenType: store>(signer: &signer, cap: BurnCapability<TokenType>) {
- move_to(signer, cap)
-}
-
-
-
-
-public fun destroy_burn_capability<TokenType: store>(cap: Token::BurnCapability<TokenType>)
-
-
-
-
-public fun destroy_burn_capability<TokenType: store>(cap: BurnCapability<TokenType>) {
- let BurnCapability<TokenType> { } = cap;
-}
-
-
-
-
-amount
tokens.
-Fails if the sender does not have a published MintCapability.
-
-
-public fun mint<TokenType: store>(account: &signer, amount: u128): Token::Token<TokenType>
-
-
-
-
-public fun mint<TokenType: store>(account: &signer, amount: u128): Token<TokenType>
-acquires TokenInfo, MintCapability {
- mint_with_capability(
- borrow_global<MintCapability<TokenType>>(Signer::address_of(account)),
- amount,
- )
-}
-
-
-
-
-amount
.
-The caller must have a reference to a MintCapability.
-Only the Association account can acquire such a reference, and it can do so only via
-borrow_sender_mint_capability
-
-
-public fun mint_with_capability<TokenType: store>(_capability: &Token::MintCapability<TokenType>, amount: u128): Token::Token<TokenType>
-
-
-
-
-public fun mint_with_capability<TokenType: store>(
- _capability: &MintCapability<TokenType>,
- amount: u128,
-): Token<TokenType> acquires TokenInfo {
- do_mint(amount)
-}
-
-
-
-
-fun do_mint<TokenType: store>(amount: u128): Token::Token<TokenType>
-
-
-
-
-fun do_mint<TokenType: store>(amount: u128): Token<TokenType> acquires TokenInfo {
- // update market cap resource to reflect minting
- let (token_address, module_name, token_name) = name_of_token<TokenType>();
- let info = borrow_global_mut<TokenInfo<TokenType>>(token_address);
- info.total_value = info.total_value + amount;
- Event::emit_event(
- &mut info.mint_events,
- MintEvent {
- amount,
- token_code: TokenCode { addr: token_address, module_name, name: token_name },
- },
- );
- Token<TokenType> { value: amount }
-}
-
-
-
-
-FixedTimeMintKey
with given MintCapability
.
-
-
-public fun issue_fixed_mint_key<TokenType: store>(_capability: &Token::MintCapability<TokenType>, _amount: u128, _period: u64): Token::FixedTimeMintKey<TokenType>
-
-
-
-
-public fun issue_fixed_mint_key<TokenType: store>( _capability: &MintCapability<TokenType>,
- _amount: u128, _period: u64): FixedTimeMintKey<TokenType>{
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-LinearTimeMintKey
with given MintCapability
.
-
-
-public fun issue_linear_mint_key<TokenType: store>(_capability: &Token::MintCapability<TokenType>, _amount: u128, _period: u64): Token::LinearTimeMintKey<TokenType>
-
-
-
-
-public fun issue_linear_mint_key<TokenType: store>( _capability: &MintCapability<TokenType>,
- _amount: u128, _period: u64): LinearTimeMintKey<TokenType>{
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-LinearTimeMintKey
, for deprecated
-
-
-public fun destroy_linear_time_key<TokenType: store>(key: Token::LinearTimeMintKey<TokenType>): (u128, u128, u64, u64)
-
-
-
-
-public fun destroy_linear_time_key<TokenType: store>(key: LinearTimeMintKey<TokenType>): (u128, u128, u64, u64) {
- let LinearTimeMintKey<TokenType> { total, minted, start_time, period} = key;
- (total, minted, start_time, period)
-}
-
-
-
-
-public fun read_linear_time_key<TokenType: store>(key: &Token::LinearTimeMintKey<TokenType>): (u128, u128, u64, u64)
-
-
-
-
-public fun read_linear_time_key<TokenType: store>(key: &LinearTimeMintKey<TokenType>): (u128, u128, u64, u64) {
- (key.total, key.minted, key.start_time, key.period)
-}
-
-
-
-
-signer
.
-
-
-public fun burn<TokenType: store>(account: &signer, tokens: Token::Token<TokenType>)
-
-
-
-
-public fun burn<TokenType: store>(account: &signer, tokens: Token<TokenType>)
-acquires TokenInfo, BurnCapability {
- burn_with_capability(
- borrow_global<BurnCapability<TokenType>>(Signer::address_of(account)),
- tokens,
- )
-}
-
-
-
-
-BurnCapability
.
-
-
-public fun burn_with_capability<TokenType: store>(_capability: &Token::BurnCapability<TokenType>, tokens: Token::Token<TokenType>)
-
-
-
-
-public fun burn_with_capability<TokenType: store>(
- _capability: &BurnCapability<TokenType>,
- tokens: Token<TokenType>,
-) acquires TokenInfo {
- let (token_address, module_name, token_name) = name_of_token<TokenType>();
- let info = borrow_global_mut<TokenInfo<TokenType>>(token_address);
- let Token { value } = tokens;
- info.total_value = info.total_value - value;
- Event::emit_event(
- &mut info.burn_events,
- BurnEvent {
- amount: value,
- token_code: TokenCode { addr: token_address, module_name, name: token_name },
- },
- );
-}
-
-
-
-
-public fun zero<TokenType: store>(): Token::Token<TokenType>
-
-
-
-
-public fun zero<TokenType: store>(): Token<TokenType> {
- Token<TokenType> { value: 0 }
-}
-
-
-
-
-public fun value<TokenType: store>(token: &Token::Token<TokenType>): u128
-
-
-
-
-public fun value<TokenType: store>(token: &Token<TokenType>): u128 {
- token.value
-}
-
-
-
-
-public fun split<TokenType: store>(token: Token::Token<TokenType>, value: u128): (Token::Token<TokenType>, Token::Token<TokenType>)
-
-
-
-
-public fun split<TokenType: store>(
- token: Token<TokenType>,
- value: u128,
-): (Token<TokenType>, Token<TokenType>) {
- let other = withdraw(&mut token, value);
- (token, other)
-}
-
-
-
-
-value
-The new token will have a value = value
-Fails if the tokens value is less than value
-
-
-public fun withdraw<TokenType: store>(token: &mut Token::Token<TokenType>, value: u128): Token::Token<TokenType>
-
-
-
-
-public fun withdraw<TokenType: store>(
- token: &mut Token<TokenType>,
- value: u128,
-): Token<TokenType> {
- // Check that `value` is less than the token's value
- assert!(token.value >= value, Errors::limit_exceeded(EAMOUNT_EXCEEDS_COIN_VALUE));
- token.value = token.value - value;
- Token { value: value }
-}
-
-
-
-
-public fun join<TokenType: store>(token1: Token::Token<TokenType>, token2: Token::Token<TokenType>): Token::Token<TokenType>
-
-
-
-
-public fun join<TokenType: store>(
- token1: Token<TokenType>,
- token2: Token<TokenType>,
-): Token<TokenType> {
- deposit(&mut token1, token2);
- token1
-}
-
-
-
-
-check
token is consumed in the process
-
-
-public fun deposit<TokenType: store>(token: &mut Token::Token<TokenType>, check: Token::Token<TokenType>)
-
-
-
-
-public fun deposit<TokenType: store>(token: &mut Token<TokenType>, check: Token<TokenType>) {
- let Token { value } = check;
- token.value = token.value + value;
-}
-
-
-
-
-public fun destroy_zero<TokenType: store>(token: Token::Token<TokenType>)
-
-
-
-
-public fun destroy_zero<TokenType: store>(token: Token<TokenType>) {
- let Token { value } = token;
- assert!(value == 0, Errors::invalid_state(EDESTROY_TOKEN_NON_ZERO))
-}
-
-
-
-
-TokenType
token.
-
-
-public fun scaling_factor<TokenType: store>(): u128
-
-
-
-
-public fun scaling_factor<TokenType: store>(): u128 acquires TokenInfo {
- let token_address = token_address<TokenType>();
- borrow_global<TokenInfo<TokenType>>(token_address).scaling_factor
-}
-
-
-
-
-TokenType
.
-
-
-public fun market_cap<TokenType: store>(): u128
-
-
-
-
-public fun market_cap<TokenType: store>(): u128 acquires TokenInfo {
- let token_address = token_address<TokenType>();
- borrow_global<TokenInfo<TokenType>>(token_address).total_value
-}
-
-
-
-
-TokenType
is a registered in token_address
.
-
-
-public fun is_registered_in<TokenType: store>(token_address: address): bool
-
-
-
-
-public fun is_registered_in<TokenType: store>(token_address: address): bool {
- exists<TokenInfo<TokenType>>(token_address)
-}
-
-
-
-
-TokenType1
is same with TokenType2
-
-
-public fun is_same_token<TokenType1: store, TokenType2: store>(): bool
-
-
-
-
-public fun is_same_token<TokenType1: store, TokenType2: store>(): bool {
- return token_code<TokenType1>() == token_code<TokenType2>()
-}
-
-
-
-
-public fun token_address<TokenType: store>(): address
-
-
-
-
-public fun token_address<TokenType: store>(): address {
- let (addr, _, _) = name_of<TokenType>();
- addr
-}
-
-
-
-
-public fun token_code<TokenType: store>(): Token::TokenCode
-
-
-
-
-public fun token_code<TokenType: store>(): TokenCode {
- let (addr, module_name, name) = name_of<TokenType>();
- TokenCode {
- addr,
- module_name,
- name
- }
-}
-
-
-
-
-TokenType
.
-
-
-fun name_of<TokenType: store>(): (address, vector<u8>, vector<u8>)
-
-
-
-
-native fun name_of<TokenType: store>(): (address, vector<u8>, vector<u8>);
-
-
-
-
-fun name_of_token<TokenType: store>(): (address, vector<u8>, vector<u8>)
-
-
-
-
-fun name_of_token<TokenType: store>(): (address, vector<u8>, vector<u8>) {
- name_of<TokenType>()
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `register_token`
-
-
-public fun register_token<TokenType: store>(account: &signer, precision: u8)
-
-
-
-
-
-include RegisterTokenAbortsIf<TokenType>;
-include RegisterTokenEnsures<TokenType>;
-
-
-
-
-
-
-
-
-schema RegisterTokenAbortsIf<TokenType> {
- precision: u8;
- account: signer;
- aborts_if precision > MAX_PRECISION;
- aborts_if Signer::address_of(account) != SPEC_TOKEN_TEST_ADDRESS();
- aborts_if exists<MintCapability<TokenType>>(Signer::address_of(account));
- aborts_if exists<BurnCapability<TokenType>>(Signer::address_of(account));
- aborts_if exists<TokenInfo<TokenType>>(Signer::address_of(account));
-}
-
-
-
-
-
-
-
-
-schema RegisterTokenEnsures<TokenType> {
- account: signer;
- ensures exists<MintCapability<TokenType>>(Signer::address_of(account));
- ensures exists<BurnCapability<TokenType>>(Signer::address_of(account));
- ensures exists<TokenInfo<TokenType>>(Signer::address_of(account));
-}
-
-
-
-
-
-
-### Function `remove_mint_capability`
-
-
-public fun remove_mint_capability<TokenType: store>(signer: &signer): Token::MintCapability<TokenType>
-
-
-
-
-
-aborts_if !exists<MintCapability<TokenType>>(Signer::address_of(signer));
-ensures !exists<MintCapability<TokenType>>(Signer::address_of(signer));
-
-
-
-
-
-
-### Function `add_mint_capability`
-
-
-public fun add_mint_capability<TokenType: store>(signer: &signer, cap: Token::MintCapability<TokenType>)
-
-
-
-
-
-aborts_if exists<MintCapability<TokenType>>(Signer::address_of(signer));
-ensures exists<MintCapability<TokenType>>(Signer::address_of(signer));
-
-
-
-
-
-
-### Function `destroy_mint_capability`
-
-
-public fun destroy_mint_capability<TokenType: store>(cap: Token::MintCapability<TokenType>)
-
-
-
-
-
-
-
-### Function `remove_burn_capability`
-
-
-public fun remove_burn_capability<TokenType: store>(signer: &signer): Token::BurnCapability<TokenType>
-
-
-
-
-
-aborts_if !exists<BurnCapability<TokenType>>(Signer::address_of(signer));
-ensures !exists<BurnCapability<TokenType>>(Signer::address_of(signer));
-
-
-
-
-
-
-### Function `add_burn_capability`
-
-
-public fun add_burn_capability<TokenType: store>(signer: &signer, cap: Token::BurnCapability<TokenType>)
-
-
-
-
-
-aborts_if exists<BurnCapability<TokenType>>(Signer::address_of(signer));
-ensures exists<BurnCapability<TokenType>>(Signer::address_of(signer));
-
-
-
-
-
-
-### Function `destroy_burn_capability`
-
-
-public fun destroy_burn_capability<TokenType: store>(cap: Token::BurnCapability<TokenType>)
-
-
-
-
-
-
-
-### Function `mint`
-
-
-public fun mint<TokenType: store>(account: &signer, amount: u128): Token::Token<TokenType>
-
-
-
-
-
-aborts_if spec_abstract_total_value<TokenType>() + amount > MAX_U128;
-aborts_if !exists<MintCapability<TokenType>>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `mint_with_capability`
-
-
-public fun mint_with_capability<TokenType: store>(_capability: &Token::MintCapability<TokenType>, amount: u128): Token::Token<TokenType>
-
-
-
-
-
-aborts_if spec_abstract_total_value<TokenType>() + amount > MAX_U128;
-ensures spec_abstract_total_value<TokenType>() ==
- old(global<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS()).total_value) + amount;
-
-
-
-
-
-
-### Function `do_mint`
-
-
-fun do_mint<TokenType: store>(amount: u128): Token::Token<TokenType>
-
-
-
-
-
-aborts_if !exists<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS());
-aborts_if spec_abstract_total_value<TokenType>() + amount > MAX_U128;
-
-
-
-
-
-
-### Function `issue_fixed_mint_key`
-
-
-public fun issue_fixed_mint_key<TokenType: store>(_capability: &Token::MintCapability<TokenType>, _amount: u128, _period: u64): Token::FixedTimeMintKey<TokenType>
-
-
-
-
-
-
-
-### Function `issue_linear_mint_key`
-
-
-public fun issue_linear_mint_key<TokenType: store>(_capability: &Token::MintCapability<TokenType>, _amount: u128, _period: u64): Token::LinearTimeMintKey<TokenType>
-
-
-
-
-
-
-
-### Function `burn`
-
-
-public fun burn<TokenType: store>(account: &signer, tokens: Token::Token<TokenType>)
-
-
-
-
-
-aborts_if spec_abstract_total_value<TokenType>() - tokens.value < 0;
-aborts_if !exists<BurnCapability<TokenType>>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `burn_with_capability`
-
-
-public fun burn_with_capability<TokenType: store>(_capability: &Token::BurnCapability<TokenType>, tokens: Token::Token<TokenType>)
-
-
-
-
-
-aborts_if spec_abstract_total_value<TokenType>() - tokens.value < 0;
-ensures spec_abstract_total_value<TokenType>() ==
- old(global<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS()).total_value) - tokens.value;
-
-
-
-
-
-
-### Function `zero`
-
-
-public fun zero<TokenType: store>(): Token::Token<TokenType>
-
-
-
-
-
-
-
-### Function `value`
-
-
-public fun value<TokenType: store>(token: &Token::Token<TokenType>): u128
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `split`
-
-
-public fun split<TokenType: store>(token: Token::Token<TokenType>, value: u128): (Token::Token<TokenType>, Token::Token<TokenType>)
-
-
-
-
-
-aborts_if token.value < value;
-ensures old(token.value) == result_1.value + result_2.value;
-
-
-
-
-
-
-### Function `withdraw`
-
-
-public fun withdraw<TokenType: store>(token: &mut Token::Token<TokenType>, value: u128): Token::Token<TokenType>
-
-
-
-
-
-aborts_if token.value < value;
-ensures result.value == value;
-ensures token.value == old(token).value - value;
-
-
-
-
-
-
-### Function `join`
-
-
-public fun join<TokenType: store>(token1: Token::Token<TokenType>, token2: Token::Token<TokenType>): Token::Token<TokenType>
-
-
-
-
-
-aborts_if token1.value + token2.value > max_u128();
-ensures old(token1).value + old(token2).value == result.value;
-ensures token1.value + token2.value == result.value;
-
-
-
-
-
-
-### Function `deposit`
-
-
-public fun deposit<TokenType: store>(token: &mut Token::Token<TokenType>, check: Token::Token<TokenType>)
-
-
-
-
-
-aborts_if token.value + check.value > max_u128();
-ensures old(token).value + check.value == token.value;
-
-
-
-
-
-
-### Function `destroy_zero`
-
-
-public fun destroy_zero<TokenType: store>(token: Token::Token<TokenType>)
-
-
-
-
-
-aborts_if token.value > 0;
-
-
-
-
-
-
-### Function `scaling_factor`
-
-
-public fun scaling_factor<TokenType: store>(): u128
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `market_cap`
-
-
-public fun market_cap<TokenType: store>(): u128
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `is_registered_in`
-
-
-public fun is_registered_in<TokenType: store>(token_address: address): bool
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `is_same_token`
-
-
-public fun is_same_token<TokenType1: store, TokenType2: store>(): bool
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `token_address`
-
-
-public fun token_address<TokenType: store>(): address
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures [abstract] exists<TokenInfo<TokenType>>(result);
-ensures [abstract] result == SPEC_TOKEN_TEST_ADDRESS();
-ensures [abstract] global<TokenInfo<TokenType>>(result).total_value == 100000000u128;
-
-
-
-
-
-
-### Function `token_code`
-
-
-public fun token_code<TokenType: store>(): Token::TokenCode
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-
-
-
-We use an uninterpreted function to represent the result of derived address. The actual value
-does not matter for the verification of callers.
-
-
-
-
-
-fun spec_token_code<TokenType>(): TokenCode;
-
-
-
-
-
-
-### Function `name_of`
-
-
-fun name_of<TokenType: store>(): (address, vector<u8>, vector<u8>)
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-
-
-
-
-
-
-### Function `name_of_token`
-
-
-fun name_of_token<TokenType: store>(): (address, vector<u8>, vector<u8>)
-
-
-
-
-
-pragma opaque = true;
-aborts_if false;
-ensures [abstract] exists<TokenInfo<TokenType>>(result_1);
-ensures [abstract] result_1 == SPEC_TOKEN_TEST_ADDRESS();
-ensures [abstract] global<TokenInfo<TokenType>>(result_1).total_value == 100000000u128;
-
-
-
-
-
-
-
-
-fun SPEC_TOKEN_TEST_ADDRESS(): address {
- @0x2
-}
-
-
-
-
-
-
-
-
-fun spec_abstract_total_value<TokenType>(): u128 {
- global<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS()).total_value
-}
-
diff --git a/vm/stdlib/compiled/latest/doc/TransactionFee.md b/vm/stdlib/compiled/latest/doc/TransactionFee.md
deleted file mode 100644
index b0324f2ec4..0000000000
--- a/vm/stdlib/compiled/latest/doc/TransactionFee.md
+++ /dev/null
@@ -1,265 +0,0 @@
-
-
-
-# Module `0x1::TransactionFee`
-
-TransactionFee
collect gas fees used by transactions in blocks temporarily.
-Then they are distributed in TransactionManager
.
-
-
-- [Resource `TransactionFee`](#0x1_TransactionFee_TransactionFee)
-- [Function `initialize`](#0x1_TransactionFee_initialize)
-- [Function `add_txn_fee_token`](#0x1_TransactionFee_add_txn_fee_token)
-- [Function `pay_fee`](#0x1_TransactionFee_pay_fee)
-- [Function `distribute_transaction_fees`](#0x1_TransactionFee_distribute_transaction_fees)
-- [Specification](#@Specification_0)
- - [Function `initialize`](#@Specification_0_initialize)
- - [Function `add_txn_fee_token`](#@Specification_0_add_txn_fee_token)
- - [Function `pay_fee`](#@Specification_0_pay_fee)
- - [Function `distribute_transaction_fees`](#@Specification_0_distribute_transaction_fees)
-
-
-use 0x1::CoreAddresses;
-use 0x1::STC;
-use 0x1::Timestamp;
-use 0x1::Token;
-
-
-
-
-
-
-## Resource `TransactionFee`
-
-The TransactionFee
resource holds a preburn resource for each
-fiat TokenType
that can be collected as a transaction fee.
-
-
-struct TransactionFee<TokenType> has key
-
-
-
-
-fee: Token::Token<TokenType>
-TransactionFee
resource with the TreasuryCompliance account.
-
-
-public fun initialize(account: &signer)
-
-
-
-
-public fun initialize(
- account: &signer,
-) {
- Timestamp::assert_genesis();
- CoreAddresses::assert_genesis_address(account);
-
- // accept fees in all the currencies
- add_txn_fee_token<STC>(account);
-}
-
-
-
-
-Preburn<TokenType>
resource under fee_account
-
-
-fun add_txn_fee_token<TokenType: store>(account: &signer)
-
-
-
-
-fun add_txn_fee_token<TokenType: store>(
- account: &signer,
-) {
- move_to(
- account,
- TransactionFee<TokenType> {
- fee: Token::zero(),
- }
- )
- }
-
-
-
-
-token
into the transaction fees bucket
-
-
-public fun pay_fee<TokenType: store>(token: Token::Token<TokenType>)
-
-
-
-
-public fun pay_fee<TokenType: store>(token: Token<TokenType>) acquires TransactionFee {
- let txn_fees = borrow_global_mut<TransactionFee<TokenType>>(
- CoreAddresses::GENESIS_ADDRESS()
- );
- Token::deposit(&mut txn_fees.fee, token)
-}
-
-
-
-
-TokenType
token.
-If the TokenType
is STC, it unpacks the token and preburns the
-underlying fiat.
-
-
-public fun distribute_transaction_fees<TokenType: store>(account: &signer): Token::Token<TokenType>
-
-
-
-
-public fun distribute_transaction_fees<TokenType: store>(
- account: &signer,
-): Token<TokenType> acquires TransactionFee {
- let fee_address = CoreAddresses::GENESIS_ADDRESS();
- CoreAddresses::assert_genesis_address(account);
-
- // extract fees
- let txn_fees = borrow_global_mut<TransactionFee<TokenType>>(fee_address);
- let value = Token::value<TokenType>(&txn_fees.fee);
- if (value > 0) {
- Token::withdraw(&mut txn_fees.fee, value)
- }else {
- Token::zero<TokenType>()
- }
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer)
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if exists<TransactionFee<STC>>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `add_txn_fee_token`
-
-
-fun add_txn_fee_token<TokenType: store>(account: &signer)
-
-
-
-
-
-aborts_if exists<TransactionFee<TokenType>>(Signer::address_of(account));
-
-
-
-
-
-
-### Function `pay_fee`
-
-
-public fun pay_fee<TokenType: store>(token: Token::Token<TokenType>)
-
-
-
-
-
-aborts_if !exists<TransactionFee<TokenType>>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if global<TransactionFee<TokenType>>(CoreAddresses::SPEC_GENESIS_ADDRESS()).fee.value + token.value > max_u128();
-
-
-
-
-
-
-### Function `distribute_transaction_fees`
-
-
-public fun distribute_transaction_fees<TokenType: store>(account: &signer): Token::Token<TokenType>
-
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/TransactionManager.md b/vm/stdlib/compiled/latest/doc/TransactionManager.md
deleted file mode 100644
index e7d53fbf5a..0000000000
--- a/vm/stdlib/compiled/latest/doc/TransactionManager.md
+++ /dev/null
@@ -1,442 +0,0 @@
-
-
-
-# Module `0x1::TransactionManager`
-
-TransactionManager
manages:
-1. prologue and epilogue of transactions.
-2. prologue of blocks.
-
-
-- [Constants](#@Constants_0)
-- [Function `prologue`](#0x1_TransactionManager_prologue)
-- [Function `epilogue`](#0x1_TransactionManager_epilogue)
-- [Function `epilogue_v2`](#0x1_TransactionManager_epilogue_v2)
-- [Function `block_prologue`](#0x1_TransactionManager_block_prologue)
-- [Specification](#@Specification_1)
- - [Function `prologue`](#@Specification_1_prologue)
- - [Function `epilogue`](#@Specification_1_epilogue)
- - [Function `block_prologue`](#@Specification_1_block_prologue)
-
-
-use 0x1::Account;
-use 0x1::Block;
-use 0x1::BlockReward;
-use 0x1::ChainId;
-use 0x1::CoreAddresses;
-use 0x1::Epoch;
-use 0x1::Errors;
-use 0x1::PackageTxnManager;
-use 0x1::STC;
-use 0x1::Signer;
-use 0x1::Timestamp;
-use 0x1::Token;
-use 0x1::TransactionFee;
-use 0x1::TransactionPublishOption;
-use 0x1::TransactionTimeout;
-use 0x1::Vector;
-
-
-
-
-
-
-## Constants
-
-
-
-
-
-
-const EPROLOGUE_ACCOUNT_DOES_NOT_EXIST: u64 = 0;
-
-
-
-
-
-
-
-
-const EPROLOGUE_BAD_CHAIN_ID: u64 = 6;
-
-
-
-
-
-
-
-
-const EPROLOGUE_MODULE_NOT_ALLOWED: u64 = 7;
-
-
-
-
-
-
-
-
-const EPROLOGUE_SCRIPT_NOT_ALLOWED: u64 = 8;
-
-
-
-
-
-
-
-
-const EPROLOGUE_TRANSACTION_EXPIRED: u64 = 5;
-
-
-
-
-
-
-
-
-const TXN_PAYLOAD_TYPE_PACKAGE: u8 = 1;
-
-
-
-
-
-
-
-
-const TXN_PAYLOAD_TYPE_SCRIPT: u8 = 0;
-
-
-
-
-
-
-
-
-const TXN_PAYLOAD_TYPE_SCRIPT_FUNCTION: u8 = 2;
-
-
-
-
-
-
-## Function `prologue`
-
-The prologue is invoked at the beginning of every transaction
-It verifies:
-- The account's auth key matches the transaction's public key
-- That the account has enough balance to pay for all of the gas
-- That the sequence number matches the transaction's sequence key
-
-
-public fun prologue<TokenType: store>(account: signer, txn_sender: address, txn_sequence_number: u64, txn_authentication_key_preimage: vector<u8>, txn_gas_price: u64, txn_max_gas_units: u64, txn_expiration_time: u64, chain_id: u8, txn_payload_type: u8, txn_script_or_package_hash: vector<u8>, txn_package_address: address)
-
-
-
-
-public fun prologue<TokenType: store>(
- account: signer,
- txn_sender: address,
- txn_sequence_number: u64,
- txn_authentication_key_preimage: vector<u8>,
- txn_gas_price: u64,
- txn_max_gas_units: u64,
- txn_expiration_time: u64,
- chain_id: u8,
- txn_payload_type: u8,
- txn_script_or_package_hash: vector<u8>,
- txn_package_address: address,
-) {
- // Can only be invoked by genesis account
- assert!(
- Signer::address_of(&account) == CoreAddresses::GENESIS_ADDRESS(),
- Errors::requires_address(EPROLOGUE_ACCOUNT_DOES_NOT_EXIST),
- );
- // Check that the chain ID stored on-chain matches the chain ID
- // specified by the transaction
- assert!(ChainId::get() == chain_id, Errors::invalid_argument(EPROLOGUE_BAD_CHAIN_ID));
- Account::txn_prologue<TokenType>(
- &account,
- txn_sender,
- txn_sequence_number,
- txn_authentication_key_preimage,
- txn_gas_price,
- txn_max_gas_units,
- );
- assert!(
- TransactionTimeout::is_valid_transaction_timestamp(txn_expiration_time),
- Errors::invalid_argument(EPROLOGUE_TRANSACTION_EXPIRED),
- );
- if (txn_payload_type == TXN_PAYLOAD_TYPE_PACKAGE) {
- // stdlib upgrade is not affected by PublishOption
- if (txn_package_address != CoreAddresses::GENESIS_ADDRESS()) {
- assert!(
- TransactionPublishOption::is_module_allowed(Signer::address_of(&account)),
- Errors::invalid_argument(EPROLOGUE_MODULE_NOT_ALLOWED),
- );
- };
- PackageTxnManager::package_txn_prologue_v2(
- &account,
- txn_sender,
- txn_package_address,
- txn_script_or_package_hash,
- );
- } else if (txn_payload_type == TXN_PAYLOAD_TYPE_SCRIPT) {
- assert!(
- TransactionPublishOption::is_script_allowed(
- Signer::address_of(&account),
- ),
- Errors::invalid_argument(EPROLOGUE_SCRIPT_NOT_ALLOWED),
- );
- };
- // do nothing for TXN_PAYLOAD_TYPE_SCRIPT_FUNCTION
-}
-
-
-
-
-public fun epilogue<TokenType: store>(account: signer, txn_sender: address, txn_sequence_number: u64, txn_gas_price: u64, txn_max_gas_units: u64, gas_units_remaining: u64, txn_payload_type: u8, _txn_script_or_package_hash: vector<u8>, txn_package_address: address, success: bool)
-
-
-
-
-public fun epilogue<TokenType: store>(
- account: signer,
- txn_sender: address,
- txn_sequence_number: u64,
- txn_gas_price: u64,
- txn_max_gas_units: u64,
- gas_units_remaining: u64,
- txn_payload_type: u8,
- _txn_script_or_package_hash: vector<u8>,
- txn_package_address: address,
- // txn execute success or fail.
- success: bool,
-) {
- epilogue_v2<TokenType>(account, txn_sender, txn_sequence_number, Vector::empty(), txn_gas_price, txn_max_gas_units, gas_units_remaining, txn_payload_type, _txn_script_or_package_hash, txn_package_address, success)
-}
-
-
-
-
-public fun epilogue_v2<TokenType: store>(account: signer, txn_sender: address, txn_sequence_number: u64, txn_authentication_key_preimage: vector<u8>, txn_gas_price: u64, txn_max_gas_units: u64, gas_units_remaining: u64, txn_payload_type: u8, _txn_script_or_package_hash: vector<u8>, txn_package_address: address, success: bool)
-
-
-
-
-public fun epilogue_v2<TokenType: store>(
- account: signer,
- txn_sender: address,
- txn_sequence_number: u64,
- txn_authentication_key_preimage: vector<u8>,
- txn_gas_price: u64,
- txn_max_gas_units: u64,
- gas_units_remaining: u64,
- txn_payload_type: u8,
- _txn_script_or_package_hash: vector<u8>,
- txn_package_address: address,
- // txn execute success or fail.
- success: bool,
-) {
- CoreAddresses::assert_genesis_address(&account);
- Account::txn_epilogue_v2<TokenType>(
- &account,
- txn_sender,
- txn_sequence_number,
- txn_authentication_key_preimage,
- txn_gas_price,
- txn_max_gas_units,
- gas_units_remaining,
- );
- if (txn_payload_type == TXN_PAYLOAD_TYPE_PACKAGE) {
- PackageTxnManager::package_txn_epilogue(
- &account,
- txn_sender,
- txn_package_address,
- success,
- );
- }
-}
-
-
-
-
-public fun block_prologue(account: signer, parent_hash: vector<u8>, timestamp: u64, author: address, auth_key_vec: vector<u8>, uncles: u64, number: u64, chain_id: u8, parent_gas_used: u64)
-
-
-
-
-public fun block_prologue(
- account: signer,
- parent_hash: vector<u8>,
- timestamp: u64,
- author: address,
- auth_key_vec: vector<u8>,
- uncles: u64,
- number: u64,
- chain_id: u8,
- parent_gas_used: u64,
-) {
- // Can only be invoked by genesis account
- CoreAddresses::assert_genesis_address(&account);
- // Check that the chain ID stored on-chain matches the chain ID
- // specified by the transaction
- assert!(ChainId::get() == chain_id, Errors::invalid_argument(EPROLOGUE_BAD_CHAIN_ID));
-
- // deal with previous block first.
- let txn_fee = TransactionFee::distribute_transaction_fees<STC>(&account);
-
- // then deal with current block.
- Timestamp::update_global_time(&account, timestamp);
- Block::process_block_metadata(
- &account,
- parent_hash,
- author,
- timestamp,
- uncles,
- number,
- );
- let reward = Epoch::adjust_epoch(&account, number, timestamp, uncles, parent_gas_used);
- // pass in previous block gas fees.
- BlockReward::process_block_reward(&account, number, reward, author, auth_key_vec, txn_fee);
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `prologue`
-
-
-public fun prologue<TokenType: store>(account: signer, txn_sender: address, txn_sequence_number: u64, txn_authentication_key_preimage: vector<u8>, txn_gas_price: u64, txn_max_gas_units: u64, txn_expiration_time: u64, chain_id: u8, txn_payload_type: u8, txn_script_or_package_hash: vector<u8>, txn_package_address: address)
-
-
-
-
-
-aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-aborts_if !exists<ChainId::ChainId>(CoreAddresses::GENESIS_ADDRESS());
-aborts_if ChainId::get() != chain_id;
-aborts_if !exists<Account::Account>(txn_sender);
-aborts_if Hash::sha3_256(txn_authentication_key_preimage) != global<Account::Account>(txn_sender).authentication_key;
-aborts_if txn_gas_price * txn_max_gas_units > max_u64();
-include Timestamp::AbortsIfTimestampNotExists;
-include Block::AbortsIfBlockMetadataNotExist;
-aborts_if txn_gas_price * txn_max_gas_units > 0 && !exists<Account::Balance<TokenType>>(txn_sender);
-aborts_if txn_gas_price * txn_max_gas_units > 0 && StarcoinFramework::Token::spec_token_code<TokenType>() != StarcoinFramework::Token::spec_token_code<STC>();
-aborts_if txn_gas_price * txn_max_gas_units > 0 && global<Account::Balance<TokenType>>(txn_sender).token.value < txn_gas_price * txn_max_gas_units;
-aborts_if txn_gas_price * txn_max_gas_units > 0 && txn_sequence_number >= max_u64();
-aborts_if txn_sequence_number < global<Account::Account>(txn_sender).sequence_number;
-aborts_if txn_sequence_number != global<Account::Account>(txn_sender).sequence_number;
-include TransactionTimeout::AbortsIfTimestampNotValid;
-aborts_if !TransactionTimeout::spec_is_valid_transaction_timestamp(txn_expiration_time);
-include TransactionPublishOption::AbortsIfTxnPublishOptionNotExistWithBool {
- is_script_or_package: (txn_payload_type == TXN_PAYLOAD_TYPE_PACKAGE || txn_payload_type == TXN_PAYLOAD_TYPE_SCRIPT),
-};
-aborts_if txn_payload_type == TXN_PAYLOAD_TYPE_PACKAGE && txn_package_address != CoreAddresses::GENESIS_ADDRESS() && !TransactionPublishOption::spec_is_module_allowed(Signer::address_of(account));
-aborts_if txn_payload_type == TXN_PAYLOAD_TYPE_SCRIPT && !TransactionPublishOption::spec_is_script_allowed(Signer::address_of(account));
-include PackageTxnManager::CheckPackageTxnAbortsIfWithType{is_package: (txn_payload_type == TXN_PAYLOAD_TYPE_PACKAGE), sender:txn_sender, package_address: txn_package_address, package_hash: txn_script_or_package_hash};
-
-
-
-
-
-
-### Function `epilogue`
-
-
-public fun epilogue<TokenType: store>(account: signer, txn_sender: address, txn_sequence_number: u64, txn_gas_price: u64, txn_max_gas_units: u64, gas_units_remaining: u64, txn_payload_type: u8, _txn_script_or_package_hash: vector<u8>, txn_package_address: address, success: bool)
-
-
-
-
-
-pragma verify = false;
-include CoreAddresses::AbortsIfNotGenesisAddress;
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if !exists<Account::Account>(txn_sender);
-aborts_if !exists<Account::Balance<TokenType>>(txn_sender);
-aborts_if txn_max_gas_units < gas_units_remaining;
-aborts_if txn_sequence_number + 1 > max_u64();
-aborts_if txn_gas_price * (txn_max_gas_units - gas_units_remaining) > max_u64();
-include PackageTxnManager::AbortsIfPackageTxnEpilogue {
- is_package: (txn_payload_type == TXN_PAYLOAD_TYPE_PACKAGE),
- package_address: txn_package_address,
- success: success,
-};
-
-
-
-
-
-
-### Function `block_prologue`
-
-
-public fun block_prologue(account: signer, parent_hash: vector<u8>, timestamp: u64, author: address, auth_key_vec: vector<u8>, uncles: u64, number: u64, chain_id: u8, parent_gas_used: u64)
-
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/TransactionPublishOption.md b/vm/stdlib/compiled/latest/doc/TransactionPublishOption.md
deleted file mode 100644
index efe406fe14..0000000000
--- a/vm/stdlib/compiled/latest/doc/TransactionPublishOption.md
+++ /dev/null
@@ -1,368 +0,0 @@
-
-
-
-# Module `0x1::TransactionPublishOption`
-
-TransactionPublishOption
provide an option to limit:
-- whether user can use script or publish custom modules on chain.
-
-
-- [Struct `TransactionPublishOption`](#0x1_TransactionPublishOption_TransactionPublishOption)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_TransactionPublishOption_initialize)
-- [Function `new_transaction_publish_option`](#0x1_TransactionPublishOption_new_transaction_publish_option)
-- [Function `is_script_allowed`](#0x1_TransactionPublishOption_is_script_allowed)
-- [Function `is_module_allowed`](#0x1_TransactionPublishOption_is_module_allowed)
-- [Specification](#@Specification_1)
- - [Function `initialize`](#@Specification_1_initialize)
- - [Function `new_transaction_publish_option`](#@Specification_1_new_transaction_publish_option)
- - [Function `is_script_allowed`](#@Specification_1_is_script_allowed)
- - [Function `is_module_allowed`](#@Specification_1_is_module_allowed)
-
-
-use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::Errors;
-use 0x1::Signer;
-use 0x1::Timestamp;
-
-
-
-
-
-
-## Struct `TransactionPublishOption`
-
-Defines and holds the publishing policies for the VM. There are three possible configurations:
-1. !script_allowed && !module_publishing_allowed No module publishing, only script function in module are allowed.
-2. script_allowed && !module_publishing_allowed No module publishing, custom scripts are allowed.
-3. script_allowed && module_publishing_allowed Both module publishing and custom scripts are allowed.
-We represent these as the following resource.
-
-
-struct TransactionPublishOption has copy, drop, store
-
-
-
-
-script_allowed: bool
-module_publishing_allowed: bool
-const EINVALID_ARGUMENT: u64 = 18;
-
-
-
-
-
-
-The script hash already exists in the allowlist
-
-
-const EALLOWLIST_ALREADY_CONTAINS_SCRIPT: u64 = 1002;
-
-
-
-
-
-
-The script hash has an invalid length
-
-
-const EINVALID_SCRIPT_HASH: u64 = 1001;
-
-
-
-
-
-
-
-
-const EPROLOGUE_ACCOUNT_DOES_NOT_EXIST: u64 = 0;
-
-
-
-
-
-
-
-
-const SCRIPT_HASH_LENGTH: u64 = 32;
-
-
-
-
-
-
-## Function `initialize`
-
-Module initialization.
-
-
-public fun initialize(account: &signer, script_allowed: bool, module_publishing_allowed: bool)
-
-
-
-
-public fun initialize(
- account: &signer,
- script_allowed: bool,
- module_publishing_allowed: bool,
-) {
- Timestamp::assert_genesis();
- assert!(
- Signer::address_of(account) == CoreAddresses::GENESIS_ADDRESS(),
- Errors::requires_address(EPROLOGUE_ACCOUNT_DOES_NOT_EXIST),
- );
- let transaction_publish_option = Self::new_transaction_publish_option(script_allowed, module_publishing_allowed);
- Config::publish_new_config(
- account,
- transaction_publish_option,
- );
-}
-
-
-
-
-public fun new_transaction_publish_option(script_allowed: bool, module_publishing_allowed: bool): TransactionPublishOption::TransactionPublishOption
-
-
-
-
-public fun new_transaction_publish_option(
- script_allowed: bool,
- module_publishing_allowed: bool,
-): TransactionPublishOption {
- TransactionPublishOption { script_allowed, module_publishing_allowed }
-}
-
-
-
-
-public fun is_script_allowed(account: address): bool
-
-
-
-
-public fun is_script_allowed(account: address): bool {
- let publish_option = Config::get_by_address<TransactionPublishOption>(account);
- publish_option.script_allowed
-}
-
-
-
-
-public fun is_module_allowed(account: address): bool
-
-
-
-
-public fun is_module_allowed(account: address): bool {
- let publish_option = Config::get_by_address<TransactionPublishOption>(account);
- publish_option.module_publishing_allowed
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-
-
-fun spec_is_script_allowed(addr: address) : bool{
- let publish_option = Config::get_by_address<TransactionPublishOption>(addr);
- publish_option.script_allowed
-}
-
-
-
-
-
-
-
-
-fun spec_is_module_allowed(addr: address) : bool{
- let publish_option = Config::get_by_address<TransactionPublishOption>(addr);
- publish_option.module_publishing_allowed
-}
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, script_allowed: bool, module_publishing_allowed: bool)
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-include Config::PublishNewConfigAbortsIf<TransactionPublishOption>;
-include Config::PublishNewConfigEnsures<TransactionPublishOption>;
-
-
-
-
-
-
-### Function `new_transaction_publish_option`
-
-
-public fun new_transaction_publish_option(script_allowed: bool, module_publishing_allowed: bool): TransactionPublishOption::TransactionPublishOption
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `is_script_allowed`
-
-
-public fun is_script_allowed(account: address): bool
-
-
-
-
-
-include Config::AbortsIfConfigNotExist<TransactionPublishOption>{
- addr: account
-};
-
-
-
-
-
-
-### Function `is_module_allowed`
-
-
-public fun is_module_allowed(account: address): bool
-
-
-
-
-
-include Config::AbortsIfConfigNotExist<TransactionPublishOption>{
- addr: account
-};
-
-
-
-
-
-
-
-
-schema AbortsIfTxnPublishOptionNotExist {
- include Config::AbortsIfConfigNotExist<TransactionPublishOption>{
- addr: CoreAddresses::SPEC_GENESIS_ADDRESS()
- };
-}
-
-
-
-
-
-
-
-
-schema AbortsIfTxnPublishOptionNotExistWithBool {
- is_script_or_package : bool;
- aborts_if is_script_or_package && !exists<Config::Config<TransactionPublishOption>>(CoreAddresses::GENESIS_ADDRESS());
-}
-
diff --git a/vm/stdlib/compiled/latest/doc/TransactionTimeout.md b/vm/stdlib/compiled/latest/doc/TransactionTimeout.md
deleted file mode 100644
index a2cea59222..0000000000
--- a/vm/stdlib/compiled/latest/doc/TransactionTimeout.md
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
-# Module `0x1::TransactionTimeout`
-
-A module used to check expiration time of transactions.
-
-
-- [Function `is_valid_transaction_timestamp`](#0x1_TransactionTimeout_is_valid_transaction_timestamp)
-- [Specification](#@Specification_0)
- - [Function `is_valid_transaction_timestamp`](#@Specification_0_is_valid_transaction_timestamp)
-
-
-use 0x1::Block;
-use 0x1::Timestamp;
-use 0x1::TransactionTimeoutConfig;
-
-
-
-
-
-
-## Function `is_valid_transaction_timestamp`
-
-Check whether the given timestamp is valid for transactions.
-
-
-public fun is_valid_transaction_timestamp(txn_timestamp: u64): bool
-
-
-
-
-public fun is_valid_transaction_timestamp(txn_timestamp: u64): bool {
- let current_block_time = Timestamp::now_seconds();
- let block_number = Block::get_current_block_number();
- // before first block, just require txn_timestamp > genesis timestamp.
- if (block_number == 0) {
- return txn_timestamp > current_block_time
- };
- let timeout = TransactionTimeoutConfig::duration_seconds();
- let max_txn_time = current_block_time + timeout;
- current_block_time < txn_timestamp && txn_timestamp < max_txn_time
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-
-
-fun spec_is_valid_transaction_timestamp(txn_timestamp: u64):bool {
- if (Block::get_current_block_number() == 0) {
- txn_timestamp > Timestamp::now_seconds()
- } else {
- Timestamp::now_seconds() < txn_timestamp && txn_timestamp <
- (Timestamp::now_seconds() + TransactionTimeoutConfig::duration_seconds())
- }
-}
-
-
-
-
-
-
-### Function `is_valid_transaction_timestamp`
-
-
-public fun is_valid_transaction_timestamp(txn_timestamp: u64): bool
-
-
-
-
-
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if !exists<Block::BlockMetadata>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-include Timestamp::AbortsIfTimestampNotExists;
-aborts_if Block::get_current_block_number() != 0 && Timestamp::now_seconds() + TransactionTimeoutConfig::duration_seconds() > max_u64();
-aborts_if Block::get_current_block_number() != 0 && !exists<Config::Config<TransactionTimeoutConfig::TransactionTimeoutConfig>>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-
-
-schema AbortsIfTimestampNotValid {
- aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
- aborts_if !exists<Block::BlockMetadata>(CoreAddresses::SPEC_GENESIS_ADDRESS());
- include Timestamp::AbortsIfTimestampNotExists;
- aborts_if Block::get_current_block_number() != 0 && Timestamp::now_seconds() + TransactionTimeoutConfig::duration_seconds() > max_u64();
- aborts_if Block::get_current_block_number() != 0 && !exists<Config::Config<TransactionTimeoutConfig::TransactionTimeoutConfig>>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-}
-
diff --git a/vm/stdlib/compiled/latest/doc/TransactionTimeoutConfig.md b/vm/stdlib/compiled/latest/doc/TransactionTimeoutConfig.md
deleted file mode 100644
index 66cb29cde5..0000000000
--- a/vm/stdlib/compiled/latest/doc/TransactionTimeoutConfig.md
+++ /dev/null
@@ -1,255 +0,0 @@
-
-
-
-# Module `0x1::TransactionTimeoutConfig`
-
-Onchain configuration for timeout setting of transaction.
-
-
-- [Struct `TransactionTimeoutConfig`](#0x1_TransactionTimeoutConfig_TransactionTimeoutConfig)
-- [Function `initialize`](#0x1_TransactionTimeoutConfig_initialize)
-- [Function `new_transaction_timeout_config`](#0x1_TransactionTimeoutConfig_new_transaction_timeout_config)
-- [Function `get_transaction_timeout_config`](#0x1_TransactionTimeoutConfig_get_transaction_timeout_config)
-- [Function `duration_seconds`](#0x1_TransactionTimeoutConfig_duration_seconds)
-- [Specification](#@Specification_0)
- - [Function `initialize`](#@Specification_0_initialize)
- - [Function `new_transaction_timeout_config`](#@Specification_0_new_transaction_timeout_config)
- - [Function `get_transaction_timeout_config`](#@Specification_0_get_transaction_timeout_config)
- - [Function `duration_seconds`](#@Specification_0_duration_seconds)
-
-
-use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::Timestamp;
-
-
-
-
-
-
-## Struct `TransactionTimeoutConfig`
-
-config structs.
-
-
-struct TransactionTimeoutConfig has copy, drop, store
-
-
-
-
-duration_seconds: u64
-public fun initialize(account: &signer, duration_seconds: u64)
-
-
-
-
-public fun initialize(account: &signer, duration_seconds: u64) {
- Timestamp::assert_genesis();
- CoreAddresses::assert_genesis_address(account);
-
- Config::publish_new_config<Self::TransactionTimeoutConfig>(
- account,
- new_transaction_timeout_config(duration_seconds)
- );
-}
-
-
-
-
-public fun new_transaction_timeout_config(duration_seconds: u64): TransactionTimeoutConfig::TransactionTimeoutConfig
-
-
-
-
-public fun new_transaction_timeout_config(duration_seconds: u64) : TransactionTimeoutConfig {
- TransactionTimeoutConfig {duration_seconds: duration_seconds}
-}
-
-
-
-
-public fun get_transaction_timeout_config(): TransactionTimeoutConfig::TransactionTimeoutConfig
-
-
-
-
-public fun get_transaction_timeout_config(): TransactionTimeoutConfig {
- Config::get_by_address<TransactionTimeoutConfig>(CoreAddresses::GENESIS_ADDRESS())
-}
-
-
-
-
-public fun duration_seconds(): u64
-
-
-
-
-public fun duration_seconds() :u64 {
- let config = get_transaction_timeout_config();
- config.duration_seconds
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict = true;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, duration_seconds: u64)
-
-
-
-
-
-aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-include Config::PublishNewConfigAbortsIf<TransactionTimeoutConfig>;
-include Config::PublishNewConfigEnsures<TransactionTimeoutConfig>;
-
-
-
-
-
-
-### Function `new_transaction_timeout_config`
-
-
-public fun new_transaction_timeout_config(duration_seconds: u64): TransactionTimeoutConfig::TransactionTimeoutConfig
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `get_transaction_timeout_config`
-
-
-public fun get_transaction_timeout_config(): TransactionTimeoutConfig::TransactionTimeoutConfig
-
-
-
-
-
-include Config::AbortsIfConfigNotExist<TransactionTimeoutConfig>{
- addr: CoreAddresses::GENESIS_ADDRESS()
-};
-
-
-
-
-
-
-### Function `duration_seconds`
-
-
-public fun duration_seconds(): u64
-
-
-
-
-
-include Config::AbortsIfConfigNotExist<TransactionTimeoutConfig>{
- addr: CoreAddresses::GENESIS_ADDRESS()
-};
-
-
-
-
-
-
-
-
-schema AbortsIfTxnTimeoutConfigNotExist {
- include Config::AbortsIfConfigNotExist<TransactionTimeoutConfig>{
- addr: CoreAddresses::GENESIS_ADDRESS()
- };
-}
-
diff --git a/vm/stdlib/compiled/latest/doc/TransferScripts.md b/vm/stdlib/compiled/latest/doc/TransferScripts.md
deleted file mode 100644
index 030fd6e384..0000000000
--- a/vm/stdlib/compiled/latest/doc/TransferScripts.md
+++ /dev/null
@@ -1,253 +0,0 @@
-
-
-
-# Module `0x1::TransferScripts`
-
-
-
-- [Constants](#@Constants_0)
-- [Function `peer_to_peer`](#0x1_TransferScripts_peer_to_peer)
-- [Function `peer_to_peer_v2`](#0x1_TransferScripts_peer_to_peer_v2)
-- [Function `batch_peer_to_peer`](#0x1_TransferScripts_batch_peer_to_peer)
-- [Function `batch_peer_to_peer_v2`](#0x1_TransferScripts_batch_peer_to_peer_v2)
-- [Function `peer_to_peer_batch`](#0x1_TransferScripts_peer_to_peer_batch)
-- [Function `peer_to_peer_with_metadata`](#0x1_TransferScripts_peer_to_peer_with_metadata)
-- [Function `peer_to_peer_with_metadata_v2`](#0x1_TransferScripts_peer_to_peer_with_metadata_v2)
-
-
-use 0x1::Account;
-use 0x1::Errors;
-use 0x1::Vector;
-
-
-
-
-
-
-## Constants
-
-
-
-
-
-
-const EDEPRECATED_FUNCTION: u64 = 19;
-
-
-
-
-
-
-
-
-const EADDRESS_AND_AUTH_KEY_MISMATCH: u64 = 101;
-
-
-
-
-
-
-
-
-const ELENGTH_MISMATCH: u64 = 102;
-
-
-
-
-
-
-## Function `peer_to_peer`
-
-
-
-public(script) fun peer_to_peer<TokenType: store>(account: signer, payee: address, _payee_auth_key: vector<u8>, amount: u128)
-
-
-
-
-public(script) fun peer_to_peer<TokenType: store>(account: signer, payee: address, _payee_auth_key: vector<u8>, amount: u128) {
- peer_to_peer_v2<TokenType>(account, payee, amount)
-}
-
-
-
-
-public(script) fun peer_to_peer_v2<TokenType: store>(account: signer, payee: address, amount: u128)
-
-
-
-
-public(script) fun peer_to_peer_v2<TokenType: store>(account: signer, payee: address, amount: u128) {
- if (!Account::exists_at(payee)) {
- Account::create_account_with_address<TokenType>(payee);
- };
- Account::pay_from<TokenType>(&account, payee, amount)
-}
-
-
-
-
-public(script) fun batch_peer_to_peer<TokenType: store>(account: signer, payeees: vector<address>, _payee_auth_keys: vector<vector<u8>>, amounts: vector<u128>)
-
-
-
-
-public(script) fun batch_peer_to_peer<TokenType: store>(account: signer, payeees: vector<address>, _payee_auth_keys: vector<vector<u8>>, amounts: vector<u128>) {
- batch_peer_to_peer_v2<TokenType>(account, payeees, amounts)
-}
-
-
-
-
-public(script) fun batch_peer_to_peer_v2<TokenType: store>(account: signer, payeees: vector<address>, amounts: vector<u128>)
-
-
-
-
-public(script) fun batch_peer_to_peer_v2<TokenType: store>(account: signer, payeees: vector<address>, amounts: vector<u128>) {
- let len = Vector::length(&payeees);
- assert!(len == Vector::length(&amounts), ELENGTH_MISMATCH);
- let i = 0;
- while (i < len){
- let payee = *Vector::borrow(&payeees, i);
- if (!Account::exists_at(payee)) {
- Account::create_account_with_address<TokenType>(payee);
- };
- let amount = *Vector::borrow(&amounts, i);
- Account::pay_from<TokenType>(&account, payee, amount);
- i = i + 1;
- }
-}
-
-
-
-
-public(script) fun peer_to_peer_batch<TokenType: store>(_account: signer, _payeees: vector<u8>, _payee_auth_keys: vector<u8>, _amount: u128)
-
-
-
-
-public(script) fun peer_to_peer_batch<TokenType: store>(_account: signer, _payeees: vector<u8>, _payee_auth_keys: vector<u8>, _amount: u128) {
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-public(script) fun peer_to_peer_with_metadata<TokenType: store>(account: signer, payee: address, _payee_auth_key: vector<u8>, amount: u128, metadata: vector<u8>)
-
-
-
-
-public(script) fun peer_to_peer_with_metadata<TokenType: store>(
- account: signer,
- payee: address,
- _payee_auth_key: vector<u8>,
- amount: u128,
- metadata: vector<u8>,
-) {
- peer_to_peer_with_metadata_v2<TokenType>(account, payee, amount, metadata)
-}
-
-
-
-
-public(script) fun peer_to_peer_with_metadata_v2<TokenType: store>(account: signer, payee: address, amount: u128, metadata: vector<u8>)
-
-
-
-
-public(script) fun peer_to_peer_with_metadata_v2<TokenType: store>(
- account: signer,
- payee: address,
- amount: u128,
- metadata: vector<u8>,
-) {
- if (!Account::exists_at(payee)) {
- Account::create_account_with_address<TokenType>(payee);
- };
- Account::pay_from_with_metadata<TokenType>(&account,payee, amount, metadata)
-}
-
-
-
-
-use 0x1::Errors;
-use 0x1::Event;
-use 0x1::Math;
-use 0x1::Signer;
-use 0x1::Timestamp;
-use 0x1::Token;
-
-
-
-
-
-
-## Resource `Treasury`
-
-
-
-struct Treasury<TokenT> has store, key
-
-
-
-
-balance: Token::Token<TokenT>
-withdraw_events: Event::EventHandle<Treasury::WithdrawEvent>
-deposit_events: Event::EventHandle<Treasury::DepositEvent>
-TokenT
to be withdraw from Treasury.
-
-
-struct WithdrawCapability<TokenT> has store, key
-
-
-
-
-dummy_field: bool
-struct LinearWithdrawCapability<TokenT> has store, key
-
-
-
-
-total: u128
-withdraw: u128
-start_time: u64
-period: u64
-struct WithdrawEvent has drop, store
-
-
-
-
-amount: u128
-struct DepositEvent has drop, store
-
-
-
-
-amount: u128
-const ERR_INVALID_PERIOD: u64 = 101;
-
-
-
-
-
-
-
-
-const ERR_NOT_AUTHORIZED: u64 = 104;
-
-
-
-
-
-
-
-
-const ERR_TOO_BIG_AMOUNT: u64 = 103;
-
-
-
-
-
-
-
-
-const ERR_TREASURY_NOT_EXIST: u64 = 105;
-
-
-
-
-
-
-
-
-const ERR_ZERO_AMOUNT: u64 = 102;
-
-
-
-
-
-
-## Function `initialize`
-
-Init a Treasury for TokenT,can only be called by token issuer.
-
-
-public fun initialize<TokenT: store>(signer: &signer, init_token: Token::Token<TokenT>): Treasury::WithdrawCapability<TokenT>
-
-
-
-
-public fun initialize<TokenT:store>(signer: &signer, init_token: Token<TokenT>) :WithdrawCapability<TokenT> {
- let token_issuer = Token::token_address<TokenT>();
- assert!(Signer::address_of(signer) == token_issuer, Errors::requires_address(ERR_NOT_AUTHORIZED));
- let treasure = Treasury{
- balance: init_token,
- withdraw_events: Event::new_event_handle<WithdrawEvent>(signer),
- deposit_events: Event::new_event_handle<DepositEvent>(signer),
- };
- move_to(signer,treasure);
- WithdrawCapability<TokenT>{}
-}
-
-
-
-
-public fun exists_at<TokenT: store>(): bool
-
-
-
-
-public fun exists_at<TokenT:store>(): bool {
- let token_issuer = Token::token_address<TokenT>();
- exists<Treasury<TokenT>>(token_issuer)
-}
-
-
-
-
-public fun balance<TokenT: store>(): u128
-
-
-
-
-public fun balance<TokenT:store>(): u128 acquires Treasury{
- let token_issuer = Token::token_address<TokenT>();
- if(!exists<Treasury<TokenT>>(token_issuer)){
- return 0
- };
- let treasury = borrow_global<Treasury<TokenT>>(token_issuer);
- Token::value(&treasury.balance)
-}
-
-
-
-
-public fun deposit<TokenT: store>(token: Token::Token<TokenT>)
-
-
-
-
-public fun deposit<TokenT:store>(token: Token<TokenT>) acquires Treasury{
- assert!(exists_at<TokenT>(), Errors::not_published(ERR_TREASURY_NOT_EXIST));
- let token_address = Token::token_address<TokenT>();
- let treasury = borrow_global_mut<Treasury<TokenT>>(token_address);
- let amount = Token::value(&token);
- Event::emit_event(
- &mut treasury.deposit_events,
- DepositEvent {
- amount,
- },
- );
- Token::deposit(&mut treasury.balance, token);
-}
-
-
-
-
-fun do_withdraw<TokenT: store>(amount: u128): Token::Token<TokenT>
-
-
-
-
-fun do_withdraw<TokenT:store>(amount: u128): Token<TokenT> acquires Treasury {
- assert!(amount > 0, Errors::invalid_argument(ERR_ZERO_AMOUNT));
- assert!(exists_at<TokenT>(), Errors::not_published(ERR_TREASURY_NOT_EXIST));
- let token_address = Token::token_address<TokenT>();
- let treasury = borrow_global_mut<Treasury<TokenT>>(token_address);
- assert!(amount <= Token::value(&treasury.balance) , Errors::invalid_argument(ERR_TOO_BIG_AMOUNT));
- Event::emit_event(
- &mut treasury.withdraw_events,
- WithdrawEvent {
- amount,
- },
- );
- Token::withdraw(&mut treasury.balance, amount)
-}
-
-
-
-
-LinearWithdrawCapability
.
-
-
-public fun withdraw_with_capability<TokenT: store>(_cap: &mut Treasury::WithdrawCapability<TokenT>, amount: u128): Token::Token<TokenT>
-
-
-
-
-public fun withdraw_with_capability<TokenT:store>(_cap: &mut WithdrawCapability<TokenT>, amount: u128): Token<TokenT> acquires Treasury {
- let token = do_withdraw(amount);
- token
-}
-
-
-
-
-public fun withdraw<TokenT: store>(signer: &signer, amount: u128): Token::Token<TokenT>
-
-
-
-
-public fun withdraw<TokenT:store>(signer: &signer, amount: u128) : Token<TokenT> acquires Treasury, WithdrawCapability{
- let cap = borrow_global_mut<WithdrawCapability<TokenT>>(Signer::address_of(signer));
- Self::withdraw_with_capability(cap, amount)
-}
-
-
-
-
-LinearWithdrawCapability
with given WithdrawCapability
.
-
-
-public fun issue_linear_withdraw_capability<TokenT: store>(_capability: &mut Treasury::WithdrawCapability<TokenT>, amount: u128, period: u64): Treasury::LinearWithdrawCapability<TokenT>
-
-
-
-
-public fun issue_linear_withdraw_capability<TokenT: store>( _capability: &mut WithdrawCapability<TokenT>,
- amount: u128, period: u64): LinearWithdrawCapability<TokenT>{
- assert!(period > 0, Errors::invalid_argument(ERR_INVALID_PERIOD));
- assert!(amount > 0, Errors::invalid_argument(ERR_ZERO_AMOUNT));
- let start_time = Timestamp::now_seconds();
- LinearWithdrawCapability<TokenT> {
- total: amount,
- withdraw: 0,
- start_time,
- period
- }
-}
-
-
-
-
-LinearWithdrawCapability
.
-
-
-public fun withdraw_with_linear_capability<TokenT: store>(cap: &mut Treasury::LinearWithdrawCapability<TokenT>): Token::Token<TokenT>
-
-
-
-
-public fun withdraw_with_linear_capability<TokenT: store>(cap: &mut LinearWithdrawCapability<TokenT>): Token<TokenT> acquires Treasury {
- let amount = withdraw_amount_of_linear_cap(cap);
- let token = do_withdraw(amount);
- cap.withdraw = cap.withdraw + amount;
- token
-}
-
-
-
-
-public fun withdraw_by_linear<TokenT: store>(signer: &signer): Token::Token<TokenT>
-
-
-
-
-public fun withdraw_by_linear<TokenT:store>(signer: &signer) : Token<TokenT> acquires Treasury, LinearWithdrawCapability{
- let cap = borrow_global_mut<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
- Self::withdraw_with_linear_capability(cap)
-}
-
-
-
-
-LinearWithdrawCapability
.
-
-
-public fun split_linear_withdraw_cap<TokenT: store>(cap: &mut Treasury::LinearWithdrawCapability<TokenT>, amount: u128): (Token::Token<TokenT>, Treasury::LinearWithdrawCapability<TokenT>)
-
-
-
-
-public fun split_linear_withdraw_cap<TokenT: store>(cap: &mut LinearWithdrawCapability<TokenT>, amount: u128): (Token<TokenT>, LinearWithdrawCapability<TokenT>) acquires Treasury {
- assert!(amount > 0, Errors::invalid_argument(ERR_ZERO_AMOUNT));
- let token = Self::withdraw_with_linear_capability(cap);
- assert!((cap.withdraw + amount) <= cap.total, Errors::invalid_argument(ERR_TOO_BIG_AMOUNT));
- cap.total = cap.total - amount;
- let start_time = Timestamp::now_seconds();
- let new_period = cap.start_time + cap.period - start_time;
- let new_key = LinearWithdrawCapability<TokenT> {
- total: amount,
- withdraw: 0,
- start_time,
- period: new_period
- };
- (token, new_key)
-}
-
-
-
-
-public fun withdraw_amount_of_linear_cap<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u128
-
-
-
-
-public fun withdraw_amount_of_linear_cap<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): u128 {
- let now = Timestamp::now_seconds();
- let elapsed_time = now - cap.start_time;
- if (elapsed_time >= cap.period) {
- cap.total - cap.withdraw
- }else {
- Math::mul_div(cap.total, (elapsed_time as u128), (cap.period as u128)) - cap.withdraw
- }
-}
-
-
-
-
-LinearWithdrawCapability
is empty.
-
-
-public fun is_empty_linear_withdraw_cap<TokenT: store>(key: &Treasury::LinearWithdrawCapability<TokenT>): bool
-
-
-
-
-public fun is_empty_linear_withdraw_cap<TokenT:store>(key: &LinearWithdrawCapability<TokenT>) : bool {
- key.total == key.withdraw
-}
-
-
-
-
-signer
.
-
-
-public fun remove_withdraw_capability<TokenT: store>(signer: &signer): Treasury::WithdrawCapability<TokenT>
-
-
-
-
-public fun remove_withdraw_capability<TokenT: store>(signer: &signer): WithdrawCapability<TokenT>
-acquires WithdrawCapability {
- move_from<WithdrawCapability<TokenT>>(Signer::address_of(signer))
-}
-
-
-
-
-signer
.
-
-
-public fun add_withdraw_capability<TokenT: store>(signer: &signer, cap: Treasury::WithdrawCapability<TokenT>)
-
-
-
-
-public fun add_withdraw_capability<TokenT: store>(signer: &signer, cap: WithdrawCapability<TokenT>) {
- move_to(signer, cap)
-}
-
-
-
-
-public fun destroy_withdraw_capability<TokenT: store>(cap: Treasury::WithdrawCapability<TokenT>)
-
-
-
-
-public fun destroy_withdraw_capability<TokenT: store>(cap: WithdrawCapability<TokenT>) {
- let WithdrawCapability<TokenT> { } = cap;
-}
-
-
-
-
-signer
, a address only can have one LinearWithdrawCapabilitypublic fun add_linear_withdraw_capability<TokenT: store>(signer: &signer, cap: Treasury::LinearWithdrawCapability<TokenT>)
-
-
-
-
-public fun add_linear_withdraw_capability<TokenT: store>(signer: &signer, cap: LinearWithdrawCapability<TokenT>){
- move_to(signer, cap)
-}
-
-
-
-
-signer
.
-
-
-public fun remove_linear_withdraw_capability<TokenT: store>(signer: &signer): Treasury::LinearWithdrawCapability<TokenT>
-
-
-
-
-public fun remove_linear_withdraw_capability<TokenT: store>(signer: &signer): LinearWithdrawCapability<TokenT>
-acquires LinearWithdrawCapability {
- move_from<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer))
-}
-
-
-
-
-public fun destroy_linear_withdraw_capability<TokenT: store>(cap: Treasury::LinearWithdrawCapability<TokenT>)
-
-
-
-
-public fun destroy_linear_withdraw_capability<TokenT: store>(cap: LinearWithdrawCapability<TokenT>) {
- let LinearWithdrawCapability{ total: _, withdraw: _, start_time: _, period: _ } = cap;
-}
-
-
-
-
-public fun is_empty_linear_withdraw_capability<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): bool
-
-
-
-
-public fun is_empty_linear_withdraw_capability<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>):bool {
- cap.total == cap.withdraw
-}
-
-
-
-
-public fun get_linear_withdraw_capability_total<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u128
-
-
-
-
-public fun get_linear_withdraw_capability_total<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>):u128 {
- cap.total
-}
-
-
-
-
-public fun get_linear_withdraw_capability_withdraw<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u128
-
-
-
-
-public fun get_linear_withdraw_capability_withdraw<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>):u128 {
- cap.withdraw
-}
-
-
-
-
-public fun get_linear_withdraw_capability_period<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u64
-
-
-
-
-public fun get_linear_withdraw_capability_period<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>):u64 {
- cap.period
-}
-
-
-
-
-public fun get_linear_withdraw_capability_start_time<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u64
-
-
-
-
-public fun get_linear_withdraw_capability_start_time<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>):u64 {
- cap.start_time
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-
-
-fun spec_balance<TokenType>(): u128 {
- global<Treasury<TokenType>>(Token::SPEC_TOKEN_TEST_ADDRESS()).balance.value
-}
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize<TokenT: store>(signer: &signer, init_token: Token::Token<TokenT>): Treasury::WithdrawCapability<TokenT>
-
-
-
-
-
-
-
-### Function `exists_at`
-
-
-public fun exists_at<TokenT: store>(): bool
-
-
-
-
-
-
-
-### Function `balance`
-
-
-public fun balance<TokenT: store>(): u128
-
-
-
-
-
-
-
-### Function `deposit`
-
-
-public fun deposit<TokenT: store>(token: Token::Token<TokenT>)
-
-
-
-
-
-
-
-### Function `do_withdraw`
-
-
-fun do_withdraw<TokenT: store>(amount: u128): Token::Token<TokenT>
-
-
-
-
-
-aborts_if !exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-
-
-
-
-
-
-### Function `withdraw_with_capability`
-
-
-public fun withdraw_with_capability<TokenT: store>(_cap: &mut Treasury::WithdrawCapability<TokenT>, amount: u128): Token::Token<TokenT>
-
-
-
-
-
-
-
-### Function `withdraw`
-
-
-public fun withdraw<TokenT: store>(signer: &signer, amount: u128): Token::Token<TokenT>
-
-
-
-
-
-
-
-### Function `issue_linear_withdraw_capability`
-
-
-public fun issue_linear_withdraw_capability<TokenT: store>(_capability: &mut Treasury::WithdrawCapability<TokenT>, amount: u128, period: u64): Treasury::LinearWithdrawCapability<TokenT>
-
-
-
-
-
-aborts_if period == 0;
-aborts_if amount == 0;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(StarcoinFramework::CoreAddresses::SPEC_GENESIS_ADDRESS());
-
-
-
-
-
-
-### Function `withdraw_with_linear_capability`
-
-
-public fun withdraw_with_linear_capability<TokenT: store>(cap: &mut Treasury::LinearWithdrawCapability<TokenT>): Token::Token<TokenT>
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `split_linear_withdraw_cap`
-
-
-public fun split_linear_withdraw_cap<TokenT: store>(cap: &mut Treasury::LinearWithdrawCapability<TokenT>, amount: u128): (Token::Token<TokenT>, Treasury::LinearWithdrawCapability<TokenT>)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `withdraw_amount_of_linear_cap`
-
-
-public fun withdraw_amount_of_linear_cap<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u128
-
-
-
-
-
-pragma verify = false;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(StarcoinFramework::CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if Timestamp::spec_now_seconds() < cap.start_time;
-aborts_if Timestamp::spec_now_seconds() - cap.start_time >= cap.period && cap.total < cap.withdraw;
-aborts_if [abstract] Timestamp::spec_now_seconds() - cap.start_time < cap.period && Math::spec_mul_div() < cap.withdraw;
-
-
-
-
-
-
-### Function `is_empty_linear_withdraw_cap`
-
-
-public fun is_empty_linear_withdraw_cap<TokenT: store>(key: &Treasury::LinearWithdrawCapability<TokenT>): bool
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `remove_withdraw_capability`
-
-
-public fun remove_withdraw_capability<TokenT: store>(signer: &signer): Treasury::WithdrawCapability<TokenT>
-
-
-
-
-
-aborts_if !exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
-ensures !exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
-
-
-
-
-
-
-### Function `add_withdraw_capability`
-
-
-public fun add_withdraw_capability<TokenT: store>(signer: &signer, cap: Treasury::WithdrawCapability<TokenT>)
-
-
-
-
-
-aborts_if exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
-ensures exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
-
-
-
-
-
-
-### Function `destroy_withdraw_capability`
-
-
-public fun destroy_withdraw_capability<TokenT: store>(cap: Treasury::WithdrawCapability<TokenT>)
-
diff --git a/vm/stdlib/compiled/latest/doc/TreasuryScripts.md b/vm/stdlib/compiled/latest/doc/TreasuryScripts.md
deleted file mode 100644
index df5bd9e7d3..0000000000
--- a/vm/stdlib/compiled/latest/doc/TreasuryScripts.md
+++ /dev/null
@@ -1,228 +0,0 @@
-
-
-
-# Module `0x1::TreasuryScripts`
-
-
-
-- [Function `withdraw_and_split_lt_withdraw_cap`](#0x1_TreasuryScripts_withdraw_and_split_lt_withdraw_cap)
-- [Function `withdraw_token_with_linear_withdraw_capability`](#0x1_TreasuryScripts_withdraw_token_with_linear_withdraw_capability)
-- [Function `propose_withdraw`](#0x1_TreasuryScripts_propose_withdraw)
-- [Function `execute_withdraw_proposal`](#0x1_TreasuryScripts_execute_withdraw_proposal)
-- [Specification](#@Specification_0)
- - [Function `withdraw_and_split_lt_withdraw_cap`](#@Specification_0_withdraw_and_split_lt_withdraw_cap)
- - [Function `withdraw_token_with_linear_withdraw_capability`](#@Specification_0_withdraw_token_with_linear_withdraw_capability)
- - [Function `propose_withdraw`](#@Specification_0_propose_withdraw)
- - [Function `execute_withdraw_proposal`](#@Specification_0_execute_withdraw_proposal)
-
-
-use 0x1::Account;
-use 0x1::Offer;
-use 0x1::Token;
-use 0x1::Treasury;
-use 0x1::TreasuryWithdrawDaoProposal;
-
-
-
-
-
-
-## Function `withdraw_and_split_lt_withdraw_cap`
-
-
-
-public(script) fun withdraw_and_split_lt_withdraw_cap<TokenT: store>(signer: signer, for_address: address, amount: u128, lock_period: u64)
-
-
-
-
-public(script) fun withdraw_and_split_lt_withdraw_cap<TokenT: store>(
- signer: signer,
- for_address: address,
- amount: u128,
- lock_period: u64,
-) {
- // 1. take cap: LinearWithdrawCapability<TokenT>
- let cap = Treasury::remove_linear_withdraw_capability<TokenT>(&signer);
-
- // 2. withdraw token and split
- let (tokens, new_cap) = Treasury::split_linear_withdraw_cap(&mut cap, amount);
-
- // 3. deposit
- Account::deposit_to_self(&signer, tokens);
-
- // 4. put or destroy key
- if (Treasury::is_empty_linear_withdraw_capability(&cap)) {
- Treasury::destroy_linear_withdraw_capability(cap);
- } else {
- Treasury::add_linear_withdraw_capability(&signer, cap);
- };
-
- // 5. offer
- Offer::create(&signer, new_cap, for_address, lock_period);
-}
-
-
-
-
-public(script) fun withdraw_token_with_linear_withdraw_capability<TokenT: store>(signer: signer)
-
-
-
-
-public(script) fun withdraw_token_with_linear_withdraw_capability<TokenT: store>(
- signer: signer,
-) {
- // 1. take cap
- let cap = Treasury::remove_linear_withdraw_capability<TokenT>(&signer);
-
- // 2. withdraw token
- let tokens = Treasury::withdraw_with_linear_capability(&mut cap);
-
- // 3. deposit
- Account::deposit_to_self(&signer, tokens);
-
- // 4. put or destroy key
- if (Treasury::is_empty_linear_withdraw_capability(&cap)) {
- Treasury::destroy_linear_withdraw_capability(cap);
- } else {
- Treasury::add_linear_withdraw_capability(&signer, cap);
- };
-}
-
-
-
-
-public(script) fun propose_withdraw<TokenT: copy, drop, store>(signer: signer, receiver: address, amount: u128, period: u64, exec_delay: u64)
-
-
-
-
-public(script) fun propose_withdraw<TokenT: copy + drop + store>(signer: signer, receiver: address, amount: u128, period: u64, exec_delay: u64){
- TreasuryWithdrawDaoProposal::propose_withdraw<TokenT>(&signer, receiver, amount, period, exec_delay)
-}
-
-
-
-
-public(script) fun execute_withdraw_proposal<TokenT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
-
-
-
-
-public(script) fun execute_withdraw_proposal<TokenT:copy + drop + store>(signer: signer, proposer_address: address,
- proposal_id: u64,){
- TreasuryWithdrawDaoProposal::execute_withdraw_proposal<TokenT>(&signer, proposer_address, proposal_id);
-}
-
-
-
-
-public(script) fun withdraw_and_split_lt_withdraw_cap<TokenT: store>(signer: signer, for_address: address, amount: u128, lock_period: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `withdraw_token_with_linear_withdraw_capability`
-
-
-public(script) fun withdraw_token_with_linear_withdraw_capability<TokenT: store>(signer: signer)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `propose_withdraw`
-
-
-public(script) fun propose_withdraw<TokenT: copy, drop, store>(signer: signer, receiver: address, amount: u128, period: u64, exec_delay: u64)
-
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-### Function `execute_withdraw_proposal`
-
-
-public(script) fun execute_withdraw_proposal<TokenT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
-
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/TreasuryWithdrawDaoProposal.md b/vm/stdlib/compiled/latest/doc/TreasuryWithdrawDaoProposal.md
deleted file mode 100644
index bafc420f3f..0000000000
--- a/vm/stdlib/compiled/latest/doc/TreasuryWithdrawDaoProposal.md
+++ /dev/null
@@ -1,335 +0,0 @@
-
-
-
-# Module `0x1::TreasuryWithdrawDaoProposal`
-
-TreasuryWithdrawDaoProposal is a dao proposal for withdraw Token from Treasury.
-
-
-- [Resource `WrappedWithdrawCapability`](#0x1_TreasuryWithdrawDaoProposal_WrappedWithdrawCapability)
-- [Struct `WithdrawToken`](#0x1_TreasuryWithdrawDaoProposal_WithdrawToken)
-- [Constants](#@Constants_0)
-- [Function `plugin`](#0x1_TreasuryWithdrawDaoProposal_plugin)
-- [Function `propose_withdraw`](#0x1_TreasuryWithdrawDaoProposal_propose_withdraw)
-- [Function `execute_withdraw_proposal`](#0x1_TreasuryWithdrawDaoProposal_execute_withdraw_proposal)
-- [Function `withdraw_for_block_reward`](#0x1_TreasuryWithdrawDaoProposal_withdraw_for_block_reward)
-- [Specification](#@Specification_1)
- - [Function `plugin`](#@Specification_1_plugin)
- - [Function `propose_withdraw`](#@Specification_1_propose_withdraw)
- - [Function `execute_withdraw_proposal`](#@Specification_1_execute_withdraw_proposal)
-
-
-use 0x1::CoreAddresses;
-use 0x1::Dao;
-use 0x1::Errors;
-use 0x1::Signer;
-use 0x1::Token;
-use 0x1::Treasury;
-
-
-
-
-
-
-## Resource `WrappedWithdrawCapability`
-
-A wrapper of Token MintCapability.
-
-
-struct WrappedWithdrawCapability<TokenT> has key
-
-
-
-
-cap: Treasury::WithdrawCapability<TokenT>
-struct WithdrawToken has copy, drop, store
-
-
-
-
-receiver: address
-amount: u128
-period: u64
-const ERR_NOT_AUTHORIZED: u64 = 101;
-
-
-
-
-
-
-Only receiver can execute TreasuryWithdrawDaoProposal
-
-
-const ERR_NEED_RECEIVER_TO_EXECUTE: u64 = 102;
-
-
-
-
-
-
-The withdraw amount of propose is too many.
-
-
-const ERR_TOO_MANY_WITHDRAW_AMOUNT: u64 = 103;
-
-
-
-
-
-
-## Function `plugin`
-
-Plugin method of the module.
-Should be called by token issuer.
-
-
-public fun plugin<TokenT: store>(signer: &signer, cap: Treasury::WithdrawCapability<TokenT>)
-
-
-
-
-public fun plugin<TokenT: store>(signer: &signer, cap: Treasury::WithdrawCapability<TokenT>) {
- let token_issuer = Token::token_address<TokenT>();
- assert!(Signer::address_of(signer) == token_issuer, Errors::requires_address(ERR_NOT_AUTHORIZED));
- move_to(signer, WrappedWithdrawCapability<TokenT> { cap: cap });
-}
-
-
-
-
-public fun propose_withdraw<TokenT: copy, drop, store>(signer: &signer, receiver: address, amount: u128, period: u64, exec_delay: u64)
-
-
-
-
-public fun propose_withdraw<TokenT: copy + drop + store>(signer: &signer, receiver: address, amount: u128, period: u64, exec_delay: u64) {
- let quorum_votes = Dao::quorum_votes<TokenT>();
- assert!(amount <= quorum_votes, Errors::invalid_argument(ERR_TOO_MANY_WITHDRAW_AMOUNT));
- Dao::propose<TokenT, WithdrawToken>(
- signer,
- WithdrawToken { receiver, amount, period },
- exec_delay,
- );
-}
-
-
-
-
-public fun execute_withdraw_proposal<TokenT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64)
-
-
-
-
-public fun execute_withdraw_proposal<TokenT: copy + drop + store>(
- signer: &signer,
- proposer_address: address,
- proposal_id: u64,
-) acquires WrappedWithdrawCapability {
- let WithdrawToken { receiver, amount, period } = Dao::extract_proposal_action<TokenT, WithdrawToken>(
- proposer_address,
- proposal_id,
- );
- assert!(receiver == Signer::address_of(signer), Errors::requires_address(ERR_NEED_RECEIVER_TO_EXECUTE));
- let cap = borrow_global_mut<WrappedWithdrawCapability<TokenT>>(Token::token_address<TokenT>());
- let linear_cap = Treasury::issue_linear_withdraw_capability<TokenT>(&mut cap.cap, amount, period);
- Treasury::add_linear_withdraw_capability(signer, linear_cap);
-}
-
-
-
-
-public fun withdraw_for_block_reward<TokenT: store>(signer: &signer, reward: u128): Token::Token<TokenT>
-
-
-
-
-public fun withdraw_for_block_reward<TokenT: store>(signer: &signer, reward: u128):Token<TokenT> acquires WrappedWithdrawCapability {
- CoreAddresses::assert_genesis_address(signer);
- let cap = borrow_global_mut<WrappedWithdrawCapability<TokenT>>(Signer::address_of(signer));
- Treasury::withdraw_with_capability(&mut cap.cap, reward)
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict;
-pragma aborts_if_is_partial;
-
-
-
-
-
-
-### Function `plugin`
-
-
-public fun plugin<TokenT: store>(signer: &signer, cap: Treasury::WithdrawCapability<TokenT>)
-
-
-
-
-
-pragma aborts_if_is_partial = false;
-let sender = Signer::address_of(signer);
-aborts_if sender != Token::SPEC_TOKEN_TEST_ADDRESS();
-aborts_if !exists<Treasury::WithdrawCapability<TokenT>>(sender);
-aborts_if exists<WrappedWithdrawCapability<TokenT>>(sender);
-ensures !exists<Treasury::WithdrawCapability<TokenT>>(sender);
-ensures exists<WrappedWithdrawCapability<TokenT>>(sender);
-
-
-
-
-
-
-### Function `propose_withdraw`
-
-
-public fun propose_withdraw<TokenT: copy, drop, store>(signer: &signer, receiver: address, amount: u128, period: u64, exec_delay: u64)
-
-
-
-
-
-pragma aborts_if_is_partial = false;
-let quorum_votes = Dao::spec_quorum_votes<TokenT>();
-aborts_if amount > quorum_votes;
-include Dao::AbortIfDaoConfigNotExist<TokenT>;
-include Dao::AbortIfDaoInfoNotExist<TokenT>;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::SPEC_GENESIS_ADDRESS());
-aborts_if exec_delay > 0 && exec_delay < Dao::spec_dao_config<TokenT>().min_action_delay;
-include Dao::CheckQuorumVotes<TokenT>;
-let sender = Signer::address_of(signer);
-aborts_if exists<Dao::Proposal<TokenT, WithdrawToken>>(sender);
-
-
-
-
-
-
-### Function `execute_withdraw_proposal`
-
-
-public fun execute_withdraw_proposal<TokenT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64)
-
-
-
-
-
-pragma aborts_if_is_partial = true;
-let expected_states = vec<u8>(6);
-include Dao::CheckProposalStates<TokenT, WithdrawToken>{expected_states};
-let proposal = global<Dao::Proposal<TokenT, WithdrawToken>>(proposer_address);
-aborts_if Option::is_none(proposal.action);
-aborts_if !exists<WrappedWithdrawCapability<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-
diff --git a/vm/stdlib/compiled/latest/doc/U256.md b/vm/stdlib/compiled/latest/doc/U256.md
deleted file mode 100644
index defa97067b..0000000000
--- a/vm/stdlib/compiled/latest/doc/U256.md
+++ /dev/null
@@ -1,900 +0,0 @@
-
-
-
-# Module `0x1::U256`
-
-Implementation u256.
-
-
-- [Struct `U256`](#0x1_U256_U256)
-- [Constants](#@Constants_0)
-- [Function `zero`](#0x1_U256_zero)
-- [Function `one`](#0x1_U256_one)
-- [Function `from_u64`](#0x1_U256_from_u64)
-- [Function `from_u128`](#0x1_U256_from_u128)
-- [Function `from_big_endian`](#0x1_U256_from_big_endian)
-- [Function `from_little_endian`](#0x1_U256_from_little_endian)
-- [Function `to_u128`](#0x1_U256_to_u128)
-- [Function `compare`](#0x1_U256_compare)
-- [Function `add`](#0x1_U256_add)
-- [Function `sub`](#0x1_U256_sub)
-- [Function `mul`](#0x1_U256_mul)
-- [Function `div`](#0x1_U256_div)
-- [Function `rem`](#0x1_U256_rem)
-- [Function `pow`](#0x1_U256_pow)
-- [Function `add_nocarry`](#0x1_U256_add_nocarry)
-- [Function `sub_noborrow`](#0x1_U256_sub_noborrow)
-- [Function `from_bytes`](#0x1_U256_from_bytes)
-- [Function `native_add`](#0x1_U256_native_add)
-- [Function `native_sub`](#0x1_U256_native_sub)
-- [Function `native_mul`](#0x1_U256_native_mul)
-- [Function `native_div`](#0x1_U256_native_div)
-- [Function `native_rem`](#0x1_U256_native_rem)
-- [Function `native_pow`](#0x1_U256_native_pow)
-- [Specification](#@Specification_1)
- - [Function `from_u128`](#@Specification_1_from_u128)
- - [Function `to_u128`](#@Specification_1_to_u128)
- - [Function `add`](#@Specification_1_add)
- - [Function `sub`](#@Specification_1_sub)
- - [Function `mul`](#@Specification_1_mul)
- - [Function `div`](#@Specification_1_div)
- - [Function `rem`](#@Specification_1_rem)
- - [Function `pow`](#@Specification_1_pow)
-
-
-use 0x1::Arith;
-use 0x1::Errors;
-use 0x1::Vector;
-
-
-
-
-
-
-## Struct `U256`
-
-use vector to represent data.
-so that we can use buildin vector ops later to construct U256.
-vector should always has two elements.
-
-
-struct U256 has copy, drop, store
-
-
-
-
-bits: vector<u64>
-const EQUAL: u8 = 0;
-
-
-
-
-
-
-
-
-const GREATER_THAN: u8 = 2;
-
-
-
-
-
-
-
-
-const LESS_THAN: u8 = 1;
-
-
-
-
-
-
-
-
-const ERR_INVALID_LENGTH: u64 = 100;
-
-
-
-
-
-
-
-
-const ERR_OVERFLOW: u64 = 200;
-
-
-
-
-
-
-
-
-const WORD: u8 = 4;
-
-
-
-
-
-
-## Function `zero`
-
-
-
-public fun zero(): U256::U256
-
-
-
-
-public fun zero(): U256 {
- from_u128(0u128)
-}
-
-
-
-
-public fun one(): U256::U256
-
-
-
-
-public fun one(): U256 {
- from_u128(1u128)
-}
-
-
-
-
-public fun from_u64(v: u64): U256::U256
-
-
-
-
-public fun from_u64(v: u64): U256 {
- from_u128((v as u128))
-}
-
-
-
-
-public fun from_u128(v: u128): U256::U256
-
-
-
-
-public fun from_u128(v: u128): U256 {
- let low = ((v & 0xffffffffffffffff) as u64);
- let high = ((v >> 64) as u64);
- let bits = Vector::singleton(low);
- Vector::push_back(&mut bits, high);
- Vector::push_back(&mut bits, 0u64);
- Vector::push_back(&mut bits, 0u64);
- U256 {
- bits
- }
-}
-
-
-
-
-public fun from_big_endian(data: vector<u8>): U256::U256
-
-
-
-
-public fun from_big_endian(data: vector<u8>): U256 {
- // TODO: define error code.
- assert!(Vector::length(&data) <= 32, Errors::invalid_argument(ERR_INVALID_LENGTH));
- from_bytes(&data, true)
-}
-
-
-
-
-public fun from_little_endian(data: vector<u8>): U256::U256
-
-
-
-
-public fun from_little_endian(data: vector<u8>): U256 {
- // TODO: define error code.
- assert!(Vector::length(&data) <= 32, Errors::invalid_argument(ERR_INVALID_LENGTH));
- from_bytes(&data, false)
-}
-
-
-
-
-public fun to_u128(v: &U256::U256): u128
-
-
-
-
-public fun to_u128(v: &U256): u128 {
- assert!(*Vector::borrow(&v.bits, 3) == 0, Errors::invalid_state(ERR_OVERFLOW));
- assert!(*Vector::borrow(&v.bits, 2) == 0, Errors::invalid_state(ERR_OVERFLOW));
- ((*Vector::borrow(&v.bits, 1) as u128) << 64) | (*Vector::borrow(&v.bits, 0) as u128)
-}
-
-
-
-
-public fun compare(a: &U256::U256, b: &U256::U256): u8
-
-
-
-
-public fun compare(a: &U256, b: &U256): u8 {
- let i = (WORD as u64);
- while (i > 0) {
- i = i - 1;
- let a_bits = *Vector::borrow(&a.bits, i);
- let b_bits = *Vector::borrow(&b.bits, i);
- if (a_bits != b_bits) {
- if (a_bits < b_bits) {
- return LESS_THAN
- } else {
- return GREATER_THAN
- }
- }
- };
- EQUAL
-}
-
-
-
-
-public fun add(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-public fun add(a: U256, b: U256): U256 {
- native_add(&mut a, &b);
- a
-}
-
-
-
-
-public fun sub(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-public fun sub(a: U256, b: U256): U256 {
- native_sub(&mut a, &b);
- a
-}
-
-
-
-
-public fun mul(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-public fun mul(a: U256, b: U256): U256 {
- native_mul(&mut a, &b);
- a
-}
-
-
-
-
-public fun div(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-public fun div(a: U256, b: U256): U256 {
- native_div(&mut a, &b);
- a
-}
-
-
-
-
-public fun rem(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-public fun rem(a: U256, b: U256): U256 {
- native_rem(&mut a, &b);
- a
-}
-
-
-
-
-public fun pow(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-public fun pow(a: U256, b: U256): U256 {
- native_pow(&mut a, &b);
- a
-}
-
-
-
-
-fun add_nocarry(a: &mut U256::U256, b: &U256::U256)
-
-
-
-
-fun add_nocarry(a: &mut U256, b: &U256) {
- let carry = 0;
- let idx = 0;
- let len = (WORD as u64);
- while (idx < len) {
- let a_bit = Vector::borrow_mut(&mut a.bits, idx);
- let b_bit = Vector::borrow(&b.bits, idx);
- *a_bit = StarcoinFramework::Arith::adc(*a_bit, *b_bit, &mut carry);
- idx = idx + 1;
- };
-
- // check overflow
- assert!(carry == 0, 100);
-}
-
-
-
-
-fun sub_noborrow(a: &mut U256::U256, b: &U256::U256)
-
-
-
-
-fun sub_noborrow(a: &mut U256, b: &U256) {
- let borrow = 0;
- let idx = 0;
- let len =(WORD as u64);
- while (idx < len) {
- let a_bit = Vector::borrow_mut(&mut a.bits, idx);
- let b_bit = Vector::borrow(&b.bits, idx);
- *a_bit = StarcoinFramework::Arith::sbb(*a_bit, *b_bit, &mut borrow);
- idx = idx + 1;
- };
-
- // check overflow
- assert!(borrow == 0, 100);
-
-}
-
-
-
-
-fun from_bytes(data: &vector<u8>, be: bool): U256::U256
-
-
-
-
-native fun from_bytes(data: &vector<u8>, be: bool): U256;
-
-
-
-
-fun native_add(a: &mut U256::U256, b: &U256::U256)
-
-
-
-
-native fun native_add(a: &mut U256, b: &U256);
-
-
-
-
-fun native_sub(a: &mut U256::U256, b: &U256::U256)
-
-
-
-
-native fun native_sub(a: &mut U256, b: &U256);
-
-
-
-
-fun native_mul(a: &mut U256::U256, b: &U256::U256)
-
-
-
-
-native fun native_mul(a: &mut U256, b: &U256);
-
-
-
-
-fun native_div(a: &mut U256::U256, b: &U256::U256)
-
-
-
-
-native fun native_div(a: &mut U256, b: &U256);
-
-
-
-
-fun native_rem(a: &mut U256::U256, b: &U256::U256)
-
-
-
-
-native fun native_rem(a: &mut U256, b: &U256);
-
-
-
-
-fun native_pow(a: &mut U256::U256, b: &U256::U256)
-
-
-
-
-native fun native_pow(a: &mut U256, b: &U256);
-
-
-
-
-pragma verify = false;
-
-
-
-
-
-
-
-
-fun value_of_U256(a: U256): num {
- ( a.bits[0] // 0 * 64
- + a.bits[1] << 64 // 1 * 64
- + a.bits[2] << 128 // 2 * 64
- + a.bits[3] << 192 // 3 * 64
- )
-}
-
-
-
-
-
-
-### Function `from_u128`
-
-
-public fun from_u128(v: u128): U256::U256
-
-
-
-
-
-pragma opaque;
-ensures value_of_U256(result) == v;
-
-
-
-
-
-
-### Function `to_u128`
-
-
-public fun to_u128(v: &U256::U256): u128
-
-
-
-
-
-pragma opaque;
-aborts_if value_of_U256(v) >= (1 << 128);
-ensures value_of_U256(v) == result;
-
-
-
-
-
-
-### Function `add`
-
-
-public fun add(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-
-pragma opaque;
-aborts_if value_of_U256(a) + value_of_U256(b) >= (1 << 256);
-ensures value_of_U256(result) == value_of_U256(a) + value_of_U256(b);
-
-
-
-
-
-
-### Function `sub`
-
-
-public fun sub(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-
-pragma opaque;
-aborts_if value_of_U256(a) > value_of_U256(b);
-ensures value_of_U256(result) == value_of_U256(a) - value_of_U256(b);
-
-
-
-
-
-
-### Function `mul`
-
-
-public fun mul(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-
-pragma opaque;
-aborts_if value_of_U256(a) * value_of_U256(b) >= (1 << 256);
-ensures value_of_U256(result) == value_of_U256(a) * value_of_U256(b);
-
-
-
-
-
-
-### Function `div`
-
-
-public fun div(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-
-pragma opaque;
-aborts_if value_of_U256(b) == 0;
-ensures value_of_U256(result) == value_of_U256(a) / value_of_U256(b);
-
-
-
-
-
-
-### Function `rem`
-
-
-public fun rem(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-
-pragma opaque;
-aborts_if value_of_U256(b) == 0;
-ensures value_of_U256(result) == value_of_U256(a) % value_of_U256(b);
-
-
-
-
-
-
-### Function `pow`
-
-
-public fun pow(a: U256::U256, b: U256::U256): U256::U256
-
-
-
-
-
-pragma opaque;
-
diff --git a/vm/stdlib/compiled/latest/doc/UpgradeModuleDaoProposal.md b/vm/stdlib/compiled/latest/doc/UpgradeModuleDaoProposal.md
deleted file mode 100644
index e00c8e31c0..0000000000
--- a/vm/stdlib/compiled/latest/doc/UpgradeModuleDaoProposal.md
+++ /dev/null
@@ -1,365 +0,0 @@
-
-
-
-# Module `0x1::UpgradeModuleDaoProposal`
-
-UpgradeModuleDaoProposal is a proposal moudle used to upgrade contract codes under a token.
-
-
-- [Resource `UpgradeModuleCapability`](#0x1_UpgradeModuleDaoProposal_UpgradeModuleCapability)
-- [Struct `UpgradeModule`](#0x1_UpgradeModuleDaoProposal_UpgradeModule)
-- [Struct `UpgradeModuleV2`](#0x1_UpgradeModuleDaoProposal_UpgradeModuleV2)
-- [Constants](#@Constants_0)
-- [Function `plugin`](#0x1_UpgradeModuleDaoProposal_plugin)
-- [Function `propose_module_upgrade_v2`](#0x1_UpgradeModuleDaoProposal_propose_module_upgrade_v2)
-- [Function `submit_module_upgrade_plan`](#0x1_UpgradeModuleDaoProposal_submit_module_upgrade_plan)
-- [Specification](#@Specification_1)
- - [Function `plugin`](#@Specification_1_plugin)
- - [Function `propose_module_upgrade_v2`](#@Specification_1_propose_module_upgrade_v2)
- - [Function `submit_module_upgrade_plan`](#@Specification_1_submit_module_upgrade_plan)
-
-
-use 0x1::Dao;
-use 0x1::Errors;
-use 0x1::PackageTxnManager;
-use 0x1::Signer;
-use 0x1::Token;
-
-
-
-
-
-
-## Resource `UpgradeModuleCapability`
-
-A wrapper of PackageTxnManager::UpgradePlanCapability
.
-
-
-struct UpgradeModuleCapability<TokenT> has key
-
-
-
-
-cap: PackageTxnManager::UpgradePlanCapability
-struct UpgradeModule has copy, drop, store
-
-
-
-
-module_address: address
-package_hash: vector<u8>
-version: u64
-struct UpgradeModuleV2 has copy, drop, store
-
-
-
-
-module_address: address
-package_hash: vector<u8>
-version: u64
-enforced: bool
-const ERR_NOT_AUTHORIZED: u64 = 401;
-
-
-
-
-
-
-
-
-const ERR_ADDRESS_MISSMATCH: u64 = 402;
-
-
-
-
-
-
-
-
-const ERR_UNABLE_TO_UPGRADE: u64 = 400;
-
-
-
-
-
-
-## Function `plugin`
-
-If this goverment can upgrade module, call this to register capability.
-
-
-public fun plugin<TokenT: store>(signer: &signer, cap: PackageTxnManager::UpgradePlanCapability)
-
-
-
-
-public fun plugin<TokenT: store>(
- signer: &signer,
- cap: PackageTxnManager::UpgradePlanCapability,
-) {
- let token_issuer = Token::token_address<TokenT>();
- assert!(Signer::address_of(signer) == token_issuer, Errors::requires_address(ERR_NOT_AUTHORIZED));
- move_to(signer, UpgradeModuleCapability<TokenT> { cap })
-}
-
-
-
-
-public fun propose_module_upgrade_v2<TokenT: copy, drop, store>(signer: &signer, module_address: address, package_hash: vector<u8>, version: u64, exec_delay: u64, enforced: bool)
-
-
-
-
-public fun propose_module_upgrade_v2<TokenT: copy + drop + store>(
- signer: &signer,
- module_address: address,
- package_hash: vector<u8>,
- version: u64,
- exec_delay: u64,
- enforced: bool,
-) acquires UpgradeModuleCapability {
- let cap = borrow_global<UpgradeModuleCapability<TokenT>>(Token::token_address<TokenT>());
- let account_address = PackageTxnManager::account_address(&cap.cap);
- assert!(account_address == module_address, Errors::requires_capability(ERR_ADDRESS_MISSMATCH));
- Dao::propose<TokenT, UpgradeModuleV2>(
- signer,
- UpgradeModuleV2 { module_address, package_hash, version, enforced },
- exec_delay,
- );
-}
-
-
-
-
-public fun submit_module_upgrade_plan<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-public fun submit_module_upgrade_plan<TokenT: copy + drop + store>(
- proposer_address: address,
- proposal_id: u64,
-) acquires UpgradeModuleCapability {
- let UpgradeModuleV2 { module_address, package_hash, version, enforced } = Dao::extract_proposal_action<
- TokenT,
- UpgradeModuleV2,
- >(proposer_address, proposal_id);
- let cap = borrow_global<UpgradeModuleCapability<TokenT>>(Token::token_address<TokenT>());
- let account_address = PackageTxnManager::account_address(&cap.cap);
- assert!(account_address == module_address, Errors::requires_capability(ERR_ADDRESS_MISSMATCH));
- PackageTxnManager::submit_upgrade_plan_with_cap_v2(
- &cap.cap,
- package_hash,
- version,
- enforced,
- );
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict;
-pragma aborts_if_is_partial;
-
-
-
-
-
-
-### Function `plugin`
-
-
-public fun plugin<TokenT: store>(signer: &signer, cap: PackageTxnManager::UpgradePlanCapability)
-
-
-
-
-
-pragma aborts_if_is_partial = false;
-let sender = Signer::address_of(signer);
-aborts_if sender != Token::SPEC_TOKEN_TEST_ADDRESS();
-aborts_if exists<UpgradeModuleCapability<TokenT>>(sender);
-
-
-
-
-
-
-
-
-schema AbortIfUnableUpgrade<TokenT> {
- module_address: address;
- let token_issuer = Token::SPEC_TOKEN_TEST_ADDRESS();
- aborts_if !exists<UpgradeModuleCapability<TokenT>>(token_issuer);
- let cap = global<UpgradeModuleCapability<TokenT>>(token_issuer).cap;
- aborts_if PackageTxnManager::account_address(cap) != module_address;
-}
-
-
-
-
-
-
-### Function `propose_module_upgrade_v2`
-
-
-public fun propose_module_upgrade_v2<TokenT: copy, drop, store>(signer: &signer, module_address: address, package_hash: vector<u8>, version: u64, exec_delay: u64, enforced: bool)
-
-
-
-
-
-pragma aborts_if_is_partial = true;
-include AbortIfUnableUpgrade<TokenT>;
-
-
-
-
-
-
-### Function `submit_module_upgrade_plan`
-
-
-public fun submit_module_upgrade_plan<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
-
-
-
-
-let expected_states = vec<u8>(6);
-include Dao::CheckProposalStates<TokenT, UpgradeModule>{expected_states};
-let proposal = global<Dao::Proposal<TokenT, UpgradeModule>>(proposer_address);
-aborts_if Option::is_none(proposal.action);
-let action = proposal.action.vec[0];
-include AbortIfUnableUpgrade<TokenT>{module_address: action.module_address};
-
diff --git a/vm/stdlib/compiled/latest/doc/VMConfig.md b/vm/stdlib/compiled/latest/doc/VMConfig.md
deleted file mode 100644
index 5e3feb3ace..0000000000
--- a/vm/stdlib/compiled/latest/doc/VMConfig.md
+++ /dev/null
@@ -1,715 +0,0 @@
-
-
-
-# Module `0x1::VMConfig`
-
-VMConfig
keep track of VM related configuration, like gas schedule.
-
-
-- [Struct `VMConfig`](#0x1_VMConfig_VMConfig)
-- [Struct `GasSchedule`](#0x1_VMConfig_GasSchedule)
-- [Struct `GasConstants`](#0x1_VMConfig_GasConstants)
-- [Struct `GasCost`](#0x1_VMConfig_GasCost)
-- [Function `instruction_schedule`](#0x1_VMConfig_instruction_schedule)
-- [Function `native_schedule`](#0x1_VMConfig_native_schedule)
-- [Function `gas_constants`](#0x1_VMConfig_gas_constants)
-- [Function `new_gas_cost`](#0x1_VMConfig_new_gas_cost)
-- [Function `new_vm_config`](#0x1_VMConfig_new_vm_config)
-- [Function `initialize`](#0x1_VMConfig_initialize)
-- [Specification](#@Specification_0)
- - [Function `initialize`](#@Specification_0_initialize)
-
-
-use 0x1::ChainId;
-use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::Vector;
-
-
-
-
-
-
-## Struct `VMConfig`
-
-The struct to hold all config data needed to operate the VM.
-* gas_schedule: Cost of running the VM.
-
-
-struct VMConfig has copy, drop, store
-
-
-
-
-gas_schedule: VMConfig::GasSchedule
-struct GasSchedule has copy, drop, store
-
-
-
-
-instruction_schedule: vector<u8>
-native_schedule: vector<u8>
-gas_constants: VMConfig::GasConstants
-struct GasConstants has copy, drop, store
-
-
-
-
-global_memory_per_byte_cost: u64
-global_memory_per_byte_write_cost: u64
-min_transaction_gas_units: u64
-large_transaction_cutoff: u64
-INTRINSIC_GAS_PER_BYTE
per byte
-instrinsic_gas_per_byte: u64
-maximum_number_of_gas_units: u64
-MAX_PRICE_PER_GAS_UNIT
to always satisfy the inequality that
- MAXIMUM_NUMBER_OF_GAS_UNITS * MAX_PRICE_PER_GAS_UNIT < min(u64::MAX, GasUnitsmin_price_per_gas_unit: u64
-max_price_per_gas_unit: u64
-max_transaction_size_in_bytes: u64
-gas_unit_scaling_factor: u64
-default_account_size: u64
-GasCost
tracks:
-- instruction cost: how much time/computational power is needed to perform the instruction
-- memory cost: how much memory is required for the instruction, and storage overhead
-
-
-struct GasCost has copy, drop, store
-
-
-
-
-instruction_gas: u64
-memory_gas: u64
-public fun instruction_schedule(): vector<VMConfig::GasCost>
-
-
-
-
-public fun instruction_schedule(): vector<GasCost> {
- let table = Vector::empty();
-
- // POP
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // RET
- Vector::push_back(&mut table, new_gas_cost(638, 1));
- // BR_TRUE
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // BR_FALSE
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // BRANCH
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // LD_U64
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // LD_CONST
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // LD_TRUE
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // LD_FALSE
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // COPY_LOC
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // MOVE_LOC
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // ST_LOC
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // MUT_BORROW_LOC
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // IMM_BORROW_LOC
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // MUT_BORROW_FIELD
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // IMM_BORROW_FIELD
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // CALL
- Vector::push_back(&mut table, new_gas_cost(1132, 1));
- // PACK
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // UNPACK
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // READ_REF
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // WRITE_REF
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // ADD
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // SUB
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // MUL
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // MOD
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // DIV
- Vector::push_back(&mut table, new_gas_cost(3, 1));
- // BIT_OR
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // BIT_AND
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // XOR
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // OR
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // AND
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // NOT
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // EQ
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // NEQ
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // LT
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // GT
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // LE
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // GE
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // ABORT
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // NOP
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // EXISTS
- Vector::push_back(&mut table, new_gas_cost(41, 1));
- // MUT_BORROW_GLOBAL
- Vector::push_back(&mut table, new_gas_cost(21, 1));
- // IML_BORROW_GLOBAL
- Vector::push_back(&mut table, new_gas_cost(23, 1));
- // MOVE_FROM
- Vector::push_back(&mut table, new_gas_cost(459, 1));
- // MOVE_TO
- Vector::push_back(&mut table, new_gas_cost(13, 1));
- // FREEZE_REF
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // SHL
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // SHR
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // LD_U8
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // LD_U128
- Vector::push_back(&mut table, new_gas_cost(1, 1));
-
- // CAST_U8
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // CAST_U64
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // CAST_U128
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // MUT_BORORW_FIELD_GENERIC
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // IMM_BORORW_FIELD_GENERIC
- Vector::push_back(&mut table, new_gas_cost(1, 1));
- // CALL_GENERIC
- Vector::push_back(&mut table, new_gas_cost(582, 1));
- // PACK_GENERIC
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // UNPACK_GENERIC
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- // EXISTS_GENERIC
- Vector::push_back(&mut table, new_gas_cost(34, 1));
- // MUT_BORROW_GLOBAL_GENERIC
- Vector::push_back(&mut table, new_gas_cost(15, 1));
- // IMM_BORROW_GLOBAL_GENERIC
- Vector::push_back(&mut table, new_gas_cost(14, 1));
- // MOVE_FROM_GENERIC
- Vector::push_back(&mut table, new_gas_cost(13, 1));
- // MOVE_TO_GENERIC
- Vector::push_back(&mut table, new_gas_cost(27, 1));
-
- // VEC_PACK
- Vector::push_back(&mut table, new_gas_cost(84, 1));
- // VEC_LEN
- Vector::push_back(&mut table, new_gas_cost(98, 1));
- // VEC_IMM_BORROW
- Vector::push_back(&mut table, new_gas_cost(1334, 1));
- // VEC_MUT_BORROW
- Vector::push_back(&mut table, new_gas_cost(1902, 1));
- // VEC_PUSH_BACK
- Vector::push_back(&mut table, new_gas_cost(53, 1));
- // VEC_POP_BACK
- Vector::push_back(&mut table, new_gas_cost(227, 1));
- // VEC_UNPACK
- Vector::push_back(&mut table, new_gas_cost(572, 1));
- // VEC_SWAP
- Vector::push_back(&mut table, new_gas_cost(1436, 1));
- table
-}
-
-
-
-
-public fun native_schedule(): vector<VMConfig::GasCost>
-
-
-
-
-public fun native_schedule(): vector<GasCost> {
- let table = Vector::empty();
- //Hash::sha2_256 0
- Vector::push_back(&mut table, new_gas_cost(21, 1));
- //Hash::sha3_256 1
- Vector::push_back(&mut table, new_gas_cost(64, 1));
- //Signature::ed25519_verify 2
- Vector::push_back(&mut table, new_gas_cost(61, 1));
- //ED25519_THRESHOLD_VERIFY 3 this native funciton is deprecated
- Vector::push_back(&mut table, new_gas_cost(3351, 1));
- //BSC::to_bytes 4
- Vector::push_back(&mut table, new_gas_cost(181, 1));
- //Vector::length 5
- Vector::push_back(&mut table, new_gas_cost(98, 1));
- //Vector::empty 6
- Vector::push_back(&mut table, new_gas_cost(84, 1));
- //Vector::borrow 7
- Vector::push_back(&mut table, new_gas_cost(1334, 1));
- //Vector::borrow_mut 8
- Vector::push_back(&mut table, new_gas_cost(1902, 1));
- //Vector::push_back 9
- Vector::push_back(&mut table, new_gas_cost(53, 1));
- //Vector::pop_back 10
- Vector::push_back(&mut table, new_gas_cost(227, 1));
- //Vector::destory_empty 11
- Vector::push_back(&mut table, new_gas_cost(572, 1));
- //Vector::swap 12
- Vector::push_back(&mut table, new_gas_cost(1436, 1));
- //Signature::ed25519_validate_pubkey 13
- Vector::push_back(&mut table, new_gas_cost(26, 1));
- //Signer::borrow_address 14
- Vector::push_back(&mut table, new_gas_cost(353, 1));
- //Account::creator_signer 15
- Vector::push_back(&mut table, new_gas_cost(24, 1));
- //Account::destroy_signer 16
- Vector::push_back(&mut table, new_gas_cost(212, 1));
- //Event::emit_event 17
- Vector::push_back(&mut table, new_gas_cost(52, 1));
- //BCS::to_address 18
- Vector::push_back(&mut table, new_gas_cost(26, 1));
- //Token::name_of 19
- Vector::push_back(&mut table, new_gas_cost(2002, 1));
- //Hash::keccak_256 20
- Vector::push_back(&mut table, new_gas_cost(64, 1));
- //Hash::ripemd160 21
- Vector::push_back(&mut table, new_gas_cost(64, 1));
- //Signature::native_ecrecover 22
- Vector::push_back(&mut table, new_gas_cost(128, 1));
- //U256::from_bytes 23
- Vector::push_back(&mut table, new_gas_cost(2, 1));
- //U256::add 24
- Vector::push_back(&mut table, new_gas_cost(4, 1));
- //U256::sub 25
- Vector::push_back(&mut table, new_gas_cost(4, 1));
- //U256::mul 26
- Vector::push_back(&mut table, new_gas_cost(4, 1));
- //U256::div 27
- Vector::push_back(&mut table, new_gas_cost(10, 1));
- // U256::rem 28
- Vector::push_back(&mut table, new_gas_cost(4, 1));
- // U256::pow 29
- Vector::push_back(&mut table, new_gas_cost(8, 1));
- // TODO: settle down the gas cost
- // Vector::append 30
- Vector::push_back(&mut table, new_gas_cost(40, 1));
- // Vector::remove 31
- Vector::push_back(&mut table, new_gas_cost(20, 1));
- // Vector::reverse 32
- Vector::push_back(&mut table, new_gas_cost(10, 1));
-
- table
-}
-
-
-
-
-public fun gas_constants(): VMConfig::GasConstants
-
-
-
-
-public fun gas_constants(): GasConstants {
- let min_price_per_gas_unit: u64 = if (ChainId::is_test()) { 0 } else { 1 };
- let maximum_number_of_gas_units: u64 = 40000000;//must less than base_block_gas_limit
-
- if (ChainId::is_test() || ChainId::is_dev() || ChainId::is_halley()) {
- maximum_number_of_gas_units = maximum_number_of_gas_units * 10
- };
- GasConstants {
- global_memory_per_byte_cost: 4,
- global_memory_per_byte_write_cost: 9,
- min_transaction_gas_units: 600,
- large_transaction_cutoff: 600,
- instrinsic_gas_per_byte: 8,
- maximum_number_of_gas_units,
- min_price_per_gas_unit,
- max_price_per_gas_unit: 10000,
- max_transaction_size_in_bytes: 1024 * 128,
- gas_unit_scaling_factor: 1,
- default_account_size: 800,
- }
-}
-
-
-
-
-fun new_gas_cost(instr_gas: u64, mem_gas: u64): VMConfig::GasCost
-
-
-
-
-fun new_gas_cost(instr_gas: u64, mem_gas: u64): GasCost {
- GasCost {
- instruction_gas: instr_gas,
- memory_gas: mem_gas,
- }
-}
-
-
-
-
-public fun new_vm_config(instruction_schedule: vector<u8>, native_schedule: vector<u8>, global_memory_per_byte_cost: u64, global_memory_per_byte_write_cost: u64, min_transaction_gas_units: u64, large_transaction_cutoff: u64, instrinsic_gas_per_byte: u64, maximum_number_of_gas_units: u64, min_price_per_gas_unit: u64, max_price_per_gas_unit: u64, max_transaction_size_in_bytes: u64, gas_unit_scaling_factor: u64, default_account_size: u64): VMConfig::VMConfig
-
-
-
-
-public fun new_vm_config(
- instruction_schedule: vector<u8>,
- native_schedule: vector<u8>,
- global_memory_per_byte_cost: u64,
- global_memory_per_byte_write_cost: u64,
- min_transaction_gas_units: u64,
- large_transaction_cutoff: u64,
- instrinsic_gas_per_byte: u64,
- maximum_number_of_gas_units: u64,
- min_price_per_gas_unit: u64,
- max_price_per_gas_unit: u64,
- max_transaction_size_in_bytes: u64,
- gas_unit_scaling_factor: u64,
- default_account_size: u64,
-): VMConfig {
- let gas_constants = GasConstants {
- global_memory_per_byte_cost,
- global_memory_per_byte_write_cost,
- min_transaction_gas_units,
- large_transaction_cutoff,
- instrinsic_gas_per_byte,
- maximum_number_of_gas_units,
- min_price_per_gas_unit,
- max_price_per_gas_unit,
- max_transaction_size_in_bytes,
- gas_unit_scaling_factor,
- default_account_size,
- };
- VMConfig {
- gas_schedule: GasSchedule { instruction_schedule, native_schedule, gas_constants },
- }
-}
-
-
-
-
-public fun initialize(account: &signer, instruction_schedule: vector<u8>, native_schedule: vector<u8>, global_memory_per_byte_cost: u64, global_memory_per_byte_write_cost: u64, min_transaction_gas_units: u64, large_transaction_cutoff: u64, instrinsic_gas_per_byte: u64, maximum_number_of_gas_units: u64, min_price_per_gas_unit: u64, max_price_per_gas_unit: u64, max_transaction_size_in_bytes: u64, gas_unit_scaling_factor: u64, default_account_size: u64)
-
-
-
-
-public fun initialize(
- account: &signer,
- instruction_schedule: vector<u8>,
- native_schedule: vector<u8>,
- global_memory_per_byte_cost: u64,
- global_memory_per_byte_write_cost: u64,
- min_transaction_gas_units: u64,
- large_transaction_cutoff: u64,
- instrinsic_gas_per_byte: u64,
- maximum_number_of_gas_units: u64,
- min_price_per_gas_unit: u64,
- max_price_per_gas_unit: u64,
- max_transaction_size_in_bytes: u64,
- gas_unit_scaling_factor: u64,
- default_account_size: u64,
-) {
- CoreAddresses::assert_genesis_address(account);
- Config::publish_new_config<VMConfig>(
- account,
- new_vm_config(
- instruction_schedule,
- native_schedule,
- global_memory_per_byte_cost,
- global_memory_per_byte_write_cost,
- min_transaction_gas_units,
- large_transaction_cutoff,
- instrinsic_gas_per_byte,
- maximum_number_of_gas_units,
- min_price_per_gas_unit,
- max_price_per_gas_unit,
- max_transaction_size_in_bytes,
- gas_unit_scaling_factor,
- default_account_size,
- ),
- );
-}
-
-
-
-
-pragma verify = false;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `initialize`
-
-
-public fun initialize(account: &signer, instruction_schedule: vector<u8>, native_schedule: vector<u8>, global_memory_per_byte_cost: u64, global_memory_per_byte_write_cost: u64, min_transaction_gas_units: u64, large_transaction_cutoff: u64, instrinsic_gas_per_byte: u64, maximum_number_of_gas_units: u64, min_price_per_gas_unit: u64, max_price_per_gas_unit: u64, max_transaction_size_in_bytes: u64, gas_unit_scaling_factor: u64, default_account_size: u64)
-
-
-
-
-
-aborts_if Signer::address_of(account) != CoreAddresses::SPEC_GENESIS_ADDRESS();
-aborts_if exists<Config::Config<VMConfig>>(Signer::address_of(account));
-aborts_if
- exists<Config::ModifyConfigCapabilityHolder<VMConfig>>(
- Signer::address_of(account),
- );
-ensures exists<Config::Config<VMConfig>>(Signer::address_of(account));
-ensures
- exists<Config::ModifyConfigCapabilityHolder<VMConfig>>(
- Signer::address_of(account),
- );
-
diff --git a/vm/stdlib/compiled/latest/doc/Vector.md b/vm/stdlib/compiled/latest/doc/Vector.md
deleted file mode 100644
index c32a0d1c52..0000000000
--- a/vm/stdlib/compiled/latest/doc/Vector.md
+++ /dev/null
@@ -1,837 +0,0 @@
-
-
-
-# Module `0x1::Vector`
-
-A variable-sized container that can hold any type. Indexing is 0-based, and
-vectors are growable. This module has many native functions.
-Verification of modules that use this one uses model functions that are implemented
-directly in Boogie. The specification language has built-in functions operations such
-as vec
. There are some helper functions defined here for specifications in other
-modules as well.
-
->Note: We did not verify most of the
-Move functions here because many have loops, requiring loop invariants to prove, and
-the return on investment didn't seem worth it for these simple functions.
-
-
-- [Constants](#@Constants_0)
-- [Function `empty`](#0x1_Vector_empty)
-- [Function `length`](#0x1_Vector_length)
-- [Function `borrow`](#0x1_Vector_borrow)
-- [Function `push_back`](#0x1_Vector_push_back)
-- [Function `borrow_mut`](#0x1_Vector_borrow_mut)
-- [Function `pop_back`](#0x1_Vector_pop_back)
-- [Function `destroy_empty`](#0x1_Vector_destroy_empty)
-- [Function `swap`](#0x1_Vector_swap)
-- [Function `singleton`](#0x1_Vector_singleton)
-- [Function `reverse`](#0x1_Vector_reverse)
-- [Function `native_reverse`](#0x1_Vector_native_reverse)
-- [Function `append`](#0x1_Vector_append)
-- [Function `native_append`](#0x1_Vector_native_append)
-- [Function `is_empty`](#0x1_Vector_is_empty)
-- [Function `contains`](#0x1_Vector_contains)
-- [Function `index_of`](#0x1_Vector_index_of)
-- [Function `remove`](#0x1_Vector_remove)
-- [Function `native_remove`](#0x1_Vector_native_remove)
-- [Function `swap_remove`](#0x1_Vector_swap_remove)
-- [Function `split`](#0x1_Vector_split)
-- [Specification](#@Specification_1)
- - [Helper Functions](#@Helper_Functions_2)
- - [Function `singleton`](#@Specification_1_singleton)
- - [Function `reverse`](#@Specification_1_reverse)
- - [Function `append`](#@Specification_1_append)
- - [Function `is_empty`](#@Specification_1_is_empty)
- - [Function `contains`](#@Specification_1_contains)
- - [Function `index_of`](#@Specification_1_index_of)
- - [Function `remove`](#@Specification_1_remove)
- - [Function `swap_remove`](#@Specification_1_swap_remove)
- - [Function `split`](#@Specification_1_split)
-
-
-
-
-
-
-
-
-## Constants
-
-
-
-
-The index into the vector is out of bounds
-
-
-const EINDEX_OUT_OF_BOUNDS: u64 = 0;
-
-
-
-
-
-
-## Function `empty`
-
-Create an empty vector.
-
-
-public fun empty<Element>(): vector<Element>
-
-
-
-
-native public fun empty<Element>(): vector<Element>;
-
-
-
-
-public fun length<Element>(v: &vector<Element>): u64
-
-
-
-
-native public fun length<Element>(v: &vector<Element>): u64;
-
-
-
-
-i
th element of the vector v
.
-Aborts if i
is out of bounds.
-
-
-public fun borrow<Element>(v: &vector<Element>, i: u64): &Element
-
-
-
-
-native public fun borrow<Element>(v: &vector<Element>, i: u64): ∈
-
-
-
-
-e
to the end of the vector v
.
-
-
-public fun push_back<Element>(v: &mut vector<Element>, e: Element)
-
-
-
-
-native public fun push_back<Element>(v: &mut vector<Element>, e: Element);
-
-
-
-
-i
th element in the vector v
.
-Aborts if i
is out of bounds.
-
-
-public fun borrow_mut<Element>(v: &mut vector<Element>, i: u64): &mut Element
-
-
-
-
-native public fun borrow_mut<Element>(v: &mut vector<Element>, i: u64): &mut Element;
-
-
-
-
-v
.
-Aborts if v
is empty.
-
-
-public fun pop_back<Element>(v: &mut vector<Element>): Element
-
-
-
-
-native public fun pop_back<Element>(v: &mut vector<Element>): Element;
-
-
-
-
-v
.
-Aborts if v
is not empty.
-
-
-public fun destroy_empty<Element>(v: vector<Element>)
-
-
-
-
-native public fun destroy_empty<Element>(v: vector<Element>);
-
-
-
-
-i
th and j
th indices in the vector v
.
-Aborts if i
or j
is out of bounds.
-
-
-public fun swap<Element>(v: &mut vector<Element>, i: u64, j: u64)
-
-
-
-
-native public fun swap<Element>(v: &mut vector<Element>, i: u64, j: u64);
-
-
-
-
-e
.
-
-
-public fun singleton<Element>(e: Element): vector<Element>
-
-
-
-
-public fun singleton<Element>(e: Element): vector<Element> {
- let v = empty();
- push_back(&mut v, e);
- v
-}
-
-
-
-
-v
in place.
-
-
-public fun reverse<Element>(v: &mut vector<Element>)
-
-
-
-
-public fun reverse<Element>(v: &mut vector<Element>) {
- native_reverse(v)
-}
-
-
-
-
-fun native_reverse<Element>(this: &mut vector<Element>)
-
-
-
-
-native fun native_reverse<Element>(this: &mut vector<Element>);
-
-
-
-
-other
vector into the lhs
vector.
-
-
-public fun append<Element>(lhs: &mut vector<Element>, other: vector<Element>)
-
-
-
-
-public fun append<Element>(lhs: &mut vector<Element>, other: vector<Element>) {
- native_append(lhs, other);
-}
-
-
-
-
-fun native_append<Element>(lhs: &mut vector<Element>, other: vector<Element>)
-
-
-
-
-native fun native_append<Element>(lhs: &mut vector<Element>, other: vector<Element>);
-
-
-
-
-true
if the vector v
has no elements and false
otherwise.
-
-
-public fun is_empty<Element>(v: &vector<Element>): bool
-
-
-
-
-public fun is_empty<Element>(v: &vector<Element>): bool {
- length(v) == 0
-}
-
-
-
-
-e
is in the vector v
.
-
-
-public fun contains<Element>(v: &vector<Element>, e: &Element): bool
-
-
-
-
-public fun contains<Element>(v: &vector<Element>, e: &Element): bool {
- let i = 0;
- let len = length(v);
- while (i < len) {
- if (borrow(v, i) == e) return true;
- i = i + 1;
- };
- false
-}
-
-
-
-
-(true, i)
if e
is in the vector v
at index i
.
-Otherwise, returns (false, 0)
.
-
-
-public fun index_of<Element>(v: &vector<Element>, e: &Element): (bool, u64)
-
-
-
-
-public fun index_of<Element>(v: &vector<Element>, e: &Element): (bool, u64) {
- let i = 0;
- let len = length(v);
- while (i < len) {
- if (borrow(v, i) == e) return (true, i);
- i = i + 1;
- };
- (false, 0)
-}
-
-
-
-
-i
th element of the vector v
, shifting all subsequent elements.
-This is O(n) and preserves ordering of elements in the vector.
-Aborts if i
is out of bounds.
-
-
-public fun remove<Element>(v: &mut vector<Element>, i: u64): Element
-
-
-
-
-public fun remove<Element>(v: &mut vector<Element>, i: u64): Element {
- let len = length(v);
- // i out of bounds; abort
- if (i >= len) abort EINDEX_OUT_OF_BOUNDS;
-
- native_remove(v, i)
-}
-
-
-
-
-fun native_remove<Element>(this: &mut vector<Element>, i: u64): Element
-
-
-
-
-native fun native_remove<Element>(this: &mut vector<Element>, i: u64): Element;
-
-
-
-
-i
th element of the vector v
with the last element and then pop the vector.
-This is O(1), but does not preserve ordering of elements in the vector.
-Aborts if i
is out of bounds.
-
-
-public fun swap_remove<Element>(v: &mut vector<Element>, i: u64): Element
-
-
-
-
-public fun swap_remove<Element>(v: &mut vector<Element>, i: u64): Element {
- let last_idx = length(v) - 1;
- swap(v, i, last_idx);
- pop_back(v)
-}
-
-
-
-
-public fun split<Element: copy, drop, store>(v: &vector<Element>, sub_len: u64): vector<vector<Element>>
-
-
-
-
-public fun split<Element: copy + drop + store>(v: &vector<Element>, sub_len: u64): vector<vector<Element>> {
- let result = empty<vector<Element>>();
- let len = length(v) / sub_len;
-
- let rem = 0;
- if (len * sub_len < length(v)) {
- rem = length(v) - len * sub_len;
- };
-
- let i = 0;
- while (i < len) {
- let sub = empty<Element>();
- let j = 0;
- while (j < sub_len) {
- let index = sub_len * i + j;
- push_back(&mut sub, *borrow(v, index));
- j = j + 1;
- };
- push_back<vector<Element>>(&mut result, sub);
- i = i + 1;
- };
-
- if (rem > 0) {
- let sub = empty<Element>();
- let index = length(v) - rem;
- while (index < length(v)) {
- push_back(&mut sub, *borrow(v, index));
- index = index + 1;
- };
- push_back<vector<Element>>(&mut result, sub);
- };
- result
-}
-
-
-
-
-fun spec_contains<Element>(v: vector<Element>, e: Element): bool {
- exists x in v: x == e
-}
-
-
-
-Check if v1
is equal to the result of adding e
at the end of v2
-
-
-
-
-
-fun eq_push_back<Element>(v1: vector<Element>, v2: vector<Element>, e: Element): bool {
- len(v1) == len(v2) + 1 &&
- v1[len(v1)-1] == e &&
- v1[0..len(v1)-1] == v2[0..len(v2)]
-}
-
-
-
-Check if v
is equal to the result of concatenating v1
and v2
-
-
-
-
-
-fun eq_append<Element>(v: vector<Element>, v1: vector<Element>, v2: vector<Element>): bool {
- len(v) == len(v1) + len(v2) &&
- v[0..len(v1)] == v1 &&
- v[len(v1)..len(v)] == v2
-}
-
-
-
-Check v1
is equal to the result of removing the first element of v2
-
-
-
-
-
-fun eq_pop_front<Element>(v1: vector<Element>, v2: vector<Element>): bool {
- len(v1) + 1 == len(v2) &&
- v1 == v2[1..len(v2)]
-}
-
-
-
-Check that v1
is equal to the result of removing the element at index i
from v2
.
-
-
-
-
-
-fun eq_remove_elem_at_index<Element>(i: u64, v1: vector<Element>, v2: vector<Element>): bool {
- len(v1) + 1 == len(v2) &&
- v1[0..i] == v2[0..i] &&
- v1[i..len(v1)] == v2[i + 1..len(v2)]
-}
-
-
-
-
-
-
-### Function `singleton`
-
-
-public fun singleton<Element>(e: Element): vector<Element>
-
-
-
-
-
-aborts_if false;
-ensures result == vec(e);
-
-
-
-
-
-
-
-
-fun spec_singleton<Element>(e: Element): vector<Element> {
- vec(e)
-}
-
-
-
-
-
-
-### Function `reverse`
-
-
-public fun reverse<Element>(v: &mut vector<Element>)
-
-
-
-
-
-pragma intrinsic = true;
-
-
-
-
-
-
-### Function `append`
-
-
-public fun append<Element>(lhs: &mut vector<Element>, other: vector<Element>)
-
-
-
-
-
-pragma intrinsic = true;
-
-
-
-
-
-
-### Function `is_empty`
-
-
-public fun is_empty<Element>(v: &vector<Element>): bool
-
-
-
-
-
-pragma intrinsic = true;
-
-
-
-
-
-
-### Function `contains`
-
-
-public fun contains<Element>(v: &vector<Element>, e: &Element): bool
-
-
-
-
-
-pragma intrinsic = true;
-
-
-
-
-
-
-### Function `index_of`
-
-
-public fun index_of<Element>(v: &vector<Element>, e: &Element): (bool, u64)
-
-
-
-
-
-pragma intrinsic = true;
-
-
-
-
-
-
-### Function `remove`
-
-
-public fun remove<Element>(v: &mut vector<Element>, i: u64): Element
-
-
-
-
-
-pragma intrinsic = true;
-
-
-
-
-
-
-### Function `swap_remove`
-
-
-public fun swap_remove<Element>(v: &mut vector<Element>, i: u64): Element
-
-
-
-
-
-pragma intrinsic = true;
-
-
-
-
-
-
-### Function `split`
-
-
-public fun split<Element: copy, drop, store>(v: &vector<Element>, sub_len: u64): vector<vector<Element>>
-
-
-
-
-
-pragma verify = false;
-aborts_if sub_len == 0;
-
diff --git a/vm/stdlib/compiled/latest/doc/Version.md b/vm/stdlib/compiled/latest/doc/Version.md
deleted file mode 100644
index 398f54e8d8..0000000000
--- a/vm/stdlib/compiled/latest/doc/Version.md
+++ /dev/null
@@ -1,156 +0,0 @@
-
-
-
-# Module `0x1::Version`
-
-Version
tracks version of something, like current VM version.
-
-
-- [Struct `Version`](#0x1_Version_Version)
-- [Constants](#@Constants_0)
-- [Function `new_version`](#0x1_Version_new_version)
-- [Function `get`](#0x1_Version_get)
-- [Specification](#@Specification_1)
- - [Function `new_version`](#@Specification_1_new_version)
- - [Function `get`](#@Specification_1_get)
-
-
-use 0x1::Config;
-
-
-
-
-
-
-## Struct `Version`
-
-Version.
-
-
-struct Version has copy, drop, store
-
-
-
-
-major: u64
-const EMAJOR_TO_OLD: u64 = 101;
-
-
-
-
-
-
-## Function `new_version`
-
-Create a new version.
-
-
-public fun new_version(major: u64): Version::Version
-
-
-
-
-public fun new_version(major: u64): Version {
- Version { major }
-}
-
-
-
-
-addr
.
-
-
-public fun get(addr: address): u64
-
-
-
-
-public fun get(addr: address): u64 {
- let version = Config::get_by_address<Self::Version>(addr);
- version.major
-}
-
-
-
-
-pragma verify;
-pragma aborts_if_is_strict;
-
-
-
-
-
-
-### Function `new_version`
-
-
-public fun new_version(major: u64): Version::Version
-
-
-
-
-
-aborts_if false;
-
-
-
-
-
-
-### Function `get`
-
-
-public fun get(addr: address): u64
-
-
-
-
-
-aborts_if !exists<Config::Config<Version>>(addr);
-
diff --git a/vm/stdlib/compiled/latest/doc/YieldFarming.md b/vm/stdlib/compiled/latest/doc/YieldFarming.md
deleted file mode 100644
index 855bdb9a5d..0000000000
--- a/vm/stdlib/compiled/latest/doc/YieldFarming.md
+++ /dev/null
@@ -1,886 +0,0 @@
-
-
-
-# Module `0x1::YieldFarming`
-
-
-
-- [Resource `Farming`](#0x1_YieldFarming_Farming)
-- [Resource `FarmingAsset`](#0x1_YieldFarming_FarmingAsset)
-- [Resource `ParameterModifyCapability`](#0x1_YieldFarming_ParameterModifyCapability)
-- [Resource `Stake`](#0x1_YieldFarming_Stake)
-- [Struct `Exp`](#0x1_YieldFarming_Exp)
-- [Constants](#@Constants_0)
-- [Function `exp`](#0x1_YieldFarming_exp)
-- [Function `mul_u128`](#0x1_YieldFarming_mul_u128)
-- [Function `div_u128`](#0x1_YieldFarming_div_u128)
-- [Function `truncate`](#0x1_YieldFarming_truncate)
-- [Function `initialize`](#0x1_YieldFarming_initialize)
-- [Function `initialize_asset`](#0x1_YieldFarming_initialize_asset)
-- [Function `modify_parameter`](#0x1_YieldFarming_modify_parameter)
-- [Function `stake`](#0x1_YieldFarming_stake)
-- [Function `unstake`](#0x1_YieldFarming_unstake)
-- [Function `harvest`](#0x1_YieldFarming_harvest)
-- [Function `query_gov_token_amount`](#0x1_YieldFarming_query_gov_token_amount)
-- [Function `query_total_stake`](#0x1_YieldFarming_query_total_stake)
-- [Function `query_stake`](#0x1_YieldFarming_query_stake)
-- [Function `calculate_harvest_index_with_asset`](#0x1_YieldFarming_calculate_harvest_index_with_asset)
-- [Function `calculate_harvest_index_weight_zero`](#0x1_YieldFarming_calculate_harvest_index_weight_zero)
-- [Function `calculate_harvest_index`](#0x1_YieldFarming_calculate_harvest_index)
-- [Function `calculate_withdraw_amount`](#0x1_YieldFarming_calculate_withdraw_amount)
-- [Function `exists_at`](#0x1_YieldFarming_exists_at)
-- [Function `exists_asset_at`](#0x1_YieldFarming_exists_asset_at)
-- [Function `exists_stake_at_address`](#0x1_YieldFarming_exists_stake_at_address)
-- [Specification](#@Specification_1)
-
-
-use 0x1::Errors;
-use 0x1::Token;
-
-
-
-
-
-
-## Resource `Farming`
-
-The object of yield farming
-RewardTokenT meaning token of yield farming
-
-
-struct Farming<PoolType, RewardTokenT> has store, key
-
-
-
-
-treasury_token: Token::Token<RewardTokenT>
-struct FarmingAsset<PoolType, AssetT> has store, key
-
-
-
-
-asset_total_weight: u128
-harvest_index: u128
-last_update_timestamp: u64
-release_per_second: u128
-start_time: u64
-struct ParameterModifyCapability<PoolType, AssetT> has store, key
-
-
-
-
-dummy_field: bool
-struct Stake<PoolType, AssetT> has store, key
-
-
-
-
-asset: AssetT
-asset_weight: u128
-last_harvest_index: u128
-gain: u128
-struct Exp has copy, drop, store
-
-
-
-
-mantissa: u128
-const EDEPRECATED_FUNCTION: u64 = 19;
-
-
-
-
-
-
-
-
-const ERR_EXP_DIVIDE_BY_ZERO: u64 = 107;
-
-
-
-
-
-
-
-
-const ERR_FARMING_BALANCE_EXCEEDED: u64 = 108;
-
-
-
-
-
-
-
-
-const ERR_FARMING_HAVERST_NO_GAIN: u64 = 105;
-
-
-
-
-
-
-
-
-const ERR_FARMING_INIT_REPEATE: u64 = 101;
-
-
-
-
-
-
-
-
-const ERR_FARMING_NOT_ENOUGH_ASSET: u64 = 109;
-
-
-
-
-
-
-
-
-const ERR_FARMING_NOT_STILL_FREEZE: u64 = 102;
-
-
-
-
-
-
-
-
-const ERR_FARMING_STAKE_EXISTS: u64 = 103;
-
-
-
-
-
-
-
-
-const ERR_FARMING_STAKE_NOT_EXISTS: u64 = 104;
-
-
-
-
-
-
-
-
-const ERR_FARMING_TIMESTAMP_INVALID: u64 = 110;
-
-
-
-
-
-
-
-
-const ERR_FARMING_TOTAL_WEIGHT_IS_ZERO: u64 = 106;
-
-
-
-
-
-
-
-
-const EXP_SCALE: u128 = 1000000000000000000;
-
-
-
-
-
-
-## Function `exp`
-
-
-
-fun exp(num: u128, denom: u128): YieldFarming::Exp
-
-
-
-
-fun exp(num: u128, denom: u128): Exp {
- // if overflow move will abort
- let scaledNumerator = mul_u128(num, EXP_SCALE);
- let rational = div_u128(scaledNumerator, denom);
- Exp {
- mantissa: rational
- }
-}
-
-
-
-
-fun mul_u128(a: u128, b: u128): u128
-
-
-
-
-fun mul_u128(a: u128, b: u128): u128 {
- if (a == 0 || b == 0) {
- return 0
- };
-
- a * b
-}
-
-
-
-
-fun div_u128(a: u128, b: u128): u128
-
-
-
-
-fun div_u128(a: u128, b: u128): u128 {
- if ( b == 0) {
- abort Errors::invalid_argument(ERR_EXP_DIVIDE_BY_ZERO)
- };
- if (a == 0) {
- return 0
- };
- a / b
-}
-
-
-
-
-fun truncate(exp: YieldFarming::Exp): u128
-
-
-
-
-fun truncate(exp: Exp): u128 {
- return exp.mantissa / EXP_SCALE
-}
-
-
-
-
-public fun initialize<PoolType: store, RewardTokenT: store>(_account: &signer, _treasury_token: Token::Token<RewardTokenT>)
-
-
-
-
-public fun initialize<
- PoolType: store,
- RewardTokenT: store>(_account: &signer,
- _treasury_token: Token::Token<RewardTokenT>) {
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-public fun initialize_asset<PoolType: store, AssetT: store>(_account: &signer, _release_per_second: u128, _delay: u64): YieldFarming::ParameterModifyCapability<PoolType, AssetT>
-
-
-
-
-public fun initialize_asset<PoolType: store, AssetT: store>(
- _account: &signer,
- _release_per_second: u128,
- _delay: u64): ParameterModifyCapability<PoolType, AssetT> {
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-public fun modify_parameter<PoolType: store, RewardTokenT: store, AssetT: store>(_cap: &YieldFarming::ParameterModifyCapability<PoolType, AssetT>, _broker: address, _release_per_second: u128)
-
-
-
-
-public fun modify_parameter<PoolType: store, RewardTokenT: store, AssetT: store>(
- _cap: &ParameterModifyCapability<PoolType, AssetT>,
- _broker: address,
- _release_per_second: u128) {
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-public fun stake<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address, _asset: AssetT, _asset_weight: u128)
-
-
-
-
-public fun stake<PoolType: store, RewardTokenT: store, AssetT: store>(
- _account: &signer,
- _broker: address,
- _asset: AssetT,
- _asset_weight: u128) {
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-public fun unstake<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address): (AssetT, Token::Token<RewardTokenT>)
-
-
-
-
-public fun unstake<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address)
-: (AssetT, Token::Token<RewardTokenT>) {
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-public fun harvest<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address, _amount: u128): Token::Token<RewardTokenT>
-
-
-
-
-public fun harvest<PoolType: store,
- RewardTokenT: store,
- AssetT: store>(
- _account: &signer,
- _broker: address,
- _amount: u128): Token::Token<RewardTokenT> {
- abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
-
-
-
-public fun query_gov_token_amount<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address): u128
-
-
-
-
-public fun query_gov_token_amount<PoolType: store,
- RewardTokenT: store,
- AssetT: store>(_account: &signer, _broker: address): u128 {
- 0
-}
-
-
-
-
-public fun query_total_stake<PoolType: store, AssetT: store>(_broker: address): u128
-
-
-
-
-public fun query_total_stake<PoolType: store,
- AssetT: store>(_broker: address): u128 {
- 0
-}
-
-
-
-
-public fun query_stake<PoolType: store, AssetT: store>(_account: &signer): u128
-
-
-
-
-public fun query_stake<PoolType: store,
- AssetT: store>(_account: &signer): u128 {
- 0
-}
-
-
-
-
-fun calculate_harvest_index_with_asset<PoolType, AssetT>(_farming_asset: &YieldFarming::FarmingAsset<PoolType, AssetT>, _now_seconds: u64): u128
-
-
-
-
-fun calculate_harvest_index_with_asset<PoolType, AssetT>(_farming_asset: &FarmingAsset<PoolType, AssetT>, _now_seconds: u64): u128 {
- 0
-}
-
-
-
-
-public fun calculate_harvest_index_weight_zero(_harvest_index: u128, _last_update_timestamp: u64, _now_seconds: u64, _release_per_second: u128): u128
-
-
-
-
-public fun calculate_harvest_index_weight_zero(_harvest_index: u128,
- _last_update_timestamp: u64,
- _now_seconds: u64,
- _release_per_second: u128): u128 {
- 0
-}
-
-
-
-
-public fun calculate_harvest_index(_harvest_index: u128, _asset_total_weight: u128, _last_update_timestamp: u64, _now_seconds: u64, _release_per_second: u128): u128
-
-
-
-
-public fun calculate_harvest_index(_harvest_index: u128,
- _asset_total_weight: u128,
- _last_update_timestamp: u64,
- _now_seconds: u64,
- _release_per_second: u128): u128 {
- 0
-}
-
-
-
-
-public fun calculate_withdraw_amount(_harvest_index: u128, _last_harvest_index: u128, _asset_weight: u128): u128
-
-
-
-
-public fun calculate_withdraw_amount(_harvest_index: u128,
- _last_harvest_index: u128,
- _asset_weight: u128): u128 {
- 0
-}
-
-
-
-
-public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool
-
-
-
-
-public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool {
- exists<Farming<PoolType, RewardTokenT>>(broker)
-}
-
-
-
-
-public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool
-
-
-
-
-public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool {
- exists<FarmingAsset<PoolType, AssetT>>(broker)
-}
-
-
-
-
-public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool
-
-
-
-
-public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool {
- exists<Stake<PoolType, AssetT>>(account)
-}
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/doc/YieldFarmingV2.md b/vm/stdlib/compiled/latest/doc/YieldFarmingV2.md
deleted file mode 100644
index 8e1c6d9958..0000000000
--- a/vm/stdlib/compiled/latest/doc/YieldFarmingV2.md
+++ /dev/null
@@ -1,1429 +0,0 @@
-
-
-
-# Module `0x1::YieldFarmingV2`
-
-
-
-- [Struct `Exp`](#0x1_YieldFarmingV2_Exp)
-- [Resource `Farming`](#0x1_YieldFarmingV2_Farming)
-- [Resource `FarmingAsset`](#0x1_YieldFarmingV2_FarmingAsset)
-- [Resource `Stake`](#0x1_YieldFarmingV2_Stake)
-- [Resource `ParameterModifyCapability`](#0x1_YieldFarmingV2_ParameterModifyCapability)
-- [Resource `HarvestCapability`](#0x1_YieldFarmingV2_HarvestCapability)
-- [Constants](#@Constants_0)
-- [Function `exp_direct`](#0x1_YieldFarmingV2_exp_direct)
-- [Function `exp_direct_expand`](#0x1_YieldFarmingV2_exp_direct_expand)
-- [Function `mantissa`](#0x1_YieldFarmingV2_mantissa)
-- [Function `add_exp`](#0x1_YieldFarmingV2_add_exp)
-- [Function `exp`](#0x1_YieldFarmingV2_exp)
-- [Function `add_u128`](#0x1_YieldFarmingV2_add_u128)
-- [Function `sub_u128`](#0x1_YieldFarmingV2_sub_u128)
-- [Function `mul_u128`](#0x1_YieldFarmingV2_mul_u128)
-- [Function `div_u128`](#0x1_YieldFarmingV2_div_u128)
-- [Function `truncate`](#0x1_YieldFarmingV2_truncate)
-- [Function `initialize`](#0x1_YieldFarmingV2_initialize)
-- [Function `add_asset`](#0x1_YieldFarmingV2_add_asset)
-- [Function `modify_parameter`](#0x1_YieldFarmingV2_modify_parameter)
-- [Function `stake`](#0x1_YieldFarmingV2_stake)
-- [Function `stake_for_cap`](#0x1_YieldFarmingV2_stake_for_cap)
-- [Function `unstake`](#0x1_YieldFarmingV2_unstake)
-- [Function `unstake_with_cap`](#0x1_YieldFarmingV2_unstake_with_cap)
-- [Function `harvest`](#0x1_YieldFarmingV2_harvest)
-- [Function `harvest_with_cap`](#0x1_YieldFarmingV2_harvest_with_cap)
-- [Function `query_gov_token_amount`](#0x1_YieldFarmingV2_query_gov_token_amount)
-- [Function `query_total_stake`](#0x1_YieldFarmingV2_query_total_stake)
-- [Function `query_stake`](#0x1_YieldFarmingV2_query_stake)
-- [Function `query_info`](#0x1_YieldFarmingV2_query_info)
-- [Function `calculate_harvest_index_with_asset`](#0x1_YieldFarmingV2_calculate_harvest_index_with_asset)
-- [Function `calculate_harvest_index_weight_zero`](#0x1_YieldFarmingV2_calculate_harvest_index_weight_zero)
-- [Function `calculate_harvest_index`](#0x1_YieldFarmingV2_calculate_harvest_index)
-- [Function `calculate_withdraw_amount`](#0x1_YieldFarmingV2_calculate_withdraw_amount)
-- [Function `exists_at`](#0x1_YieldFarmingV2_exists_at)
-- [Function `exists_asset_at`](#0x1_YieldFarmingV2_exists_asset_at)
-- [Function `exists_stake_at_address`](#0x1_YieldFarmingV2_exists_stake_at_address)
-- [Specification](#@Specification_1)
-
-
-use 0x1::Errors;
-use 0x1::Math;
-use 0x1::Signer;
-use 0x1::Timestamp;
-use 0x1::Token;
-
-
-
-
-
-
-## Struct `Exp`
-
-
-
-struct Exp has copy, drop, store
-
-
-
-
-mantissa: u128
-struct Farming<PoolType, RewardTokenT> has store, key
-
-
-
-
-treasury_token: Token::Token<RewardTokenT>
-struct FarmingAsset<PoolType, AssetT> has store, key
-
-
-
-
-asset_total_weight: u128
-harvest_index: u128
-last_update_timestamp: u64
-release_per_second: u128
-start_time: u64
-alive: bool
-struct Stake<PoolType, AssetT> has store, key
-
-
-
-
-asset: AssetT
-asset_weight: u128
-last_harvest_index: u128
-gain: u128
-struct ParameterModifyCapability<PoolType, AssetT> has store, key
-
-
-
-
-dummy_field: bool
-struct HarvestCapability<PoolType, AssetT> has store, key
-
-
-
-
-trigger: address
-const ERR_EXP_DIVIDE_BY_ZERO: u64 = 107;
-
-
-
-
-
-
-
-
-const ERR_FARMING_BALANCE_EXCEEDED: u64 = 108;
-
-
-
-
-
-
-
-
-const ERR_FARMING_HAVERST_NO_GAIN: u64 = 105;
-
-
-
-
-
-
-
-
-const ERR_FARMING_INIT_REPEATE: u64 = 101;
-
-
-
-
-
-
-
-
-const ERR_FARMING_NOT_ENOUGH_ASSET: u64 = 109;
-
-
-
-
-
-
-
-
-const ERR_FARMING_NOT_STILL_FREEZE: u64 = 102;
-
-
-
-
-
-
-
-
-const ERR_FARMING_STAKE_EXISTS: u64 = 103;
-
-
-
-
-
-
-
-
-const ERR_FARMING_STAKE_NOT_EXISTS: u64 = 104;
-
-
-
-
-
-
-
-
-const ERR_FARMING_TIMESTAMP_INVALID: u64 = 110;
-
-
-
-
-
-
-
-
-const ERR_FARMING_TOTAL_WEIGHT_IS_ZERO: u64 = 106;
-
-
-
-
-
-
-
-
-const EXP_SCALE: u128 = 1000000000000000000;
-
-
-
-
-
-
-
-
-const ERR_FARMING_ALIVE_STATE_INVALID: u64 = 114;
-
-
-
-
-
-
-
-
-const ERR_FARMING_CALC_LAST_IDX_BIGGER_THAN_NOW: u64 = 112;
-
-
-
-
-
-
-
-
-const ERR_FARMING_NOT_ALIVE: u64 = 113;
-
-
-
-
-
-
-
-
-const ERR_FARMING_TOKEN_SCALE_OVERFLOW: u64 = 111;
-
-
-
-
-
-
-
-
-const EXP_MAX_SCALE: u128 = 9;
-
-
-
-
-
-
-## Function `exp_direct`
-
-
-
-fun exp_direct(num: u128): YieldFarmingV2::Exp
-
-
-
-
-fun exp_direct(num: u128): Exp {
- Exp {
- mantissa: num
- }
-}
-
-
-
-
-fun exp_direct_expand(num: u128): YieldFarmingV2::Exp
-
-
-
-
-fun exp_direct_expand(num: u128): Exp {
- Exp {
- mantissa: mul_u128(num, EXP_SCALE)
- }
-}
-
-
-
-
-fun mantissa(a: YieldFarmingV2::Exp): u128
-
-
-
-
-fun mantissa(a: Exp): u128 {
- a.mantissa
-}
-
-
-
-
-fun add_exp(a: YieldFarmingV2::Exp, b: YieldFarmingV2::Exp): YieldFarmingV2::Exp
-
-
-
-
-fun add_exp(a: Exp, b: Exp): Exp {
- Exp {
- mantissa: add_u128(a.mantissa, b.mantissa)
- }
-}
-
-
-
-
-fun exp(num: u128, denom: u128): YieldFarmingV2::Exp
-
-
-
-
-fun exp(num: u128, denom: u128): Exp {
- // if overflow move will abort
- let scaledNumerator = mul_u128(num, EXP_SCALE);
- let rational = div_u128(scaledNumerator, denom);
- Exp {
- mantissa: rational
- }
-}
-
-
-
-
-fun add_u128(a: u128, b: u128): u128
-
-
-
-
-fun add_u128(a: u128, b: u128): u128 {
- a + b
-}
-
-
-
-
-fun sub_u128(a: u128, b: u128): u128
-
-
-
-
-fun sub_u128(a: u128, b: u128): u128 {
- a - b
-}
-
-
-
-
-fun mul_u128(a: u128, b: u128): u128
-
-
-
-
-fun mul_u128(a: u128, b: u128): u128 {
- if (a == 0 || b == 0) {
- return 0
- };
- a * b
-}
-
-
-
-
-fun div_u128(a: u128, b: u128): u128
-
-
-
-
-fun div_u128(a: u128, b: u128): u128 {
- if (b == 0) {
- abort Errors::invalid_argument(ERR_EXP_DIVIDE_BY_ZERO)
- };
- if (a == 0) {
- return 0
- };
- a / b
-}
-
-
-
-
-fun truncate(exp: YieldFarmingV2::Exp): u128
-
-
-
-
-fun truncate(exp: Exp): u128 {
- return exp.mantissa / EXP_SCALE
-}
-
-
-
-
-public fun initialize<PoolType: store, RewardTokenT: store>(signer: &signer, treasury_token: Token::Token<RewardTokenT>)
-
-
-
-
-public fun initialize<
- PoolType: store,
- RewardTokenT: store>(signer: &signer, treasury_token: Token::Token<RewardTokenT>) {
- let scaling_factor = Math::pow(10, (EXP_MAX_SCALE as u64));
- let token_scale = Token::scaling_factor<RewardTokenT>();
- assert!(token_scale <= scaling_factor, Errors::limit_exceeded(ERR_FARMING_TOKEN_SCALE_OVERFLOW));
- assert!(!exists_at<PoolType, RewardTokenT>(
- Signer::address_of(signer)), Errors::invalid_state(ERR_FARMING_INIT_REPEATE));
-
- move_to(signer, Farming<PoolType, RewardTokenT> {
- treasury_token,
- });
-}
-
-
-
-
-public fun add_asset<PoolType: store, AssetT: store>(signer: &signer, release_per_second: u128, delay: u64): YieldFarmingV2::ParameterModifyCapability<PoolType, AssetT>
-
-
-
-
-public fun add_asset<PoolType: store, AssetT: store>(
- signer: &signer,
- release_per_second: u128,
- delay: u64): ParameterModifyCapability<PoolType, AssetT> {
- assert!(!exists_asset_at<PoolType, AssetT>(
- Signer::address_of(signer)),
- Errors::invalid_state(ERR_FARMING_INIT_REPEATE));
-
- let now_seconds = Timestamp::now_seconds();
-
- move_to(signer, FarmingAsset<PoolType, AssetT> {
- asset_total_weight: 0,
- harvest_index: 0,
- last_update_timestamp: now_seconds,
- release_per_second,
- start_time: now_seconds + delay,
- alive: true
- });
- ParameterModifyCapability<PoolType, AssetT> {}
-}
-
-
-
-
-public fun modify_parameter<PoolType: store, RewardTokenT: store, AssetT: store>(_cap: &YieldFarmingV2::ParameterModifyCapability<PoolType, AssetT>, broker: address, release_per_second: u128, alive: bool)
-
-
-
-
-public fun modify_parameter<PoolType: store, RewardTokenT: store, AssetT: store>(
- _cap: &ParameterModifyCapability<PoolType, AssetT>,
- broker: address,
- release_per_second: u128,
- alive: bool) acquires FarmingAsset {
-
- // Not support to shuttingdown alive state.
- assert!(alive, Errors::invalid_state(ERR_FARMING_ALIVE_STATE_INVALID));
-
- let farming_asset = borrow_global_mut<FarmingAsset<PoolType, AssetT>>(broker);
- // assert!(farming_asset.alive != alive, Errors::invalid_state(ERR_FARMING_ALIVE_STATE_INVALID));
-
- let now_seconds = Timestamp::now_seconds();
-
- farming_asset.release_per_second = release_per_second;
- farming_asset.last_update_timestamp = now_seconds;
-
- // if the pool is alive, then update index
- if (farming_asset.alive) {
- farming_asset.harvest_index = calculate_harvest_index_with_asset<PoolType, AssetT>(farming_asset, now_seconds);
- };
- farming_asset.alive = alive;
-}
-
-
-
-
-public fun stake<PoolType: store, RewardTokenT: store, AssetT: store>(signer: &signer, broker: address, asset: AssetT, asset_weight: u128, _cap: &YieldFarmingV2::ParameterModifyCapability<PoolType, AssetT>)
-
-
-
-
-public fun stake<PoolType: store, RewardTokenT: store, AssetT: store>(
- signer: &signer,
- broker: address,
- asset: AssetT,
- asset_weight: u128,
- _cap: &ParameterModifyCapability<PoolType, AssetT>) acquires FarmingAsset {
- let harvest_cap = stake_for_cap<
- PoolType,
- RewardTokenT,
- AssetT>(signer, broker, asset, asset_weight, _cap);
-
- move_to(signer, harvest_cap);
-}
-
-
-
-
-public fun stake_for_cap<PoolType: store, RewardTokenT: store, AssetT: store>(signer: &signer, broker: address, asset: AssetT, asset_weight: u128, _cap: &YieldFarmingV2::ParameterModifyCapability<PoolType, AssetT>): YieldFarmingV2::HarvestCapability<PoolType, AssetT>
-
-
-
-
-public fun stake_for_cap<PoolType: store, RewardTokenT: store, AssetT: store>(
- signer: &signer,
- broker: address,
- asset: AssetT,
- asset_weight: u128,
- _cap: &ParameterModifyCapability<PoolType, AssetT>)
-: HarvestCapability<PoolType, AssetT> acquires FarmingAsset {
- let account = Signer::address_of(signer);
- assert!(!exists_stake_at_address<PoolType, AssetT>(account),
- Errors::invalid_state(ERR_FARMING_STAKE_EXISTS));
-
- let farming_asset = borrow_global_mut<FarmingAsset<PoolType, AssetT>>(broker);
- assert!(farming_asset.alive, Errors::invalid_state(ERR_FARMING_NOT_ALIVE));
-
- // Check locking time
- let now_seconds = Timestamp::now_seconds();
- assert!(farming_asset.start_time <= now_seconds, Errors::invalid_state(ERR_FARMING_NOT_STILL_FREEZE));
-
- let time_period = now_seconds - farming_asset.last_update_timestamp;
-
- if (farming_asset.asset_total_weight <= 0) {
- // Stake as first user
- let gain = farming_asset.release_per_second * (time_period as u128);
- move_to(signer, Stake<PoolType, AssetT> {
- asset,
- asset_weight,
- last_harvest_index: 0,
- gain,
- });
- farming_asset.harvest_index = 0;
- farming_asset.asset_total_weight = asset_weight;
- } else {
- let new_harvest_index = calculate_harvest_index_with_asset<PoolType, AssetT>(farming_asset, now_seconds);
- move_to(signer, Stake<PoolType, AssetT> {
- asset,
- asset_weight,
- last_harvest_index: new_harvest_index,
- gain: 0,
- });
- farming_asset.asset_total_weight = farming_asset.asset_total_weight + asset_weight;
- farming_asset.harvest_index = new_harvest_index;
- };
- farming_asset.last_update_timestamp = now_seconds;
- HarvestCapability<PoolType, AssetT> { trigger: account }
-}
-
-
-
-
-public fun unstake<PoolType: store, RewardTokenT: store, AssetT: store>(signer: &signer, broker: address): (AssetT, Token::Token<RewardTokenT>)
-
-
-
-
-public fun unstake<PoolType: store, RewardTokenT: store, AssetT: store>(
- signer: &signer,
- broker: address)
-: (AssetT, Token::Token<RewardTokenT>) acquires HarvestCapability, Farming, FarmingAsset, Stake {
- let account = Signer::address_of(signer);
- let cap = move_from<HarvestCapability<PoolType, AssetT>>(account);
- unstake_with_cap(broker, cap)
-}
-
-
-
-
-public fun unstake_with_cap<PoolType: store, RewardTokenT: store, AssetT: store>(broker: address, cap: YieldFarmingV2::HarvestCapability<PoolType, AssetT>): (AssetT, Token::Token<RewardTokenT>)
-
-
-
-
-public fun unstake_with_cap<PoolType: store, RewardTokenT: store, AssetT: store>(
- broker: address,
- cap: HarvestCapability<PoolType, AssetT>)
-: (AssetT, Token::Token<RewardTokenT>) acquires Farming, FarmingAsset, Stake {
- // Destroy capability
- let HarvestCapability<PoolType, AssetT> { trigger } = cap;
-
- let farming = borrow_global_mut<Farming<PoolType, RewardTokenT>>(broker);
- let farming_asset = borrow_global_mut<FarmingAsset<PoolType, AssetT>>(broker);
-
- let Stake<PoolType, AssetT> { last_harvest_index, asset_weight, asset, gain } =
- move_from<Stake<PoolType, AssetT>>(trigger);
-
- let now_seconds = Timestamp::now_seconds();
- let new_harvest_index = calculate_harvest_index_with_asset<PoolType, AssetT>(farming_asset, now_seconds);
-
- let period_gain = calculate_withdraw_amount(new_harvest_index, last_harvest_index, asset_weight);
- let total_gain = gain + period_gain;
- let withdraw_token = Token::withdraw<RewardTokenT>(&mut farming.treasury_token, total_gain);
-
- // Dont update harvest index that because the `Stake` object has droped.
- // let new_index = calculate_harvest_index_with_asset<PoolType, AssetT>(farming_asset, now_seconds);
- assert!(farming_asset.asset_total_weight >= asset_weight, Errors::invalid_state(ERR_FARMING_NOT_ENOUGH_ASSET));
-
- // Update farm asset
- farming_asset.asset_total_weight = farming_asset.asset_total_weight - asset_weight;
- farming_asset.last_update_timestamp = now_seconds;
-
- if (farming_asset.alive) {
- farming_asset.harvest_index = new_harvest_index;
- };
-
- (asset, withdraw_token)
-}
-
-
-
-
-public fun harvest<PoolType: store, RewardTokenT: store, AssetT: store>(signer: &signer, broker: address, amount: u128): Token::Token<RewardTokenT>
-
-
-
-
-public fun harvest<PoolType: store,
- RewardTokenT: store,
- AssetT: store>(
- signer: &signer,
- broker: address,
- amount: u128) : Token::Token<RewardTokenT> acquires HarvestCapability, Farming, FarmingAsset, Stake {
- let account = Signer::address_of(signer);
- let cap = borrow_global_mut<HarvestCapability<PoolType, AssetT>>(account);
- harvest_with_cap(broker, amount, cap)
-}
-
-
-
-
-public fun harvest_with_cap<PoolType: store, RewardTokenT: store, AssetT: store>(broker: address, amount: u128, _cap: &YieldFarmingV2::HarvestCapability<PoolType, AssetT>): Token::Token<RewardTokenT>
-
-
-
-
-public fun harvest_with_cap<PoolType: store,
- RewardTokenT: store,
- AssetT: store>(
- broker: address,
- amount: u128,
- _cap: &HarvestCapability<PoolType, AssetT>): Token::Token<RewardTokenT> acquires Farming, FarmingAsset, Stake {
- let farming = borrow_global_mut<Farming<PoolType, RewardTokenT>>(broker);
- let farming_asset = borrow_global_mut<FarmingAsset<PoolType, AssetT>>(broker);
- let stake = borrow_global_mut<Stake<PoolType, AssetT>>(_cap.trigger);
-
- let now_seconds = Timestamp::now_seconds();
- let new_harvest_index = calculate_harvest_index_with_asset<PoolType, AssetT>(farming_asset, now_seconds);
-
- let period_gain = calculate_withdraw_amount(
- new_harvest_index,
- stake.last_harvest_index,
- stake.asset_weight
- );
-
- let total_gain = stake.gain + period_gain;
- //assert!(total_gain > 0, Errors::limit_exceeded(ERR_FARMING_HAVERST_NO_GAIN));
- assert!(total_gain >= amount, Errors::limit_exceeded(ERR_FARMING_BALANCE_EXCEEDED));
-
- let withdraw_amount = if (amount <= 0) {
- total_gain
- } else {
- amount
- };
-
- let withdraw_token = Token::withdraw<RewardTokenT>(&mut farming.treasury_token, withdraw_amount);
- stake.gain = total_gain - withdraw_amount;
- stake.last_harvest_index = new_harvest_index;
-
- if (farming_asset.alive) {
- farming_asset.harvest_index = new_harvest_index;
- };
- farming_asset.last_update_timestamp = now_seconds;
-
- withdraw_token
-}
-
-
-
-
-public fun query_gov_token_amount<PoolType: store, RewardTokenT: store, AssetT: store>(account: address, broker: address): u128
-
-
-
-
-public fun query_gov_token_amount<PoolType: store,
- RewardTokenT: store,
- AssetT: store>(account: address, broker: address): u128 acquires FarmingAsset, Stake {
- let farming_asset = borrow_global_mut<FarmingAsset<PoolType, AssetT>>(broker);
- let stake = borrow_global_mut<Stake<PoolType, AssetT>>(account);
- let now_seconds = Timestamp::now_seconds();
-
- let new_harvest_index = calculate_harvest_index_with_asset<PoolType, AssetT>(
- farming_asset,
- now_seconds
- );
-
- let new_gain = calculate_withdraw_amount(
- new_harvest_index,
- stake.last_harvest_index,
- stake.asset_weight
- );
- stake.gain + new_gain
-}
-
-
-
-
-public fun query_total_stake<PoolType: store, AssetT: store>(broker: address): u128
-
-
-
-
-public fun query_total_stake<PoolType: store,
- AssetT: store>(broker: address): u128 acquires FarmingAsset {
- let farming_asset = borrow_global_mut<FarmingAsset<PoolType, AssetT>>(broker);
- farming_asset.asset_total_weight
-}
-
-
-
-
-public fun query_stake<PoolType: store, AssetT: store>(account: address): u128
-
-
-
-
-public fun query_stake<PoolType: store,
- AssetT: store>(account: address): u128 acquires Stake {
- let stake = borrow_global_mut<Stake<PoolType, AssetT>>(account);
- stake.asset_weight
-}
-
-
-
-
-public fun query_info<PoolType: store, AssetT: store>(broker: address): (bool, u128, u128, u128)
-
-
-
-
-public fun query_info<PoolType: store, AssetT: store>(broker: address): (bool, u128, u128, u128) acquires FarmingAsset {
- let asset = borrow_global_mut<FarmingAsset<PoolType, AssetT>>(broker);
- (
- asset.alive,
- asset.release_per_second,
- asset.asset_total_weight,
- asset.harvest_index
- )
-}
-
-
-
-
-fun calculate_harvest_index_with_asset<PoolType, AssetT>(farming_asset: &YieldFarmingV2::FarmingAsset<PoolType, AssetT>, now_seconds: u64): u128
-
-
-
-
-fun calculate_harvest_index_with_asset<PoolType, AssetT>(farming_asset: &FarmingAsset<PoolType, AssetT>, now_seconds: u64): u128 {
- // Recalculate harvest index
- if (farming_asset.asset_total_weight <= 0) {
- calculate_harvest_index_weight_zero(
- farming_asset.harvest_index,
- farming_asset.last_update_timestamp,
- now_seconds,
- farming_asset.release_per_second
- )
- } else {
- calculate_harvest_index(
- farming_asset.harvest_index,
- farming_asset.asset_total_weight,
- farming_asset.last_update_timestamp,
- now_seconds,
- farming_asset.release_per_second
- )
- }
-}
-
-
-
-
-public fun calculate_harvest_index_weight_zero(harvest_index: u128, last_update_timestamp: u64, now_seconds: u64, release_per_second: u128): u128
-
-
-
-
-public fun calculate_harvest_index_weight_zero(harvest_index: u128,
- last_update_timestamp: u64,
- now_seconds: u64,
- release_per_second: u128): u128 {
- assert!(last_update_timestamp <= now_seconds, Errors::invalid_argument(ERR_FARMING_TIMESTAMP_INVALID));
- let time_period = now_seconds - last_update_timestamp;
- let addtion_index = release_per_second * ((time_period as u128));
- harvest_index + mantissa(exp_direct_expand(addtion_index))
-}
-
-
-
-
-public fun calculate_harvest_index(harvest_index: u128, asset_total_weight: u128, last_update_timestamp: u64, now_seconds: u64, release_per_second: u128): u128
-
-
-
-
-public fun calculate_harvest_index(harvest_index: u128,
- asset_total_weight: u128,
- last_update_timestamp: u64,
- now_seconds: u64,
- release_per_second: u128): u128 {
- assert!(asset_total_weight > 0, Errors::invalid_argument(ERR_FARMING_TOTAL_WEIGHT_IS_ZERO));
- assert!(last_update_timestamp <= now_seconds, Errors::invalid_argument(ERR_FARMING_TIMESTAMP_INVALID));
-
- let time_period = now_seconds - last_update_timestamp;
- let numr = (release_per_second * (time_period as u128));
- let denom = asset_total_weight;
- harvest_index + mantissa(exp(numr, denom))
-}
-
-
-
-
-public fun calculate_withdraw_amount(harvest_index: u128, last_harvest_index: u128, asset_weight: u128): u128
-
-
-
-
-public fun calculate_withdraw_amount(harvest_index: u128,
- last_harvest_index: u128,
- asset_weight: u128): u128 {
- assert!(harvest_index >= last_harvest_index, Errors::invalid_argument(ERR_FARMING_CALC_LAST_IDX_BIGGER_THAN_NOW));
- let amount = asset_weight * (harvest_index - last_harvest_index);
- truncate(exp_direct(amount))
-}
-
-
-
-
-public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool
-
-
-
-
-public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool {
- exists<Farming<PoolType, RewardTokenT>>(broker)
-}
-
-
-
-
-public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool
-
-
-
-
-public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool {
- exists<FarmingAsset<PoolType, AssetT>>(broker)
-}
-
-
-
-
-public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool
-
-
-
-
-public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool {
- exists<Stake<PoolType, AssetT>>(account)
-}
-
-
-
-
-pragma verify = false;
-
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/accept_token.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/accept_token.abi
deleted file mode 100644
index 9d200103bb..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/accept_token.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/create_account_with_initial_amount.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/create_account_with_initial_amount.abi
deleted file mode 100644
index 3a0f339cc3..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/create_account_with_initial_amount.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/create_account_with_initial_amount_v2.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/create_account_with_initial_amount_v2.abi
deleted file mode 100644
index 4c1f45295a..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/create_account_with_initial_amount_v2.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/rotate_authentication_key.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/rotate_authentication_key.abi
deleted file mode 100644
index d69bd37110..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Account/rotate_authentication_key.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/AccountScripts/disable_auto_accept_token.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/AccountScripts/disable_auto_accept_token.abi
deleted file mode 100644
index 3661e68024..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/AccountScripts/disable_auto_accept_token.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/AccountScripts/enable_auto_accept_token.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/AccountScripts/enable_auto_accept_token.abi
deleted file mode 100644
index 2cb1e7b537..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/AccountScripts/enable_auto_accept_token.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Dao/destroy_terminated_proposal.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Dao/destroy_terminated_proposal.abi
deleted file mode 100644
index ce2f1889bb..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Dao/destroy_terminated_proposal.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Dao/queue_proposal_action.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Dao/queue_proposal_action.abi
deleted file mode 100644
index afbffcd70e..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Dao/queue_proposal_action.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/cast_vote.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/cast_vote.abi
deleted file mode 100644
index 4b294bf355..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/cast_vote.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/flip_vote.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/flip_vote.abi
deleted file mode 100644
index 5aca87b205..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/flip_vote.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/revoke_vote.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/revoke_vote.abi
deleted file mode 100644
index 66a558bbf2..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/revoke_vote.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/revoke_vote_of_power.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/revoke_vote_of_power.abi
deleted file mode 100644
index 2338979494..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/revoke_vote_of_power.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/unstake_vote.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/unstake_vote.abi
deleted file mode 100644
index 2d215ed5b2..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/DaoVoteScripts/unstake_vote.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/DummyToken/mint.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/DummyToken/mint.abi
deleted file mode 100644
index 0174dc6223..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/DummyToken/mint.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/EmptyScripts/empty_script.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/EmptyScripts/empty_script.abi
deleted file mode 100644
index 2be29aba49..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/EmptyScripts/empty_script.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Genesis/initialize.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Genesis/initialize.abi
deleted file mode 100644
index a2f881aec1..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Genesis/initialize.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Genesis/initialize_v2.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Genesis/initialize_v2.abi
deleted file mode 100644
index 3c0fe67b2c..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Genesis/initialize_v2.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/GenesisNFT/mint.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/GenesisNFT/mint.abi
deleted file mode 100644
index b6a74ac41c..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/GenesisNFT/mint.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModifyDaoConfigProposal/execute.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/ModifyDaoConfigProposal/execute.abi
deleted file mode 100644
index a32f55747c..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModifyDaoConfigProposal/execute.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModifyDaoConfigProposal/propose.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/ModifyDaoConfigProposal/propose.abi
deleted file mode 100644
index 9dea639031..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModifyDaoConfigProposal/propose.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/cancel_upgrade_plan.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/cancel_upgrade_plan.abi
deleted file mode 100644
index f39e40a4b1..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/cancel_upgrade_plan.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/execute_module_upgrade_plan_propose.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/execute_module_upgrade_plan_propose.abi
deleted file mode 100644
index 0f59d6f097..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/execute_module_upgrade_plan_propose.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/propose_module_upgrade_v2.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/propose_module_upgrade_v2.abi
deleted file mode 100644
index a949b2605f..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/propose_module_upgrade_v2.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/submit_module_upgrade_plan.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/submit_module_upgrade_plan.abi
deleted file mode 100644
index 6b11cc23b4..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/submit_module_upgrade_plan.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/submit_upgrade_plan.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/submit_upgrade_plan.abi
deleted file mode 100644
index 1198af0176..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/submit_upgrade_plan.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/update_module_upgrade_strategy.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/update_module_upgrade_strategy.abi
deleted file mode 100644
index a166e00189..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/ModuleUpgradeScripts/update_module_upgrade_strategy.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/NFT/accept.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/NFT/accept.abi
deleted file mode 100644
index 8e678ebdf6..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/NFT/accept.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/NFT/destroy_empty.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/NFT/destroy_empty.abi
deleted file mode 100644
index 456cb71a6b..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/NFT/destroy_empty.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/NFT/transfer.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/NFT/transfer.abi
deleted file mode 100644
index 492b218d3f..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/NFT/transfer.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Offer/take_offer.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Offer/take_offer.abi
deleted file mode 100644
index a9ad0fa82d..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Offer/take_offer.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/execute_on_chain_config_proposal.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/execute_on_chain_config_proposal.abi
deleted file mode 100644
index 884f242133..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/execute_on_chain_config_proposal.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/execute_on_chain_config_proposal_v2.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/execute_on_chain_config_proposal_v2.abi
deleted file mode 100644
index 4fa4c35ae4..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/execute_on_chain_config_proposal_v2.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_consensus_config.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_consensus_config.abi
deleted file mode 100644
index 543cd101e7..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_consensus_config.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_move_language_version.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_move_language_version.abi
deleted file mode 100644
index 20cc2fa37b..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_move_language_version.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_reward_config.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_reward_config.abi
deleted file mode 100644
index 8a2a050dc4..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_reward_config.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_txn_publish_option.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_txn_publish_option.abi
deleted file mode 100644
index 1f80407e9a..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_txn_publish_option.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_txn_timeout_config.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_txn_timeout_config.abi
deleted file mode 100644
index 7dbba62f2f..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_txn_timeout_config.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_vm_config.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_vm_config.abi
deleted file mode 100644
index 2a990bca6b..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/OnChainConfigScripts/propose_update_vm_config.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Oracle/init_data_source.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Oracle/init_data_source.abi
deleted file mode 100644
index c5e6b0be05..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Oracle/init_data_source.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Oracle/register_oracle.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Oracle/register_oracle.abi
deleted file mode 100644
index b9d93a29f1..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Oracle/register_oracle.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/Oracle/update.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/Oracle/update.abi
deleted file mode 100644
index acbc5310b3..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/Oracle/update.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/PackageTxnManager/convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/PackageTxnManager/convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2.abi
deleted file mode 100644
index 179a1e0583..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/PackageTxnManager/convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/take_linear_withdraw_capability.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/take_linear_withdraw_capability.abi
deleted file mode 100644
index aa00d595bc..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/take_linear_withdraw_capability.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v2_to_v3.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v2_to_v3.abi
deleted file mode 100644
index 824b629fe6..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v2_to_v3.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v5_to_v6.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v5_to_v6.abi
deleted file mode 100644
index 4556e0dee1..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v5_to_v6.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v6_to_v7.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v6_to_v7.abi
deleted file mode 100644
index 285bf84a83..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v6_to_v7.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v7_to_v8.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v7_to_v8.abi
deleted file mode 100644
index 6795d80954..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/StdlibUpgradeScripts/upgrade_from_v7_to_v8.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/batch_peer_to_peer.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/batch_peer_to_peer.abi
deleted file mode 100644
index f6a196ffad..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/batch_peer_to_peer.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/batch_peer_to_peer_v2.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/batch_peer_to_peer_v2.abi
deleted file mode 100644
index 77a837ee22..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/batch_peer_to_peer_v2.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer.abi
deleted file mode 100644
index 29e6b70d14..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_batch.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_batch.abi
deleted file mode 100644
index 0e6a00b002..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_batch.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_v2.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_v2.abi
deleted file mode 100644
index b3e5683aa4..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_v2.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_with_metadata.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_with_metadata.abi
deleted file mode 100644
index 1520ef4a53..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_with_metadata.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_with_metadata_v2.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_with_metadata_v2.abi
deleted file mode 100644
index 461b7ede92..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TransferScripts/peer_to_peer_with_metadata_v2.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/execute_withdraw_proposal.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/execute_withdraw_proposal.abi
deleted file mode 100644
index c718e096be..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/execute_withdraw_proposal.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/propose_withdraw.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/propose_withdraw.abi
deleted file mode 100644
index 471d3f1c6e..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/propose_withdraw.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/withdraw_and_split_lt_withdraw_cap.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/withdraw_and_split_lt_withdraw_cap.abi
deleted file mode 100644
index 2aa691183e..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/withdraw_and_split_lt_withdraw_cap.abi and /dev/null differ
diff --git a/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/withdraw_token_with_linear_withdraw_capability.abi b/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/withdraw_token_with_linear_withdraw_capability.abi
deleted file mode 100644
index 7e0f00e17f..0000000000
Binary files a/vm/stdlib/compiled/latest/transaction_scripts/abi/TreasuryScripts/withdraw_token_with_linear_withdraw_capability.abi and /dev/null differ
diff --git a/vm/stdlib/src/lib.rs b/vm/stdlib/src/lib.rs
index 93b7994e39..9fa554186e 100644
--- a/vm/stdlib/src/lib.rs
+++ b/vm/stdlib/src/lib.rs
@@ -10,7 +10,6 @@ use move_bytecode_verifier::{dependencies, verify_module};
use move_compiler::command_line::compiler::construct_pre_compiled_lib_from_compiler;
use move_compiler::FullyCompiledProgram;
use once_cell::sync::Lazy;
-use rayon::prelude::*;
use sha2::{Digest, Sha256};
use starcoin_crypto::hash::PlainCryptoHash;
use starcoin_crypto::HashValue;
@@ -80,7 +79,6 @@ static FRESH_MOVELANG_STDLIB: Lazy