From 4b2d08dfa39327f243f59d1c1459900b272c5391 Mon Sep 17 00:00:00 2001 From: sanlee42 Date: Tue, 1 Aug 2023 09:53:07 +0000 Subject: [PATCH 1/6] EasyGas --- build/StarcoinFramework/BuildInfo.yaml | 6 +- .../abis/Account/accept_token.abi | Bin 52 -> 0 bytes .../abis/Account/accept_token_entry.abi | Bin 58 -> 0 bytes .../create_account_with_initial_amount.abi | Bin 117 -> 0 bytes ...eate_account_with_initial_amount_entry.abi | Bin 111 -> 0 bytes .../create_account_with_initial_amount_v2.abi | Bin 108 -> 0 bytes .../Account/remove_zero_balance_entry.abi | Bin 65 -> 0 bytes .../Account/rotate_authentication_key.abi | Bin 64 -> 0 bytes .../rotate_authentication_key_entry.abi | Bin 70 -> 0 bytes .../Account/set_auto_accept_token_entry.abi | Bin 64 -> 0 bytes .../disable_auto_accept_token.abi | Bin 143 -> 0 bytes .../enable_auto_accept_token.abi | Bin 141 -> 0 bytes .../AccountScripts/remove_zero_balance.abi | Bin 87 -> 0 bytes .../abis/Block/checkpoint_entry.abi | Bin 43 -> 0 bytes .../abis/Block/update_state_root_entry.abi | Bin 59 -> 0 bytes .../abis/Dao/destroy_terminated_proposal.abi | Bin 141 -> 0 bytes .../abis/Dao/queue_proposal_action.abi | Bin 128 -> 0 bytes .../abis/DaoVoteScripts/cast_vote.abi | Bin 105 -> 0 bytes .../abis/DaoVoteScripts/flip_vote.abi | Bin 144 -> 0 bytes .../abis/DaoVoteScripts/revoke_vote.abi | Bin 122 -> 0 bytes .../DaoVoteScripts/revoke_vote_of_power.abi | Bin 139 -> 0 bytes .../abis/DaoVoteScripts/unstake_vote.abi | Bin 92 -> 0 bytes .../abis/DummyToken/mint.abi | Bin 51 -> 0 bytes .../abis/EmptyScripts/empty_script.abi | Bin 46 -> 0 bytes .../abis/Genesis/initialize.abi | Bin 939 -> 0 bytes .../abis/Genesis/initialize_v2.abi | Bin 960 -> 0 bytes .../abis/GenesisNFT/mint.abi | Bin 84 -> 0 bytes .../abis/GenesisNFT/mint_entry.abi | Bin 65 -> 0 bytes .../abis/ModifyDaoConfigProposal/execute.abi | Bin 176 -> 0 bytes .../abis/ModifyDaoConfigProposal/propose.abi | Bin 168 -> 0 bytes .../cancel_upgrade_plan.abi | Bin 137 -> 0 bytes .../execute_module_upgrade_plan_propose.abi | Bin 249 -> 0 bytes .../propose_module_upgrade_v2.abi | Bin 135 -> 0 bytes .../submit_module_upgrade_plan.abi | Bin 184 -> 0 bytes .../submit_upgrade_plan.abi | Bin 241 -> 0 bytes .../update_module_upgrade_strategy.abi | Bin 137 -> 0 bytes ..._module_upgrade_strategy_with_min_time.abi | Bin 253 -> 0 bytes build/StarcoinFramework/abis/NFT/accept.abi | Bin 115 -> 0 bytes .../abis/NFT/accept_entry.abi | Bin 125 -> 0 bytes .../abis/NFT/destroy_empty.abi | Bin 101 -> 0 bytes .../abis/NFT/destroy_empty_entry.abi | Bin 104 -> 0 bytes .../abis/NFT/remove_empty_gallery.abi | Bin 113 -> 0 bytes .../abis/NFT/remove_empty_gallery_entry.abi | Bin 112 -> 0 bytes build/StarcoinFramework/abis/NFT/transfer.abi | Bin 148 -> 0 bytes .../abis/NFT/transfer_entry.abi | Bin 119 -> 0 bytes .../abis/Offer/take_offer.abi | Bin 112 -> 0 bytes .../execute_on_chain_config_proposal.abi | Bin 96 -> 0 bytes .../execute_on_chain_config_proposal_v2.abi | Bin 128 -> 0 bytes .../propose_update_consensus_config.abi | Bin 336 -> 0 bytes .../propose_update_move_language_version.abi | Bin 103 -> 0 bytes .../propose_update_reward_config.abi | Bin 96 -> 0 bytes .../propose_update_txn_publish_option.abi | Bin 130 -> 0 bytes .../propose_update_txn_timeout_config.abi | Bin 105 -> 0 bytes .../propose_update_vm_config.abi | Bin 416 -> 0 bytes .../abis/Oracle/init_data_source.abi | Bin 77 -> 0 bytes .../abis/Oracle/init_data_source_entry.abi | Bin 76 -> 0 bytes .../abis/Oracle/register_oracle.abi | Bin 75 -> 0 bytes .../abis/Oracle/register_oracle_entry.abi | Bin 74 -> 0 bytes .../StarcoinFramework/abis/Oracle/update.abi | Bin 62 -> 0 bytes .../abis/Oracle/update_entry.abi | Bin 61 -> 0 bytes ...t_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2.abi | Bin 100 -> 0 bytes .../take_linear_withdraw_capability.abi | Bin 146 -> 0 bytes .../upgrade_from_v11_to_v12.abi | Bin 65 -> 0 bytes .../upgrade_from_v2_to_v3.abi | Bin 117 -> 0 bytes .../upgrade_from_v5_to_v6.abi | Bin 63 -> 0 bytes .../upgrade_from_v6_to_v7.abi | Bin 63 -> 0 bytes .../upgrade_from_v7_to_v8.abi | Bin 63 -> 0 bytes .../TransferScripts/batch_peer_to_peer.abi | Bin 138 -> 0 bytes .../TransferScripts/batch_peer_to_peer_v2.abi | Bin 121 -> 0 bytes .../abis/TransferScripts/peer_to_peer.abi | Bin 93 -> 0 bytes .../TransferScripts/peer_to_peer_batch.abi | Bin 105 -> 0 bytes .../abis/TransferScripts/peer_to_peer_v2.abi | Bin 78 -> 0 bytes .../peer_to_peer_with_metadata.abi | Bin 118 -> 0 bytes .../peer_to_peer_with_metadata_v2.abi | Bin 103 -> 0 bytes .../execute_withdraw_proposal.abi | Bin 101 -> 0 bytes .../abis/TreasuryScripts/propose_withdraw.abi | Bin 99 -> 0 bytes .../withdraw_and_split_lt_withdraw_cap.abi | Bin 113 -> 0 bytes ..._token_with_linear_withdraw_capability.abi | Bin 91 -> 0 bytes .../StarcoinFramework/bytecode_modules/ACL.mv | Bin 435 -> 465 bytes .../bytecode_modules/Account.mv | Bin 6233 -> 6793 bytes .../bytecode_modules/Authenticator.mv | Bin 801 -> 873 bytes .../StarcoinFramework/bytecode_modules/BCS.mv | Bin 3074 -> 3135 bytes .../bytecode_modules/BlockReward.mv | Bin 1514 -> 1593 bytes .../bytecode_modules/Collection.mv | Bin 814 -> 842 bytes .../bytecode_modules/Collection2.mv | Bin 1860 -> 1924 bytes .../bytecode_modules/Compare.mv | Bin 623 -> 682 bytes .../bytecode_modules/EVMAddress.mv | Bin 400 -> 476 bytes .../bytecode_modules/EasyGasOracle.mv | Bin 0 -> 894 bytes .../bytecode_modules/EasyGasOracleScript.mv | Bin 0 -> 219 bytes .../bytecode_modules/GasSchedule.mv | Bin 8511 -> 8542 bytes .../bytecode_modules/Genesis.mv | Bin 3627 -> 3629 bytes .../GenesisSignerCapability.mv | Bin 454 -> 470 bytes .../bytecode_modules/Math.mv | Bin 688 -> 746 bytes .../bytecode_modules/MerkleNFTDistributor.mv | Bin 1259 -> 1338 bytes .../bytecode_modules/MerkleProof.mv | Bin 322 -> 369 bytes .../StarcoinFramework/bytecode_modules/NFT.mv | Bin 4087 -> 4041 bytes .../bytecode_modules/NFTGallery.mv | Bin 2178 -> 2260 bytes .../bytecode_modules/Option.mv | Bin 1051 -> 1136 bytes .../bytecode_modules/Oracle.mv | Bin 1893 -> 1982 bytes .../bytecode_modules/PriceOracleAggregator.mv | Bin 498 -> 570 bytes .../bytecode_modules/Ring.mv | Bin 1292 -> 1418 bytes .../bytecode_modules/Secp256k1.mv | Bin 604 -> 633 bytes .../bytecode_modules/SimpleMap.mv | Bin 1160 -> 1281 bytes .../bytecode_modules/StarcoinVerifier.mv | Bin 1910 -> 1988 bytes .../bytecode_modules/StdlibUpgradeScripts.mv | Bin 1943 -> 2036 bytes .../bytecode_modules/String.mv | Bin 927 -> 936 bytes .../bytecode_modules/TransactionManager.mv | Bin 1288 -> 1532 bytes .../bytecode_modules/TransferScripts.mv | Bin 719 -> 777 bytes .../bytecode_modules/TypeInfo.mv | Bin 312 -> 341 bytes .../bytecode_modules/U256.mv | Bin 1125 -> 1196 bytes .../bytecode_modules/VMConfig.mv | Bin 3967 -> 4003 bytes .../bytecode_modules/Vector.mv | Bin 1256 -> 1240 bytes build/StarcoinFramework/docs/ACL.md | 205 - build/StarcoinFramework/docs/Account.md | 3464 ----------------- .../StarcoinFramework/docs/AccountScripts.md | 93 - build/StarcoinFramework/docs/Authenticator.md | 448 --- build/StarcoinFramework/docs/BCS.md | 1599 -------- build/StarcoinFramework/docs/Bitwise.md | 179 - build/StarcoinFramework/docs/Block.md | 941 ----- build/StarcoinFramework/docs/BlockReward.md | 397 -- build/StarcoinFramework/docs/ChainId.md | 425 -- build/StarcoinFramework/docs/Collection.md | 430 -- build/StarcoinFramework/docs/Collection2.md | 878 ----- build/StarcoinFramework/docs/Compare.md | 340 -- build/StarcoinFramework/docs/Config.md | 773 ---- .../StarcoinFramework/docs/ConsensusConfig.md | 700 ---- .../docs/ConsensusStrategy.md | 143 - build/StarcoinFramework/docs/CoreAddresses.md | 178 - build/StarcoinFramework/docs/Dao.md | 2330 ----------- .../StarcoinFramework/docs/DaoVoteScripts.md | 197 - build/StarcoinFramework/docs/Debug.md | 72 - build/StarcoinFramework/docs/DummyToken.md | 46 - build/StarcoinFramework/docs/EmptyScripts.md | 48 - build/StarcoinFramework/docs/Epoch.md | 1041 ----- build/StarcoinFramework/docs/Errors.md | 623 --- build/StarcoinFramework/docs/Event.md | 300 -- build/StarcoinFramework/docs/EventUtil.md | 175 - build/StarcoinFramework/docs/FixedPoint32.md | 439 --- build/StarcoinFramework/docs/FromBCS.md | 205 - build/StarcoinFramework/docs/GasSchedule.md | 513 --- build/StarcoinFramework/docs/Genesis.md | 804 ---- build/StarcoinFramework/docs/GenesisNFT.md | 49 - .../docs/GenesisSignerCapability.md | 114 - build/StarcoinFramework/docs/Hash.md | 116 - .../StarcoinFramework/docs/LanguageVersion.md | 114 - build/StarcoinFramework/docs/Math.md | 377 -- build/StarcoinFramework/docs/MerkleNFT.md | 330 -- .../StarcoinFramework/docs/MintDaoProposal.md | 258 -- build/StarcoinFramework/docs/MintScripts.md | 10 - .../docs/ModifyDaoConfigProposal.md | 300 -- .../docs/ModuleUpgradeScripts.md | 314 -- build/StarcoinFramework/docs/NFT.md | 104 - build/StarcoinFramework/docs/Offer.md | 305 -- .../docs/OnChainConfigDao.md | 257 -- .../docs/OnChainConfigScripts.md | 378 -- build/StarcoinFramework/docs/Option.md | 787 ---- build/StarcoinFramework/docs/Oracle.md | 88 - .../docs/PackageTxnManager.md | 1454 ------- build/StarcoinFramework/docs/README.md | 108 - build/StarcoinFramework/docs/RewardConfig.md | 240 -- build/StarcoinFramework/docs/Ring.md | 426 -- build/StarcoinFramework/docs/SIPs.md | 11 - build/StarcoinFramework/docs/STC.md | 403 -- build/StarcoinFramework/docs/Secp256k1.md | 296 -- .../docs/SharedEd25519PublicKey.md | 309 -- build/StarcoinFramework/docs/Signature.md | 154 - .../StarcoinFramework/docs/SignedInteger64.md | 352 -- build/StarcoinFramework/docs/Signer.md | 94 - build/StarcoinFramework/docs/SimpleMap.md | 543 --- .../docs/StarcoinVerifier.md | 715 ---- .../docs/StdlibUpgradeScripts.md | 359 -- build/StarcoinFramework/docs/String.md | 530 --- build/StarcoinFramework/docs/Table.md | 831 ---- build/StarcoinFramework/docs/Timestamp.md | 461 --- build/StarcoinFramework/docs/Token.md | 1845 --------- .../StarcoinFramework/docs/TransactionFee.md | 245 -- .../docs/TransactionManager.md | 426 -- .../docs/TransactionPublishOption.md | 348 -- .../docs/TransactionTimeout.md | 108 - .../docs/TransactionTimeoutConfig.md | 235 -- .../StarcoinFramework/docs/TransferScripts.md | 252 -- build/StarcoinFramework/docs/Treasury.md | 1230 ------ .../StarcoinFramework/docs/TreasuryScripts.md | 204 - .../docs/TreasuryWithdrawDaoProposal.md | 320 -- build/StarcoinFramework/docs/TypeInfo.md | 192 - build/StarcoinFramework/docs/U256.md | 946 ----- .../docs/UpgradeModuleDaoProposal.md | 350 -- build/StarcoinFramework/docs/VMConfig.md | 738 ---- build/StarcoinFramework/docs/Vector.md | 861 ---- build/StarcoinFramework/docs/Version.md | 146 - build/StarcoinFramework/docs/YieldFarming.md | 886 ----- .../StarcoinFramework/docs/YieldFarmingV2.md | 1429 ------- .../source_maps/Account.mvsm | Bin 46439 -> 51351 bytes .../source_maps/EasyGasOracle.mvsm | Bin 0 -> 4946 bytes .../source_maps/EasyGasOracleScript.mvsm | Bin 0 -> 1082 bytes .../source_maps/GenesisSignerCapability.mvsm | Bin 1176 -> 1176 bytes .../source_maps/StdlibUpgradeScripts.mvsm | Bin 6099 -> 6351 bytes .../source_maps/TransactionManager.mvsm | Bin 8503 -> 9981 bytes integration-tests/account/basic.exp | 14 +- .../account/delegate_account.exp | 4 +- .../account/txn_prologue_and_epilogue.exp | 66 +- .../account/txn_prologue_and_epilogue.move | 130 +- .../account/withdraw_capability.exp | 14 +- .../account/withdraw_zero_token.exp | 2 +- .../authenticator/authenticator.exp | 18 +- integration-tests/block/block_checkpoints.exp | 8 +- integration-tests/block/checkpoints_test.exp | 8 +- integration-tests/block_reward/basic.exp | 18 +- .../collection2/collection_add_by_other.exp | 8 +- .../collection2/collection_by_owner.exp | 14 +- .../collection2/collection_mut_by_other.exp | 10 +- integration-tests/compare/compare.exp | 2 +- integration-tests/dao/test_dao_config.exp | 16 +- integration-tests/dao/test_dao_failure.exp | 32 +- integration-tests/dao/test_dao_propose.exp | 18 +- .../dao/test_mint_dao_proposal.exp | 10 +- integration-tests/debug/debug.exp | 2 +- .../epoch/adjust_epoch_block_time_max.exp | 2 +- .../epoch/adjust_epoch_block_time_min.exp | 2 +- .../epoch/adjust_epoch_failed.exp | 2 +- integration-tests/epoch/adjust_gas_limit.exp | 2 +- .../incubator/SortedLinkedList.exp | 32 +- integration-tests/list/linked_list.exp | 10 +- integration-tests/math/sum_avg.exp | 2 +- integration-tests/move/option.exp | 2 +- integration-tests/natives/signature.exp | 8 +- integration-tests/nft/identifier_nft.exp | 10 +- integration-tests/nft/nft_boxminer.exp | 4 +- integration-tests/nft/nft_card.exp | 10 +- integration-tests/nft/nft_metadata.exp | 10 +- integration-tests/nft/test_gallery.exp | 26 +- integration-tests/nft/test_genesis_nft.exp | 2 +- integration-tests/nft/test_nft.exp | 8 +- integration-tests/offer/offer.exp | 2 +- integration-tests/on_chain_config/config.exp | 14 +- .../test_onchain_config_dao.exp | 8 +- integration-tests/oracle/EasyGas.exp | 13 + integration-tests/oracle/EasyGas.move | 33 + integration-tests/oracle/oracle.exp | 4 +- .../cancel_upgrade_plan.exp | 8 +- .../package_txn_manager/only_new_module.exp | 2 +- .../override_upgrade_plan.exp | 10 +- .../package_txn_manager.exp | 20 +- integration-tests/ring/rind_set.exp | 2 +- integration-tests/ring/ring_add.exp | 2 +- integration-tests/ring/ring_borrow.exp | 2 +- integration-tests/ring/ring_borrow_mut.exp | 2 +- integration-tests/ring/ring_index_of.exp | 8 +- .../shared_ed25519_public_key/shared_key.exp | 2 +- .../signer_capability/create_signer.exp | 2 +- .../signer_capability/destroy_signer.exp | 2 +- integration-tests/token/burn_and_destroy.exp | 4 +- .../token/create_account_with_token.exp | 4 +- integration-tests/token/mint_stc.exp | 2 +- integration-tests/token/my_token.exp | 4 +- .../token/transfer_then_abort.exp | 2 +- .../transaction_fee/distribute_txn_fee.exp | 2 +- .../transaction_scripts/create_account.exp | 2 +- .../execute_modify_dao_config_proposal.exp | 6 +- .../execute_on_chain_config_proposal.exp | 6 +- .../transaction_scripts/module_upgrade.exp | 10 +- .../transaction_scripts/peer_to_peer.exp | 4 +- .../peer_to_peer_with_metadata.exp | 4 +- integration-tests/u256/test_u256_gas.exp | 16 +- .../upgrade_module_dao_proposal/basic.exp | 10 +- integration-tests/vector/big_vector.exp | 16 +- integration-tests/vector/contains.exp | 2 +- integration-tests/vector/index_of.exp | 2 +- integration-tests/vector/remove.exp | 4 +- integration-tests/vector/reverse.exp | 4 +- integration-tests/vector/spawn_from.exp | 4 +- integration-tests/vector/split.exp | 4 +- integration-tests/vector/swap_remove.exp | 2 +- integration-tests/version/basic.exp | 2 +- integration-tests/yield_farming/basic.exp | 2 +- .../yield_farming/cap_local_store.exp | 2 +- sources/Account.move | 184 +- sources/EasyGas.move | 88 + sources/GenesisSignerCapability.move | 7 +- sources/StdlibUpgradeScripts.move | 7 +- sources/TransactionManager.move | 24 +- 281 files changed, 733 insertions(+), 40299 deletions(-) delete mode 100644 build/StarcoinFramework/abis/Account/accept_token.abi delete mode 100644 build/StarcoinFramework/abis/Account/accept_token_entry.abi delete mode 100644 build/StarcoinFramework/abis/Account/create_account_with_initial_amount.abi delete mode 100644 build/StarcoinFramework/abis/Account/create_account_with_initial_amount_entry.abi delete mode 100644 build/StarcoinFramework/abis/Account/create_account_with_initial_amount_v2.abi delete mode 100644 build/StarcoinFramework/abis/Account/remove_zero_balance_entry.abi delete mode 100644 build/StarcoinFramework/abis/Account/rotate_authentication_key.abi delete mode 100644 build/StarcoinFramework/abis/Account/rotate_authentication_key_entry.abi delete mode 100644 build/StarcoinFramework/abis/Account/set_auto_accept_token_entry.abi delete mode 100644 build/StarcoinFramework/abis/AccountScripts/disable_auto_accept_token.abi delete mode 100644 build/StarcoinFramework/abis/AccountScripts/enable_auto_accept_token.abi delete mode 100644 build/StarcoinFramework/abis/AccountScripts/remove_zero_balance.abi delete mode 100644 build/StarcoinFramework/abis/Block/checkpoint_entry.abi delete mode 100644 build/StarcoinFramework/abis/Block/update_state_root_entry.abi delete mode 100644 build/StarcoinFramework/abis/Dao/destroy_terminated_proposal.abi delete mode 100644 build/StarcoinFramework/abis/Dao/queue_proposal_action.abi delete mode 100644 build/StarcoinFramework/abis/DaoVoteScripts/cast_vote.abi delete mode 100644 build/StarcoinFramework/abis/DaoVoteScripts/flip_vote.abi delete mode 100644 build/StarcoinFramework/abis/DaoVoteScripts/revoke_vote.abi delete mode 100644 build/StarcoinFramework/abis/DaoVoteScripts/revoke_vote_of_power.abi delete mode 100644 build/StarcoinFramework/abis/DaoVoteScripts/unstake_vote.abi delete mode 100644 build/StarcoinFramework/abis/DummyToken/mint.abi delete mode 100644 build/StarcoinFramework/abis/EmptyScripts/empty_script.abi delete mode 100644 build/StarcoinFramework/abis/Genesis/initialize.abi delete mode 100644 build/StarcoinFramework/abis/Genesis/initialize_v2.abi delete mode 100644 build/StarcoinFramework/abis/GenesisNFT/mint.abi delete mode 100644 build/StarcoinFramework/abis/GenesisNFT/mint_entry.abi delete mode 100644 build/StarcoinFramework/abis/ModifyDaoConfigProposal/execute.abi delete mode 100644 build/StarcoinFramework/abis/ModifyDaoConfigProposal/propose.abi delete mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/cancel_upgrade_plan.abi delete mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/execute_module_upgrade_plan_propose.abi delete mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/propose_module_upgrade_v2.abi delete mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/submit_module_upgrade_plan.abi delete mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/submit_upgrade_plan.abi delete mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/update_module_upgrade_strategy.abi delete mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/update_module_upgrade_strategy_with_min_time.abi delete mode 100644 build/StarcoinFramework/abis/NFT/accept.abi delete mode 100644 build/StarcoinFramework/abis/NFT/accept_entry.abi delete mode 100644 build/StarcoinFramework/abis/NFT/destroy_empty.abi delete mode 100644 build/StarcoinFramework/abis/NFT/destroy_empty_entry.abi delete mode 100644 build/StarcoinFramework/abis/NFT/remove_empty_gallery.abi delete mode 100644 build/StarcoinFramework/abis/NFT/remove_empty_gallery_entry.abi delete mode 100644 build/StarcoinFramework/abis/NFT/transfer.abi delete mode 100644 build/StarcoinFramework/abis/NFT/transfer_entry.abi delete mode 100644 build/StarcoinFramework/abis/Offer/take_offer.abi delete mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal.abi delete mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal_v2.abi delete mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_consensus_config.abi delete mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_move_language_version.abi delete mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_reward_config.abi delete mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_txn_publish_option.abi delete mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_txn_timeout_config.abi delete mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_vm_config.abi delete mode 100644 build/StarcoinFramework/abis/Oracle/init_data_source.abi delete mode 100644 build/StarcoinFramework/abis/Oracle/init_data_source_entry.abi delete mode 100644 build/StarcoinFramework/abis/Oracle/register_oracle.abi delete mode 100644 build/StarcoinFramework/abis/Oracle/register_oracle_entry.abi delete mode 100644 build/StarcoinFramework/abis/Oracle/update.abi delete mode 100644 build/StarcoinFramework/abis/Oracle/update_entry.abi delete mode 100644 build/StarcoinFramework/abis/PackageTxnManager/convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2.abi delete mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/take_linear_withdraw_capability.abi delete mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v11_to_v12.abi delete mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v2_to_v3.abi delete mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v5_to_v6.abi delete mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v6_to_v7.abi delete mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v7_to_v8.abi delete mode 100644 build/StarcoinFramework/abis/TransferScripts/batch_peer_to_peer.abi delete mode 100644 build/StarcoinFramework/abis/TransferScripts/batch_peer_to_peer_v2.abi delete mode 100644 build/StarcoinFramework/abis/TransferScripts/peer_to_peer.abi delete mode 100644 build/StarcoinFramework/abis/TransferScripts/peer_to_peer_batch.abi delete mode 100644 build/StarcoinFramework/abis/TransferScripts/peer_to_peer_v2.abi delete mode 100644 build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata.abi delete mode 100644 build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata_v2.abi delete mode 100644 build/StarcoinFramework/abis/TreasuryScripts/execute_withdraw_proposal.abi delete mode 100644 build/StarcoinFramework/abis/TreasuryScripts/propose_withdraw.abi delete mode 100644 build/StarcoinFramework/abis/TreasuryScripts/withdraw_and_split_lt_withdraw_cap.abi delete mode 100644 build/StarcoinFramework/abis/TreasuryScripts/withdraw_token_with_linear_withdraw_capability.abi create mode 100644 build/StarcoinFramework/bytecode_modules/EasyGasOracle.mv create mode 100644 build/StarcoinFramework/bytecode_modules/EasyGasOracleScript.mv delete mode 100644 build/StarcoinFramework/docs/ACL.md delete mode 100644 build/StarcoinFramework/docs/Account.md delete mode 100644 build/StarcoinFramework/docs/AccountScripts.md delete mode 100644 build/StarcoinFramework/docs/Authenticator.md delete mode 100644 build/StarcoinFramework/docs/BCS.md delete mode 100644 build/StarcoinFramework/docs/Bitwise.md delete mode 100644 build/StarcoinFramework/docs/Block.md delete mode 100644 build/StarcoinFramework/docs/BlockReward.md delete mode 100644 build/StarcoinFramework/docs/ChainId.md delete mode 100644 build/StarcoinFramework/docs/Collection.md delete mode 100644 build/StarcoinFramework/docs/Collection2.md delete mode 100644 build/StarcoinFramework/docs/Compare.md delete mode 100644 build/StarcoinFramework/docs/Config.md delete mode 100644 build/StarcoinFramework/docs/ConsensusConfig.md delete mode 100644 build/StarcoinFramework/docs/ConsensusStrategy.md delete mode 100644 build/StarcoinFramework/docs/CoreAddresses.md delete mode 100644 build/StarcoinFramework/docs/Dao.md delete mode 100644 build/StarcoinFramework/docs/DaoVoteScripts.md delete mode 100644 build/StarcoinFramework/docs/Debug.md delete mode 100644 build/StarcoinFramework/docs/DummyToken.md delete mode 100644 build/StarcoinFramework/docs/EmptyScripts.md delete mode 100644 build/StarcoinFramework/docs/Epoch.md delete mode 100644 build/StarcoinFramework/docs/Errors.md delete mode 100644 build/StarcoinFramework/docs/Event.md delete mode 100644 build/StarcoinFramework/docs/EventUtil.md delete mode 100644 build/StarcoinFramework/docs/FixedPoint32.md delete mode 100644 build/StarcoinFramework/docs/FromBCS.md delete mode 100644 build/StarcoinFramework/docs/GasSchedule.md delete mode 100644 build/StarcoinFramework/docs/Genesis.md delete mode 100644 build/StarcoinFramework/docs/GenesisNFT.md delete mode 100644 build/StarcoinFramework/docs/GenesisSignerCapability.md delete mode 100644 build/StarcoinFramework/docs/Hash.md delete mode 100644 build/StarcoinFramework/docs/LanguageVersion.md delete mode 100644 build/StarcoinFramework/docs/Math.md delete mode 100644 build/StarcoinFramework/docs/MerkleNFT.md delete mode 100644 build/StarcoinFramework/docs/MintDaoProposal.md delete mode 100644 build/StarcoinFramework/docs/MintScripts.md delete mode 100644 build/StarcoinFramework/docs/ModifyDaoConfigProposal.md delete mode 100644 build/StarcoinFramework/docs/ModuleUpgradeScripts.md delete mode 100644 build/StarcoinFramework/docs/NFT.md delete mode 100644 build/StarcoinFramework/docs/Offer.md delete mode 100644 build/StarcoinFramework/docs/OnChainConfigDao.md delete mode 100644 build/StarcoinFramework/docs/OnChainConfigScripts.md delete mode 100644 build/StarcoinFramework/docs/Option.md delete mode 100644 build/StarcoinFramework/docs/Oracle.md delete mode 100644 build/StarcoinFramework/docs/PackageTxnManager.md delete mode 100644 build/StarcoinFramework/docs/README.md delete mode 100644 build/StarcoinFramework/docs/RewardConfig.md delete mode 100644 build/StarcoinFramework/docs/Ring.md delete mode 100644 build/StarcoinFramework/docs/SIPs.md delete mode 100644 build/StarcoinFramework/docs/STC.md delete mode 100644 build/StarcoinFramework/docs/Secp256k1.md delete mode 100644 build/StarcoinFramework/docs/SharedEd25519PublicKey.md delete mode 100644 build/StarcoinFramework/docs/Signature.md delete mode 100644 build/StarcoinFramework/docs/SignedInteger64.md delete mode 100644 build/StarcoinFramework/docs/Signer.md delete mode 100644 build/StarcoinFramework/docs/SimpleMap.md delete mode 100644 build/StarcoinFramework/docs/StarcoinVerifier.md delete mode 100644 build/StarcoinFramework/docs/StdlibUpgradeScripts.md delete mode 100644 build/StarcoinFramework/docs/String.md delete mode 100644 build/StarcoinFramework/docs/Table.md delete mode 100644 build/StarcoinFramework/docs/Timestamp.md delete mode 100644 build/StarcoinFramework/docs/Token.md delete mode 100644 build/StarcoinFramework/docs/TransactionFee.md delete mode 100644 build/StarcoinFramework/docs/TransactionManager.md delete mode 100644 build/StarcoinFramework/docs/TransactionPublishOption.md delete mode 100644 build/StarcoinFramework/docs/TransactionTimeout.md delete mode 100644 build/StarcoinFramework/docs/TransactionTimeoutConfig.md delete mode 100644 build/StarcoinFramework/docs/TransferScripts.md delete mode 100644 build/StarcoinFramework/docs/Treasury.md delete mode 100644 build/StarcoinFramework/docs/TreasuryScripts.md delete mode 100644 build/StarcoinFramework/docs/TreasuryWithdrawDaoProposal.md delete mode 100644 build/StarcoinFramework/docs/TypeInfo.md delete mode 100644 build/StarcoinFramework/docs/U256.md delete mode 100644 build/StarcoinFramework/docs/UpgradeModuleDaoProposal.md delete mode 100644 build/StarcoinFramework/docs/VMConfig.md delete mode 100644 build/StarcoinFramework/docs/Vector.md delete mode 100644 build/StarcoinFramework/docs/Version.md delete mode 100644 build/StarcoinFramework/docs/YieldFarming.md delete mode 100644 build/StarcoinFramework/docs/YieldFarmingV2.md create mode 100644 build/StarcoinFramework/source_maps/EasyGasOracle.mvsm create mode 100644 build/StarcoinFramework/source_maps/EasyGasOracleScript.mvsm create mode 100644 integration-tests/oracle/EasyGas.exp create mode 100644 integration-tests/oracle/EasyGas.move create mode 100644 sources/EasyGas.move diff --git a/build/StarcoinFramework/BuildInfo.yaml b/build/StarcoinFramework/BuildInfo.yaml index 516531b1..da429949 100644 --- a/build/StarcoinFramework/BuildInfo.yaml +++ b/build/StarcoinFramework/BuildInfo.yaml @@ -5,12 +5,12 @@ compiled_package_info: StarcoinAssociation: "0x0000000000000000000000000a550c18" StarcoinFramework: "0x00000000000000000000000000000001" VMReserved: "0x00000000000000000000000000000000" - source_digest: 88545469FF3E16035E05352124B98D1C4408DD2CFDC741EEE1C13000F9EBB4E6 + source_digest: 637209FA52731CFA47D4139FE4B6A885FAF533D29D4582C33D7B099E4400275D build_flags: dev_mode: false test_mode: false - generate_docs: true - generate_abis: true + generate_docs: false + generate_abis: false install_dir: ~ force_recompilation: true additional_named_addresses: {} diff --git a/build/StarcoinFramework/abis/Account/accept_token.abi b/build/StarcoinFramework/abis/Account/accept_token.abi deleted file mode 100644 index 9d200103bba4cab95e514b53ebb285d0c755d619..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 52 rcmZSNNlZ>oEhvdE$Z_oEUXM5 diff --git a/build/StarcoinFramework/abis/Account/accept_token_entry.abi b/build/StarcoinFramework/abis/Account/accept_token_entry.abi deleted file mode 100644 index 2b482dca062b2318b5715c6fbd3be6f34420187e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 58 wcmZP+N=!~pEhvdE$tTo6?yl?AB`0Jb0ww*UYD diff --git a/build/StarcoinFramework/abis/Account/create_account_with_initial_amount.abi b/build/StarcoinFramework/abis/Account/create_account_with_initial_amount.abi deleted file mode 100644 index 3a0f339cc353d4570b0cde92a85dbb530355c5fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 117 zcmZQnN-j!GEJ=+|Ois=(%`1s7&n(G^&&21c%u{Or`c n_>#(kRA%0^qSWGy_{5YHAYIJD8J}1RG$}i^l8uoM)jVbZNYf;R diff --git a/build/StarcoinFramework/abis/Account/create_account_with_initial_amount_entry.abi b/build/StarcoinFramework/abis/Account/create_account_with_initial_amount_entry.abi deleted file mode 100644 index 85e0e210662cfb028ed70d85cd0bf586e27de61b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 111 zcmZS7NG?iEEJ=+|Ois=(%`1s7&n(G^&&b8nw4&7FjQGTq6d+y9!iQ=SGXTNfBT@hW diff --git a/build/StarcoinFramework/abis/Account/create_account_with_initial_amount_v2.abi b/build/StarcoinFramework/abis/Account/create_account_with_initial_amount_v2.abi deleted file mode 100644 index 4c1f45295a18a8131e201e656fe1455d6ab3bb48..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 108 zcmZQnO)g4JEJ=+|Ois=(%`1s7&n(G^&&FKOw~c diff --git a/build/StarcoinFramework/abis/Account/remove_zero_balance_entry.abi b/build/StarcoinFramework/abis/Account/remove_zero_balance_entry.abi deleted file mode 100644 index fbf4971e07f1b4f09419d14af5065dc92ff9ac6f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 65 zcmZRSEK1GIFH4QDN-fHdPfE;5%u7yod$@!&uB@B#QCHdK@dGRHc H1*r@GXD1P$ diff --git a/build/StarcoinFramework/abis/Account/rotate_authentication_key.abi b/build/StarcoinFramework/abis/Account/rotate_authentication_key.abi deleted file mode 100644 index d69bd3711090057f9356eb8be41ea954ddfce013..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 64 zcmZRSEXprQEJ=+|EG@}M%`3@FPAtjH&x_Aatzod$@!&uB@7IV?0Ko>ASG;! E08^3>X8-^I diff --git a/build/StarcoinFramework/abis/Account/rotate_authentication_key_entry.abi b/build/StarcoinFramework/abis/Account/rotate_authentication_key_entry.abi deleted file mode 100644 index 81a17ade1bde1b646230c12657146299bc2584b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 70 zcmZRSFUl`TEJ=+|EG@}M%`3@FPAtjH&x_Aat&9h9iz*pV0VBI(a&mrYUI_yOBYR$I JIY=QJBLMs_68-=H diff --git a/build/StarcoinFramework/abis/Account/set_auto_accept_token_entry.abi b/build/StarcoinFramework/abis/Account/set_auto_accept_token_entry.abi deleted file mode 100644 index 9b5dab255076407f3479733b0c47c4deac06427f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 64 zcmZRSE>10pPb@9Tk55caPAw>jFUikN&5KXXD=DgEKn0BKj>*aSrFkU`42*24d5K9m GsSE&O@erf{ diff --git a/build/StarcoinFramework/abis/AccountScripts/disable_auto_accept_token.abi b/build/StarcoinFramework/abis/AccountScripts/disable_auto_accept_token.abi deleted file mode 100644 index 3661e68024d18bfd36fc740cc47c41d61d85495b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 143 zcmY+8F%H5o5Col;f}U1`dw;X+-|t;CVo=qXG3p{dt=-hn3=p)P6s^Rgl#J3rsBCMvZ0dd Jto_0i!U}23Ei#!e?;@$HJtfE8$^%OmaXJm(3R+_NC8nOh%3w8fzTmYHrJGo*ip8Xe1({T1 IZVzVX4*7pAVgLXD diff --git a/build/StarcoinFramework/abis/AccountScripts/remove_zero_balance.abi b/build/StarcoinFramework/abis/AccountScripts/remove_zero_balance.abi deleted file mode 100644 index f0ffaf791dfb308dd7fb43027e6724298f135c24..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 87 zcmZP+E=tYKFH4QDN-fHdPfE;5%u7yXKn09^j>*aSrFkX6$wiq3CB>o&L0~-!AUz6B U5IqWvTqXJ0sd@1wl?AB`03GfbVE_OC diff --git a/build/StarcoinFramework/abis/Block/checkpoint_entry.abi b/build/StarcoinFramework/abis/Block/checkpoint_entry.abi deleted file mode 100644 index 951dc0d50be147f0a28dd610cacc2f651ab344fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 43 kcmZP+NX|%2&MwH$%qxjc%_}LYWIzRstWG)k$=N_b0Pbf9yZ`_I diff --git a/build/StarcoinFramework/abis/Block/update_state_root_entry.abi b/build/StarcoinFramework/abis/Block/update_state_root_entry.abi deleted file mode 100644 index b9e52802f2acbc99f04bca4b766e0c944707f2b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 59 zcmZP+FD*z(EJ=+oE&-86`S~UBsd*(ul?Z~d?f4Ej diff --git a/build/StarcoinFramework/abis/Dao/destroy_terminated_proposal.abi b/build/StarcoinFramework/abis/Dao/destroy_terminated_proposal.abi deleted file mode 100644 index ce2f1889bbeaf26c89e3660d2ffbbc34dce0c104..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 141 zcmY+*!3u*w3kO+tmW@hH5>M^mG;$jwVn9BIf6ea*T<|YgP diff --git a/build/StarcoinFramework/abis/DaoVoteScripts/revoke_vote_of_power.abi b/build/StarcoinFramework/abis/DaoVoteScripts/revoke_vote_of_power.abi deleted file mode 100644 index 23389794941963603744099b20158a509fe01b6b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 139 zcmZP+DM~HN&rXdm%P&cd&rgdl$S+SVVn79qd@hOkVL%1J$wiq3CB+H~5KRij`MIeI zAf3eu`FRS73I#>^1^LB^IZUi2Kr{2$5|c|Z^YfSmAmXV-@rfxZMXANbEZi`a@tG-1 ItYABt0e5mNhX4Qo diff --git a/build/StarcoinFramework/abis/DaoVoteScripts/unstake_vote.abi b/build/StarcoinFramework/abis/DaoVoteScripts/unstake_vote.abi deleted file mode 100644 index 2d215ed5b289f54c3d649a0e8a5be45ebcad09b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 92 zcmZSNDa|V`Nz6`-FUv1UWk3atd@hOkVLS*#g{&4u;?^UR3NQS zF5Z+8?S#hvpuG<0Yw@9%LAwZ@q;6Z3lE^ERk(ofI*uje)x5Yy{%UMCUs*~sd>tc5f zW>$*Q_F|WuG8%%68lnuXj$)^KuR5rVS1+KlOmV0r=>?e-FR9;Fc#TbiDw#OKfUfp~ z*iX^L1a4w3aP#~Yo+WUC;`YRzJ-R}*xAOND_&62Iv8f8dg-4VtajhgUXfcXgin-Z# zEbd7K>?25H{GjX2(fT^E7k#P>Qira+gi3ULEvd0xDa%5w#pJ2< GDT=@P_gq8( diff --git a/build/StarcoinFramework/abis/Genesis/initialize_v2.abi b/build/StarcoinFramework/abis/Genesis/initialize_v2.abi deleted file mode 100644 index 3c0fe67b2c2780b6544131d0940a2aa7839cede3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 960 zcmaJ=+iu%142@MFE3mdp)+Alf^(nQMMDfMK(Ve&>_Wh zct{oZ=#Wqv{G;LYWA*kcKK#^9M~ti0_lHQ8!4gh7MD$MF1>MU~L8Xlx#D+Xc1CbO+ z>yx9K$1Z5F==2iY5!w-@|Dc@?=qvHDlR-OzR>pQ+>|~5yp(N%8nW%+VJ*1(qe*Oa=T!@(@#+;+)-DdEjCw{!#dGS{1zurY zqe_Mb=+RZa7yB_f+rmvu1#Vv6!;=I~P~4u_vqx8`_E!GB0w2d>IW|^_aN!ZVg}6pW zFldp)ZKT|6GZYU|1?&iS%qH*o!We24jn^xrBD;_*zn<*-^DRC$5W6j_p73 zKrhI1V|>YTx7zwJOkxJMR{2Qc+dqPRz;ntmH_rlHloMGNo_Hgp_+s*S-UL-5U)SPk zRL4J5kn=|im{mNpFKCkmmu$)Y`+AH|^$wY;3#hnbj-83bA)9#xf64e#TFg%*&x)y{ zcsdtgH~96ic{R7-gV9H<6R`a~29@sI((CzeG8nFS@qKF(l`3dyBK zMX7lu3Qz+SKnCb2lw_nTBowFSrKA=mDCCwFmndW;mH~yJW&{8gIVTn*CS~SimQ*I_ HF)#oCI#?`y diff --git a/build/StarcoinFramework/abis/ModuleUpgradeScripts/execute_module_upgrade_plan_propose.abi b/build/StarcoinFramework/abis/ModuleUpgradeScripts/execute_module_upgrade_plan_propose.abi deleted file mode 100644 index 0f59d6f0975549ee781be2c645f639e027d95ddb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 249 zcmZvW!3x4K42JE{lNS#@K)~zpEj)UXolDomS=`#vq~Kn_=XTm62nPO3`11Wx2YQgr zLV60AN76YC$sp-C8n0stF)*!uNA1rawkznxCKrXD>QqcnOi)emHbFH(KLh7}a`KOA zL2mR#r_2I9kq0v*B5c8UTrvkwU>9fod^vIq*X*sh;E!q};ZDBU)ykv|Vj|}CwrtF( G9X2mP)mEYa diff --git a/build/StarcoinFramework/abis/ModuleUpgradeScripts/propose_module_upgrade_v2.abi b/build/StarcoinFramework/abis/ModuleUpgradeScripts/propose_module_upgrade_v2.abi deleted file mode 100644 index a949b2605f38ed346a7270ad9ac26a181cf615b5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 135 zcmY+*F%E)25Jur$0&0k{vhf<;!^&81COf}Cz@5nq5WT&L+W6}4#gm$-IMPFSnUEIk zj2LM>hyUX7@)5T$xMmx4_7Iy{MwI68`-$1$UhkFiNF7p7-f!Y|h4~<*YVkx)jEP>= K4&^SE!QlH9BYDpOVmEvqQX=Z d!ZzM`t~!S0X!40atw|eE$-DXB#X>ct8W;}oFADZq?VD9Hz^f|{Mcz{mk(GXenAIW2Vn diff --git a/build/StarcoinFramework/abis/ModuleUpgradeScripts/update_module_upgrade_strategy_with_min_time.abi b/build/StarcoinFramework/abis/ModuleUpgradeScripts/update_module_upgrade_strategy_with_min_time.abi deleted file mode 100644 index f8e8ad1c3526deda24b77d0ab2352ce33291f1d6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 253 zcmY+-O%8%E5CvdiWn8%O0JC#rxC0BK8>5jD<7z-UfkxVrwn(^xhZgyXVV0BkzULj9 znrDtsYTi_YO}W*(gGQ`1%ozcHA{uo6~2 diff --git a/build/StarcoinFramework/abis/NFT/accept.abi b/build/StarcoinFramework/abis/NFT/accept.abi deleted file mode 100644 index 8e678ebdf6e0745c2c4686c13d2b8b43e6d23750..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 115 zcmZQ%OH58qEhu3?1&o4zZXxc8IXS6CmBGnHnFS@qCJLT;nI#H|3JM4*g|z%41&9G4 iQ5zukO)W{(0dbu2Q!4G4IP%g;;&XvwU`7&9i~#_UKOpJ= diff --git a/build/StarcoinFramework/abis/NFT/accept_entry.abi b/build/StarcoinFramework/abis/NFT/accept_entry.abi deleted file mode 100644 index 6bbac000954dd76372168a442b862c87ca6a029e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 125 zcmZSNNlZ>oEhvdk%_}LYWIzRsTz+mL?uj`$sYR9c3Z8kHB?^fO2qA@%dVP;-`6-ol3TgR83JJxjc`2zy2}~S$X(jQwKm}k%5>NpH05b|C;Q#;t diff --git a/build/StarcoinFramework/abis/NFT/destroy_empty.abi b/build/StarcoinFramework/abis/NFT/destroy_empty.abi deleted file mode 100644 index 456cb71a6b807e3ff1ded3a0ea1ea4c87edc1257..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 101 zcmZSNO-U^-Dax;mPt7eTsboL}j3S;Xsd*)tX_=`-er_Sb$wiq3CB-rdE)YEmU_A;b WYM40k(n{iUQ%e%TjHLXON(KOtS02Ow diff --git a/build/StarcoinFramework/abis/NFT/destroy_empty_entry.abi b/build/StarcoinFramework/abis/NFT/destroy_empty_entry.abi deleted file mode 100644 index 808b5de8e4b340feeb698404fb44aae9cc74d1c0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 104 zcmZP+PDw2;Dax;mPt7eT0g`zoMU@PwfRWcT1t^}GmYG`Q=N6)%-~!R2P?C|V0M@2} XqJW7bFRdg#H?<@Y%t*>lsbl~EAG9CQ diff --git a/build/StarcoinFramework/abis/NFT/remove_empty_gallery.abi b/build/StarcoinFramework/abis/NFT/remove_empty_gallery.abi deleted file mode 100644 index 17b89be0420c216f5af1c708508d8a372ca81587..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 113 zcmZP+DN4=FFH4P2%`GUYj89L@$w@7$WIzRsf_`ox?hvWq~GssI20 diff --git a/build/StarcoinFramework/abis/NFT/remove_empty_gallery_entry.abi b/build/StarcoinFramework/abis/NFT/remove_empty_gallery_entry.abi deleted file mode 100644 index b1fbfa40febd7d2d8712cf8f229861b1b293a1de..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 112 zcmZRSDoV}GFH4P2%`GUYj89L@$w@7$j8DxgDXL^Z1&myNZXxav1u6;I6luA22CXT$clK5Pp0GN>k6l4GZS0Ex% diff --git a/build/StarcoinFramework/abis/NFT/transfer.abi b/build/StarcoinFramework/abis/NFT/transfer.abi deleted file mode 100644 index 492b218d3f592f9a7ec995649a9e69386ebd4e33..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 148 zcmZSNC@D(JD^5!-Vn79qf_`ox?uj`$sYR8+$wiq3CB?1^AyBmnKsg&A_DwBG)B$mv z@>4496v{J8G87UrQxX)?it=+65{gsvQc{Z&6iV_H5{gojQ!~qeJSL93w37H-piVF& Q38<5aDKmwM1Ezun020?NT>t<8 diff --git a/build/StarcoinFramework/abis/NFT/transfer_entry.abi b/build/StarcoinFramework/abis/NFT/transfer_entry.abi deleted file mode 100644 index 8d60d00add5eb81a28d97db17b8cd7fc533c05a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 119 zcmZSND=A9MD^5!-icifeDXL^Z1&myNZXxc8IXS6Cm6{46P^Ah$L4~xU{9J{E;?%s9 t)S?81l6-}PqSWNn%rYR4i6bwqBtAE_BoWL=%1^0eV#-Wm;()1O0RX&3Beehk diff --git a/build/StarcoinFramework/abis/Offer/take_offer.abi b/build/StarcoinFramework/abis/Offer/take_offer.abi deleted file mode 100644 index a9ad0fa82daa7b9d54a2bda74f4d8a74d3198b16..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 112 zcmZSNDoM;vjn7X@OD$qR1&plzAW;*A5TFVLFk2xpFGZoCv_zpKU!gcNJukILy;#9H nKPM+Oxg;|`&jze0HN{SkksWMeY6>GSm=T|tl2VjfT+9LhZ_FU^ diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal.abi deleted file mode 100644 index 884f242133a0dfd3c23c4124f88188cc5eb7697a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 96 zcmZQnNUcasE-guo&(Dib&PdDzlKFXQnd$KbMfnB!#fdo#sDM$#KhGJY&KayMIJqdZ Vprn|Akprr&gpnJjGd?qg2>_4i9Yz2E diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal_v2.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal_v2.abi deleted file mode 100644 index 4fa4c35ae48059c06d426e5a35cd997092d34d6c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 128 zcmZQnPOV5yE-guo&(Dib&PdDzlKFXQnd$KbMfnB!#fdrbWkw9BfKkLh&l#lD8LTom wxhS)sq?mz;t0X@=H7~xTvLKZMYDfu_0K}ZsqWHv=l%mw)Vis<=$(bok03miMaR2}S diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_consensus_config.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_consensus_config.abi deleted file mode 100644 index 543cd101e7edf2498e698efba40846aa2c98e310..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 336 zcmZvX-3r1m3`VzlBjSyqf}r>?K7bcKK&ffA1-rJiDRXb{enh7%SK%a_FUik7IPW6L z5WU;@i&U-fw9+Ij4 z@ZG=zHY#Z8F^nsV(?1@K-2$Lxu|e;kdh5WY4jm@}nu>xT8E$1mR=Y;*YO-_bwR+Cr k!{F*?Lu~vWCbpB9QblQ~CKk)c{j+78ukeW=H5%257l6TdQUCw| diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_move_language_version.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_move_language_version.abi deleted file mode 100644 index 20cc2fa37bdc490fcebd86f4502be32b5f8fb34d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 103 zcmY+*y$ygM5C%}7)YcK)!~rZE;BwJVB*8lZ__w{4g|C0MPg#=|(2*9dpj}T;Wbp@k m(1~1viutqMD8t4<29-7VY0e?lVvK7A*LPfl8#674{J0mKfgk<= diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_reward_config.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_reward_config.abi deleted file mode 100644 index 8a2a050dc4420618735cd693b78e4d566b7c1b55..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 96 zcmZRSDJaS>$S+QfFD*z(EJ=+oN-a+;N{LU-&r8cpXFvsvBK~>K8Ht&B&S2T#KWN+zzOs#QwU6cj-_gVKf4 q6r%7(yZL9Qh5ZqT{ikazl(ib;#?(qs5{8QJnW`JGV}yifxZMNGiy+$o diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_vm_config.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_vm_config.abi deleted file mode 100644 index 2a990bca6b7f541e34e8d467df74325ac39c4ee0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 416 zcmZ`#J8r`;47D|M=+G`kk|OBPv*Z9BdH{l!DTjbW3HqdQPhZJ_fdptZXn2qBL-vOd zeej8(gb6dj#ew!>c>{nC*`PF?phu%sM|&g=z}KGRezJ@v1GnJ;vQ z9B1oCwBX43xImx?<5Cl~Pg#BZLw-lzM&29?c<+|{FbVY4zKKr11WB-RlHgGo8PWQg~*y#!4{-;RrDAB-thZsiGK*HM_Vwd{bo?F hftF8T+VdA^Bx XKt>S*10#O{L@+)vC8a2}xR?b1NjV;M diff --git a/build/StarcoinFramework/abis/StdlibUpgradeScripts/take_linear_withdraw_capability.abi b/build/StarcoinFramework/abis/StdlibUpgradeScripts/take_linear_withdraw_capability.abi deleted file mode 100644 index aa00d595bca5c1539c642797b187a94fb93168bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 146 zcmY++F%H5o3_#KJ4(#{@3~&nOiaBzflvtQJik(*6z7kCQ`RPw*$5)QRHDixEdr2Ml zNZ4>;VgH2xrqk?6czLvE$CPL4+}!SfW=f3CS^qj3U7$DLI)*p%Asf$wiq3CB-TV5K#rF o5emg%aRrb`3S~wLCHV?KlNbd`@=FqP;)_d?;}di9OY=&Y0np4ODF6Tf diff --git a/build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v5_to_v6.abi b/build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v5_to_v6.abi deleted file mode 100644 index 4556e0dee177ee7b6fc436f0300a236dbec1203e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 63 zcmZP+EiFhdN=!+OPb)m!JNQDcm>@LWBC#(CShi}$nCAcP5r2(*boVX*)>WLRLi!qGy JDQk9%!xsmXDwzNP diff --git a/build/StarcoinFramework/abis/TransferScripts/batch_peer_to_peer_v2.abi b/build/StarcoinFramework/abis/TransferScripts/batch_peer_to_peer_v2.abi deleted file mode 100644 index 77a837ee22e0c1774f99ac5ed3c6804d7a0d7b86..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 121 zcmZP+O-d|D&WJBaO)ZKq$%oKoMhvKckw2s;F|Rl+wJ12bD6^oXSV6%Fq)nj&Dy&eF vpPiZqBo*>YGE$3*^%%LpBJm}a1*uHz1&NiZsj0dk=a$SpYZe-i diff --git a/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_batch.abi b/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_batch.abi deleted file mode 100644 index 0e6a00b00275b6a7d0b4a825ad8e90095b6f20e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 105 zcmY+2!3uyN5Cs*XqD#@Q)qUCIg(0cvdhqXyIyILWMlT7-B#~b4EY_(%dfGCFav-lZ jpGk_+qePED(h|%-i5q~@>G@0IDvmtbvwGqy)*$8v1hgLr diff --git a/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_v2.abi b/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_v2.abi deleted file mode 100644 index b3e5683aa44a9e5b325dbb3dd40571434908cc07..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 78 zcmZSNFGx)-iZ98J2h(Ln45)ySKcpxzuQ)BWC^)$&v!JAyfsv~uKRY!qzNE4sm5H?= Ru`)H4g)K2RzcjCe82}9b6;}WN diff --git a/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata.abi b/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata.abi deleted file mode 100644 index 1520ef4a5321644322edccb872cb99758a3116e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 118 zcmY++I|_g>5Jgc3HHb}mx263s=o3ZqA&y9PuLLZ-&FL-;5lF0oi}$V@JE$z8QvD-4 qCGqEqG|p*{dREkHIN(`xMAJseKx4Vca=oVm*^m(zF0Xa>eGNS!Fe9n} diff --git a/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata_v2.abi b/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata_v2.abi deleted file mode 100644 index 461b7ede9224195aa646f979d7d4ba2ee548cd4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 103 zcmZRSEl5o*iZ98J2h-)5B^mL#sU?Xii6x2gWkw9BfRR6>C^4@%Ewv~(xhS)sq?mz` kt0X@=H7~xTvLKb2wIH!FHI;=eF*m<7uY{QcW)K@A05a$vaR2}S diff --git a/build/StarcoinFramework/abis/TreasuryScripts/execute_withdraw_proposal.abi b/build/StarcoinFramework/abis/TreasuryScripts/execute_withdraw_proposal.abi deleted file mode 100644 index c718e096beaa6aa06e261b96d12b0fcf14ba2a49..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 101 zcmZRSOsz;wE-guoFV8H=NGVDzk1r_7FUT)W%wa$UjQk-*sfop hCHdK@dGRGo0uVi^Me&I#DMhKp#Vp(~Q{ppIm;eMIA9nx% diff --git a/build/StarcoinFramework/abis/TreasuryScripts/propose_withdraw.abi b/build/StarcoinFramework/abis/TreasuryScripts/propose_withdraw.abi deleted file mode 100644 index 471d3f1c6edbe320d07b58cdd7f4869564b55421..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 99 zcmY+x%L;%X5CzbzuxL~NR(lb>kn|WC$IQQP-8pKBOpy{y39@^(rTJ6y#;_@KT^)xg isZoQ_f!jzwG91DK?zO!r-_q#_4&>VjFP!l>ZEZhEtQ_J1 diff --git a/build/StarcoinFramework/abis/TreasuryScripts/withdraw_and_split_lt_withdraw_cap.abi b/build/StarcoinFramework/abis/TreasuryScripts/withdraw_and_split_lt_withdraw_cap.abi deleted file mode 100644 index 2aa691183e004ca09cf0fe6558fe85e5454fcfeb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 113 zcmY+&!45z$3;<9=I5_wRzr?+1)``WeOIs0t&q?APpPQ~|8wp;3nLta52Fc)CkEQx^ o<01j|lza9Pi)rP0<2_`sW>{GOi6p4D9UgqskE*lm%F4h1m_AbU$j`xfLZ2uWWxF$2P@yuju zVdR}VQO`)8laY~uiH(s9NOH6D07-UUK1K#sHg+}+HcmFKiTR3L>|C4-oD7UWa$2WhzF!M08aIx}p XGcd9<3bLtl1Esi`Em#skE&~=THdY6H_WWp$Q;Y&^w-`mZ-Z8TAd|~Wi zNNWOfGDbix_pR9YE%Rfe-@|3nK#q srzjT#KLZ~l50f4@lLaFWGYc0hKQ{v-JEI_*IyX>?o7sYikqM{;02rndH~;_u diff --git a/build/StarcoinFramework/bytecode_modules/Account.mv b/build/StarcoinFramework/bytecode_modules/Account.mv index f904edd0771aa66325a50be8d90699be33d7f15b..35c536446c27c72dfe878df03161720b97ea9ec7 100644 GIT binary patch delta 3093 zcma)8Npn=m5w5IP^|q>h{a!EHmu|F6=pnSALOUQKRVznXu}{Vz*jfcjZk z=wFnd=QF<^ZV7%r{9?Mb!m{MSWh}&RWSmx+wpT%+7#w(=Q?htmkgqAv_Qe4rB=rh8V_RgfQgMdN_yEkvvTgr8r8~#tRuc z>=hUrgQ&vTIJZ$@BE`ufDol~qbWJT|Gvwfihj6rxyd0}1oNXYSL#EhqFJf#yJ?un! z+mjT+sRF|3Muam2XPXcfcr#;iBSr{$i=j*d+XPWWC2 z;nhyUYhB%l@AqI}*L!KY+(&q0KjBJ0qTV@x42#|7X68M@WC;JU#~J@<&;k}b83thX zQ_Et(*I@(&-#9b~6&8GR6y^L|7H8_)ICCq;2B!ND7y}`{0}}wY z_yq72_ft3$qxN?JFrUHq;8-&-@qOBop8*o*eh%?0F!>z3Ik4R?U>=WfegLNh6F)?? z3bVc>J@F&5v3`txSnvXlVF;O@q=$=ycHpOg0qScD7zf0)v505m<8keP7dvrhYz>^? zCz?+Voe-yo&J3L$at6+a=L?1SLR^ZY*u=TGKE4<)#+Txy@ujJy>7|(~;nLA7h4%)A zTjQ%k*9+If<(cK_vZq?mk*yc|4?P{cw9LU8kF`7AubjUrwsOL9JZB|8V!IeQRrbd+Q_b z;iH{Zsrc5xJ$?uEY9H`W)?QmOA2m%Akg+hpG$6S zl8$?y(0)MZ+Z?u}L*R10B_I0SX>qQhpzbHbE(!y9sMPo6PlPHhh?#d?5a^TS6S(s4*JMA?#XrESOVSuyE(YG z*+aWM#31nAYFgU&qUX`R*Tm$a%gHYbU1x{z79Q_Ink~S?qxmT|#!MsMkDby2D_~}r z_ooHv1}szs;v6qG!m)8JJNP7Wu2#`lA?K#Ueuc( zZOc~WYFpXbRgQAGVOTVrMLrv6rHY`ZBh%8#M>nZrG8!;?;D?Dq3n&Me7ZXreO1|U& z9f29;V{e&O4VC?lCJOL({LK&Aj;FR~&SNC2bfB^+>S$DJt$Z-X*PSAidB=@zbs13- ztH+h{lx_ol<_573C!Q z_f_(&CSN(HV1g-a#&jlH!&%1ElGyh{Rw#>pT7^{W=|wkvKH?PH#DZL;od8M2c4U;-DXz*Juat@BP2yR(o#L+C zd?oie1`rfF#g2SJvJeA9LP%B?75vBJWKqJWs(iib;)8s8ug!%U89sygf8Eii_>s4D z5Avg_;2ic3d~Op=V|T=fPbE2x)Pou0$5NH^C3?ivf>BH0&kXiLdUqo2g^8|f44W`n QdzRQw%vds7SK=}IFQL^zxBvhE delta 2553 zcmZ8i&2t=A5r5tD-h8|_J3F)5T}iw8SV^m|k#_ZAt@Pv%eb|zf*l}bfwj4Wlj2(gu z3ARZbNCL?c5+DhcLu!B%6qOSvPCoKSaHP0!N>NmC;ua26(LIudVXNjhZ+d>+uc!O> zdOz*_Wq$q3fqxiR2vGnrfCE>YhrgBbbM;7l=zipQ9|vER{J+;@_v`v^Q2%o17hrxj zjNzBVe~t@Z&kaStp8sNFxXbRo5JkFT9|VYmEG2sCp?g^hQK5U4?!9#HBYQusYpyUx z65HJJgy(r6gt{Za1>g6Cs0#oo267xkM~ESmWEfVA4Wu|D4$^WI0lHF*c}#EmjN>^@ z1X_qmq|BxmrVT;LelrZSAv0SA#&*OwS7e-zDUF4MU@_q56D3+M_3*Nj<1%}%1hEh{ zC=0O)i4fhB=n~;nj;Hxs&oFDP+AG952iOP*Hv2fr*?z`zHO4Kfl-Ld^!ufo&o&0N` z;S`=N6I`ehTx57|fZ!4i3h{h}V0VZfFAo#!8Tz>H3seLtUTiR48DYFS%D6w)B)m3G zdAu~i%j=VjH>Mb0o+dO8W+X`YaBxug-=o^g;LQL9zSVX>6duh32={Hr5%_%vh5i9O zdhaZ_Ak6F{#W(LZ8Q<#yN4g0oK&l^h09^Sais!w5G9~5*Ky8v;GN>N|)xrA^($gT+ zParr0uJ;kFQ&jme5W)E=6Xef$UHCbiqm9B(C^q?j$~O26C=Ii}P1`}*o62-EJ(u>* z-V0JMok*S8ZQLF_KesKt*$eT7ayh-2HqsaSmwVYC1Mw-?LzqIo%^>R zzWLyd2M2Gz_87yjAp3XW)$AZz%l;58J^p8O2f8=?BA_>@@f8z;AKqs4zF`vZ3wIgi ztBm53g9zWG+Q4fj;tkRHmL%T;jS8K6%<;d?=zfP$y9lo_(K=`iGY%vJ; zA>>s7&2bnf&HfsH0%x;>8*|5N(CCRVIinf{h+K_l z=gM1ih7QOPqZ*>B8%UlB9qrgiJ4qpw#))K-V#uT*c{aOSn(G#kjspNFBW560Hby#} z4xqyp176i8SRy_@E|bBQu;-9~v8FUb)M$GeQX64Gg@(or603}Kz&MPo6RX~kt`^p# zs}g~AIH|=v(`=`|kPY_u-74+o7__~rM(%xBp(IK4qQ?WQK3NBVy`1fdh$8i`igjUY zA#k-)D7pqp!q%}51cF+w(7pp9MyMfKFqpLHd7P=dd8&$}9dhvP0QS>PGXQ}R6ve0A zYX(cw4q}a7Jh2By_JSSC{?t>wu@wRZE;gjEj29%ACk>Fdw8J=-I!ub0RG`Xu zW#&;D8Yls+q2$^|?x*Ys4$%+>$Bt&}l!%{jM`mq~~b=_QzidDCa+;e5NTZ6o(mYBXlhNaJW@#EZ;6%dCV=EV{ABotMx!&{@3)nt37T8EiwToF$ zZ8kS5=8#A_fd46`Q8ArFE@rk@opLu>En8W)x|YrN_IF?6E)_x`tpZxkoaPK42lLb! zB>hOE>$t`<0L!AFN%t?{@oT>hyV)ad}E@m@b(^qVs3=g|7bZq-x3oE9FIXnLQO#z^)j#Ga;|3n`~n@jUBHt zChw{PwnS77jkIS}o{;y|TWpKj6Ajx&@sJCY1_x`1a` z%TFei#kD8gLuw1xbHjNOd0Z${k8-cFroP%$o(Hyr8#!gC!2;w_K`cq*lMXR!Mjjqw a4T~b%tX1QF8sbOpbRKLcJE%1<75@R50r!Rg diff --git a/build/StarcoinFramework/bytecode_modules/Authenticator.mv b/build/StarcoinFramework/bytecode_modules/Authenticator.mv index c5a74c50726f9630bc63c08e50f2b5271cbbcc8f..7fff119e122a9a7d9b41cf70cc56ef926141b43c 100644 GIT binary patch delta 469 zcmW+yO-h_W5Ur}NuAct;=KIV?AZ9iy5+Z~!kVUUu3JG|EVT^+sbw(y*M9^gxSx)8x z@d}cq8;{@ta)6Laq&{oWyw~;mb-lWizcRcV{EGqr5g|}uQ|B3IVFBaEwFq_Y3SN`Ji>+$Gd{P}csg}0vyBnmi$P43y~Y~$Vp{19lH8{0Zk8p**n zzp?{oI;P85140A{n-vsvu)$)zV{H~%?a{`UV%kI*BNdKDRQX&lld(Bs6G;<;mkbV7 z08P?}0R6WCYDhL%oyZhQ*lqr~bU+GbiwCwJGfPf$*)--nPzI6xN{vJOtnNiL^RLP4; z8ez=JITGJ$c8w;~qs4>_W#TE_he)y5N@3nk`)ENo61pYj)YSys4FjUIan} zNIMPav4^&0mwKz_ZvClwO&+Oz*yl1*hJp4t7}kw>Ek)z9fQ2Vb4hd)AQ3s$%$moS^ z2;>l*I8A2$h!1Avs840I3bYjj`UfN@!J!(EV}%uD=vk4dNL#;Q)BtjIYwMYkGzr2l DrMxEN diff --git a/build/StarcoinFramework/bytecode_modules/BCS.mv b/build/StarcoinFramework/bytecode_modules/BCS.mv index d66fd2976727d10389ab808b938c050b7740b0c9..d58d5363cc266a5cbb3bec62584544ee56c164b7 100644 GIT binary patch delta 707 zcmY*Xy-!n76hG&@d+&SqzOOzCr7Z;oqHUo<1tV|K!Og@34bjPj6ljD9Ew)voi;0Va z#zd~0(dgh`K-@GMql24qcW^V&+1c}8FrML;bAIP{KJLf;;``#gSCwDB0sxKRk*A#K zCyGB-Kux+jdzj zQwsK_7{jW4E1qJ(UXle$(cX|HO36NwXA6!`e0@G8B5+dSJLK^jj2#N)o?@M1UBxb` zMI1k*UHdTOy#xNE+QErKUfYW<^X7nm;Ev-F``Uezt#H*lR;pHc45t1t<@u>6PZ=~+ zFu>VFPc*94?AIJvpwb|aMj4tGO*v_Rm8!snfe589($N0)%Kp@u{~GWKn|hv7-?sDu rrGb5}=Z4bIhm&qI;6D|j4~ty-U0$}qcA^}ZW2k|E% zzY3{N#i202>9q=v!jgU)F2`r#kCcT1L}UbK0q2ku0E#5ITmhyyhQy8$8NgBqIEsL{ zU=y-HN)E^hwnXMGkQZs0Vql6AV7fR~h+9>W0X39>dd^vca-dnjOaZL|+Fo`WunDo=W)#@NdiGCvUatPVIVSxf#{-0){&_9Ui#swbP<&o>@#K6<#j zx3M>p+dJDMxx2G9^6%w+x|8}u&4{jFR0mX<^-pbOe!$~QA~x(7%*nP&Eu73{tYV!Q zr-zyUsczSJd0y8M6Twa40t)%g>SGr>X#92Y>$*Y123NHFfnK5Jxqw%ngg-3=rLmx9 zw){}n?0{E4XAcdt`I!A|+M?xunRmtDZ^HRTx5xd(S~^WrtZuJbVX11t?6$aD}e2K`ayHa`(wOxlDWS41ECF9wg3PC diff --git a/build/StarcoinFramework/bytecode_modules/BlockReward.mv b/build/StarcoinFramework/bytecode_modules/BlockReward.mv index f2b272971c95f54f03e0c167c1b19ab91bce5520..533de2359e99cadbee5359e8418a3d24c7ac3322 100644 GIT binary patch delta 547 zcmXYt&uddb5XX1+=i8m#_wwFLn^S>kYR14ERTA ziZAdQ)K7ZOlQ*g&&((GFRdwytEWYqw0x&}ya-8vwwHP$u>k0cj^E{a4D76 z9J$pg&veD3WfKe3-1EmR7$Uu`t3O#74g`~;*`_Ka^ zhNIKzS@=wMTJm@}-k%;+4#y7%$A|a&gUSAEG#pRO-pOQg@~A(Wg+KJM(WkQq2mQUl z-J@{Ep68w*@leohN~2GpNm$`4DW!R`No`?@3h^x5=IxH@82j(hi&*DdC_EK+Op%eu z;XkkW@RDy>)4@DraYE!SeB!q7Yqd>XiK!Q9=|e86t1rMf yEWHu0AQl=IaLiDlMpqDzVJ@z9t84rn80IYkQe@s0U=xg1F!9klP!dmJl#;*m)ktLk delta 487 zcmYjNJ!@4#5S_ChcjxZx-cQj8G0BUG&lf)sjc^;mpoL(O+DaZMArK=7iXc{kq!1zO zFA%}PLJO-0mi_<>OABlL32EFsES%yDbLKEJXJ+BITzj|pM+zbm(1Kc6)SHjZdz`d0 zyn_3x4h(-Qn&L-s)xUO=@Yx;d`0;Rad(WKF1qxm&0i%}TNw0_yk3z2PDum>0tU$b0 zH!$ToGWv6E34>9WC1%_M1ORPF+$8 zASgG>r?=YU_yzMAnd}2%2dLI)xipQ61{>mI>}7+k0;KbUmSF2Sbfb`pzF#a^mGRek2CwqJe&AEh6heT$rs sHyEkKNhz_TfzvO0Wzw#gPw;vu1)@X`zC&Qiw+P=h*`A_oP%A}$0dtW#qW}N^ diff --git a/build/StarcoinFramework/bytecode_modules/Collection.mv b/build/StarcoinFramework/bytecode_modules/Collection.mv index 306c01fc8c236d304380ad8666cf6810adb50368..14cb6885c15c02e39d50fe39f2f4d45ea04ee280 100644 GIT binary patch delta 380 zcmX9)J5EC}5ZqbsvmJk4p5F_fB0{3d4HAtT8DQKt>&~g!s%I$Ytl5|3BWw1Fx_8t14?7J*J_iOP{qz^tJfiL|C_ z*o=dTv>_HKERjkISn=#we3LbUL&=MXB~@W{rfkP$x=_PF8B_*|6I#?p@_FPls+zpI jrjI-xRqWY~ z6hXle@Z!Q_&zpJv{O(`;>Us7po`@Py;?$YhmA&oU18%|=zlfh^;Lst<6vN z4b7MH?T_26FDoV@#HEQK?pg;jePY5?Z?U7v?oPZ)du5Q~D5u;;j^n)fSQZ$h5g`ae z56!QKxW?USWPkwICaPqu3xP_UCpxADDuj-}tia9+t*A1ap)o>hVhb&cP?3ZsPY-N# zjQ{~9&jkxQi>x5}Iwk diff --git a/build/StarcoinFramework/bytecode_modules/Collection2.mv b/build/StarcoinFramework/bytecode_modules/Collection2.mv index ab314639e15c5fc1a7e499593dba7915fa0d0cbf..18a0ceb49462ba1dd03873cf1c5d36824700f1e1 100644 GIT binary patch delta 671 zcmZuuJ#Q2-5cP~dcGvdp-fV8O_pz6|B$wRrkw{4BVxkLlbaa$ZrbMEkp-O{9iO~K6 zN`xp-3PeE_XlVEgAW=a{LCg3;Ni%+)XTLYk{**r}PF^*?oDo8FKv=Y;Y<`1!fj9L9 z{)FVM`XbXmN!L72SN0+uyKkxTKhn>-^E%J-_xa0{H)qP$8U*YWg~0s*%iw%SAe0|v zTo+Jr=L$7kuSQl~+lsZQfIHV4uBzNB7~28MsNOW*t+r#oKVpmryNnHOQcZozXjqM^ zhQ_p2r8KFgRBzKxwM(;VkM>CsP)SI0TC{iJY=OpRLK*-_96%<3w_qGbn5-8};)(V< zj6FoS-e=-m;Ri7K^wHxdPtQNf23A3$;+W7svJjL~I&-X{X)w325?)(~dBxpbgNSz32$Q(GlCGN0cR0Zt>^=^w`G3Cz~51lyXw#OWUQ*{S} z@sLCCs?cSkSlL17I1D-4ac#fq!yBPMAH^mkD|p1(2_6hBUJm9papLt3H(mh36|dQvLjiz=VYj``yXaAGVMDvxnE-$`5n%E%t^pYk4~~RScuj< ha*tpC(ixUfwvQX}$}G2>+QUCfNETT z_N%;<*<0H;@9o0x|lZLhJRkRs>WL(u_8`7jUv?0Kj^Ho&d+M z@tBr&^;se^&x@tXfO2&lEpOz-A%1|1T(z)xK&U_fG}{iMR7&?eH_|lNa{M)IB$M z;BoibOy`dX%T#Nf7an2=GMC&q_c9jP|Bq58rTb~7M}4f4KIN%*__86$fL^jSI7rqU ieT{#>${FUVE#Z|^vQaoeYXSaRB9B{zq!-;&JNpCJ7&+kp diff --git a/build/StarcoinFramework/bytecode_modules/Compare.mv b/build/StarcoinFramework/bytecode_modules/Compare.mv index e3e7ef4a6ae9a2ad703c9dd09d6d19fe9d1ae49a..86aec6c01b49cdb2ae53ccb26ea7085154096dc5 100644 GIT binary patch delta 284 zcmXw!y-Ec!5QXRDXOhe=Vqqyr!0Hwjw+dJaf`x^R)_PeKQCF7>mcD|^_JXZ1;7jNu z2v#;0zJil04#}6p`O?gfd+`s?o8Ju+Q3N^bW^Tv%c?p+`_>Oh{Kx)76WYvR=Ua}R= zC_J?0il9LB3_^+tS_T-FdSHyTK+;!(0xXI2zsf`wyp>4)WVJeBufM)M9XdYl7R!DZ z@AlXDs=GN~Uhr8z4E_E1nq#4s1%<}XBPrNulR!e5c5%?kp^)lO_4J7O%8Pm~(;H6E YOxtFbgKH>IHcl5=Wn|<3v&n{j0mO?UN&o-= delta 234 zcmYk0JqiLb5Ju;l{JGgJECdThOeI=+1Gi8tRICIWZ(;2fmSDSJVPoM%Jc@-^a1s#A zgf|~~$&iQn=;LkpE-eu`5Gx*;@x-mRoh!Qbj-q;^RU#opoS;~sA%`Zx3fTIz!K@Te zNS7dJF8!umPUZRkf(%G^k!R|irv)nOu|OPP?`!m`!o#~dp0Td%CVQ9t3-j!~cw0xu Y2e^3RSunaJM}f8cEoTHazs!N@3%|z|Y5)KL diff --git a/build/StarcoinFramework/bytecode_modules/EVMAddress.mv b/build/StarcoinFramework/bytecode_modules/EVMAddress.mv index 9cb4ecebac2b0c410bd4a101d46305c5b3bb18f7..486a2ad6212e59a89d0807ca7c0d0c46a3600c74 100644 GIT binary patch delta 249 zcmWlUy-Gtt6ok+0o;`c_4@80%UT3qve~6@*}6X=yD+f`OcMu{9AXdz}+T#On2FLaZXVnMRLZ1q?uow}s?P*g(yd!87s+DR;FI|{-;5I|>kXJ^CC21JY&##pF@O^8)ur?MCDB!aC+urUTJD@)JeHN*>e2|ozF z_VM0bA9Q|6pTYnj2&9N~l+Zw#;lzeA+O>F(&Yh6`8E+UrR9*Cm5OlrC>g)W7Az89F z&R7^zw)lL$G;2)FiaUXuE#~1byme&3ncj#hQ^a-#frS`EUE?IGxtoR`%EAJr~z(*k^i^m}Y?sybRrF_Y|F?VA60} zOh_XF7BGR-mPXn+A`Rd(q*u}k7#gHVA51vS+U-@=zHYL7Y1Mh2*PE&fFY3mg7e!;+ z*0u*%wz6&6&dNn)n~Q9ny(^bxx7BZ&GPixE><|5$?b=>f^ExEXoBF-2rd8K${n^dM z&WaaVo7THpX=AhEU}3wo$hs_T>rIo}H0z6woWISpWmzrKd6su|lay8YU##EQMcHAbYdg1b&t zN0X)XJieN~n$E6g>G|d5+v#i;|1I8+wd;J*Us&4iZY(b9lv=Rsu5T{59g^5c822Ai z1y95p>5yPxO}7jvj- literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/bytecode_modules/EasyGasOracleScript.mv b/build/StarcoinFramework/bytecode_modules/EasyGasOracleScript.mv new file mode 100644 index 0000000000000000000000000000000000000000..b93e65ce5cb9181f89757df470a7cdbbf9478899 GIT binary patch literal 219 zcmY+8zY4-I5XSE=*R;|oMOQ~bCuc`N#L>YAD4`7!5G_eMIQs}bfzRhln24Yr+{gE4 z`8}r3QUXAZz=CJIklAvauQ$aFD|N?toDc{Q83ZNeFLYNPVdg{_Uz2A1Goqg2}U8K;)1Ke8^rMv1cKu3iWgiLgjItg zJ6@ycgKIsQC?V1KVoVIi#3vK>$rlqJ)F&PYiI0-7KY$QUb)TBbG}ZOcQ**xWob%OJ zRXuZI`qK2$cg_DpV2lNv1y)e92X{D6mfZc*-naZJFP*Wg@QwY)+Til!Ky-ETLKB&s zSRxM)O_gn{@ z5Zuc0iS>TqGt0w=zx?%f5B46OTReJv`Jef!d-(NZizoeKZ=QJN(Cp0IYrpQ`XX8c~ zSdq;wUJgo974t4an?-IJg^BJ^t=Z-{<#1X`!vRQ1M{Kvb*gTX#O0Xq2n>uo8A$UrG zpd#m0q@?M-0jp)?+jB)A|sg-b+EHW{hh=)#cgQGO;zZM0w+|YHA1CZGLjj$Mu7_oT&KZXb=gTB zU9VDBN0M!+6B}ToNgq0~5r$2Om>MM$Z-+l=bMq!{5?ksd@($g6v$A$&loqo^gLf)r zm4v{%GV^Y&`R$Eyf*2`%iRtY6CyU%lWY^GpkXAuP$w&P z!mNpaE3+_@PE&1^H4EJWWKQ0J>;%6E^uFs~m1vEVw3o~Ttp73urut$* zrM?RIOOTE}_c8SdY%n3>_i=J;zM%H1s=ZJs>u5ph)CBGM8|LOH>$q4MPdELG3DU7> zZX;GE$ey>%1T6Np84;CR=+d4v6EO9iLgZcTWOngRlN9tCyulxpGz;nryQ!cW$H-EXV?q>8OcGBGdC^r wa}F)~5tf|LwYa>;*fS177V@?wuC&&!DMxL)=g%OEIR33+Wr_2U4RVX!02H_GD*ylh delta 2312 zcmZ`*NoW*76s_vzPp7-bOeYi5nVC#tLNq}X$B-D8NL=DB5fS$&QBlOG3`$gt8FyR` z63UC9hlm&TAR-8!a`Pe{B7!1l5WRWuE(reau1aOvN*$Wt|NZ6tU-i5C+v@SvrLo*E z2M8fHC6;DcdaB)6qnW)+62qUV^-)W~Pwj1!{j84P1+A_UQf0=$mDue+FL-(T85M zZEKEBHR_^85IOM$dN5+NTr+7V2pgzQ=hhl1QWyym;{r4dm#42aSbwz-p@AOQYN#0% z8Z*#DAP8_$fR+R+q-aag5iSF1o*^m0Sps~K_8Y_WDH!D3%lIL4kI|Zt*k2K-T6h;~ zc<34#dbR*d0`vn-l%)=IUVJ=DCdd*Mn-vM^Y#zQ|f_V|XPk@aw_Z%rUNwHbDObC}2 z3ClY0 zHpLa2<1Sm`7F$)vA(-jO4DVqdbgQaCLffF0x3|0z3$lEFwyS%{2C}>nJJhWVVzcjc z;lRGgavnS3#|%7nsoTl^3LbkPqjF`19FM&Ze3b$6*bg672rCKK1M1l5dJsMY-)vmv z?RlT$2Y-M~Us}I3G0UixB(TpAgJBl0&{YcmzXT^NzJyFj~JOOEy z3-TPCAy`A6vpOXcpPs??WS(z%5n5Gg*jS!#`5D-#GC&?@Ma92G;-NqjeNWFx@w^l- z2$y1mA5G0g+3RR(hU1D$am7enQG(Z;A|JHNG;VT*g19BQ&D9bGymG_ERo5u&=5x+9 z*ZR$i= diff --git a/build/StarcoinFramework/bytecode_modules/Genesis.mv b/build/StarcoinFramework/bytecode_modules/Genesis.mv index 8d67e880e708d6507be92afbb8d77cc790b1d63e..a993a71d8b20ea01a2e44c32fb6c58080a58ace0 100644 GIT binary patch delta 120 zcmV-;0Ehpp9IYHLp&aWA1^@s62>}2;0zNnccA^3Vm;)XKwgc${2cHMk2?+EM5C()1 zfdLGK68H(RFO2~S9ZCT(0RRjjF_XUm9s)HIv)uvU0R#aG2>`Rb1Jnct1!Zk;ba}Ip a2uK44I1UT}I1aP#3pD}0j delta 141 zcmZ20vsy-fq0DP;HUjzdfWY?qk0xb85q@jPNOz>% delta 94 zcmWN?yAgsw6hP7YJ}m35r5+Dwf-#)Kq6Fhrl%S&=Gp2pz46dKSyx~D6Yq)O2MG=pN2CHa zx-2?UR4_LsSdM?Yef`Kc5{ps954iOP)^x$M603f@zp@&3t&_yA^eT2E%oju^IMZ`VZJ$9@_u_ delta 190 zcmWm6F%CgN5C-7+cV>6-6ljRNifCy#0F6rJ0P+$Ef{@@Tbt;YQ31}ta04||(1{}g} zCiyb+&tyLOp%0h%8yO<9AjPV#8#UW+WzvE3%M5QS%E|L)ycuYGTf<0N)|EJTO|X(+N%BGFLr1hkeNED?cYD{%l9M3QER;EoNsm=jePpSNSKuf7!WW3jj5Q1~uC1_FP}$s`-rH z(7jh*Df?j>_S&rbH#X;Ymcj@7UDbZ)I{vxXe{}AeUYvNNjtH*R@KTrM0k*wd0IkFb zYE?#ht*yYsRjZtKuG0~nsjqu-&UBYEbZ&ifOROP_dB_SXebbcn71wMui*8viHOVS# z&=VPjNR|O}P?-%E*9XeyQ0?HFB`ck(9$@M@>2e?`sBFkFQ<{`^nid0vP8@IXXV;9z z)7d&FGc=CMIA0Hjh`iFz* zV0iTGXg2r%#QpKvtolMJm9k2}kRVWv7!sz%jY%b9BH08&%oq-UG0-kk(nR7|s$S|% zy9cb2sXprVIh&@}9oAc<7M|8UhJr)x=>US4qe8aJS<;)jZd&Y-5gim^JF1u$5I8#T z_mH`$6;b!h&VLDsguSF#7An?k*d|9B0oLw%vac5Sa;jgdM=7hidWTY8J=7b8_rUHx o$e);uNHzrdCZ!;_+qZg=QOI`deB?|3IEQBN>jZEM0XHzUr z#`~v>=?guX&!@)+={s$8JI|*_CoiYtquKFd{A@Cx?9UEoi_^3w;wa>o0Nuzf=dv7C z#1J83o){@26J;erRWJ;J(b0e@3Zk68mR^gSbib88itU4y+YF&}rKKS_n@hN2z(o|B zvQ{0o$cP4l-S)zl0UUc{?OkLJ9Gu)zyZ$+#mI_b$nCMYjhW`bH0C_f1h GFu-59-$7RZ diff --git a/build/StarcoinFramework/bytecode_modules/MerkleProof.mv b/build/StarcoinFramework/bytecode_modules/MerkleProof.mv index 27c43e894adba8f2d675b862c1928bf000847399..078282555e9e2beb22f7518ceea76d4674f6794a 100644 GIT binary patch delta 192 zcmXAjF$%&!5JhKpb|#zMCAc6K5(5%YD?zZZ5NvF0Ej)lA3W|X!c#a&w%6r&(1kYgQ z4NUMi@4fCn)mLTr^y35oA_PNbpvS_~MReJi7q?`;I_Ied| delta 143 zcmXAiI|{-;6ae3MciHy{2E-z0KqF`+*xQ&&+u*TmwzaeM7#_k)Sa|~@PBl}_ho02l z=Wh!D5D^lmMpmTjT^vs7h7*63wsDL}ff6E+mdmDG59M_pj_8^tYbRUv3|V^gP;m}5 h@2Qi8v4v?3wK!`xs_{Qe0*<>MGZ&2pSh3-f;0wQ?4<-Nr diff --git a/build/StarcoinFramework/bytecode_modules/NFT.mv b/build/StarcoinFramework/bytecode_modules/NFT.mv index cf97fbd3cd94c264447836e29d3e4e945ae000c7..2e48c3516761fc5f56c92358bcfb0387d2982e76 100644 GIT binary patch delta 612 zcma)2JBw366h7z7%zez6`${mbn`{zAO_1nrHrZruc1a2aOA8fTUxg^z2o@q(34(=< z&Bb1O5hR5o{((hUuvPp6iehK$+`E53rWn4NkMH%jv)7rwZvA8r03w8x(o5p@50d+$ ztA2|;;lKCyb?~f~dM|4``b+IO^4EI9{HcG_(dYKD_*eVg{4I|CT|A9IR}%#P+PHxr zuGi}zZzL1+)J?SD^~a~S2KCJGCIq(@}Uuf^}AB3z=zECVk}Xl(h8N* zj!cf+{tt4gTai0%?5&8=2qq&L$OgruXs{AE_b``qv?@@Kssf(X#mDH%*XrzWnTI0Ut0yTs=EP&lb3!;-QSKhIrE2Rn<&_~z82~jCzqvCG-3FG2; zV$UVCUJfz~veAw-Rn$pzh&J3~u-$c0Lb;ZW=HVfwI>?g^-MWg)<-+1say}jM P(Db67?#KP4pZ4G%i7-uP delta 654 zcma)(zl#$=6vy9tGqXSD&1`lP44TU&@jy39^b(UxX3yhtprE}9-kmn$Um*4tR)W}U zc_3H|f~2t!tc3VaSc#2=h2UZ5Yy@pY+-BaJ+3%ar_d6fD$KBl*?JpbvfJI0ty(#X0 zBDoYD^;x_Z;mdHTqi`JB(hf=(fj)K!imaj zZ{v3g6{=TteIyghXatjy3@$9M+ri1uS5YD9^vYnvt_%h)E}z=lx2El^FhZ}~I&D-U zSk2?OKqEC+>DV91IckUtm;?KT=0s;bpX)m6NvUE64AHytgQyzhOj#sv(U#v6cQv8S zDzGBT#yisZ=U|%J6EyUj(RR!&&V1VE2WLI3~& diff --git a/build/StarcoinFramework/bytecode_modules/NFTGallery.mv b/build/StarcoinFramework/bytecode_modules/NFTGallery.mv index bda70d9e15f10338f3b469feef051e14342bf596..7b0364a1abd25488c88f8e031c2c94f58b93d5bf 100644 GIT binary patch delta 1081 zcmY*Y%WfQ15Ur~F=!_#P7sB7Umif*s#bVLVQ3ZlaL`s1lw|qP*x)$ zSg?vve*hpBd;qLLd;uF+Ba|h-fCP0riU=dkRp07U=hUgH{;c;~@8-AlUseNvM+g)S z#EqvYzoxg&Rny<8tr~JKWhJFPlqSHuWtUl&{uGbps%h< z1l*Jo#8xdSleE2#sP)bi5#%m5eC};5@wtCx!soRKNA&fp{HzbQwh_cjwNGg;4^!GJ z>)%AM{6M3Drs|t3fp!jmmMkD%Yg0YS~Q6;h-+Za=je;X;u5ukNj*f8#Se^ zma5fqqdmtqLsI~1(<1E)%1paMcMNF`3e*Ms@Hzd7Ud=x~zkIA8&QBj)p0sm0GsXEQ zk4}#7-F^R~_6ylu*Z0mYF3vv9AIvY0KRo^5EZm9Udq+(dQIX*OA!dd{7J5C4QB&$EuGI$K04Y_L zL9g02a08q&>JXg_7&Au}oUqagOGg-Us}5Nw7NmfaXYVF57fgsSlSMRS0_W!@e+{B? z&bT!F1^)pWIkq`Q<1+OQGh4aoF)}1!t%=@|+Otk$2L>3%z}n<&u#COsEn^Flvw9Ji zoVWQQITbutC~R=js#N0<#bxVb&uMl0nV7cP-O6l6sgTWG_OF~UBHg-QBP};9_Q{I> zq#YSB6w868~% zvBIeRKHFOCRo#@hARct4OgCsN-h|h|k;6FVDp%Rx8eb%DNm`tm_?t!C=XK(@6DNX* z>oQk1L*5cA;*_lr8_^WHBo!FQBs1dAkV#aR7-B;Q%PEit3$Y&?hdlfjm@rN$EiBKy I!ip;R7aSvTYybcN delta 1019 zcmY*YJ&znk5Ur~In3=Ag-rbw+{kDB)-<^HNAflts*kD^0a)1ya*t8JXU<&{> zLZI-Ry7mL=4{6^#qTi_a%>1RwPpZECyc)W%t1J9VW&Q8fV_QG!+wfig)9c@_@q*T% zwr83OO*;!jt9S7%g1&gJC+|y}b9wL01+ka6S!Wb59r%3@#8kpUVES3_~s}2729w1 z=7Bz19W9FoCx<7ihs$F5{^{}Ew@!8bvB%4YtM``WJIm9<2S;zO!oB6m>GA4=!~1uS z?!CKgpEqxA&uI<_Fl-zQ1_?HG-$6oo=td*0>Q4KWnWAccH0Rbg8&U{}SO`V2#4sjJ zI%Cs?gBL+-Qxq_0E;_gd-Z-<5UI$FZ6N6W*Suq`8vTXK&@peN7B>2qhIhhYGWD!*= z$OVZnUHJmsY`k|qPj21m+0s)kF%`ZruSw=o@6?zo?=qKNa-Pg(_Ev0lXPj7Sljp#~ zy;HMrD_2VODtTXXxli7NS`;b{UbD#>4=B}Kr{Jx5^+_?y)`x-%%0kZXIg!==X@^&P z#Oi4+PYxX2YLaodr59$*fJ}+Wb#a}bExj#h>a{NyqxFUJ(n+ywQ(qb+mX%Xt1I303 zMg%WvBZ5Vepjr|S(uNq^WQD1peNovBB>b=WIaAJ(`BY`X_N9O7+^ClVx1^-k<&Bm!m3g>l`OS-k{T!IQ_-i0UEJEB`KzfLeA% z1xS(P)*0?AJ=yamFu4(J304ElKpC`vIW8fWvuIR~6+7I=i#zef z;mPUi!O5v!~Brm8&-=FUP1D3R;#4Nj-y`3>%*B0#C=10#cfnTjGMS7D%J z1Cq_ENxo8X#Y589}RkyVu&>dwH`et5*)ZgQlHgsutj04nm7FGvvs;h)x|ri4n> z^zDEC*W4c@?8f(ee$QkwvC98VllV4OIpb9B0qI8=Rmp2oYqA)A@vV0B#JPz&({%~l E0M8{mVgLXD delta 488 zcmYk3y-Gwe5QXO_H<``k?(W@P1;xTf?JV^w2(r31zJc#xAqa{fB8b*<3kxfsNd!fF z01?E(R&cWZrkHSYK9V_;H@TM8o0%8&08k=$@}AS4JC4N#9)(l7M|t3`f965_;Gk!Y z(z(0i@-a~RDO|4YP7m4z0{Kp^6VgXe=}IM0dYA9p^DXeP1(*xv;%#q1J_`Bh+ini= zzB!;B8cK6ZbNvk=LTjk6undVK*VrgeoeU+B60v!q$ev%V>6NyS1NkXMRR*`(BJNb&lB`?UOxMmt g+r(fZ!lDH#il{ctuT0jAP0KQoa_+!}WfKti1VVBw5dZ)H diff --git a/build/StarcoinFramework/bytecode_modules/Oracle.mv b/build/StarcoinFramework/bytecode_modules/Oracle.mv index 348476de27b193dfe2f939586be8033b3bb5aa6e..7e71bf7c213cd864d4ffb5b54a276fb8c2e8935b 100644 GIT binary patch delta 622 zcmXX@Id4-z5T0-Ldb|7leBjve5$AA-0|W?1;wM0&K%xmHf)bI)A`%2g#t5ZK0~O_y zXsBptTu`K^qC`T7KR}a;j+Tafc1GIyzPUcFW=@l@#p6%yKVB120aW42E%D$B~R3%Pfd0kZcT{gUX?*AxywI22srf9Yb|9EzKL7M-At5 zXvWB)#f2c$PKv=V%u=0FUeTA>kl2ut_;S$VD?6b>Tn(|=MEJ)wu0u!H8xj=VKr{H8 zt#D}RIG<;(ZU%%Ravio%Jd3IkO++7q)mX-xrtcb2y z^%1<{pay2FMMf}so?yeWxGUCe*cM+9vy^6BJozgt*hvv{%CXGPJhd1Oj=Qp{Vn+_C zsHQR&1?feqe13?T)nX_UqqVx1 z-|3P%-E@k(%u2Ft4Dn9(;w#WClB;>vYsmlD~TgG+bnE?E9ni(e0p3-`%bCb|dmV hir8nab2i9iFVY?jOD_1XHQq)=zfHIG5R%^N?thbVEP*qLv>?*|L>OJDr>w*TW402qWIf})*sz7Dc~r9bf-lPAj5D_Q?RRb&tZ z5HLtklxWld8W6QIED_l1Bx+|Yg7hXbsaFUT(h%)VCw`zZ&JZw{62w*>6^R=~D4jx$ z2?}K;A!{OH>j2qu3{hDVNsKM#xDEhU-U>mzQ3ivc8*-{H*K`d$V#d zoef)APMY~LtEUgW$+)V5p=ciSJ_r;ECYV}qM!(T>*s%LSg51$cH)pjU

c7J9JU>;-TQ5g6O>Y252;ZxnF83Y9c z3>pksK>-jz6wb6k(M~LocOJ!rkRxDjEvOiiVnRk`oK9Vch@DT+C48VU156HX5FlY^ zbtMC$l*xSlcsL2obX<*^>15edZLeP5j~27}eAXsVS8aY*-;5{MfBwrWo-axY>|qGO zTwuC=6G6IHey LpwNRTg;DSWgf1nZ diff --git a/build/StarcoinFramework/bytecode_modules/Ring.mv b/build/StarcoinFramework/bytecode_modules/Ring.mv index 870e433ee9fc90ba055fbebda1186a8e2267f49c..868c648d3443124b11a5ee0c27a78862b3894682 100644 GIT binary patch delta 791 zcmZ8fO=}cE5bdh&nvd?9o}Jy<-F&P<3?fE|1SDw`|9}^7!IMGbV!&i~N!CL^$U!_P zUStS(5`f39kAnZetKPj@Jqn85@T%w4tJmFA{oFotC$C4}U80mKKxLS*u1~?d zfi?OHA0R!|PceH%o#ZW9`;NT(M981%rzzgs#DBE05ELq{lmVp>Q$b}ENFdaLi6Oz1 z62UBq={(B?t+9g6oiHdUiIg^-3Y4Z^E!gQxm99$BW49EE?hQ-9deIBh2dTvY$MujS zzmN)|0dc@ZFM3>RHOr&Ok491HbGGc5x$vIZm)!A{_g$Giu6>^h8u+1K@ckEGc5Yx| zbEP4PkU9W~n6^}!D~L(7|IoRjKcBi~B@a=KS~s^~J=q@b&ZmdX6L@?+*&k2t&-ZA2 zFqG4i0Z7$;#%fELiv~Lb@`(gmr zbj^Y@t7d~XoouSA?1EEU;24&^Ya9ymP=CH_}RayQY0PU~1^HeOL}VJ!}M`|6h0 st=a_Pg_9dvy&fu4Iq65}29n*ySk}EzvzW7q%Buc*zUUZq^UbXN0!}kdLI3~& delta 709 zcmZ8f%W4%t5Ur}No|*2h>6y8iOa!B#7kt89NHBwlBr&>o<3>a`u7uy(606>jUP$6dal3$&($9RI} zXZnfN5x2!V_WlFM@R3PA@mpJeb4C2&avK5xFai*jieLcMFd0S5R!Vp-&LRXIh+ zUeO0Zz(>(qpr%ouTGTjo5*26CC>rb)*J950Q+9pG@nOg{(M2Calvu}Too!+pyBJf8 z&#oIR1EK>%er4@nYo<@{l-pq8Abr6_`i-wG9~>UMNXK+JeWxuSR^?*qWXxmQlk~)# zZ}&t@FqAiJ?|E3HXg1P&v-R}8ChT30f#-b7ZU?{;y6S3x+ZZq>wTrZ?;Q-sXE0a9k zup_G2bOf`QE0;WZm~&@cjU(<$y23Y?GbOvD+6qSP7jve3C!V%iZ8dYA+pfk3A{==n z-mGol(dZ-@G?JT{aTI$V5Y7V%f~dWG^6#2BIJfCW7Dz92PMa0}o*&28Le1 z8>fgX8xJPQwW$MI1*|00v>RZ97goBCbV zv;>Ag1Ki=U{P2MD7ryo zn)dYc%jvhi>*n$J(=q@fWX_|s3telvxh!||MfHcLypz^Hi2JkL4o|A#B`~A_TEJW= zloVRrM^_{qH3hOmSo#`vHv5LUz(!3%U6PAdq|3Qh|lWqtNsMXDMBE5j<4@M$LC&a-XyQ>-FL$a7YQM1Bw`tNcyvbU6J6Io z=^L5P{EOmqU60=D!hX?h_g$;>hyKd74@s1LOiu4qCtTEtgluOKu+waj;HYQ=O}7W^ zQXgph;BdNS!RfVzz&-(a&<*^p?NA+FMI1S6)4XOgo9FeskvH>JUf8zne_C<7A|)DcKV6+3MdffP8b*;pqw z*E1)C6EqNETfe3Adr9?d`FQ$hcJS03E~m@Iyfo#@)$#0LrOSD>dZj{29W9PZw|p_H zrpM)c@w`+aj;lqrQLZ1#CnsJ?%qkxjtZPn?p@zFrW3N)_#2y;+dXK;t zqSFubRPG=rQk5xaoUZ@XC}`M;UE$bAyCfN!*tkmznMu!5Aw@j$W}l=Ev2tQUK9=D} z7+kY3^vSy7VGFL((pU{}y(2u7x9cYc12rnV^bOw(4}*mv H9p39Vqo+=+ delta 626 zcmY+AziSjh6vyZNn3>&qb32#wZj+M`2qG53VIj%nR5W^O;U6I)DHJ3jNnsb#rLmB0 zZA42e|A1g2SX!m96)eR6z{)pw67(_q*!|9Y_kHGj98T(+Z&!bbGsg75R9LmNw#%=e zweR2~_%r+h)f?`+4?GN?cqC`c@f-i3-f88U&(-T&d)IN;I50R`8fb3^BkjweomQ4r zaS}odz0iad`l%T-<1|R)ZXNb+lOPay?X}TGPM;zn5zNJ+6oJqO-LvF_7_3dLQVrd2 zc;ENW4jv!uzS!|QFAw*hJU#4AvF*O&^P^cp0Au=XFap^`YA7RDwkHNWEXkD~Wr`?f zQ%BrQn}DdtFO19ah!a8eaKq{m+ducPdPvNM5xSQ)07*TSm&FKdFe9=`K$AO3Bc0b4 zpe-7UnZko}8B6BF%RvFQQ}>frkCXxftn)=3C!i5zMnTPXQEf!)7F*e(|NG10#!5fh z|IioL{TIDlR}mDQvzuy+>RGuFREQjSvYj49SCHlvZLq;z;%l}E9BibCP{C^y@2WBc o7UkPAv!riU+`}Y%KTS>a*^AFr_m$U%vy|%`O02pxBGI(}0G4Ap7ytkO diff --git a/build/StarcoinFramework/bytecode_modules/StarcoinVerifier.mv b/build/StarcoinFramework/bytecode_modules/StarcoinVerifier.mv index 684d44fe5845cdaffafd90109c0a8e06a708ef5c..1f79c3cc854a84bffd1177410c4789f649e19618 100644 GIT binary patch delta 655 zcmYLHO>0v@6ulqw@!rf!@?Jh)+cZhjHpMDpjLK|uVb`uIZfjbKfofZti0H;mSGtnX zm11$@A5dJoP~7`BbS;Po&MTq==W^zrGjj*d{3w5_Jbu&uW)%QfgoKhN_aBK@n9KM0 z8TC(kDxzbZs^|I%n%B{p_r*KrJ6*L{dxmIEH@d2T$xv) zv#J)tGX~7S{caF(t-%NtPC3(+yqeeYG|#xwNjnX0_MUy5uA?$BP*E6FV1|myi~($j zbWp<7Q2hq3`F$K}b!&HLc5w9W1W)jsy1To7XEssW2S-N-55#0Voy3Rtr<1Mi@y?#y zy>~c!7)>YR(bmPwSNtZwUCE6VXb6es49$lLL<`1HJ3=O2jHqL%>leka<{;5V8oeye z%aQ>j9s02tA^8`g+i9&9A)T&-{!=z=z_I@-Zgl7R1y#MjwpG#j$4@=iWRINiw`DhR z(#a}Phy_~yr93-us%~j?VTkP^^iS_s!a_Z(Q^*FC&}hMF|6N|iwqI8pEeC_1xMTq> zq9u$;Ym1KjvD#drMA{H_S!O}1FHtFcgvILyQpzBS%W=vs^1oDDxY!xLpdDI&Q}_P> DRqaba delta 600 zcmYLFO=}ZT6ulqsW9Ge?$xJenG|kwg>4%6Qjj0j@#fffQxbg=`yNatqvruqR=tk&H z-c}G@bmO9kAh=N%;t%jg2vyv=_Du-(!g-u`?z#89d%rdQCP#0|-&O&DMKEOAJlGe< z7|0VmL;Z>VaB!+p^--Om`Kqr(=lZ*f&yv&^AP_JJkQzXFXpcYxvqql{ecm@@-&jb1 z$Xg+WJrZT%;>>}+zY&n%Duzg4?poW7GkzHp9S;T-uUtL8#mSd!QtV-Q}>=v zH#^1(G=xMehPsA)tQteT0GYT9=#rr|_gsux6-U}gqc_Ag85=Ni%I=F8-+@S2sp^sI zXh%{87SJMELFAQutKRM+BD$b#*g#dd9r>`|9@bP1mbNXi_Mb02ujGL47w)s{mv@V$ z2`*R@$!{2PcP_7PPmA2rcxQy=2!@OIl(3LzDfu;n5*jT`(A`qEvE!bpd!3562V!^m zWx|lOwm1RzLp|DrNLol#A~Upw)RFQbCo~vX3>}1e8g2Zto1c3zXbBNC?1k`JWmIVk9Uojf; zMi&f<1|>!)8&$CgRf8HQ)QxHwGzp?*Be0Zw_7cHw6T)SJYm{sYJOZa9bHG;|M5(%f zOiI}^-c|4**QUo^qwt(ZO)g*n-XM&S#}{KnZe0S>`f|R2JXkN4!M;ik>snBu+VyG; zL2uNlW(_Okjy6$3e527so^)Gu;N48uDJ8kQTl4F>ku>#E(oU9jC+X^*?)xYdFrh3| zOmSN%+hs1ZvuF4-@NbXjhuh=%z1jHDlga4=_6aNH*<|{7zL?BL)A4+?c)CA17)=fq zv%}LG|ASRKI*zhCUq7B~HTJ*l{dn=^JvHMyyIc1&CH6KQ7bHle4chZSD~2>i3|!DY zg~=gBNRt8{00}8w zqDXlHN=hn30TmJjCC8S|r%%VfEgk!Bd0uWm&3;==L>%b>P>2!!QyF6uGjXFm7L( b#`h0dT@e!t*9pt^ovG2Z7tCdQV~+m=gV-;K diff --git a/build/StarcoinFramework/bytecode_modules/String.mv b/build/StarcoinFramework/bytecode_modules/String.mv index 4b51f4373525345475828b2193f430dc1ee0f914..a718cd408f0896e17de2b6da730b431dfe2a7a7c 100644 GIT binary patch delta 155 zcmbQwzJlFwq0DP;HUKf&xN(!W-9}Vq~&loLt2u&nPf?7E_!&6B8FB0|O%q zH-i9!1tSyCa0U@W5Qm42iw&q!oY@(uGMZVIotcM`mCJ%aJq*zWH>Bki-_5%lb&5*a7ob>)F1C=Z@d^cI)v;m55f!O9+zQ9gSP{&1 JwK7!e{R1+R8W8{h diff --git a/build/StarcoinFramework/bytecode_modules/TransactionManager.mv b/build/StarcoinFramework/bytecode_modules/TransactionManager.mv index 04b09867267e7ad0d560384b428c5088bd8349e3..6623b37c6cdd5c49a871d28bdcfee4f014846789 100644 GIT binary patch delta 724 zcmZ`$zl#$=6n<}Ze(lWeW+$7UdZ)>myQrrD&n6(q1(5?Ag~+wb8rKkrmypegSEaSE zIZ|4Qt(A6mwzmEe7Gh%~h=sF34$&CXcYy> znv@XKxkBol(+K3ehafim0G!PNg1LYpg1U$iQr^J8VlzkFD%myer80tU@d~hQtbp8+ zau={&wWIK|jG%C(5`lZQhEUkGop3!tjBf%{Frg`%)6dgu$^~?R=7s2Tk2#7sj$@Cu zXNXMxHLI`vN)R$3d1Ce zCo5q*OOwaNVLFeqK{6g44dW+CeyK2jeiWzE(ReaEPUB}cm)}V*T#?h+&vI<8*{%`)&5@@N znwtvkup5G!JG`xAp6Ng-6K&DnDoB;yWyuC`Qv}5QeL|tGjx-W@n~%b~lM`vO9hth#wFLEC?Z+Q}9oC5)~vavWhpaUS-9j z;Kd)HC&i1u$KcsRko2xBqz^^$)>Cis_Fp;ktJm#ku>g=DbXC{u!fYxkGZ2(Se5ffsW`9OD3wcG> z#P15lQZT|5WhO8NyY#g0MlyIfw$`FydM->h%(*)k??zN1X*9UAXv z9wssAo3Yz7$*v=F*$)$U5G8V!^%;#$0+nawW57Ngx;jR~+7ZLjfryc^kgpqwRdRG$ NNve_lMa$iW;15nbBU1nX delta 296 zcmZXOJx)VG421o+evZ9ah!i@ALIYQLqDu-IXd`hOBs$9QM0$icLe4<}hd|;ItZSN2 z{+SugvwoJxxAWgn05Ak)y_Ne~9`1&Bd?NecQ$6yke(^VU1p)yBqJU7ca8e~Xl%#2L zHguwU1q{!z&O2$|8eluggPF}tOf78xdgDETwH86%|6EOH_%a>w;2W>SOQTIpJ6d0E zeOc9YF|6gnb;L$4+gMg^5E?wvbfDFaiF*U&0T+HPIra+aQOE9qz@U++gCj&Dp7ZVo~M@VHss%KtWKC_c^Fl$JDc4{75SZZ=fe$m8Q`o?0Br{r-PA^uVQrLh*ZwFRk6W*xY z>N_{*-gDmcpyRdsNeuu3f{_V_fs91QJ-6QYJ2t};)9i)Q#))bd0s%Mxjs#K*WkCV^ z?bQ&_Gewuv1VNoSG!Lj42rU7OcTq+l)Jq<-UycD2K>z>% diff --git a/build/StarcoinFramework/bytecode_modules/U256.mv b/build/StarcoinFramework/bytecode_modules/U256.mv index 5114e77f7fa3bb190418c315f2b2e2fa6f316645..e923809b5f9f07f184e1012756e5235bafd57552 100644 GIT binary patch delta 411 zcmZ{gy-EW?5P)Z9_jYghe!P=t%#V@~B-kh_!WDuRf~CHJ7!d=Ck!bJ*Y(y;1!&1Rg z@BysstOR=>z)A}X8#^cQ2O>Ddvh(dXyR-A`-k8~|@{6Ycz(Y`^q_8I_&(U=*a7Dl3 zDY+jaQpa-M-b>{_$ZHwAr!$=iD)<2c6+?}HC9Q$VQOsa;&@dQdFrhv3GNBoH_VV1f|-(F|*fm4VEPT8(@R(4#~I*d0eN z{v_F|IBRehzvoqHoX`W*6c_6jBA(z+WuKLI%6%3;`gK3#=B5{?yl&+;0{+^PtbPKm CM=lcp delta 323 zcmZ{fJ4*vW6ov0=XLe?GmR&H4Mld0Sq*7EY1VIggb$*P6wWP9&Q`iZXg4o#GSPFta z!phppLhpvfLhw}g@g2^+_wGI4xn2JV1^@zrAtUV1@DJt`Gl~>x%7XzE7%|X^jo7@g(4Qt<^VL|d_}%x# nWn}=gRIiLYRQh@A)B~r|8MadmSxCKm+ecfWA=?osc`5xLF0CWX diff --git a/build/StarcoinFramework/bytecode_modules/VMConfig.mv b/build/StarcoinFramework/bytecode_modules/VMConfig.mv index d4a4038b71b1b7f39be486752cba792c6aef31b6..ec731ac18d8ecbb2a4900f0aad7b805f55fbfcb7 100644 GIT binary patch literal 4003 zcmds4OK;>v5blTFesnvTnPfA0?6QvwAaO!~asX*j5NHo@0j&@RERUyWVy(v>`H>}i zSfTwLd*Lr2xO3pf4e<{+aNvN%FQD3EPlA(@h_sO+T5{X{Rdv-@)m=S3-`)OG3POlS ziO>82-~Y(^TG-RiobTyRmixCo@L!0x)eqw5T~MNg5l$>(JA?>$9C!#kE=Y*SVBmwC zNYg3HCL{nYdYgEJ-Z9;4(DA!IA?%(c)UoapMTzwwfa$&?ZDkYck`1AN3FBvt`Ywer zb!pI-xZLKHf{aq3m{8!v_Xu;K^N9QS)1y3_C3ENKI7+fdQ?VKbM|q(?oK6c}mbw&= zbzJ3z`XnkrTvkz5l}tai*RyUX^@uHeMI)ONLr1( zMUsV85oKkxVql!qK(5?PqhhZAC5!7SpUuV%Vd#>$q11UiSVZ3>i+T}e^wHp zjO`dV%OZ(&L$GtQ15+-6?-=+zsS@%Of&~*;Iqqgdb|8bPX{t|mB3R|33gyZoa+y_6-h2FF?fA70x~PbH4$+SO4hUyVbrkO z^2yMXL{iDjRB1~g9qCF>`cg_IgQ0y$7z0)Q2Ro#S1mw(E7v9i1WPm^KSoQF3xSrVR z|6lPo4QGjZ#qp-?hUn)L^NZm(E&uJ-ypT7HKZav*T~!~mbKUrL^L(>80pRrL0%`Z> zEd(DU_%H4JzMTNk@7(qEuRGrBwvWa2aqIZM#*6WMfaG%%!8Z^bTbBbw{|f}4AozQ5 z6Ev+KZ)UEKm*DTN;0yY{Bl!DBK3`tuR}#iyVfbIP{nf&D_d~?n2M9iH)7X#lM?@dX z7M9%`l|}ef-$&w#km@&oAWZA$=eHGn0e=U=b)|GpE zYF-uZZg&0rV0OBjU0?qVg#R{zU)3+h2eb34cs@e-V|;ED4yR7T$1+#y5oI=P7P@u$ R-Fie+(A>O(5gTzv{sC>GIamMy literal 3967 zcmds4&2HpG5bhuUjk}%9OtP8DW|v*K01_v}qCJ2V6a?A>5(0z}7t1r#GqL2cBe$I; z99H`h-1f3Z9)K$^fW!gq8*t#jfmfi~Zcl=fIz-w?5iR+rzpAeK`s?a(&&zv%3y%;o zpd?_ykWU{wUo!WrBmXD*vlIO44#VHw_vLf%)fAj4VT2RMC&Y!zgNwlB0}g{t5U`Ta z+=Sy2BEf?m07~zf+kInyBP4`95QO?67z489$&iJNpEnu?6#6uvQQs19ms1KhN5pnRg;8ZauhJrqwe{Z4lPWz`o4(A|)3}YGtH^Xt*Cra!I#^}J zEXm@vS{LP6e4@&Dc2+5{>gr9z_Owi`$NoCaivd zOiWL@(Vz|}n6Kg`a4*W;g<2+cR>jGDUetLNn^D^r)rEnfl?h&@iPH)0r#gn%l?Ts- zIvv2{ILR_~wwJ*2mQ}n`xzd0p?TU|2>RFcRW4^<8 z`5nH;C!8`i<@=m5K7jHInI90&=v}C9Q|0fCJjXTrrD+oOfd{bd2qGPid_OZ=fk+On z!$4AZJn|(K)R_d5x%(ry3+6l!+=H#qw5jBtW8b|&_wrp62DaJeC9o#Jh2st1ZhJtc zb=(l~9>NARZA=(7>~=yj8VDk&U}mUrg(rLwh=B-&5K=@V_c37%T=`$@5H@bxB#Fp* z&~BO|=TjH(XC1p9-gP$vt^fZOw=$dy^_u6K*}~}SiRH!c+or!Q(M!5v{4pGx*LD4| zI5&;oG|zYKX71O|9R!~s_-|H-ew+yL$8@{t`QCJVY+j$)#C?4*J{bNMqUSb(Zy`9g zE(eJJHwZpM@DJ^0qCel<915ZJ@kcFu3I7wpKe7V#kuON)W!tj4+@9TwC`5}_^ zV+5aAIs0sWLHse*FqLnWn(%eMi_9xQeg({*1JnBYylUY~_y-7%<^2PxszW3WhCfIA zZLwYAxjB_}+unZNuZwply}mwJobII8_kRcBzl-44&5QBD;=C@NPZ0hXpIe2)uTR6r cF-Pn%WiAv8-MRX#Jti`0PU6v+jX5L#0&`?Gj{pDw diff --git a/build/StarcoinFramework/bytecode_modules/Vector.mv b/build/StarcoinFramework/bytecode_modules/Vector.mv index fca0c13f9fa22089f35b632ccb13ea8f3c0c1427..ccd5d44b8211f0b9f46c6068eb77bcec872b8cba 100644 GIT binary patch delta 394 zcmYk2u}T9$5Qb-FcklLg<}fiAPcfB|gn*>6nbN`+uo5I7h}ilPDp&~0^#MB@3oGBk z+R9cT;0xF|xgun$*>89M*>8V}&tmdCSa1da5rG`tpufZIFvsisfxa*wc5><&sID|hY~hEi3&o+Y z+tsfdkcOu6qnT1=AtAHlZEZ;idu8N83#K(nVJGFwpJ{8~U)U4OOp)_ieDce7=x5=i nT>APpwwe3-P>XPBG90Nwg1*h+GQm`F6<(XPc`|7-BPRFPMa@gAH2|XM+wx&KRM1N{RFhPb&7^wpUtJ?040;u7IIoUAORiSrY_{F?$ny)5}OUZ58 zR9_|wOUqj9pg)nGn!1**H?c0xZ6%)L%GXDBb7wg&3Rnt9sn}rWX>L#5aWcoYjY~bX h>0agCnKH4b9ulmnEhhm+r7SL_%C5Lf2MWJ01b;C>E3*Iq diff --git a/build/StarcoinFramework/docs/ACL.md b/build/StarcoinFramework/docs/ACL.md deleted file mode 100644 index acad22c6..00000000 --- a/build/StarcoinFramework/docs/ACL.md +++ /dev/null @@ -1,205 +0,0 @@ - - - -# Module `0x1::ACL` - -Access control list (acl) module. An acl is a list of account addresses who -have the access permission to a certain object. -This module uses a vector to represent the list, but can be refactored to -use a "set" instead when it's available in the language in the future. - - -- [Struct `ACL`](#0x1_ACL_ACL) -- [Constants](#@Constants_0) -- [Function `empty`](#0x1_ACL_empty) -- [Function `add`](#0x1_ACL_add) -- [Function `remove`](#0x1_ACL_remove) -- [Function `contains`](#0x1_ACL_contains) -- [Function `assert_contains`](#0x1_ACL_assert_contains) - - -

use 0x1::Errors;
-use 0x1::Vector;
-
- - - - - -## Struct `ACL` - - - -
struct ACL has copy, drop, store
-
- - - -
-Fields - - -
-
-list: vector<address> -
-
- -
-
- - -
- - - -## Constants - - - - -The ACL already contains the address. - - -
const ECONTAIN: u64 = 0;
-
- - - - - -The ACL does not contain the address. - - -
const ENOT_CONTAIN: u64 = 1;
-
- - - - - -## Function `empty` - -Return an empty ACL. - - -
public fun empty(): ACL::ACL
-
- - - -
-Implementation - - -
public fun empty(): ACL {
-    ACL{ list: Vector::empty<address>() }
-}
-
- - - -
- - - -## Function `add` - -Add the address to the ACL. - - -
public fun add(acl: &mut ACL::ACL, addr: address)
-
- - - -
-Implementation - - -
public fun add(acl: &mut ACL, addr: address) {
-    assert!(!Vector::contains(&mut acl.list, &addr), Errors::invalid_argument(ECONTAIN));
-    Vector::push_back(&mut acl.list, addr);
-}
-
- - - -
- - - -## Function `remove` - -Remove the address from the ACL. - - -
public fun remove(acl: &mut ACL::ACL, addr: address)
-
- - - -
-Implementation - - -
public fun remove(acl: &mut ACL, addr: address) {
-    let (found, index) = Vector::index_of(&mut acl.list, &addr);
-    assert!(found, Errors::invalid_argument(ENOT_CONTAIN));
-    Vector::remove(&mut acl.list, index);
-}
-
- - - -
- - - -## Function `contains` - -Return true iff the ACL contains the address. - - -
public fun contains(acl: &ACL::ACL, addr: address): bool
-
- - - -
-Implementation - - -
public fun contains(acl: &ACL, addr: address): bool {
-    Vector::contains(&acl.list, &addr)
-}
-
- - - -
- - - -## Function `assert_contains` - -assert! that the ACL has the address. - - -
public fun assert_contains(acl: &ACL::ACL, addr: address)
-
- - - -
-Implementation - - -
public fun assert_contains(acl: &ACL, addr: address) {
-    assert!(contains(acl, addr), Errors::invalid_argument(ENOT_CONTAIN));
-}
-
- - - -
diff --git a/build/StarcoinFramework/docs/Account.md b/build/StarcoinFramework/docs/Account.md deleted file mode 100644 index 8dd831d9..00000000 --- a/build/StarcoinFramework/docs/Account.md +++ /dev/null @@ -1,3464 +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) -- [Struct `RotateAuthKeyEvent`](#0x1_Account_RotateAuthKeyEvent) -- [Struct `ExtractWithdrawCapEvent`](#0x1_Account_ExtractWithdrawCapEvent) -- [Struct `SignerDelegateEvent`](#0x1_Account_SignerDelegateEvent) -- [Resource `EventStore`](#0x1_Account_EventStore) -- [Constants](#@Constants_0) -- [Function `remove_signer_capability`](#0x1_Account_remove_signer_capability) -- [Function `get_genesis_capability`](#0x1_Account_get_genesis_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 `create_account_with_initial_amount_entry`](#0x1_Account_create_account_with_initial_amount_entry) -- [Function `create_delegate_account`](#0x1_Account_create_delegate_account) -- [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 `rotate_authentication_key_entry`](#0x1_Account_rotate_authentication_key_entry) -- [Function `do_rotate_authentication_key`](#0x1_Account_do_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 `accept_token_entry`](#0x1_Account_accept_token_entry) -- [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_entry`](#0x1_Account_set_auto_accept_token_entry) -- [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) -- [Function `remove_zero_balance_entry`](#0x1_Account_remove_zero_balance_entry) -- [Function `remove_zero_balance`](#0x1_Account_remove_zero_balance) -- [Function `make_event_store_if_not_exist`](#0x1_Account_make_event_store_if_not_exist) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::Authenticator;
-use 0x1::BCS;
-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
-
- - - -
-Fields - - -
-
-authentication_key: vector<u8> -
-
- The current authentication key. - This can be different than the key used to create the account -
-
-withdrawal_capability: Option::Option<Account::WithdrawCapability> -
-
- A 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> -
-
- A 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> -
-
- event handle for account balance withdraw event -
-
-deposit_events: Event::EventHandle<Account::DepositEvent> -
-
- event handle for account balance deposit event -
-
-accept_token_events: Event::EventHandle<Account::AcceptTokenEvent> -
-
- Event handle for accept_token event -
-
-sequence_number: u64 -
-
- The current sequence number. - Incremented by one each time a transaction is submitted -
-
- - -
- - - -## Resource `Balance` - -A resource that holds the tokens stored in this account - - -
struct Balance<TokenType> has key
-
- - - -
-Fields - - -
-
-token: Token::Token<TokenType> -
-
- -
-
- - -
- - - -## Struct `WithdrawCapability` - -The holder of WithdrawCapability for account_address can withdraw Token from -account_address/Account::Account/balance. -There is at most one WithdrawCapability in existence for a given address. - - -
struct WithdrawCapability has store
-
- - - -
-Fields - - -
-
-account_address: address -
-
- -
-
- - -
- - - -## Struct `KeyRotationCapability` - -The holder of KeyRotationCapability for account_address can rotate the authentication key for -account_address (i.e., write to account_address/Account::Account/authentication_key). -There is at most one KeyRotationCapability in existence for a given address. - - -
struct KeyRotationCapability has store
-
- - - -
-Fields - - -
-
-account_address: address -
-
- -
-
- - -
- - - -## Struct `WithdrawEvent` - -Message for balance withdraw event. - - -
struct WithdrawEvent has drop, store
-
- - - -
-Fields - - -
-
-amount: u128 -
-
- The amount of Token sent -
-
-token_code: Token::TokenCode -
-
- The code symbol for the token that was sent -
-
-metadata: vector<u8> -
-
- Metadata associated with the withdraw -
-
- - -
- - - -## Struct `DepositEvent` - -Message for balance deposit event. - - -
struct DepositEvent has drop, store
-
- - - -
-Fields - - -
-
-amount: u128 -
-
- The amount of Token sent -
-
-token_code: Token::TokenCode -
-
- The code symbol for the token that was sent -
-
-metadata: vector<u8> -
-
- Metadata associated with the deposit -
-
- - -
- - - -## Struct `AcceptTokenEvent` - -Message for accept token events - - -
struct AcceptTokenEvent has drop, store
-
- - - -
-Fields - - -
-
-token_code: Token::TokenCode -
-
- -
-
- - -
- - - -## Resource `SignerDelegated` - - - -
struct SignerDelegated has key
-
- - - -
-Fields - - -
-
-dummy_field: bool -
-
- -
-
- - -
- - - -## Struct `SignerCapability` - - - -
struct SignerCapability has store
-
- - - -
-Fields - - -
-
-addr: address -
-
- -
-
- - -
- - - -## Resource `AutoAcceptToken` - - - -
struct AutoAcceptToken has key
-
- - - -
-Fields - - -
-
-enable: bool -
-
- -
-
- - -
- - - -## Struct `RotateAuthKeyEvent` - -Message for rotate_authentication_key events - - -
struct RotateAuthKeyEvent has drop, store
-
- - - -
-Fields - - -
-
-account_address: address -
-
- -
-
-new_auth_key: vector<u8> -
-
- -
-
- - -
- - - -## Struct `ExtractWithdrawCapEvent` - -Message for extract_withdraw_capability events - - -
struct ExtractWithdrawCapEvent has drop, store
-
- - - -
-Fields - - -
-
-account_address: address -
-
- -
-
- - -
- - - -## Struct `SignerDelegateEvent` - -Message for SignerDelegate events - - -
struct SignerDelegateEvent has drop, store
-
- - - -
-Fields - - -
-
-account_address: address -
-
- -
-
- - -
- - - -## Resource `EventStore` - - - -
struct EventStore has key
-
- - - -
-Fields - - -
-
-rotate_auth_key_events: Event::EventHandle<Account::RotateAuthKeyEvent> -
-
- Event handle for rotate_authentication_key event -
-
-extract_withdraw_cap_events: Event::EventHandle<Account::ExtractWithdrawCapEvent> -
-
- Event handle for extract_withdraw_capability event -
-
-signer_delegate_events: Event::EventHandle<Account::SignerDelegateEvent> -
-
- Event handle for signer delegated event -
-
- - -
- - - -## Constants - - - - - - -
const MAX_U64: u128 = 18446744073709551615;
-
- - - - - - - -
const EDEPRECATED_FUNCTION: u64 = 19;
-
- - - - - - - -
const EPROLOGUE_ACCOUNT_DOES_NOT_EXIST: u64 = 0;
-
- - - - - -The address bytes length - - -
const ADDRESS_LENGTH: u64 = 16;
-
- - - - - - - -
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
-
- - - -
-Implementation - - -
public fun remove_signer_capability(signer: &signer): SignerCapability
-acquires Account, EventStore {
-    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 {});
-
-        make_event_store_if_not_exist(signer);
-        let event_store = borrow_global_mut<EventStore>(signer_addr);
-        Event::emit_event<SignerDelegateEvent>(
-            &mut event_store.signer_delegate_events,
-            SignerDelegateEvent {
-                account_address: signer_addr
-            }
-        );
-    };
-
-    let signer_cap = SignerCapability {addr: signer_addr };
-    signer_cap
-}
-
- - - -
- - - -## Function `get_genesis_capability` - - - -
public(friend) fun get_genesis_capability(): Account::SignerCapability
-
- - - -
-Implementation - - -
public (friend) fun get_genesis_capability():SignerCapability{
-    let signer_cap = SignerCapability {addr: Token::token_address<STC>() };
-    signer_cap
-}
-
- - - -
- - - -## Function `create_signer_with_cap` - - - -
public fun create_signer_with_cap(cap: &Account::SignerCapability): signer
-
- - - -
-Implementation - - -
public fun create_signer_with_cap(cap: &SignerCapability): signer {
-    create_signer(cap.addr)
-}
-
- - - -
- - - -## Function `destroy_signer_cap` - - - -
public fun destroy_signer_cap(cap: Account::SignerCapability)
-
- - - -
-Implementation - - -
public fun destroy_signer_cap(cap: SignerCapability) {
-    let SignerCapability {addr: _} = cap;
-}
-
- - - -
- - - -## Function `signer_address` - - - -
public fun signer_address(cap: &Account::SignerCapability): address
-
- - - -
-Implementation - - -
public fun signer_address(cap: &SignerCapability): address {
-    cap.addr
-}
-
- - - -
- - - -## Function `is_signer_delegated` - - - -
public fun is_signer_delegated(addr: address): bool
-
- - - -
-Implementation - - -
public fun is_signer_delegated(addr: address): bool {
-    exists<SignerDelegated>(addr)
-}
-
- - - -
- - - -## Function `create_genesis_account` - -Create an genesis account at new_account_address and return signer. -Genesis authentication_key is zero bytes. - - -
public fun create_genesis_account(new_account_address: address): signer
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
aborts_if !Timestamp::is_genesis();
-aborts_if len(DUMMY_AUTH_KEY) != 32;
-aborts_if exists<Account>(new_account_address);
-
- - - -
- - - -## Function `release_genesis_signer` - -Release genesis account signer - - -
public fun release_genesis_signer(_genesis_account: signer)
-
- - - -
-Implementation - - -
public fun release_genesis_signer(_genesis_account: signer){
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `create_account` - -Deprecated since @v5 - - -
public fun create_account<TokenType: store>(_authentication_key: vector<u8>): address
-
- - - -
-Implementation - - -
public fun create_account<TokenType: store>(_authentication_key: vector<u8>): address {
-    abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
- - - -
- -
-Specification - - - -
aborts_if true;
-
- - - -
- - - -## Function `create_account_with_address` - -Creates a new account at 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)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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>)
-
- - - -
-Implementation - - -
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});
-    move_to(new_account, EventStore {
-          rotate_auth_key_events: Event::new_event_handle<RotateAuthKeyEvent>(new_account),
-          extract_withdraw_cap_events: Event::new_event_handle<ExtractWithdrawCapEvent>(new_account),
-          signer_delegate_events: Event::new_event_handle<SignerDelegateEvent>(new_account),
-    });
-}
-
- - - -
- -
-Specification - - - -
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_signer` - - - -
fun create_signer(addr: address): signer
-
- - - -
-Implementation - - -
native fun create_signer(addr: address): signer;
-
- - - -
- - - -## Function `create_account_with_initial_amount` - - - -
public entry fun create_account_with_initial_amount<TokenType: store>(account: signer, fresh_address: address, _auth_key: vector<u8>, initial_amount: u128)
-
- - - -
-Implementation - - -
public entry 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_entry<TokenType>(account, fresh_address, initial_amount);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `create_account_with_initial_amount_v2` - - - -
public entry fun create_account_with_initial_amount_v2<TokenType: store>(account: signer, fresh_address: address, initial_amount: u128)
-
- - - -
-Implementation - - -
public entry fun create_account_with_initial_amount_v2<TokenType: store>(account: signer, fresh_address: address, initial_amount: u128)
-acquires Account, Balance, AutoAcceptToken {
-    create_account_with_initial_amount_entry<TokenType>(account, fresh_address, initial_amount);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `create_account_with_initial_amount_entry` - - - -
public entry fun create_account_with_initial_amount_entry<TokenType: store>(account: signer, fresh_address: address, initial_amount: u128)
-
- - - -
-Implementation - - -
public entry fun create_account_with_initial_amount_entry<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);
-    };
-}
-
- - - -
- - - -## Function `create_delegate_account` - -Generate an new address and create a new account, then delegate the account and return the new account address and SignerCapability - - -
public fun create_delegate_account(sender: &signer): (address, Account::SignerCapability)
-
- - - -
-Implementation - - -
public fun create_delegate_account(sender: &signer) : (address, SignerCapability) acquires Balance, Account, EventStore {
-    let sender_address = Signer::address_of(sender);
-    let sequence_number = Self::sequence_number(sender_address);
-    // use stc balance as part of seed, just for new address more random.
-    let stc_balance = Self::balance<STC>(sender_address);
-
-    let seed_bytes = BCS::to_bytes(&sender_address);
-    Vector::append(&mut seed_bytes, BCS::to_bytes(&sequence_number));
-    Vector::append(&mut seed_bytes, BCS::to_bytes(&stc_balance));
-
-    let seed_hash = Hash::sha3_256(seed_bytes);
-    let i = 0;
-    let address_bytes = Vector::empty();
-    while (i < ADDRESS_LENGTH) {
-        Vector::push_back(&mut address_bytes, *Vector::borrow(&seed_hash,i));
-        i = i + 1;
-    };
-    let new_address = BCS::to_address(address_bytes);
-    Self::create_account_with_address<STC>(new_address);
-    let new_signer = Self::create_signer(new_address);
-    (new_address, Self::remove_signer_capability(&new_signer))
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deposit_to_self` - -Deposits the to_deposit token into the self's account balance - - -
public fun deposit_to_self<TokenType: store>(account: &signer, to_deposit: Token::Token<TokenType>)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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` - -Deposits the 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>)
-
- - - -
-Implementation - - -
public fun deposit<TokenType: store>(
-    receiver: address,
-    to_deposit: Token<TokenType>,
-) acquires Account, Balance, AutoAcceptToken {
-    deposit_with_metadata<TokenType>(receiver, to_deposit, x"")
-}
-
- - - -
- -
-Specification - - - -
include DepositWithMetadataAbortsIf<TokenType>;
-
- - - -
- - - -## Function `deposit_with_metadata` - -Deposits the 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>)
-
- - - -
-Implementation - - -
public fun deposit_with_metadata<TokenType: store>(
-    receiver: address,
-    to_deposit: Token<TokenType>,
-    metadata: vector<u8>,
-) acquires Account, Balance, AutoAcceptToken {
-
-    if (!exists_at(receiver)) {
-        create_account_with_address<TokenType>(receiver);
-    };
-
-    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);
-    };
-}
-
- - - -
- -
-Specification - - - -
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` - -Helper to deposit amount to the given account balance - - -
fun deposit_to_balance<TokenType: store>(balance: &mut Account::Balance<TokenType>, token: Token::Token<TokenType>)
-
- - - -
-Implementation - - -
fun deposit_to_balance<TokenType: store>(balance: &mut Balance<TokenType>, token: Token::Token<TokenType>) {
-    Token::deposit(&mut balance.token, token)
-}
-
- - - -
- -
-Specification - - - -
aborts_if balance.token.value + token.value > MAX_U128;
-
- - - -
- - - -## Function `withdraw_from_balance` - -Helper to withdraw amount from the given account balance and return the withdrawn Token - - -
fun withdraw_from_balance<TokenType: store>(balance: &mut Account::Balance<TokenType>, amount: u128): Token::Token<TokenType>
-
- - - -
-Implementation - - -
fun withdraw_from_balance<TokenType: store>(balance: &mut Balance<TokenType>, amount: u128): Token<TokenType>{
-    Token::withdraw(&mut balance.token, amount)
-}
-
- - - -
- -
-Specification - - - -
aborts_if balance.token.value < amount;
-
- - - -
- - - -## Function `withdraw` - -Withdraw amount Token from the account balance - - -
public fun withdraw<TokenType: store>(account: &signer, amount: u128): Token::Token<TokenType>
-
- - - -
-Implementation - - -
public fun withdraw<TokenType: store>(account: &signer, amount: u128): Token<TokenType>
-acquires Account, Balance {
-    withdraw_with_metadata<TokenType>(account, amount, x"")
-}
-
- - - -
- -
-Specification - - - -
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` - -Withdraw amount tokens from signer with given metadata. - - -
public fun withdraw_with_metadata<TokenType: store>(account: &signer, amount: u128, metadata: vector<u8>): Token::Token<TokenType>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
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` - -Withdraw amount Token from the account under cap.account_address with no metadata - - -
public fun withdraw_with_capability<TokenType: store>(cap: &Account::WithdrawCapability, amount: u128): Token::Token<TokenType>
-
- - - -
-Implementation - - -
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"")
-}
-
- - - -
- -
-Specification - - - -
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` - -Withdraw amount Token from the account under cap.account_address with metadata - - -
public fun withdraw_with_capability_and_metadata<TokenType: store>(cap: &Account::WithdrawCapability, amount: u128, metadata: vector<u8>): Token::Token<TokenType>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
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` - -Return a unique capability granting permission to withdraw from the sender's account balance. - - -
public fun extract_withdraw_capability(sender: &signer): Account::WithdrawCapability
-
- - - -
-Implementation - - -
public fun extract_withdraw_capability(
-    sender: &signer
-): WithdrawCapability acquires Account, EventStore {
-    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));
-
-    make_event_store_if_not_exist(sender);
-    let event_store = borrow_global_mut<EventStore>(sender_addr);
-    Event::emit_event<ExtractWithdrawCapEvent>(
-        &mut event_store.extract_withdraw_cap_events,
-        ExtractWithdrawCapEvent {
-            account_address: sender_addr,
-        }
-    );
-    let account = borrow_global_mut<Account>(sender_addr);
-    Option::extract(&mut account.withdrawal_capability)
-}
-
- - - -
- -
-Specification - - - -
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` - -Return the withdraw capability to the account it originally came from - - -
public fun restore_withdraw_capability(cap: Account::WithdrawCapability)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
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>)
-
- - - -
-Implementation - - -
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,
-    });
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Account>(account);
-
- - - -
- - - -## Function `emit_account_deposit_event` - - - -
fun emit_account_deposit_event<TokenType: store>(account: address, amount: u128, metadata: vector<u8>)
-
- - - -
-Implementation - - -
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,
-    });
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Account>(account);
-
- - - -
- - - -## Function `pay_from_capability` - -Withdraws amount Token using the passed in WithdrawCapability, and deposits it -into the payee'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>)
-
- - - -
-Implementation - - -
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,
-    );
-}
-
- - - -
- -
-Specification - - - -
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` - -Withdraw amount Token from the transaction sender's -account balance and send the token to the payee 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>)
-
- - - -
-Implementation - - -
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,
-    );
-}
-
- - - -
- -
-Specification - - - -
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` - -Withdraw amount Token from the transaction sender's -account balance and send the token to the payee address -Creates the payee account if it does not exist - - -
public fun pay_from<TokenType: store>(account: &signer, payee: address, amount: u128)
-
- - - -
-Implementation - - -
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"");
-}
-
- - - -
- -
-Specification - - - -
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` - -Rotate the authentication key for the account under cap.account_address - - -
public fun rotate_authentication_key_with_capability(cap: &Account::KeyRotationCapability, new_authentication_key: vector<u8>)
-
- - - -
-Implementation - - -
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;
-}
-
- - - -
- -
-Specification - - - -
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` - -Return a unique capability granting permission to rotate the sender's authentication key - - -
public fun extract_key_rotation_capability(account: &signer): Account::KeyRotationCapability
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
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` - -Return the key rotation capability to the account it originally came from - - -
public fun restore_key_rotation_capability(cap: Account::KeyRotationCapability)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
aborts_if Option::is_some(global<Account>(cap.account_address).key_rotation_capability);
-aborts_if !exists<Account>(cap.account_address);
-
- - - -
- - - -## Function `destroy_key_rotation_capability` - - - -
public fun destroy_key_rotation_capability(cap: Account::KeyRotationCapability)
-
- - - -
-Implementation - - -
public fun destroy_key_rotation_capability(cap: KeyRotationCapability) {
-    let KeyRotationCapability {account_address: _} = cap;
-}
-
- - - -
- - - -## Function `rotate_authentication_key` - - - -
public entry fun rotate_authentication_key(account: signer, new_key: vector<u8>)
-
- - - -
-Implementation - - -
public entry fun rotate_authentication_key(account: signer, new_key: vector<u8>) acquires Account, EventStore {
-    rotate_authentication_key_entry(account, new_key);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `rotate_authentication_key_entry` - - - -
public entry fun rotate_authentication_key_entry(account: signer, new_key: vector<u8>)
-
- - - -
-Implementation - - -
public entry fun rotate_authentication_key_entry(account: signer, new_key: vector<u8>) acquires Account, EventStore {
-    do_rotate_authentication_key(&account, new_key);
-}
-
- - - -
- - - -## Function `do_rotate_authentication_key` - - - -
public fun do_rotate_authentication_key(account: &signer, new_key: vector<u8>)
-
- - - -
-Implementation - - -
public fun do_rotate_authentication_key(account: &signer, new_key: vector<u8>) acquires Account, EventStore {
-    let key_rotation_capability = extract_key_rotation_capability(account);
-    rotate_authentication_key_with_capability(&key_rotation_capability, copy new_key);
-    restore_key_rotation_capability(key_rotation_capability);
-
-    make_event_store_if_not_exist(account);
-    let signer_addr = Signer::address_of(account);
-    let event_store = borrow_global_mut<EventStore>(signer_addr);
-    Event::emit_event<RotateAuthKeyEvent>(
-        &mut event_store.rotate_auth_key_events,
-        RotateAuthKeyEvent {
-            account_address: signer_addr,
-            new_auth_key: new_key,
-        }
-    );
-}
-
- - - -
- - - -## Function `balance_for` - -Helper to return the u128 value of the balance for account - - -
fun balance_for<TokenType: store>(balance: &Account::Balance<TokenType>): u128
-
- - - -
-Implementation - - -
fun balance_for<TokenType: store>(balance: &Balance<TokenType>): u128 {
-    Token::value<TokenType>(&balance.token)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `balance` - -Return the current TokenType balance of the account at addr. - - -
public fun balance<TokenType: store>(addr: address): u128
-
- - - -
-Implementation - - -
public fun balance<TokenType: store>(addr: address): u128 acquires Balance {
-    if (exists<Balance<TokenType>>(addr)) {
-        balance_for(borrow_global<Balance<TokenType>>(addr))
-    } else {
-        0u128
-    }
-}
-
- - - -
- - - -## Function `do_accept_token` - -Add a balance of Token type to the sending account. - - -
public fun do_accept_token<TokenType: store>(account: &signer)
-
- - - -
-Implementation - - -
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,
-        },
-    );
-}
-
- - - -
- -
-Specification - - - -
aborts_if exists<Balance<TokenType>>(Signer::address_of(account));
-aborts_if !exists<Account>(Signer::address_of(account));
-
- - - -
- - - -## Function `accept_token` - - - -
public entry fun accept_token<TokenType: store>(account: signer)
-
- - - -
-Implementation - - -
public entry fun accept_token<TokenType: store>(account: signer) acquires Account {
-    accept_token_entry<TokenType>(account);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `accept_token_entry` - - - -
public entry fun accept_token_entry<TokenType: store>(account: signer)
-
- - - -
-Implementation - - -
public entry fun accept_token_entry<TokenType: store>(account: signer) acquires Account {
-    do_accept_token<TokenType>(&account);
-}
-
- - - -
- - - -## Function `is_accepts_token` - -This is a alias of is_accept_token - - -
public fun is_accepts_token<TokenType: store>(addr: address): bool
-
- - - -
-Implementation - - -
public fun is_accepts_token<TokenType: store>(addr: address): bool acquires AutoAcceptToken {
-    Self::is_accept_token<TokenType>(addr)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - - -
aborts_if false;
-
- - - -
- - - -## Function `is_accept_token` - -Return whether the account at addr accept Token type tokens - - -
public fun is_accept_token<TokenType: store>(addr: address): bool
-
- - - -
-Implementation - - -
public fun is_accept_token<TokenType: store>(addr: address): bool acquires AutoAcceptToken {
-    if (can_auto_accept_token(addr)) {
-        true
-    } else {
-        exists<Balance<TokenType>>(addr)
-    }
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `can_auto_accept_token` - -Check whether the address can auto accept token. - - -
public fun can_auto_accept_token(addr: address): bool
-
- - - -
-Implementation - - -
public fun can_auto_accept_token(addr: address): bool acquires AutoAcceptToken {
-    if (exists<AutoAcceptToken>(addr)) {
-        borrow_global<AutoAcceptToken>(addr).enable
-    } else {
-        false
-    }
-}
-
- - - -
- - - -## Function `set_auto_accept_token_entry` - - - -
public entry fun set_auto_accept_token_entry(account: signer, enable: bool)
-
- - - -
-Implementation - - -
public entry fun set_auto_accept_token_entry(account: signer, enable: bool) acquires AutoAcceptToken {
-    set_auto_accept_token(&account, enable);
-}
-
- - - -
- - - -## Function `set_auto_accept_token` - -Configure whether auto-accept tokens. - - -
public fun set_auto_accept_token(account: &signer, enable: bool)
-
- - - -
-Implementation - - -
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});
-    };
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `try_accept_token` - -try to accept token for addr. - - -
fun try_accept_token<TokenType: store>(addr: address)
-
- - - -
-Implementation - - -
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)
-        }
-    };
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `sequence_number_for_account` - -Helper to return the sequence number field for given account - - -
fun sequence_number_for_account(account: &Account::Account): u64
-
- - - -
-Implementation - - -
fun sequence_number_for_account(account: &Account): u64 {
-    account.sequence_number
-}
-
- - - -
- - - -## Function `sequence_number` - -Return the current sequence number at addr - - -
public fun sequence_number(addr: address): u64
-
- - - -
-Implementation - - -
public fun sequence_number(addr: address): u64 acquires Account {
-    sequence_number_for_account(borrow_global<Account>(addr))
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Account>(addr);
-
- - - -
- - - -## Function `authentication_key` - -Return the authentication key for this account - - -
public fun authentication_key(addr: address): vector<u8>
-
- - - -
-Implementation - - -
public fun authentication_key(addr: address): vector<u8> acquires Account {
-    *&borrow_global<Account>(addr).authentication_key
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Account>(addr);
-
- - - -
- - - -## Function `delegated_key_rotation_capability` - -Return true if the account at addr has delegated its key rotation capability - - -
public fun delegated_key_rotation_capability(addr: address): bool
-
- - - -
-Implementation - - -
public fun delegated_key_rotation_capability(addr: address): bool
-acquires Account {
-    Option::is_none(&borrow_global<Account>(addr).key_rotation_capability)
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Account>(addr);
-
- - - -
- - - -## Function `delegated_withdraw_capability` - -Return true if the account at addr has delegated its withdraw capability - - -
public fun delegated_withdraw_capability(addr: address): bool
-
- - - -
-Implementation - - -
public fun delegated_withdraw_capability(addr: address): bool
-acquires Account {
-    Option::is_none(&borrow_global<Account>(addr).withdrawal_capability)
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Account>(addr);
-
- - - -
- - - -## Function `withdraw_capability_address` - -Return a reference to the address associated with the given withdraw capability - - -
public fun withdraw_capability_address(cap: &Account::WithdrawCapability): &address
-
- - - -
-Implementation - - -
public fun withdraw_capability_address(cap: &WithdrawCapability): &address {
-    &cap.account_address
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `key_rotation_capability_address` - -Return a reference to the address associated with the given key rotation capability - - -
public fun key_rotation_capability_address(cap: &Account::KeyRotationCapability): &address
-
- - - -
-Implementation - - -
public fun key_rotation_capability_address(cap: &KeyRotationCapability): &address {
-    &cap.account_address
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `exists_at` - -Checks if an account exists at check_addr - - -
public fun exists_at(check_addr: address): bool
-
- - - -
-Implementation - - -
public fun exists_at(check_addr: address): bool {
-    exists<Account>(check_addr)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `is_dummy_auth_key` - - - -
fun is_dummy_auth_key(account: &Account::Account): bool
-
- - - -
-Implementation - - -
fun is_dummy_auth_key(account: &Account): bool {
-    *&account.authentication_key == DUMMY_AUTH_KEY
-}
-
- - - -
- - - -## Function `txn_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 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)
-
- - - -
-Implementation - - -
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));
-}
-
- - - -
- -
-Specification - - - -
aborts_if Signer::address_of(account) != CoreAddresses::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` - -The epilogue is invoked at the end of transactions. -It collects gas and bumps the sequence number - - -
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)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `txn_epilogue_v2` - -The epilogue is invoked at the end of transactions. -It collects gas and bumps the sequence number - - -
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)
-
- - - -
-Implementation - - -
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);
-    };
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-aborts_if Signer::address_of(account) != CoreAddresses::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::GENESIS_ADDRESS());
-aborts_if txn_gas_price * (txn_max_gas_units - gas_units_remaining) > 0 &&
-        global<TransactionFee::TransactionFee<TokenType>>(CoreAddresses::GENESIS_ADDRESS()).fee.value + txn_gas_price * (txn_max_gas_units - gas_units_remaining) > max_u128();
-
- - - -
- - - -## Function `remove_zero_balance_entry` - - - -
public entry fun remove_zero_balance_entry<TokenType: store>(account: signer)
-
- - - -
-Implementation - - -
public entry fun remove_zero_balance_entry<TokenType: store>(account: signer) acquires Balance {
-    remove_zero_balance<TokenType>(&account);
-}
-
- - - -
- - - -## Function `remove_zero_balance` - -Remove zero Balance - - -
public fun remove_zero_balance<TokenType: store>(account: &signer)
-
- - - -
-Implementation - - -
public fun remove_zero_balance<TokenType: store>(account: &signer) acquires Balance {
-    let addr: address = Signer::address_of(account);
-    let Balance<TokenType> { token } = move_from<Balance<TokenType>>(addr);
-    Token::destroy_zero<TokenType>(token);
-}
-
- - - -
- -
-Specification - - - -
let addr = Signer::address_of(account);
-aborts_if !exists<Balance<TokenType>>(addr);
-ensures !exists<Balance<TokenType>>(addr);
-
- - - -
- - - -## Function `make_event_store_if_not_exist` - -Make a event store if it's not exist. - - -
fun make_event_store_if_not_exist(account: &signer)
-
- - - -
-Implementation - - -
fun make_event_store_if_not_exist(account: &signer) {
-    if (!exists<EventStore>(Signer::address_of(account))) {
-        move_to(account, EventStore {
-          rotate_auth_key_events: Event::new_event_handle<RotateAuthKeyEvent>(account),
-          extract_withdraw_cap_events: Event::new_event_handle<ExtractWithdrawCapEvent>(account),
-          signer_delegate_events: Event::new_event_handle<SignerDelegateEvent>(account),
-        })
-    };
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/AccountScripts.md b/build/StarcoinFramework/docs/AccountScripts.md deleted file mode 100644 index 0b0181fa..00000000 --- a/build/StarcoinFramework/docs/AccountScripts.md +++ /dev/null @@ -1,93 +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) -- [Function `remove_zero_balance`](#0x1_AccountScripts_remove_zero_balance) - - -
use 0x1::Account;
-
- - - - - -## Function `enable_auto_accept_token` - -Enable account's auto-accept-token feature. -The script function is reenterable. - - -
public entry fun enable_auto_accept_token(account: signer)
-
- - - -
-Implementation - - -
public entry fun enable_auto_accept_token(account: signer) {
-    Account::set_auto_accept_token_entry(account, true);
-}
-
- - - -
- - - -## Function `disable_auto_accept_token` - -Disable account's auto-accept-token feature. -The script function is reenterable. - - -
public entry fun disable_auto_accept_token(account: signer)
-
- - - -
-Implementation - - -
public entry fun disable_auto_accept_token(account: signer) {
-    Account::set_auto_accept_token_entry(account, false);
-}
-
- - - -
- - - -## Function `remove_zero_balance` - -Remove zero Balance - - -
public entry fun remove_zero_balance<TokenType: store>(account: signer)
-
- - - -
-Implementation - - -
public entry fun remove_zero_balance<TokenType: store>(account: signer) {
-    Account::remove_zero_balance_entry<TokenType>(account);
-}
-
- - - -
diff --git a/build/StarcoinFramework/docs/Authenticator.md b/build/StarcoinFramework/docs/Authenticator.md deleted file mode 100644 index baad0a7d..00000000 --- a/build/StarcoinFramework/docs/Authenticator.md +++ /dev/null @@ -1,448 +0,0 @@ - - - -# Module `0x1::Authenticator` - -Move representation of the authenticator types -- Ed25519 (single-sig) -- MultiEd25519 (K-of-N multisig) - - -- [Struct `MultiEd25519PublicKey`](#0x1_Authenticator_MultiEd25519PublicKey) -- [Constants](#@Constants_0) -- [Function `create_multi_ed25519`](#0x1_Authenticator_create_multi_ed25519) -- [Function `ed25519_authentication_key`](#0x1_Authenticator_ed25519_authentication_key) -- [Function `derived_address`](#0x1_Authenticator_derived_address) -- [Function `multi_ed25519_authentication_key`](#0x1_Authenticator_multi_ed25519_authentication_key) -- [Function `public_keys`](#0x1_Authenticator_public_keys) -- [Function `threshold`](#0x1_Authenticator_threshold) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-public_keys: vector<vector<u8>> -
-
- vector of ed25519 public keys -
-
-threshold: u8 -
-
- approval threshold -
-
- - -
- - - -## Constants - - - - - - -
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
-
- - - -
-Implementation - - -
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 }
-}
-
- - - -
- -
-Specification - - - -
aborts_if threshold == 0;
-aborts_if threshold > Vector::length(public_keys);
-aborts_if Vector::length(public_keys) > 32;
-
- - - -
- - - -## Function `ed25519_authentication_key` - -Compute an authentication key for the ed25519 public key public_key - - -
public fun ed25519_authentication_key(public_key: vector<u8>): vector<u8>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
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` - -convert authentication key to address - - -
public fun derived_address(authentication_key: vector<u8>): address
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
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` - -Compute a multied25519 account authentication key for the policy k - - -
public fun multi_ed25519_authentication_key(k: &Authenticator::MultiEd25519PublicKey): vector<u8>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `public_keys` - -Return the public keys involved in the multisig policy k - - -
public fun public_keys(k: &Authenticator::MultiEd25519PublicKey): &vector<vector<u8>>
-
- - - -
-Implementation - - -
public fun public_keys(k: &MultiEd25519PublicKey): &vector<vector<u8>> {
-    &k.public_keys
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `threshold` - -Return the threshold for the multisig policy k - - -
public fun threshold(k: &Authenticator::MultiEd25519PublicKey): u8
-
- - - -
-Implementation - - -
public fun threshold(k: &MultiEd25519PublicKey): u8 {
-    *&k.threshold
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/BCS.md b/build/StarcoinFramework/docs/BCS.md deleted file mode 100644 index 9e684aac..00000000 --- a/build/StarcoinFramework/docs/BCS.md +++ /dev/null @@ -1,1599 +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. - - -- [Constants](#@Constants_0) -- [Function `to_bytes`](#0x1_BCS_to_bytes) -- [Function `to_address`](#0x1_BCS_to_address) -- [Function `deserialize_option_bytes_vector`](#0x1_BCS_deserialize_option_bytes_vector) -- [Function `deserialize_bytes_vector`](#0x1_BCS_deserialize_bytes_vector) -- [Function `deserialize_u64_vector`](#0x1_BCS_deserialize_u64_vector) -- [Function `deserialize_u128_vector`](#0x1_BCS_deserialize_u128_vector) -- [Function `deserialize_option_bytes`](#0x1_BCS_deserialize_option_bytes) -- [Function `deserialize_address`](#0x1_BCS_deserialize_address) -- [Function `deserialize_16_bytes`](#0x1_BCS_deserialize_16_bytes) -- [Function `deserialize_bytes`](#0x1_BCS_deserialize_bytes) -- [Function `deserialize_u128`](#0x1_BCS_deserialize_u128) -- [Function `deserialize_u64`](#0x1_BCS_deserialize_u64) -- [Function `deserialize_u32`](#0x1_BCS_deserialize_u32) -- [Function `deserialize_u16`](#0x1_BCS_deserialize_u16) -- [Function `deserialize_u8`](#0x1_BCS_deserialize_u8) -- [Function `deserialize_option_tag`](#0x1_BCS_deserialize_option_tag) -- [Function `deserialize_len`](#0x1_BCS_deserialize_len) -- [Function `deserialize_bool`](#0x1_BCS_deserialize_bool) -- [Function `get_byte`](#0x1_BCS_get_byte) -- [Function `get_n_bytes`](#0x1_BCS_get_n_bytes) -- [Function `get_n_bytes_as_u128`](#0x1_BCS_get_n_bytes_as_u128) -- [Function `deserialize_uleb128_as_u32`](#0x1_BCS_deserialize_uleb128_as_u32) -- [Function `serialize_u32_as_uleb128`](#0x1_BCS_serialize_u32_as_uleb128) -- [Function `skip_option_bytes_vector`](#0x1_BCS_skip_option_bytes_vector) -- [Function `skip_option_bytes`](#0x1_BCS_skip_option_bytes) -- [Function `skip_bytes_vector`](#0x1_BCS_skip_bytes_vector) -- [Function `skip_bytes`](#0x1_BCS_skip_bytes) -- [Function `skip_n_bytes`](#0x1_BCS_skip_n_bytes) -- [Function `skip_u64_vector`](#0x1_BCS_skip_u64_vector) -- [Function `skip_u128_vector`](#0x1_BCS_skip_u128_vector) -- [Function `skip_u256`](#0x1_BCS_skip_u256) -- [Function `skip_u128`](#0x1_BCS_skip_u128) -- [Function `skip_u64`](#0x1_BCS_skip_u64) -- [Function `skip_u32`](#0x1_BCS_skip_u32) -- [Function `skip_u16`](#0x1_BCS_skip_u16) -- [Function `skip_address`](#0x1_BCS_skip_address) -- [Function `skip_bool`](#0x1_BCS_skip_bool) -- [Function `can_skip`](#0x1_BCS_can_skip) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::Errors;
-use 0x1::Option;
-
- - - - - -## Constants - - - - - - -
const ERR_INPUT_NOT_LARGE_ENOUGH: u64 = 201;
-
- - - - - - - -
const ERR_INVALID_ULEB128_NUMBER_UNEXPECTED_ZERO_DIGIT: u64 = 207;
-
- - - - - - - -
const ERR_OVERFLOW_PARSING_ULEB128_ENCODED_UINT32: u64 = 206;
-
- - - - - - - -
const ERR_UNEXPECTED_BOOL_VALUE: u64 = 205;
-
- - - - - - - -
const INTEGER32_MAX_VALUE: u64 = 2147483647;
-
- - - - - -## Function `to_bytes` - -Return the binary representation of v in BCS (Starcoin Canonical Serialization) format - - -
public fun to_bytes<MoveValue>(v: &MoveValue): vector<u8>
-
- - - -
-Implementation - - -
native public fun to_bytes<MoveValue>(v: &MoveValue): vector<u8>;
-
- - - -
- - - -## Function `to_address` - -Return the address of key bytes - - -
public fun to_address(key_bytes: vector<u8>): address
-
- - - -
-Implementation - - -
native public fun to_address(key_bytes: vector<u8>): address;
-
- - - -
- - - -## Function `deserialize_option_bytes_vector` - - - -
public fun deserialize_option_bytes_vector(input: &vector<u8>, offset: u64): (vector<Option::Option<vector<u8>>>, u64)
-
- - - -
-Implementation - - -
public fun deserialize_option_bytes_vector(input: &vector<u8>, offset: u64): (vector<Option::Option<vector<u8>>>, u64) {
-    let (len, new_offset) = deserialize_len(input, offset);
-    let i = 0;
-    let vec = Vector::empty<Option::Option<vector<u8>>>();
-    while (i < len) {
-        let (opt_bs, o) = deserialize_option_bytes(input, new_offset);
-        Vector::push_back(&mut vec, opt_bs);
-        new_offset = o;
-        i = i + 1;
-    };
-    (vec, new_offset)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_bytes_vector` - - - -
public fun deserialize_bytes_vector(input: &vector<u8>, offset: u64): (vector<vector<u8>>, u64)
-
- - - -
-Implementation - - -
public fun deserialize_bytes_vector(input: &vector<u8>, offset: u64): (vector<vector<u8>>, u64) {
-    let (len, new_offset) = deserialize_len(input, offset);
-    let i = 0;
-    let vec = Vector::empty<vector<u8>>();
-    while (i < len) {
-        let (opt_bs, o) = deserialize_bytes(input, new_offset);
-        Vector::push_back(&mut vec, opt_bs);
-        new_offset = o;
-        i = i + 1;
-    };
-    (vec, new_offset)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_u64_vector` - - - -
public fun deserialize_u64_vector(input: &vector<u8>, offset: u64): (vector<u64>, u64)
-
- - - -
-Implementation - - -
public fun deserialize_u64_vector(input: &vector<u8>, offset: u64): (vector<u64>, u64) {
-    let (len, new_offset) = deserialize_len(input, offset);
-    let i = 0;
-    let vec = Vector::empty<u64>();
-    while (i < len) {
-        let (opt_bs, o) = deserialize_u64(input, new_offset);
-        Vector::push_back(&mut vec, opt_bs);
-        new_offset = o;
-        i = i + 1;
-    };
-    (vec, new_offset)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_u128_vector` - - - -
public fun deserialize_u128_vector(input: &vector<u8>, offset: u64): (vector<u128>, u64)
-
- - - -
-Implementation - - -
public fun deserialize_u128_vector(input: &vector<u8>, offset: u64): (vector<u128>, u64) {
-    let (len, new_offset) = deserialize_len(input, offset);
-    let i = 0;
-    let vec = Vector::empty<u128>();
-    while (i < len) {
-        let (opt_bs, o) = deserialize_u128(input, new_offset);
-        Vector::push_back(&mut vec, opt_bs);
-        new_offset = o;
-        i = i + 1;
-    };
-    (vec, new_offset)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_option_bytes` - - - -
public fun deserialize_option_bytes(input: &vector<u8>, offset: u64): (Option::Option<vector<u8>>, u64)
-
- - - -
-Implementation - - -
public fun deserialize_option_bytes(input: &vector<u8>, offset: u64): (Option::Option<vector<u8>>, u64) {
-    let (tag, new_offset) = deserialize_option_tag(input, offset);
-    if (!tag) {
-        return (Option::none<vector<u8>>(), new_offset)
-    } else {
-        let (bs, new_offset) = deserialize_bytes(input, new_offset);
-        return (Option::some<vector<u8>>(bs), new_offset)
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_address` - - - -
public fun deserialize_address(input: &vector<u8>, offset: u64): (address, u64)
-
- - - -
-Implementation - - -
public fun deserialize_address(input: &vector<u8>, offset: u64): (address, u64) {
-    let (content, new_offset) = deserialize_16_bytes(input, offset);
-    (BCS::to_address(content), new_offset)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_16_bytes` - - - -
public fun deserialize_16_bytes(input: &vector<u8>, offset: u64): (vector<u8>, u64)
-
- - - -
-Implementation - - -
public fun deserialize_16_bytes(input: &vector<u8>, offset: u64): (vector<u8>, u64) {
-    let content = get_n_bytes(input, offset, 16);
-    (content, offset + 16)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_bytes` - - - -
public fun deserialize_bytes(input: &vector<u8>, offset: u64): (vector<u8>, u64)
-
- - - -
-Implementation - - -
public fun deserialize_bytes(input: &vector<u8>, offset: u64): (vector<u8>, u64) {
-    let (len, new_offset) = deserialize_len(input, offset);
-    let content = get_n_bytes(input, new_offset, len);
-    (content, new_offset + len)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_u128` - - - -
public fun deserialize_u128(input: &vector<u8>, offset: u64): (u128, u64)
-
- - - -
-Implementation - - -
public fun deserialize_u128(input: &vector<u8>, offset: u64): (u128, u64) {
-    let u = get_n_bytes_as_u128(input, offset, 16);
-    (u, offset + 16)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_u64` - - - -
public fun deserialize_u64(input: &vector<u8>, offset: u64): (u64, u64)
-
- - - -
-Implementation - - -
public fun deserialize_u64(input: &vector<u8>, offset: u64): (u64, u64) {
-    let u = get_n_bytes_as_u128(input, offset, 8);
-    ((u as u64), offset + 8)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_u32` - - - -
public fun deserialize_u32(input: &vector<u8>, offset: u64): (u64, u64)
-
- - - -
-Implementation - - -
public fun deserialize_u32(input: &vector<u8>, offset: u64): (u64, u64) {
-    let u = get_n_bytes_as_u128(input, offset, 4);
-    ((u as u64), offset + 4)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_u16` - - - -
public fun deserialize_u16(input: &vector<u8>, offset: u64): (u64, u64)
-
- - - -
-Implementation - - -
public fun deserialize_u16(input: &vector<u8>, offset: u64): (u64, u64) {
-    let u = get_n_bytes_as_u128(input, offset, 2);
-    ((u as u64), offset + 2)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_u8` - - - -
public fun deserialize_u8(input: &vector<u8>, offset: u64): (u8, u64)
-
- - - -
-Implementation - - -
public fun deserialize_u8(input: &vector<u8>, offset: u64): (u8, u64) {
-    let u = get_byte(input, offset);
-    (u, offset + 1)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_option_tag` - - - -
public fun deserialize_option_tag(input: &vector<u8>, offset: u64): (bool, u64)
-
- - - -
-Implementation - - -
public fun deserialize_option_tag(input: &vector<u8>, offset: u64): (bool, u64) {
-    deserialize_bool(input, offset)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_len` - - - -
public fun deserialize_len(input: &vector<u8>, offset: u64): (u64, u64)
-
- - - -
-Implementation - - -
public fun deserialize_len(input: &vector<u8>, offset: u64): (u64, u64) {
-    deserialize_uleb128_as_u32(input, offset)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_bool` - - - -
public fun deserialize_bool(input: &vector<u8>, offset: u64): (bool, u64)
-
- - - -
-Implementation - - -
public fun deserialize_bool(input: &vector<u8>, offset: u64): (bool, u64) {
-    let b = get_byte(input, offset);
-    if (b == 1) {
-        return (true, offset + 1)
-    } else if (b == 0) {
-        return (false, offset + 1)
-    } else {
-        abort ERR_UNEXPECTED_BOOL_VALUE
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `get_byte` - - - -
fun get_byte(input: &vector<u8>, offset: u64): u8
-
- - - -
-Implementation - - -
fun get_byte(input: &vector<u8>, offset: u64): u8 {
-    assert!(((offset + 1) <= Vector::length(input)) && (offset < offset + 1), Errors::invalid_state(ERR_INPUT_NOT_LARGE_ENOUGH));
-    *Vector::borrow(input, offset)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `get_n_bytes` - - - -
fun get_n_bytes(input: &vector<u8>, offset: u64, n: u64): vector<u8>
-
- - - -
-Implementation - - -
fun get_n_bytes(input: &vector<u8>, offset: u64, n: u64): vector<u8> {
-    assert!(((offset + n) <= Vector::length(input)) && (offset < offset + n), Errors::invalid_state(ERR_INPUT_NOT_LARGE_ENOUGH));
-    let i = 0;
-    let content = Vector::empty<u8>();
-    while (i < n) {
-        let b = *Vector::borrow(input, offset + i);
-        Vector::push_back(&mut content, b);
-        i = i + 1;
-    };
-    content
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `get_n_bytes_as_u128` - - - -
fun get_n_bytes_as_u128(input: &vector<u8>, offset: u64, n: u64): u128
-
- - - -
-Implementation - - -
fun get_n_bytes_as_u128(input: &vector<u8>, offset: u64, n: u64): u128 {
-    assert!(((offset + n) <= Vector::length(input)) && (offset < offset + n), Errors::invalid_state(ERR_INPUT_NOT_LARGE_ENOUGH));
-    let number: u128 = 0;
-    let i = 0;
-    while (i < n) {
-        let byte = *Vector::borrow(input, offset + i);
-        let s = (i as u8) * 8;
-        number = number + ((byte as u128) << s);
-        i = i + 1;
-    };
-    number
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `deserialize_uleb128_as_u32` - - - -
public fun deserialize_uleb128_as_u32(input: &vector<u8>, offset: u64): (u64, u64)
-
- - - -
-Implementation - - -
public fun deserialize_uleb128_as_u32(input: &vector<u8>, offset: u64): (u64, u64) {
-    let value: u64 = 0;
-    let shift = 0;
-    let new_offset = offset;
-    while (shift < 32) {
-        let x = get_byte(input, new_offset);
-        new_offset = new_offset + 1;
-        let digit: u8 = x & 0x7F;
-        value = value | (digit as u64) << shift;
-        if ((value < 0) || (value > INTEGER32_MAX_VALUE)) {
-            abort ERR_OVERFLOW_PARSING_ULEB128_ENCODED_UINT32
-        };
-        if (digit == x) {
-            if (shift > 0 && digit == 0) {
-                abort ERR_INVALID_ULEB128_NUMBER_UNEXPECTED_ZERO_DIGIT
-            };
-            return (value, new_offset)
-        };
-        shift = shift + 7
-    };
-    abort ERR_OVERFLOW_PARSING_ULEB128_ENCODED_UINT32
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-pragma verify = false;
-
- - - -
- - - -## Function `serialize_u32_as_uleb128` - - - -
fun serialize_u32_as_uleb128(value: u64): vector<u8>
-
- - - -
-Implementation - - -
fun serialize_u32_as_uleb128(value: u64): vector<u8> {
-    let output = Vector::empty<u8>();
-    while ((value >> 7) != 0) {
-        Vector::push_back(&mut output, (((value & 0x7f) | 0x80) as u8));
-        value = value >> 7;
-    };
-    Vector::push_back(&mut output, (value as u8));
-    output
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_option_bytes_vector` - - - -
public fun skip_option_bytes_vector(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_option_bytes_vector(input: &vector<u8>, offset: u64): u64 {
-    let (len, new_offset) = deserialize_len(input, offset);
-    let i = 0;
-    while (i < len) {
-        new_offset = skip_option_bytes(input, new_offset);
-        i = i + 1;
-    };
-    new_offset
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_option_bytes` - - - -
public fun skip_option_bytes(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_option_bytes(input: &vector<u8>, offset: u64):  u64 {
-    let (tag, new_offset) = deserialize_option_tag(input, offset);
-    if (!tag) {
-        new_offset
-    } else {
-        skip_bytes(input, new_offset)
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_bytes_vector` - - - -
public fun skip_bytes_vector(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_bytes_vector(input: &vector<u8>, offset: u64): u64 {
-    let (len, new_offset) = deserialize_len(input, offset);
-    let i = 0;
-    while (i < len) {
-        new_offset = skip_bytes(input, new_offset);
-        i = i + 1;
-    };
-    new_offset
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_bytes` - - - -
public fun skip_bytes(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_bytes(input: &vector<u8>, offset: u64): u64 {
-    let (len, new_offset) = deserialize_len(input, offset);
-    new_offset + len
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_n_bytes` - - - -
public fun skip_n_bytes(input: &vector<u8>, offset: u64, n: u64): u64
-
- - - -
-Implementation - - -
public fun skip_n_bytes(input: &vector<u8>, offset: u64, n:u64): u64 {
-    can_skip(input, offset, n );
-    offset + n
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_u64_vector` - - - -
public fun skip_u64_vector(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_u64_vector(input: &vector<u8>, offset: u64): u64 {
-    let (len, new_offset) = deserialize_len(input, offset);
-    can_skip(input, new_offset, len * 8);
-    new_offset + len * 8
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_u128_vector` - - - -
public fun skip_u128_vector(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_u128_vector(input: &vector<u8>, offset: u64): u64 {
-    let (len, new_offset) = deserialize_len(input, offset);
-    can_skip(input, new_offset, len * 16);
-    new_offset + len * 16
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_u256` - - - -
public fun skip_u256(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_u256(input: &vector<u8>, offset: u64): u64 {
-    can_skip(input, offset, 32 );
-    offset + 32
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_u128` - - - -
public fun skip_u128(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_u128(input: &vector<u8>, offset: u64): u64 {
-    can_skip(input, offset, 16 );
-    offset + 16
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_u64` - - - -
public fun skip_u64(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_u64(input: &vector<u8>, offset: u64): u64 {
-    can_skip(input, offset, 8 );
-    offset + 8
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_u32` - - - -
public fun skip_u32(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_u32(input: &vector<u8>, offset: u64): u64 {
-    can_skip(input, offset, 4 );
-    offset + 4
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_u16` - - - -
public fun skip_u16(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_u16(input: &vector<u8>, offset: u64): u64 {
-    can_skip(input, offset, 2 );
-    offset + 2
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_address` - - - -
public fun skip_address(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_address(input: &vector<u8>, offset: u64): u64 {
-    skip_n_bytes(input, offset, 16)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `skip_bool` - - - -
public fun skip_bool(input: &vector<u8>, offset: u64): u64
-
- - - -
-Implementation - - -
public fun skip_bool(input: &vector<u8>, offset: u64):  u64{
-    can_skip(input, offset, 1);
-    offset + 1
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `can_skip` - - - -
fun can_skip(input: &vector<u8>, offset: u64, n: u64)
-
- - - -
-Implementation - - -
fun can_skip(input: &vector<u8>, offset: u64, n: u64){
-    assert!(((offset + n) <= Vector::length(input)) && (offset < offset + n), Errors::invalid_state(ERR_INPUT_NOT_LARGE_ENOUGH));
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
- - - - - - - -
native fun serialize<MoveValue>(v: &MoveValue): vector<u8>;
-
diff --git a/build/StarcoinFramework/docs/Bitwise.md b/build/StarcoinFramework/docs/Bitwise.md deleted file mode 100644 index 74d8a7ca..00000000 --- a/build/StarcoinFramework/docs/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) -- [Module Specification](#@Module_Specification_0) - - -
- - - - - -## Function `and` - -bit and: x & y - - -
public fun and(x: u64, y: u64): u64
-
- - - -
-Implementation - - -
public fun and(x: u64, y: u64): u64 {
-    (x & y as u64)
-}
-
- - - -
- - - -## Function `or` - -bit or: x | y - - -
public fun or(x: u64, y: u64): u64
-
- - - -
-Implementation - - -
public fun or(x: u64, y: u64): u64 {
-    (x | y as u64)
-}
-
- - - -
- - - -## Function `xor` - -bit xor: x ^ y - - -
public fun xor(x: u64, y: u64): u64
-
- - - -
-Implementation - - -
public fun xor(x: u64, y: u64): u64 {
-    (x ^ y as u64)
-}
-
- - - -
- - - -## Function `not` - -bit not: !x - - -
public fun not(x: u64): u64
-
- - - -
-Implementation - - -
public fun not(x: u64): u64 {
-   (x ^ 18446744073709551615u64 as u64)
-}
-
- - - -
- - - -## Function `lshift` - -left shift n bits. - - -
public fun lshift(x: u64, n: u8): u64
-
- - - -
-Implementation - - -
public fun lshift(x: u64, n: u8): u64 {
-    (x << n  as u64)
-}
-
- - - -
- - - -## Function `rshift` - -right shift n bits. - - -
public fun rshift(x: u64, n: u8): u64
-
- - - -
-Implementation - - -
public fun rshift(x: u64, n: u8): u64 {
-    (x >> n  as u64)
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-
diff --git a/build/StarcoinFramework/docs/Block.md b/build/StarcoinFramework/docs/Block.md deleted file mode 100644 index 534f285d..00000000 --- a/build/StarcoinFramework/docs/Block.md +++ /dev/null @@ -1,941 +0,0 @@ - - - -# Module `0x1::Block` - -Block module provide metadata for generated blocks. - - -- [Resource `BlockMetadata`](#0x1_Block_BlockMetadata) -- [Struct `NewBlockEvent`](#0x1_Block_NewBlockEvent) -- [Struct `Checkpoint`](#0x1_Block_Checkpoint) -- [Resource `Checkpoints`](#0x1_Block_Checkpoints) -- [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) -- [Function `checkpoints_init`](#0x1_Block_checkpoints_init) -- [Function `checkpoint_entry`](#0x1_Block_checkpoint_entry) -- [Function `checkpoint`](#0x1_Block_checkpoint) -- [Function `base_checkpoint`](#0x1_Block_base_checkpoint) -- [Function `latest_state_root`](#0x1_Block_latest_state_root) -- [Function `base_latest_state_root`](#0x1_Block_base_latest_state_root) -- [Function `update_state_root_entry`](#0x1_Block_update_state_root_entry) -- [Function `update_state_root`](#0x1_Block_update_state_root) -- [Function `base_update_state_root`](#0x1_Block_base_update_state_root) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::BCS;
-use 0x1::CoreAddresses;
-use 0x1::Errors;
-use 0x1::Event;
-use 0x1::Hash;
-use 0x1::Option;
-use 0x1::Ring;
-use 0x1::Timestamp;
-use 0x1::Vector;
-
- - - - - -## Resource `BlockMetadata` - -Block metadata struct. - - -
struct BlockMetadata has key
-
- - - -
-Fields - - -
-
-number: u64 -
-
- number of the current block -
-
-parent_hash: vector<u8> -
-
- Hash of the parent block. -
-
-author: address -
-
- Author of the current block. -
-
-uncles: u64 -
-
- number of uncles. -
-
-new_block_events: Event::EventHandle<Block::NewBlockEvent> -
-
- Handle of events when new blocks are emitted -
-
- - -
- - - -## Struct `NewBlockEvent` - -Events emitted when new block generated. - - -
struct NewBlockEvent has drop, store
-
- - - -
-Fields - - -
-
-number: u64 -
-
- -
-
-author: address -
-
- -
-
-timestamp: u64 -
-
- -
-
-uncles: u64 -
-
- -
-
- - -
- - - -## Struct `Checkpoint` - - - -
struct Checkpoint has copy, drop, store
-
- - - -
-Fields - - -
-
-block_number: u64 -
-
- -
-
-block_hash: vector<u8> -
-
- -
-
-state_root: Option::Option<vector<u8>> -
-
- -
-
- - -
- - - -## Resource `Checkpoints` - - - -
struct Checkpoints has store, key
-
- - - -
-Fields - - -
-
-checkpoints: Ring::Ring<Block::Checkpoint> -
-
- -
-
-index: u64 -
-
- -
-
-last_number: u64 -
-
- -
-
- - -
- - - -## Constants - - - - - - -
const BLOCK_HEADER_LENGTH: u64 = 247;
-
- - - - - - - -
const BLOCK_INTERVAL_NUMBER: u64 = 5;
-
- - - - - - - -
const CHECKPOINT_LENGTH: u64 = 60;
-
- - - - - - - -
const EBLOCK_NUMBER_MISMATCH: u64 = 17;
-
- - - - - - - -
const ERROR_INTERVAL_TOO_LITTLE: u64 = 20;
-
- - - - - - - -
const ERROR_NOT_BLOCK_HEADER: u64 = 19;
-
- - - - - - - -
const ERROR_NO_HAVE_CHECKPOINT: u64 = 18;
-
- - - - - -## Function `initialize` - -This can only be invoked by the GENESIS_ACCOUNT at genesis - - -
public fun initialize(account: &signer, parent_hash: vector<u8>)
-
- - - -
-Implementation - - -
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),
-        });
-}
-
- - - -
- -
-Specification - - - -
aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-aborts_if exists<BlockMetadata>(Signer::address_of(account));
-
- - - -
- - - -## Function `get_current_block_number` - -Get the current block number - - -
public fun get_current_block_number(): u64
-
- - - -
-Implementation - - -
public fun get_current_block_number(): u64 acquires BlockMetadata {
-  borrow_global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).number
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `get_parent_hash` - -Get the hash of the parent block. - - -
public fun get_parent_hash(): vector<u8>
-
- - - -
-Implementation - - -
public fun get_parent_hash(): vector<u8> acquires BlockMetadata {
-  *&borrow_global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).parent_hash
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `get_current_author` - -Gets the address of the author of the current block - - -
public fun get_current_author(): address
-
- - - -
-Implementation - - -
public fun get_current_author(): address acquires BlockMetadata {
-  borrow_global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).author
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `process_block_metadata` - -Call at block prologue - - -
public fun process_block_metadata(account: &signer, parent_hash: vector<u8>, author: address, timestamp: u64, uncles: u64, number: u64)
-
- - - -
-Implementation - - -
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,
-      }
-    );
-}
-
- - - -
- -
-Specification - - - -
aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
-aborts_if number != global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).number + 1;
-
- - - - - - - -
schema AbortsIfBlockMetadataNotExist {
-    aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
-}
-
- - - -
- - - -## Function `checkpoints_init` - - - -
public fun checkpoints_init(account: &signer)
-
- - - -
-Implementation - - -
public fun checkpoints_init(account: &signer){
-    CoreAddresses::assert_genesis_address(account);
-
-    let checkpoints = Ring::create_with_capacity<Checkpoint>(CHECKPOINT_LENGTH);
-    move_to<Checkpoints>(
-        account,
-        Checkpoints {
-           checkpoints,
-           index        : 0,
-           last_number  : 0,
-    });
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `checkpoint_entry` - - - -
public entry fun checkpoint_entry(_account: signer)
-
- - - -
-Implementation - - -
public entry fun checkpoint_entry(_account: signer) acquires BlockMetadata, Checkpoints {
-    checkpoint();
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `checkpoint` - - - -
public fun checkpoint()
-
- - - -
-Implementation - - -
public fun checkpoint() acquires BlockMetadata, Checkpoints{
-    let parent_block_number = get_current_block_number() - 1;
-    let parent_block_hash   = get_parent_hash();
-
-    let checkpoints = borrow_global_mut<Checkpoints>(CoreAddresses::GENESIS_ADDRESS());
-    base_checkpoint(checkpoints, parent_block_number, parent_block_hash);
-
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `base_checkpoint` - - - -
fun base_checkpoint(checkpoints: &mut Block::Checkpoints, parent_block_number: u64, parent_block_hash: vector<u8>)
-
- - - -
-Implementation - - -
fun base_checkpoint(checkpoints: &mut Checkpoints, parent_block_number: u64, parent_block_hash:vector<u8>){
-    assert!(checkpoints.last_number + BLOCK_INTERVAL_NUMBER <= parent_block_number || checkpoints.last_number == 0, Errors::invalid_argument(ERROR_INTERVAL_TOO_LITTLE));
-
-    checkpoints.index = checkpoints.index + 1;
-    checkpoints.last_number = parent_block_number;
-    let op_checkpoint = Ring::push<Checkpoint>(&mut checkpoints.checkpoints, Checkpoint {
-                                                            block_number: parent_block_number,
-                                                            block_hash: parent_block_hash,
-                                                            state_root: Option::none<vector<u8>>(),
-                                                        } );
-    if(Option::is_some(&op_checkpoint)){
-        Option::destroy_some(op_checkpoint);
-    }else{
-        Option::destroy_none(op_checkpoint);
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `latest_state_root` - - - -
public fun latest_state_root(): (u64, vector<u8>)
-
- - - -
-Implementation - - -
public fun latest_state_root():(u64,vector<u8>) acquires  Checkpoints{
-    let checkpoints = borrow_global<Checkpoints>(CoreAddresses::GENESIS_ADDRESS());
-    base_latest_state_root(checkpoints)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `base_latest_state_root` - - - -
fun base_latest_state_root(checkpoints: &Block::Checkpoints): (u64, vector<u8>)
-
- - - -
-Implementation - - -
fun base_latest_state_root(checkpoints: &Checkpoints):(u64,vector<u8>){
-    let len = Ring::capacity<Checkpoint>(&checkpoints.checkpoints);
-    let j = if(checkpoints.index < len - 1){
-        checkpoints.index
-    }else{
-        len
-    };
-    let i = checkpoints.index;
-    while( j > 0){
-        let op_checkpoint = Ring::borrow(&checkpoints.checkpoints, i - 1 );
-        if( Option::is_some(op_checkpoint) && Option::is_some(&Option::borrow(op_checkpoint).state_root) ) {
-            let state_root = Option::borrow(&Option::borrow(op_checkpoint).state_root);
-            return (Option::borrow(op_checkpoint).block_number, *state_root)
-        };
-        j = j - 1;
-        i = i - 1;
-    };
-
-    abort Errors::invalid_state(ERROR_NO_HAVE_CHECKPOINT)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `update_state_root_entry` - - - -
public entry fun update_state_root_entry(_account: signer, header: vector<u8>)
-
- - - -
-Implementation - - -
public entry fun update_state_root_entry(_account: signer , header: vector<u8>)
-acquires Checkpoints {
-    update_state_root(header);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `update_state_root` - - - -
public fun update_state_root(header: vector<u8>)
-
- - - -
-Implementation - - -
public fun update_state_root(header: vector<u8>) acquires  Checkpoints {
-    let checkpoints = borrow_global_mut<Checkpoints>(CoreAddresses::GENESIS_ADDRESS());
-    base_update_state_root(checkpoints, header);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `base_update_state_root` - - - -
fun base_update_state_root(checkpoints: &mut Block::Checkpoints, header: vector<u8>)
-
- - - -
-Implementation - - -
fun base_update_state_root(checkpoints: &mut Checkpoints, header: vector<u8>){
-    let prefix = Hash::sha3_256(b"STARCOIN::BlockHeader");
-
-    //parent_hash
-    let new_offset = BCS::skip_bytes(&header,0);
-    //timestamp
-    let new_offset = BCS::skip_u64(&header,new_offset);
-    //number
-    let (number,new_offset) = BCS::deserialize_u64(&header,new_offset);
-    //author
-    new_offset = BCS::skip_address(&header,new_offset);
-    //author_auth_key
-    new_offset = BCS::skip_option_bytes(&header,new_offset);
-    //txn_accumulator_root
-    new_offset = BCS::skip_bytes(&header,new_offset);
-    //block_accumulator_root
-    new_offset = BCS::skip_bytes(&header,new_offset);
-    //state_root
-    let (state_root,_new_offset) = BCS::deserialize_bytes(&header,new_offset);
-
-    Vector::append(&mut prefix,header);
-    let block_hash = Hash::sha3_256(prefix);
-
-    let len = Ring::capacity<Checkpoint>(&checkpoints.checkpoints);
-    let j = if(checkpoints.index < len - 1){
-        checkpoints.index
-    }else{
-        len
-    };
-    let i = checkpoints.index;
-    while( j > 0){
-        let op_checkpoint = Ring::borrow_mut(&mut checkpoints.checkpoints, i - 1);
-
-        if( Option::is_some(op_checkpoint) && &Option::borrow(op_checkpoint).block_hash == &block_hash && Option::borrow<Checkpoint>(op_checkpoint).block_number == number) {
-
-            let op_state_root = &mut Option::borrow_mut<Checkpoint>(op_checkpoint).state_root;
-            if(Option::is_some(op_state_root)){
-                Option::swap(op_state_root, state_root);
-            }else{
-                Option::fill(op_state_root, state_root);
-            };
-            return
-        };
-        j = j - 1;
-        i = i - 1;
-    };
-
-    abort Errors::invalid_state(ERROR_NO_HAVE_CHECKPOINT)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/BlockReward.md b/build/StarcoinFramework/docs/BlockReward.md deleted file mode 100644 index 213d255d..00000000 --- a/build/StarcoinFramework/docs/BlockReward.md +++ /dev/null @@ -1,397 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-reward_number: u64 -
-
- How many block rewards has been handled. -
-
-infos: vector<BlockReward::RewardInfo> -
-
- informations about the reward distribution. -
-
-reward_events: Event::EventHandle<BlockReward::BlockRewardEvent> -
-
- event handle used to emit block reward event. -
-
- - -
- - - -## Struct `RewardInfo` - -Reward info of miners. - - -
struct RewardInfo has store
-
- - - -
-Fields - - -
-
-number: u64 -
-
- number of the block miner minted. -
-
-reward: u128 -
-
- how many stc rewards. -
-
-miner: address -
-
- miner who mint the block. -
-
-gas_fees: Token::Token<STC::STC> -
-
- store the gas fee that users consumed. -
-
- - -
- - - -## Struct `BlockRewardEvent` - -block reward event - - -
struct BlockRewardEvent has drop, store
-
- - - -
-Fields - - -
-
-block_number: u64 -
-
- block number -
-
-block_reward: u128 -
-
- STC reward. -
-
-gas_fees: u128 -
-
- gas fees in STC. -
-
-miner: address -
-
- block miner -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
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),
-    });
-}
-
- - - -
- -
-Specification - - - -
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` - -Process the given block rewards. - - -
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>)
-
- - - -
-Implementation - - -
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);
-
-}
-
- - - -
- -
-Specification - - - -
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;
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/ChainId.md b/build/StarcoinFramework/docs/ChainId.md deleted file mode 100644 index 89ab9fd3..00000000 --- a/build/StarcoinFramework/docs/ChainId.md +++ /dev/null @@ -1,425 +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) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::CoreAddresses;
-use 0x1::Timestamp;
-
- - - - - -## Resource `ChainId` - -chain id data structure. - - -
struct ChainId has key
-
- - - -
-Fields - - -
-
-id: u8 -
-
- real id. -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
public fun initialize(account: &signer, id: u8) {
-    Timestamp::assert_genesis();
-    CoreAddresses::assert_genesis_address(account);
-    move_to(account, ChainId { id });
-}
-
- - - -
- -
-Specification - - - -
aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-aborts_if exists<ChainId>(Signer::address_of(account));
-ensures exists<ChainId>(Signer::address_of(account));
-
- - - -
- - - -## Function `get` - -Return the chain ID of this chain - - -
public fun get(): u8
-
- - - -
-Implementation - - -
public fun get(): u8 acquires ChainId {
-    borrow_global<ChainId>(CoreAddresses::GENESIS_ADDRESS()).id
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `is_dev` - - - -
public fun is_dev(): bool
-
- - - -
-Implementation - - -
public fun is_dev(): bool acquires ChainId {
-    get() == DEV_CHAIN_ID
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `is_test` - - - -
public fun is_test(): bool
-
- - - -
-Implementation - - -
public fun is_test(): bool acquires ChainId {
-    get() == TEST_CHAIN_ID
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `is_halley` - - - -
public fun is_halley(): bool
-
- - - -
-Implementation - - -
public fun is_halley(): bool acquires ChainId {
-    get() == HALLEY_CHAIN_ID
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `is_proxima` - - - -
public fun is_proxima(): bool
-
- - - -
-Implementation - - -
public fun is_proxima(): bool acquires ChainId {
-    get() == PROXIMA_CHAIN_ID
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `is_barnard` - - - -
public fun is_barnard(): bool
-
- - - -
-Implementation - - -
public fun is_barnard(): bool acquires ChainId {
-    get() == BARNARD_CHAIN_ID
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `is_main` - - - -
public fun is_main(): bool
-
- - - -
-Implementation - - -
public fun is_main(): bool acquires ChainId {
-    get() == MAIN_CHAIN_ID
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/Collection.md b/build/StarcoinFramework/docs/Collection.md deleted file mode 100644 index 6716cbb4..00000000 --- a/build/StarcoinFramework/docs/Collection.md +++ /dev/null @@ -1,430 +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) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::Errors;
-use 0x1::Option;
-use 0x1::Signer;
-use 0x1::Vector;
-
- - - - - -## Struct `Collection` - -Collection in memory, can not drop & store. - - -
struct Collection<T>
-
- - - -
-Fields - - -
-
-items: vector<T> -
-
- -
-
-owner: address -
-
- the owner of Collection. -
-
- - -
- - - -## Resource `CollectionStore` - -Collection in global store. - - -
struct CollectionStore<T: store> has key
-
- - - -
-Fields - - -
-
-items: Option::Option<vector<T>> -
-
- items in the CollectionStore. - use Option at here is for temporary take away from store to construct Collection. -
-
- - -
- - - -## Constants - - - - - - -
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 ith element of the collection c. -Aborts if i is out of bounds. - - -
public fun borrow<T>(c: &Collection::Collection<T>, i: u64): &T
-
- - - -
-Implementation - - -
public fun borrow<T>(c: &Collection<T>, i: u64): &T{
-    Vector::borrow(&c.items, i)
-}
-
- - - -
- - - -## Function `pop_back` - -Pop an element from the end of vector v. -Aborts if v is empty. - - -
public fun pop_back<T>(account: &signer, c: &mut Collection::Collection<T>): T
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `exists_at` - -check the Collection exists in addr - - -
fun exists_at<T: store>(addr: address): bool
-
- - - -
-Implementation - - -
fun exists_at<T: store>(addr: address): bool{
-    exists<CollectionStore<T>>(addr)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `put` - -Deprecated since @v3 -Put items to account's Collection last position. - - -
public fun put<T: store>(_account: &signer, _item: T)
-
- - - -
-Implementation - - -
public fun put<T: store>(_account: &signer, _item: T) {
-    abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `take` - -Take last item from account's Collection of T. - - -
public fun take<T: store>(account: &signer): T
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `borrow_collection` - -Borrow collection of T from addr - - -
public fun borrow_collection<T: store>(addr: address): Collection::Collection<T>
-
- - - -
-Implementation - - -
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
-    }
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `return_collection` - -Return the Collection of T - - -
public fun return_collection<T: store>(c: Collection::Collection<T>)
-
- - - -
-Implementation - - -
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);
-    }
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `destroy_empty` - - - -
fun destroy_empty<T: store>(c: Collection::CollectionStore<T>)
-
- - - -
-Implementation - - -
fun destroy_empty<T: store>(c: CollectionStore<T>){
-    let CollectionStore{ items } = c;
-    Option::destroy_none(items);
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = false;
-
diff --git a/build/StarcoinFramework/docs/Collection2.md b/build/StarcoinFramework/docs/Collection2.md deleted file mode 100644 index 42e6ff21..00000000 --- a/build/StarcoinFramework/docs/Collection2.md +++ /dev/null @@ -1,878 +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) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::Errors;
-use 0x1::Option;
-use 0x1::Signer;
-use 0x1::Vector;
-
- - - - - -## Struct `Collection` - -Collection in memory, can not drop & store. - - -
struct Collection<T>
-
- - - -
-Fields - - -
-
-items: vector<T> -
-
- -
-
-owner: address -
-
- -
-
-can_put: bool -
-
- -
-
-can_mut: bool -
-
- -
-
-can_take: bool -
-
- -
-
- - -
- - - -## Resource `CollectionStore` - -Collection in global store. - - -
struct CollectionStore<T: store> has key
-
- - - -
-Fields - - -
-
-items: Option::Option<vector<T>> -
-
- items in the CollectionStore. - use Option at here is for temporary take away from store to construct Collection. -
-
-anyone_can_put: bool -
-
- -
-
-anyone_can_mut: bool -
-
- -
-
- - -
- - - -## Constants - - - - -The operator require the collection owner or collection set anyone_can_put to true. - - -
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
-
- - - -
-Implementation - - -
public fun length<T>(c: &Collection<T>): u64{
-    Vector::length(&c.items)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `borrow` - -Acquire an immutable reference to the ith element of the collection c. -Aborts if i is out of bounds. - - -
public fun borrow<T>(c: &Collection2::Collection<T>, i: u64): &T
-
- - - -
-Implementation - - -
public fun borrow<T>(c: &Collection<T>, i: u64): &T{
-    Vector::borrow(&c.items, i)
-}
-
- - - -
- - - -## Function `push_back` - -Add item v to the end of the collection c. -require owner of Collection. - - -
public fun push_back<T>(c: &mut Collection2::Collection<T>, t: T)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- - - -## Function `borrow_mut` - -Return a mutable reference to the ith 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
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `pop_back` - -Pop an element from the end of vector v. -Aborts if v is empty. - - -
public fun pop_back<T>(c: &mut Collection2::Collection<T>): T
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `remove` - - - -
public fun remove<T>(c: &mut Collection2::Collection<T>, i: u64): T
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `append` - - - -
public fun append<T>(c: &mut Collection2::Collection<T>, other: T)
-
- - - -
-Implementation - - -
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))
-}
-
- - - -
- - - -## Function `append_all` - - - -
public fun append_all<T>(c: &mut Collection2::Collection<T>, other: vector<T>)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `exists_at` - -check the Collection exists in addr - - -
public fun exists_at<T: store>(addr: address): bool
-
- - - -
-Implementation - - -
public fun exists_at<T: store>(addr: address): bool{
-    exists<CollectionStore<T>>(addr)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `is_accept` - -check 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
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `accept` - -signer allow other send T to self -create a Collection of T and set anyone_can_put to true -if the Collection exists, just update anyone_can_put to true - - -
public fun accept<T: store>(signer: &signer)
-
- - - -
-Implementation - - -
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;
-    }
-}
-
- - - -
- - - -## Function `put` - -Put items to to_addr's Collection of T -put = borrow_collection + append + return_collection. - - -
public fun put<T: store>(signer: &signer, owner: address, item: T)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `put_all` - -Put all items to owner's collection of T. - - -
public fun put_all<T: store>(signer: &signer, owner: address, items: vector<T>)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `take` - -Take last item from signer's Collection of T. - - -
public fun take<T: store>(signer: &signer): T
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `create_collection` - - - -
public fun create_collection<T: store>(signer: &signer, anyone_can_put: bool, anyone_can_mut: bool)
-
- - - -
-Implementation - - -
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})
-}
-
- - - -
- - - -## Function `length_of` - -Return the length of Collection from owner, if collection do not exist, return 0. - - -
public fun length_of<T: store>(owner: address): u64
-
- - - -
-Implementation - - -
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
-    }
-}
-
- - - -
- - - -## Function `borrow_collection` - -Borrow collection of T from 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>
-
- - - -
-Implementation - - -
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,
-    }
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `return_collection` - -Return the Collection of T - - -
public fun return_collection<T: store>(c: Collection2::Collection<T>)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `destroy_collection` - - - -
public fun destroy_collection<T: store>(signer: &signer)
-
- - - -
-Implementation - - -
public fun destroy_collection<T: store>(signer: &signer) acquires CollectionStore{
-    let c = move_from<CollectionStore<T>>(Signer::address_of(signer));
-    destroy_empty(c);
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `destroy_empty` - - - -
fun destroy_empty<T: store>(c: Collection2::CollectionStore<T>)
-
- - - -
-Implementation - - -
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);
-    }
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = false;
-
diff --git a/build/StarcoinFramework/docs/Compare.md b/build/StarcoinFramework/docs/Compare.md deleted file mode 100644 index 998884cc..00000000 --- a/build/StarcoinFramework/docs/Compare.md +++ /dev/null @@ -1,340 +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_u64`](#0x1_Compare_cmp_u64) -- [Function `is_equal`](#0x1_Compare_is_equal) -- [Function `is_less_than`](#0x1_Compare_is_less_than) -- [Function `is_greater_than`](#0x1_Compare_is_greater_than) -- [Module Specification](#@Module_Specification_1) - - -
- - - - - -## 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
-
- - - -
-Implementation - - -
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 v1 = *Vector::borrow(v1, i1);
-        let v2 = *Vector::borrow(v2, i2);
-        let elem_cmp = if (v1 == v2) EQUAL
-            else if (v1 < v2) LESS_THAN
-            else GREATER_THAN;
-        if (elem_cmp != 0) return elem_cmp
-        // else, compare next element
-    };
-    // all compared elements equal; use length comparison to break the tie
-    len_cmp
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `cmp_bytes` - - - -
public fun cmp_bytes(v1: &vector<u8>, v2: &vector<u8>): u8
-
- - - -
-Implementation - - -
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 i = 0;
-    while (i < l1 && i < l2) {
-        let v1 = *Vector::borrow(v1, i);
-        let v2 = *Vector::borrow(v2, i);
-        let elem_cmp = if (v1 == v2) EQUAL
-            else if (v1 < v2) LESS_THAN
-            else GREATER_THAN;
-        if (elem_cmp != 0) {
-            return elem_cmp
-        };
-        // else, compare next element
-        i = i + 1;
-    };
-    // all compared elements equal; use length comparison to break the tie
-    len_cmp
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `cmp_u64` - - - -
fun cmp_u64(i1: u64, i2: u64): u8
-
- - - -
-Implementation - - -
fun cmp_u64(i1: u64, i2: u64): u8 {
-    if (i1 == i2) EQUAL
-    else if (i1 < i2) LESS_THAN
-    else GREATER_THAN
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `is_equal` - - - -
public fun is_equal(result: u8): bool
-
- - - -
-Implementation - - -
public fun is_equal(result: u8): bool {
-    result == EQUAL
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `is_less_than` - - - -
public fun is_less_than(result: u8): bool
-
- - - -
-Implementation - - -
public fun is_less_than(result: u8): bool {
-    result == LESS_THAN
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `is_greater_than` - - - -
public fun is_greater_than(result: u8): bool
-
- - - -
-Implementation - - -
public fun is_greater_than(result: u8): bool {
-    result == GREATER_THAN
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/Config.md b/build/StarcoinFramework/docs/Config.md deleted file mode 100644 index cdffd8bb..00000000 --- a/build/StarcoinFramework/docs/Config.md +++ /dev/null @@ -1,773 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-payload: ConfigValue -
-
- -
-
- - -
- - - -## Struct `ModifyConfigCapability` - -Accounts with this privilege can modify config of type ConfigValue under account_address - - -
struct ModifyConfigCapability<ConfigValue: copy, drop, store> has store
-
- - - -
-Fields - - -
-
-account_address: address -
-
- -
-
-events: Event::EventHandle<Config::ConfigChangeEvent<ConfigValue>> -
-
- -
-
- - -
- - - -## Resource `ModifyConfigCapabilityHolder` - -A holder for ModifyConfigCapability, for extraction and restoration of ModifyConfigCapability. - - -
struct ModifyConfigCapabilityHolder<ConfigValue: copy, drop, store> has store, key
-
- - - -
-Fields - - -
-
-cap: Option::Option<Config::ModifyConfigCapability<ConfigValue>> -
-
- -
-
- - -
- - - -## Struct `ConfigChangeEvent` - -Event emitted when config value is changed. - - -
struct ConfigChangeEvent<ConfigValue: copy, drop, store> has drop, store
-
- - - -
-Fields - - -
-
-account_address: address -
-
- -
-
-value: ConfigValue -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Config<ConfigValue>>(addr);
-ensures exists<Config<ConfigValue>>(addr);
-ensures result == spec_get<ConfigValue>(addr);
-
- - - -
- - - -## Function `config_exist_by_address` - -Check whether the config of ConfigValue type exists under addr. - - -
public fun config_exist_by_address<ConfigValue: copy, drop, store>(addr: address): bool
-
- - - -
-Implementation - - -
public fun config_exist_by_address<ConfigValue: copy + drop + store>(addr: address): bool {
-    exists<Config<ConfigValue>>(addr)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == exists<Config<ConfigValue>>(addr);
-
- - - -
- - - -## Function `set` - -Set a config item to a new value with capability stored under signer - - -
public fun set<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
let addr = Signer::address_of(account);
-let cap_opt = spec_cap<ConfigValue>(addr);
-let cap = Option::borrow(spec_cap<ConfigValue>(Signer::address_of(account)));
-aborts_if !exists<ModifyConfigCapabilityHolder<ConfigValue>>(addr);
-aborts_if Option::is_none<ModifyConfigCapability<ConfigValue>>(cap_opt);
-ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(addr);
-pragma aborts_if_is_partial;
-ensures exists<Config<ConfigValue>>(
-    Option::borrow(spec_cap<ConfigValue>(Signer::address_of(account))).account_address,
-);
-ensures global<Config<ConfigValue>>(
-    Option::borrow(spec_cap<ConfigValue>(Signer::address_of(account))).account_address,
-).payload == payload;
-
- - - - - - - -
fun spec_cap<ConfigValue>(addr: address): Option<ModifyConfigCapability<ConfigValue>> {
-   global<ModifyConfigCapabilityHolder<ConfigValue>>(addr).cap
-}
-
- - - -
- - - -## Function `set_with_capability` - -Set a config item to a new value with cap. - - -
public fun set_with_capability<ConfigValue: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<ConfigValue>, payload: ConfigValue)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Config<ConfigValue>>(cap.account_address);
-ensures exists<Config<ConfigValue>>(cap.account_address);
-ensures global<Config<ConfigValue>>(cap.account_address).payload == payload;
-
- - - -
- - - -## Function `publish_new_config_with_capability` - -Publish a new config item. The caller will use the returned ModifyConfigCapability to specify the access control -policy for who can modify the config. - - -
public fun publish_new_config_with_capability<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue): Config::ModifyConfigCapability<ConfigValue>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
include PublishNewConfigAbortsIf<ConfigValue>;
-ensures exists<Config<ConfigValue>>(Signer::address_of(account));
-ensures global<Config<ConfigValue>>(Signer::address_of(account)).payload == payload;
-ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-ensures Option::is_none(global<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account)).cap);
-
- - - -
- - - -## Function `publish_new_config` - -Publish a new config item under account address. - - -
public fun publish_new_config<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue)
-
- - - -
-Implementation - - -
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)});
-}
-
- - - -
- -
-Specification - - - -
include PublishNewConfigAbortsIf<ConfigValue>;
-ensures exists<Config<ConfigValue>>(Signer::address_of(account));
-ensures global<Config<ConfigValue>>(Signer::address_of(account)).payload == payload;
-ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
-ensures Option::is_some(global<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account)).cap);
-
- - - - - - - -
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));
-}
-
- - - - - - - -
schema AbortsIfCapNotExist<ConfigValue> {
-    address: address;
-    aborts_if !exists<ModifyConfigCapabilityHolder<ConfigValue>>(address);
-    aborts_if Option::is_none<ModifyConfigCapability<ConfigValue>>(
-        global<ModifyConfigCapabilityHolder<ConfigValue>>(address).cap,
-    );
-}
-
- - - -
- - - -## Function `extract_modify_config_capability` - -Extract account's ModifyConfigCapability for ConfigValue type - - -
public fun extract_modify_config_capability<ConfigValue: copy, drop, store>(account: &signer): Config::ModifyConfigCapability<ConfigValue>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
let address = Signer::address_of(account);
-include AbortsIfCapNotExist<ConfigValue>;
-ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(address);
-ensures Option::is_none<ModifyConfigCapability<ConfigValue>>(
-    global<ModifyConfigCapabilityHolder<ConfigValue>>(address).cap
-);
-ensures result == old(Option::borrow(global<ModifyConfigCapabilityHolder<ConfigValue>>(address).cap));
-
- - - -
- - - -## Function `restore_modify_config_capability` - -Restore account's ModifyConfigCapability - - -
public fun restore_modify_config_capability<ConfigValue: copy, drop, store>(cap: Config::ModifyConfigCapability<ConfigValue>)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address);
-aborts_if Option::is_some(global<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address).cap);
-ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address);
-ensures Option::is_some(global<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address).cap);
-ensures Option::borrow(global<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address).cap) == cap;
-
- - - -
- - - -## Function `destroy_modify_config_capability` - -Destroy the given ModifyConfigCapability - - -
public fun destroy_modify_config_capability<ConfigValue: copy, drop, store>(cap: Config::ModifyConfigCapability<ConfigValue>)
-
- - - -
-Implementation - - -
public fun destroy_modify_config_capability<ConfigValue: copy + drop + store>(
-    cap: ModifyConfigCapability<ConfigValue>,
-) {
-    let ModifyConfigCapability{account_address:_, events} = cap;
-    Event::destroy_handle(events)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `account_address` - -Return the address of the given ModifyConfigCapability - - -
public fun account_address<ConfigValue: copy, drop, store>(cap: &Config::ModifyConfigCapability<ConfigValue>): address
-
- - - -
-Implementation - - -
public fun account_address<ConfigValue: copy + drop + store>(cap: &ModifyConfigCapability<ConfigValue>): address {
-    cap.account_address
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == cap.account_address;
-
- - - -
- - - -## Function `emit_config_change_event` - -Emit a config change event. - - -
fun emit_config_change_event<ConfigValue: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<ConfigValue>, value: ConfigValue)
-
- - - -
-Implementation - - -
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,
-        },
-    );
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
- - - - - - - -
fun spec_get<ConfigValue>(addr: address): ConfigValue {
-   global<Config<ConfigValue>>(addr).payload
-}
-
diff --git a/build/StarcoinFramework/docs/ConsensusConfig.md b/build/StarcoinFramework/docs/ConsensusConfig.md deleted file mode 100644 index fc33060d..00000000 --- a/build/StarcoinFramework/docs/ConsensusConfig.md +++ /dev/null @@ -1,700 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-uncle_rate_target: u64 -
-
- Uncle block rate per epoch -
-
-base_block_time_target: u64 -
-
- Average target time to calculate a block's difficulty -
-
-base_reward_per_block: u128 -
-
- Rewards per block -
-
-base_reward_per_uncle_percent: u64 -
-
- Percentage of base_reward_per_block to reward a uncle block -
-
-epoch_block_count: u64 -
-
- Blocks each epoch -
-
-base_block_difficulty_window: u64 -
-
- How many ancestor blocks which use to calculate next block's difficulty -
-
-min_block_time_target: u64 -
-
- Minimum target time to calculate a block's difficulty -
-
-max_block_time_target: u64 -
-
- Maximum target time to calculate a block's difficulty -
-
-base_max_uncles_per_block: u64 -
-
- Maximum number of uncle block per block -
-
-base_block_gas_limit: u64 -
-
- Maximum gases per block -
-
-strategy: u8 -
-
- Strategy to calculate difficulty -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
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,
-        ),
-    );
-}
-
- - - -
- -
-Specification - - - -
aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::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` - -Create a new consensus config mainly used in DAO. - - -
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
-
- - - -
-Implementation - - -
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,
-    }
-}
-
- - - -
- -
-Specification - - - -
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` - -Get config data. - - -
public fun get_config(): ConsensusConfig::ConsensusConfig
-
- - - -
-Implementation - - -
public fun get_config(): ConsensusConfig {
-    Config::get_by_address<ConsensusConfig>(CoreAddresses::GENESIS_ADDRESS())
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Config::Config<ConsensusConfig>>(CoreAddresses::GENESIS_ADDRESS());
-
- - - - - - - -
fun spec_get_config(): ConsensusConfig {
-   global<Config::Config<ConsensusConfig>>(CoreAddresses::GENESIS_ADDRESS()).payload
-}
-
- - - -
- - - -## Function `uncle_rate_target` - -Get uncle_rate_target - - -
public fun uncle_rate_target(config: &ConsensusConfig::ConsensusConfig): u64
-
- - - -
-Implementation - - -
public fun uncle_rate_target(config: &ConsensusConfig): u64 {
-    config.uncle_rate_target
-}
-
- - - -
- - - -## Function `base_block_time_target` - -Get base_block_time_target - - -
public fun base_block_time_target(config: &ConsensusConfig::ConsensusConfig): u64
-
- - - -
-Implementation - - -
public fun base_block_time_target(config: &ConsensusConfig): u64 {
-    config.base_block_time_target
-}
-
- - - -
- - - -## Function `base_reward_per_block` - -Get base_reward_per_block - - -
public fun base_reward_per_block(config: &ConsensusConfig::ConsensusConfig): u128
-
- - - -
-Implementation - - -
public fun base_reward_per_block(config: &ConsensusConfig): u128 {
-    config.base_reward_per_block
-}
-
- - - -
- - - -## Function `epoch_block_count` - -Get epoch_block_count - - -
public fun epoch_block_count(config: &ConsensusConfig::ConsensusConfig): u64
-
- - - -
-Implementation - - -
public fun epoch_block_count(config: &ConsensusConfig): u64 {
-    config.epoch_block_count
-}
-
- - - -
- - - -## Function `base_block_difficulty_window` - -Get base_block_difficulty_window - - -
public fun base_block_difficulty_window(config: &ConsensusConfig::ConsensusConfig): u64
-
- - - -
-Implementation - - -
public fun base_block_difficulty_window(config: &ConsensusConfig): u64 {
-    config.base_block_difficulty_window
-}
-
- - - -
- - - -## Function `base_reward_per_uncle_percent` - -Get base_reward_per_uncle_percent - - -
public fun base_reward_per_uncle_percent(config: &ConsensusConfig::ConsensusConfig): u64
-
- - - -
-Implementation - - -
public fun base_reward_per_uncle_percent(config: &ConsensusConfig): u64 {
-    config.base_reward_per_uncle_percent
-}
-
- - - -
- - - -## Function `min_block_time_target` - -Get min_block_time_target - - -
public fun min_block_time_target(config: &ConsensusConfig::ConsensusConfig): u64
-
- - - -
-Implementation - - -
public fun min_block_time_target(config: &ConsensusConfig): u64 {
-    config.min_block_time_target
-}
-
- - - -
- - - -## Function `max_block_time_target` - -Get max_block_time_target - - -
public fun max_block_time_target(config: &ConsensusConfig::ConsensusConfig): u64
-
- - - -
-Implementation - - -
public fun max_block_time_target(config: &ConsensusConfig): u64 {
-    config.max_block_time_target
-}
-
- - - -
- - - -## Function `base_max_uncles_per_block` - -Get base_max_uncles_per_block - - -
public fun base_max_uncles_per_block(config: &ConsensusConfig::ConsensusConfig): u64
-
- - - -
-Implementation - - -
public fun base_max_uncles_per_block(config: &ConsensusConfig): u64 {
-    config.base_max_uncles_per_block
-}
-
- - - -
- - - -## Function `base_block_gas_limit` - -Get base_block_gas_limit - - -
public fun base_block_gas_limit(config: &ConsensusConfig::ConsensusConfig): u64
-
- - - -
-Implementation - - -
public fun base_block_gas_limit(config: &ConsensusConfig): u64 {
-    config.base_block_gas_limit
-}
-
- - - -
- - - -## Function `strategy` - -Get strategy - - -
public fun strategy(config: &ConsensusConfig::ConsensusConfig): u8
-
- - - -
-Implementation - - -
public fun strategy(config: &ConsensusConfig): u8 {
-    config.strategy
-}
-
- - - -
- - - -## Function `compute_reward_per_block` - -Compute block reward given the new_epoch_block_time_target. - - -
public fun compute_reward_per_block(new_epoch_block_time_target: u64): u128
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Config::Config<ConsensusConfig>>(CoreAddresses::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` - -Compute block reward given the 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
-
- - - -
-Implementation - - -
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))
-}
-
- - - -
- -
-Specification - - - -
include Math::MulDivAbortsIf{x: config.base_reward_per_block, y: new_epoch_block_time_target, z: config.base_block_time_target};
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/ConsensusStrategy.md b/build/StarcoinFramework/docs/ConsensusStrategy.md deleted file mode 100644 index f8f72b50..00000000 --- a/build/StarcoinFramework/docs/ConsensusStrategy.md +++ /dev/null @@ -1,143 +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) -- [Module Specification](#@Module_Specification_0) - - -
use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::Timestamp;
-
- - - - - -## Struct `ConsensusStrategy` - -ConsensusStrategy data. - - -
struct ConsensusStrategy has copy, drop, store
-
- - - -
-Fields - - -
-
-value: u8 -
-
- Value of strategy -
-
- - -
- - - -## Function `initialize` - -Publish the chain ID under the genesis account - - -
public fun initialize(account: &signer, consensus_strategy: u8)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::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` - -Return the consensus strategy type of this chain - - -
public fun get(): u8
-
- - - -
-Implementation - - -
public fun get(): u8 {
-    Config::get_by_address<ConsensusStrategy>(CoreAddresses::GENESIS_ADDRESS()).value
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Config::Config<ConsensusStrategy>>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/CoreAddresses.md b/build/StarcoinFramework/docs/CoreAddresses.md deleted file mode 100644 index 70f433be..00000000 --- a/build/StarcoinFramework/docs/CoreAddresses.md +++ /dev/null @@ -1,178 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Implementation - - -
public fun GENESIS_ADDRESS(): address {
-    @0x1
-}
-
- - - -
- - - -## Function `assert_genesis_address` - -Assert signer is genesis. - - -
public fun assert_genesis_address(account: &signer)
-
- - - -
-Implementation - - -
public fun assert_genesis_address(account: &signer) {
-    assert!(Signer::address_of(account) == GENESIS_ADDRESS(),
-            Errors::requires_address(ENOT_GENESIS_ACCOUNT))
-}
-
- - - -
- -
-Specification - - - -
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) != GENESIS_ADDRESS();
-}
-
- - - -
- - - -## Function `ASSOCIATION_ROOT_ADDRESS` - -The address of the root association account. This account is -created in genesis, and cannot be changed. This address has -ultimate authority over the permissions granted (or removed) from -accounts on-chain. - - -
public fun ASSOCIATION_ROOT_ADDRESS(): address
-
- - - -
-Implementation - - -
public fun ASSOCIATION_ROOT_ADDRESS(): address {
-    @0xA550C18
-}
-
- - - -
- - - -## Function `VM_RESERVED_ADDRESS` - -The reserved address for transactions inserted by the VM into blocks (e.g. -block metadata transactions). Because the transaction is sent from -the VM, an account _cannot_ exist at the 0x0 address since there -is no signer for the transaction. - - -
public fun VM_RESERVED_ADDRESS(): address
-
- - - -
-Implementation - - -
public fun VM_RESERVED_ADDRESS(): address {
-    @0x0
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/Dao.md b/build/StarcoinFramework/docs/Dao.md deleted file mode 100644 index db025649..00000000 --- a/build/StarcoinFramework/docs/Dao.md +++ /dev/null @@ -1,2330 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-next_proposal_id: u64 -
-
- next proposal id. -
-
-proposal_create_event: Event::EventHandle<Dao::ProposalCreatedEvent> -
-
- proposal creating event. -
-
-vote_changed_event: Event::EventHandle<Dao::VoteChangedEvent> -
-
- voting event. -
-
- - -
- - - -## Struct `DaoConfig` - -Configuration of the Token's DAO. - - -
struct DaoConfig<TokenT: copy, drop, store> has copy, drop, store
-
- - - -
-Fields - - -
-
-voting_delay: u64 -
-
- after proposal created, how long use should wait before he can vote (in milliseconds) -
-
-voting_period: u64 -
-
- how long the voting window is (in milliseconds). -
-
-voting_quorum_rate: u8 -
-
- the quorum rate to agree on the proposal. - if 50% votes needed, then the voting_quorum_rate should be 50. - it should between (0, 100]. -
-
-min_action_delay: u64 -
-
- how long the proposal should wait before it can be executed (in milliseconds). -
-
- - -
- -
-Specification - - - -
invariant voting_quorum_rate > 0 && voting_quorum_rate <= 100;
-invariant voting_delay > 0;
-invariant voting_period > 0;
-invariant min_action_delay > 0;
-
- - - -
- - - -## Struct `ProposalCreatedEvent` - -emitted when proposal created. - - -
struct ProposalCreatedEvent has drop, store
-
- - - -
-Fields - - -
-
-proposal_id: u64 -
-
- the proposal id. -
-
-proposer: address -
-
- proposer is the user who create the proposal. -
-
- - -
- - - -## Struct `VoteChangedEvent` - -emitted when user vote/revoke_vote. - - -
struct VoteChangedEvent has drop, store
-
- - - -
-Fields - - -
-
-proposal_id: u64 -
-
- the proposal id. -
-
-voter: address -
-
- the voter. -
-
-proposer: address -
-
- creator of the proposal. -
-
-agree: bool -
-
- agree with the proposal or not -
-
-vote: u128 -
-
- latest vote count of the voter. -
-
- - -
- - - -## Resource `Proposal` - -Proposal data struct. - - -
struct Proposal<Token: store, Action: store> has key
-
- - - -
-Fields - - -
-
-id: u64 -
-
- id of the proposal -
-
-proposer: address -
-
- creator of the proposal -
-
-start_time: u64 -
-
- when voting begins. -
-
-end_time: u64 -
-
- when voting ends. -
-
-for_votes: u128 -
-
- count of voters who agree with the proposal -
-
-against_votes: u128 -
-
- count of voters who're against the proposal -
-
-eta: u64 -
-
- executable after this time. -
-
-action_delay: u64 -
-
- after how long, the agreed proposal can be executed. -
-
-quorum_votes: u128 -
-
- how many votes to reach to make the proposal pass. -
-
-action: Option::Option<Action> -
-
- proposal action. -
-
- - -
- - - -## Resource `Vote` - -User vote info. - - -
struct Vote<TokenT: store> has key
-
- - - -
-Fields - - -
-
-proposer: address -
-
- vote for the proposal under the proposer. -
-
-id: u64 -
-
- proposal id. -
-
-stake: Token::Token<TokenT> -
-
- how many tokens to stake. -
-
-agree: bool -
-
- vote for or vote against. -
-
- - -
- - - -## Constants - - - - - - -
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 have 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)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
let sender = Signer::address_of(signer);
-aborts_if sender != Token::SPEC_TOKEN_TEST_ADDRESS();
-include NewDaoConfigParamSchema<TokenT>;
-include Config::PublishNewConfigAbortsIf<DaoConfig<TokenT>>{account: signer};
-aborts_if exists<DaoGlobalInfo<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::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` - -create a 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>
-
- - - -
-Implementation - - -
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 }
-}
-
- - - -
- -
-Specification - - - -
include NewDaoConfigParamSchema<TokenT>;
-
- - - - - - - -
schema NewDaoConfigParamSchema<TokenT> {
-    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;
-}
-
- - - -
- - - -## Function `propose` - -propose a proposal. -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)
-
- - - -
-Implementation - - -
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,
-        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 },
-    );
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-let proposer = Signer::address_of(signer);
-include GenerateNextProposalIdSchema<TokenT>;
-pragma addition_overflow_unchecked = true;
-include AbortIfDaoConfigNotExist<TokenT>;
-include AbortIfDaoInfoNotExist<TokenT>;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::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` - -votes for a proposal. -User can only vote once, then the stake is locked, -which can only be unstaked by user after the proposal is expired, or cancelled, or executed. -So think twice before casting 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)
-
- - - -
-Implementation - - -
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,
-        },
-    );
-}
-
- - - -
- -
-Specification - - - -
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>)
-
- - - -
-Implementation - - -
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;
-    };
-}
-
- - - -
- -
-Specification - - - -
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` - -Let user change their vote during the voting time. - - -
public fun change_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64, agree: bool)
-
- - - -
-Implementation - - -
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,
-            },
-        );
-    };
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-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
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
include CheckFlipVote<TokenT, ActionT>;
-ensures my_vote.agree == !old(my_vote).agree;
-
- - - -
- - - -## Function `revoke_vote` - -Revoke some voting powers from vote on 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>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-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>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
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` - -Retrieve back my staked token voted for a proposal. - - -
public fun unstake_votes<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64): Token::Token<TokenT>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-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` - -queue agreed proposal to execute. - - -
public entry fun queue_proposal_action<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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;
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-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` - -extract proposal action to execute. - - -
public fun extract_proposal_action<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64): ActionT
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
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` - -remove terminated proposal from proposer - - -
public entry fun destroy_terminated_proposal<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
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` - -check whether a proposal exists in 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
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
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` - -Get the proposal state. - - -
public fun proposal_state<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64): u8
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
include AbortIfTimestampNotExist;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::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 `do_proposal_state` - - - -
fun do_proposal_state<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposal: &Dao::Proposal<TokenT, ActionT>, current_time: u64): u8
-
- - - -
-Implementation - - -
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
-    }
-}
-
- - - -
- - - -## Function `proposal_info` - -get proposal's information. -return: (id, start_time, end_time, for_votes, against_votes). - - -
public fun proposal_info<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address): (u64, u64, u64, u128, u128)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Proposal<TokenT, ActionT>>(proposer_address);
-
- - - -
- - - -## Function `vote_of` - -Get voter's vote info on proposal with proposal_id of proposer_address. - - -
public fun vote_of<TokenT: copy, drop, store>(voter: address, proposer_address: address, proposal_id: u64): (bool, u128)
-
- - - -
-Implementation - - -
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))
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Vote<TokenT>>(voter);
-let vote = global<Vote<TokenT>>(voter);
-include CheckVoteOnProposal<TokenT>{vote, proposer_address, proposal_id};
-
- - - -
- - - -## Function `has_vote` - -Check whether voter has voted on proposal with proposal_id of proposer_address. - - -
public fun has_vote<TokenT: copy, drop, store>(voter: address, proposer_address: address, proposal_id: u64): bool
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `generate_next_proposal_id` - - - -
fun generate_next_proposal_id<TokenT: store>(): u64
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
include GenerateNextProposalIdSchema<TokenT>;
-ensures result == old(global<DaoGlobalInfo<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS()).next_proposal_id);
-
- - - - - - - -
schema GenerateNextProposalIdSchema<TokenT> {
-    aborts_if global<DaoGlobalInfo<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS()).next_proposal_id >= MAX_U64;
-    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;
-}
-
- - - -
- - - -## Function `voting_delay` - -get default voting delay of the DAO. - - -
public fun voting_delay<TokenT: copy, drop, store>(): u64
-
- - - -
-Implementation - - -
public fun voting_delay<TokenT: copy + drop + store>(): u64 {
-    get_config<TokenT>().voting_delay
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `voting_period` - -get the default voting period of the DAO. - - -
public fun voting_period<TokenT: copy, drop, store>(): u64
-
- - - -
-Implementation - - -
public fun voting_period<TokenT: copy + drop + store>(): u64 {
-    get_config<TokenT>().voting_period
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `quorum_votes` - -Quorum votes to make proposal pass. - - -
public fun quorum_votes<TokenT: copy, drop, store>(): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-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` - -Get the quorum rate in percent. - - -
public fun voting_quorum_rate<TokenT: copy, drop, store>(): u8
-
- - - -
-Implementation - - -
public fun voting_quorum_rate<TokenT: copy + drop + store>(): u8 {
-    get_config<TokenT>().voting_quorum_rate
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == global<Config::Config<DaoConfig<TokenT>>>((Token::SPEC_TOKEN_TEST_ADDRESS())).payload.voting_quorum_rate;
-
- - - -
- - - -## Function `min_action_delay` - -Get the min_action_delay of the DAO. - - -
public fun min_action_delay<TokenT: copy, drop, store>(): u64
-
- - - -
-Implementation - - -
public fun min_action_delay<TokenT: copy + drop + store>(): u64 {
-    get_config<TokenT>().min_action_delay
-}
-
- - - -
- -
-Specification - - - -
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>
-
- - - -
-Implementation - - -
fun get_config<TokenT: copy + drop + store>(): DaoConfig<TokenT> {
-    let token_issuer = Token::token_address<TokenT>();
-    Config::get_by_address<DaoConfig<TokenT>>(token_issuer)
-}
-
- - - -
- -
-Specification - - - -
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` - -update function, modify dao config. -if any param is 0, it means no change to that param. - - -
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)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
include CheckModifyConfigWithCap<TokenT>;
-aborts_if voting_quorum_rate > 0 && voting_quorum_rate > 100;
-
- - - -
- - - -## Function `set_voting_delay` - -set voting delay - - -
public fun set_voting_delay<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
include CheckModifyConfigWithCap<TokenT>;
-aborts_if value == 0;
-
- - - -
- - - -## Function `set_voting_period` - -set voting period - - -
public fun set_voting_period<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
include CheckModifyConfigWithCap<TokenT>;
-aborts_if value == 0;
-
- - - -
- - - -## Function `set_voting_quorum_rate` - -set voting quorum rate - - -
public fun set_voting_quorum_rate<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u8)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if !(value > 0 && value <= 100);
-include CheckModifyConfigWithCap<TokenT>;
-
- - - -
- - - -## Function `set_min_action_delay` - -set min action delay - - -
public fun set_min_action_delay<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if value == 0;
-include CheckModifyConfigWithCap<TokenT>;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/DaoVoteScripts.md b/build/StarcoinFramework/docs/DaoVoteScripts.md deleted file mode 100644 index 7bd67431..00000000 --- a/build/StarcoinFramework/docs/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) -- [Module Specification](#@Module_Specification_0) - - -
use 0x1::Account;
-use 0x1::Dao;
-use 0x1::Signer;
-use 0x1::Token;
-
- - - - - -## Function `cast_vote` - - - -
public entry fun cast_vote<Token: copy, drop, store, ActionT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64, agree: bool, votes: u128)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- - - -## Function `revoke_vote` - -revoke all votes on a proposal - - -
public entry fun revoke_vote<Token: copy, drop, store, Action: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- - - -## Function `flip_vote` - -Let user change their vote during the voting time. - - -
public entry fun flip_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- - - -## Function `revoke_vote_of_power` - -revoke some votes on a proposal - - -
public entry fun revoke_vote_of_power<Token: copy, drop, store, Action: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64, power: u128)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- - - -## Function `unstake_vote` - - - -
public entry fun unstake_vote<Token: copy, drop, store, Action: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_partial = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/Debug.md b/build/StarcoinFramework/docs/Debug.md deleted file mode 100644 index 9d714ba9..00000000 --- a/build/StarcoinFramework/docs/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) -- [Module Specification](#@Module_Specification_0) - - -
- - - - - -## Function `print` - -Print data of Type T. - - -
public fun print<T: store>(x: &T)
-
- - - -
-Implementation - - -
native public fun print<T: store>(x: &T);
-
- - - -
- - - -## Function `print_stack_trace` - -Print current stack. - - -
public fun print_stack_trace()
-
- - - -
-Implementation - - -
native public fun print_stack_trace();
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/DummyToken.md b/build/StarcoinFramework/docs/DummyToken.md deleted file mode 100644 index ebf1331d..00000000 --- a/build/StarcoinFramework/docs/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 entry fun mint(sender: signer, amount: u128)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
diff --git a/build/StarcoinFramework/docs/EmptyScripts.md b/build/StarcoinFramework/docs/EmptyScripts.md deleted file mode 100644 index 08c13a3c..00000000 --- a/build/StarcoinFramework/docs/EmptyScripts.md +++ /dev/null @@ -1,48 +0,0 @@ - - - -# Module `0x1::EmptyScripts` - - - -- [Function `empty_script`](#0x1_EmptyScripts_empty_script) -- [Module Specification](#@Module_Specification_0) - - -
- - - - - -## Function `empty_script` - - - -
public entry fun empty_script()
-
- - - -
-Implementation - - -
public entry fun empty_script() {
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_partial = false;
-pragma aborts_if_is_strict = false;
-
diff --git a/build/StarcoinFramework/docs/Epoch.md b/build/StarcoinFramework/docs/Epoch.md deleted file mode 100644 index 17ac2e3c..00000000 --- a/build/StarcoinFramework/docs/Epoch.md +++ /dev/null @@ -1,1041 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-number: u64 -
-
- Number of current epoch -
-
-start_time: u64 -
-
- Start time of current epoch -
-
-start_block_number: u64 -
-
- Start block's number of current epoch -
-
-end_block_number: u64 -
-
- End block's number of current epoch -
-
-block_time_target: u64 -
-
- Average target time to calculate a block's difficulty in current epoch -
-
-reward_per_block: u128 -
-
- Rewards per block in current epoch -
-
-reward_per_uncle_percent: u64 -
-
- Percentage of reward_per_block to reward a uncle block in current epoch -
-
-block_difficulty_window: u64 -
-
- How many ancestor blocks which use to calculate next block's difficulty in current epoch -
-
-max_uncles_per_block: u64 -
-
- Maximum number of uncle block per block in current epoch -
-
-block_gas_limit: u64 -
-
- Maximum gases per block in current epoch -
-
-strategy: u8 -
-
- Strategy to calculate difficulty in current epoch -
-
-new_epoch_events: Event::EventHandle<Epoch::NewEpochEvent> -
-
- Switch Epoch Event -
-
- - -
- - - -## Struct `NewEpochEvent` - -New epoch event. - - -
struct NewEpochEvent has drop, store
-
- - - -
-Fields - - -
-
-number: u64 -
-
- Epoch::number -
-
-start_time: u64 -
-
- Epoch::start_time -
-
-start_block_number: u64 -
-
- Epoch::start_block_number -
-
-end_block_number: u64 -
-
- Epoch::end_block_number -
-
-block_time_target: u64 -
-
- Epoch::block_time_target -
-
-reward_per_block: u128 -
-
- Epoch::reward_per_block -
-
-previous_epoch_total_reward: u128 -
-
- Total rewards during previous epoch -
-
- - -
- - - -## Resource `EpochData` - -Epoch data. - - -
struct EpochData has key
-
- - - -
-Fields - - -
-
-uncles: u64 -
-
- Up to now, Number of uncle block during current epoch -
-
-total_reward: u128 -
-
- Up to now, Total rewards during current epoch -
-
-total_gas: u128 -
-
- Up to now, Total gases during current epoch -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
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 });
-}
-
- - - -
- -
-Specification - - - -
aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
-aborts_if !exists<Config::Config<ConsensusConfig>>(CoreAddresses::GENESIS_ADDRESS());
-aborts_if exists<Epoch>(Signer::address_of(account));
-aborts_if exists<EpochData>(Signer::address_of(account));
-
- - - -
- - - -## Function `compute_next_block_time_target` - -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
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `adjust_epoch` - -adjust_epoch try to advance to next epoch if current epoch ends. - - -
public fun adjust_epoch(account: &signer, block_number: u64, timestamp: u64, uncles: u64, parent_gas_used: u64): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-aborts_if Signer::address_of(account) != CoreAddresses::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)
-
- - - -
-Implementation - - -
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);
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `compute_gas_limit` - -Compute block's gas limit of next epoch. - - -
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>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
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
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
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)
-
- - - -
-Implementation - - -
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);
-    }
-}
-
- - - -
- -
-Specification - - - -
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)
-
- - - -
-Implementation - - -
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,
-        },
-    );
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `start_time` - -Get start time of current epoch - - -
public fun start_time(): u64
-
- - - -
-Implementation - - -
public fun start_time(): u64 acquires Epoch {
-    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-    epoch_ref.start_time
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `uncles` - -Get uncles number of current epoch - - -
public fun uncles(): u64
-
- - - -
-Implementation - - -
public fun uncles(): u64 acquires EpochData {
-    let epoch_data = borrow_global<EpochData>(CoreAddresses::GENESIS_ADDRESS());
-    epoch_data.uncles
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<EpochData>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `total_gas` - -Get total gas of current epoch - - -
public fun total_gas(): u128
-
- - - -
-Implementation - - -
public fun total_gas(): u128 acquires EpochData {
-    let epoch_data = borrow_global<EpochData>(CoreAddresses::GENESIS_ADDRESS());
-    epoch_data.total_gas
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<EpochData>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `block_gas_limit` - -Get block's gas_limit of current epoch - - -
public fun block_gas_limit(): u64
-
- - - -
-Implementation - - -
public fun block_gas_limit(): u64 acquires Epoch {
-    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-    epoch_ref.block_gas_limit
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `start_block_number` - -Get start block's number of current epoch - - -
public fun start_block_number(): u64
-
- - - -
-Implementation - - -
public fun start_block_number(): u64 acquires Epoch {
-    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-    epoch_ref.start_block_number
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `end_block_number` - -Get end block's number of current epoch - - -
public fun end_block_number(): u64
-
- - - -
-Implementation - - -
public fun end_block_number(): u64 acquires Epoch {
-    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-    epoch_ref.end_block_number
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `number` - -Get current epoch number - - -
public fun number(): u64
-
- - - -
-Implementation - - -
public fun number(): u64 acquires Epoch {
-    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-    epoch_ref.number
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `block_time_target` - -Get current block time target - - -
public fun block_time_target(): u64
-
- - - -
-Implementation - - -
public fun block_time_target(): u64 acquires Epoch {
-    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-    epoch_ref.block_time_target
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/Errors.md b/build/StarcoinFramework/docs/Errors.md deleted file mode 100644 index 75b214eb..00000000 --- a/build/StarcoinFramework/docs/Errors.md +++ /dev/null @@ -1,623 +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) -- [Module Specification](#@Module_Specification_1) - - -
- - - - - -## 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
-
- - - -
-Implementation - - -
fun make(category: u8, reason: u64): u64 {
-    (category as u64) + (reason << 8)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-pragma verify = false;
-aborts_if [abstract] false;
-ensures [abstract] result == category;
-
- - - -
- - - -## Function `invalid_state` - -Create an error of invalid_state - - -
public fun invalid_state(reason: u64): u64
-
- - - -
-Implementation - - -
public fun invalid_state(reason: u64): u64 { make(INVALID_STATE, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == INVALID_STATE;
-
- - - -
- - - -## Function `requires_address` - -Create an error of requires_address. - - -
public fun requires_address(reason: u64): u64
-
- - - -
-Implementation - - -
public fun requires_address(reason: u64): u64 { make(REQUIRES_ADDRESS, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == REQUIRES_ADDRESS;
-
- - - -
- - - -## Function `requires_role` - -Create an error of requires_role. - - -
public fun requires_role(reason: u64): u64
-
- - - -
-Implementation - - -
public fun requires_role(reason: u64): u64 { make(REQUIRES_ROLE, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == REQUIRES_ROLE;
-
- - - -
- - - -## Function `requires_capability` - -Create an error of requires_capability. - - -
public fun requires_capability(reason: u64): u64
-
- - - -
-Implementation - - -
public fun requires_capability(reason: u64): u64 { make(REQUIRES_CAPABILITY, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == REQUIRES_CAPABILITY;
-
- - - -
- - - -## Function `not_published` - -Create an error of not_published. - - -
public fun not_published(reason: u64): u64
-
- - - -
-Implementation - - -
public fun not_published(reason: u64): u64 { make(NOT_PUBLISHED, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == NOT_PUBLISHED;
-
- - - -
- - - -## Function `already_published` - -Create an error of already_published. - - -
public fun already_published(reason: u64): u64
-
- - - -
-Implementation - - -
public fun already_published(reason: u64): u64 { make(ALREADY_PUBLISHED, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == ALREADY_PUBLISHED;
-
- - - -
- - - -## Function `invalid_argument` - -Create an error of invalid_argument. - - -
public fun invalid_argument(reason: u64): u64
-
- - - -
-Implementation - - -
public fun invalid_argument(reason: u64): u64 { make(INVALID_ARGUMENT, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == INVALID_ARGUMENT;
-
- - - -
- - - -## Function `limit_exceeded` - -Create an error of limit_exceeded. - - -
public fun limit_exceeded(reason: u64): u64
-
- - - -
-Implementation - - -
public fun limit_exceeded(reason: u64): u64 { make(LIMIT_EXCEEDED, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == LIMIT_EXCEEDED;
-
- - - -
- - - -## Function `internal` - -Create an error of internal. - - -
public fun internal(reason: u64): u64
-
- - - -
-Implementation - - -
public fun internal(reason: u64): u64 { make(INTERNAL, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == INTERNAL;
-
- - - -
- - - -## Function `deprecated` - -Create an error of deprecated. - - -
public fun deprecated(reason: u64): u64
-
- - - -
-Implementation - - -
public fun deprecated(reason: u64): u64 { make(DEPRECATED, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == DEPRECATED;
-
- - - -
- - - -## Function `custom` - -Create an error of custom. - - -
public fun custom(reason: u64): u64
-
- - - -
-Implementation - - -
public fun custom(reason: u64): u64 { make(CUSTOM, reason) }
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == CUSTOM;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/Event.md b/build/StarcoinFramework/docs/Event.md deleted file mode 100644 index aed6dda1..00000000 --- a/build/StarcoinFramework/docs/Event.md +++ /dev/null @@ -1,300 +0,0 @@ - - - -# Module `0x1::Event` - -The Event module defines an EventHandleGenerator that is used to create -EventHandles with unique GUIDs. It contains a counter for the number -of EventHandles 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) -- [Module Specification](#@Module_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
-
- - - -
-Fields - - -
-
-counter: u64 -
-
- -
-
-addr: address -
-
- -
-
- - -
- - - -## Struct `EventHandle` - -A handle for an event such that: -1. Other modules can emit events to this handle. -2. Storage can use this handle to prove the total number of events that happened in the past. - - -
struct EventHandle<T: drop, store> has store
-
- - - -
-Fields - - -
-
-counter: u64 -
-
- Total number of events emitted to this event stream. -
-
-guid: vector<u8> -
-
- A globally unique ID for this event stream. -
-
- - -
- - - -## Constants - - - - -The event generator resource was in an invalid state - - -
const EEVENT_GENERATOR: u64 = 0;
-
- - - - - -## Function `publish_generator` - -Publishs a new event handle generator. - - -
public fun publish_generator(account: &signer)
-
- - - -
-Implementation - - -
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 })
-}
-
- - - -
- - - -## Function `fresh_guid` - -Derive a fresh unique id by using sender's EventHandleGenerator. The generated vector is indeed unique because it -was derived from the hash(sender's EventHandleGenerator || sender_address). This module guarantees that the -EventHandleGenerator is only going to be monotonically increased and there's no way to revert it or destroy it. Thus -such counter is going to give distinct value for each of the new event stream under each sender. And since we -hash it with the sender's address, the result is guaranteed to be globally unique. - - -
fun fresh_guid(counter: &mut Event::EventHandleGenerator): vector<u8>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `new_event_handle` - -Use EventHandleGenerator to generate a unique event handle for sig - - -
public fun new_event_handle<T: drop, store>(account: &signer): Event::EventHandle<T>
-
- - - -
-Implementation - - -
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))
-    }
-}
-
- - - -
- - - -## Function `emit_event` - -Emit an event with payload msg by using handle_ref's key and counter. - - -
public fun emit_event<T: drop, store>(handle_ref: &mut Event::EventHandle<T>, msg: T)
-
- - - -
-Implementation - - -
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;
-}
-
- - - -
- - - -## Function `write_to_event_store` - -Native procedure that writes to the actual event stream in Event store -This will replace the "native" portion of EmitEvent bytecode - - -
fun write_to_event_store<T: drop, store>(guid: vector<u8>, count: u64, msg: T)
-
- - - -
-Implementation - - -
native fun write_to_event_store<T: drop + store>(guid: vector<u8>, count: u64, msg: T);
-
- - - -
- - - -## Function `destroy_handle` - -Destroy a unique handle. - - -
public fun destroy_handle<T: drop, store>(handle: Event::EventHandle<T>)
-
- - - -
-Implementation - - -
public fun destroy_handle<T: drop + store>(handle: EventHandle<T>) {
-    EventHandle<T> { counter: _, guid: _ } = handle;
-}
-
- - - -
- - - -## Module Specification - - - -Functions of the event module are mocked out using the intrinsic -pragma. They are implemented in the prover's prelude. - - -
pragma intrinsic = true;
-
diff --git a/build/StarcoinFramework/docs/EventUtil.md b/build/StarcoinFramework/docs/EventUtil.md deleted file mode 100644 index 420e3c6f..00000000 --- a/build/StarcoinFramework/docs/EventUtil.md +++ /dev/null @@ -1,175 +0,0 @@ - - - -# Module `0x1::EventUtil` - - - -- [Resource `EventHandleWrapper`](#0x1_EventUtil_EventHandleWrapper) -- [Constants](#@Constants_0) -- [Function `init_event`](#0x1_EventUtil_init_event) -- [Function `uninit_event`](#0x1_EventUtil_uninit_event) -- [Function `emit_event`](#0x1_EventUtil_emit_event) -- [Function `exist_event`](#0x1_EventUtil_exist_event) - - -
use 0x1::Errors;
-use 0x1::Event;
-use 0x1::Signer;
-
- - - - - -## Resource `EventHandleWrapper` - - - -
struct EventHandleWrapper<EventT: drop, store> has key
-
- - - -
-Fields - - -
-
-handle: Event::EventHandle<EventT> -
-
- -
-
- - -
- - - -## Constants - - - - - - -
const ERR_INIT_REPEATE: u64 = 101;
-
- - - - - - - -
const ERR_RESOURCE_NOT_EXISTS: u64 = 102;
-
- - - - - -## Function `init_event` - - - -
public fun init_event<EventT: drop, store>(sender: &signer)
-
- - - -
-Implementation - - -
public fun init_event<EventT: store + drop>(sender: &signer) {
-    let broker = Signer::address_of(sender);
-    assert!(!exists<EventHandleWrapper<EventT>>(broker), Errors::invalid_state(ERR_INIT_REPEATE));
-    move_to(sender, EventHandleWrapper<EventT> {
-        handle: Event::new_event_handle<EventT>(sender)
-    });
-}
-
- - - -
- - - -## Function `uninit_event` - - - -
public fun uninit_event<EventT: drop, store>(sender: &signer)
-
- - - -
-Implementation - - -
public fun uninit_event<EventT: store + drop>(sender: &signer) acquires EventHandleWrapper {
-    let broker = Signer::address_of(sender);
-    assert!(exists<EventHandleWrapper<EventT>>(broker), Errors::invalid_state(ERR_RESOURCE_NOT_EXISTS));
-    let EventHandleWrapper<EventT> { handle } = move_from<EventHandleWrapper<EventT>>(broker);
-    Event::destroy_handle<EventT>(handle);
-}
-
- - - -
- - - -## Function `emit_event` - - - -
public fun emit_event<EventT: drop, store>(broker: address, event: EventT)
-
- - - -
-Implementation - - -
public fun emit_event<EventT: store + drop>(broker: address, event: EventT) acquires EventHandleWrapper {
-    let event_handle = borrow_global_mut<EventHandleWrapper<EventT>>(broker);
-    Event::emit_event(&mut event_handle.handle, event);
-}
-
- - - -
- - - -## Function `exist_event` - - - -
public fun exist_event<EventT: drop, store>(broker: address): bool
-
- - - -
-Implementation - - -
public fun exist_event<EventT: store + drop>(broker: address): bool {
-    exists<EventHandleWrapper<EventT>>(broker)
-}
-
- - - -
diff --git a/build/StarcoinFramework/docs/FixedPoint32.md b/build/StarcoinFramework/docs/FixedPoint32.md deleted file mode 100644 index 16bc13d8..00000000 --- a/build/StarcoinFramework/docs/FixedPoint32.md +++ /dev/null @@ -1,439 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-value: u64 -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - -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;
-include MultiplyAbortsIf;
-ensures result == spec_multiply_u64(val, multiplier);
-
- - - - - - - -
schema MultiplyAbortsIf {
-    val: num;
-    multiplier: FixedPoint32;
-    aborts_if spec_multiply_u64(val, multiplier) > MAX_U64 with Errors::LIMIT_EXCEEDED;
-}
-
- - - - - - - -
fun spec_multiply_u64(val: num, multiplier: FixedPoint32): num {
-   (val * multiplier.value) >> 32
-}
-
- - - -
- - - -## Function `divide_u64` - -Divide a u64 integer by a fixed-point number, truncating any -fractional part of the quotient. This will abort if the divisor -is zero or if the quotient overflows. - - -
public fun divide_u64(val: u64, divisor: FixedPoint32::FixedPoint32): u64
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - -See comment at Self::multiply_64. - - -
pragma opaque = true;
-include DivideAbortsIf;
-ensures result == spec_divide_u64(val, divisor);
-
- - - - - - - -
schema DivideAbortsIf {
-    val: num;
-    divisor: FixedPoint32;
-    aborts_if divisor.value == 0 with Errors::INVALID_ARGUMENT;
-    aborts_if spec_divide_u64(val, divisor) > MAX_U64 with Errors::LIMIT_EXCEEDED;
-}
-
- - - - - - - -
fun spec_divide_u64(val: num, divisor: FixedPoint32): num {
-   (val << 32) / divisor.value
-}
-
- - - -
- - - -## Function `create_from_rational` - -Create a fixed-point value from a rational number specified by its -numerator and denominator. This function is for convenience; it is also -perfectly fine to create a fixed-point value by directly specifying the -raw value. This will abort if the denominator is zero or if the ratio is -not in the range 2^-32 .. 2^32-1. - - -
public fun create_from_rational(numerator: u64, denominator: u64): FixedPoint32::FixedPoint32
-
- - - -
-Implementation - - -
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) }
-}
-
- - - -
- -
-Specification - - -See comment at Self::multiply_64. - - -
pragma verify = false;
-pragma opaque = true;
-include CreateFromRationalAbortsIf;
-ensures result == spec_create_from_rational(numerator, denominator);
-
- - - - - - - -
schema CreateFromRationalAbortsIf {
-    numerator: u64;
-    denominator: u64;
-    let scaled_numerator = numerator << 64;
-    let scaled_denominator = denominator << 32;
-    let quotient = scaled_numerator / scaled_denominator;
-    aborts_if scaled_denominator == 0 with Errors::INVALID_ARGUMENT;
-    aborts_if quotient == 0 && scaled_numerator != 0 with Errors::INVALID_ARGUMENT;
-    aborts_if quotient > MAX_U64 with Errors::LIMIT_EXCEEDED;
-}
-
- - - - - - - -
fun spec_create_from_rational(numerator: num, denominator: num): FixedPoint32 {
-   FixedPoint32{value: (numerator << 64) / (denominator << 32)}
-}
-
- - - -
- - - -## Function `create_from_raw_value` - -create a fixedpoint 32 from u64. - - -
public fun create_from_raw_value(value: u64): FixedPoint32::FixedPoint32
-
- - - -
-Implementation - - -
public fun create_from_raw_value(value: u64): FixedPoint32 {
-    FixedPoint32 { value }
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if false;
-ensures result.value == value;
-
- - - -
- - - -## Function `get_raw_value` - -Accessor for the raw u64 value. Other less common operations, such as -adding or subtracting FixedPoint32 values, can be done using the raw -values directly. - - -
public fun get_raw_value(num: FixedPoint32::FixedPoint32): u64
-
- - - -
-Implementation - - -
public fun get_raw_value(num: FixedPoint32): u64 {
-    num.value
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/FromBCS.md b/build/StarcoinFramework/docs/FromBCS.md deleted file mode 100644 index c9094f7c..00000000 --- a/build/StarcoinFramework/docs/FromBCS.md +++ /dev/null @@ -1,205 +0,0 @@ - - - -# Module `0x1::FromBCS` - -This module provides a number of functions to convert _primitive_ types from their representation in std::bcs -to values. This is the opposite of bcs::to_bytes. Note that it is not safe to define a generic public from_bytes -function because this can violate implicit struct invariants, therefore only primitive types are offerred. If -a general conversion back-and-force is needed, consider the StarcoinFramework::Any type which preserves invariants. - -Example: -``` -use std::bcs; -use StarcoinFramework::from_bcs; - -assert!(from_bcs::to_address(bcs::to_bytes(&@0xabcdef)) == @0xabcdef, 0); -``` - - -- [Constants](#@Constants_0) -- [Function `to_bool`](#0x1_FromBCS_to_bool) -- [Function `to_u8`](#0x1_FromBCS_to_u8) -- [Function `to_u64`](#0x1_FromBCS_to_u64) -- [Function `to_u128`](#0x1_FromBCS_to_u128) -- [Function `to_address`](#0x1_FromBCS_to_address) -- [Function `from_bytes`](#0x1_FromBCS_from_bytes) - - -
- - - - - -## Constants - - - - -UTF8 check failed in conversion from bytes to string - - -
const EINVALID_UTF8: u64 = 1;
-
- - - - - -## Function `to_bool` - - - -
public fun to_bool(v: vector<u8>): bool
-
- - - -
-Implementation - - -
public fun to_bool(v: vector<u8>): bool {
-    from_bytes<bool>(v)
-}
-
- - - -
- - - -## Function `to_u8` - - - -
public fun to_u8(v: vector<u8>): u8
-
- - - -
-Implementation - - -
public fun to_u8(v: vector<u8>): u8 {
-    from_bytes<u8>(v)
-}
-
- - - -
- - - -## Function `to_u64` - - - -
public fun to_u64(v: vector<u8>): u64
-
- - - -
-Implementation - - -
public fun to_u64(v: vector<u8>): u64 {
-    from_bytes<u64>(v)
-}
-
- - - -
- - - -## Function `to_u128` - - - -
public fun to_u128(v: vector<u8>): u128
-
- - - -
-Implementation - - -
public fun to_u128(v: vector<u8>): u128 {
-    from_bytes<u128>(v)
-}
-
- - - -
- - - -## Function `to_address` - - - -
public fun to_address(v: vector<u8>): address
-
- - - -
-Implementation - - -
public fun to_address(v: vector<u8>): address {
-    from_bytes<address>(v)
-}
-
- - - -
- - - -## Function `from_bytes` - -Package private native function to deserialize a type T. - -Note that this function does not put any constraint on T. If code uses this function to -deserialize a linear value, its their responsibility that the data they deserialize is -owned. - - -
public(friend) fun from_bytes<T>(bytes: vector<u8>): T
-
- - - -
-Implementation - - -
public(friend) native fun from_bytes<T>(bytes: vector<u8>): T;
-
- - - -
- -
-Specification - - - -
pragma opaque;
-
- - - -
diff --git a/build/StarcoinFramework/docs/GasSchedule.md b/build/StarcoinFramework/docs/GasSchedule.md deleted file mode 100644 index c88ffa45..00000000 --- a/build/StarcoinFramework/docs/GasSchedule.md +++ /dev/null @@ -1,513 +0,0 @@ - - - -# Module `0x1::GasSchedule` - -Gas schedule configuration. - - -- [Struct `GasEntry`](#0x1_GasSchedule_GasEntry) -- [Resource `GasSchedule`](#0x1_GasSchedule_GasSchedule) -- [Function `gas_schedule`](#0x1_GasSchedule_gas_schedule) -- [Function `new_gas_entry`](#0x1_GasSchedule_new_gas_entry) -- [Function `new_constant_entry`](#0x1_GasSchedule_new_constant_entry) -- [Function `initialize`](#0x1_GasSchedule_initialize) -- [Function `new_gas_schedule_for_test`](#0x1_GasSchedule_new_gas_schedule_for_test) -- [Module Specification](#@Module_Specification_0) - - -
use 0x1::ChainId;
-use 0x1::Config;
-use 0x1::CoreAddresses;
-
- - - - - -## Struct `GasEntry` - - - -
struct GasEntry has copy, drop, store
-
- - - -
-Fields - - -
-
-key: vector<u8> -
-
- -
-
-val: u64 -
-
- -
-
- - -
- - - -## Resource `GasSchedule` - - - -
struct GasSchedule has copy, drop, store, key
-
- - - -
-Fields - - -
-
-entries: vector<GasSchedule::GasEntry> -
-
- -
-
- - -
- - - -## Function `gas_schedule` - -The 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 - - -
public fun gas_schedule(): vector<GasSchedule::GasEntry>
-
- - - -
-Implementation - - -
public fun gas_schedule(): vector<GasEntry> {
-    let table = Vector::empty();
-
-    // instruction_schedule
-    // POP
-    Vector::push_back(&mut table, new_gas_entry(b"instr.pop", 1, 1));
-    // RET
-    Vector::push_back(&mut table, new_gas_entry(b"instr.ret", 638, 1));
-    // BR_TRUE
-    Vector::push_back(&mut table, new_gas_entry(b"instr.br_true", 1, 1));
-    // BR_FALSE
-    Vector::push_back(&mut table, new_gas_entry(b"instr.br_false", 1, 1));
-    // BRANCH
-    Vector::push_back(&mut table, new_gas_entry(b"instr.branch", 1, 1));
-    // LD_U64
-    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_u64", 1, 1));
-    // LD_CONST
-    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_const.per_byte", 1, 1));
-    // LD_TRUE
-    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_true", 1, 1));
-    // LD_FALSE
-    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_false", 1, 1));
-    // COPY_LOC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.copy_loc.per_abs_mem_unit", 1, 1));
-    // MOVE_LOC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.move_loc.per_abs_mem_unit", 1, 1));
-    // ST_LOC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.st_loc.per_abs_mem_unit", 1, 1));
-    // MUT_BORROW_LOC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.mut_borrow_loc", 2, 1));
-    // IMM_BORROW_LOC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.imm_borrow_loc", 1, 1));
-    // MUT_BORROW_FIELD
-    Vector::push_back(&mut table, new_gas_entry(b"instr.mut_borrow_field", 1, 1));
-    // IMM_BORROW_FIELD
-    Vector::push_back(&mut table, new_gas_entry(b"instr.imm_borrow_field", 1, 1));
-    // CALL
-    Vector::push_back(&mut table, new_gas_entry(b"instr.call.per_arg", 1132, 1));
-    // PACK
-    Vector::push_back(&mut table, new_gas_entry(b"instr.pack.per_abs_mem_unit", 2, 1));
-    // UNPACK
-    Vector::push_back(&mut table, new_gas_entry(b"instr.unpack.per_abs_mem_unit", 2, 1));
-    // READ_REF
-    Vector::push_back(&mut table, new_gas_entry(b"instr.read_ref.per_abs_mem_unit", 1, 1));
-    // WRITE_REF
-    Vector::push_back(&mut table, new_gas_entry(b"instr.write_ref.per_abs_mem_unit", 1, 1));
-    // ADD
-    Vector::push_back(&mut table, new_gas_entry(b"instr.add", 1, 1));
-    // SUB
-    Vector::push_back(&mut table, new_gas_entry(b"instr.sub", 1, 1));
-    // MUL
-    Vector::push_back(&mut table, new_gas_entry(b"instr.mul", 1, 1));
-    // MOD
-    Vector::push_back(&mut table, new_gas_entry(b"instr.mod", 1, 1));
-    // DIV
-    Vector::push_back(&mut table, new_gas_entry(b"instr.div", 3, 1));
-    // BIT_OR
-    Vector::push_back(&mut table, new_gas_entry(b"instr.bit_or", 2, 1));
-    // BIT_AND
-    Vector::push_back(&mut table, new_gas_entry(b"instr.bit_and", 2, 1));
-    // XOR
-    Vector::push_back(&mut table, new_gas_entry(b"instr.xor", 1, 1));
-    // OR
-    Vector::push_back(&mut table, new_gas_entry(b"instr.or", 2, 1));
-    // AND
-    Vector::push_back(&mut table, new_gas_entry(b"instr.and", 1, 1));
-    // NOT
-    Vector::push_back(&mut table, new_gas_entry(b"instr.not", 1, 1));
-    // EQ
-    Vector::push_back(&mut table, new_gas_entry(b"instr.eq.per_abs_mem_unit", 1, 1));
-    // NEQ
-    Vector::push_back(&mut table, new_gas_entry(b"instr.neq.per_abs_mem_unit", 1, 1));
-    // LT
-    Vector::push_back(&mut table, new_gas_entry(b"instr.lt", 1, 1));
-    // GT
-    Vector::push_back(&mut table, new_gas_entry(b"instr.gt", 1, 1));
-    // LE
-    Vector::push_back(&mut table, new_gas_entry(b"instr.le", 2, 1));
-    // GE
-    Vector::push_back(&mut table, new_gas_entry(b"instr.ge", 1, 1));
-    // ABORT
-    Vector::push_back(&mut table, new_gas_entry(b"instr.abort", 1, 1));
-    // NOP
-    Vector::push_back(&mut table, new_gas_entry(b"instr.nop", 1, 1));
-    // EXISTS
-    Vector::push_back(&mut table, new_gas_entry(b"instr.exists.per_abs_mem_unit", 41, 1));
-    // MUT_BORROW_GLOBAL
-    Vector::push_back(&mut table, new_gas_entry(b"instr.mut_borrow_global.per_abs_mem_unit", 21, 1));
-    // IML_BORROW_GLOBAL
-    Vector::push_back(&mut table, new_gas_entry(b"instr.imm_borrow_global.per_abs_mem_unit", 23, 1));
-    // MOVE_FROM
-    Vector::push_back(&mut table, new_gas_entry(b"instr.move_from.per_abs_mem_unit", 459, 1));
-    // MOVE_TO
-    Vector::push_back(&mut table, new_gas_entry(b"instr.move_to.per_abs_mem_unit", 13, 1));
-    // FREEZE_REF
-    Vector::push_back(&mut table, new_gas_entry(b"instr.freeze_ref", 1, 1));
-    // SHL
-    Vector::push_back(&mut table, new_gas_entry(b"instr.shl", 2, 1));
-    // SHR
-    Vector::push_back(&mut table, new_gas_entry(b"instr.shr", 1, 1));
-    // LD_U8
-    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_u8", 1, 1));
-    // LD_U128
-    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_u128", 1, 1));
-
-    // CAST_U8
-    Vector::push_back(&mut table, new_gas_entry(b"instr.cast_u8", 2, 1));
-    // CAST_U64
-    Vector::push_back(&mut table, new_gas_entry(b"instr.cast_u64", 1, 1));
-    // CAST_U128
-    Vector::push_back(&mut table, new_gas_entry(b"instr.cast_u128", 1, 1));
-    // MUT_BORORW_FIELD_GENERIC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.mut_borrow_field_generic.base", 1, 1));
-    // IMM_BORORW_FIELD_GENERIC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.imm_borrow_field_generic.base", 1, 1));
-    // CALL_GENERIC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.call_generic.per_arg", 582, 1));
-    // PACK_GENERIC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.pack_generic.per_abs_mem_unit", 2, 1));
-    // UNPACK_GENERIC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.unpack_generic.per_abs_mem_unit", 2, 1));
-    // EXISTS_GENERIC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.exists_generic.per_abs_mem_unit", 34, 1));
-    // MUT_BORROW_GLOBAL_GENERIC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.mut_borrow_global_generic.per_abs_mem_unit", 15, 1));
-    // IMM_BORROW_GLOBAL_GENERIC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.imm_borrow_global_generic.per_abs_mem_unit", 14, 1));
-    // MOVE_FROM_GENERIC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.move_from_generic.per_abs_mem_unit", 13, 1));
-    // MOVE_TO_GENERIC
-    Vector::push_back(&mut table, new_gas_entry(b"instr.move_to_generic.per_abs_mem_unit", 27, 1));
-
-    // VEC_PACK
-    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_pack.per_elem", 84, 1));
-    // VEC_LEN
-    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_len.base", 98, 1));
-    // VEC_IMM_BORROW
-    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_imm_borrow.base", 1334, 1));
-    // VEC_MUT_BORROW
-    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_mut_borrow.base", 1902, 1));
-    // VEC_PUSH_BACK
-    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_push_back.per_abs_mem_unit", 53, 1));
-    // VEC_POP_BACK
-    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_pop_back.base", 227, 1));
-    // VEC_UNPACK
-    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_unpack.per_expected_elem", 572, 1));
-    // VEC_SWAP
-    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_swap.base", 1436, 1));
-
-    Vector::push_back(&mut table, new_constant_entry(b"instr.ld_u16", 3));
-    Vector::push_back(&mut table, new_constant_entry(b"instr.ld_u32", 2));
-    Vector::push_back(&mut table, new_constant_entry(b"instr.ld_u256", 3));
-    Vector::push_back(&mut table, new_constant_entry(b"instr.cast_u16", 3));
-    Vector::push_back(&mut table, new_constant_entry(b"instr.cast_u32", 2));
-    Vector::push_back(&mut table, new_constant_entry(b"instr.cast_u256", 3));
-
-    // native_schedule
-    //Hash::sha2_256 0
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.hash.sha2_256.per_byte", 21, 1));
-    //Hash::sha3_256 1
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.hash.sha3_256.per_byte", 64, 1));
-    //Signature::ed25519_verify 2
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.signature.ed25519_verify.per_byte", 61, 1));
-    //ED25519_THRESHOLD_VERIFY 3 this native funciton is deprecated
-    Vector::push_back(&mut table, new_gas_entry(b"", 3351, 1));
-    //BSC::to_bytes 4
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.bcs.to_bytes.per_byte_serialized", 181, 1));
-    //Vector::length 5
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.length.base", 98, 1));
-    //Vector::empty 6
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.empty.base", 84, 1));
-    //Vector::borrow 7
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.borrow.base", 1334, 1));
-    //Vector::borrow_mut 8
-    Vector::push_back(&mut table, new_gas_entry(b"", 1902, 1));
-    //Vector::push_back 9
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.push_back.legacy_per_abstract_memory_unit", 53, 1));
-    //Vector::pop_back 10
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.pop_back.base", 227, 1));
-    //Vector::destory_empty 11
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.destroy_empty.base", 572, 1));
-    //Vector::swap 12
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.swap.base", 1436, 1));
-    //Signature::ed25519_validate_pubkey 13
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.signature.ed25519_validate_key.per_byte", 26, 1));
-    //Signer::borrow_address 14
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.signer.borrow_address.base", 353, 1));
-    //Account::creator_signer 15
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.account.create_signer.base", 24, 1));
-    //Account::destroy_signer 16
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.account.destroy_signer.base", 212, 1));
-    //Event::emit_event 17
-    Vector::push_back(&mut table, new_gas_entry(b"nursery.event.write_to_event_store.unit_cost", 52, 1));
-    //BCS::to_address 18
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.bcs.to_address.per_byte", 26, 1));
-    //Token::name_of 19
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.token.name_of.base", 2002, 1));
-    //Hash::keccak_256 20
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.hash.keccak256.per_byte", 64, 1));
-    //Hash::ripemd160 21
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.hash.ripemd160.per_byte", 64, 1));
-    //Signature::native_ecrecover 22
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.signature.ec_recover.per_byte", 128, 1));
-    //U256::from_bytes 23
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.from_bytes.per_byte", 2, 1));
-    //U256::add 24
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.add.base", 4, 1));
-    //U256::sub 25
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.sub.base", 4, 1));
-    //U256::mul 26
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.mul.base", 4, 1));
-    //U256::div 27
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.div.base", 10, 1));
-    // U256::rem 28
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.rem.base", 4, 1));
-    // U256::pow 29
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.pow.base", 8, 1));
-    // TODO: settle down the gas cost
-    // Vector::append 30
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.append.legacy_per_abstract_memory_unit", 40, 1));
-    // Vector::remove 31
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.remove.legacy_per_abstract_memory_unit", 20, 1));
-    // Vector::reverse 32
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.reverse.legacy_per_abstract_memory_unit", 10, 1));
-    // Table::new_table_handle 33
-    Vector::push_back(&mut table, new_gas_entry(b"table.new_table_handle.base", 4, 1));
-    // Table::add_box 34
-    Vector::push_back(&mut table, new_gas_entry(b"table.add_box.per_byte_serialized", 4, 1));
-    // Table::borrow_box 35
-    Vector::push_back(&mut table, new_gas_entry(b"table.borrow_box.per_byte_serialized", 10, 1));
-    // Table::remove_box 36
-    Vector::push_back(&mut table, new_gas_entry(b"table.remove_box.per_byte_serialized", 8, 1));
-    // Table::contains_box 37
-    Vector::push_back(&mut table, new_gas_entry(b"table.contains_box.per_byte_serialized", 40, 1));
-    // Table::destroy_empty_box 38
-    Vector::push_back(&mut table, new_gas_entry(b"table.destroy_empty_box.base", 20, 1));
-    // Table::drop_unchecked_box 39
-    Vector::push_back(&mut table, new_gas_entry(b"table.drop_unchecked_box.base", 73, 1));
-    // string.check_utf8 40
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.string.check_utf8.per_byte", 4, 1));
-    // string.sub_str 41
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.string.sub_string.per_byte", 4, 1));
-    // string.is_char_boundary 42
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.string.is_char_boundary.base", 4, 1));
-    // Table::string.index_of 43
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.string.index_of.per_byte_searched", 4, 1));
-    // Table::string.index_of 44
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.frombcs.base", 4, 1));
-    // Table::string.index_of 45
-    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.secp256k1.base", 4, 1));
-    // Table::string.index_of 46
-    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.spawn_from.legacy_per_abstract_memory_unit", 4, 1));
-
-    Vector::push_back(&mut table, new_constant_entry(b"nursery.debug.print.base_cost", 1));
-    Vector::push_back(&mut table, new_constant_entry(b"nursery.debug.print_stack_trace.base_cost", 1));
-    Vector::push_back(&mut table, new_constant_entry(b"move_stdlib.hash.sha2_256.legacy_min_input_len", 1));
-    Vector::push_back(&mut table, new_constant_entry(b"move_stdlib.hash.sha3_256.legacy_min_input_len", 1));
-    Vector::push_back(&mut table, new_constant_entry(b"move_stdlib.bcs.to_bytes.failure", 182));
-    Vector::push_back(&mut table, new_constant_entry(b"move_stdlib.bcs.to_bytes.legacy_min_output_size", 1));
-
-    // constant config values
-    Vector::push_back(&mut table, new_constant_entry(b"txn.global_memory_per_byte_cost", 4));
-    Vector::push_back(&mut table, new_constant_entry(b"txn.global_memory_per_byte_write_cost", 9));
-    Vector::push_back(&mut table, new_constant_entry(b"txn.min_transaction_gas_units", 600));
-    Vector::push_back(&mut table, new_constant_entry(b"txn.large_transaction_cutoff", 600));
-    Vector::push_back(&mut table, new_constant_entry(b"txn.intrinsic_gas_per_byte", 8));
-    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
-    };
-    Vector::push_back(&mut table, new_constant_entry(b"txn.maximum_number_of_gas_units", maximum_number_of_gas_units));
-    Vector::push_back(&mut table, new_constant_entry(b"txn.min_price_per_gas_unit", if (ChainId::is_test()) { 0 }  else { 1 }));
-    Vector::push_back(&mut table, new_constant_entry(b"txn.max_price_per_gas_unit", 10000));
-    Vector::push_back(&mut table, new_constant_entry(b"txn.max_transaction_size_in_bytes", 1024 * 128));
-    Vector::push_back(&mut table, new_constant_entry(b"txn.gas_unit_scaling_factor", 1));
-    Vector::push_back(&mut table, new_constant_entry(b"txn.default_account_size", 800));
-
-    table
-}
-
- - - -
- - - -## Function `new_gas_entry` - - - -
public fun new_gas_entry(key: vector<u8>, instr_gas: u64, mem_gas: u64): GasSchedule::GasEntry
-
- - - -
-Implementation - - -
public fun new_gas_entry(key: vector<u8>, instr_gas: u64, mem_gas: u64): GasEntry {
-    GasEntry {
-        key,
-        val: instr_gas + mem_gas,
-    }
-}
-
- - - -
- - - -## Function `new_constant_entry` - - - -
fun new_constant_entry(key: vector<u8>, val: u64): GasSchedule::GasEntry
-
- - - -
-Implementation - - -
fun new_constant_entry(key: vector<u8>, val: u64): GasEntry {
-    GasEntry {
-        key,
-        val,
-    }
-}
-
- - - -
- - - -## Function `initialize` - -Initialize the gas schedule under the genesis account - - -
public fun initialize(account: &signer, gas_schedule: GasSchedule::GasSchedule)
-
- - - -
-Implementation - - -
public fun initialize(account: &signer, gas_schedule: GasSchedule) {
-    CoreAddresses::assert_genesis_address(account);
-    Config::publish_new_config<GasSchedule>(
-        account,
-        gas_schedule,
-    );
-}
-
- - - -
- - - -## Function `new_gas_schedule_for_test` - - - -
public fun new_gas_schedule_for_test(): GasSchedule::GasSchedule
-
- - - -
-Implementation - - -
public fun new_gas_schedule_for_test(): GasSchedule {
-    let entry = GasEntry {
-        key: Vector::empty(),
-        val: 1,
-    };
-    let entries = Vector::empty();
-    Vector::push_back(&mut entries, entry);
-
-    GasSchedule {
-        entries,
-    }
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/Genesis.md b/build/StarcoinFramework/docs/Genesis.md deleted file mode 100644 index 9cbc23f7..00000000 --- a/build/StarcoinFramework/docs/Genesis.md +++ /dev/null @@ -1,804 +0,0 @@ - - - -# Module `0x1::Genesis` - -The module for init Genesis - - -- [Function `initialize`](#0x1_Genesis_initialize) -- [Function `initialize_v2`](#0x1_Genesis_initialize_v2) -- [Function `initialize_v3`](#0x1_Genesis_initialize_v3) -- [Function `do_initialize`](#0x1_Genesis_do_initialize) -- [Function `initialize_for_unit_tests`](#0x1_Genesis_initialize_for_unit_tests) -- [Module Specification](#@Module_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::GasSchedule;
-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 entry 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)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- - - -## Function `initialize_v2` - - - -
public entry 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)
-
- - - -
-Implementation - - -
public entry 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,
-) {
-    // create genesis account
-    let genesis_account = Account::create_genesis_account(CoreAddresses::GENESIS_ADDRESS());
-
-    Self::do_initialize(
-    &genesis_account,
-    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,
-    );
-
-    Account::release_genesis_signer(genesis_account);
-}
-
- - - -
- - - -## Function `initialize_v3` - - - -
public entry fun initialize_v3(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, gas_schedule: GasSchedule::GasSchedule)
-
- - - -
-Implementation - - -
public entry fun initialize_v3(
-    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,
-    gas_schedule: GasSchedule,
-) {
-    // create genesis account
-    let genesis_account = Account::create_genesis_account(CoreAddresses::GENESIS_ADDRESS());
-
-    Self::do_initialize(
-    &genesis_account,
-    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,
-    );
-
-    GasSchedule::initialize(&genesis_account, gas_schedule);
-    Account::release_genesis_signer(genesis_account);
-}
-
- - - -
- - - -## Function `do_initialize` - - - -
fun do_initialize(genesis_account: &signer, 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)
-
- - - -
-Implementation - - -
fun do_initialize(
-    genesis_account: &signer,
-    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();
-
-    //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, 6);
-
-    //v11 -> v12
-    {
-
-    };
-    StdlibUpgradeScripts::do_upgrade_from_v11_to_v12(genesis_account);
-    //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(association);
-}
-
- - - -
- - - -## Function `initialize_for_unit_tests` - -Init the genesis for unit tests - - -
public fun initialize_for_unit_tests()
-
- - - -
-Implementation - - -
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;
-
-    // create genesis account
-    let genesis_account = Account::create_genesis_account(CoreAddresses::GENESIS_ADDRESS());
-
-    Self::do_initialize(
-        &genesis_account,
-        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,
-    );
-
-    Account::release_genesis_signer(genesis_account);
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_partial = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/GenesisNFT.md b/build/StarcoinFramework/docs/GenesisNFT.md deleted file mode 100644 index 5f4ab2de..00000000 --- a/build/StarcoinFramework/docs/GenesisNFT.md +++ /dev/null @@ -1,49 +0,0 @@ - - - -# Module `0x1::GenesisNFTScripts` - - - -- [Function `mint`](#0x1_GenesisNFTScripts_mint) -- [Module Specification](#@Module_Specification_0) - - -
use 0x1::GenesisNFT;
-
- - - - - -## Function `mint` - -Mint a GenesisNFT - - -
public entry fun mint(sender: signer, index: u64, merkle_proof: vector<vector<u8>>)
-
- - - -
-Implementation - - -
public entry fun mint(sender: signer, index: u64, merkle_proof:vector<vector<u8>>) {
-    GenesisNFT::mint_entry(sender, index, merkle_proof);
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-
diff --git a/build/StarcoinFramework/docs/GenesisSignerCapability.md b/build/StarcoinFramework/docs/GenesisSignerCapability.md deleted file mode 100644 index 5ffea8c8..00000000 --- a/build/StarcoinFramework/docs/GenesisSignerCapability.md +++ /dev/null @@ -1,114 +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
-
- - - -
-Fields - - -
-
-cap: Account::SignerCapability -
-
- -
-
- - -
- - - -## Constants - - - - - - -
const ENOT_GENESIS_ACCOUNT: u64 = 11;
-
- - - - - -## Function `initialize` - - - -
public(friend) fun initialize(signer: &signer, cap: Account::SignerCapability)
-
- - - -
-Implementation - - -
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});
-}
-
- - - -
- - - -## Function `get_genesis_signer` - - - -
public(friend) fun get_genesis_signer(): signer
-
- - - -
-Implementation - - -
public(friend) fun get_genesis_signer(): signer acquires GenesisSignerCapability {
-    let cap = borrow_global<GenesisSignerCapability>(CoreAddresses::GENESIS_ADDRESS());
-    Account::create_signer_with_cap(&cap.cap)
-}
-
- - - -
diff --git a/build/StarcoinFramework/docs/Hash.md b/build/StarcoinFramework/docs/Hash.md deleted file mode 100644 index 47f83022..00000000 --- a/build/StarcoinFramework/docs/Hash.md +++ /dev/null @@ -1,116 +0,0 @@ - - - -# Module `0x1::Hash` - -The module provide sha-hash functionality for Move. - - -- [Function `sha2_256`](#0x1_Hash_sha2_256) -- [Function `sha3_256`](#0x1_Hash_sha3_256) -- [Function `keccak_256`](#0x1_Hash_keccak_256) -- [Function `ripemd160`](#0x1_Hash_ripemd160) -- [Module Specification](#@Module_Specification_0) - - -
- - - - - -## Function `sha2_256` - - - -
public fun sha2_256(data: vector<u8>): vector<u8>
-
- - - -
-Implementation - - -
native public fun sha2_256(data: vector<u8>): vector<u8>;
-
- - - -
- - - -## Function `sha3_256` - - - -
public fun sha3_256(data: vector<u8>): vector<u8>
-
- - - -
-Implementation - - -
native public fun sha3_256(data: vector<u8>): vector<u8>;
-
- - - -
- - - -## Function `keccak_256` - - - -
public fun keccak_256(data: vector<u8>): vector<u8>
-
- - - -
-Implementation - - -
native public fun keccak_256(data: vector<u8>): vector<u8>;
-
- - - -
- - - -## Function `ripemd160` - - - -
public fun ripemd160(data: vector<u8>): vector<u8>
-
- - - -
-Implementation - - -
native public fun ripemd160(data: vector<u8>): vector<u8>;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/LanguageVersion.md b/build/StarcoinFramework/docs/LanguageVersion.md deleted file mode 100644 index 1c8bb89d..00000000 --- a/build/StarcoinFramework/docs/LanguageVersion.md +++ /dev/null @@ -1,114 +0,0 @@ - - - -# Module `0x1::LanguageVersion` - - - -- [Struct `LanguageVersion`](#0x1_LanguageVersion_LanguageVersion) -- [Function `new`](#0x1_LanguageVersion_new) -- [Function `version`](#0x1_LanguageVersion_version) - - -
- - - - - -## Struct `LanguageVersion` - - - -
struct LanguageVersion has copy, drop, store
-
- - - -
-Fields - - -
-
-major: u64 -
-
- -
-
- - -
- - - -## Function `new` - - - -
public fun new(version: u64): LanguageVersion::LanguageVersion
-
- - - -
-Implementation - - -
public fun new(version: u64): LanguageVersion {
-    LanguageVersion {major: version}
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `version` - - - -
public fun version(version: &LanguageVersion::LanguageVersion): u64
-
- - - -
-Implementation - - -
public fun version(version: &LanguageVersion): u64 {
-    version.major
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
diff --git a/build/StarcoinFramework/docs/Math.md b/build/StarcoinFramework/docs/Math.md deleted file mode 100644 index 73b4eab0..00000000 --- a/build/StarcoinFramework/docs/Math.md +++ /dev/null @@ -1,377 +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) -- [Module Specification](#@Module_Specification_1) - - -
- - - - - -## Constants - - - - - - -
const U128_MAX: u128 = 340282366920938463463374607431768211455;
-
- - - - - - - -
const U64_MAX: u64 = 18446744073709551615;
-
- - - - - -## Function `u64_max` - -u64::MAX - - -
public fun u64_max(): u64
-
- - - -
-Implementation - - -
public fun u64_max(): u64 {
-    U64_MAX
-}
-
- - - -
- - - -## Function `u128_max` - -u128::MAX - - -
public fun u128_max(): u128
-
- - - -
-Implementation - - -
public fun u128_max(): u128 {
-    U128_MAX
-}
-
- - - -
- - - -## Function `sqrt` - -babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) - - -
public fun sqrt(y: u128): u64
-
- - - -
-Implementation - - -
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)
-    }
-}
-
- - - -
- -
-Specification - - - -
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` - -calculate the y pow of x. - - -
public fun pow(x: u64, y: u64): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
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` - -https://medium.com/coinmonks/math-in-solidity-part-3-percents-and-proportions-4db014e080b1 -calculate x * y /z with as little loss of precision as possible and avoid overflow - - -
public fun mul_div(x: u128, y: u128, z: u128): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
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;
-
- - - -
- - - -## Function `sum` - -calculate sum of nums - - -
public fun sum(nums: &vector<u128>): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `avg` - -calculate average of nums - - -
public fun avg(nums: &vector<u128>): u128
-
- - - -
-Implementation - - -
public fun avg(nums: &vector<u128>): u128{
-    let len = Vector::length(nums);
-    let sum = sum(nums);
-    sum/(len as u128)
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/MerkleNFT.md b/build/StarcoinFramework/docs/MerkleNFT.md deleted file mode 100644 index 95bae1b9..00000000 --- a/build/StarcoinFramework/docs/MerkleNFT.md +++ /dev/null @@ -1,330 +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
-
- - - -
-Fields - - -
-
-merkle_root: vector<u8> -
-
- -
-
-claimed_bitmap: vector<u128> -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `mint_with_cap` - - - -
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>
-
- - - -
-Implementation - - -
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
-    }
-
- - - -
- - - -## Function `encode_leaf` - - - -
fun encode_leaf(index: &u64, account: &address): vector<u8>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `set_minted_` - - - -
fun set_minted_<NFTMeta: copy, drop, store>(distribution: &mut MerkleNFTDistributor::MerkleNFTDistribution<NFTMeta>, index: u64)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-pragma opaque;
-
- - - -
- - - -## Function `verify_proof` - - - -
public fun verify_proof<NFTMeta: copy, drop, store>(account: address, creator: address, index: u64, merkle_proof: vector<vector<u8>>): bool
-
- - - -
-Implementation - - -
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))
-    }
-
- - - -
- - - -## Function `is_minted` - - - -
public fun is_minted<NFTMeta: copy, drop, store>(creator: address, index: u64): bool
-
- - - -
-Implementation - - -
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)
-    }
-
- - - -
- - - -## Function `is_minted_` - - - -
fun is_minted_<NFTMeta: copy, drop, store>(distribution: &MerkleNFTDistributor::MerkleNFTDistribution<NFTMeta>, index: u64): bool
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-pragma opaque;
-
- - - -
diff --git a/build/StarcoinFramework/docs/MintDaoProposal.md b/build/StarcoinFramework/docs/MintDaoProposal.md deleted file mode 100644 index 7bf5a984..00000000 --- a/build/StarcoinFramework/docs/MintDaoProposal.md +++ /dev/null @@ -1,258 +0,0 @@ - - - -# Module `0x1::MintDaoProposal` - -MintDaoProposal is a dao proposal for mint extra tokens. - - -- [Resource `WrappedMintCapability`](#0x1_MintDaoProposal_WrappedMintCapability) -- [Struct `MintToken`](#0x1_MintDaoProposal_MintToken) -- [Constants](#@Constants_0) -- [Function `plugin`](#0x1_MintDaoProposal_plugin) -- [Function `propose_mint_to`](#0x1_MintDaoProposal_propose_mint_to) -- [Function `execute_mint_proposal`](#0x1_MintDaoProposal_execute_mint_proposal) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-cap: Token::MintCapability<TokenType> -
-
- -
-
- - -
- - - -## Struct `MintToken` - -MintToken request. - - -
struct MintToken has copy, drop, store
-
- - - -
-Fields - - -
-
-receiver: address -
-
- the receiver of minted tokens. -
-
-amount: u128 -
-
- how many tokens to mint. -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
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 });
-}
-
- - - -
- -
-Specification - - - -
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` - -Entrypoint for the proposal. - - -
public fun propose_mint_to<TokenT: copy, drop, store>(signer: &signer, receiver: address, amount: u128, exec_delay: u64)
-
- - - -
-Implementation - - -
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,
-    );
-}
-
- - - -
- -
-Specification - - - -
pragma aborts_if_is_partial = false;
-include Dao::AbortIfDaoConfigNotExist<TokenT>;
-include Dao::AbortIfDaoInfoNotExist<TokenT>;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::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` - -Once the proposal is agreed, anyone can call the method to make the proposal happen. - - -
public fun execute_mint_proposal<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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());
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict;
-pragma aborts_if_is_partial;
-
diff --git a/build/StarcoinFramework/docs/MintScripts.md b/build/StarcoinFramework/docs/MintScripts.md deleted file mode 100644 index dbbdd845..00000000 --- a/build/StarcoinFramework/docs/MintScripts.md +++ /dev/null @@ -1,10 +0,0 @@ - - - -# Module `0x1::MintScripts` - - - - - -
diff --git a/build/StarcoinFramework/docs/ModifyDaoConfigProposal.md b/build/StarcoinFramework/docs/ModifyDaoConfigProposal.md deleted file mode 100644 index 1afc8c43..00000000 --- a/build/StarcoinFramework/docs/ModifyDaoConfigProposal.md +++ /dev/null @@ -1,300 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-cap: Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>> -
-
- -
-
- - -
- - - -## Struct `DaoConfigUpdate` - -a proposal action to update dao config. -if any field is 0, that means the proposal want to update. - - -
struct DaoConfigUpdate has copy, drop, store
-
- - - -
-Fields - - -
-
-voting_delay: u64 -
-
- new voting delay setting. -
-
-voting_period: u64 -
-
- new voting period setting. -
-
-voting_quorum_rate: u8 -
-
- new voting quorum rate setting. -
-
-min_action_delay: u64 -
-
- new min action delay setting. -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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>>{address: 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` - -Entrypoint for the proposal. - - -
public entry 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)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
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::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` - -Once the proposal is agreed, anyone can call the method to make the proposal happen. - - -
public entry fun execute<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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,
-    );
-}
-
- - - -
- -
-Specification - - - -
pragma aborts_if_is_partial = true;
-aborts_if !exists<DaoConfigModifyCapability<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict;
-pragma aborts_if_is_partial;
-
diff --git a/build/StarcoinFramework/docs/ModuleUpgradeScripts.md b/build/StarcoinFramework/docs/ModuleUpgradeScripts.md deleted file mode 100644 index 4ac2a7f2..00000000 --- a/build/StarcoinFramework/docs/ModuleUpgradeScripts.md +++ /dev/null @@ -1,314 +0,0 @@ - - - -# Module `0x1::ModuleUpgradeScripts` - - - -- [Constants](#@Constants_0) -- [Function `propose_module_upgrade_v2`](#0x1_ModuleUpgradeScripts_propose_module_upgrade_v2) -- [Function `update_module_upgrade_strategy`](#0x1_ModuleUpgradeScripts_update_module_upgrade_strategy) -- [Function `update_module_upgrade_strategy_with_min_time`](#0x1_ModuleUpgradeScripts_update_module_upgrade_strategy_with_min_time) -- [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) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::Config;
-use 0x1::Errors;
-use 0x1::Option;
-use 0x1::PackageTxnManager;
-use 0x1::Signer;
-use 0x1::UpgradeModuleDaoProposal;
-use 0x1::Version;
-
- - - - - -## Constants - - - - - - -
const ERR_WRONG_UPGRADE_STRATEGY: u64 = 100;
-
- - - - - -## Function `propose_module_upgrade_v2` - - - -
public entry 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)
-
- - - -
-Implementation - - -
public entry 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
-    );
-}
-
- - - -
- - - -## Function `update_module_upgrade_strategy` - -Update sender's module upgrade strategy to strategy - - -
public entry fun update_module_upgrade_strategy(sender: signer, strategy: u8)
-
- - - -
-Implementation - - -
public entry 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>(),
-    );
-}
-
- - - -
- - - -## Function `update_module_upgrade_strategy_with_min_time` - -Update sender's module upgrade strategy to strategy with min_time_limit. -This can only be invoked when strategy is STRATEGY_TWO_PHASE. - - -
public entry fun update_module_upgrade_strategy_with_min_time(sender: signer, strategy: u8, min_time_limit: u64)
-
- - - -
-Implementation - - -
public entry fun update_module_upgrade_strategy_with_min_time(
-    sender: signer,
-    strategy: u8,
-    min_time_limit: u64,
-){
-    // 1. check version
-    assert!(strategy == PackageTxnManager::get_strategy_two_phase(), Errors::invalid_argument(ERR_WRONG_UPGRADE_STRATEGY));
-    // 2. update strategy
-    PackageTxnManager::update_module_upgrade_strategy(
-        &sender,
-        strategy,
-        Option::some<u64>(min_time_limit),
-    );
-}
-
- - - -
- - - -## Function `submit_module_upgrade_plan` - -a alias of execute_module_upgrade_plan_propose, will deprecated in the future. - - -
public entry fun submit_module_upgrade_plan<Token: copy, drop, store>(sender: signer, proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- - - -## Function `execute_module_upgrade_plan_propose` - -Execute module upgrade plan propose by submit module upgrade plan, the propose must been agreed, and anyone can execute this function. - - -
public entry fun execute_module_upgrade_plan_propose<Token: copy, drop, store>(_sender: signer, proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `submit_upgrade_plan` - -Directly submit a upgrade plan, the sender's module upgrade plan must been PackageTxnManager::STRATEGY_TWO_PHASE and have UpgradePlanCapability - - -
public entry fun submit_upgrade_plan(sender: signer, package_hash: vector<u8>, version: u64, enforced: bool)
-
- - - -
-Implementation - - -
public entry fun submit_upgrade_plan(sender: signer, package_hash: vector<u8>, version:u64, enforced: bool) {
-    PackageTxnManager::submit_upgrade_plan_v2(&sender, package_hash, version, enforced);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `cancel_upgrade_plan` - -Cancel current upgrade plan, the sender must have UpgradePlanCapability. - - -
public entry fun cancel_upgrade_plan(signer: signer)
-
- - - -
-Implementation - - -
public entry fun cancel_upgrade_plan(
-    signer: signer,
-) {
-    PackageTxnManager::cancel_upgrade_plan(&signer);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_partial = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/NFT.md b/build/StarcoinFramework/docs/NFT.md deleted file mode 100644 index b257544e..00000000 --- a/build/StarcoinFramework/docs/NFT.md +++ /dev/null @@ -1,104 +0,0 @@ - - - -# Module `0x1::NFTGalleryScripts` - - - -- [Function `accept`](#0x1_NFTGalleryScripts_accept) -- [Function `transfer`](#0x1_NFTGalleryScripts_transfer) -- [Function `remove_empty_gallery`](#0x1_NFTGalleryScripts_remove_empty_gallery) -- [Module Specification](#@Module_Specification_0) - - -
use 0x1::NFTGallery;
-
- - - - - -## Function `accept` - -Init a NFTGallery for accept NFT - - -
public entry fun accept<NFTMeta: copy, drop, store, NFTBody: store>(sender: signer)
-
- - - -
-Implementation - - -
public entry fun accept<NFTMeta: copy + store + drop, NFTBody: store>(sender: signer) {
-    NFTGallery::accept_entry<NFTMeta, NFTBody>(sender);
-}
-
- - - -
- - - -## Function `transfer` - -Transfer NFT with id from sender to receiver - - -
public entry fun transfer<NFTMeta: copy, drop, store, NFTBody: store>(sender: signer, id: u64, receiver: address)
-
- - - -
-Implementation - - -
public entry fun transfer<NFTMeta: copy + store + drop, NFTBody: store>(
-    sender: signer,
-    id: u64, receiver: address
-) {
-    NFTGallery::transfer_entry<NFTMeta, NFTBody>(sender, id, receiver);
-}
-
- - - -
- - - -## Function `remove_empty_gallery` - -Remove empty NFTGallery. - - -
public entry fun remove_empty_gallery<NFTMeta: copy, drop, store, NFTBody: store>(sender: signer)
-
- - - -
-Implementation - - -
public entry fun remove_empty_gallery<NFTMeta: copy + store + drop, NFTBody: store>(sender: signer) {
-    NFTGallery::remove_empty_gallery_entry<NFTMeta, NFTBody>(sender);
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-
diff --git a/build/StarcoinFramework/docs/Offer.md b/build/StarcoinFramework/docs/Offer.md deleted file mode 100644 index 59f75057..00000000 --- a/build/StarcoinFramework/docs/Offer.md +++ /dev/null @@ -1,305 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-offered: Offered -
-
- -
-
-for: address -
-
- -
-
-time_lock: u64 -
-
- -
-
- - -
- - - -## Constants - - - - -An offer of the specified type for the account does not match - - -
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)
-
- - - -
-Implementation - - -
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 });
-}
-
- - - -
- -
-Specification - - - -
include Timestamp::AbortsIfTimestampNotExists;
-aborts_if Timestamp::now_seconds() + lock_period > max_u64();
-aborts_if exists<Offer<Offered>>(Signer::address_of(account));
-
- - - -
- - - -## Function `redeem` - -Claim the value of type 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
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
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` - -Returns true if an offer of type Offered exists at offer_address. - - -
public fun exists_at<Offered: store>(offer_address: address): bool
-
- - - -
-Implementation - - -
public fun exists_at<Offered: store>(offer_address: address): bool {
-    exists<Offer<Offered>>(offer_address)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `address_of` - -Returns the address of the Offered type stored at offer_address. -Fails if no such Offer exists. - - -
public fun address_of<Offered: store>(offer_address: address): address
-
- - - -
-Implementation - - -
public fun address_of<Offered: store>(offer_address: address): address acquires Offer {
-    borrow_global<Offer<Offered>>(offer_address).for
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Offer<Offered>>(offer_address);
-
- - - -
- - - -## Function `take_offer` - -Take Offer and put to signer's Collection. - - -
public entry fun take_offer<Offered: store>(signer: signer, offer_address: address)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify = true;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/OnChainConfigDao.md b/build/StarcoinFramework/docs/OnChainConfigDao.md deleted file mode 100644 index 1fc075ec..00000000 --- a/build/StarcoinFramework/docs/OnChainConfigDao.md +++ /dev/null @@ -1,257 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-cap: Config::ModifyConfigCapability<ConfigT> -
-
- -
-
- - -
- - - -## Struct `OnChainConfigUpdate` - -request of updating configuration. - - -
struct OnChainConfigUpdate<ConfigT: copy, drop, store> has copy, drop, store
-
- - - -
-Fields - - -
-
-value: ConfigT -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
pragma aborts_if_is_partial = false;
-let sender = Signer::address_of(signer);
-aborts_if sender != Token::SPEC_TOKEN_TEST_ADDRESS();
-include Config::AbortsIfCapNotExist<ConfigT>{address: sender};
-aborts_if exists<WrappedConfigModifyCapability<TokenT, ConfigT>>(sender);
-ensures exists<WrappedConfigModifyCapability<TokenT, ConfigT>>(sender);
-
- - - -
- - - -## Function `propose_update` - -issue a proposal to update config of ConfigT goved by TokenT - - -
public fun propose_update<TokenT: copy, drop, store, ConfigT: copy, drop, store>(signer: &signer, new_config: ConfigT, exec_delay: u64)
-
- - - -
-Implementation - - -
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,
-    );
-}
-
- - - -
- -
-Specification - - - -
pragma aborts_if_is_partial = false;
-include Dao::AbortIfDaoConfigNotExist<TokenT>;
-include Dao::AbortIfDaoInfoNotExist<TokenT>;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::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` - -Once the proposal is agreed, anyone can call the method to make the proposal happen. -Caller need to make sure that the proposal of 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)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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());
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict;
-pragma aborts_if_is_partial;
-
diff --git a/build/StarcoinFramework/docs/OnChainConfigScripts.md b/build/StarcoinFramework/docs/OnChainConfigScripts.md deleted file mode 100644 index f2072a84..00000000 --- a/build/StarcoinFramework/docs/OnChainConfigScripts.md +++ /dev/null @@ -1,378 +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) - - -
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 entry 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)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `propose_update_reward_config` - - - -
public entry fun propose_update_reward_config(account: signer, reward_delay: u64, exec_delay: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `propose_update_txn_publish_option` - - - -
public entry fun propose_update_txn_publish_option(account: signer, script_allowed: bool, module_publishing_allowed: bool, exec_delay: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `propose_update_txn_timeout_config` - - - -
public entry fun propose_update_txn_timeout_config(account: signer, duration_seconds: u64, exec_delay: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `propose_update_vm_config` - - - -
public entry 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)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `propose_update_move_language_version` - - - -
public entry fun propose_update_move_language_version(account: signer, new_version: u64, exec_delay: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `execute_on_chain_config_proposal` - - - -
public entry fun execute_on_chain_config_proposal<ConfigT: copy, drop, store>(account: signer, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `execute_on_chain_config_proposal_v2` - - - -
public entry fun execute_on_chain_config_proposal_v2<TokenType: copy, drop, store, ConfigT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
diff --git a/build/StarcoinFramework/docs/Option.md b/build/StarcoinFramework/docs/Option.md deleted file mode 100644 index 4f518c53..00000000 --- a/build/StarcoinFramework/docs/Option.md +++ /dev/null @@ -1,787 +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) -- [Module Specification](#@Module_Specification_1) - - [Helper Schema](#@Helper_Schema_2) - - -
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
-
- - - -
-Fields - - -
-
-vec: vector<Element> -
-
- -
-
- - -
- -
-Specification - - -The size of vector is always less than equal to 1 -because it's 0 for "none" or 1 for "some". - - -
invariant len(vec) <= 1;
-
- - - -
- - - -## Constants - - - - -The Option is in an invalid state for the operation attempted. -The Option is Some while it should be None. - - -
const EOPTION_IS_SET: u64 = 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>
-
- - - -
-Implementation - - -
public fun none<Element>(): Option<Element> {
-    Option { vec: Vector::empty() }
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if false;
-ensures result == spec_none<Element>();
-
- - - - - - - -
fun spec_none<Element>(): Option<Element> {
-   Option{ vec: vec() }
-}
-
- - - -
- - - -## Function `some` - -Return an Option containing e - - -
public fun some<Element>(e: Element): Option::Option<Element>
-
- - - -
-Implementation - - -
public fun some<Element>(e: Element): Option<Element> {
-    Option { vec: Vector::singleton(e) }
-}
-
- - - -
- -
-Specification - - - -
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` - -Return true if t does not hold a value - - -
public fun is_none<Element>(t: &Option::Option<Element>): bool
-
- - - -
-Implementation - - -
public fun is_none<Element>(t: &Option<Element>): bool {
-    Vector::is_empty(&t.vec)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if false;
-ensures result == is_none(t);
-
- - - -
- - - -## Function `is_some` - -Return true if t holds a value - - -
public fun is_some<Element>(t: &Option::Option<Element>): bool
-
- - - -
-Implementation - - -
public fun is_some<Element>(t: &Option<Element>): bool {
-    !Vector::is_empty(&t.vec)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if false;
-ensures result == is_some(t);
-
- - - -
- - - -## Function `contains` - -Return true if the value in 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
-
- - - -
-Implementation - - -
public fun contains<Element>(t: &Option<Element>, e_ref: &Element): bool {
-    Vector::contains(&t.vec, e_ref)
-}
-
- - - -
- -
-Specification - - - -
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` - -Return an immutable reference to the value inside t -Aborts if t does not hold a value - - -
public fun borrow<Element>(t: &Option::Option<Element>): &Element
-
- - - -
-Implementation - - -
public fun borrow<Element>(t: &Option<Element>): &Element {
-    assert!(is_some(t), Errors::invalid_argument(EOPTION_NOT_SET));
-    Vector::borrow(&t.vec, 0)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-include AbortsIfNone<Element>;
-ensures result == borrow(t);
-
- - - -
- - - -## Function `borrow_with_default` - -Return a reference to the value inside 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
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if false;
-ensures result == (if (is_some(t)) borrow(t) else default_ref);
-
- - - -
- - - -## Function `get_with_default` - -Return the value inside 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
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if false;
-ensures result == (if (is_some(t)) borrow(t) else default);
-
- - - -
- - - -## Function `fill` - -Convert the none option 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)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if is_some(t) with Errors::INVALID_ARGUMENT;
-ensures is_some(t);
-ensures borrow(t) == e;
-
- - - -
- - - -## Function `extract` - -Convert a 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
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-include AbortsIfNone<Element>;
-ensures result == borrow(old(t));
-ensures is_none(t);
-
- - - -
- - - -## Function `borrow_mut` - -Return a mutable reference to the value inside t -Aborts if t does not hold a value - - -
public fun borrow_mut<Element>(t: &mut Option::Option<Element>): &mut Element
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-include AbortsIfNone<Element>;
-ensures result == borrow(t);
-
- - - -
- - - -## Function `swap` - -Swap the old value inside 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
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-include AbortsIfNone<Element>;
-ensures result == borrow(old(t));
-ensures is_some(t);
-ensures borrow(t) == e;
-
- - - -
- - - -## Function `destroy_with_default` - -Destroys 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
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if false;
-ensures result == (if (is_some(t)) borrow(t) else default);
-
- - - -
- - - -## Function `destroy_some` - -Unpack t and return its contents -Aborts if t does not hold a value - - -
public fun destroy_some<Element>(t: Option::Option<Element>): Element
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-include AbortsIfNone<Element>;
-ensures result == borrow(t);
-
- - - -
- - - -## Function `destroy_none` - -Unpack t -Aborts if t holds a value - - -
public fun destroy_none<Element>(t: Option::Option<Element>)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if is_some(t) with Errors::INVALID_ARGUMENT;
-
- - - -
- - - -## Module Specification - - - - -
pragma aborts_if_is_strict;
-
- - - - - -### Helper Schema - - - - - - -
schema AbortsIfNone<Element> {
-    t: Option<Element>;
-    aborts_if is_none(t) with Errors::INVALID_ARGUMENT;
-}
-
diff --git a/build/StarcoinFramework/docs/Oracle.md b/build/StarcoinFramework/docs/Oracle.md deleted file mode 100644 index b3dcdb3b..00000000 --- a/build/StarcoinFramework/docs/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 entry fun register_oracle<OracleT: copy, drop, store>(sender: signer, precision: u8)
-
- - - -
-Implementation - - -
public entry fun register_oracle<OracleT: copy+store+drop>(sender: signer, precision: u8){
-    PriceOracle::register_oracle_entry<OracleT>(sender, precision);
-}
-
- - - -
- - - -## Function `init_data_source` - - - -
public entry fun init_data_source<OracleT: copy, drop, store>(sender: signer, init_value: u128)
-
- - - -
-Implementation - - -
public entry fun init_data_source<OracleT: copy+store+drop>(sender: signer, init_value: u128){
-    PriceOracle::init_data_source_entry<OracleT>(sender, init_value);
-}
-
- - - -
- - - -## Function `update` - - - -
public entry fun update<OracleT: copy, drop, store>(sender: signer, value: u128)
-
- - - -
-Implementation - - -
public entry fun update<OracleT: copy+store+drop>(sender: signer, value: u128){
-    PriceOracle::update_entry<OracleT>(sender, value);
-}
-
- - - -
diff --git a/build/StarcoinFramework/docs/PackageTxnManager.md b/build/StarcoinFramework/docs/PackageTxnManager.md deleted file mode 100644 index 328505ed..00000000 --- a/build/StarcoinFramework/docs/PackageTxnManager.md +++ /dev/null @@ -1,1454 +0,0 @@ - - - -# Module `0x1::PackageTxnManager` - -The module provides strategies for module upgrading. - - -- [Struct `UpgradePlan`](#0x1_PackageTxnManager_UpgradePlan) -- [Resource `UpgradePlanCapability`](#0x1_PackageTxnManager_UpgradePlanCapability) -- [Struct `UpgradePlanV2`](#0x1_PackageTxnManager_UpgradePlanV2) -- [Resource `ModuleUpgradeStrategy`](#0x1_PackageTxnManager_ModuleUpgradeStrategy) -- [Resource `TwoPhaseUpgrade`](#0x1_PackageTxnManager_TwoPhaseUpgrade) -- [Struct `TwoPhaseUpgradeConfig`](#0x1_PackageTxnManager_TwoPhaseUpgradeConfig) -- [Resource `TwoPhaseUpgradeV2`](#0x1_PackageTxnManager_TwoPhaseUpgradeV2) -- [Struct `UpgradeEvent`](#0x1_PackageTxnManager_UpgradeEvent) -- [Constants](#@Constants_0) -- [Function `get_strategy_arbitrary`](#0x1_PackageTxnManager_get_strategy_arbitrary) -- [Function `get_strategy_two_phase`](#0x1_PackageTxnManager_get_strategy_two_phase) -- [Function `get_strategy_new_module`](#0x1_PackageTxnManager_get_strategy_new_module) -- [Function `get_strategy_freeze`](#0x1_PackageTxnManager_get_strategy_freeze) -- [Function `get_default_min_time_limit`](#0x1_PackageTxnManager_get_default_min_time_limit) -- [Function `update_module_upgrade_strategy`](#0x1_PackageTxnManager_update_module_upgrade_strategy) -- [Function `account_address`](#0x1_PackageTxnManager_account_address) -- [Function `destroy_upgrade_plan_cap`](#0x1_PackageTxnManager_destroy_upgrade_plan_cap) -- [Function `extract_submit_upgrade_plan_cap`](#0x1_PackageTxnManager_extract_submit_upgrade_plan_cap) -- [Function `convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2`](#0x1_PackageTxnManager_convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2) -- [Function `submit_upgrade_plan_v2`](#0x1_PackageTxnManager_submit_upgrade_plan_v2) -- [Function `submit_upgrade_plan_with_cap_v2`](#0x1_PackageTxnManager_submit_upgrade_plan_with_cap_v2) -- [Function `cancel_upgrade_plan`](#0x1_PackageTxnManager_cancel_upgrade_plan) -- [Function `cancel_upgrade_plan_with_cap`](#0x1_PackageTxnManager_cancel_upgrade_plan_with_cap) -- [Function `get_module_upgrade_strategy`](#0x1_PackageTxnManager_get_module_upgrade_strategy) -- [Function `get_upgrade_plan`](#0x1_PackageTxnManager_get_upgrade_plan) -- [Function `get_upgrade_plan_v2`](#0x1_PackageTxnManager_get_upgrade_plan_v2) -- [Function `check_package_txn`](#0x1_PackageTxnManager_check_package_txn) -- [Function `check_package_txn_v2`](#0x1_PackageTxnManager_check_package_txn_v2) -- [Function `finish_upgrade_plan`](#0x1_PackageTxnManager_finish_upgrade_plan) -- [Function `package_txn_prologue`](#0x1_PackageTxnManager_package_txn_prologue) -- [Function `package_txn_prologue_v2`](#0x1_PackageTxnManager_package_txn_prologue_v2) -- [Function `package_txn_epilogue`](#0x1_PackageTxnManager_package_txn_epilogue) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-package_hash: vector<u8> -
-
- -
-
-active_after_time: u64 -
-
- -
-
-version: u64 -
-
- -
-
- - -
- - - -## Resource `UpgradePlanCapability` - -The holder of UpgradePlanCapability for account_address can submit UpgradePlan for account_address. - - -
struct UpgradePlanCapability has store, key
-
- - - -
-Fields - - -
-
-account_address: address -
-
- -
-
- - -
- - - -## Struct `UpgradePlanV2` - - - -
struct UpgradePlanV2 has copy, drop, store
-
- - - -
-Fields - - -
-
-package_hash: vector<u8> -
-
- -
-
-active_after_time: u64 -
-
- -
-
-version: u64 -
-
- -
-
-enforced: bool -
-
- -
-
- - -
- - - -## Resource `ModuleUpgradeStrategy` - -module upgrade strategy - - -
struct ModuleUpgradeStrategy has store, key
-
- - - -
-Fields - - -
-
-strategy: u8 -
-
- 0 arbitrary - 1 two phase upgrade - 2 only new module - 3 freeze -
-
- - -
- - - -## Resource `TwoPhaseUpgrade` - -data of two phase upgrade strategy. - - -
struct TwoPhaseUpgrade has key
-
- - - -
-Fields - - -
-
-config: PackageTxnManager::TwoPhaseUpgradeConfig -
-
- -
-
-plan: Option::Option<PackageTxnManager::UpgradePlan> -
-
- -
-
-version_cap: Config::ModifyConfigCapability<Version::Version> -
-
- -
-
-upgrade_event: Event::EventHandle<PackageTxnManager::UpgradeEvent> -
-
- -
-
- - -
- - - -## Struct `TwoPhaseUpgradeConfig` - -config of two phase upgrade strategy. - - -
struct TwoPhaseUpgradeConfig has copy, drop, store
-
- - - -
-Fields - - -
-
-min_time_limit: u64 -
-
- -
-
- - -
- - - -## Resource `TwoPhaseUpgradeV2` - -data of two phase upgrade strategy. - - -
struct TwoPhaseUpgradeV2 has key
-
- - - -
-Fields - - -
-
-config: PackageTxnManager::TwoPhaseUpgradeConfig -
-
- -
-
-plan: Option::Option<PackageTxnManager::UpgradePlanV2> -
-
- -
-
-version_cap: Config::ModifyConfigCapability<Version::Version> -
-
- -
-
-upgrade_event: Event::EventHandle<PackageTxnManager::UpgradeEvent> -
-
- -
-
- - -
- - - -## Struct `UpgradeEvent` - -module upgrade event. - - -
struct UpgradeEvent has drop, store
-
- - - -
-Fields - - -
-
-package_address: address -
-
- -
-
-package_hash: vector<u8> -
-
- -
-
-version: u64 -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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
-
- - - -
-Implementation - - -
public fun get_strategy_arbitrary(): u8 { STRATEGY_ARBITRARY }
-
- - - -
- - - -## Function `get_strategy_two_phase` - -two phase stragegy - - -
public fun get_strategy_two_phase(): u8
-
- - - -
-Implementation - - -
public fun get_strategy_two_phase(): u8 { STRATEGY_TWO_PHASE }
-
- - - -
- - - -## Function `get_strategy_new_module` - -new module strategy - - -
public fun get_strategy_new_module(): u8
-
- - - -
-Implementation - - -
public fun get_strategy_new_module(): u8 { STRATEGY_NEW_MODULE }
-
- - - -
- - - -## Function `get_strategy_freeze` - -freezed strategy - - -
public fun get_strategy_freeze(): u8
-
- - - -
-Implementation - - -
public fun get_strategy_freeze(): u8 { STRATEGY_FREEZE }
-
- - - -
- - - -## Function `get_default_min_time_limit` - -default min time limit - - -
public fun get_default_min_time_limit(): u64
-
- - - -
-Implementation - - -
public fun get_default_min_time_limit(): u64 { DEFAULT_MIN_TIME_LIMIT }
-
- - - -
- - - -## Function `update_module_upgrade_strategy` - -Update account's ModuleUpgradeStrategy - - -
public fun update_module_upgrade_strategy(account: &signer, strategy: u8, min_time: Option::Option<u64>)
-
- - - -
-Implementation - - -
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);
-        };
-    };
-}
-
- - - -
- -
-Specification - - - -
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 `account_address` - -Get account address of UpgradePlanCapability - - -
public fun account_address(cap: &PackageTxnManager::UpgradePlanCapability): address
-
- - - -
-Implementation - - -
public fun account_address(cap: &UpgradePlanCapability): address {
-    cap.account_address
-}
-
- - - -
- - - -## Function `destroy_upgrade_plan_cap` - -destroy the given UpgradePlanCapability - - -
public fun destroy_upgrade_plan_cap(cap: PackageTxnManager::UpgradePlanCapability)
-
- - - -
-Implementation - - -
public fun destroy_upgrade_plan_cap(cap: UpgradePlanCapability){
-    let UpgradePlanCapability{account_address:_} = cap;
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `extract_submit_upgrade_plan_cap` - -extract out UpgradePlanCapability from signer. - - -
public fun extract_submit_upgrade_plan_cap(account: &signer): PackageTxnManager::UpgradePlanCapability
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
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 entry fun convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2(account: signer, package_address: address)
-
- - - -
-Implementation - - -
public entry 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
-        });
-    };
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `submit_upgrade_plan_v2` - - - -
public fun submit_upgrade_plan_v2(account: &signer, package_hash: vector<u8>, version: u64, enforced: bool)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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)
-
- - - -
-Implementation - - -
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 });
-}
-
- - - -
- -
-Specification - - - -
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` - -Cancel a module upgrade plan. - - -
public fun cancel_upgrade_plan(account: &signer)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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` - -Cancel a module upgrade plan with given cap. - - -
public fun cancel_upgrade_plan_with_cap(cap: &PackageTxnManager::UpgradePlanCapability)
-
- - - -
-Implementation - - -
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>();
-}
-
- - - -
- -
-Specification - - - -
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` - -Get module upgrade strategy of an module address. - - -
public fun get_module_upgrade_strategy(module_address: address): u8
-
- - - -
-Implementation - - -
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
-    }
-}
-
- - - -
- -
-Specification - - - -
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` - -Get module upgrade plan of an address. - - -
public fun get_upgrade_plan(_module_address: address): Option::Option<PackageTxnManager::UpgradePlan>
-
- - - -
-Implementation - - -
public fun get_upgrade_plan(_module_address: address): Option<UpgradePlan> {
-    // DEPRECATED_CODE
-    Option::none<UpgradePlan>()
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `get_upgrade_plan_v2` - -Get module upgrade plan of an address. - - -
public fun get_upgrade_plan_v2(module_address: address): Option::Option<PackageTxnManager::UpgradePlanV2>
-
- - - -
-Implementation - - -
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>()
-    }
-}
-
- - - -
- -
-Specification - - - -
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` - -Check againest on the given package data. - - -
public fun check_package_txn(package_address: address, package_hash: vector<u8>)
-
- - - -
-Implementation - - -
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){
-        Errors::invalid_argument(ESTRATEGY_FREEZED);
-    };
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-include CheckPackageTxnAbortsIf;
-
- - - -
- - - -## Function `check_package_txn_v2` - - - -
public fun check_package_txn_v2(txn_sender: address, package_address: address, package_hash: vector<u8>)
-
- - - -
-Implementation - - -
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){
-        Errors::invalid_argument(ESTRATEGY_FREEZED);
-    };
-}
-
- - - -
- - - -## Function `finish_upgrade_plan` - - - -
fun finish_upgrade_plan(package_address: address)
-
- - - -
-Implementation - - -
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>();
-}
-
- - - -
- -
-Specification - - - -
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` - -Prologue of package transaction. - - -
public fun package_txn_prologue(account: &signer, package_address: address, package_hash: vector<u8>)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-include CheckPackageTxnAbortsIf{};
-
- - - -
- - - -## Function `package_txn_prologue_v2` - - - -
public fun package_txn_prologue_v2(account: &signer, txn_sender: address, package_address: address, package_hash: vector<u8>)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- - - -## Function `package_txn_epilogue` - -Package txn finished, and clean UpgradePlan - - -
public fun package_txn_epilogue(account: &signer, _txn_sender: address, package_address: address, success: bool)
-
- - - -
-Implementation - - -
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);
-        };
-    };
-}
-
- - - -
- -
-Specification - - - -
aborts_if Signer::address_of(account) != CoreAddresses::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);
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/README.md b/build/StarcoinFramework/docs/README.md deleted file mode 100644 index 8810b9b2..00000000 --- a/build/StarcoinFramework/docs/README.md +++ /dev/null @@ -1,108 +0,0 @@ - - - -# Move StarcoinFramework Modules - - -This is the root document for the Move StarcoinFramework module documentation. The Move StarcoinFramework provides modules that can be used to access or interact with Starcoin blockchain. - - - - -## Index - - -- [`0x1::ACL`](ACL.md#0x1_ACL) -- [`0x1::Account`](Account.md#0x1_Account) -- [`0x1::AccountScripts`](AccountScripts.md#0x1_AccountScripts) -- [`0x1::Arith`](U256.md#0x1_Arith) -- [`0x1::Authenticator`](Authenticator.md#0x1_Authenticator) -- [`0x1::BCS`](BCS.md#0x1_BCS) -- [`0x1::BitOperators`](Bitwise.md#0x1_BitOperators) -- [`0x1::Block`](Block.md#0x1_Block) -- [`0x1::BlockReward`](BlockReward.md#0x1_BlockReward) -- [`0x1::ChainId`](ChainId.md#0x1_ChainId) -- [`0x1::Collection`](Collection.md#0x1_Collection) -- [`0x1::Collection2`](Collection2.md#0x1_Collection2) -- [`0x1::Compare`](Compare.md#0x1_Compare) -- [`0x1::Config`](Config.md#0x1_Config) -- [`0x1::ConsensusConfig`](ConsensusConfig.md#0x1_ConsensusConfig) -- [`0x1::ConsensusStrategy`](ConsensusStrategy.md#0x1_ConsensusStrategy) -- [`0x1::CoreAddresses`](CoreAddresses.md#0x1_CoreAddresses) -- [`0x1::Dao`](Dao.md#0x1_Dao) -- [`0x1::DaoVoteScripts`](DaoVoteScripts.md#0x1_DaoVoteScripts) -- [`0x1::Debug`](Debug.md#0x1_Debug) -- [`0x1::DummyToken`](DummyToken.md#0x1_DummyToken) -- [`0x1::DummyTokenScripts`](DummyToken.md#0x1_DummyTokenScripts) -- [`0x1::EVMAddress`](Signature.md#0x1_EVMAddress) -- [`0x1::EmptyScripts`](EmptyScripts.md#0x1_EmptyScripts) -- [`0x1::Epoch`](Epoch.md#0x1_Epoch) -- [`0x1::Errors`](Errors.md#0x1_Errors) -- [`0x1::Event`](Event.md#0x1_Event) -- [`0x1::EventUtil`](EventUtil.md#0x1_EventUtil) -- [`0x1::FixedPoint32`](FixedPoint32.md#0x1_FixedPoint32) -- [`0x1::FromBCS`](FromBCS.md#0x1_FromBCS) -- [`0x1::GasSchedule`](GasSchedule.md#0x1_GasSchedule) -- [`0x1::Genesis`](Genesis.md#0x1_Genesis) -- [`0x1::GenesisNFT`](GenesisNFT.md#0x1_GenesisNFT) -- [`0x1::GenesisNFTScripts`](GenesisNFT.md#0x1_GenesisNFTScripts) -- [`0x1::GenesisSignerCapability`](GenesisSignerCapability.md#0x1_GenesisSignerCapability) -- [`0x1::Hash`](Hash.md#0x1_Hash) -- [`0x1::IdentifierNFT`](NFT.md#0x1_IdentifierNFT) -- [`0x1::IdentifierNFTScripts`](NFT.md#0x1_IdentifierNFTScripts) -- [`0x1::LanguageVersion`](LanguageVersion.md#0x1_LanguageVersion) -- [`0x1::Math`](Math.md#0x1_Math) -- [`0x1::MerkleNFTDistributor`](MerkleNFT.md#0x1_MerkleNFTDistributor) -- [`0x1::MerkleProof`](MerkleNFT.md#0x1_MerkleProof) -- [`0x1::MintDaoProposal`](MintDaoProposal.md#0x1_MintDaoProposal) -- [`0x1::MintScripts`](MintScripts.md#0x1_MintScripts) -- [`0x1::ModifyDaoConfigProposal`](ModifyDaoConfigProposal.md#0x1_ModifyDaoConfigProposal) -- [`0x1::ModuleUpgradeScripts`](ModuleUpgradeScripts.md#0x1_ModuleUpgradeScripts) -- [`0x1::NFT`](NFT.md#0x1_NFT) -- [`0x1::NFTGallery`](NFT.md#0x1_NFTGallery) -- [`0x1::NFTGalleryScripts`](NFT.md#0x1_NFTGalleryScripts) -- [`0x1::Offer`](Offer.md#0x1_Offer) -- [`0x1::OnChainConfigDao`](OnChainConfigDao.md#0x1_OnChainConfigDao) -- [`0x1::OnChainConfigScripts`](OnChainConfigScripts.md#0x1_OnChainConfigScripts) -- [`0x1::Option`](Option.md#0x1_Option) -- [`0x1::Oracle`](Oracle.md#0x1_Oracle) -- [`0x1::PackageTxnManager`](PackageTxnManager.md#0x1_PackageTxnManager) -- [`0x1::PriceOracle`](Oracle.md#0x1_PriceOracle) -- [`0x1::PriceOracleAggregator`](Oracle.md#0x1_PriceOracleAggregator) -- [`0x1::PriceOracleScripts`](Oracle.md#0x1_PriceOracleScripts) -- [`0x1::RewardConfig`](RewardConfig.md#0x1_RewardConfig) -- [`0x1::Ring`](Ring.md#0x1_Ring) -- [`0x1::SIP_2`](SIPs.md#0x1_SIP_2) -- [`0x1::SIP_3`](SIPs.md#0x1_SIP_3) -- [`0x1::STC`](STC.md#0x1_STC) -- [`0x1::STCUSDOracle`](Oracle.md#0x1_STCUSDOracle) -- [`0x1::Secp256k1`](Secp256k1.md#0x1_Secp256k1) -- [`0x1::SharedEd25519PublicKey`](SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey) -- [`0x1::Signature`](Signature.md#0x1_Signature) -- [`0x1::SignedInteger64`](SignedInteger64.md#0x1_SignedInteger64) -- [`0x1::Signer`](Signer.md#0x1_Signer) -- [`0x1::SimpleMap`](SimpleMap.md#0x1_SimpleMap) -- [`0x1::StarcoinVerifier`](StarcoinVerifier.md#0x1_StarcoinVerifier) -- [`0x1::StdlibUpgradeScripts`](StdlibUpgradeScripts.md#0x1_StdlibUpgradeScripts) -- [`0x1::String`](String.md#0x1_String) -- [`0x1::StructuredHash`](StarcoinVerifier.md#0x1_StructuredHash) -- [`0x1::Table`](Table.md#0x1_Table) -- [`0x1::Timestamp`](Timestamp.md#0x1_Timestamp) -- [`0x1::Token`](Token.md#0x1_Token) -- [`0x1::TransactionFee`](TransactionFee.md#0x1_TransactionFee) -- [`0x1::TransactionManager`](TransactionManager.md#0x1_TransactionManager) -- [`0x1::TransactionPublishOption`](TransactionPublishOption.md#0x1_TransactionPublishOption) -- [`0x1::TransactionTimeout`](TransactionTimeout.md#0x1_TransactionTimeout) -- [`0x1::TransactionTimeoutConfig`](TransactionTimeoutConfig.md#0x1_TransactionTimeoutConfig) -- [`0x1::TransferScripts`](TransferScripts.md#0x1_TransferScripts) -- [`0x1::Treasury`](Treasury.md#0x1_Treasury) -- [`0x1::TreasuryScripts`](TreasuryScripts.md#0x1_TreasuryScripts) -- [`0x1::TreasuryWithdrawDaoProposal`](TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal) -- [`0x1::TypeInfo`](TypeInfo.md#0x1_TypeInfo) -- [`0x1::U256`](U256.md#0x1_U256) -- [`0x1::UpgradeModuleDaoProposal`](UpgradeModuleDaoProposal.md#0x1_UpgradeModuleDaoProposal) -- [`0x1::VMConfig`](VMConfig.md#0x1_VMConfig) -- [`0x1::Vector`](Vector.md#0x1_Vector) -- [`0x1::Version`](Version.md#0x1_Version) -- [`0x1::YieldFarming`](YieldFarming.md#0x1_YieldFarming) -- [`0x1::YieldFarmingV2`](YieldFarmingV2.md#0x1_YieldFarmingV2) diff --git a/build/StarcoinFramework/docs/RewardConfig.md b/build/StarcoinFramework/docs/RewardConfig.md deleted file mode 100644 index 4c300f5d..00000000 --- a/build/StarcoinFramework/docs/RewardConfig.md +++ /dev/null @@ -1,240 +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) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::Timestamp;
-
- - - - - -## Struct `RewardConfig` - -Reward configuration - - -
struct RewardConfig has copy, drop, store
-
- - - -
-Fields - - -
-
-reward_delay: u64 -
-
- how many blocks delay reward distribution. -
-
- - -
- - - -## Constants - - - - - - -
const EINVALID_ARGUMENT: u64 = 18;
-
- - - - - -## Function `initialize` - -Module initialization. - - -
public fun initialize(account: &signer, reward_delay: u64)
-
- - - -
-Implementation - - -
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)
-    );
-}
-
- - - -
- -
-Specification - - - -
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` - -Create a new reward config mainly used in DAO. - - -
public fun new_reward_config(reward_delay: u64): RewardConfig::RewardConfig
-
- - - -
-Implementation - - -
public fun new_reward_config(reward_delay: u64) : RewardConfig {
-    RewardConfig {reward_delay: reward_delay}
-}
-
- - - -
- -
-Specification - - - -
- - - -## Function `get_reward_config` - -Get reward configuration. - - -
public fun get_reward_config(): RewardConfig::RewardConfig
-
- - - -
-Implementation - - -
public fun get_reward_config(): RewardConfig {
-    Config::get_by_address<RewardConfig>(CoreAddresses::GENESIS_ADDRESS())
-}
-
- - - -
- -
-Specification - - - -
include GetRewardConfigAbortsIf;
-
- - - - - - - -
schema GetRewardConfigAbortsIf {
-    aborts_if !exists<Config::Config<RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());
-}
-
- - - -
- - - -## Function `reward_delay` - -Get reward delay. - - -
public fun reward_delay(): u64
-
- - - -
-Implementation - - -
public fun reward_delay() :u64 {
-    let reward_config = get_reward_config();
-    reward_config.reward_delay
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Config::Config<RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/Ring.md b/build/StarcoinFramework/docs/Ring.md deleted file mode 100644 index 074de19a..00000000 --- a/build/StarcoinFramework/docs/Ring.md +++ /dev/null @@ -1,426 +0,0 @@ - - - -# Module `0x1::Ring` - -A ring-shaped container that can hold any type, indexed from 0 -The capacity is fixed at creation time, and the accessible index is constantly growing - - -- [Struct `Ring`](#0x1_Ring_Ring) -- [Constants](#@Constants_0) -- [Function `create_with_capacity`](#0x1_Ring_create_with_capacity) -- [Function `is_full`](#0x1_Ring_is_full) -- [Function `capacity`](#0x1_Ring_capacity) -- [Function `push`](#0x1_Ring_push) -- [Function `borrow`](#0x1_Ring_borrow) -- [Function `borrow_mut`](#0x1_Ring_borrow_mut) -- [Function `index_of`](#0x1_Ring_index_of) -- [Function `destroy`](#0x1_Ring_destroy) - - -
use 0x1::Errors;
-use 0x1::Option;
-
- - - - - -## Struct `Ring` - - - -
struct Ring<Element> has store
-
- - - -
-Fields - - -
-
-data: vector<Option::Option<Element>> -
-
- -
-
-insertion_index: u64 -
-
- -
-
-external_index: u64 -
-
- -
-
- - -
- - - -## Constants - - - - -The index into the vector is out of bounds - - -
const ERROR_RING_INDEX_OUT_OF_BOUNDS: u64 = 101;
-
- - - - - -## Function `create_with_capacity` - -Create a Ring with capacity. - - -
public fun create_with_capacity<Element>(len: u64): Ring::Ring<Element>
-
- - - -
-Implementation - - -
public fun create_with_capacity<Element>( len: u64 ):Ring<Element>{
-    let data = Vector::empty<Option::Option<Element>>();
-    let i = 0;
-    while(i < len){
-        Vector::push_back(&mut data , Option::none<Element>());
-        i = i + 1;
-    };
-    Ring {
-        data             : data,
-        insertion_index  : 0,
-        external_index   : 0,
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `is_full` - -is Ring full - - -
public fun is_full<Element>(r: &Ring::Ring<Element>): bool
-
- - - -
-Implementation - - -
public fun is_full<Element>(r: &Ring<Element>):bool{
-    Option::is_some(Vector::borrow(&r.data, r.insertion_index))
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `capacity` - -Return the capacity of the Ring. - - -
public fun capacity<Element>(r: &Ring::Ring<Element>): u64
-
- - - -
-Implementation - - -
public fun capacity<Element>(r: &Ring<Element>): u64{
-    Vector::length( &r.data )
-}
-
- - - -
- -
-Specification - - - -
- - - -## Function `push` - -Add element e to the insertion_index of the Ring r. - - -
public fun push<Element>(r: &mut Ring::Ring<Element>, e: Element): Option::Option<Element>
-
- - - -
-Implementation - - -
public fun push<Element> (r: &mut Ring<Element> , e: Element):Option::Option<Element>{
-    let op_e = Vector::borrow_mut<Option::Option<Element>>(&mut r.data, r.insertion_index);
-    let res = if(  Option::is_none<Element>(op_e) ){
-        Option::fill( op_e, e);
-        Option::none<Element>()
-    }else{
-       Option::some<Element>( Option::swap( op_e, e) )
-    };
-    r.insertion_index = ( r.insertion_index + 1 ) % Vector::length(&r.data);
-    r.external_index = r.external_index + 1;
-    res
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `borrow` - -Return a reference to the ith element in the Ring r. - - -
public fun borrow<Element>(r: &Ring::Ring<Element>, i: u64): &Option::Option<Element>
-
- - - -
-Implementation - - -
public fun borrow<Element>(r:& Ring<Element>, i: u64):&Option::Option<Element>{
-    let len = capacity<Element>(r);
-    if( r.external_index > len - 1) {
-        assert!( i >= r.external_index - len && i < r.external_index , Errors::invalid_argument(ERROR_RING_INDEX_OUT_OF_BOUNDS));
-        Vector::borrow(&r.data, i % len)
-    }else {
-        assert!( i < len , Errors::invalid_argument(ERROR_RING_INDEX_OUT_OF_BOUNDS));
-        Vector::borrow(&r.data, i )
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `borrow_mut` - -Return a mutable reference to the ith element in the Ring r. - - -
public fun borrow_mut<Element>(r: &mut Ring::Ring<Element>, i: u64): &mut Option::Option<Element>
-
- - - -
-Implementation - - -
public fun borrow_mut<Element>(r: &mut Ring<Element>, i: u64):&mut Option::Option<Element>{
-    let len = capacity<Element>(r);
-    if( r.external_index > len - 1) {
-        assert!( i >= r.external_index - len && i < r.external_index , Errors::invalid_argument(ERROR_RING_INDEX_OUT_OF_BOUNDS));
-        Vector::borrow_mut(&mut r.data, i % len)
-    }else {
-        assert!( i < len , Errors::invalid_argument(ERROR_RING_INDEX_OUT_OF_BOUNDS));
-        Vector::borrow_mut(&mut r.data, i )
-    }
-
-}
-
- - - -
- -
-Specification - - - -
- - - -## Function `index_of` - -Return Option::Option<u64> if e is in the Ring r at index i. -Otherwise, returns Option::none<u64>. - - -
public fun index_of<Element>(r: &Ring::Ring<Element>, e: &Element): Option::Option<u64>
-
- - - -
-Implementation - - -
public fun index_of<Element>(r: &Ring<Element>, e: &Element):Option::Option<u64>{
-    let i = 0;
-    let len = capacity<Element>(r);
-    while ( i < len ) {
-        if ( Option::borrow(Vector::borrow( &r.data, i )) == e) return Option::some(i + r.external_index - len);
-        i = i + 1;
-    };
-    Option::none<u64>()
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `destroy` - -Destroy the Ring r. -Returns the vector saved by ring - - -
public fun destroy<Element>(r: Ring::Ring<Element>): vector<Element>
-
- - - -
-Implementation - - -
public fun destroy<Element>(r: Ring<Element>):vector<Element>{
-    let Ring {
-        data            : data ,
-        insertion_index : _,
-        external_index  : _,
-    } = r ;
-    let len = Vector::length(&data);
-    let i = 0;
-    let vec = Vector::empty<Element>();
-    while ( i < len ) {
-        let op_e = Vector::pop_back( &mut data );
-        if ( Option::is_some(&op_e) ) {
-            Vector::push_back(&mut vec, Option::destroy_some(op_e))
-        }else {
-           Option::destroy_none(op_e)
-        };
-        i = i + 1;
-    };
-    Vector::destroy_empty(data);
-    vec
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
diff --git a/build/StarcoinFramework/docs/SIPs.md b/build/StarcoinFramework/docs/SIPs.md deleted file mode 100644 index b466bfe7..00000000 --- a/build/StarcoinFramework/docs/SIPs.md +++ /dev/null @@ -1,11 +0,0 @@ - - - -# Module `0x1::SIP_3` - -https://github.com/starcoinorg/SIPs/tree/master/sip-3 - - - - -
diff --git a/build/StarcoinFramework/docs/STC.md b/build/StarcoinFramework/docs/STC.md deleted file mode 100644 index b22272d5..00000000 --- a/build/StarcoinFramework/docs/STC.md +++ /dev/null @@ -1,403 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-dummy_field: bool -
-
- -
-
- - -
- - - -## Resource `SharedBurnCapability` - -Burn capability of STC. - - -
struct SharedBurnCapability has store, key
-
- - - -
-Fields - - -
-
-cap: Token::BurnCapability<STC::STC> -
-
- -
-
- - -
- - - -## Constants - - - - -precision of STC token. - - -
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)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `initialize_v2` - -STC initialization. - - -
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>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
include Token::RegisterTokenAbortsIf<STC>{precision: PRECISION};
-
- - - -
- - - -## Function `is_stc` - -Returns true if TokenType is STC::STC - - -
public fun is_stc<TokenType: store>(): bool
-
- - - -
-Implementation - - -
public fun is_stc<TokenType: store>(): bool {
-    Token::is_same_token<STC, TokenType>()
-}
-
- - - -
- -
-Specification - - - -
- - - -## Function `burn` - -Burn STC tokens. -It can be called by anyone. - - -
public fun burn(token: Token::Token<STC::STC>)
-
- - - -
-Implementation - - -
public fun burn(token: Token<STC>) acquires SharedBurnCapability {
-    let cap = borrow_global<SharedBurnCapability>(token_address());
-    Token::burn_with_capability(&cap.cap, token);
-}
-
- - - -
- -
-Specification - - - -
aborts_if Token::spec_abstract_total_value<STC>() - token.value < 0;
-aborts_if !exists<SharedBurnCapability>(Token::SPEC_TOKEN_TEST_ADDRESS());
-
- - - -
- - - -## Function `token_address` - -Return STC token address. - - -
public fun token_address(): address
-
- - - -
-Implementation - - -
public fun token_address(): address {
-    Token::token_address<STC>()
-}
-
- - - -
- -
-Specification - - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/Secp256k1.md b/build/StarcoinFramework/docs/Secp256k1.md deleted file mode 100644 index bb6b5bbb..00000000 --- a/build/StarcoinFramework/docs/Secp256k1.md +++ /dev/null @@ -1,296 +0,0 @@ - - - -# Module `0x1::Secp256k1` - -This module implements ECDSA signatures based on the prime-order secp256k1 ellptic curve (i.e., cofactor is 1). - - -- [Struct `ECDSARawPublicKey`](#0x1_Secp256k1_ECDSARawPublicKey) -- [Struct `ECDSASignature`](#0x1_Secp256k1_ECDSASignature) -- [Constants](#@Constants_0) -- [Function `ecdsa_signature_from_bytes`](#0x1_Secp256k1_ecdsa_signature_from_bytes) -- [Function `ecdsa_raw_public_key_from_64_bytes`](#0x1_Secp256k1_ecdsa_raw_public_key_from_64_bytes) -- [Function `ecdsa_raw_public_key_to_bytes`](#0x1_Secp256k1_ecdsa_raw_public_key_to_bytes) -- [Function `ecdsa_signature_to_bytes`](#0x1_Secp256k1_ecdsa_signature_to_bytes) -- [Function `ecdsa_recover`](#0x1_Secp256k1_ecdsa_recover) -- [Function `ecdsa_recover_internal`](#0x1_Secp256k1_ecdsa_recover_internal) - - -
use 0x1::Errors;
-use 0x1::Option;
-
- - - - - -## Struct `ECDSARawPublicKey` - -A 64-byte ECDSA public key. - - -
struct ECDSARawPublicKey has copy, drop, store
-
- - - -
-Fields - - -
-
-bytes: vector<u8> -
-
- -
-
- - -
- - - -## Struct `ECDSASignature` - -A 64-byte ECDSA signature. - - -
struct ECDSASignature has copy, drop, store
-
- - - -
-Fields - - -
-
-bytes: vector<u8> -
-
- -
-
- - -
- - - -## Constants - - - - -An error occurred while deserializing, for example due to wrong input size. - - -
const E_DESERIALIZE: u64 = 1;
-
- - - - - -The size of a secp256k1-based ECDSA public key, in bytes. - - -
const RAW_PUBLIC_KEY_NUM_BYTES: u64 = 64;
-
- - - - - -The size of a secp256k1-based ECDSA signature, in bytes. - - -
const SIGNATURE_NUM_BYTES: u64 = 64;
-
- - - - - -## Function `ecdsa_signature_from_bytes` - -Constructs an ECDSASignature struct from the given 64 bytes. - - -
public fun ecdsa_signature_from_bytes(bytes: vector<u8>): Secp256k1::ECDSASignature
-
- - - -
-Implementation - - -
public fun ecdsa_signature_from_bytes(bytes: vector<u8>): ECDSASignature {
-    assert!(Vector::length(&bytes) == SIGNATURE_NUM_BYTES, Errors::invalid_argument(E_DESERIALIZE));
-    ECDSASignature { bytes }
-}
-
- - - -
- - - -## Function `ecdsa_raw_public_key_from_64_bytes` - -Constructs an ECDSARawPublicKey struct, given a 64-byte raw representation. - - -
public fun ecdsa_raw_public_key_from_64_bytes(bytes: vector<u8>): Secp256k1::ECDSARawPublicKey
-
- - - -
-Implementation - - -
public fun ecdsa_raw_public_key_from_64_bytes(bytes: vector<u8>): ECDSARawPublicKey {
-    assert!(Vector::length(&bytes) == RAW_PUBLIC_KEY_NUM_BYTES, Errors::invalid_argument(E_DESERIALIZE));
-    ECDSARawPublicKey { bytes }
-}
-
- - - -
- - - -## Function `ecdsa_raw_public_key_to_bytes` - -Serializes an ECDSARawPublicKey struct to 64-bytes. - - -
public fun ecdsa_raw_public_key_to_bytes(pk: &Secp256k1::ECDSARawPublicKey): vector<u8>
-
- - - -
-Implementation - - -
public fun ecdsa_raw_public_key_to_bytes(pk: &ECDSARawPublicKey): vector<u8> {
-    *&pk.bytes
-}
-
- - - -
- - - -## Function `ecdsa_signature_to_bytes` - -Serializes an ECDSASignature struct to 64-bytes. - - -
public fun ecdsa_signature_to_bytes(sig: &Secp256k1::ECDSASignature): vector<u8>
-
- - - -
-Implementation - - -
public fun ecdsa_signature_to_bytes(sig: &ECDSASignature): vector<u8> {
-    *&sig.bytes
-}
-
- - - -
- - - -## Function `ecdsa_recover` - -Recovers the signer's raw (64-byte) public key from a secp256k1 ECDSA signature given the recovery_id and the signed -message (32 byte digest). - -Note that an invalid signature, or a signature from a different message, will result in the recovery of an -incorrect public key. This recovery algorithm can only be used to check validity of a signature if the signer's -public key (or its hash) is known beforehand. - - -
public fun ecdsa_recover(message: vector<u8>, recovery_id: u8, signature: &Secp256k1::ECDSASignature): Option::Option<Secp256k1::ECDSARawPublicKey>
-
- - - -
-Implementation - - -
public fun ecdsa_recover(
-    message: vector<u8>,
-    recovery_id: u8,
-    signature: &ECDSASignature,
-): Option<ECDSARawPublicKey> {
-    let (pk, success) = ecdsa_recover_internal(message, recovery_id, *&signature.bytes);
-    if (success) {
-        Option::some(ecdsa_raw_public_key_from_64_bytes(pk))
-    } else {
-        Option::none<ECDSARawPublicKey>()
-    }
-}
-
- - - -
- - - -## Function `ecdsa_recover_internal` - -Returns (public_key, true) if signature verifies on message under the recovered public_key -and returns ([], false) otherwise. - - -
fun ecdsa_recover_internal(message: vector<u8>, recovery_id: u8, signature: vector<u8>): (vector<u8>, bool)
-
- - - -
-Implementation - - -
native fun ecdsa_recover_internal(
-    message: vector<u8>,
-    recovery_id: u8,
-    signature: vector<u8>
-): (vector<u8>, bool);
-
- - - -
- -
-Specification - - - -
pragma opaque;
-
- - - -
diff --git a/build/StarcoinFramework/docs/SharedEd25519PublicKey.md b/build/StarcoinFramework/docs/SharedEd25519PublicKey.md deleted file mode 100644 index f19c8fb2..00000000 --- a/build/StarcoinFramework/docs/SharedEd25519PublicKey.md +++ /dev/null @@ -1,309 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-key: vector<u8> -
-
- 32 byte ed25519 public key -
-
-rotation_cap: Account::KeyRotationCapability -
-
- rotation capability for an account whose authentication key is always derived from key -
-
- - -
- - - -## Constants - - - - - - -
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>)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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>)
-
- - - -
-Implementation - - -
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;
-}
-
- - - -
- -
-Specification - - - -
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` - -(1) rotate the public key stored 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>)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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` - -Return the public key stored under addr. -Aborts if addr does not hold a SharedEd25519PublicKey resource. - - -
public fun key(addr: address): vector<u8>
-
- - - -
-Implementation - - -
public fun key(addr: address): vector<u8> acquires SharedEd25519PublicKey {
-    *&borrow_global<SharedEd25519PublicKey>(addr).key
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<SharedEd25519PublicKey>(addr);
-
- - - -
- - - -## Function `exists_at` - -Returns true if addr holds a SharedEd25519PublicKey resource. - - -
public fun exists_at(addr: address): bool
-
- - - -
-Implementation - - -
public fun exists_at(addr: address): bool {
-    exists<SharedEd25519PublicKey>(addr)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/Signature.md b/build/StarcoinFramework/docs/Signature.md deleted file mode 100644 index e819d8cf..00000000 --- a/build/StarcoinFramework/docs/Signature.md +++ /dev/null @@ -1,154 +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) -- [Function `secp256k1_verify`](#0x1_Signature_secp256k1_verify) -- [Module Specification](#@Module_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
-
- - - -
-Implementation - - -
native public fun ed25519_validate_pubkey(public_key: vector<u8>): bool;
-
- - - -
- - - -## Function `ed25519_verify` - - - -
public fun ed25519_verify(signature: vector<u8>, public_key: vector<u8>, message: vector<u8>): bool
-
- - - -
-Implementation - - -
native public fun ed25519_verify(signature: vector<u8>, public_key: vector<u8>, message: vector<u8>): bool;
-
- - - -
- - - -## Function `native_ecrecover` - -recover address from ECDSA signature, if recover fail, return an empty vector - - -
fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>
-
- - - -
-Implementation - - -
native fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>;
-
- - - -
- - - -## Function `ecrecover` - -recover address from ECDSA signature, if recover fail, return None - - -
public fun ecrecover(hash: vector<u8>, signature: vector<u8>): Option::Option<EVMAddress::EVMAddress>
-
- - - -
-Implementation - - -
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))
-    }
-}
-
- - - -
- - - -## Function `secp256k1_verify` - - - -
public fun secp256k1_verify(signature: vector<u8>, addr: vector<u8>, message: vector<u8>): bool
-
- - - -
-Implementation - - -
public fun secp256k1_verify(signature: vector<u8>, addr: vector<u8>, message: vector<u8>) : bool{
-  let receover_address_opt:Option<EVMAddress>  = ecrecover(message, signature);
-  let expect_address =  EVMAddress::new(addr);
-  &Option::destroy_some<EVMAddress>(receover_address_opt) == &expect_address
-}
-
- - - -
- - - -## Module Specification - - - -
pragma intrinsic = true;
-
diff --git a/build/StarcoinFramework/docs/SignedInteger64.md b/build/StarcoinFramework/docs/SignedInteger64.md deleted file mode 100644 index 5d4c8fc2..00000000 --- a/build/StarcoinFramework/docs/SignedInteger64.md +++ /dev/null @@ -1,352 +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) -- [Module Specification](#@Module_Specification_0) - - -
- - - - - -## Struct `SignedInteger64` - -Define a signed integer type with two 32 bits. - - -
struct SignedInteger64 has copy, drop, store
-
- - - -
-Fields - - -
-
-value: u64 -
-
- -
-
-is_negative: bool -
-
- -
-
- - -
- - - -## Function `multiply_u64` - -Multiply a u64 integer by a signed integer number. - - -
public fun multiply_u64(num: u64, multiplier: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
- - - -
-Implementation - - -
public fun multiply_u64(num: u64, multiplier: SignedInteger64): SignedInteger64 {
-    let product = multiplier.value * num;
-    SignedInteger64 { value: product, is_negative: multiplier.is_negative }
-}
-
- - - -
- -
-Specification - - - -
aborts_if multiplier.value * num > max_u64();
-
- - - -
- - - -## Function `divide_u64` - -Divide a u64 integer by a signed integer number. - - -
public fun divide_u64(num: u64, divisor: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
- - - -
-Implementation - - -
public fun divide_u64(num: u64, divisor: SignedInteger64): SignedInteger64 {
-    let quotient = num / divisor.value;
-    SignedInteger64 { value: quotient, is_negative: divisor.is_negative }
-}
-
- - - -
- -
-Specification - - - -
aborts_if divisor.value == 0;
-
- - - -
- - - -## Function `sub_u64` - -Sub: num - minus - - -
public fun sub_u64(num: u64, minus: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
- - - -
-Implementation - - -
public fun sub_u64(num: u64, minus: SignedInteger64): SignedInteger64 {
-    if (minus.is_negative) {
-        let result = num + minus.value;
-        SignedInteger64 { value: result, is_negative: false }
-    } else {
-        if (num >= minus.value) {
-            let result = num - minus.value;
-            SignedInteger64 { value: result, is_negative: false }
-        }else {
-            let result = minus.value - num;
-            SignedInteger64 { value: result, is_negative: true }
-        }
-    }
-}
-
- - - -
- -
-Specification - - - -
aborts_if minus.is_negative && num + minus.value > max_u64();
-
- - - -
- - - -## Function `add_u64` - -Add: num + addend - - -
public fun add_u64(num: u64, addend: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
-
- - - -
-Implementation - - -
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, is_negative: false }
-        }else {
-            let result = addend.value - num;
-            SignedInteger64 { value: result, is_negative: true }
-        }
-    } else {
-        let result = num + addend.value;
-        SignedInteger64 { value: result, is_negative: false }
-    }
-}
-
- - - -
- -
-Specification - - - -
aborts_if !addend.is_negative && num + addend.value > max_u64();
-
- - - -
- - - -## Function `create_from_raw_value` - -Create a signed integer value from a unsigned integer - - -
public fun create_from_raw_value(value: u64, is_negative: bool): SignedInteger64::SignedInteger64
-
- - - -
-Implementation - - -
public fun create_from_raw_value(value: u64, is_negative: bool): SignedInteger64 {
-    SignedInteger64 { value, is_negative }
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == SignedInteger64 { value, is_negative };
-
- - - -
- - - -## Function `get_value` - -Get value part of i64 ignore sign part. - - -
public fun get_value(num: SignedInteger64::SignedInteger64): u64
-
- - - -
-Implementation - - -
public fun get_value(num: SignedInteger64): u64 {
-    num.value
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == num.value;
-
- - - -
- - - -## Function `is_negative` - -Check if the given num is negative. - - -
public fun is_negative(num: SignedInteger64::SignedInteger64): bool
-
- - - -
-Implementation - - -
public fun is_negative(num: SignedInteger64): bool {
-    num.is_negative
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == num.is_negative;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/Signer.md b/build/StarcoinFramework/docs/Signer.md deleted file mode 100644 index 8f0f1d8c..00000000 --- a/build/StarcoinFramework/docs/Signer.md +++ /dev/null @@ -1,94 +0,0 @@ - - - -# Module `0x1::Signer` - -Provide access methods for Signer. - - -- [Function `borrow_address`](#0x1_Signer_borrow_address) -- [Function `address_of`](#0x1_Signer_address_of) -- [Module Specification](#@Module_Specification_0) - - -
- - - - - -## 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
-
- - - -
-Implementation - - -
native public fun borrow_address(s: &signer): &address;
-
- - - -
- - - -## Function `address_of` - -Copies the address of the signer - - -
public fun address_of(s: &signer): address
-
- - - -
-Implementation - - -
public fun address_of(s: &signer): address {
-    *borrow_address(s)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-ensures result == address_of(s);
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/SimpleMap.md b/build/StarcoinFramework/docs/SimpleMap.md deleted file mode 100644 index 7e47f32f..00000000 --- a/build/StarcoinFramework/docs/SimpleMap.md +++ /dev/null @@ -1,543 +0,0 @@ - - - -# Module `0x1::SimpleMap` - -This module provides a solution for sorted maps, that is it has the properties that -1) Keys point to Values -2) Each Key must be unique -3) A Key can be found within O(N) time -4) The keys are unsorted. -5) Adds and removals take O(N) time - - -- [Struct `SimpleMap`](#0x1_SimpleMap_SimpleMap) -- [Struct `Element`](#0x1_SimpleMap_Element) -- [Constants](#@Constants_0) -- [Function `length`](#0x1_SimpleMap_length) -- [Function `create`](#0x1_SimpleMap_create) -- [Function `borrow`](#0x1_SimpleMap_borrow) -- [Function `borrow_mut`](#0x1_SimpleMap_borrow_mut) -- [Function `contains_key`](#0x1_SimpleMap_contains_key) -- [Function `destroy_empty`](#0x1_SimpleMap_destroy_empty) -- [Function `add`](#0x1_SimpleMap_add) -- [Function `upsert`](#0x1_SimpleMap_upsert) -- [Function `remove`](#0x1_SimpleMap_remove) -- [Function `find`](#0x1_SimpleMap_find) - - -
use 0x1::Errors;
-use 0x1::Option;
-use 0x1::Vector;
-
- - - - - -## Struct `SimpleMap` - - - -
struct SimpleMap<Key, Value> has copy, drop, store
-
- - - -
-Fields - - -
-
-data: vector<SimpleMap::Element<Key, Value>> -
-
- -
-
- - -
- - - -## Struct `Element` - - - -
struct Element<Key, Value> has copy, drop, store
-
- - - -
-Fields - - -
-
-key: Key -
-
- -
-
-value: Value -
-
- -
-
- - -
- - - -## Constants - - - - -Map key already exists - - -
const EKEY_ALREADY_EXISTS: u64 = 1;
-
- - - - - -Map key is not found - - -
const EKEY_NOT_FOUND: u64 = 2;
-
- - - - - -## Function `length` - - - -
public fun length<Key: store, Value: store>(map: &SimpleMap::SimpleMap<Key, Value>): u64
-
- - - -
-Implementation - - -
public fun length<Key: store, Value: store>(map: &SimpleMap<Key, Value>): u64 {
-    Vector::length(&map.data)
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `create` - - - -
public fun create<Key: store, Value: store>(): SimpleMap::SimpleMap<Key, Value>
-
- - - -
-Implementation - - -
public fun create<Key: store, Value: store>(): SimpleMap<Key, Value> {
-    SimpleMap {
-        data: Vector::empty(),
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `borrow` - - - -
public fun borrow<Key: store, Value: store>(map: &SimpleMap::SimpleMap<Key, Value>, key: &Key): &Value
-
- - - -
-Implementation - - -
public fun borrow<Key: store, Value: store>(
-    map: &SimpleMap<Key, Value>,
-    key: &Key,
-): &Value {
-    let maybe_idx = find(map, key);
-    assert!(Option::is_some(&maybe_idx), Errors::invalid_argument(EKEY_NOT_FOUND));
-    let idx = Option::extract(&mut maybe_idx);
-    &Vector::borrow(&map.data, idx).value
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `borrow_mut` - - - -
public fun borrow_mut<Key: store, Value: store>(map: &mut SimpleMap::SimpleMap<Key, Value>, key: &Key): &mut Value
-
- - - -
-Implementation - - -
public fun borrow_mut<Key: store, Value: store>(
-    map: &mut SimpleMap<Key, Value>,
-    key: &Key,
-): &mut Value {
-    let maybe_idx = find(map, key);
-    assert!(Option::is_some(&maybe_idx), Errors::invalid_argument(EKEY_NOT_FOUND));
-    let idx = Option::extract(&mut maybe_idx);
-    &mut Vector::borrow_mut(&mut map.data, idx).value
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `contains_key` - - - -
public fun contains_key<Key: store, Value: store>(map: &SimpleMap::SimpleMap<Key, Value>, key: &Key): bool
-
- - - -
-Implementation - - -
public fun contains_key<Key: store, Value: store>(
-    map: &SimpleMap<Key, Value>,
-    key: &Key,
-): bool {
-    let maybe_idx = find(map, key);
-    Option::is_some(&maybe_idx)
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `destroy_empty` - - - -
public fun destroy_empty<Key: store, Value: store>(map: SimpleMap::SimpleMap<Key, Value>)
-
- - - -
-Implementation - - -
public fun destroy_empty<Key: store, Value: store>(map: SimpleMap<Key, Value>) {
-    let SimpleMap { data } = map;
-    Vector::destroy_empty(data);
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `add` - - - -
public fun add<Key: store, Value: store>(map: &mut SimpleMap::SimpleMap<Key, Value>, key: Key, value: Value)
-
- - - -
-Implementation - - -
public fun add<Key: store, Value: store>(
-    map: &mut SimpleMap<Key, Value>,
-    key: Key,
-    value: Value,
-) {
-    let maybe_idx = find(map, &key);
-    assert!(Option::is_none(&maybe_idx), Errors::invalid_argument(EKEY_ALREADY_EXISTS));
-
-    Vector::push_back(&mut map.data, Element { key, value });
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `upsert` - -Insert key/value pair or update an existing key to a new value - - -
public fun upsert<Key: store, Value: store>(map: &mut SimpleMap::SimpleMap<Key, Value>, key: Key, value: Value): (Option::Option<Key>, Option::Option<Value>)
-
- - - -
-Implementation - - -
public fun upsert<Key: store, Value: store>(
-    map: &mut SimpleMap<Key, Value>,
-    key: Key,
-    value: Value
-): (Option::Option<Key>, Option::Option<Value>) {
-    let data = &mut map.data;
-    let len = Vector::length(data);
-    let i = 0;
-    while (i < len) {
-        let element = Vector::borrow(data, i);
-        if (&element.key == &key) {
-            Vector::push_back(data, Element { key, value });
-            Vector::swap(data, i, len);
-            let Element { key, value } = Vector::pop_back(data);
-            return (Option::some(key), Option::some(value))
-        };
-        i = i + 1;
-    };
-    Vector::push_back(&mut map.data, Element { key, value });
-    (Option::none(), Option::none())
-}
-
- - - -
- -
-Specification - - - -
pragma verify=false;
-
- - - -
- - - -## Function `remove` - - - -
public fun remove<Key: store, Value: store>(map: &mut SimpleMap::SimpleMap<Key, Value>, key: &Key): (Key, Value)
-
- - - -
-Implementation - - -
public fun remove<Key: store, Value: store>(
-    map: &mut SimpleMap<Key, Value>,
-    key: &Key,
-): (Key, Value) {
-    let maybe_idx = find(map, key);
-    assert!(Option::is_some(&maybe_idx), Errors::invalid_argument(EKEY_NOT_FOUND));
-    let placement = Option::extract(&mut maybe_idx);
-    let Element { key, value } = Vector::swap_remove(&mut map.data, placement);
-    (key, value)
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `find` - - - -
fun find<Key: store, Value: store>(map: &SimpleMap::SimpleMap<Key, Value>, key: &Key): Option::Option<u64>
-
- - - -
-Implementation - - -
fun find<Key: store, Value: store>(
-    map: &SimpleMap<Key, Value>,
-    key: &Key,
-): Option::Option<u64> {
-    let leng = Vector::length(&map.data);
-    let i = 0;
-    while (i < leng) {
-        let element = Vector::borrow(&map.data, i);
-        if (&element.key == key) {
-            return Option::some(i)
-        };
-        i = i + 1;
-    };
-    Option::none<u64>()
-}
-
- - - -
- -
-Specification - - - -
pragma verify=false;
-
- - - -
diff --git a/build/StarcoinFramework/docs/StarcoinVerifier.md b/build/StarcoinFramework/docs/StarcoinVerifier.md deleted file mode 100644 index cb7c6a28..00000000 --- a/build/StarcoinFramework/docs/StarcoinVerifier.md +++ /dev/null @@ -1,715 +0,0 @@ - - - -# Module `0x1::StarcoinVerifier` - - - -- [Struct `AccountState`](#0x1_StarcoinVerifier_AccountState) -- [Struct `StateProof`](#0x1_StarcoinVerifier_StateProof) -- [Struct `SparseMerkleProof`](#0x1_StarcoinVerifier_SparseMerkleProof) -- [Struct `SMTNode`](#0x1_StarcoinVerifier_SMTNode) -- [Constants](#@Constants_0) -- [Function `bcs_deserialize_account_state`](#0x1_StarcoinVerifier_bcs_deserialize_account_state) -- [Function `new_state_proof`](#0x1_StarcoinVerifier_new_state_proof) -- [Function `new_sparse_merkle_proof`](#0x1_StarcoinVerifier_new_sparse_merkle_proof) -- [Function `new_smt_node`](#0x1_StarcoinVerifier_new_smt_node) -- [Function `empty_smt_node`](#0x1_StarcoinVerifier_empty_smt_node) -- [Function `verify_state_proof`](#0x1_StarcoinVerifier_verify_state_proof) -- [Function `verify_smp`](#0x1_StarcoinVerifier_verify_smp) -- [Function `compute_smp_root_by_path_and_node_hash`](#0x1_StarcoinVerifier_compute_smp_root_by_path_and_node_hash) -- [Function `placeholder`](#0x1_StarcoinVerifier_placeholder) -- [Function `create_literal_hash`](#0x1_StarcoinVerifier_create_literal_hash) -- [Function `hash_key`](#0x1_StarcoinVerifier_hash_key) -- [Function `hash_value`](#0x1_StarcoinVerifier_hash_value) -- [Function `count_common_prefix`](#0x1_StarcoinVerifier_count_common_prefix) -- [Function `get_bit_at_from_msb`](#0x1_StarcoinVerifier_get_bit_at_from_msb) - - -
use 0x1::BCS;
-use 0x1::Hash;
-use 0x1::Option;
-use 0x1::StructuredHash;
-
- - - - - -## Struct `AccountState` - - - -
struct AccountState has copy, drop, store
-
- - - -
-Fields - - -
-
-storage_roots: vector<Option::Option<vector<u8>>> -
-
- -
-
- - -
- - - -## Struct `StateProof` - - - -
struct StateProof has copy, drop, store
-
- - - -
-Fields - - -
-
-account_proof: StarcoinVerifier::SparseMerkleProof -
-
- - * Account state's proof for global state root. - -
-
-account_state: vector<u8> -
-
- - * Account state including storage roots. - -
-
-proof: StarcoinVerifier::SparseMerkleProof -
-
- - * State's proof for account storage root. - -
-
- - -
- - - -## Struct `SparseMerkleProof` - - - -
struct SparseMerkleProof has copy, drop, store
-
- - - -
-Fields - - -
-
-siblings: vector<vector<u8>> -
-
- -
-
-leaf: StarcoinVerifier::SMTNode -
-
- -
-
- - -
- - - -## Struct `SMTNode` - - - -
struct SMTNode has copy, drop, store
-
- - - -
-Fields - - -
-
-hash1: vector<u8> -
-
- -
-
-hash2: vector<u8> -
-
- -
-
- - -
- - - -## Constants - - - - - - -
const ACCOUNT_STORAGE_INDEX_RESOURCE: u64 = 1;
-
- - - - - - - -
const BLOB_HASH_PREFIX: vector<u8> = [66, 108, 111, 98];
-
- - - - - - - -
const DEFAULT_VALUE: vector<u8> = [];
-
- - - - - - - -
const ERROR_ACCOUNT_STORAGE_ROOTS: u64 = 101;
-
- - - - - - - -
const ERROR_LITERAL_HASH_WRONG_LENGTH: u64 = 102;
-
- - - - - - - -
const HASH_LEN_IN_BITS: u64 = 256;
-
- - - - - - - -
const SPARSE_MERKLE_INTERNAL_NODE: vector<u8> = [83, 112, 97, 114, 115, 101, 77, 101, 114, 107, 108, 101, 73, 110, 116, 101, 114, 110, 97, 108, 78, 111, 100, 101];
-
- - - - - - - -
const SPARSE_MERKLE_LEAF_NODE: vector<u8> = [83, 112, 97, 114, 115, 101, 77, 101, 114, 107, 108, 101, 76, 101, 97, 102, 78, 111, 100, 101];
-
- - - - - - - -
const SPARSE_MERKLE_PLACEHOLDER_HASH_LITERAL: vector<u8> = [83, 80, 65, 82, 83, 69, 95, 77, 69, 82, 75, 76, 69, 95, 80, 76, 65, 67, 69, 72, 79, 76, 68, 69, 82, 95, 72, 65, 83, 72];
-
- - - - - -## Function `bcs_deserialize_account_state` - - - -
public fun bcs_deserialize_account_state(data: &vector<u8>): StarcoinVerifier::AccountState
-
- - - -
-Implementation - - -
public fun bcs_deserialize_account_state(data: &vector<u8>): AccountState {
-    let (vec, _) = BCS::deserialize_option_bytes_vector(data, 0);
-    AccountState{
-        storage_roots: vec
-    }
-}
-
- - - -
- - - -## Function `new_state_proof` - - - -
public fun new_state_proof(account_proof: StarcoinVerifier::SparseMerkleProof, account_state: vector<u8>, proof: StarcoinVerifier::SparseMerkleProof): StarcoinVerifier::StateProof
-
- - - -
-Implementation - - -
public fun new_state_proof(account_proof: SparseMerkleProof, account_state: vector<u8>, proof: SparseMerkleProof): StateProof {
-    StateProof{
-        account_proof,
-        account_state,
-        proof,
-    }
-}
-
- - - -
- - - -## Function `new_sparse_merkle_proof` - - - -
public fun new_sparse_merkle_proof(siblings: vector<vector<u8>>, leaf: StarcoinVerifier::SMTNode): StarcoinVerifier::SparseMerkleProof
-
- - - -
-Implementation - - -
public fun new_sparse_merkle_proof(siblings: vector<vector<u8>>, leaf: SMTNode): SparseMerkleProof {
-    SparseMerkleProof{
-        siblings,
-        leaf,
-    }
-}
-
- - - -
- - - -## Function `new_smt_node` - - - -
public fun new_smt_node(hash1: vector<u8>, hash2: vector<u8>): StarcoinVerifier::SMTNode
-
- - - -
-Implementation - - -
public fun new_smt_node(hash1: vector<u8>, hash2: vector<u8>): SMTNode {
-    SMTNode{
-        hash1,
-        hash2,
-    }
-}
-
- - - -
- - - -## Function `empty_smt_node` - - - -
public fun empty_smt_node(): StarcoinVerifier::SMTNode
-
- - - -
-Implementation - - -
public fun empty_smt_node(): SMTNode {
-    SMTNode{
-        hash1: Vector::empty(),
-        hash2: Vector::empty(),
-    }
-}
-
- - - -
- - - -## Function `verify_state_proof` - - - -
public fun verify_state_proof(state_proof: &StarcoinVerifier::StateProof, state_root: &vector<u8>, account_address: address, resource_struct_tag: &vector<u8>, state: &vector<u8>): bool
-
- - - -
-Implementation - - -
public fun verify_state_proof(state_proof: &StateProof, state_root: &vector<u8>,
-                                       account_address: address, resource_struct_tag: &vector<u8>,
-                                       state: &vector<u8>): bool {
-    let accountState: AccountState = bcs_deserialize_account_state(&state_proof.account_state);
-    assert!(Vector::length(&accountState.storage_roots) > ACCOUNT_STORAGE_INDEX_RESOURCE, ERROR_ACCOUNT_STORAGE_ROOTS);
-
-    // First, verify state for storage root.
-    let storageRoot = Option::borrow(Vector::borrow(&accountState.storage_roots, ACCOUNT_STORAGE_INDEX_RESOURCE));
-    let ok: bool = verify_smp(&state_proof.proof.siblings,
-        &state_proof.proof.leaf,
-        storageRoot,
-        resource_struct_tag, // resource struct tag BCS serialized as key
-        state);
-    if (!ok) {
-        return false
-    };
-
-    // Then, verify account state for global state root.
-    ok = verify_smp(&state_proof.account_proof.siblings,
-        &state_proof.account_proof.leaf,
-        state_root,
-        &BCS::to_bytes<address>(&account_address), // account address as key
-        &state_proof.account_state,
-    );
-    ok
-}
-
- - - -
- - - -## Function `verify_smp` - -Verify sparse merkle proof by key and value. - - -
public fun verify_smp(sibling_nodes: &vector<vector<u8>>, leaf_data: &StarcoinVerifier::SMTNode, expected_root: &vector<u8>, key: &vector<u8>, value: &vector<u8>): bool
-
- - - -
-Implementation - - -
public fun verify_smp(sibling_nodes: &vector<vector<u8>>, leaf_data: &SMTNode, expected_root: &vector<u8>, key: &vector<u8>, value: &vector<u8>): bool {
-    let path = hash_key(key);
-    let current_hash: vector<u8>;
-    if (*value == DEFAULT_VALUE) {
-        // Non-membership proof.
-        if (empty_smt_node() == *leaf_data) {
-            current_hash = placeholder();
-        } else {
-            if (*&leaf_data.hash1 == *&path) {
-                return false
-            };
-            if (!(count_common_prefix(&leaf_data.hash1, &path) >= Vector::length(sibling_nodes))) {
-                return false
-            };
-            current_hash = StructuredHash::hash(SPARSE_MERKLE_LEAF_NODE, leaf_data);
-        };
-    } else {
-        // Membership proof.
-        if (empty_smt_node() == *leaf_data) {
-            return false
-        };
-        if (*&leaf_data.hash1 != *&path) {
-            return false
-        };
-        let value_hash = hash_value(value);
-        if (*&leaf_data.hash2 != value_hash) {
-            return false
-        };
-        current_hash = StructuredHash::hash(SPARSE_MERKLE_LEAF_NODE, leaf_data);
-    };
-
-    current_hash = compute_smp_root_by_path_and_node_hash(sibling_nodes, &path, ¤t_hash);
-    current_hash == *expected_root
-}
-
- - - -
- - - -## Function `compute_smp_root_by_path_and_node_hash` - - - -
public fun compute_smp_root_by_path_and_node_hash(sibling_nodes: &vector<vector<u8>>, path: &vector<u8>, node_hash: &vector<u8>): vector<u8>
-
- - - -
-Implementation - - -
public fun compute_smp_root_by_path_and_node_hash(sibling_nodes: &vector<vector<u8>>, path: &vector<u8>, node_hash: &vector<u8>): vector<u8> {
-    let current_hash = *node_hash;
-    let i = 0;
-    let proof_length = Vector::length(sibling_nodes);
-    while (i < proof_length) {
-        let sibling = *Vector::borrow(sibling_nodes, i);
-        let bit = get_bit_at_from_msb(path, proof_length - i - 1);
-        let internal_node = if (bit) {
-            SMTNode{ hash1: sibling, hash2: current_hash }
-        } else {
-            SMTNode{ hash1: current_hash, hash2: sibling }
-        };
-        current_hash = StructuredHash::hash(SPARSE_MERKLE_INTERNAL_NODE, &internal_node);
-        i = i + 1;
-    };
-    current_hash
-}
-
- - - -
- - - -## Function `placeholder` - - - -
public fun placeholder(): vector<u8>
-
- - - -
-Implementation - - -
public fun placeholder(): vector<u8> {
-    create_literal_hash(&SPARSE_MERKLE_PLACEHOLDER_HASH_LITERAL)
-}
-
- - - -
- - - -## Function `create_literal_hash` - - - -
public fun create_literal_hash(word: &vector<u8>): vector<u8>
-
- - - -
-Implementation - - -
public fun create_literal_hash(word: &vector<u8>): vector<u8> {
-    if (Vector::length(word)  <= 32) {
-        let lenZero = 32 - Vector::length(word);
-        let i = 0;
-        let r = *word;
-        while (i < lenZero) {
-            Vector::push_back(&mut r, 0);
-            i = i + 1;
-        };
-        return r
-    };
-    abort ERROR_LITERAL_HASH_WRONG_LENGTH
-}
-
- - - -
- - - -## Function `hash_key` - - - -
fun hash_key(key: &vector<u8>): vector<u8>
-
- - - -
-Implementation - - -
fun hash_key(key: &vector<u8>): vector<u8> {
-    Hash::sha3_256(*key)
-}
-
- - - -
- - - -## Function `hash_value` - - - -
fun hash_value(value: &vector<u8>): vector<u8>
-
- - - -
-Implementation - - -
fun hash_value(value: &vector<u8>): vector<u8> {
-    StructuredHash::hash(BLOB_HASH_PREFIX, value)
-}
-
- - - -
- - - -## Function `count_common_prefix` - - - -
fun count_common_prefix(data1: &vector<u8>, data2: &vector<u8>): u64
-
- - - -
-Implementation - - -
fun count_common_prefix(data1: &vector<u8>, data2: &vector<u8>): u64 {
-    let count = 0;
-    let i = 0;
-    while ( i < Vector::length(data1) * 8) {
-        if (get_bit_at_from_msb(data1, i) == get_bit_at_from_msb(data2, i)) {
-            count = count + 1;
-        } else {
-            break
-        };
-        i = i + 1;
-    };
-    count
-}
-
- - - -
- - - -## Function `get_bit_at_from_msb` - - - -
fun get_bit_at_from_msb(data: &vector<u8>, index: u64): bool
-
- - - -
-Implementation - - -
fun get_bit_at_from_msb(data: &vector<u8>, index: u64): bool {
-    let pos = index / 8;
-    let bit = (7 - index % 8);
-    (*Vector::borrow(data, pos) >> (bit as u8)) & 1u8 != 0
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-pragma opaque;
-
- - - -
diff --git a/build/StarcoinFramework/docs/StdlibUpgradeScripts.md b/build/StarcoinFramework/docs/StdlibUpgradeScripts.md deleted file mode 100644 index 58dfb3ff..00000000 --- a/build/StarcoinFramework/docs/StdlibUpgradeScripts.md +++ /dev/null @@ -1,359 +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) -- [Function `upgrade_from_v11_to_v12`](#0x1_StdlibUpgradeScripts_upgrade_from_v11_to_v12) -- [Function `do_upgrade_from_v11_to_v12`](#0x1_StdlibUpgradeScripts_do_upgrade_from_v11_to_v12) -- [Module Specification](#@Module_Specification_0) - - -
use 0x1::Account;
-use 0x1::Block;
-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 entry fun upgrade_from_v2_to_v3(account: signer, total_stc_amount: u128)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- - - -## Function `take_linear_withdraw_capability` - -association account should call this script after upgrade from v2 to v3. - - -
public entry fun take_linear_withdraw_capability(signer: signer)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- - - -## Function `do_upgrade_from_v5_to_v6` - - - -
public fun do_upgrade_from_v5_to_v6(sender: &signer)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- - - -## Function `upgrade_from_v5_to_v6` - - - -
public entry fun upgrade_from_v5_to_v6(sender: signer)
-
- - - -
-Implementation - - -
public entry fun upgrade_from_v5_to_v6(sender: signer) {
-   Self::do_upgrade_from_v5_to_v6(&sender)
-}
-
- - - -
- - - -## Function `upgrade_from_v6_to_v7` - - - -
public entry fun upgrade_from_v6_to_v7(sender: signer)
-
- - - -
-Implementation - - -
public entry fun upgrade_from_v6_to_v7(sender: signer) {
-    Self::do_upgrade_from_v6_to_v7_with_language_version(&sender, 2);
-}
-
- - - -
- - - -## Function `do_upgrade_from_v6_to_v7` - -deprecated, use do_upgrade_from_v6_to_v7_with_language_version. - - -
public fun do_upgrade_from_v6_to_v7(sender: &signer)
-
- - - -
-Implementation - - -
public fun do_upgrade_from_v6_to_v7(sender: &signer) {
-   do_upgrade_from_v6_to_v7_with_language_version(sender, 2);
-}
-
- - - -
- - - -## Function `do_upgrade_from_v6_to_v7_with_language_version` - - - -
public fun do_upgrade_from_v6_to_v7_with_language_version(sender: &signer, language_version: u64)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- - - -## Function `upgrade_from_v7_to_v8` - - - -
public entry fun upgrade_from_v7_to_v8(sender: signer)
-
- - - -
-Implementation - - -
public entry fun upgrade_from_v7_to_v8(sender: signer) {
-    do_upgrade_from_v7_to_v8(&sender);
-}
-
- - - -
- - - -## Function `do_upgrade_from_v7_to_v8` - - - -
public fun do_upgrade_from_v7_to_v8(sender: &signer)
-
- - - -
-Implementation - - -
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);
-    };
-}
-
- - - -
- - - -## Function `upgrade_from_v11_to_v12` - - - -
public entry fun upgrade_from_v11_to_v12(sender: signer)
-
- - - -
-Implementation - - -
public entry fun upgrade_from_v11_to_v12(sender: signer) {
-    do_upgrade_from_v11_to_v12(&sender);
-}
-
- - - -
- - - -## Function `do_upgrade_from_v11_to_v12` - - - -
public fun do_upgrade_from_v11_to_v12(sender: &signer)
-
- - - -
-Implementation - - -
public fun do_upgrade_from_v11_to_v12(sender: &signer) {
-    {
-        Block::checkpoints_init(sender);
-    };
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/String.md b/build/StarcoinFramework/docs/String.md deleted file mode 100644 index 856a29b2..00000000 --- a/build/StarcoinFramework/docs/String.md +++ /dev/null @@ -1,530 +0,0 @@ - - - -# Module `0x1::String` - -The string module defines the String type which represents UTF8 encoded strings. - - -- [Struct `String`](#0x1_String_String) -- [Constants](#@Constants_0) -- [Function `utf8`](#0x1_String_utf8) -- [Function `try_utf8`](#0x1_String_try_utf8) -- [Function `bytes`](#0x1_String_bytes) -- [Function `is_empty`](#0x1_String_is_empty) -- [Function `length`](#0x1_String_length) -- [Function `append`](#0x1_String_append) -- [Function `append_utf8`](#0x1_String_append_utf8) -- [Function `insert`](#0x1_String_insert) -- [Function `sub_string`](#0x1_String_sub_string) -- [Function `index_of`](#0x1_String_index_of) -- [Function `internal_check_utf8`](#0x1_String_internal_check_utf8) -- [Function `internal_is_char_boundary`](#0x1_String_internal_is_char_boundary) -- [Function `internal_sub_string`](#0x1_String_internal_sub_string) -- [Function `internal_index_of`](#0x1_String_internal_index_of) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::Errors;
-use 0x1::Option;
-use 0x1::Vector;
-
- - - - - -## Struct `String` - -A String holds a sequence of bytes which is guaranteed to be in utf8 format. - - -
struct String has copy, drop, store
-
- - - -
-Fields - - -
-
-bytes: vector<u8> -
-
- -
-
- - -
- - - -## Constants - - - - -An invalid UTF8 encoding. - - -
const EINVALID_UTF8: u64 = 1;
-
- - - - - -Index out of range. - - -
const EINVALID_INDEX: u64 = 2;
-
- - - - - -## Function `utf8` - -Creates a new string from a sequence of bytes. Aborts if the bytes do not represent valid utf8. - - -
public fun utf8(bytes: vector<u8>): String::String
-
- - - -
-Implementation - - -
public fun utf8(bytes: vector<u8>): String {
-    assert!(internal_check_utf8(&bytes), Errors::invalid_state(EINVALID_UTF8));
-    String{bytes}
-}
-
- - - -
- - - -## Function `try_utf8` - -Tries to create a new string from a sequence of bytes. - - -
public fun try_utf8(bytes: vector<u8>): Option::Option<String::String>
-
- - - -
-Implementation - - -
public fun try_utf8(bytes: vector<u8>): Option<String> {
-    if (internal_check_utf8(&bytes)) {
-        Option::some(String{bytes})
-    } else {
-        Option::none()
-    }
-}
-
- - - -
- - - -## Function `bytes` - -Returns a reference to the underlying byte vector. - - -
public fun bytes(s: &String::String): &vector<u8>
-
- - - -
-Implementation - - -
public fun bytes(s: &String): &vector<u8> {
-    &s.bytes
-}
-
- - - -
- - - -## Function `is_empty` - -Checks whether this string is empty. - - -
public fun is_empty(s: &String::String): bool
-
- - - -
-Implementation - - -
public fun is_empty(s: &String): bool {
-    Vector::is_empty(&s.bytes)
-}
-
- - - -
- - - -## Function `length` - -Returns the length of this string, in bytes. - - -
public fun length(s: &String::String): u64
-
- - - -
-Implementation - - -
public fun length(s: &String): u64 {
-    Vector::length(&s.bytes)
-}
-
- - - -
- - - -## Function `append` - -Appends a string. - - -
public fun append(s: &mut String::String, r: String::String)
-
- - - -
-Implementation - - -
public fun append(s: &mut String, r: String) {
-    Vector::append(&mut s.bytes, *&r.bytes)
-}
-
- - - -
- - - -## Function `append_utf8` - -Appends bytes which must be in valid utf8 format. - - -
public fun append_utf8(s: &mut String::String, bytes: vector<u8>)
-
- - - -
-Implementation - - -
public fun append_utf8(s: &mut String, bytes: vector<u8>) {
-    append(s, utf8(bytes))
-}
-
- - - -
- - - -## Function `insert` - -Insert the other string at the byte index in given string. The index must be at a valid utf8 char -boundary. - - -
public fun insert(s: &mut String::String, at: u64, o: String::String)
-
- - - -
-Implementation - - -
public fun insert(s: &mut String, at: u64, o: String) {
-    let bytes = &s.bytes;
-    assert!(at <= Vector::length(bytes) && internal_is_char_boundary(bytes, at), Errors::invalid_state(EINVALID_INDEX));
-    let l = length(s);
-    let front = sub_string(s, 0, at);
-    let end = sub_string(s, at, l);
-    append(&mut front, o);
-    append(&mut front, end);
-    *s = front;
-}
-
- - - -
- - - -## Function `sub_string` - -Returns a sub-string using the given byte indices, where i is the first byte position and j is the start -of the first byte not included (or the length of the string). The indices must be at valid utf8 char boundaries, -guaranteeing that the result is valid utf8. - - -
public fun sub_string(s: &String::String, i: u64, j: u64): String::String
-
- - - -
-Implementation - - -
public fun sub_string(s: &String, i: u64, j: u64): String {
-    let bytes = &s.bytes;
-    let l = Vector::length(bytes);
-    assert!(
-        j <= l && i <= j && internal_is_char_boundary(bytes, i) && internal_is_char_boundary(bytes, j),
-        Errors::invalid_state(EINVALID_INDEX)
-    );
-    String{bytes: internal_sub_string(bytes, i, j)}
-}
-
- - - -
- - - -## Function `index_of` - -Computes the index of the first occurrence of a string. Returns length(s) if no occurrence found. - - -
public fun index_of(s: &String::String, r: &String::String): u64
-
- - - -
-Implementation - - -
public fun index_of(s: &String, r: &String): u64 {
-    internal_index_of(&s.bytes, &r.bytes)
-}
-
- - - -
- - - -## Function `internal_check_utf8` - - - -
fun internal_check_utf8(v: &vector<u8>): bool
-
- - - -
-Implementation - - -
native fun internal_check_utf8(v: &vector<u8>): bool;
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if [abstract] false;
-ensures [abstract] result == spec_internal_check_utf8(v);
-
- - - -
- - - -## Function `internal_is_char_boundary` - - - -
fun internal_is_char_boundary(v: &vector<u8>, i: u64): bool
-
- - - -
-Implementation - - -
native fun internal_is_char_boundary(v: &vector<u8>, i: u64): bool;
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if [abstract] false;
-ensures [abstract] result == spec_internal_is_char_boundary(v, i);
-
- - - -
- - - -## Function `internal_sub_string` - - - -
fun internal_sub_string(v: &vector<u8>, i: u64, j: u64): vector<u8>
-
- - - -
-Implementation - - -
native fun internal_sub_string(v: &vector<u8>, i: u64, j: u64): vector<u8>;
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if [abstract] false;
-ensures [abstract] result == spec_internal_sub_string(v, i, j);
-
- - - -
- - - -## Function `internal_index_of` - - - -
fun internal_index_of(v: &vector<u8>, r: &vector<u8>): u64
-
- - - -
-Implementation - - -
native fun internal_index_of(v: &vector<u8>, r: &vector<u8>): u64;
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if [abstract] false;
-ensures [abstract] result == spec_internal_index_of(v, r);
-
- - - - - - - -
fun spec_internal_check_utf8(v: vector<u8>): bool;
-
-fun spec_internal_is_char_boundary(v: vector<u8>, i: u64): bool;
-
-fun spec_internal_sub_string(v: vector<u8>, i: u64, j: u64): vector<u8>;
-
-fun spec_internal_index_of(v: vector<u8>, r: vector<u8>): u64;
-
- - - -
- - - -## Module Specification - - - - - - -
fun spec_utf8(bytes: vector<u8>): String {
-   String{bytes}
-}
-
diff --git a/build/StarcoinFramework/docs/Table.md b/build/StarcoinFramework/docs/Table.md deleted file mode 100644 index f7c4a3f5..00000000 --- a/build/StarcoinFramework/docs/Table.md +++ /dev/null @@ -1,831 +0,0 @@ - - - -# Module `0x1::Table` - -Type of large-scale storage tables. - - -- [Struct `Table`](#0x1_Table_Table) -- [Resource `Box`](#0x1_Table_Box) -- [Constants](#@Constants_0) -- [Function `new`](#0x1_Table_new) -- [Function `destroy_empty`](#0x1_Table_destroy_empty) -- [Function `add`](#0x1_Table_add) -- [Function `borrow`](#0x1_Table_borrow) -- [Function `borrow_with_default`](#0x1_Table_borrow_with_default) -- [Function `borrow_mut`](#0x1_Table_borrow_mut) -- [Function `length`](#0x1_Table_length) -- [Function `empty`](#0x1_Table_empty) -- [Function `borrow_mut_with_default`](#0x1_Table_borrow_mut_with_default) -- [Function `upsert`](#0x1_Table_upsert) -- [Function `remove`](#0x1_Table_remove) -- [Function `contains`](#0x1_Table_contains) -- [Function `new_table_handle`](#0x1_Table_new_table_handle) -- [Function `add_box`](#0x1_Table_add_box) -- [Function `borrow_box`](#0x1_Table_borrow_box) -- [Function `borrow_box_mut`](#0x1_Table_borrow_box_mut) -- [Function `contains_box`](#0x1_Table_contains_box) -- [Function `remove_box`](#0x1_Table_remove_box) -- [Function `destroy_empty_box`](#0x1_Table_destroy_empty_box) -- [Function `drop_unchecked_box`](#0x1_Table_drop_unchecked_box) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::Errors;
-
- - - - - -## Struct `Table` - -Type of tables - - -
struct Table<K: copy, drop, V> has store
-
- - - -
-Fields - - -
-
-handle: address -
-
- -
-
-length: u64 -
-
- -
-
- - -
- -
-Specification - - - -
pragma intrinsic = map,
-map_new = new,
-map_destroy_empty = destroy_empty,
-map_len = length,
-map_is_empty = empty,
-map_has_key = contains,
-map_add_no_override = add,
-map_del_must_exist = remove,
-map_borrow = borrow,
-map_borrow_mut = borrow_mut,
-map_spec_get = spec_get,
-map_spec_set = spec_set,
-map_spec_del = spec_remove,
-map_spec_len = spec_len,
-map_spec_has_key = spec_contains;
-
- - - -
- - - -## Resource `Box` - -Wrapper for values. Required for making values appear as resources in the implementation. - - -
struct Box<V> has drop, store, key
-
- - - -
-Fields - - -
-
-val: V -
-
- -
-
- - -
- - - -## Constants - - - - - - -
const EALREADY_EXISTS: u64 = 100;
-
- - - - - - - -
const ENOT_EMPTY: u64 = 102;
-
- - - - - - - -
const ENOT_FOUND: u64 = 101;
-
- - - - - -## Function `new` - -Create a new Table. - - -
public fun new<K: copy, drop, V: store>(): Table::Table<K, V>
-
- - - -
-Implementation - - -
public fun new<K: copy + drop, V: store>(): Table<K, V> {
-    Table{
-        handle: new_table_handle<K, V>(),
-        length: 0,
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic;
-
- - - -
- - - -## Function `destroy_empty` - -Destroy a table. The table must be empty to succeed. - - -
public fun destroy_empty<K: copy, drop, V>(table: Table::Table<K, V>)
-
- - - -
-Implementation - - -
public fun destroy_empty<K: copy + drop, V>(table: Table<K, V>) {
-    assert!(table.length == 0, Errors::invalid_state(ENOT_EMPTY));
-    destroy_empty_box<K, V, Box<V>>(&table);
-    drop_unchecked_box<K, V, Box<V>>(table)
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic;
-
- - - -
- - - -## Function `add` - -Add a new entry to the table. Aborts if an entry for this -key already exists. The entry itself is not stored in the -table, and cannot be discovered from it. - - -
public fun add<K: copy, drop, V>(table: &mut Table::Table<K, V>, key: K, val: V)
-
- - - -
-Implementation - - -
public fun add<K: copy + drop, V>(table: &mut Table<K, V>, key: K, val: V) {
-    add_box<K, V, Box<V>>(table, key, Box{val});
-    table.length = table.length + 1
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic;
-
- - - -
- - - -## Function `borrow` - -Acquire an immutable reference to the value which key maps to. -Aborts if there is no entry for key. - - -
public fun borrow<K: copy, drop, V>(table: &Table::Table<K, V>, key: K): &V
-
- - - -
-Implementation - - -
public fun borrow<K: copy + drop, V>(table: &Table<K, V>, key: K): &V {
-    &borrow_box<K, V, Box<V>>(table, key).val
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic;
-
- - - -
- - - -## Function `borrow_with_default` - -Acquire an immutable reference to the value which key maps to. -Returns specified default value if there is no entry for key. - - -
public fun borrow_with_default<K: copy, drop, V>(table: &Table::Table<K, V>, key: K, default: &V): &V
-
- - - -
-Implementation - - -
public fun borrow_with_default<K: copy + drop, V>(table: &Table<K, V>, key: K, default: &V): &V {
-    if (!contains(table, copy key)) {
-        default
-    } else {
-        borrow(table, copy key)
-    }
-}
-
- - - -
- - - -## Function `borrow_mut` - -Acquire a mutable reference to the value which key maps to. -Aborts if there is no entry for key. - - -
public fun borrow_mut<K: copy, drop, V>(table: &mut Table::Table<K, V>, key: K): &mut V
-
- - - -
-Implementation - - -
public fun borrow_mut<K: copy + drop, V>(table: &mut Table<K, V>, key: K): &mut V {
-    &mut borrow_box_mut<K, V, Box<V>>(table, key).val
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic;
-
- - - -
- - - -## Function `length` - -Returns the length of the table, i.e. the number of entries. - - -
public fun length<K: copy, drop, V>(table: &Table::Table<K, V>): u64
-
- - - -
-Implementation - - -
public fun length<K: copy + drop, V>(table: &Table<K, V>): u64 {
-    table.length
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic;
-
- - - -
- - - -## Function `empty` - -Returns true if this table is empty. - - -
public fun empty<K: copy, drop, V>(table: &Table::Table<K, V>): bool
-
- - - -
-Implementation - - -
public fun empty<K: copy + drop, V>(table: &Table<K, V>): bool {
-    table.length == 0
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic;
-
- - - -
- - - -## Function `borrow_mut_with_default` - -Acquire a mutable reference to the value which key maps to. -Insert the pair (key, default) first if there is no entry for key. - - -
public fun borrow_mut_with_default<K: copy, drop, V: drop>(table: &mut Table::Table<K, V>, key: K, default: V): &mut V
-
- - - -
-Implementation - - -
public fun borrow_mut_with_default<K: copy + drop, V: drop>(table: &mut Table<K, V>, key: K, default: V): &mut V {
-    if (!contains(table, copy key)) {
-        add(table, copy key, default)
-    };
-    borrow_mut(table, key)
-}
-
- - - -
- -
-Specification - - - -
pragma opaque, verify=false;
-aborts_if false;
-
- - - -
- - - -## Function `upsert` - -Insert the pair (key, value) if there is no entry for key. -update the value of the entry for key to value otherwise - - -
public fun upsert<K: copy, drop, V: drop>(table: &mut Table::Table<K, V>, key: K, value: V)
-
- - - -
-Implementation - - -
public fun upsert<K: copy + drop, V: drop>(table: &mut Table<K, V>, key: K, value: V) {
-    if (!contains(table, copy key)) {
-        add(table, copy key, value)
-    } else {
-        let ref = borrow_mut(table, key);
-        *ref = value;
-    };
-}
-
- - - -
- - - -## Function `remove` - -Remove from table and return the value which key maps to. -Aborts if there is no entry for key. - - -
public fun remove<K: copy, drop, V>(table: &mut Table::Table<K, V>, key: K): V
-
- - - -
-Implementation - - -
public fun remove<K: copy + drop, V>(table: &mut Table<K, V>, key: K): V {
-    let Box{val} = remove_box<K, V, Box<V>>(table, key);
-    table.length = table.length - 1;
-    val
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic;
-
- - - -
- - - -## Function `contains` - -Returns true iff table contains an entry for key. - - -
public fun contains<K: copy, drop, V>(table: &Table::Table<K, V>, key: K): bool
-
- - - -
-Implementation - - -
public fun contains<K: copy + drop, V>(table: &Table<K, V>, key: K): bool {
-    contains_box<K, V, Box<V>>(table, key)
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic;
-
- - - -
- - - -## Function `new_table_handle` - - - -
fun new_table_handle<K, V>(): address
-
- - - -
-Implementation - - -
native fun new_table_handle<K, V>(): address;
-
- - - -
- - - -## Function `add_box` - - - -
fun add_box<K: copy, drop, V, B>(table: &mut Table::Table<K, V>, key: K, val: Table::Box<V>)
-
- - - -
-Implementation - - -
native fun add_box<K: copy + drop, V, B>(table: &mut Table<K, V>, key: K, val: Box<V>);
-
- - - -
- - - -## Function `borrow_box` - - - -
fun borrow_box<K: copy, drop, V, B>(table: &Table::Table<K, V>, key: K): &Table::Box<V>
-
- - - -
-Implementation - - -
native fun borrow_box<K: copy + drop, V, B>(table: &Table<K, V>, key: K): &Box<V>;
-
- - - -
- - - -## Function `borrow_box_mut` - - - -
fun borrow_box_mut<K: copy, drop, V, B>(table: &mut Table::Table<K, V>, key: K): &mut Table::Box<V>
-
- - - -
-Implementation - - -
native fun borrow_box_mut<K: copy + drop, V, B>(table: &mut Table<K, V>, key: K): &mut Box<V>;
-
- - - -
- - - -## Function `contains_box` - - - -
fun contains_box<K: copy, drop, V, B>(table: &Table::Table<K, V>, key: K): bool
-
- - - -
-Implementation - - -
native fun contains_box<K: copy + drop, V, B>(table: &Table<K, V>, key: K): bool;
-
- - - -
- - - -## Function `remove_box` - - - -
fun remove_box<K: copy, drop, V, B>(table: &mut Table::Table<K, V>, key: K): Table::Box<V>
-
- - - -
-Implementation - - -
native fun remove_box<K: copy + drop, V, B>(table: &mut Table<K, V>, key: K): Box<V>;
-
- - - -
- - - -## Function `destroy_empty_box` - - - -
fun destroy_empty_box<K: copy, drop, V, B>(table: &Table::Table<K, V>)
-
- - - -
-Implementation - - -
native fun destroy_empty_box<K: copy + drop, V, B>(table: &Table<K, V>);
-
- - - -
- - - -## Function `drop_unchecked_box` - - - -
fun drop_unchecked_box<K: copy, drop, V, B>(table: Table::Table<K, V>)
-
- - - -
-Implementation - - -
native fun drop_unchecked_box<K: copy + drop, V, B>(table: Table<K, V>);
-
- - - -
- - - -## Module Specification - - - - - - -
native fun spec_len<K, V>(t: Table<K, V>): num;
-
- - - - - - - -
native fun spec_contains<K, V>(t: Table<K, V>, k: K): bool;
-
- - - - - - - -
native fun spec_set<K, V>(t: Table<K, V>, k: K, v: V): Table<K, V>;
-
- - - - - - - -
native fun spec_remove<K, V>(t: Table<K, V>, k: K): Table<K, V>;
-
- - - - - - - -
native fun spec_get<K, V>(t: Table<K, V>, k: K): V;
-
diff --git a/build/StarcoinFramework/docs/Timestamp.md b/build/StarcoinFramework/docs/Timestamp.md deleted file mode 100644 index a4af9aaa..00000000 --- a/build/StarcoinFramework/docs/Timestamp.md +++ /dev/null @@ -1,461 +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) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::CoreAddresses;
-use 0x1::Errors;
-
- - - - - -## Resource `CurrentTimeMilliseconds` - - - -
struct CurrentTimeMilliseconds has key
-
- - - -
-Fields - - -
-
-milliseconds: u64 -
-
- -
-
- - -
- - - -## Resource `TimeHasStarted` - -A singleton resource used to determine whether time has started. This -is called at the end of genesis. - - -
struct TimeHasStarted has key
-
- - - -
-Fields - - -
-
-dummy_field: bool -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if Signer::address_of(account) != CoreAddresses::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)
-
- - - -
-Implementation - - -
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;
-}
-
- - - -
- -
-Specification - - - -
aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-aborts_if !exists<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
-aborts_if timestamp <= global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds;
-ensures global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds == timestamp;
-
- - - -
- - - -## Function `now_seconds` - - - -
public fun now_seconds(): u64
-
- - - -
-Implementation - - -
public fun now_seconds(): u64 acquires CurrentTimeMilliseconds {
-    now_milliseconds() / MILLI_CONVERSION_FACTOR
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
-ensures result == now_milliseconds() / MILLI_CONVERSION_FACTOR;
-
- - - - - - - -
fun spec_now_seconds(): u64 {
-   global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds / MILLI_CONVERSION_FACTOR
-}
-
- - - -
- - - -## Function `now_milliseconds` - - - -
public fun now_milliseconds(): u64
-
- - - -
-Implementation - - -
public fun now_milliseconds(): u64 acquires CurrentTimeMilliseconds {
-    borrow_global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
-ensures result == global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds;
-
- - - - - - - -
fun spec_now_millseconds(): u64 {
-   global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds
-}
-
- - - -
- - - -## Function `set_time_has_started` - -Marks that time has started and genesis has finished. This can only be called from genesis. - - -
public fun set_time_has_started(account: &signer)
-
- - - -
-Implementation - - -
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{});
-}
-
- - - -
- -
-Specification - - - -
aborts_if Signer::address_of(account) != CoreAddresses::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` - -Helper function to determine if the blockchain is in genesis state. - - -
public fun is_genesis(): bool
-
- - - -
-Implementation - - -
public fun is_genesis(): bool {
-    !exists<TimeHasStarted>(CoreAddresses::GENESIS_ADDRESS())
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == !exists<TimeHasStarted>(CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `assert_genesis` - -Helper function to assert genesis state. - - -
public fun assert_genesis()
-
- - - -
-Implementation - - -
public fun assert_genesis() {
-    assert!(is_genesis(), Errors::invalid_state(ENOT_GENESIS));
-}
-
- - - -
- -
-Specification - - - -
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::GENESIS_ADDRESS());
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/Token.md b/build/StarcoinFramework/docs/Token.md deleted file mode 100644 index a32c5fb7..00000000 --- a/build/StarcoinFramework/docs/Token.md +++ /dev/null @@ -1,1845 +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 `type_of`](#0x1_Token_type_of) -- [Function `name_of`](#0x1_Token_name_of) -- [Function `name_of_token`](#0x1_Token_name_of_token) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-value: u128 -
-
- -
-
- - -
- - - -## Struct `TokenCode` - -Token Code which identify a unique Token. - - -
struct TokenCode has copy, drop, store
-
- - - -
-Fields - - -
-
-addr: address -
-
- address who define the module contains the Token Type. -
-
-module_name: vector<u8> -
-
- module which contains the Token Type. -
-
-name: vector<u8> -
-
- name of the token. may nested if the token is an instantiated generic token type. -
-
- - -
- - - -## Resource `MintCapability` - -A minting capability allows tokens of type TokenType to be minted - - -
struct MintCapability<TokenType> has store, key
-
- - - -
-Fields - - -
-
-dummy_field: bool -
-
- -
-
- - -
- - - -## Resource `FixedTimeMintKey` - -A fixed time mint key which can mint token until global time > end_time - - -
struct FixedTimeMintKey<TokenType> has store, key
-
- - - -
-Fields - - -
-
-total: u128 -
-
- -
-
-end_time: u64 -
-
- -
-
- - -
- - - -## Resource `LinearTimeMintKey` - -A linear time mint key which can mint token in a period by time-based linear release. - - -
struct LinearTimeMintKey<TokenType> has store, key
-
- - - -
-Fields - - -
-
-total: u128 -
-
- -
-
-minted: u128 -
-
- -
-
-start_time: u64 -
-
- -
-
-period: u64 -
-
- -
-
- - -
- - - -## Resource `BurnCapability` - -A burn capability allows tokens of type TokenType to be burned. - - -
struct BurnCapability<TokenType> has store, key
-
- - - -
-Fields - - -
-
-dummy_field: bool -
-
- -
-
- - -
- - - -## Struct `MintEvent` - -Event emitted when token minted. - - -
struct MintEvent has drop, store
-
- - - -
-Fields - - -
-
-amount: u128 -
-
- funds added to the system -
-
-token_code: Token::TokenCode -
-
- full info of Token. -
-
- - -
- - - -## Struct `BurnEvent` - -Event emitted when token burned. - - -
struct BurnEvent has drop, store
-
- - - -
-Fields - - -
-
-amount: u128 -
-
- funds removed from the system -
-
-token_code: Token::TokenCode -
-
- full info of Token -
-
- - -
- - - -## Resource `TokenInfo` - -Token information. - - -
struct TokenInfo<TokenType> has key
-
- - - -
-Fields - - -
-
-total_value: u128 -
-
- The total value for the token represented by - TokenType. Mutable. -
-
-scaling_factor: u128 -
-
- The scaling factor for the coin (i.e. the amount to divide by - to get to the human-readable representation for this currency). - e.g. 10^6 for Coin1 -
-
-mint_events: Event::EventHandle<Token::MintEvent> -
-
- event stream for minting -
-
-burn_events: Event::EventHandle<Token::BurnEvent> -
-
- event stream for burning -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
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),
-        },
-    );
-}
-
- - - -
- -
-Specification - - - -
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` - -Remove mint capability from signer. - - -
public fun remove_mint_capability<TokenType: store>(signer: &signer): Token::MintCapability<TokenType>
-
- - - -
-Implementation - - -
public fun remove_mint_capability<TokenType: store>(signer: &signer): MintCapability<TokenType>
-acquires MintCapability {
-    move_from<MintCapability<TokenType>>(Signer::address_of(signer))
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<MintCapability<TokenType>>(Signer::address_of(signer));
-ensures !exists<MintCapability<TokenType>>(Signer::address_of(signer));
-
- - - -
- - - -## Function `add_mint_capability` - -Add mint capability to signer. - - -
public fun add_mint_capability<TokenType: store>(signer: &signer, cap: Token::MintCapability<TokenType>)
-
- - - -
-Implementation - - -
public fun add_mint_capability<TokenType: store>(signer: &signer, cap: MintCapability<TokenType>) {
-    move_to(signer, cap)
-}
-
- - - -
- -
-Specification - - - -
aborts_if exists<MintCapability<TokenType>>(Signer::address_of(signer));
-ensures exists<MintCapability<TokenType>>(Signer::address_of(signer));
-
- - - -
- - - -## Function `destroy_mint_capability` - -Destroy the given mint capability. - - -
public fun destroy_mint_capability<TokenType: store>(cap: Token::MintCapability<TokenType>)
-
- - - -
-Implementation - - -
public fun destroy_mint_capability<TokenType: store>(cap: MintCapability<TokenType>) {
-    let MintCapability<TokenType> {} = cap;
-}
-
- - - -
- -
-Specification - - - -
- - - -## Function `remove_burn_capability` - -remove the token burn capability from signer. - - -
public fun remove_burn_capability<TokenType: store>(signer: &signer): Token::BurnCapability<TokenType>
-
- - - -
-Implementation - - -
public fun remove_burn_capability<TokenType: store>(signer: &signer): BurnCapability<TokenType>
-acquires BurnCapability {
-    move_from<BurnCapability<TokenType>>(Signer::address_of(signer))
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<BurnCapability<TokenType>>(Signer::address_of(signer));
-ensures !exists<BurnCapability<TokenType>>(Signer::address_of(signer));
-
- - - -
- - - -## Function `add_burn_capability` - -Add token burn capability to signer. - - -
public fun add_burn_capability<TokenType: store>(signer: &signer, cap: Token::BurnCapability<TokenType>)
-
- - - -
-Implementation - - -
public fun add_burn_capability<TokenType: store>(signer: &signer, cap: BurnCapability<TokenType>) {
-    move_to(signer, cap)
-}
-
- - - -
- -
-Specification - - - -
aborts_if exists<BurnCapability<TokenType>>(Signer::address_of(signer));
-ensures exists<BurnCapability<TokenType>>(Signer::address_of(signer));
-
- - - -
- - - -## Function `destroy_burn_capability` - -Destroy the given burn capability. - - -
public fun destroy_burn_capability<TokenType: store>(cap: Token::BurnCapability<TokenType>)
-
- - - -
-Implementation - - -
public fun destroy_burn_capability<TokenType: store>(cap: BurnCapability<TokenType>) {
-    let BurnCapability<TokenType> {} = cap;
-}
-
- - - -
- -
-Specification - - - -
- - - -## Function `mint` - -Return amount tokens. -Fails if the sender does not have a published MintCapability. - - -
public fun mint<TokenType: store>(account: &signer, amount: u128): Token::Token<TokenType>
-
- - - -
-Implementation - - -
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,
-    )
-}
-
- - - -
- -
-Specification - - - -
aborts_if spec_abstract_total_value<TokenType>() + amount > MAX_U128;
-aborts_if !exists<MintCapability<TokenType>>(Signer::address_of(account));
-
- - - -
- - - -## Function `mint_with_capability` - -Mint a new Token::Token worth 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>
-
- - - -
-Implementation - - -
public fun mint_with_capability<TokenType: store>(
-    _capability: &MintCapability<TokenType>,
-    amount: u128,
-): Token<TokenType> acquires TokenInfo {
-    do_mint(amount)
-}
-
- - - -
- -
-Specification - - - -
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>
-
- - - -
-Implementation - - -
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 }
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS());
-aborts_if spec_abstract_total_value<TokenType>() + amount > MAX_U128;
-
- - - -
- - - -## Function `issue_fixed_mint_key` - -Deprecated since @v3 -Issue a FixedTimeMintKey with given MintCapability. - - -
public fun issue_fixed_mint_key<TokenType: store>(_capability: &Token::MintCapability<TokenType>, _amount: u128, _period: u64): Token::FixedTimeMintKey<TokenType>
-
- - - -
-Implementation - - -
public fun issue_fixed_mint_key<TokenType: store>(
-    _capability: &MintCapability<TokenType>,
-    _amount: u128,
-    _period: u64,
-): FixedTimeMintKey<TokenType> {
-    abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
- - - -
- -
-Specification - - - -
aborts_if true;
-
- - - -
- - - -## Function `issue_linear_mint_key` - -Deprecated since @v3 -Issue a LinearTimeMintKey with given MintCapability. - - -
public fun issue_linear_mint_key<TokenType: store>(_capability: &Token::MintCapability<TokenType>, _amount: u128, _period: u64): Token::LinearTimeMintKey<TokenType>
-
- - - -
-Implementation - - -
public fun issue_linear_mint_key<TokenType: store>(
-    _capability: &MintCapability<TokenType>,
-    _amount: u128,
-    _period: u64,
-): LinearTimeMintKey<TokenType> {
-    abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
- - - -
- -
-Specification - - - -
aborts_if true;
-
- - - -
- - - -## Function `destroy_linear_time_key` - -Destroy LinearTimeMintKey, for deprecated - - -
public fun destroy_linear_time_key<TokenType: store>(key: Token::LinearTimeMintKey<TokenType>): (u128, u128, u64, u64)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `read_linear_time_key` - - - -
public fun read_linear_time_key<TokenType: store>(key: &Token::LinearTimeMintKey<TokenType>): (u128, u128, u64, u64)
-
- - - -
-Implementation - - -
public fun read_linear_time_key<TokenType: store>(key: &LinearTimeMintKey<TokenType>): (u128, u128, u64, u64) {
-    (key.total, key.minted, key.start_time, key.period)
-}
-
- - - -
- - - -## Function `burn` - -Burn some tokens of signer. - - -
public fun burn<TokenType: store>(account: &signer, tokens: Token::Token<TokenType>)
-
- - - -
-Implementation - - -
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,
-    )
-}
-
- - - -
- -
-Specification - - - -
aborts_if spec_abstract_total_value<TokenType>() - tokens.value < 0;
-aborts_if !exists<BurnCapability<TokenType>>(Signer::address_of(account));
-
- - - -
- - - -## Function `burn_with_capability` - -Burn tokens with the given BurnCapability. - - -
public fun burn_with_capability<TokenType: store>(_capability: &Token::BurnCapability<TokenType>, tokens: Token::Token<TokenType>)
-
- - - -
-Implementation - - -
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 },
-        },
-    );
-}
-
- - - -
- -
-Specification - - - -
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` - -Create a new Token::Token with a value of 0 - - -
public fun zero<TokenType: store>(): Token::Token<TokenType>
-
- - - -
-Implementation - - -
public fun zero<TokenType: store>(): Token<TokenType> {
-    Token<TokenType> { value: 0 }
-}
-
- - - -
- -
-Specification - - - -
ensures result.value == 0;
-
- - - -
- - - -## Function `value` - -Public accessor for the value of a token - - -
public fun value<TokenType: store>(token: &Token::Token<TokenType>): u128
-
- - - -
-Implementation - - -
public fun value<TokenType: store>(token: &Token<TokenType>): u128 {
-    token.value
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == token.value;
-
- - - -
- - - -## Function `split` - -Splits the given token into two and returns them both - - -
public fun split<TokenType: store>(token: Token::Token<TokenType>, value: u128): (Token::Token<TokenType>, Token::Token<TokenType>)
-
- - - -
-Implementation - - -
public fun split<TokenType: store>(
-    token: Token<TokenType>,
-    value: u128,
-): (Token<TokenType>, Token<TokenType>) {
-    let rest = withdraw(&mut token, value);
-    (token, rest)
-}
-
- - - -
- -
-Specification - - - -
aborts_if token.value < value;
-ensures token.value == result_1.value + result_2.value;
-
- - - -
- - - -## Function `withdraw` - -"Divides" the given token into two, where the original token is modified in place. -The original token will have value = original value - 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>
-
- - - -
-Implementation - - -
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 }
-}
-
- - - -
- -
-Specification - - - -
aborts_if token.value < value;
-ensures result.value == value;
-ensures token.value == old(token).value - value;
-
- - - -
- - - -## Function `join` - -Merges two tokens of the same token and returns a new token whose -value is equal to the sum of the two inputs - - -
public fun join<TokenType: store>(token1: Token::Token<TokenType>, token2: Token::Token<TokenType>): Token::Token<TokenType>
-
- - - -
-Implementation - - -
public fun join<TokenType: store>(
-    token1: Token<TokenType>,
-    token2: Token<TokenType>,
-): Token<TokenType> {
-    deposit(&mut token1, token2);
-    token1
-}
-
- - - -
- -
-Specification - - - -
aborts_if token1.value + token2.value > max_u128();
-ensures token1.value + token2.value == result.value;
-
- - - -
- - - -## Function `deposit` - -"Merges" the two tokens -The token passed in by reference will have a value equal to the sum of the two tokens -The check token is consumed in the process - - -
public fun deposit<TokenType: store>(token: &mut Token::Token<TokenType>, check: Token::Token<TokenType>)
-
- - - -
-Implementation - - -
public fun deposit<TokenType: store>(token: &mut Token<TokenType>, check: Token<TokenType>) {
-    let Token { value } = check;
-    token.value = token.value + value;
-}
-
- - - -
- -
-Specification - - - -
aborts_if token.value + check.value > max_u128();
-ensures old(token).value + check.value == token.value;
-
- - - -
- - - -## Function `destroy_zero` - -Destroy a token -Fails if the value is non-zero -The amount of Token in the system is a tightly controlled property, -so you cannot "burn" any non-zero amount of Token - - -
public fun destroy_zero<TokenType: store>(token: Token::Token<TokenType>)
-
- - - -
-Implementation - - -
public fun destroy_zero<TokenType: store>(token: Token<TokenType>) {
-    let Token { value } = token;
-    assert!(value == 0, Errors::invalid_state(EDESTROY_TOKEN_NON_ZERO))
-}
-
- - - -
- -
-Specification - - - -
aborts_if token.value > 0;
-
- - - -
- - - -## Function `scaling_factor` - -Returns the scaling_factor for the TokenType token. - - -
public fun scaling_factor<TokenType: store>(): u128
-
- - - -
-Implementation - - -
public fun scaling_factor<TokenType: store>(): u128 acquires TokenInfo {
-    let token_address = token_address<TokenType>();
-    borrow_global<TokenInfo<TokenType>>(token_address).scaling_factor
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == global<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS()).scaling_factor;
-
- - - -
- - - -## Function `market_cap` - -Return the total amount of token of type TokenType. - - -
public fun market_cap<TokenType: store>(): u128
-
- - - -
-Implementation - - -
public fun market_cap<TokenType: store>(): u128 acquires TokenInfo {
-    let token_address = token_address<TokenType>();
-    borrow_global<TokenInfo<TokenType>>(token_address).total_value
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == global<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS()).total_value;
-
- - - -
- - - -## Function `is_registered_in` - -Return true if the type TokenType is a registered in token_address. - - -
public fun is_registered_in<TokenType: store>(token_address: address): bool
-
- - - -
-Implementation - - -
public fun is_registered_in<TokenType: store>(token_address: address): bool {
-    exists<TokenInfo<TokenType>>(token_address)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == exists<TokenInfo<TokenType>>(token_address);
-
- - - -
- - - -## Function `is_same_token` - -Return true if the type TokenType1 is same with TokenType2 - - -
public fun is_same_token<TokenType1: store, TokenType2: store>(): bool
-
- - - -
-Implementation - - -
public fun is_same_token<TokenType1: store, TokenType2: store>(): bool {
-    return token_code<TokenType1>() == token_code<TokenType2>()
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `token_address` - -Return the TokenType's address - - -
public fun token_address<TokenType: store>(): address
-
- - - -
-Implementation - - -
public fun token_address<TokenType: store>(): address {
-    let (addr, _, _) = name_of<TokenType>();
-    addr
-}
-
- - - -
- -
-Specification - - - -
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` - -Return the token code for the registered token. - - -
public fun token_code<TokenType: store>(): Token::TokenCode
-
- - - -
-Implementation - - -
public fun token_code<TokenType: store>(): TokenCode {
-    let (addr, module_name, name) = name_of<TokenType>();
-    TokenCode {
-        addr,
-        module_name,
-        name
-    }
-}
-
- - - -
- -
-Specification - - - -
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 `type_of` - - - -
public(friend) fun type_of<T>(): (address, vector<u8>, vector<u8>)
-
- - - -
-Implementation - - -
public (friend) fun type_of<T>(): (address, vector<u8>, vector<u8>){
-    name_of<T>()
-}
-
- - - -
- - - -## Function `name_of` - -Return Token's module address, module name, and type name of TokenType. - - -
fun name_of<TokenType>(): (address, vector<u8>, vector<u8>)
-
- - - -
-Implementation - - -
native fun name_of<TokenType>(): (address, vector<u8>, vector<u8>);
-
- - - -
- -
-Specification - - - -
pragma opaque = true;
-aborts_if false;
-
- - - -
- - - -## Function `name_of_token` - - - -
fun name_of_token<TokenType: store>(): (address, vector<u8>, vector<u8>)
-
- - - -
-Implementation - - -
fun name_of_token<TokenType: store>(): (address, vector<u8>, vector<u8>) {
-    name_of<TokenType>()
-}
-
- - - -
- -
-Specification - - - -
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>(): num {
-   global<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS()).total_value
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/TransactionFee.md b/build/StarcoinFramework/docs/TransactionFee.md deleted file mode 100644 index b6dcc89b..00000000 --- a/build/StarcoinFramework/docs/TransactionFee.md +++ /dev/null @@ -1,245 +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) -- [Module Specification](#@Module_Specification_0) - - -
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
-
- - - -
-Fields - - -
-
-fee: Token::Token<TokenType> -
-
- -
-
- - -
- - - -## Function `initialize` - -Called in genesis. Sets up the needed resources to collect transaction fees from the -TransactionFee resource with the TreasuryCompliance account. - - -
public fun initialize(account: &signer)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-aborts_if exists<TransactionFee<STC>>(Signer::address_of(account));
-
- - - -
- - - -## Function `add_txn_fee_token` - -publishing a wrapper of the Preburn<TokenType> resource under fee_account - - -
fun add_txn_fee_token<TokenType: store>(account: &signer)
-
- - - -
-Implementation - - -
fun add_txn_fee_token<TokenType: store>(
-    account: &signer,
-) {
-    move_to(
-        account,
-        TransactionFee<TokenType> {
-            fee: Token::zero(),
-        }
-    )
- }
-
- - - -
- -
-Specification - - - -
aborts_if exists<TransactionFee<TokenType>>(Signer::address_of(account));
-
- - - -
- - - -## Function `pay_fee` - -Deposit token into the transaction fees bucket - - -
public fun pay_fee<TokenType: store>(token: Token::Token<TokenType>)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<TransactionFee<TokenType>>(CoreAddresses::GENESIS_ADDRESS());
-aborts_if global<TransactionFee<TokenType>>(CoreAddresses::GENESIS_ADDRESS()).fee.value + token.value > max_u128();
-
- - - -
- - - -## Function `distribute_transaction_fees` - -Distribute the transaction fees collected in the 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>
-
- - - -
-Implementation - - -
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>()
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/TransactionManager.md b/build/StarcoinFramework/docs/TransactionManager.md deleted file mode 100644 index f463b735..00000000 --- a/build/StarcoinFramework/docs/TransactionManager.md +++ /dev/null @@ -1,426 +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) -- [Module Specification](#@Module_Specification_1) - - -
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;
-
- - - - - -## 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)
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
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` - -The epilogue is invoked at the end of transactions. -It collects gas and bumps the sequence number - - -
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)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-include CoreAddresses::AbortsIfNotGenesisAddress;
-aborts_if Signer::address_of(account) != CoreAddresses::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 `epilogue_v2` - -The epilogue is invoked at the end of transactions. -It collects gas and bumps the sequence number - - -
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)
-
- - - -
-Implementation - - -
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,
-        );
-    }
-}
-
- - - -
- - - -## Function `block_prologue` - -Set the metadata for the current block and distribute transaction fees and block rewards. -The runtime always runs this before executing the transactions in a block. - - -
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)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/TransactionPublishOption.md b/build/StarcoinFramework/docs/TransactionPublishOption.md deleted file mode 100644 index 9507c62a..00000000 --- a/build/StarcoinFramework/docs/TransactionPublishOption.md +++ /dev/null @@ -1,348 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-script_allowed: bool -
-
- -
-
-module_publishing_allowed: bool -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
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,
-    );
-}
-
- - - -
- -
-Specification - - - -
aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-include Config::PublishNewConfigAbortsIf<TransactionPublishOption>;
-include Config::PublishNewConfigEnsures<TransactionPublishOption>;
-
- - - -
- - - -## Function `new_transaction_publish_option` - -Create a new option. Mainly used in DAO. - - -
public fun new_transaction_publish_option(script_allowed: bool, module_publishing_allowed: bool): TransactionPublishOption::TransactionPublishOption
-
- - - -
-Implementation - - -
public fun new_transaction_publish_option(
-    script_allowed: bool,
-    module_publishing_allowed: bool,
-): TransactionPublishOption {
-    TransactionPublishOption { script_allowed, module_publishing_allowed }
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `is_script_allowed` - -Check if sender can execute script with - - -
public fun is_script_allowed(account: address): bool
-
- - - -
-Implementation - - -
public fun is_script_allowed(account: address): bool {
-    let publish_option = Config::get_by_address<TransactionPublishOption>(account);
-    publish_option.script_allowed
-}
-
- - - -
- -
-Specification - - - -
include Config::AbortsIfConfigNotExist<TransactionPublishOption>{
-    addr: account
-};
-
- - - -
- - - -## Function `is_module_allowed` - -Check if a sender can publish a module - - -
public fun is_module_allowed(account: address): bool
-
- - - -
-Implementation - - -
public fun is_module_allowed(account: address): bool {
-    let publish_option = Config::get_by_address<TransactionPublishOption>(account);
-    publish_option.module_publishing_allowed
-}
-
- - - -
- -
-Specification - - - -
include Config::AbortsIfConfigNotExist<TransactionPublishOption>{
-    addr: account
-};
-
- - - - - - - -
schema AbortsIfTxnPublishOptionNotExist {
-    include Config::AbortsIfConfigNotExist<TransactionPublishOption>{
-        addr: CoreAddresses::GENESIS_ADDRESS()
-    };
-}
-
- - - - - - - -
schema AbortsIfTxnPublishOptionNotExistWithBool {
-    is_script_or_package : bool;
-    aborts_if is_script_or_package && !exists<Config::Config<TransactionPublishOption>>(CoreAddresses::GENESIS_ADDRESS());
-}
-
- - - -
- - - -## Module Specification - - - -
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
-}
-
diff --git a/build/StarcoinFramework/docs/TransactionTimeout.md b/build/StarcoinFramework/docs/TransactionTimeout.md deleted file mode 100644 index 9e5baaf1..00000000 --- a/build/StarcoinFramework/docs/TransactionTimeout.md +++ /dev/null @@ -1,108 +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) -- [Module Specification](#@Module_Specification_0) - - -
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
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
-aborts_if !exists<Block::BlockMetadata>(CoreAddresses::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::GENESIS_ADDRESS());
-
- - - - - - - -
schema AbortsIfTimestampNotValid {
-    aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
-    aborts_if !exists<Block::BlockMetadata>(CoreAddresses::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::GENESIS_ADDRESS());
-}
-
- - - -
- - - -## Module Specification - - - -
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())
- }
-}
-
diff --git a/build/StarcoinFramework/docs/TransactionTimeoutConfig.md b/build/StarcoinFramework/docs/TransactionTimeoutConfig.md deleted file mode 100644 index e0488861..00000000 --- a/build/StarcoinFramework/docs/TransactionTimeoutConfig.md +++ /dev/null @@ -1,235 +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) -- [Module Specification](#@Module_Specification_0) - - -
use 0x1::Config;
-use 0x1::CoreAddresses;
-use 0x1::Timestamp;
-
- - - - - -## Struct `TransactionTimeoutConfig` - -config structs. - - -
struct TransactionTimeoutConfig has copy, drop, store
-
- - - -
-Fields - - -
-
-duration_seconds: u64 -
-
- timeout in second. -
-
- - -
- - - -## Function `initialize` - -Initialize function. Should only be called in genesis. - - -
public fun initialize(account: &signer, duration_seconds: u64)
-
- - - -
-Implementation - - -
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)
-    );
-}
-
- - - -
- -
-Specification - - - -
aborts_if !Timestamp::is_genesis();
-aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
-include Config::PublishNewConfigAbortsIf<TransactionTimeoutConfig>;
-include Config::PublishNewConfigEnsures<TransactionTimeoutConfig>;
-
- - - -
- - - -## Function `new_transaction_timeout_config` - -Create a new timeout config used in dao proposal. - - -
public fun new_transaction_timeout_config(duration_seconds: u64): TransactionTimeoutConfig::TransactionTimeoutConfig
-
- - - -
-Implementation - - -
public fun new_transaction_timeout_config(duration_seconds: u64) : TransactionTimeoutConfig {
-    TransactionTimeoutConfig {duration_seconds: duration_seconds}
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `get_transaction_timeout_config` - -Get current timeout config. - - -
public fun get_transaction_timeout_config(): TransactionTimeoutConfig::TransactionTimeoutConfig
-
- - - -
-Implementation - - -
public fun get_transaction_timeout_config(): TransactionTimeoutConfig {
-    Config::get_by_address<TransactionTimeoutConfig>(CoreAddresses::GENESIS_ADDRESS())
-}
-
- - - -
- -
-Specification - - - -
include Config::AbortsIfConfigNotExist<TransactionTimeoutConfig>{
-    addr: CoreAddresses::GENESIS_ADDRESS()
-};
-
- - - -
- - - -## Function `duration_seconds` - -Get current txn timeout in seconds. - - -
public fun duration_seconds(): u64
-
- - - -
-Implementation - - -
public fun duration_seconds() :u64 {
-    let config = get_transaction_timeout_config();
-    config.duration_seconds
-}
-
- - - -
- -
-Specification - - - -
include Config::AbortsIfConfigNotExist<TransactionTimeoutConfig>{
-    addr: CoreAddresses::GENESIS_ADDRESS()
-};
-
- - - - - - - -
schema AbortsIfTxnTimeoutConfigNotExist {
-    include Config::AbortsIfConfigNotExist<TransactionTimeoutConfig>{
-        addr: CoreAddresses::GENESIS_ADDRESS()
-    };
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = true;
-
diff --git a/build/StarcoinFramework/docs/TransferScripts.md b/build/StarcoinFramework/docs/TransferScripts.md deleted file mode 100644 index f9227cb6..00000000 --- a/build/StarcoinFramework/docs/TransferScripts.md +++ /dev/null @@ -1,252 +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;
-
- - - - - -## Constants - - - - - - -
const EDEPRECATED_FUNCTION: u64 = 19;
-
- - - - - - - -
const EADDRESS_AND_AUTH_KEY_MISMATCH: u64 = 101;
-
- - - - - - - -
const ELENGTH_MISMATCH: u64 = 102;
-
- - - - - -## Function `peer_to_peer` - - - -
public entry fun peer_to_peer<TokenType: store>(account: signer, payee: address, _payee_auth_key: vector<u8>, amount: u128)
-
- - - -
-Implementation - - -
public entry 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)
-}
-
- - - -
- - - -## Function `peer_to_peer_v2` - - - -
public entry fun peer_to_peer_v2<TokenType: store>(account: signer, payee: address, amount: u128)
-
- - - -
-Implementation - - -
public entry 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)
-}
-
- - - -
- - - -## Function `batch_peer_to_peer` - -Batch transfer token to others. - - -
public entry fun batch_peer_to_peer<TokenType: store>(account: signer, payeees: vector<address>, _payee_auth_keys: vector<vector<u8>>, amounts: vector<u128>)
-
- - - -
-Implementation - - -
public entry 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)
-}
-
- - - -
- - - -## Function `batch_peer_to_peer_v2` - -Batch transfer token to others. - - -
public entry fun batch_peer_to_peer_v2<TokenType: store>(account: signer, payeees: vector<address>, amounts: vector<u128>)
-
- - - -
-Implementation - - -
public entry 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;
-    }
-}
-
- - - -
- - - -## Function `peer_to_peer_batch` - - - -
public entry fun peer_to_peer_batch<TokenType: store>(_account: signer, _payeees: vector<u8>, _payee_auth_keys: vector<u8>, _amount: u128)
-
- - - -
-Implementation - - -
public entry fun peer_to_peer_batch<TokenType: store>(_account: signer, _payeees: vector<u8>, _payee_auth_keys: vector<u8>, _amount: u128) {
-    abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
- - - -
- - - -## Function `peer_to_peer_with_metadata` - - - -
public entry fun peer_to_peer_with_metadata<TokenType: store>(account: signer, payee: address, _payee_auth_key: vector<u8>, amount: u128, metadata: vector<u8>)
-
- - - -
-Implementation - - -
public entry 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)
-}
-
- - - -
- - - -## Function `peer_to_peer_with_metadata_v2` - - - -
public entry fun peer_to_peer_with_metadata_v2<TokenType: store>(account: signer, payee: address, amount: u128, metadata: vector<u8>)
-
- - - -
-Implementation - - -
public entry 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)
-}
-
- - - -
diff --git a/build/StarcoinFramework/docs/Treasury.md b/build/StarcoinFramework/docs/Treasury.md deleted file mode 100644 index 09400578..00000000 --- a/build/StarcoinFramework/docs/Treasury.md +++ /dev/null @@ -1,1230 +0,0 @@ - - - -# Module `0x1::Treasury` - -The module for the Treasury of DAO, which can hold the token of DAO. - - -- [Resource `Treasury`](#0x1_Treasury_Treasury) -- [Resource `WithdrawCapability`](#0x1_Treasury_WithdrawCapability) -- [Resource `LinearWithdrawCapability`](#0x1_Treasury_LinearWithdrawCapability) -- [Struct `WithdrawEvent`](#0x1_Treasury_WithdrawEvent) -- [Struct `DepositEvent`](#0x1_Treasury_DepositEvent) -- [Constants](#@Constants_0) -- [Function `initialize`](#0x1_Treasury_initialize) -- [Function `exists_at`](#0x1_Treasury_exists_at) -- [Function `balance`](#0x1_Treasury_balance) -- [Function `deposit`](#0x1_Treasury_deposit) -- [Function `do_withdraw`](#0x1_Treasury_do_withdraw) -- [Function `withdraw_with_capability`](#0x1_Treasury_withdraw_with_capability) -- [Function `withdraw`](#0x1_Treasury_withdraw) -- [Function `issue_linear_withdraw_capability`](#0x1_Treasury_issue_linear_withdraw_capability) -- [Function `withdraw_with_linear_capability`](#0x1_Treasury_withdraw_with_linear_capability) -- [Function `withdraw_by_linear`](#0x1_Treasury_withdraw_by_linear) -- [Function `split_linear_withdraw_cap`](#0x1_Treasury_split_linear_withdraw_cap) -- [Function `withdraw_amount_of_linear_cap`](#0x1_Treasury_withdraw_amount_of_linear_cap) -- [Function `is_empty_linear_withdraw_cap`](#0x1_Treasury_is_empty_linear_withdraw_cap) -- [Function `remove_withdraw_capability`](#0x1_Treasury_remove_withdraw_capability) -- [Function `add_withdraw_capability`](#0x1_Treasury_add_withdraw_capability) -- [Function `destroy_withdraw_capability`](#0x1_Treasury_destroy_withdraw_capability) -- [Function `add_linear_withdraw_capability`](#0x1_Treasury_add_linear_withdraw_capability) -- [Function `remove_linear_withdraw_capability`](#0x1_Treasury_remove_linear_withdraw_capability) -- [Function `destroy_linear_withdraw_capability`](#0x1_Treasury_destroy_linear_withdraw_capability) -- [Function `is_empty_linear_withdraw_capability`](#0x1_Treasury_is_empty_linear_withdraw_capability) -- [Function `get_linear_withdraw_capability_total`](#0x1_Treasury_get_linear_withdraw_capability_total) -- [Function `get_linear_withdraw_capability_withdraw`](#0x1_Treasury_get_linear_withdraw_capability_withdraw) -- [Function `get_linear_withdraw_capability_period`](#0x1_Treasury_get_linear_withdraw_capability_period) -- [Function `get_linear_withdraw_capability_start_time`](#0x1_Treasury_get_linear_withdraw_capability_start_time) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-balance: Token::Token<TokenT> -
-
- -
-
-withdraw_events: Event::EventHandle<Treasury::WithdrawEvent> -
-
- event handle for treasury withdraw event -
-
-deposit_events: Event::EventHandle<Treasury::DepositEvent> -
-
- event handle for treasury deposit event -
-
- - -
- -
-Specification - - - -
- - - -## Resource `WithdrawCapability` - -A withdraw capability allows tokens of type TokenT to be withdraw from Treasury. - - -
struct WithdrawCapability<TokenT> has store, key
-
- - - -
-Fields - - -
-
-dummy_field: bool -
-
- -
-
- - -
- - - -## Resource `LinearWithdrawCapability` - -A linear time withdraw capability which can withdraw token from Treasury in a period by time-based linear release. - - -
struct LinearWithdrawCapability<TokenT> has store, key
-
- - - -
-Fields - - -
-
-total: u128 -
-
- The total amount of tokens that can be withdrawn by this capability -
-
-withdraw: u128 -
-
- The amount of tokens that have been withdrawn by this capability -
-
-start_time: u64 -
-
- The time-based linear release start time, timestamp in seconds. -
-
-period: u64 -
-
- The time-based linear release period in seconds -
-
- - -
- - - -## Struct `WithdrawEvent` - -Message for treasury withdraw event. - - -
struct WithdrawEvent has drop, store
-
- - - -
-Fields - - -
-
-amount: u128 -
-
- -
-
- - -
- - - -## Struct `DepositEvent` - -Message for treasury deposit event. - - -
struct DepositEvent has drop, store
-
- - - -
-Fields - - -
-
-amount: u128 -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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>
-
- - - -
-Implementation - - -
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>{}
-}
-
- - - -
- -
-Specification - - - -
aborts_if Signer::address_of(signer) != Token::SPEC_TOKEN_TEST_ADDRESS();
-aborts_if exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-ensures exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-ensures result == WithdrawCapability<TokenT>{};
-
- - - -
- - - -## Function `exists_at` - -Check the Treasury of TokenT is exists. - - -
public fun exists_at<TokenT: store>(): bool
-
- - - -
-Implementation - - -
public fun exists_at<TokenT: store>(): bool {
-    let token_issuer = Token::token_address<TokenT>();
-    exists<Treasury<TokenT>>(token_issuer)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-
- - - -
- - - -## Function `balance` - -Get the balance of TokenT's Treasury -if the Treasury do not exists, return 0. - - -
public fun balance<TokenT: store>(): u128
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures if (exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS()))
-            result == spec_balance<TokenT>()
-        else
-            result == 0;
-
- - - -
- - - -## Function `deposit` - - - -
public fun deposit<TokenT: store>(token: Token::Token<TokenT>)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-aborts_if spec_balance<TokenT>() + token.value > MAX_U128;
-ensures spec_balance<TokenT>() == old(spec_balance<TokenT>()) + token.value;
-
- - - -
- - - -## Function `do_withdraw` - - - -
fun do_withdraw<TokenT: store>(amount: u128): Token::Token<TokenT>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
include WithdrawSchema<TokenT>;
-
- - - - - - - -
schema WithdrawSchema<TokenT> {
-    amount: u64;
-    aborts_if amount <= 0;
-    aborts_if !exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
-    aborts_if spec_balance<TokenT>() < amount;
-    ensures spec_balance<TokenT>() ==
-        old(spec_balance<TokenT>()) - amount;
-}
-
- - - -
- - - -## Function `withdraw_with_capability` - -Withdraw tokens with given LinearWithdrawCapability. - - -
public fun withdraw_with_capability<TokenT: store>(_cap: &mut Treasury::WithdrawCapability<TokenT>, amount: u128): Token::Token<TokenT>
-
- - - -
-Implementation - - -
public fun withdraw_with_capability<TokenT: store>(
-    _cap: &mut WithdrawCapability<TokenT>,
-    amount: u128,
-): Token<TokenT> acquires Treasury {
-    do_withdraw(amount)
-}
-
- - - -
- -
-Specification - - - -
include WithdrawSchema<TokenT>;
-
- - - -
- - - -## Function `withdraw` - -Withdraw from TokenT's treasury, the signer must have WithdrawCapability - - -
public fun withdraw<TokenT: store>(signer: &signer, amount: u128): Token::Token<TokenT>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
-include WithdrawSchema<TokenT>;
-
- - - -
- - - -## Function `issue_linear_withdraw_capability` - -Issue a LinearWithdrawCapability with given WithdrawCapability. - - -
public fun issue_linear_withdraw_capability<TokenT: store>(_capability: &mut Treasury::WithdrawCapability<TokenT>, amount: u128, period: u64): Treasury::LinearWithdrawCapability<TokenT>
-
- - - -
-Implementation - - -
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,
-    }
-}
-
- - - -
- -
-Specification - - - -
aborts_if period == 0;
-aborts_if amount == 0;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(StarcoinFramework::CoreAddresses::GENESIS_ADDRESS());
-
- - - -
- - - -## Function `withdraw_with_linear_capability` - -Withdraw tokens with given LinearWithdrawCapability. - - -
public fun withdraw_with_linear_capability<TokenT: store>(cap: &mut Treasury::LinearWithdrawCapability<TokenT>): Token::Token<TokenT>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma aborts_if_is_partial;
-
- - - -
- - - -## Function `withdraw_by_linear` - -Withdraw from TokenT's treasury, the signer must have LinearWithdrawCapability - - -
public fun withdraw_by_linear<TokenT: store>(signer: &signer): Token::Token<TokenT>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma aborts_if_is_partial;
-aborts_if !exists<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
-
- - - -
- - - -## Function `split_linear_withdraw_cap` - -Split the given LinearWithdrawCapability. - - -
public fun split_linear_withdraw_cap<TokenT: store>(cap: &mut Treasury::LinearWithdrawCapability<TokenT>, amount: u128): (Token::Token<TokenT>, Treasury::LinearWithdrawCapability<TokenT>)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma aborts_if_is_partial;
-ensures old(cap.total - cap.withdraw) ==
-    result_1.value + (result_2.total - result_2.withdraw) + (cap.total - cap.withdraw);
-
- - - -
- - - -## Function `withdraw_amount_of_linear_cap` - -Returns the amount of the LinearWithdrawCapability can mint now. - - -
public fun withdraw_amount_of_linear_cap<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u128
-
- - - -
-Implementation - - -
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
-    }
-}
-
- - - -
- -
-Specification - - - -
pragma aborts_if_is_partial;
-aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(StarcoinFramework::CoreAddresses::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;
-ensures [abstract] result <= cap.total - cap.withdraw;
-
- - - -
- - - -## Function `is_empty_linear_withdraw_cap` - -Check if the given LinearWithdrawCapability is empty. - - -
public fun is_empty_linear_withdraw_cap<TokenT: store>(key: &Treasury::LinearWithdrawCapability<TokenT>): bool
-
- - - -
-Implementation - - -
public fun is_empty_linear_withdraw_cap<TokenT:store>(key: &LinearWithdrawCapability<TokenT>) : bool {
-    key.total == key.withdraw
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == (key.total == key.withdraw);
-
- - - -
- - - -## Function `remove_withdraw_capability` - -Remove mint capability from signer. - - -
public fun remove_withdraw_capability<TokenT: store>(signer: &signer): Treasury::WithdrawCapability<TokenT>
-
- - - -
-Implementation - - -
public fun remove_withdraw_capability<TokenT: store>(signer: &signer): WithdrawCapability<TokenT>
-acquires WithdrawCapability {
-    move_from<WithdrawCapability<TokenT>>(Signer::address_of(signer))
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
-ensures !exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
-
- - - -
- - - -## Function `add_withdraw_capability` - -Save mint capability to signer. - - -
public fun add_withdraw_capability<TokenT: store>(signer: &signer, cap: Treasury::WithdrawCapability<TokenT>)
-
- - - -
-Implementation - - -
public fun add_withdraw_capability<TokenT: store>(signer: &signer, cap: WithdrawCapability<TokenT>) {
-    move_to(signer, cap)
-}
-
- - - -
- -
-Specification - - - -
aborts_if exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
-ensures exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
-
- - - -
- - - -## Function `destroy_withdraw_capability` - -Destroy the given mint capability. - - -
public fun destroy_withdraw_capability<TokenT: store>(cap: Treasury::WithdrawCapability<TokenT>)
-
- - - -
-Implementation - - -
public fun destroy_withdraw_capability<TokenT: store>(cap: WithdrawCapability<TokenT>) {
-    let WithdrawCapability<TokenT> {} = cap;
-}
-
- - - -
- -
-Specification - - - -
- - - -## Function `add_linear_withdraw_capability` - -Add LinearWithdrawCapability to signer, a address only can have one LinearWithdrawCapability - - -
public fun add_linear_withdraw_capability<TokenT: store>(signer: &signer, cap: Treasury::LinearWithdrawCapability<TokenT>)
-
- - - -
-Implementation - - -
public fun add_linear_withdraw_capability<TokenT: store>(signer: &signer, cap: LinearWithdrawCapability<TokenT>) {
-    move_to(signer, cap)
-}
-
- - - -
- -
-Specification - - - -
aborts_if exists<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
-ensures exists<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
-
- - - -
- - - -## Function `remove_linear_withdraw_capability` - -Remove LinearWithdrawCapability from signer. - - -
public fun remove_linear_withdraw_capability<TokenT: store>(signer: &signer): Treasury::LinearWithdrawCapability<TokenT>
-
- - - -
-Implementation - - -
public fun remove_linear_withdraw_capability<TokenT: store>(signer: &signer): LinearWithdrawCapability<TokenT>
-acquires LinearWithdrawCapability {
-    move_from<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer))
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
-ensures !exists<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
-
- - - -
- - - -## Function `destroy_linear_withdraw_capability` - -Destroy LinearWithdrawCapability. - - -
public fun destroy_linear_withdraw_capability<TokenT: store>(cap: Treasury::LinearWithdrawCapability<TokenT>)
-
- - - -
-Implementation - - -
public fun destroy_linear_withdraw_capability<TokenT: store>(cap: LinearWithdrawCapability<TokenT>) {
-    let LinearWithdrawCapability{ total: _, withdraw: _, start_time: _, period: _ } = cap;
-}
-
- - - -
- - - -## Function `is_empty_linear_withdraw_capability` - - - -
public fun is_empty_linear_withdraw_capability<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): bool
-
- - - -
-Implementation - - -
public fun is_empty_linear_withdraw_capability<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): bool {
-    cap.total == cap.withdraw
-}
-
- - - -
- - - -## Function `get_linear_withdraw_capability_total` - -Get LinearWithdrawCapability total amount - - -
public fun get_linear_withdraw_capability_total<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u128
-
- - - -
-Implementation - - -
public fun get_linear_withdraw_capability_total<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): u128 {
-    cap.total
-}
-
- - - -
- - - -## Function `get_linear_withdraw_capability_withdraw` - -Get LinearWithdrawCapability withdraw amount - - -
public fun get_linear_withdraw_capability_withdraw<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u128
-
- - - -
-Implementation - - -
public fun get_linear_withdraw_capability_withdraw<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): u128 {
-    cap.withdraw
-}
-
- - - -
- - - -## Function `get_linear_withdraw_capability_period` - -Get LinearWithdrawCapability period in seconds - - -
public fun get_linear_withdraw_capability_period<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u64
-
- - - -
-Implementation - - -
public fun get_linear_withdraw_capability_period<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): u64 {
-    cap.period
-}
-
- - - -
- - - -## Function `get_linear_withdraw_capability_start_time` - -Get LinearWithdrawCapability start_time in seconds - - -
public fun get_linear_withdraw_capability_start_time<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u64
-
- - - -
-Implementation - - -
public fun get_linear_withdraw_capability_start_time<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): u64 {
-    cap.start_time
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
- - - - - - - -
fun spec_balance<TokenType>(): num {
-   global<Treasury<TokenType>>(Token::SPEC_TOKEN_TEST_ADDRESS()).balance.value
-}
-
diff --git a/build/StarcoinFramework/docs/TreasuryScripts.md b/build/StarcoinFramework/docs/TreasuryScripts.md deleted file mode 100644 index 68c60d2f..00000000 --- a/build/StarcoinFramework/docs/TreasuryScripts.md +++ /dev/null @@ -1,204 +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) - - -
use 0x1::Account;
-use 0x1::Offer;
-use 0x1::Token;
-use 0x1::Treasury;
-use 0x1::TreasuryWithdrawDaoProposal;
-
- - - - - -## Function `withdraw_and_split_lt_withdraw_cap` - - - -
public entry fun withdraw_and_split_lt_withdraw_cap<TokenT: store>(signer: signer, for_address: address, amount: u128, lock_period: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `withdraw_token_with_linear_withdraw_capability` - - - -
public entry fun withdraw_token_with_linear_withdraw_capability<TokenT: store>(signer: signer)
-
- - - -
-Implementation - - -
public entry 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);
-    };
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `propose_withdraw` - - - -
public entry fun propose_withdraw<TokenT: copy, drop, store>(signer: signer, receiver: address, amount: u128, period: u64, exec_delay: u64)
-
- - - -
-Implementation - - -
public entry 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)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `execute_withdraw_proposal` - - - -
public entry fun execute_withdraw_proposal<TokenT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
public entry 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);
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
diff --git a/build/StarcoinFramework/docs/TreasuryWithdrawDaoProposal.md b/build/StarcoinFramework/docs/TreasuryWithdrawDaoProposal.md deleted file mode 100644 index 0e13d8cc..00000000 --- a/build/StarcoinFramework/docs/TreasuryWithdrawDaoProposal.md +++ /dev/null @@ -1,320 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-cap: Treasury::WithdrawCapability<TokenT> -
-
- -
-
- - -
- - - -## Struct `WithdrawToken` - -WithdrawToken request. - - -
struct WithdrawToken has copy, drop, store
-
- - - -
-Fields - - -
-
-receiver: address -
-
- the receiver of withdraw tokens. -
-
-amount: u128 -
-
- how many tokens to mint. -
-
-period: u64 -
-
- How long in milliseconds does it take for the token to be released -
-
- - -
- - - -## Constants - - - - - - -
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>)
-
- - - -
-Implementation - - -
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 });
-}
-
- - - -
- -
-Specification - - - -
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` - -Entrypoint for the proposal. - - -
public fun propose_withdraw<TokenT: copy, drop, store>(signer: &signer, receiver: address, amount: u128, period: u64, exec_delay: u64)
-
- - - -
-Implementation - - -
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,
-    );
-}
-
- - - -
- -
-Specification - - - -
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::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` - -Once the proposal is agreed, anyone can call the method to make the proposal happen. - - -
public fun execute_withdraw_proposal<TokenT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- -
-Specification - - - -
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());
-
- - - -
- - - -## Function `withdraw_for_block_reward` - -Provider a port for get block reward STC from Treasury, only genesis account can invoke this function. -The TreasuryWithdrawCapability is locked in TreasuryWithdrawDaoProposal, and only can withdraw by DAO proposal. -This approach is not graceful, but restricts the operation to genesis accounts only, so there are no security issues either. - - -
public fun withdraw_for_block_reward<TokenT: store>(signer: &signer, reward: u128): Token::Token<TokenT>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict;
-pragma aborts_if_is_partial;
-
diff --git a/build/StarcoinFramework/docs/TypeInfo.md b/build/StarcoinFramework/docs/TypeInfo.md deleted file mode 100644 index be768667..00000000 --- a/build/StarcoinFramework/docs/TypeInfo.md +++ /dev/null @@ -1,192 +0,0 @@ - - - -# Module `0x1::TypeInfo` - - - -- [Struct `TypeInfo`](#0x1_TypeInfo_TypeInfo) -- [Function `account_address`](#0x1_TypeInfo_account_address) -- [Function `module_name`](#0x1_TypeInfo_module_name) -- [Function `struct_name`](#0x1_TypeInfo_struct_name) -- [Function `type_of`](#0x1_TypeInfo_type_of) -- [Function `size_of_val`](#0x1_TypeInfo_size_of_val) - - -
use 0x1::BCS;
-use 0x1::Token;
-
- - - - - -## Struct `TypeInfo` - - - -
struct TypeInfo has copy, drop, store
-
- - - -
-Fields - - -
-
-account_address: address -
-
- -
-
-module_name: vector<u8> -
-
- -
-
-struct_name: vector<u8> -
-
- -
-
- - -
- - - -## Function `account_address` - - - -
public fun account_address(type_info: &TypeInfo::TypeInfo): address
-
- - - -
-Implementation - - -
public fun account_address(type_info: &TypeInfo): address {
-    type_info.account_address
-}
-
- - - -
- - - -## Function `module_name` - - - -
public fun module_name(type_info: &TypeInfo::TypeInfo): vector<u8>
-
- - - -
-Implementation - - -
public fun module_name(type_info: &TypeInfo): vector<u8> {
-    *&type_info.module_name
-}
-
- - - -
- - - -## Function `struct_name` - - - -
public fun struct_name(type_info: &TypeInfo::TypeInfo): vector<u8>
-
- - - -
-Implementation - - -
public fun struct_name(type_info: &TypeInfo): vector<u8> {
-    *&type_info.struct_name
-}
-
- - - -
- - - -## Function `type_of` - - - -
public fun type_of<T>(): TypeInfo::TypeInfo
-
- - - -
-Implementation - - -
public fun type_of<T>(): TypeInfo {
-    let (account_address, module_name, struct_name) = Token::type_of<T>();
-    TypeInfo {
-        account_address,
-        module_name,
-        struct_name
-    }
-}
-
- - - -
- - - -## Function `size_of_val` - -Return the BCS size, in bytes, of value at val_ref. - -See the [BCS spec](https://github.com/diem/bcs) - -See test_size_of_val() for an analysis of common types and -nesting patterns, as well as test_size_of_val_vectors() for an -analysis of vector size dynamism. - - -
public fun size_of_val<T: store>(val_ref: &T): u64
-
- - - -
-Implementation - - -
public fun size_of_val<T: store>(val_ref: &T): u64 {
-    // Return vector length of vectorized BCS representation.
-    Vector::length(&BCS::to_bytes<T>(val_ref))
-}
-
- - - -
diff --git a/build/StarcoinFramework/docs/U256.md b/build/StarcoinFramework/docs/U256.md deleted file mode 100644 index 7b3f3368..00000000 --- a/build/StarcoinFramework/docs/U256.md +++ /dev/null @@ -1,946 +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 `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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-bits: vector<u64> -
-
- little endian representation -
-
- - -
- -
-Specification - - - -
invariant len(bits) == 4;
-
- - - - - - - -
fun value_of_U256(a: U256): num {
-   a.bits[0] +
-   a.bits[1] * P64 +
-   a.bits[2] * P64 * P64 +
-   a.bits[3] * P64 * P64 * P64
-}
-
- - - -
- - - -## Constants - - - - - - -
const P32: u64 = 4294967296;
-
- - - - - - - -
const P64: u128 = 18446744073709551616;
-
- - - - - - - -
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
-
- - - -
-Implementation - - -
public fun zero(): U256 {
-    from_u128(0u128)
-}
-
- - - -
- - - -## Function `one` - - - -
public fun one(): U256::U256
-
- - - -
-Implementation - - -
public fun one(): U256 {
-    from_u128(1u128)
-}
-
- - - -
- - - -## Function `from_u64` - - - -
public fun from_u64(v: u64): U256::U256
-
- - - -
-Implementation - - -
public fun from_u64(v: u64): U256 {
-    from_u128((v as u128))
-}
-
- - - -
- - - -## Function `from_u128` - - - -
public fun from_u128(v: u128): U256::U256
-
- - - -
-Implementation - - -
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 }
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-pragma opaque;
-ensures value_of_U256(result) == v;
-
- - - -
- - - -## Function `from_big_endian` - - - -
public fun from_big_endian(data: vector<u8>): U256::U256
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `from_little_endian` - - - -
public fun from_little_endian(data: vector<u8>): U256::U256
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-
- - - -
- - - -## Function `to_u128` - - - -
public fun to_u128(v: &U256::U256): u128
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-pragma opaque;
-aborts_if value_of_U256(v) >= P64 * P64;
-ensures value_of_U256(v) == result;
-
- - - -
- - - -## Function `compare` - - - -
public fun compare(a: &U256::U256, b: &U256::U256): u8
-
- - - -
-Implementation - - -
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
-            }
-        }
-    };
-    return EQUAL
-}
-
- - - -
- - - -## Function `add` - - - -
public fun add(a: U256::U256, b: U256::U256): U256::U256
-
- - - -
-Implementation - - -
public fun add(a: U256, b: U256): U256 {
-    native_add(&mut a, &b);
-    a
-}
-
- - - -
- -
-Specification - - - -
aborts_if value_of_U256(a) + value_of_U256(b) >= P64 * P64 * P64 * P64;
-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
-
- - - -
-Implementation - - -
public fun sub(a: U256, b: U256): U256 {
-    native_sub(&mut a, &b);
-    a
-}
-
- - - -
- -
-Specification - - - -
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
-
- - - -
-Implementation - - -
public fun mul(a: U256, b: U256): U256 {
-    native_mul(&mut a, &b);
-    a
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-pragma timeout = 200;
-aborts_if value_of_U256(a) * value_of_U256(b) >= P64 * P64 * P64 * P64;
-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
-
- - - -
-Implementation - - -
public fun div(a: U256, b: U256): U256 {
-    native_div(&mut a, &b);
-    a
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-pragma timeout = 160;
-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
-
- - - -
-Implementation - - -
public fun rem(a: U256, b: U256): U256 {
-    native_rem(&mut a, &b);
-    a
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-pragma timeout = 160;
-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
-
- - - -
-Implementation - - -
public fun pow(a: U256, b: U256): U256 {
-    native_pow(&mut a, &b);
-    a
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-pragma opaque;
-pragma timeout = 600;
-let p = pow_spec(value_of_U256(a), value_of_U256(b));
-aborts_if p >= P64 * P64 * P64 * P64;
-ensures value_of_U256(result) == p;
-
- - - -
- - - -## Function `from_bytes` - - - -
fun from_bytes(data: &vector<u8>, be: bool): U256::U256
-
- - - -
-Implementation - - -
native fun from_bytes(data: &vector<u8>, be: bool): U256;
-
- - - -
- - - -## Function `native_add` - - - -
fun native_add(a: &mut U256::U256, b: &U256::U256)
-
- - - -
-Implementation - - -
native fun native_add(a: &mut U256, b: &U256);
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if value_of_U256(a) + value_of_U256(b) >= P64 * P64 * P64 * P64;
-ensures value_of_U256(a) == value_of_U256(old(a)) + value_of_U256(b);
-
- - - -
- - - -## Function `native_sub` - - - -
fun native_sub(a: &mut U256::U256, b: &U256::U256)
-
- - - -
-Implementation - - -
native fun native_sub(a: &mut U256, b: &U256);
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if value_of_U256(a) - value_of_U256(b) < 0;
-ensures value_of_U256(a) == value_of_U256(old(a)) - value_of_U256(b);
-
- - - -
- - - -## Function `native_mul` - - - -
fun native_mul(a: &mut U256::U256, b: &U256::U256)
-
- - - -
-Implementation - - -
native fun native_mul(a: &mut U256, b: &U256);
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if value_of_U256(a) * value_of_U256(b) >= P64 * P64 * P64 * P64;
-ensures value_of_U256(a) == value_of_U256(old(a)) * value_of_U256(b);
-
- - - -
- - - -## Function `native_div` - - - -
fun native_div(a: &mut U256::U256, b: &U256::U256)
-
- - - -
-Implementation - - -
native fun native_div(a: &mut U256, b: &U256);
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if value_of_U256(b) == 0;
-ensures value_of_U256(a) == value_of_U256(old(a)) / value_of_U256(b);
-
- - - -
- - - -## Function `native_rem` - - - -
fun native_rem(a: &mut U256::U256, b: &U256::U256)
-
- - - -
-Implementation - - -
native fun native_rem(a: &mut U256, b: &U256);
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if value_of_U256(b) == 0;
-ensures value_of_U256(a) == value_of_U256(old(a)) % value_of_U256(b);
-
- - - -
- - - -## Function `native_pow` - - - -
fun native_pow(a: &mut U256::U256, b: &U256::U256)
-
- - - -
-Implementation - - -
native fun native_pow(a: &mut U256, b: &U256);
-
- - - -
- -
-Specification - - - -
pragma opaque;
-aborts_if pow_spec(value_of_U256(a), value_of_U256(b)) >= P64 * P64 * P64 * P64;
-ensures value_of_U256(a) == pow_spec(value_of_U256(old(a)), value_of_U256(b));
-
- - - - - - - -
fun pow_spec(base: num, expon: num): num {
-   // This actually doesn't follow a strict definition as 0^0 is undefined
-   // mathematically. But the U256::pow of Rust is defined to be like this:
-   // Link: https://docs.rs/uint/0.9.3/src/uint/uint.rs.html#1000-1003
-   if (expon > 0) {
-       let x = pow_spec(base, expon / 2);
-       if (expon % 2 == 0) { x * x } else { x * x * base }
-   } else {
-       1
-   }
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = true;
-
diff --git a/build/StarcoinFramework/docs/UpgradeModuleDaoProposal.md b/build/StarcoinFramework/docs/UpgradeModuleDaoProposal.md deleted file mode 100644 index add8f904..00000000 --- a/build/StarcoinFramework/docs/UpgradeModuleDaoProposal.md +++ /dev/null @@ -1,350 +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) -- [Module Specification](#@Module_Specification_1) - - -
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
-
- - - -
-Fields - - -
-
-cap: PackageTxnManager::UpgradePlanCapability -
-
- -
-
- - -
- - - -## Struct `UpgradeModule` - -request of upgrading module contract code. - - -
struct UpgradeModule has copy, drop, store
-
- - - -
-Fields - - -
-
-module_address: address -
-
- -
-
-package_hash: vector<u8> -
-
- -
-
-version: u64 -
-
- -
-
- - -
- - - -## Struct `UpgradeModuleV2` - - - -
struct UpgradeModuleV2 has copy, drop, store
-
- - - -
-Fields - - -
-
-module_address: address -
-
- -
-
-package_hash: vector<u8> -
-
- -
-
-version: u64 -
-
- -
-
-enforced: bool -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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)
-
- - - -
-Implementation - - -
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 })
-}
-
- - - -
- -
-Specification - - - -
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)
-
- - - -
-Implementation - - -
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,
-    );
-}
-
- - - -
- -
-Specification - - - -
pragma aborts_if_is_partial = true;
-include AbortIfUnableUpgrade<TokenT>;
-
- - - -
- - - -## Function `submit_module_upgrade_plan` - -Once the proposal is agreed, anyone can call this method to generate the upgrading plan. - - -
public fun submit_module_upgrade_plan<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
-
- - - -
-Implementation - - -
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,
-    );
-}
-
- - - -
- -
-Specification - - - -
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};
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict;
-pragma aborts_if_is_partial;
-
diff --git a/build/StarcoinFramework/docs/VMConfig.md b/build/StarcoinFramework/docs/VMConfig.md deleted file mode 100644 index 973bf229..00000000 --- a/build/StarcoinFramework/docs/VMConfig.md +++ /dev/null @@ -1,738 +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) -- [Module Specification](#@Module_Specification_0) - - -
use 0x1::ChainId;
-use 0x1::Config;
-use 0x1::CoreAddresses;
-
- - - - - -## 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
-
- - - -
-Fields - - -
-
-gas_schedule: VMConfig::GasSchedule -
-
- -
-
- - -
- - - -## Struct `GasSchedule` - -The gas schedule keeps two separate schedules for the gas: -* The instruction_schedule: This holds the gas for each bytecode instruction. -* The native_schedule: This holds the gas for used (per-byte operated over) for each native -function. -A couple notes: -1. In the case that an instruction is deleted from the bytecode, that part of the cost schedule -still needs to remain the same; once a slot in the table is taken by an instruction, that is its -slot for the rest of time (since that instruction could already exist in a module on-chain). -2. The initialization of the module will publish the instruction table to the genesis -address, and will preload the vector with the gas schedule for instructions. The VM will then -load this into memory at the startup of each block. - - -
struct GasSchedule has copy, drop, store
-
- - - -
-Fields - - -
-
-instruction_schedule: vector<u8> -
-
- -
-
-native_schedule: vector<u8> -
-
- -
-
-gas_constants: VMConfig::GasConstants -
-
- -
-
- - -
- - - -## Struct `GasConstants` - -The gas constants contains all kind of constants used in gas calculation. - - -
struct GasConstants has copy, drop, store
-
- - - -
-Fields - - -
-
-global_memory_per_byte_cost: u64 -
-
- The cost per-byte written to global storage. -
-
-global_memory_per_byte_write_cost: u64 -
-
- The cost per-byte written to storage. -
-
-min_transaction_gas_units: u64 -
-
- We charge one unit of gas per-byte for the first 600 bytes -
-
-large_transaction_cutoff: u64 -
-
- Any transaction over this size will be charged INTRINSIC_GAS_PER_BYTE per byte -
-
-instrinsic_gas_per_byte: u64 -
-
- The units of gas that should be charged per byte for every transaction. -
-
-maximum_number_of_gas_units: u64 -
-
- 1 nanosecond should equal one unit of computational gas. We bound the maximum - computational time of any given transaction at 10 milliseconds. We want this number and - MAX_PRICE_PER_GAS_UNIT to always satisfy the inequality that - MAXIMUM_NUMBER_OF_GAS_UNITS * MAX_PRICE_PER_GAS_UNIT < min(u64::MAX, GasUnits::MAX) -
-
-min_price_per_gas_unit: u64 -
-
- The minimum gas price that a transaction can be submitted with. -
-
-max_price_per_gas_unit: u64 -
-
- The maximum gas unit price that a transaction can be submitted with. -
-
-max_transaction_size_in_bytes: u64 -
-
- The max transaction size in bytes that a transaction can have. -
-
-gas_unit_scaling_factor: u64 -
-
- gas unit scaling factor. -
-
-default_account_size: u64 -
-
- default account size. -
-
- - -
- - - -## Struct `GasCost` - -The 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
-
- - - -
-Fields - - -
-
-instruction_gas: u64 -
-
- -
-
-memory_gas: u64 -
-
- -
-
- - -
- - - -## Function `instruction_schedule` - - - -
public fun instruction_schedule(): vector<VMConfig::GasCost>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `native_schedule` - - - -
public fun native_schedule(): vector<VMConfig::GasCost>
-
- - - -
-Implementation - - -
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::new_table_handle 33
-    Vector::push_back(&mut table, new_gas_cost(4, 1));
-    // Table::add_box 34
-    Vector::push_back(&mut table, new_gas_cost(4, 1));
-    // Table::borrow_box 35
-    Vector::push_back(&mut table, new_gas_cost(10, 1));
-    // Table::remove_box 36
-    Vector::push_back(&mut table, new_gas_cost(8, 1));
-    // Table::contains_box 37
-    Vector::push_back(&mut table, new_gas_cost(40, 1));
-    // Table::destroy_empty_box 38
-    Vector::push_back(&mut table, new_gas_cost(20, 1));
-    // Table::drop_unchecked_box 39
-    Vector::push_back(&mut table, new_gas_cost(73, 1));
-    // string.check_utf8 40
-    Vector::push_back(&mut table, new_gas_cost(4, 1));
-    // string.sub_str 41
-    Vector::push_back(&mut table, new_gas_cost(4, 1));
-    // string.is_char_boundary 42
-    Vector::push_back(&mut table, new_gas_cost(4, 1));
-    // Table::string.index_of 43
-    Vector::push_back(&mut table, new_gas_cost(4, 1));
-    // FromBCS::from_bytes 44
-    Vector::push_back(&mut table, new_gas_cost(4, 1));
-    // Secp256k1::ecdsa_recover_internal 45
-    Vector::push_back(&mut table, new_gas_cost(4, 1));
-    // Vector::spawn_from 46
-    Vector::push_back(&mut table, new_gas_cost(4, 1));
-
-    table
-}
-
- - - -
- - - -## Function `gas_constants` - - - -
public fun gas_constants(): VMConfig::GasConstants
-
- - - -
-Implementation - - -
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,
-    }
-}
-
- - - -
- - - -## Function `new_gas_cost` - - - -
fun new_gas_cost(instr_gas: u64, mem_gas: u64): VMConfig::GasCost
-
- - - -
-Implementation - - -
fun new_gas_cost(instr_gas: u64, mem_gas: u64): GasCost {
-    GasCost {
-        instruction_gas: instr_gas,
-        memory_gas: mem_gas,
-    }
-}
-
- - - -
- - - -## Function `new_vm_config` - -Create a new vm config, mainly used in DAO. - - -
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
-
- - - -
-Implementation - - -
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 },
-    }
-}
-
- - - -
- - - -## Function `initialize` - -Initialize the table under the genesis account - - -
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)
-
- - - -
-Implementation - - -
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,
-        ),
-    );
-}
-
- - - -
- -
-Specification - - - -
aborts_if Signer::address_of(account) != CoreAddresses::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),
-    );
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/Vector.md b/build/StarcoinFramework/docs/Vector.md deleted file mode 100644 index 5ad6187f..00000000 --- a/build/StarcoinFramework/docs/Vector.md +++ /dev/null @@ -1,861 +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 `spawn_from`](#0x1_Vector_spawn_from) -- [Function `spawn_from_vec`](#0x1_Vector_spawn_from_vec) -- [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) -- [Module Specification](#@Module_Specification_1) - - [Helper Functions](#@Helper_Functions_2) - - -
- - - - - -## 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>
-
- - - -
-Implementation - - -
native public fun empty<Element>(): vector<Element>;
-
- - - -
- - - -## Function `length` - -Return the length of the vector. - - -
public fun length<Element>(v: &vector<Element>): u64
-
- - - -
-Implementation - - -
native public fun length<Element>(v: &vector<Element>): u64;
-
- - - -
- - - -## Function `borrow` - -Acquire an immutable reference to the ith element of the vector v. -Aborts if i is out of bounds. - - -
public fun borrow<Element>(v: &vector<Element>, i: u64): &Element
-
- - - -
-Implementation - - -
native public fun borrow<Element>(v: &vector<Element>, i: u64): ∈
-
- - - -
- - - -## Function `push_back` - -Add element e to the end of the vector v. - - -
public fun push_back<Element>(v: &mut vector<Element>, e: Element)
-
- - - -
-Implementation - - -
native public fun push_back<Element>(v: &mut vector<Element>, e: Element);
-
- - - -
- - - -## Function `borrow_mut` - -Return a mutable reference to the ith 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
-
- - - -
-Implementation - - -
native public fun borrow_mut<Element>(v: &mut vector<Element>, i: u64): &mut Element;
-
- - - -
- - - -## Function `pop_back` - -Pop an element from the end of vector v. -Aborts if v is empty. - - -
public fun pop_back<Element>(v: &mut vector<Element>): Element
-
- - - -
-Implementation - - -
native public fun pop_back<Element>(v: &mut vector<Element>): Element;
-
- - - -
- - - -## Function `destroy_empty` - -Destroy the vector v. -Aborts if v is not empty. - - -
public fun destroy_empty<Element>(v: vector<Element>)
-
- - - -
-Implementation - - -
native public fun destroy_empty<Element>(v: vector<Element>);
-
- - - -
- - - -## Function `spawn_from` - -Spawn a sub vector from a vector - - -
fun spawn_from<Element>(v: &vector<Element>, offset: u64, size: u64): vector<Element>
-
- - - -
-Implementation - - -
native fun spawn_from<Element>(v: &vector<Element>, offset: u64, size: u64): vector<Element>;
-
- - - -
- -
-Specification - - - -
pragma opaque;
-ensures [abstract] result == v[offset..offset+size];
-
- - - -
- - - -## Function `spawn_from_vec` - - - -
public fun spawn_from_vec<Element: copy>(v: &vector<Element>, offset: u64, size: u64): vector<Element>
-
- - - -
-Implementation - - -
public fun spawn_from_vec<Element: copy>(v: &vector<Element>, offset: u64, size: u64): vector<Element> {
-    let len = length(v);
-    let end_idx = (offset + size);
-    assert!(end_idx <= len, EINDEX_OUT_OF_BOUNDS);
-    assert!(size > 0, EINDEX_OUT_OF_BOUNDS);
-    if (offset == 0 && end_idx == len) {
-        return *v
-    };
-    spawn_from(v, offset, size)
-}
-
- - - -
- - - -## Function `swap` - -Swaps the elements at the ith and jth indices in the vector v. -Aborts if ior j is out of bounds. - - -
public fun swap<Element>(v: &mut vector<Element>, i: u64, j: u64)
-
- - - -
-Implementation - - -
native public fun swap<Element>(v: &mut vector<Element>, i: u64, j: u64);
-
- - - -
- - - -## Function `singleton` - -Return an vector of size one containing element e. - - -
public fun singleton<Element>(e: Element): vector<Element>
-
- - - -
-Implementation - - -
public fun singleton<Element>(e: Element): vector<Element> {
-    let v = empty();
-    push_back(&mut v, e);
-    v
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-ensures result == vec(e);
-
- - - - - - - -
fun spec_singleton<Element>(e: Element): vector<Element> {
-   vec(e)
-}
-
- - - -
- - - -## Function `reverse` - -Reverses the order of the elements in the vector v in place. - - -
public fun reverse<Element>(v: &mut vector<Element>)
-
- - - -
-Implementation - - -
public fun reverse<Element>(v: &mut vector<Element>) {
-    native_reverse(v)
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `native_reverse` - - - -
fun native_reverse<Element>(this: &mut vector<Element>)
-
- - - -
-Implementation - - -
native fun native_reverse<Element>(this: &mut vector<Element>);
-
- - - -
- - - -## Function `append` - -Pushes all of the elements of the other vector into the lhs vector. - - -
public fun append<Element>(lhs: &mut vector<Element>, other: vector<Element>)
-
- - - -
-Implementation - - -
public fun append<Element>(lhs: &mut vector<Element>, other: vector<Element>) {
-    native_append(lhs, other);
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `native_append` - - - -
fun native_append<Element>(lhs: &mut vector<Element>, other: vector<Element>)
-
- - - -
-Implementation - - -
native fun native_append<Element>(lhs: &mut vector<Element>, other: vector<Element>);
-
- - - -
- - - -## Function `is_empty` - -Return true if the vector v has no elements and false otherwise. - - -
public fun is_empty<Element>(v: &vector<Element>): bool
-
- - - -
-Implementation - - -
public fun is_empty<Element>(v: &vector<Element>): bool {
-    length(v) == 0
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `contains` - -Return true if e is in the vector v. - - -
public fun contains<Element>(v: &vector<Element>, e: &Element): bool
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `index_of` - -Return (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)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `remove` - -Remove the ith 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
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `native_remove` - - - -
fun native_remove<Element>(this: &mut vector<Element>, i: u64): Element
-
- - - -
-Implementation - - -
native fun native_remove<Element>(this: &mut vector<Element>, i: u64): Element;
-
- - - -
- - - -## Function `swap_remove` - -Swap the ith 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
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- -
-Specification - - - -
pragma intrinsic = true;
-
- - - -
- - - -## Function `split` - -Split a vector into sub-vectors of size sub_len, - - -
public fun split<Element: copy, drop, store>(v: &vector<Element>, sub_len: u64): vector<vector<Element>>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- -
-Specification - - - -
pragma verify = false;
-aborts_if sub_len == 0;
-
- - - -
- - - -## Module Specification - - - - - -### Helper Functions - -Check whether a vector contains an element. - - - - - -
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)]
-}
-
diff --git a/build/StarcoinFramework/docs/Version.md b/build/StarcoinFramework/docs/Version.md deleted file mode 100644 index 64012d09..00000000 --- a/build/StarcoinFramework/docs/Version.md +++ /dev/null @@ -1,146 +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) -- [Module Specification](#@Module_Specification_1) - - -
use 0x1::Config;
-
- - - - - -## Struct `Version` - -Version. - - -
struct Version has copy, drop, store
-
- - - -
-Fields - - -
-
-major: u64 -
-
- major number. -
-
- - -
- - - -## Constants - - - - - - -
const EMAJOR_TO_OLD: u64 = 101;
-
- - - - - -## Function `new_version` - -Create a new version. - - -
public fun new_version(major: u64): Version::Version
-
- - - -
-Implementation - - -
public fun new_version(major: u64): Version {
-    Version { major }
-}
-
- - - -
- -
-Specification - - - -
aborts_if false;
-
- - - -
- - - -## Function `get` - -Get version under addr. - - -
public fun get(addr: address): u64
-
- - - -
-Implementation - - -
public fun get(addr: address): u64 {
-    let version = Config::get_by_address<Self::Version>(addr);
-    version.major
-}
-
- - - -
- -
-Specification - - - -
aborts_if !exists<Config::Config<Version>>(addr);
-
- - - -
- - - -## Module Specification - - - -
pragma verify;
-pragma aborts_if_is_strict;
-
diff --git a/build/StarcoinFramework/docs/YieldFarming.md b/build/StarcoinFramework/docs/YieldFarming.md deleted file mode 100644 index e1535fd0..00000000 --- a/build/StarcoinFramework/docs/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) -- [Module Specification](#@Module_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
-
- - - -
-Fields - - -
-
-treasury_token: Token::Token<RewardTokenT> -
-
- -
-
- - -
- - - -## Resource `FarmingAsset` - - - -
struct FarmingAsset<PoolType, AssetT> has store, key
-
- - - -
-Fields - - -
-
-asset_total_weight: u128 -
-
- -
-
-harvest_index: u128 -
-
- -
-
-last_update_timestamp: u64 -
-
- -
-
-release_per_second: u128 -
-
- -
-
-start_time: u64 -
-
- -
-
- - -
- - - -## Resource `ParameterModifyCapability` - -Capability to modify parameter such as period and release amount - - -
struct ParameterModifyCapability<PoolType, AssetT> has store, key
-
- - - -
-Fields - - -
-
-dummy_field: bool -
-
- -
-
- - -
- - - -## Resource `Stake` - -To store user's asset token - - -
struct Stake<PoolType, AssetT> has store, key
-
- - - -
-Fields - - -
-
-asset: AssetT -
-
- -
-
-asset_weight: u128 -
-
- -
-
-last_harvest_index: u128 -
-
- -
-
-gain: u128 -
-
- -
-
- - -
- - - -## Struct `Exp` - - - -
struct Exp has copy, drop, store
-
- - - -
-Fields - - -
-
-mantissa: u128 -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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
-
- - - -
-Implementation - - -
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
-    }
-}
-
- - - -
- - - -## Function `mul_u128` - - - -
fun mul_u128(a: u128, b: u128): u128
-
- - - -
-Implementation - - -
fun mul_u128(a: u128, b: u128): u128 {
-    if (a == 0 || b == 0) {
-        return 0
-    };
-
-    a * b
-}
-
- - - -
- - - -## Function `div_u128` - - - -
fun div_u128(a: u128, b: u128): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `truncate` - - - -
fun truncate(exp: YieldFarming::Exp): u128
-
- - - -
-Implementation - - -
fun truncate(exp: Exp): u128 {
-    return exp.mantissa / EXP_SCALE
-}
-
- - - -
- - - -## Function `initialize` - -Called by token issuer -this will declare a yield farming pool - - -
public fun initialize<PoolType: store, RewardTokenT: store>(_account: &signer, _treasury_token: Token::Token<RewardTokenT>)
-
- - - -
-Implementation - - -
public fun initialize<
-    PoolType: store,
-    RewardTokenT: store>(_account: &signer,
-                         _treasury_token: Token::Token<RewardTokenT>) {
-    abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
- - - -
- - - -## Function `initialize_asset` - - - -
public fun initialize_asset<PoolType: store, AssetT: store>(_account: &signer, _release_per_second: u128, _delay: u64): YieldFarming::ParameterModifyCapability<PoolType, AssetT>
-
- - - -
-Implementation - - -
public fun initialize_asset<PoolType: store, AssetT: store>(
-    _account: &signer,
-    _release_per_second: u128,
-    _delay: u64): ParameterModifyCapability<PoolType, AssetT> {
-    abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
- - - -
- - - -## Function `modify_parameter` - - - -
public fun modify_parameter<PoolType: store, RewardTokenT: store, AssetT: store>(_cap: &YieldFarming::ParameterModifyCapability<PoolType, AssetT>, _broker: address, _release_per_second: u128)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `stake` - -Call by stake user, staking amount of asset in order to get yield farming token - - -
public fun stake<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address, _asset: AssetT, _asset_weight: u128)
-
- - - -
-Implementation - - -
public fun stake<PoolType: store, RewardTokenT: store, AssetT: store>(
-    _account: &signer,
-    _broker: address,
-    _asset: AssetT,
-    _asset_weight: u128) {
-    abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
- - - -
- - - -## Function `unstake` - -Unstake asset from farming pool - - -
public fun unstake<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address): (AssetT, Token::Token<RewardTokenT>)
-
- - - -
-Implementation - - -
public fun unstake<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address)
-: (AssetT, Token::Token<RewardTokenT>) {
-    abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
- - - -
- - - -## Function `harvest` - -Harvest yield farming token from stake - - -
public fun harvest<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address, _amount: u128): Token::Token<RewardTokenT>
-
- - - -
-Implementation - - -
public fun harvest<PoolType: store,
-                   RewardTokenT: store,
-                   AssetT: store>(
-    _account: &signer,
-    _broker: address,
-    _amount: u128): Token::Token<RewardTokenT> {
-    abort Errors::deprecated(EDEPRECATED_FUNCTION)
-}
-
- - - -
- - - -## Function `query_gov_token_amount` - -The user can quering all yield farming amount in any time and scene - - -
public fun query_gov_token_amount<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address): u128
-
- - - -
-Implementation - - -
public fun query_gov_token_amount<PoolType: store,
-                                  RewardTokenT: store,
-                                  AssetT: store>(_account: &signer, _broker: address): u128 {
-    0
-}
-
- - - -
- - - -## Function `query_total_stake` - -Query total stake count from yield farming resource - - -
public fun query_total_stake<PoolType: store, AssetT: store>(_broker: address): u128
-
- - - -
-Implementation - - -
public fun query_total_stake<PoolType: store,
-                             AssetT: store>(_broker: address): u128 {
-    0
-}
-
- - - -
- - - -## Function `query_stake` - -Query stake weight from user staking objects. - - -
public fun query_stake<PoolType: store, AssetT: store>(_account: &signer): u128
-
- - - -
-Implementation - - -
public fun query_stake<PoolType: store,
-                       AssetT: store>(_account: &signer): u128 {
-    0
-}
-
- - - -
- - - -## Function `calculate_harvest_index_with_asset` - -Update farming asset - - -
fun calculate_harvest_index_with_asset<PoolType, AssetT>(_farming_asset: &YieldFarming::FarmingAsset<PoolType, AssetT>, _now_seconds: u64): u128
-
- - - -
-Implementation - - -
fun calculate_harvest_index_with_asset<PoolType, AssetT>(_farming_asset: &FarmingAsset<PoolType, AssetT>, _now_seconds: u64): u128 {
-    0
-}
-
- - - -
- - - -## Function `calculate_harvest_index_weight_zero` - -There is calculating from harvest index and global parameters without asset_total_weight - - -
public fun calculate_harvest_index_weight_zero(_harvest_index: u128, _last_update_timestamp: u64, _now_seconds: u64, _release_per_second: u128): u128
-
- - - -
-Implementation - - -
public fun calculate_harvest_index_weight_zero(_harvest_index: u128,
-                                               _last_update_timestamp: u64,
-                                               _now_seconds: u64,
-                                               _release_per_second: u128): u128 {
-    0
-}
-
- - - -
- - - -## Function `calculate_harvest_index` - -There is calculating from harvest index and global parameters - - -
public fun calculate_harvest_index(_harvest_index: u128, _asset_total_weight: u128, _last_update_timestamp: u64, _now_seconds: u64, _release_per_second: u128): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `calculate_withdraw_amount` - -This function will return a gain index - - -
public fun calculate_withdraw_amount(_harvest_index: u128, _last_harvest_index: u128, _asset_weight: u128): u128
-
- - - -
-Implementation - - -
public fun calculate_withdraw_amount(_harvest_index: u128,
-                                     _last_harvest_index: u128,
-                                     _asset_weight: u128): u128 {
-    0
-}
-
- - - -
- - - -## Function `exists_at` - -Check the Farming of TokenT is exists. - - -
public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool
-
- - - -
-Implementation - - -
public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool {
-    exists<Farming<PoolType, RewardTokenT>>(broker)
-}
-
- - - -
- - - -## Function `exists_asset_at` - -Check the Farming of AsssetT is exists. - - -
public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool
-
- - - -
-Implementation - - -
public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool {
-    exists<FarmingAsset<PoolType, AssetT>>(broker)
-}
-
- - - -
- - - -## Function `exists_stake_at_address` - -Check stake at address exists. - - -
public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool
-
- - - -
-Implementation - - -
public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool {
-    exists<Stake<PoolType, AssetT>>(account)
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-
diff --git a/build/StarcoinFramework/docs/YieldFarmingV2.md b/build/StarcoinFramework/docs/YieldFarmingV2.md deleted file mode 100644 index f6d77651..00000000 --- a/build/StarcoinFramework/docs/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) -- [Module Specification](#@Module_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
-
- - - -
-Fields - - -
-
-mantissa: u128 -
-
- -
-
- - -
- - - -## Resource `Farming` - -The object of yield farming -RewardTokenT meaning token of yield farming - - -
struct Farming<PoolType, RewardTokenT> has store, key
-
- - - -
-Fields - - -
-
-treasury_token: Token::Token<RewardTokenT> -
-
- -
-
- - -
- - - -## Resource `FarmingAsset` - - - -
struct FarmingAsset<PoolType, AssetT> has store, key
-
- - - -
-Fields - - -
-
-asset_total_weight: u128 -
-
- -
-
-harvest_index: u128 -
-
- -
-
-last_update_timestamp: u64 -
-
- -
-
-release_per_second: u128 -
-
- -
-
-start_time: u64 -
-
- -
-
-alive: bool -
-
- -
-
- - -
- - - -## Resource `Stake` - -To store user's asset token - - -
struct Stake<PoolType, AssetT> has store, key
-
- - - -
-Fields - - -
-
-asset: AssetT -
-
- -
-
-asset_weight: u128 -
-
- -
-
-last_harvest_index: u128 -
-
- -
-
-gain: u128 -
-
- -
-
- - -
- - - -## Resource `ParameterModifyCapability` - -Capability to modify parameter such as period and release amount - - -
struct ParameterModifyCapability<PoolType, AssetT> has store, key
-
- - - -
-Fields - - -
-
-dummy_field: bool -
-
- -
-
- - -
- - - -## Resource `HarvestCapability` - -Harvest ability to harvest - - -
struct HarvestCapability<PoolType, AssetT> has store, key
-
- - - -
-Fields - - -
-
-trigger: address -
-
- -
-
- - -
- - - -## Constants - - - - - - -
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
-
- - - -
-Implementation - - -
fun exp_direct(num: u128): Exp {
-    Exp {
-        mantissa: num
-    }
-}
-
- - - -
- - - -## Function `exp_direct_expand` - - - -
fun exp_direct_expand(num: u128): YieldFarmingV2::Exp
-
- - - -
-Implementation - - -
fun exp_direct_expand(num: u128): Exp {
-    Exp {
-        mantissa: mul_u128(num, EXP_SCALE)
-    }
-}
-
- - - -
- - - -## Function `mantissa` - - - -
fun mantissa(a: YieldFarmingV2::Exp): u128
-
- - - -
-Implementation - - -
fun mantissa(a: Exp): u128 {
-    a.mantissa
-}
-
- - - -
- - - -## Function `add_exp` - - - -
fun add_exp(a: YieldFarmingV2::Exp, b: YieldFarmingV2::Exp): YieldFarmingV2::Exp
-
- - - -
-Implementation - - -
fun add_exp(a: Exp, b: Exp): Exp {
-    Exp {
-        mantissa: add_u128(a.mantissa, b.mantissa)
-    }
-}
-
- - - -
- - - -## Function `exp` - - - -
fun exp(num: u128, denom: u128): YieldFarmingV2::Exp
-
- - - -
-Implementation - - -
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
-    }
-}
-
- - - -
- - - -## Function `add_u128` - - - -
fun add_u128(a: u128, b: u128): u128
-
- - - -
-Implementation - - -
fun add_u128(a: u128, b: u128): u128 {
-    a + b
-}
-
- - - -
- - - -## Function `sub_u128` - - - -
fun sub_u128(a: u128, b: u128): u128
-
- - - -
-Implementation - - -
fun sub_u128(a: u128, b: u128): u128 {
-    a - b
-}
-
- - - -
- - - -## Function `mul_u128` - - - -
fun mul_u128(a: u128, b: u128): u128
-
- - - -
-Implementation - - -
fun mul_u128(a: u128, b: u128): u128 {
-    if (a == 0 || b == 0) {
-        return 0
-    };
-    a * b
-}
-
- - - -
- - - -## Function `div_u128` - - - -
fun div_u128(a: u128, b: u128): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `truncate` - - - -
fun truncate(exp: YieldFarmingV2::Exp): u128
-
- - - -
-Implementation - - -
fun truncate(exp: Exp): u128 {
-    return exp.mantissa / EXP_SCALE
-}
-
- - - -
- - - -## Function `initialize` - -Called by token issuer -this will declare a yield farming pool - - -
public fun initialize<PoolType: store, RewardTokenT: store>(signer: &signer, treasury_token: Token::Token<RewardTokenT>)
-
- - - -
-Implementation - - -
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,
-    });
-}
-
- - - -
- - - -## Function `add_asset` - -Add asset pools - - -
public fun add_asset<PoolType: store, AssetT: store>(signer: &signer, release_per_second: u128, delay: u64): YieldFarmingV2::ParameterModifyCapability<PoolType, AssetT>
-
- - - -
-Implementation - - -
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> {}
-}
-
- - - -
- - - -## Function `modify_parameter` - -Remove asset for make this pool to the state of not alive -Please make sure all user unstaking from this pool - - -
public fun modify_parameter<PoolType: store, RewardTokenT: store, AssetT: store>(_cap: &YieldFarmingV2::ParameterModifyCapability<PoolType, AssetT>, broker: address, release_per_second: u128, alive: bool)
-
- - - -
-Implementation - - -
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;
-}
-
- - - -
- - - -## Function `stake` - -Call by stake user, staking amount of asset in order to get yield farming token - - -
public fun stake<PoolType: store, RewardTokenT: store, AssetT: store>(signer: &signer, broker: address, asset: AssetT, asset_weight: u128, _cap: &YieldFarmingV2::ParameterModifyCapability<PoolType, AssetT>)
-
- - - -
-Implementation - - -
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);
-}
-
- - - -
- - - -## Function `stake_for_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>
-
- - - -
-Implementation - - -
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 }
-}
-
- - - -
- - - -## Function `unstake` - -Unstake asset from farming pool - - -
public fun unstake<PoolType: store, RewardTokenT: store, AssetT: store>(signer: &signer, broker: address): (AssetT, Token::Token<RewardTokenT>)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `unstake_with_cap` - - - -
public fun unstake_with_cap<PoolType: store, RewardTokenT: store, AssetT: store>(broker: address, cap: YieldFarmingV2::HarvestCapability<PoolType, AssetT>): (AssetT, Token::Token<RewardTokenT>)
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `harvest` - -Harvest yield farming token from stake - - -
public fun harvest<PoolType: store, RewardTokenT: store, AssetT: store>(signer: &signer, broker: address, amount: u128): Token::Token<RewardTokenT>
-
- - - -
-Implementation - - -
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)
-}
-
- - - -
- - - -## Function `harvest_with_cap` - - - -
public fun harvest_with_cap<PoolType: store, RewardTokenT: store, AssetT: store>(broker: address, amount: u128, _cap: &YieldFarmingV2::HarvestCapability<PoolType, AssetT>): Token::Token<RewardTokenT>
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `query_gov_token_amount` - -The user can quering all yield farming amount in any time and scene - - -
public fun query_gov_token_amount<PoolType: store, RewardTokenT: store, AssetT: store>(account: address, broker: address): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `query_total_stake` - -Query total stake count from yield farming resource - - -
public fun query_total_stake<PoolType: store, AssetT: store>(broker: address): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `query_stake` - -Query stake weight from user staking objects. - - -
public fun query_stake<PoolType: store, AssetT: store>(account: address): u128
-
- - - -
-Implementation - - -
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
-}
-
- - - -
- - - -## Function `query_info` - -Queyry pool info from pool type -return value: (alive, release_per_second, asset_total_weight, harvest_index) - - -
public fun query_info<PoolType: store, AssetT: store>(broker: address): (bool, u128, u128, u128)
-
- - - -
-Implementation - - -
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
-    )
-}
-
- - - -
- - - -## Function `calculate_harvest_index_with_asset` - -Update farming asset - - -
fun calculate_harvest_index_with_asset<PoolType, AssetT>(farming_asset: &YieldFarmingV2::FarmingAsset<PoolType, AssetT>, now_seconds: u64): u128
-
- - - -
-Implementation - - -
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
-        )
-    }
-}
-
- - - -
- - - -## Function `calculate_harvest_index_weight_zero` - -There is calculating from harvest index and global parameters without asset_total_weight - - -
public fun calculate_harvest_index_weight_zero(harvest_index: u128, last_update_timestamp: u64, now_seconds: u64, release_per_second: u128): u128
-
- - - -
-Implementation - - -
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))
-}
-
- - - -
- - - -## Function `calculate_harvest_index` - -There is calculating from harvest index and global parameters - - -
public fun calculate_harvest_index(harvest_index: u128, asset_total_weight: u128, last_update_timestamp: u64, now_seconds: u64, release_per_second: u128): u128
-
- - - -
-Implementation - - -
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))
-}
-
- - - -
- - - -## Function `calculate_withdraw_amount` - -This function will return a gain index - - -
public fun calculate_withdraw_amount(harvest_index: u128, last_harvest_index: u128, asset_weight: u128): u128
-
- - - -
-Implementation - - -
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))
-}
-
- - - -
- - - -## Function `exists_at` - -Check the Farming of TokenT is exists. - - -
public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool
-
- - - -
-Implementation - - -
public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool {
-    exists<Farming<PoolType, RewardTokenT>>(broker)
-}
-
- - - -
- - - -## Function `exists_asset_at` - -Check the Farming of AsssetT is exists. - - -
public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool
-
- - - -
-Implementation - - -
public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool {
-    exists<FarmingAsset<PoolType, AssetT>>(broker)
-}
-
- - - -
- - - -## Function `exists_stake_at_address` - -Check stake at address exists. - - -
public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool
-
- - - -
-Implementation - - -
public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool {
-    exists<Stake<PoolType, AssetT>>(account)
-}
-
- - - -
- - - -## Module Specification - - - -
pragma verify = false;
-
diff --git a/build/StarcoinFramework/source_maps/Account.mvsm b/build/StarcoinFramework/source_maps/Account.mvsm index a732ac0a74ea19688a728d41ac449f7750c65d9d..d79f2407ee4b23d2a2a3f2fd5207f17d338eb58f 100644 GIT binary patch literal 51351 zcmbuIcX(CBx`$U1dgxVxl+dM16KN8X4FpL7DRkIuk_`k%f+V3y2SJL6^kxACR8)$M zjub(PS@6AMm3Rp;AS7eRT$@;lBXP+sSPjx!LHcL?Vl3$INf?gUhQ z8*p}5c)bcc&JYNdHD;G`oavyS%L7=8Axze}kCqQZNa5tH5y8yl@uPz3#@<9fYlcM=xqx5Xk3ii^kFt(4 z5|noa=W8e+%?C?6&IZuWW&xSWBUhtn+=w=C@`fhpKxo!ZlU| z#WH&HnX};*DNaQyi$ZN z54X9_3RtzFn5^>yp7>=mK4k2+Eao_EK|RZvI14Pi^EekFMpv0V+i|9VhiPsq`W#cF zVBq@7sV;jF@=7q%uDr+dh!;%l(%g%65%l_CtWUwB($M=Ir!08rk85_D2%dSkV1ptZ`tWR$lBljll`Y7f4GRtsZp~)aFKKZIc%~1#t%GTN{Rz z3;NcEVl4-~zz?}$TBsdnI8JBqFetj9_b^4Qx~(tfKx2p1s&TvO5(1Qri2XCBK2 zScb%0)CFJ_5(g0Po=@EtA@Kq3C#GWA4TrH#fbIsjeH{{|xytgOL*fTob})5F7_$nd z-m<#asRw#n>Wc!s#dGVlh{y%C9A^!92#JT$H<%)2{DIt@VZqFt^wdC3dRC@?L~y*C z{WeqZ09b{`HN=v&ZN|kHn58iFxVUh`w0Jb*>oEUSqM}2q}#rZu&UHoA9RE@#A*XN z!b)Sc1-4TQ5)9SSLV7?F(41fR5TnvG#*LZheRKJLp5yX{xfE2VX2!FVMmFJD1rTQwN{1`hdl#e!RKk90w0W z-~{?92(ujmA0U4U-iE-pl(+^SA85fA>^H%LpM0Q`5a)t^pgpnXfqtMXu{MH!pig6M z0{uXr#Ci(!Y`PRHw582#`X=TX(6i~gSeHQ0rk`W|6ZCAl3+rdlv#Gh8FtAX^Fy>c- zhrzrCeLYwY=I4-K1aE_RA0|kbEQ07QRB9Df`#cpia{Da5m1m(8v@|}+J3xuSr_2Mkn zyKsGfXSXTb+S+k;LlLtl%uXMgsqdq18{QB=k?deF&F&t~wIXE)h4YFG3uF&d_woey z@hlX--nX`U+&Agp_n|~~@SfZtCux6XZpL7JPldR+3J{*1lj^rTgs;Zm01gv?x}6`m zre8si|BtY)f*$|wz3TDbgsW^1di+OV-359wcY924jdxSuG0>CwQ&`7APv&ml>&g5l z>dVJK(v$gTnE6fk$fxNJXT3G9LVXQEZ;jhw#X)h|dSk43C?U-fSP4*4n!~WhLMds^ z###)er8ypJ36zm$AFQQNR+{^;jzT$UZoxVR<)!IPH5H_Jp8DR0Tcqhu#TBLb8}$`o z0*;WTyAV{8W+m#o)gaBPSPh}FG%I6OF-Ws4*5go3nh96|h?HhF)+DGd&B<6(poTQl zu%<#yX{O#VYe};m<}|1+&Ba(tppG<`W37O?(p-wQ3~rO=gIEipo-|F%E1|wL-^4l( z4Wzjb>wRb_O?P|JNSejjkyM1n()^5;BQTptGZrfuZkJ{YtQ2S}O?UUyOqzqJZv-@# z=6tN>&_bFSSSz5VH2qjB!6N_jb9END8fGV4=5Lur+bvrKO4b8UX~{7Zm}Z(Rr1xHN zc*9Hs@}3uAtp~mLnu)am^xn(8QoZ-uLw!d<@4b#=y$gEpwFT=O=)KoPtZ%_$t8(pj zcJd}KW%rV^2x{@XG?o*hcQ@y%@$L|K0hAgTrS{d|Vg6`ro`ih7w?#5JfgT9PydCu8 zt%TJSEOukbOL&88t5^;6YE>ho$xf)6|mT7ZeL1* z4lFz2H0n8{+jK(HWlU_KJE0O*UC^BnffWb36N+HPgT)>?vIEV7hg{HY=uIKC(CA=l zFnx?Z(#BwSgCaRu{<8i}*3<-oAkKHR#^{7VCS^y}cdl2e3GY z{Lz_#*~L?DmqL$#P}>*sHIVB;{v7kssG7BWm|elDpJyP>1>Mh+u@-{v=S5h{LHBbO z)(WsV#r1E?eg!;?>XGQV5NeyQpNxDTco@_R(N{r8i5ssxZ8s*DDRdQ>+U5LPvK{#& z&=2W%YPw(@63S|Uy0%?JqfSM7Y7LT1&aZjJCi*RcvzzELtkKu z*zSs#BR^sautanG@TX>_$)&U6edNf&=EJ@d)cuaBUoM?junJMD?(9>TMKE<|AHqBi zdg-i9eKDYyPWSHh(z%oR_JdwJH)0(Cy>!mUdKmQ588ORoe4v-k8CVa1UOJPo)_`6* zzu+1-V(O*SSWkk*yu4vD-30cBzJu7uprFYvTYUa|3imvORzUWT&dRy|;V|jMz~JhtU>to4v@PrI>x1RYP6>GztTJK`e+%cl# zX&Lpc1-%s=hcyTEx$;A-0@G}^qFu34KyO8Ju_l7vik8Ki2YM^|4A;37Q*T9$wG1rw zcq<1v&hy}58GZqM4_JSGcNqC~C}8(_?^)Cj!1|DU3Hci^16|HBsR73s4tkF1g4GA~ z9J35-E9g1q4Xl%(=a_G>iVn7!V-z1081z zco=J2(RYINSUZS(3@pdmDb)ACdaPYQz6@4lZIIt_hJqezKCGUg$J!FCEnqR$uug)- zSi>qh$ZD)%RR=xRwozw8Og+}JF&kl8j5VyrKw3*}JL;|EkK%#7f9kMc>Ikd7N^=Ud zH-+e3*+M#EHt2`j2g?uo;TkgsEWS`$H^m~3IF2b_z((gjzrDyT7&MD zYFKSR_ln!T#gM1I_dyT&XRtm1y@lI^Wo$jG!4k<;gYGbkInFQ+tbrXM||1c+lzUT39VXpAjCy+5`HGP@o_6fj%P~ zr@m^K`i#&AvmT~SR}a7%20C5c5i1FFx_SoIdeG_WY^)7n@qz7*s*dv}nExym@N(7o z))90p|4yY%G4)c_7ON9DRpkUxb}orV@UR=MiQdo@vHB5>mYA)LZSx} z_v6hs6-#q8)&rnB&TU^$f)7*QTF{fATc@7d&Qae7pf{`guwDhdS#?`?s>yEp<$fxh z<7p@qMlWrOSPg|rm{q|%33)X+h~rGv(oDh{Z>o)y>W-D1%fNoSdK~+0Q-Y;QR(}QY zXVBODEmo0LHbe588>SwT#i{RB&_gmDs~G5Y*|cuzwD`2YWOZf|upA6EQR^DrW|HiO z=m*`g(O9vdW8Ij8z~XNa8n0m81tu|zuU-={6OC;%%%>sF1bt^yv6h%>Yszt0r#{C{ z;K$Sc_Q|)}fwrSW7bxxhCq4R6ECWJH{;fT$!*0F?Y!iULOOUs`VI89H@XoMALy?%ZpBIf{guX2tj9oS&$6)Ag8oCfD_FmQ{zJLL zSl2-Rpgx>Er5V5qLJeugVhsVkfHcQy1GQwG zP56WbZj)vetbR~Wnp?1TL49e?z}gKBq&bVbIfB_x zn)hIigGSPPjrxv)#X~B8nEe3QZ+n|#w=pG{O68T@i#Q$hx;zYP2IzG;1*;$EbvYT! z*m_;=j`hV6n{DqJ%*R2W+450eIOsFmS?Vi_sdoj#vF-uAE4UMDH0WKy5v(^r?+R97 zy$O0(u%0{m08{S@mSC<1y(=*0ht#Qe1@6<-YrT2qUxLLX6`REp4j$4WiRk^n`sH8- zat`Dl6&N3sUxLlXoDY_-5+6lf4_4>Z!lT$!fezf#SQS7AZbhuBpaVA&t0w5c{frx` zg{jZ0#;Oe#t4tu3#{eE4buRj3$QNdD3|xq~80;SNHq4j7@-ZJneG9DL7=MKPIfN9* z`v_6~u1$+H764$vkn?{Q-e}OnCs@&jNO9FJkH z2g~5tj=C4DgX0b4(_kAMHPYE~f=zJ5?q#m>JAY&$j)s z);}m#ycR_n3vy1afLO)I`oL1W5^EkXeC>WBtPXNRxalu&lWt|KfR`_D$J5|UbCuQf z&9B0H40O!Q###$HX5995%)CZ@?|_b(7qCu(j+y7NjICp46IK!WR*%}RFbkQdAP3WF z%)*#@OYgR>xAYHC-(t{P`V6ckpttnyxYCKf6V!JR^ydE(R(NHbMBh5hqL@0-*BYw_ z=tN%xRwC#`-!QC9(22fLSkpnL?*?HF1)aXzg7p&U^xYz?mqDlRe!?QpW|6)-gZVk= z^j&A_%LJXi+l6%)boy>8)>)_~I4>wMX`W)k$*^;!0Dyyvr$At3c1_N3h-kJ)=K~bqMr~{v%e!S8Zl= zV?}^P_Al)qKaU0;p2lSK*`|o?(^!bS987n}K7J4J0_dl)8|xzIr(vv5!6L``#RL|v zdr_@krxwO6YHXV~@EM4sK;M}$r-B|miCC$iN6!kZ-Jtgad$IO|-Ve;fIsg_K;ZORr zHwC+X{R1;(fMvf9MH~*gUyV5dbia1P8UVUqmtk!O-LE^b_JHo!Iaqta;wS0aPT~j$ z_J0%C6MF#I{!QFa+)UE~ogt(5AmTC5&*B8uJD{WYajcV|pPI2wfyEE>eUDaZvX_1< zja?CJ`>h6UJ=20szfDA(3A*2AVLbr4-~3n$K=+%m9t4Y@D;${3{dKLTTR0o}0? zSoJ|qBkq;zX=E++Z3jJ#EW+9WI>oUEYai$o$4;!>pi>-kv3>=8Tsw#LGw9>meym?W zAJ^R0^>M99E?Za7$F(r52+-eU7_%Yh-xB6tj=KZOQGS5xKObC+^rI7RiiVa z@U?_b?^65Lx|5#B9)aXUrL<+UBy- zW)Co5fc+XBi`^Xx1TzDJN6KlgA8G(Xtv+>Kh`Gd6o|=_8Bz>s*^zJ*n8zVo1G+gGp-gPv`7W360ZGuwWRSshc)p_Q>BLC>LAsWTi? zC*0hpq!Vr(sIL>~gj*A=mY`>FW3~f5gB#Pdu4iy#bp}0yXJF-kp225f%?CY$kHLBX z^b8)v8VPy^H{)m(Sp3@Zu=&g`U_WKd#GVJ1Q^r!%)usWP-RXJ6i=e~$64qCs!}>7R z*Pz4NSl@ufPfu@;B(A~klz9a6n6YhEhVK!70^JA3ylSewL(Z4^o+AYbPX1y!<1+n2 z1KIvjqto@iwl-y&K`B!zBQP$nWG??in0$90MX5w6W7^6q!Dc!mz&|gRDOZ93<#M2~ z`KL~-u5&u}JSg>734eBKV5CJ`t10yidOJW-Epx-jNb?SFV1(}g<1^w>Gt+Se(LpE@YyC71Ub!oW`RF`HutVF0G z%{o{~;Ixuz=?7^VJiLRbf!@Fru{!azz`WDgmLDOU$NdBd1bOib@s^mnrJ0L$FX)*% z2g}%crXGd0dZEosy$|ys=$ZN{tV5t@>h)L;(Yl_0GqI+Fo_~8|%>X_BCf+dh{QCpf z`7`MG_fxE2K+nJK7}4`@Ev~Zx==rw@RzuM9uX*Ncz`0WnyDHC+hXxPPRUf@M6tI26 z*9kceikSVV-M?u#2z@w|xn9K6zqvPwatp!Rruk7yJOkc0&ATXd0&Zs0{2t}L0W+fI zvugb;f6oPaGKt2D13j4}U=0R6nWSN5gWmS#Voe722_EqjBfA{P}R`u!Oa9zJIZy3swNo! z_n+8u*bAm-1cu5)q@Ow_gSWt3LW#BDJutUWYCqgeV7^7U3t$zPZMQj2H0Z$Wfz=Om zV5VbD1Ra=jv7Q1Qm@i`;0v(udV_g6pnBQULd)_86^J5hN9he1;1v)Ux(t2S`r;QBE zUE9g$fQP_5j(!pf+Xm((FCd`1h>Q z^&k7RNj%-R({Ub!TmM59R{5vLs9-nTT=r_hKE4qEr;FakB-2Vi(6ePDtp1>9%S%{4 zfSxTwc9CrWJzG}8Y6g0?jKb;)dbaG1l@59v^9pw}98=Gh?vvBAr8`jc>1houZvcII znuE0w^yz66))COBrzf$V27P+U!794j=1lYzW(cOvNu9zB#nd?|w{@M9sziN_K#!2Gq-j9-SuwjI}Fw2reiJEHi(p_yAD*BW_cEw+n|Ot8(=krn$oO?RUc|e z^C#{m470YCSq8I?m1(ZCt~6(3Eroj0G|TZasBdMOg}Z??pTRl-4W+pn%hcIOnyavk z-B_CL219>Rau4;jW;Jdh>nwrQ2wFAWbvk#(~pTszX-uSM=cFWSxyZ5v+5_3y_zBhm-Y_ z=-c3CPS&qd?kxPbC+p9sqre)kC+k}&aT|C)S+}B8ESTJhd~WLyp8|aldl_p#=!4js zSf7ACh+V-d@vzN7tTI+T&gFc82!5RwsAU1(J8jb1b73KR!>GsDw zg-j@VI25u?MpZ_x2_8b`4)iFvnUG1Q+)(&$LuL$hECp}Ls7;jE4&FoN2&K+~eM0Fo z>?@`%&)+RMYbga`70hQ@|DLX~_{J!41Nj4}_dcy?lyU1u{}e2-ZgQ_mLfVwS8`m|XAt0L%4_LsCi8dE1ux?l|foj7TXH57E>#BE(CPNq`da?pvBRamP* zCr(yitpuGonTS>AX`95!tC(j&Cr%DweGEErauMq?=)}nmVkSz{Z9PevQ>kw*Bug^`YaXOXa|hPj&{LW(VQq(A(p-sE>?vN_O7m;X zaLoSFJc(HpbAUA6)(1+n8uc{;zcj028GDd4D`8b8Is(!hfjJKbOLHLBd`Ok%Zmf48 zO`1Efc0o{@k6;z&j?$(14Q5fy;nF;XSqyW8G~L!mN^=$UJqsDq+={giGOf%vF-J-B zIjk*kk2Duy72Cuo+0y(HGaPe_H2;BF6mzUJ-PXrRvnus9h4IpCi4_AAtjuK0iPCI_ z)dD6-vjWy4m?F(Atc5UDnmw@|f@#upTc0jXbB&9^;;qo@UHRn^@Q@%sjs78o+GhJc zNB$Npe`)k8DvK`v<i)_AaZsa9b*V;mf--)Cxu z+0xituDssCh(XYO5Wvbc)pn4TPK;$-f`@^z2z@n#791QH8OThPU)?@|ya_A^#$nVG zU^OuEF^a-LcgmksSqf7Rj51giK@W^?sWSr8VuSx>B26cG>gX`^qG0t?HdPQK!LpNE zp|%IBPTq$2BIr(j8EX&dPTq%g0CXo$!#W5SXQTEh>}kNmXih`VfUvOCz$leho`N_X zEIWB6>Z4%&W6B$mH$#YRXk9}N>q*}f)$>OKyvCrPqA~9R{cH+gRREppcCS>wLc53h zazMXAGv-XtsqR@=^FgP&7ho*|o$Bt2wH$P+`vBHa(5dbdSZ{;=LUAqDJ7AFq@WpX* z0uNEqA3X@x|1d))axPd###Gcz9?ke5NImwy-d6AF9{?wcmd^{Qe#`3NBKEZ5I4 zydt23>IxSUj;W_c_p){Pb*H|5pu?{oRvXaa=ia>zzaOaY576(VPGS8CI#5qy8CwVH z39P6Dn^38Mbr4Cq z74&Dn4Y1O{DPJ%ys<%I-W%F`Q@u--XL|;;pznd?qo`TP136AJMEW8;%jI(3STj`hVS`#VN;i;9o-6>=hc9iw9W$%#?%Nl|$< z`#br3*Xzyi+-llLitQZlOY}!|OY}v>^r7Z%zRu=aN;{Q(aZ%kmB_zgiVdi?NIF`%g z^30VNajH<@`prefUpLJE_s7L1#YH7YcL_u2o|w=rp>vAQA05S2b&u-f?;MrnUVTxg z+FvzvPwCh#Haf3-Y&DxsW&ZZRdD>i=phHoj+6w^(lc#$~yWwAkOJ|J1vs zoLbx^&m}tV+2-AsTY!)6urIR6Aj-ZgiXxy0 zvMLCUEKyVhAGiRDIy#Em2!kUk-~#Vcfp$Fe&U@dwKF<04!}-*&x~r?Ie^uSL^L2*< zjRVuCZ>v_L@i|XgOy}5RkwxV@^gLhkaP7A%R~q%kNXKzIZj=0B2>(0u=a!U?kwpzDWJSM5suRyl=leEW(%)U zDb55`ys0>gEWB2w9j7~l%7}559A^;d>yn9;1z|Gg3Tj>pA*EAuM+b6JC*=jyiETvR zW{N1W2Gar%OeITUL&l#(%b(>ITpo*b&q{Zp)q zpuAAdr970DW>H1Qc?b0Qe1i2kM9P>KsM#@nLyn1BSk0k~jQKOYvb5E4x@K7!^R-CF zc^~v~UcmYl%E_3|bHxvv{vpS1*>a9k8Pv5*#~E(n?ZVj)9vyPnUmRx)1ToEJqmMU5 zBK$Y*oa(S=AkPIe?aFgJig?mQm*y6%w?W?@jP(v!1igqBG7s#h{ZRBWrig8O+=5&S ztlDD;Vy1~M+oKoOaM0~xtN>W3k;@#XHaH@F_P<3$@j3G9?J2Q*=PT(-g64w!WBm89S^|gEp#-Cm@!cLlcuhD0e09 zBPOskr(n$l-NbJFx`{s^-p8QxoV{4Dg3dO!V0{Amp6?!~zU%%*yii(H-y_|a7N^u` zmgC$3L3Eln=v_^bhz$Q2e@>>%IHQsKfz?bhA90C^F8jiRSgSzyg|S$x!Q#UCAL6zF zmP29!>J+dV65A0wKTK?kA#n`%gb6I0VK>%3(9Pi1uZP5S;)QXfdPsbVc>(m0FlHHI z>Xg+zPTkR)5wA7q6wi%mF(R`XInD$KVn|FxpJ|Fz@%al2Mg?*TvNHVzS-CmB(Sb>7 z_M1<^$G~cMoI(87)Fk`Gt61kj_lpBJO^ZvD+Qe~kA&9ogL!V@dlp8TFkUz?2ZqR}J zeAOzmD6+^DE0YtL;Iqu(_EF$fa4eRNr|>>A708x+9qV(@E$P;;N7&EA3vX&O!b)LP z1wFzp5VIPlzUic3jRrjyld+7gZ%+wWPlFz{i?ALAJ!&Uotp&Z@I*#=|=ta~{tPemh zjf`~`EKa^kTgT}DL5z!z=slr?Z9*Q4oCv{SyQQDh~Uo+^h_nRcutK@YxLu#?dkR1KzHUISp7hE=6I}h(4E=A z8UngA8*3<7+#g$aavU!>A>sLfoZ$hvN74s59!i(HnXvgXCKUu^+IFN1n^+K%rS2EI zuy(_Z{LU^Ze5fn;7>G1EVSd)g9DN?4-AD=`GCvR)Zg&pPcXpfuP`bFtD1ZJabuQC6 zkH0|q8*OWw<8G#X_dPv&nC z`(4oee?QiHp!>gjuDbt6a+K9U_x~TLxdx`5%-t5#lle;GZ2&!)&&JvadNOz0UQgyH zi1#F_c!D2>$=DoFDiYHx;FQJTH620$fg z`mwU1vNTh$a-fPd+hOIxEz(?r^%UGH&G}dxpsF<8sivAV_YiL{RF|eZ71xmFDdL@j zn$mP{1hu63Bk_KM+S0s=6~XjhN1B&0ufT26{3q5lVn#``8CEx_C(Zs?cSC(?4#FA? z4WxM|Rys74W{;a@BWYH{90HA{nT?eLO{6&%YaBF{W-eA9G?Qi))_u@inx^J_Xd%tb zSbLzQG}mD5g;vsZ)05WH{F-=|;C5*q#`*#7kY)q2oYv4rnia5ahqlsmv!`~_>`FW@ zw3p@xtg+BRntidxK}TtJ!O91V{hxR0lK=smwSU-Iv`yK*r)0?n6b@!vasUN}0;z&L zlcsplrUGeZW8Dur_wr%Q1f6@iN2+tL)x_HXI``Uy^*rd@>mjTcK<8cuvEBrWROL(? zZdqXYMCS|CZ;Va>o!z_;ho zm=@WXXE_hE!Lr#hQAZk`v|XOsLBv-;pV~86FM#gjPh))qx)D}keGC?f=EfC{Qv{Zc z@CxedMz?8%x+}TugKmUUShs?1gb1vzpc~;bhuIC&B8R@#lTqG_1GRtIBpkg0gq9i? z$P8qS*Gt-Z*v%laAlElMke8dEB{!VAqxS);*4~470CZ~~!g>>QYahot0lKwUV4Vbu zb;!4U9p^U)qP4G~N5pc(wh!bhB3FZw1?HtuHEXrS>;zWroQF68bUTm6ng+U^XJE|% z-OfX?9sr9~T$k>S6AMAKa~ygygxYS`4?)g=AUbt6`UD86aPyI;ZDR5Uh0cI^BUW9} z3wS@6N~C!f>qpQR$*o^sq^KTbpP+M$5?FVD&N0GFJkUADbmj-gs}e`5hv;vZB{B67J&hTTsfTDUtXR-Pv>{d;=pkB& zbwB7KItpth=ppJ}PrU`ZhXlY2E7IAU{x~6 z{@Dhr8|W?A&p6KRn0gC#8P=nqw_qQ`dKUB+>{hJjL2tokW4!=+3)WbBKySf*jrBd~ zE!g+4E`i>HHP`$)Se*QkDJ+t~ZXNpt=GVryS?6@0%6l%LXR-=dT|m!dov=ECp2nb zBIsLZ70#y(=v$|I_WIWOH1W29zI86g+79~GISFe%=v!yRT=tYf-#YWKCWF3p_QHA) z^sVzW$G99*-#U%80xag`Wz%UUuwV4;z}^cHW_Q`*_1_}gqYzpR**7k?;Kqx?Y$y6N zvc_Z;$oGdsXK>qqGB;j`C|)qC3^wY1o{<2z202Q)6FVC8c&d#R1A08U$E?TGMB*(5 zJ)V|gJq~(2C19-sJ)VwYeF}O!ZN~aL=A;e+Z_d%Q+^=&l7Xdb4&-U zKA`8A*;tQ*o?~9ZIt+S_`4HMC-~L1|kjveR2C>#e=@M#`J^58%m2Nkbi^yYG^z59te8F{}&2HPNXV}-#SI% zH38i!<*=H9ZWXtFi!M*RH$iv#HCV?$clp&=#@1baF;<01HXZqM%yO7IF?$QMJf=>} z+}d?w)|+?(KqqERusVZI%*J3X2A!A<#aaRu@7CQlh+ho-FxC-@;cDnI~{8d=(=&tD2uDjwz;{6D^E542O6X-R<9qDW>gI*(4#%ch1jW8YSSev43hH7eLWDeI2e)7UoMJO^IQY1$hTJ zp~1YhU7ZpQpmOk^^yo;jSO}^3pRbs!wD%KAT?BrYAWv%=-eOaWG;^?)fbIn=uvUQ{ zUQ4l-gP!q6V7(1`cHV_`0`v-O4c1A}X|G$mPJ2tz<`qGwz28%FB}|?6y4O>uz3qwD z6Li{J3#%9Cv^N>+9?)s;1gr-^r@ducu@M3~?LA4nmY8~LdV;zU4(rkVQudqNfXN6hBZdofQ~!0Woz};9gCAuQ%6xHCRki9dr3WCTc8mvjB8Aa?f7R|67T-6ZHIl z5bFr&`Tt$44?)lW)3Lq;J^vf)E3inaJfnCw1%enDgV6n8{cXQ|Et-y>c%vR<%!T@$UA2^((riLeml2>8=);I^vGd#@188@MS{c&|CiD1Gt; zc#}bo89&w(&|}7}Uyqsf#Cs0(m|2Lm4fL2cflzs=+=b%%1 zw|1SD_*%H~Kaa?*QoJ{}9#}pf~!aVtomEqwkhFY!86m==*_q zEiv^*UvI2f&>MaIu!e%(zUzwR0lj@UA8Rq_?Yl8pOF(bmoxnN^di!oCRuSm!yLz|L zN}#vzR$x5=diyRNYZpYxN%}g`}pQF z1d+m>MgQCsvHe-odE`rAwbJahpTEikdPZ-B6$^SsFT|P-dPX0JH4gNQz8>p!&@;NR z-T;f;zsj^y3)8gr9~5bc-oX^Hy&88Sd%-k^>`4zIE-}%ic^}qN&{xA)%fMof^Ymn1 zGyuEDsXt*}HMY$Y`1C0}00Mnx#>@uYdwOCef$lvIU~LB7d$wS01Dy{{#M%xPJHjW1 zI?g}9u3f*y{HL*P+BNkaRtKQl)tDnew`&)yexTcRHr7Va?fNvcn1J;q=;hk$Sm!`5 z*S2AO0eZRS)~=Upbqe{j5}=oB-%)b}re3ZYvnHlqt{KzRu9s`ZY7Z7)3ca#~16_)0 z`R*fXS) zn0Y2_dl@up0rLge-)lNz_ki#~jz43JoaSOt6Cl*;Ro7{lGfnW!+?)|vBh_1Qe?vV7 zbWwSxtMDEN-F$Pf)`9LE?&0d$_6YHgf}U-k!`cmcw%v?1ccIN}dls_-rk+D1vC4y< zL%$;C70?@Q?p4woZmp=f9q0|WI#>-r&)~*v4tfSRrm0=e;KphXdInF&@`Iki^RXs@ zp20J*CWD^Ald%Sap21B&`U_ZmZ8_~>W*4xZGR9(01j{L77V11xflXF_6!C4)!}?vU z4?qv=-B@Qq4{Kw62o|57URKX>o&>v9=6cMH#7+lnL8O&X?Ee4HXs< z)PDD+B6dukJ;GRmXBYK;+_CTojmwycr#6GX=Y%J0^KY8SjN`9;vTGdi)|+R zt(ZGNPxdRZc7jf=mtsw)c0Jh-!O8_a*?Y0_Ku`8PZ<>0t|CHlA2YRx92kQ&alfBzV z^kiR|wHy7f5N^A-`CrJVAhKX$j?eC| zIem@(Jyf|-B&feORB|f|N+@T_j`ZjI^2TN9WpEQpw1-NjRJMO&amhmdqM&@$CYn;I zP{q_$T!OWCwx7R7m?IO%Ov;T1GfL#ODndL8dNMhNbqe%kat7-kpeK{_SigYI9Dl=# ze9mSvDT`GH^kh;Ot1akt`qR|j4%6u(8}w(i(%XXS{E_HYAi}ouH$rX+L3I9}=yC98 zI{#40UbFW~WKPTUxS^PJaM+5?vf1`9H zMW+F2lI+ZbscIPL*`XblAN1_-Io1Wxv%?!$AAp`6+?Ld-Mmx^D2k6~E?i1i}qq~s~A4WN^fg;$pzy50(xEf zcdTDQuPdFM3>eVs%HN209rU{LIMxti>K7!sVI_fnL82kn0MIW;xV7sSB(@Om0O%Ja z4r3L8enH|O)**(1lSD~#m$70O@y$fy3rJ(nI zjcID{AZs_)5$GsQx0Un?=wsqt0-Y}YgmoFZ%G!Ux`VqQG^8>86ck>-_X~tp=gdWly zgEb58lx7{Q#n4llk7K}NBJ=W1hJqUhMoo13)(5j zvml6^eg*nE_%k{EF3KH&|8GwJ9x*OKa5;VHwcL#%_?*5Gr8+`r6|47tk5=S6IJ-&X_;J>hhRP z9$XEp6X-nn8ZkR#>O9!3UFX5;h_@MZ9{dp2v!L_f`B=u*dGIW(FF|LwMOf!RXSZ9i zz5u=D=GLzB;ADE|P|$gBC#+b|d9d5-bsjvOcn^bqO?eE~0?^+h7=;z}q|FP>z1A@~ zgMOj84c0Kw`Fdq6Kj?ftfRzh6U(diA4mw}I%DErI)EV<5SbqhbG0(($8Fa?%*4|Lg zOXe7lgU+qTJ;BSRpmXa?tfioH>(yABK3a|N`Jt<(?eR(i6| z!p~ubW9lsY7-j^f&cfZ=br$|0@m7M)!slVF1D%CGh4nn>EPOrI%b>IHC$OFb{gm%8 z)*GPn^#fRkKG7S?R&BhCA1~7fjgo!w_?5uanf9dRsAW)=`YQT zn58ijqti(opERSe>cKE+e#3ds!W=Hm zWUPD$NV6MO0gRBQTl+|9hHPZF7Dh?4I#y%IvNAhjj+W-FSk+*RG_RU-$IO%F0IYE^ zR+^o$@{KJ`xAuH#&L!R&D3Io3SX-db%6tiPf;1n&S_>1UIUVaNOqS+ptjjP(nlEEr zfvM7TYo8`fbBsTO#n#>aer&))5Iaq;pdSb8A5@$|{s=6;obVOu1u(k`@>B=ht zZ-1m?4FkRXk%1Kez5Q`J)(EiJ`7E)DnHB8bSc}4JU~CRowm~9dGUzr)z{)UTbvBt5 z$BR!8M8}wcJ`b$_B=!>I)nM5%cBAeCtB&z6#4Dg1h1uofve-_=tEBrVs06 z{7f<*AB7+q`aATiVD;0SGAShcVA;rxP+NdiBdzU_A@Ek+))P2i?dySUbRC z9n&I>=b;cpBM(4Nhp;e<-#?8(%mvFvo{Rc0SbrR5Ir3TvvHffF-ynYn>^aK$qsBnC zlR#fZW3~i+Z7xxF2~52)>>g=Jd7SqW&kx~N=2%RlhJ zyd7%~=#AlhSO-DBAh8hZ5IDVLGqvr{N)&<^6>;dvVEv)FA;=kEIWn?Q^TB##OhKLv zp~3u}lM@s;3+{6n%NL=-6Uh6)eCS3!m-&wHmq8DzkFlR~Kn>w&rtt97EyP$_}c67iYVqAicB8e$+slK=rU%EFrF`WO8OGruU(+Om6Bt&~lIW@h#Ju$x2WKTkhr#P~&kJo!6Zb_%MsUsz>Z-O`3=ZR1DdSV6> zIo{jX97|=Vj<>%jzE5Iue-6wXFM;DYOb*W+d8Bh21#X<2C*g)+{@>R>E~URGH99s7 zAt^aAKCy3_*B9;KsFFN`eSJMC?$MWZqJEE%l-4^wF1omUTtakWLP}gpD)p5>`8@`0 zkeEi8m_%<%aie$#VU=;}{aZ=#4oLHI;=Y8m{=GS?)Wk$z@3_9@m6PDTyMl5O<6|m1 z_5WR0T*5$4d>ki!^RV1YTJDe1|JJ&doJO1_*Co36+7_Re8^D(o?}_%tQlB?D#A)ii yJ1#XgCfRehC!S_Z^7M|2k4vQo-MnDlLB&zLF}FC)y{7$>6H{+or2k7U?ff^l4A=tz diff --git a/build/StarcoinFramework/source_maps/EasyGasOracle.mvsm b/build/StarcoinFramework/source_maps/EasyGasOracle.mvsm new file mode 100644 index 0000000000000000000000000000000000000000..0bcc1849f84bee50a0606009d8a115232e6d7fd2 GIT binary patch literal 4946 zcmb7{TWAzl9EZj=b9ZTi1Ip8Dn}O0ssFc8VB8A zV#p1K%WkgdC5<^LD&4as@Jy{TJFwQrsJI2^%@|$|$B*Gn;(Q1Rxt7mZ%N!(9+e>>r zfBVEfPc7;!`b9fLiBatay`>lGjJXa~Oyhg>1z0=_HJ2CajTr>JBg0sSAcoqKGNuoz znDqwq0Wh^SYgYHFS-+7s<~HE=#c_Kw#$-p`zzOYPI-VbvC)BuKnay3uE{+N50H@%; zT~gyJjG446>CngfF5U^yyB}3e%Fdmm-gT&v<~=OKF4jsj+KW1A?xfx*)JxNz;T~v^ zrjKwQQ`v$$lYrCGq-3mIufUAbJEpHlA(G)i+C>jE@M^D@>=$Vzh_%f3A; zr1|ZV`IIy-VqSu$r5Wwgv$0J3=B|?F1D>41d`_DGV5TvfrMUvD9a^NB#j^8km1fhD z`MfkUn2pdTO}n4=>8qu=6|)z!Q=03rUV$!YMm4*oxrutO!`fKp4otFy`q*yfqT5#8 z{WyaD*5duhWvw1Cj(N)3`g5ABrTw9bTW=+LDnP|W+Jr0UbY%Df>u=DJ!CH5~=*OQU)Ba#{ZC!&C?=8HA{Rd>1 zj@NPX`LY)T>X;ueW*MPBGgiu1ik{=UWAgQF!GGC~3BqzE7seVhfIno%NcN zlh4_WzXy`l#^gH;dI;6_{0w7Gfq6#v{4CxA=$?Yi`pU26s1^KDq&pnJXtYa{5U z>&My(y5}FW?mg1X5_C*1U`>IJ$s<_1K*!`^tQ(+X@@cGj&@uUQtjnNd z^2b;+pkuN%uYiupe_`DR9g`norTE*WWAZPUf5J+6Bc!R9v47=sGtF|lehF1vn_r=S v197j-dEBc|7b~6oh8R&pg#lu^6)N9{TZ-UHyHB-{jAE0 literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/source_maps/EasyGasOracleScript.mvsm b/build/StarcoinFramework/source_maps/EasyGasOracleScript.mvsm new file mode 100644 index 0000000000000000000000000000000000000000..018e56b33a30b94dba48424c12ec2532d74367c4 GIT binary patch literal 1082 zcmb7?J4*vW6h`mnA;ec>Aq2$2LXlKTEG-1Fv`G4}Y}T;4*(|#;A(Bco*aU)=l@JSm zg{78Sh>t2hu&}ik#IvQ<9S2T#W-i}%XE^^9t(+fUu739hyX}0p-#&X8o!%dA9F>as zkEN5^gvbF{^7mLXn|9pUvg7T@c6_(wL|)jGw8&6-urw*+fR!sZ_S~S{30>_<6}=9r zvDgi&Zlw7w+%AlJf!D0GY=2)J(L*1ANJfuvi}(PR8uk(E6;i5sf%OJy)l95+Fc^Qu z;;xhBnRk7Ieg~#qKjV%d7e=n*#a<)Ow)2Vo1xZ#l>;gfTL9e=iRRq0i!CC_Y^#?68 p^{)c6=+j_Y;4JPOWR3pmB4z=M%BvvmfL>k=%Ll!@b*wsw`~q3+tU3Sy literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/source_maps/GenesisSignerCapability.mvsm b/build/StarcoinFramework/source_maps/GenesisSignerCapability.mvsm index 70bc337e9c52032c9e54526b78b1940dbbdbf3fe..ac7d5129aa86a003497fbb2d08fc8c243b4e63ab 100644 GIT binary patch literal 1176 zcma*lKT85}9LMqB&ohVqcol*aHP}!MH5`FUQyqtiq0pT}L5PXkL5OuiI5o6Xb5qa* zXowy|P)f}$MzlrJ0|?rBUl6o?J9uv|KBr%0lX+-Rpo;X5*C+Y!DN>PG@N;VEW;5V>bw={ZZc+CnpX>_Np{RJ=N7M%mh_Z`%pqMDnQ5GM;peV;tvos{i zFE;0p!=n6s`-muQ_OcWgWd&6uQ~cZd(6&u6%^DYR!O_Kmvf}0> zFL#mlyvoJRndEBsfCJxA%I$CJd;9b}GruWM?e14j9yh&2r1QQKAGa=^PuJa@zFP72 z<@&9EJE4>sB#r()T0E6^^Se140TDmeCVv9 z)G`H6NahdFDrw@|o};cv7iBm1_K+dUFV5>l{^R;rKEE1_rHB2Wsin9ZZBMdc zhOH;1V)A4&z&Vm98$ivIJlP)VfaJ+GP$de9;~t}Ks7{oJs3QuCvVaQl(;7tignXw) zQQo0GC?d+=+nYq$&O3HcRFp%gVTy^e3pGN`qKu;2s6~{cs4-Gnt7)aPxs+*{naNCU MBAHB2TUn*P0fj#7{{R30 diff --git a/build/StarcoinFramework/source_maps/StdlibUpgradeScripts.mvsm b/build/StarcoinFramework/source_maps/StdlibUpgradeScripts.mvsm index 104c652bc295cf93fffb63a501340db4091068ef..9c34e64b84328b9638e70c02c36cf20dae2e97a6 100644 GIT binary patch literal 6351 zcmb7|U2IfE7=~wC+HFgr3oWIE7K?y@QCn|JlxR}Lh`|`KDy&4e$KBKAXuG@Y9$0!) zL{TqH6fw~ou}b_&Fi|jwrLjeYn3&j@*dRvmLQyY>f0X|ggU^_3;@vxL^4vW$XU@z! z-^|(3@y_)veb>fceDvY5kGr>zY`-fQ-r8~Vf#usiyW!_cv9>kF7#||=-(RGmD@^qU zk3E=6=e?BQmCOgZuwbSeGb(!AQE$v1Fp<>15A_V0M?sOA?qa=&Wolg( z_7r9WQ!ngstRJCTMqnXU3TmYJ7uE%sF3ka~15hi?BUo2phBU2(=Cbh561dmFIjV!m zZ`%eWKn~c?zT$=uK2N+n70^LvWTJ z8!>eVO3&9JxQG7k2OWY3u-1YO!7{9MphK_+YcJ@7d?(gE&>=XCbrN*FpTIf;4zEgxsU$Vf{sias~dD=mSTCJBl9lS`=BE;fb{|B$c$k90yE{zTkBVFc%>#TzU}tj z?^=sGkZ-aLSS>k_05JzTEcaq<1RWM@<-uVU2DwM<2U8aHlF96*OsLZR5%wn#3$vlu zn<#|IgxBZN@CzD!3sv>KLB{v;iDD3LNaej^!l7hGqsGjG>b@WoCZ6#73u>ItRT#4a zDs2nB!Bb>6rTH4x5vZ5u4_N1*L7Jt)F-MxKsC98@l;(P@ZkQ`g4=W8#(zN|q zyIGn6Ru<+-vw*c3=1a35>uG3_W)W)(v`RCFwGkFbvlZ(ZxJsI(GpS9Qr|It!ER^OH zR{XWmqOnYyAxlrFIGb z#N1;4jd8ubtw8Ry4LHN(K#GV1pby4%SX*tky5_%ycF?M>Lmo!{)HdLVltZ4ue=-fA zhunxY7xY>F9S?89)MvT1n!({fyN>VaPWzSaIt{lYud)qX?%n-}PlBF?Zmeyfr@>lJ HfieF8Z?k0h literal 6099 zcmb7|S!`5Q9EZ=ecBUIJ&{ohw!PWxqLZhZ_aH}tZ7)xVPQ8QkrmvUh?XD-x|1~tJ% zsav2CF+fawXpAuk0emnn55xsZS!^-j1D0S6Mzj_yCa&KhxruMT>m=XXch>tm|8wt5 z9_n2AW4ig}k2fs1rD5Z~zO#M(4S&Wic(__uB@hSoc1RI06wlj{{hvP$bQB zSl>a2PS2DZa|uE(?sw$BZ38n^FK!9j+Xi}ZGqLUiy*L+ZEfmXbSb>#-E2Oy_Yd@4o z^9`&65S8W#)@g`I^B~qYP%6#+mBxGsWzzhE{_eyqm*yd?<4_^ZPOR6UQkuK4PQesu zTI)1~c<@gUxThg>RC|%1u?w-MGmN(7S_C=-MOceLhhP)dX3!x>VfBL! z!A`7?K-c>rtRoO&N$s5G9N4&c-5LEp^AvIqL}J-htK7WXrDCuJdAl8fOGvq2;vKV{ zOY;QQ1n9`@z`6)JGQmuBWUeRvi$F)F39AKkWFlCtpd<4f)(fB`(~0#W=*Vot`UIxR zowwGf5MoIaHm#RmJwx73<;Zc{fTtxV(uTMcbXXQ*Edw1EYdruVo3$Xab%^^}-$^A3elp>t!!&%0M(;yuRm#h_PCn7&`K!C~PER64$sUUu^DC64 zy^Nn&>-HAZJe?9_)SODa?llR z7S@BHD_XF6UD4jAzah{SEsb>qbVUoYsVmxFc4Qu{{^%*Q7U++jALz5f#zhw=tks}D zdV-AW${R#`njAeil5uGU2VlB12UyKcm?6#eSi7J~njc^tg=%RAg`-BA^)X|b;7V!U zhSdTyrP+#g56qIL?a$g*NwW>>ez;ni%dsAUT4{D*Jr1*_*^adW=16lX)-tG*<|UqF z0&}i3gF9)SG!N6?S8$CqN3q7BUYdhgXQ4rwn@jnaf@`HYfHeq>(tHQ&1k9J_2-YYp zkY*p&NmwXNYkdtNO6@=V6H`3}HSAxVHORHL0e6_3NIPOD=!rLyqs!#%%$=iAnqo$D5C@98zh z3_>1U|1WQRENv$usBD%q}n`MRq*i(V5JuiYKu5LTSoQ zJISooYG+zi%?tR)pd_1UcQRSKJ*6tnV4s6RyEEI`kyiS7)OX=VSGP7f-PV_#xGFN$ z6hL8TGT!E7ls*%+#?_OZ?He6=NQ+QE2gUJLJCU>!&1(HHaty|Ncwt-YjMbTOWZgz; zHbZ`4+WCr|mi`xNjA@3VY**5Hz;V=ZU7TagWpFQ-a^Jxjf;?%yjCBF>rMZc{yJ3_x zw_)vo0%>l+`YPNY%{bOeP$bPktQVnJnvY-|g%W9cyN{OUZF7zJ6qHKyzwEpa^G0cU z-+Y-gce36dD3|8rSl@v$()<$EUKlIQ*Rg&FmrPorr{S-2o=(tfHe&!Nb^># zdGHBoF2xGLL}@#V1_iuV^u0;xUw^u$jan#2UW|UVmK1G z6;|45CsibpE$WFJrEVjPb$3nK-EAFqvz7JnC2XeXYcRzczC!VIB9*l|(yS5RM7s2q z`@TW_b1;07y+XUWIqhWRNuQwZw@{SnjK_WW<&$Zw;6B*o{ac5)3Up3cjkOMRPT7Ff z20EuCv9^KEDLq(^fzBztSo@$*p8I~RAA?RbFJk=ybfS3`>rbE)&7ZL@flf64#>$)G zC(+!7nUCq?OWK9@B;?SI`q2lW)NeQX5%Mv}p&R`Q{Va^68x2wSADH3(PTl#3sVot< z-9d185=y0=L_5D&)hR|#HKrDF>uO7>2t)2&?S87-U?g2_D|Nk)b65K=MbE>>>1xNR ze-lR1)&54^2jI7>EuO}M779jH&zh&c!Q+U@>2#p#S@Zq6<(atM#&g7afOiLa(B97$ zhoB^rjr)7-^lXS&*0Vtmg&VQrpoc=@PyRYYysZRTSw20fOAvF-ysmbGGS1wEGS#_9t-mR;tI zp25^(nRo6!n%#~!DvAW?-X?nZQljh^B_cY9x=CfEog}bEr4AucyAkAK^ zPmkp}C>+;N`*!qao5ZDlo^53xy4I!&3*jV2XD>RiK`J^EbToqUmy1`7nw%Y1w-P&-- zibP{pARLaa3)SUc|MAtuuK#$HnRcx@))Vn!)fJekYo7;#!RXpZ g%&LoqnuZq%t*>v2F;Rcy*go9op0$zT)r!pj0mJH`-~a#s literal 8503 zcmbuDdu&r>7>B;L|_9%?p_CS6$Hvw#^zW@*Xbb9!=XK}2HKUj69&^ikYR!b zqQ-bZ5ff1&K_J`|qId}iBqWMq#vlO`F99`}7=oIJK4;KC!XLkOkUam;=l#C#v^($n ze(%ZW&lc}Eeeqz+@#eE@@^)_;`>p4#w#99`_GUj8%4_Ypf4wngGi1Sy|FU`o;&wD) z2b1B(=o~w0FLvUli!mp~dX+eU6Ss=~SFW+67b*%R|6iU;= zYJl6MIT0%iJ*2q_>s{z6%{^F$pqDgHV0{Cr?b0mZ{p-d97GH966sW2INx+lV_4 z-Q8HXOvmEkpnR&oh{*0wmU5#a_KNn%rf4`RJC8m@4Ts+CErAP1a$~3IGp!<|stc9Taln~Z3 z(0xh*YYpVcXJ3o;8t9H@Bi1(19nE&Eqo6yQ<5*`vcQj|Qeg@sq^uqcD()f{LMaHax z46;!RdMk8GHygczya_VMMmy0DKu5CC3F6MdVD~+B??2qi!a>`;2)5sZVsR%N;f+<9 z;v#Dl7H68(h7mCaGS6x=h?)x>$!ZITOF+h1Z8bqJ!mVVr&BPysj%2m3iTe@K&1!=O z8Z!di_ENstA;hJiv)VMQ2BHxto8}kQP5ef4eLDUtacfz@1S(D+Ayp!ptIU^ ztQyc+?Fp=9ptIU?&e?*gv)VeW*Fk5sO<4Ot-_tf?y$SlBwiavE;B@Y3|6%50>U&y$ ztf8RqY2&eGgTAND$Ff1+(~fY?7^c3brJg;FKjkSo#*{(^RiX@i4y0WrEaXLyL6um6 zz8X4GC0-_OE8J?8*v}emkXi5h8xem)=2apumwPC*KeMwU7LH%7Z0;mcRkTsWO@XvW zaFxh@$hfR5ASea{I^HWkP57(Ok*e|mai4)P59=y1A&+?>=qfQ3YdYvEQHm7=T_t8< z%>-Q~3bFQq?r7Ixy$?F~FT>gfI`^k`*SUXEKJ!V?xxW(24?6dkV^x68{UunfpeJt; ztY<)H^Z?cx&>20oyUyqzv)*CQ8T}iqGoUm2uUJ<=Pu>c;8gmcm$=hVCS)eCx0W1gf ztlT{tm2@OgKhLb3WEW z7$wbetRRe*W)W5h?v~~i&iMuAz0!OMYX{sX&6QX?;eKhRc7H&c#ohTOp+uS!ux7v* zY5K7o7%R=?STDeX(mcm=Z^j%aP1kxG#!GWA)?t_+&0|>SV4^gSU>$`?(%gmRzHyVK z`8bvX4@t8UYY|M5Wr(tF0Q(yec369hg_+wQ5WK6*Ykz)9u5C1{uDX4-T=PF0p_-on diff --git a/integration-tests/account/basic.exp b/integration-tests/account/basic.exp index 7e282ee2..809ee7b7 100644 --- a/integration-tests/account/basic.exp +++ b/integration-tests/account/basic.exp @@ -2,13 +2,13 @@ processed 14 tasks task 5 'run'. lines 30-41: { - "gas_used": 129290, + "gas_used": 138618, "status": "Executed" } task 6 'run'. lines 44-55: { - "gas_used": 36041, + "gas_used": 43037, "status": { "MoveAbort": { "location": { @@ -24,7 +24,7 @@ task 6 'run'. lines 44-55: task 7 'run'. lines 58-74: { - "gas_used": 51826, + "gas_used": 58822, "status": { "MoveAbort": { "location": { @@ -40,13 +40,13 @@ task 7 'run'. lines 58-74: task 8 'run'. lines 76-95: { - "gas_used": 110588, + "gas_used": 129244, "status": "Executed" } task 9 'run'. lines 98-110: { - "gas_used": 144364, + "gas_used": 153692, "status": "Executed" } @@ -58,7 +58,7 @@ task 10 'run'. lines 112-121: task 11 'run'. lines 123-135: { - "gas_used": 308465, + "gas_used": 396498, "status": "Executed" } @@ -70,6 +70,6 @@ task 12 'run'. lines 138-147: task 13 'run'. lines 150-159: { - "gas_used": 51134, + "gas_used": 52883, "status": "Executed" } diff --git a/integration-tests/account/delegate_account.exp b/integration-tests/account/delegate_account.exp index 5441bc8c..fa633220 100644 --- a/integration-tests/account/delegate_account.exp +++ b/integration-tests/account/delegate_account.exp @@ -2,12 +2,12 @@ processed 7 tasks task 5 'run'. lines 27-44: { - "gas_used": 522360, + "gas_used": 617389, "status": "Executed" } task 6 'run'. lines 47-62: { - "gas_used": 137701, + "gas_used": 139450, "status": "Executed" } diff --git a/integration-tests/account/txn_prologue_and_epilogue.exp b/integration-tests/account/txn_prologue_and_epilogue.exp index c8f0ae6c..9fdbe5db 100644 --- a/integration-tests/account/txn_prologue_and_epilogue.exp +++ b/integration-tests/account/txn_prologue_and_epilogue.exp @@ -1,14 +1,14 @@ -processed 12 tasks +processed 15 tasks -task 3 'run'. lines 8-23: +task 3 'run'. lines 7-28: { - "gas_used": 401102, + "gas_used": 619661, "status": "Executed" } -task 4 'run'. lines 27-59: +task 4 'run'. lines 30-62: { - "gas_used": 91881, + "gas_used": 180711, "status": { "MoveAbort": { "location": { @@ -22,9 +22,9 @@ task 4 'run'. lines 27-59: } } -task 5 'run'. lines 63-90: +task 5 'run'. lines 66-92: { - "gas_used": 168011, + "gas_used": 330596, "status": { "MoveAbort": { "location": { @@ -38,9 +38,9 @@ task 5 'run'. lines 63-90: } } -task 6 'run'. lines 94-122: +task 6 'run'. lines 96-124: { - "gas_used": 140032, + "gas_used": 306926, "status": { "MoveAbort": { "location": { @@ -54,9 +54,9 @@ task 6 'run'. lines 94-122: } } -task 7 'run'. lines 126-156: +task 7 'run'. lines 128-158: { - "gas_used": 174473, + "gas_used": 354875, "status": { "MoveAbort": { "location": { @@ -70,15 +70,15 @@ task 7 'run'. lines 126-156: } } -task 8 'run'. lines 160-205: +task 8 'run'. lines 162-207: { - "gas_used": 239024, + "gas_used": 477794, "status": "Executed" } -task 9 'run'. lines 209-239: +task 9 'run'. lines 211-241: { - "gas_used": 174341, + "gas_used": 354743, "status": { "MoveAbort": { "location": { @@ -92,9 +92,9 @@ task 9 'run'. lines 209-239: } } -task 10 'run'. lines 243-274: +task 10 'run'. lines 245-276: { - "gas_used": 95560, + "gas_used": 197255, "status": { "MoveAbort": { "location": { @@ -108,9 +108,9 @@ task 10 'run'. lines 243-274: } } -task 11 'run'. lines 278-309: +task 11 'run'. lines 280-311: { - "gas_used": 89451, + "gas_used": 175156, "status": { "MoveAbort": { "location": { @@ -123,3 +123,31 @@ task 11 'run'. lines 278-309: } } } + +task 12 'run'. lines 313-349: +{ + "gas_used": 358789, + "status": { + "MoveAbort": { + "location": { + "Module": { + "address": "0x00000000000000000000000000000001", + "name": "Account" + } + }, + "abort_code": "1031" + } + } +} + +task 13 'run'. lines 351-401: +{ + "gas_used": 516751, + "status": "Executed" +} + +task 14 'run'. lines 404-427: +{ + "gas_used": 37331, + "status": "Executed" +} diff --git a/integration-tests/account/txn_prologue_and_epilogue.move b/integration-tests/account/txn_prologue_and_epilogue.move index ddb27004..0dd194e8 100644 --- a/integration-tests/account/txn_prologue_and_epilogue.move +++ b/integration-tests/account/txn_prologue_and_epilogue.move @@ -1,9 +1,8 @@ //# init -n dev -//# faucet --addr alice --amount 10000000 - //# faucet --addr Genesis +//# faucet --addr alice --amount 10000000 //# run --signers alice // create txn sender account @@ -11,6 +10,8 @@ script { use StarcoinFramework::STC::STC; use StarcoinFramework::Account; use StarcoinFramework::Authenticator; + use StarcoinFramework::DummyToken; + use StarcoinFramework::DummyToken::DummyToken; fun main(account: signer) { let txn_public_key = x"c48b687a1dd8265101b33df6ae0b6825234e3f28df9ecb38fb286cf76dae919d"; @@ -18,12 +19,14 @@ script { let address = Authenticator::derived_address(auth_key_vec); Account::create_account_with_address(address); Account::pay_from(&account, address, 5000); + let coin = DummyToken::mint(&account, 500); + Account::deposit(address, coin); + assert!(Account::balance(address) == 500, 1000); + } } // check: EXECUTED - - //# run --signers alice // prologue sender is not genesis script { @@ -76,7 +79,6 @@ script { let txn_sequence_number = 0; let txn_gas_price = 1; let txn_max_gas_units = 10000; //EPROLOGUE_CANT_PAY_GAS_DEPOSIT - Account::txn_prologue( &account, txn_sender, @@ -306,4 +308,120 @@ script { ); } } -// check: "Keep(ABORTED { code: 2818" \ No newline at end of file +// check: "Keep(ABORTED { code: 2818" + +//# run --signers Genesis +// epilouge cant pay gas deposit + +script { + use StarcoinFramework::Account; + use StarcoinFramework::Authenticator; + use StarcoinFramework::Vector; + use StarcoinFramework::DummyToken::DummyToken; + + fun main(account: signer) { + let txn_public_key = x"c48b687a1dd8265101b33df6ae0b6825234e3f28df9ecb38fb286cf76dae919d"; + let auth_key_vec = Authenticator::ed25519_authentication_key(copy txn_public_key); + let txn_sender = Authenticator::derived_address(copy auth_key_vec); + Vector::push_back(&mut txn_public_key, 0u8); //create preimage + + let seq = Account::sequence_number(txn_sender); + assert!(seq == 1, 1005); + + let txn_sequence_number = 1; + let txn_gas_price = 1; + let txn_max_gas_units = 2510; + Account::do_accept_token(&account); + + Account::txn_prologue_v2( + &account, + txn_sender, + txn_sequence_number, + txn_public_key, + txn_gas_price, + txn_max_gas_units, + 2, + 10, + ); + } + +} +// check: "Keep(ABORTED { code: 1031" + +//# run --signers Genesis +// successfully executed +script { + use StarcoinFramework::Account; + use StarcoinFramework::Authenticator; + use StarcoinFramework::Vector; + use StarcoinFramework::DummyToken::DummyToken; + + fun main(account: signer) { + let txn_public_key = x"c48b687a1dd8265101b33df6ae0b6825234e3f28df9ecb38fb286cf76dae919d"; + let auth_key_vec = Authenticator::ed25519_authentication_key(copy txn_public_key); + let txn_sender = Authenticator::derived_address(copy auth_key_vec); + Vector::push_back(&mut txn_public_key, 0u8); //create preimage + + let seq = Account::sequence_number(txn_sender); + assert!(seq == 1, 1005); + + let txn_sequence_number = 1; + let txn_gas_price = 1; + let txn_max_gas_units = 2500; + Account::do_accept_token(&account); + + Account::txn_prologue_v2( + &account, + txn_sender, + txn_sequence_number, + txn_public_key, + txn_gas_price, + txn_max_gas_units, + 2, + 10, + ); + // execute the txn... + let gas_units_remaining = 10; + Account::txn_epilogue_v3( + &account, + txn_sender, + txn_sequence_number, + Vector::empty(), + txn_gas_price, + txn_max_gas_units, + gas_units_remaining, + 2, + 10, + ); + let seq = Account::sequence_number(txn_sender); + assert!(seq == 2, 1006); + } + +} +// check: EXECUTED + + +//# run --signers Genesis +script { + use StarcoinFramework::Account; + + fun main(_account: signer){ + let (txn_gas_price, txn_max_gas_units, gas_units_remaining, + stc_price, stc_price_scaling + ) = (1, 100000, 0, 43793, 1000000000000000); + let (stc_amount, token_amount) = Account::transaction_fee_simulate(txn_gas_price, txn_max_gas_units, gas_units_remaining, + stc_price, stc_price_scaling); + assert!(stc_amount==100000, 100); + assert!(token_amount==1, 101); + + let (txn_gas_price, txn_max_gas_units, gas_units_remaining, + stc_price, stc_price_scaling + ) = (1000000, 100000, 0, 43793, 1000000000000000); + let (stc_amount, token_amount) = Account::transaction_fee_simulate(txn_gas_price, txn_max_gas_units, gas_units_remaining, + stc_price, stc_price_scaling); + assert!(stc_amount==100000000000, 102); + assert!(token_amount==4, 103); + + } +} +// check: EXECUTED diff --git a/integration-tests/account/withdraw_capability.exp b/integration-tests/account/withdraw_capability.exp index 9013ab6c..2680f580 100644 --- a/integration-tests/account/withdraw_capability.exp +++ b/integration-tests/account/withdraw_capability.exp @@ -2,13 +2,13 @@ processed 12 tasks task 5 'run'. lines 25-38: { - "gas_used": 55168, + "gas_used": 60415, "status": "Executed" } task 6 'run'. lines 41-55: { - "gas_used": 23701, + "gas_used": 25450, "status": { "MoveAbort": { "location": { @@ -24,7 +24,7 @@ task 6 'run'. lines 41-55: task 7 'run'. lines 58-73: { - "gas_used": 23701, + "gas_used": 25450, "status": { "MoveAbort": { "location": { @@ -40,24 +40,24 @@ task 7 'run'. lines 58-73: task 8 'run'. lines 76-88: { - "gas_used": 129290, + "gas_used": 138618, "status": "Executed" } task 9 'run'. lines 91-103: { - "gas_used": 148304, + "gas_used": 157632, "status": "Executed" } task 10 'run'. lines 106-117: { - "gas_used": 93822, + "gas_used": 95571, "status": "Executed" } task 11 'run'. lines 120-132: { - "gas_used": 136490, + "gas_used": 145818, "status": "Executed" } diff --git a/integration-tests/account/withdraw_zero_token.exp b/integration-tests/account/withdraw_zero_token.exp index cf58db63..9c1df52a 100644 --- a/integration-tests/account/withdraw_zero_token.exp +++ b/integration-tests/account/withdraw_zero_token.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 6-16: { - "gas_used": 34047, + "gas_used": 35796, "status": "Executed" } diff --git a/integration-tests/authenticator/authenticator.exp b/integration-tests/authenticator/authenticator.exp index 253a3a06..3bd338d3 100644 --- a/integration-tests/authenticator/authenticator.exp +++ b/integration-tests/authenticator/authenticator.exp @@ -2,13 +2,13 @@ processed 11 tasks task 2 'run'. lines 6-50: { - "gas_used": 342616, + "gas_used": 447357, "status": "Executed" } task 3 'run'. lines 52-67: { - "gas_used": 11387, + "gas_used": 14885, "status": { "MoveAbort": { "location": { @@ -24,7 +24,7 @@ task 3 'run'. lines 52-67: task 4 'run'. lines 69-84: { - "gas_used": 11460, + "gas_used": 14958, "status": { "MoveAbort": { "location": { @@ -40,7 +40,7 @@ task 4 'run'. lines 69-84: task 5 'run'. lines 86-106: { - "gas_used": 17341, + "gas_used": 100127, "status": { "MoveAbort": { "location": { @@ -56,7 +56,7 @@ task 5 'run'. lines 86-106: task 6 'run'. lines 109-128: { - "gas_used": 13329, + "gas_used": 19159, "status": { "MoveAbort": { "location": { @@ -72,7 +72,7 @@ task 6 'run'. lines 109-128: task 7 'run'. lines 131-150: { - "gas_used": 13256, + "gas_used": 19086, "status": { "MoveAbort": { "location": { @@ -88,19 +88,19 @@ task 7 'run'. lines 131-150: task 8 'run'. lines 153-182: { - "gas_used": 56679, + "gas_used": 75335, "status": "Executed" } task 9 'run'. lines 184-196: { - "gas_used": 308465, + "gas_used": 396498, "status": "Executed" } task 10 'run'. lines 198-206: { - "gas_used": 10151, + "gas_used": 11900, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/block/block_checkpoints.exp b/integration-tests/block/block_checkpoints.exp index 71b9d7c2..dcba77a2 100644 --- a/integration-tests/block/block_checkpoints.exp +++ b/integration-tests/block/block_checkpoints.exp @@ -2,24 +2,24 @@ processed 7 tasks task 3 'run'. lines 157-166: { - "gas_used": 196355, + "gas_used": 442964, "status": "Executed" } task 4 'run'. lines 168-179: { - "gas_used": 55656, + "gas_used": 73744, "status": "Executed" } task 5 'run'. lines 182-192: { - "gas_used": 343988, + "gas_used": 565558, "status": "Executed" } task 6 'run'. lines 194-205: { - "gas_used": 70139, + "gas_used": 95791, "status": "Executed" } diff --git a/integration-tests/block/checkpoints_test.exp b/integration-tests/block/checkpoints_test.exp index 7612f5bc..38529241 100644 --- a/integration-tests/block/checkpoints_test.exp +++ b/integration-tests/block/checkpoints_test.exp @@ -2,13 +2,13 @@ processed 13 tasks task 4 'run'. lines 9-27: { - "gas_used": 96408, + "gas_used": 114496, "status": "Executed" } task 7 'run'. lines 33-46: { - "gas_used": 323909, + "gas_used": 532055, "status": { "MoveAbort": { "location": { @@ -24,12 +24,12 @@ task 7 'run'. lines 33-46: task 10 'run'. lines 53-64: { - "gas_used": 355841, + "gas_used": 577411, "status": "Executed" } task 12 'run'. lines 68-81: { - "gas_used": 78260, + "gas_used": 103912, "status": "Executed" } diff --git a/integration-tests/block_reward/basic.exp b/integration-tests/block_reward/basic.exp index 4045d172..f82eeca7 100644 --- a/integration-tests/block_reward/basic.exp +++ b/integration-tests/block_reward/basic.exp @@ -2,13 +2,13 @@ processed 12 tasks task 3 'run'. lines 7-21: { - "gas_used": 192672, + "gas_used": 202015, "status": "Executed" } task 4 'run'. lines 24-40: { - "gas_used": 29041, + "gas_used": 30790, "status": { "MoveAbort": { "location": { @@ -24,13 +24,13 @@ task 4 'run'. lines 24-40: task 5 'run'. lines 43-58: { - "gas_used": 33791, + "gas_used": 35540, "status": "Executed" } task 6 'run'. lines 61-76: { - "gas_used": 33282, + "gas_used": 36780, "status": { "MoveAbort": { "location": { @@ -46,30 +46,30 @@ task 6 'run'. lines 61-76: task 7 'run'. lines 80-96: { - "gas_used": 500556, + "gas_used": 596183, "status": "Executed" } task 8 'run'. lines 99-115: { - "gas_used": 455217, + "gas_used": 472722, "status": "Executed" } task 9 'run'. lines 118-133: { - "gas_used": 199872, + "gas_used": 209215, "status": "Executed" } task 10 'run'. lines 136-150: { - "gas_used": 86207, + "gas_used": 95550, "status": "Executed" } task 11 'run'. lines 153-167: { - "gas_used": 199872, + "gas_used": 209215, "status": "Executed" } diff --git a/integration-tests/collection2/collection_add_by_other.exp b/integration-tests/collection2/collection_add_by_other.exp index f467ab53..0848f2bb 100644 --- a/integration-tests/collection2/collection_add_by_other.exp +++ b/integration-tests/collection2/collection_add_by_other.exp @@ -2,25 +2,25 @@ processed 9 tasks task 5 'run'. lines 33-42: { - "gas_used": 18414, + "gas_used": 24244, "status": "Executed" } task 6 'run'. lines 45-58: { - "gas_used": 62862, + "gas_used": 76271, "status": "Executed" } task 7 'run'. lines 61-73: { - "gas_used": 51285, + "gas_used": 64111, "status": "Executed" } task 8 'run'. lines 76-93: { - "gas_used": 35304, + "gas_used": 40551, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/collection2/collection_by_owner.exp b/integration-tests/collection2/collection_by_owner.exp index b9e41d45..742e8283 100644 --- a/integration-tests/collection2/collection_by_owner.exp +++ b/integration-tests/collection2/collection_by_owner.exp @@ -2,37 +2,37 @@ processed 13 tasks task 5 'run'. lines 29-42: { - "gas_used": 83553, + "gas_used": 104541, "status": "Executed" } task 6 'run'. lines 45-61: { - "gas_used": 72894, + "gas_used": 89801, "status": "Executed" } task 7 'run'. lines 64-81: { - "gas_used": 88429, + "gas_used": 107668, "status": "Executed" } task 8 'run'. lines 84-107: { - "gas_used": 82561, + "gas_used": 102383, "status": "Executed" } task 9 'run'. lines 110-124: { - "gas_used": 66029, + "gas_used": 79438, "status": "Executed" } task 10 'run'. lines 127-142: { - "gas_used": 35628, + "gas_used": 40875, "status": { "MoveAbort": { "location": { @@ -48,7 +48,7 @@ task 10 'run'. lines 127-142: task 11 'run'. lines 146-170: { - "gas_used": 133526, + "gas_used": 163842, "status": "Executed" } diff --git a/integration-tests/collection2/collection_mut_by_other.exp b/integration-tests/collection2/collection_mut_by_other.exp index 8064ccae..68481537 100644 --- a/integration-tests/collection2/collection_mut_by_other.exp +++ b/integration-tests/collection2/collection_mut_by_other.exp @@ -2,13 +2,13 @@ processed 10 tasks task 5 'run'. lines 35-44: { - "gas_used": 18414, + "gas_used": 24244, "status": "Executed" } task 6 'run'. lines 47-63: { - "gas_used": 38202, + "gas_used": 43449, "status": { "MoveAbort": { "location": { @@ -24,18 +24,18 @@ task 6 'run'. lines 47-63: task 7 'run'. lines 66-79: { - "gas_used": 55662, + "gas_used": 69071, "status": "Executed" } task 8 'run'. lines 82-95: { - "gas_used": 65013, + "gas_used": 77854, "status": "Executed" } task 9 'run'. lines 98-111: { - "gas_used": 56093, + "gas_used": 69502, "status": "Executed" } diff --git a/integration-tests/compare/compare.exp b/integration-tests/compare/compare.exp index 789701d3..8bbf6742 100644 --- a/integration-tests/compare/compare.exp +++ b/integration-tests/compare/compare.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-62: { - "gas_used": 1028099, + "gas_used": 1790663, "status": "Executed" } diff --git a/integration-tests/dao/test_dao_config.exp b/integration-tests/dao/test_dao_config.exp index 7eff71ad..e54381f3 100644 --- a/integration-tests/dao/test_dao_config.exp +++ b/integration-tests/dao/test_dao_config.exp @@ -2,19 +2,19 @@ processed 18 tasks task 4 'run'. lines 25-43: { - "gas_used": 249651, + "gas_used": 253732, "status": "Executed" } task 5 'run'. lines 46-67: { - "gas_used": 203300, + "gas_used": 210879, "status": "Executed" } task 6 'run'. lines 70-85: { - "gas_used": 34971, + "gas_used": 38469, "status": { "MoveAbort": { "location": { @@ -30,7 +30,7 @@ task 6 'run'. lines 70-85: task 7 'run'. lines 88-103: { - "gas_used": 34971, + "gas_used": 38469, "status": { "MoveAbort": { "location": { @@ -46,7 +46,7 @@ task 7 'run'. lines 88-103: task 8 'run'. lines 106-121: { - "gas_used": 35076, + "gas_used": 38574, "status": { "MoveAbort": { "location": { @@ -62,7 +62,7 @@ task 8 'run'. lines 106-121: task 9 'run'. lines 124-139: { - "gas_used": 34971, + "gas_used": 38469, "status": { "MoveAbort": { "location": { @@ -94,13 +94,13 @@ task 10 'run'. lines 142-152: task 11 'run'. lines 155-195: { - "gas_used": 123734, + "gas_used": 131313, "status": "Executed" } task 12 'run'. lines 199-226: { - "gas_used": 48641, + "gas_used": 52139, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/dao/test_dao_failure.exp b/integration-tests/dao/test_dao_failure.exp index a545eef0..a42dde63 100644 --- a/integration-tests/dao/test_dao_failure.exp +++ b/integration-tests/dao/test_dao_failure.exp @@ -2,7 +2,7 @@ processed 43 tasks task 5 'run'. lines 12-29: { - "gas_used": 306611, + "gas_used": 311858, "status": "Executed" } @@ -24,19 +24,19 @@ task 6 'run'. lines 31-41: task 7 'run'. lines 44-54: { - "gas_used": 157138, + "gas_used": 161219, "status": "Executed" } task 8 'run'. lines 58-68: { - "gas_used": 157138, + "gas_used": 161219, "status": "Executed" } task 9 'run'. lines 71-81: { - "gas_used": 120357, + "gas_used": 124438, "status": { "ExecutionFailure": { "location": { @@ -53,19 +53,19 @@ task 9 'run'. lines 71-81: task 11 'run'. lines 86-104: { - "gas_used": 146714, + "gas_used": 148463, "status": "Executed" } task 12 'run'. lines 107-127: { - "gas_used": 160129, + "gas_used": 161878, "status": "Executed" } task 13 'run'. lines 131-155: { - "gas_used": 147306, + "gas_used": 149055, "status": { "MoveAbort": { "location": { @@ -81,7 +81,7 @@ task 13 'run'. lines 131-155: task 14 'run'. lines 158-176: { - "gas_used": 92092, + "gas_used": 93841, "status": { "MoveAbort": { "location": { @@ -97,7 +97,7 @@ task 14 'run'. lines 158-176: task 15 'run'. lines 179-197: { - "gas_used": 74751, + "gas_used": 76500, "status": { "MoveAbort": { "location": { @@ -221,7 +221,7 @@ task 24 'run'. lines 327-341: task 25 'run'. lines 344-364: { - "gas_used": 100558, + "gas_used": 102307, "status": { "MoveAbort": { "location": { @@ -275,13 +275,13 @@ task 28 'run'. lines 406-424: task 30 'run'. lines 430-452: { - "gas_used": 155460, + "gas_used": 162456, "status": "Executed" } task 32 'run'. lines 456-470: { - "gas_used": 69654, + "gas_used": 76650, "status": "Executed" } @@ -303,19 +303,19 @@ task 33 'run'. lines 473-488: task 34 'run'. lines 491-505: { - "gas_used": 67706, + "gas_used": 74702, "status": "Executed" } task 35 'run'. lines 508-519: { - "gas_used": 157138, + "gas_used": 161219, "status": "Executed" } task 37 'run'. lines 525-545: { - "gas_used": 106149, + "gas_used": 107898, "status": { "MoveAbort": { "location": { @@ -363,7 +363,7 @@ task 39 'run'. lines 570-583: task 40 'run'. lines 586-606: { - "gas_used": 160127, + "gas_used": 161876, "status": "Executed" } diff --git a/integration-tests/dao/test_dao_propose.exp b/integration-tests/dao/test_dao_propose.exp index e76d8c48..eee46e4a 100644 --- a/integration-tests/dao/test_dao_propose.exp +++ b/integration-tests/dao/test_dao_propose.exp @@ -2,13 +2,13 @@ processed 21 tasks task 4 'run'. lines 10-24: { - "gas_used": 211680, + "gas_used": 215178, "status": "Executed" } task 5 'run'. lines 27-37: { - "gas_used": 157138, + "gas_used": 161219, "status": "Executed" } @@ -20,13 +20,13 @@ task 6 'run'. lines 40-62: task 8 'run'. lines 68-84: { - "gas_used": 146072, + "gas_used": 147821, "status": "Executed" } task 9 'run'. lines 87-103: { - "gas_used": 138372, + "gas_used": 140121, "status": "Executed" } @@ -38,13 +38,13 @@ task 11 'run'. lines 109-127: task 12 'run'. lines 131-151: { - "gas_used": 152429, + "gas_used": 154178, "status": "Executed" } task 13 'run'. lines 154-187: { - "gas_used": 498282, + "gas_used": 501780, "status": "Executed" } @@ -56,7 +56,7 @@ task 15 'run'. lines 194-216: task 17 'run'. lines 223-235: { - "gas_used": 30578, + "gas_used": 32327, "status": { "MoveAbort": { "location": { @@ -72,12 +72,12 @@ task 17 'run'. lines 223-235: task 18 'run'. lines 238-254: { - "gas_used": 155460, + "gas_used": 162456, "status": "Executed" } task 20 'run'. lines 261-275: { - "gas_used": 69654, + "gas_used": 76650, "status": "Executed" } diff --git a/integration-tests/dao/test_mint_dao_proposal.exp b/integration-tests/dao/test_mint_dao_proposal.exp index 8876d796..18770d66 100644 --- a/integration-tests/dao/test_mint_dao_proposal.exp +++ b/integration-tests/dao/test_mint_dao_proposal.exp @@ -20,7 +20,7 @@ task 7 'run'. lines 71-82: task 8 'run'. lines 85-98: { - "gas_used": 117725, + "gas_used": 119474, "status": "Executed" } @@ -58,19 +58,19 @@ task 10 'run'. lines 113-124: task 11 'run'. lines 127-137: { - "gas_used": 159206, + "gas_used": 163287, "status": "Executed" } task 12 'run'. lines 140-150: { - "gas_used": 145729, + "gas_used": 149810, "status": "Executed" } task 14 'run'. lines 156-172: { - "gas_used": 139354, + "gas_used": 141103, "status": "Executed" } @@ -82,6 +82,6 @@ task 16 'run'. lines 177-198: task 18 'run'. lines 204-222: { - "gas_used": 153789, + "gas_used": 160785, "status": "Executed" } diff --git a/integration-tests/debug/debug.exp b/integration-tests/debug/debug.exp index 0f034da4..e7c5034b 100644 --- a/integration-tests/debug/debug.exp +++ b/integration-tests/debug/debug.exp @@ -2,6 +2,6 @@ processed 4 tasks task 3 'run'. lines 42-51: { - "gas_used": 23391, + "gas_used": 32136, "status": "Executed" } diff --git a/integration-tests/epoch/adjust_epoch_block_time_max.exp b/integration-tests/epoch/adjust_epoch_block_time_max.exp index 28237215..557c38f3 100644 --- a/integration-tests/epoch/adjust_epoch_block_time_max.exp +++ b/integration-tests/epoch/adjust_epoch_block_time_max.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-40: { - "gas_used": 26693545, + "gas_used": 26784493, "status": "Executed" } diff --git a/integration-tests/epoch/adjust_epoch_block_time_min.exp b/integration-tests/epoch/adjust_epoch_block_time_min.exp index 48ce10b5..26d69a66 100644 --- a/integration-tests/epoch/adjust_epoch_block_time_min.exp +++ b/integration-tests/epoch/adjust_epoch_block_time_min.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 6-37: { - "gas_used": 26475471, + "gas_used": 26510451, "status": "Executed" } diff --git a/integration-tests/epoch/adjust_epoch_failed.exp b/integration-tests/epoch/adjust_epoch_failed.exp index 101e63fe..290eedb7 100644 --- a/integration-tests/epoch/adjust_epoch_failed.exp +++ b/integration-tests/epoch/adjust_epoch_failed.exp @@ -72,6 +72,6 @@ task 7 'run'. lines 70-83: task 8 'run'. lines 86-99: { - "gas_used": 168736, + "gas_used": 172234, "status": "Executed" } diff --git a/integration-tests/epoch/adjust_gas_limit.exp b/integration-tests/epoch/adjust_gas_limit.exp index a62af53b..86456c65 100644 --- a/integration-tests/epoch/adjust_gas_limit.exp +++ b/integration-tests/epoch/adjust_gas_limit.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-45: { - "gas_used": 189806, + "gas_used": 218956, "status": "Executed" } diff --git a/integration-tests/incubator/SortedLinkedList.exp b/integration-tests/incubator/SortedLinkedList.exp index 89d0b2e3..a9c13f13 100644 --- a/integration-tests/incubator/SortedLinkedList.exp +++ b/integration-tests/incubator/SortedLinkedList.exp @@ -2,7 +2,7 @@ processed 33 tasks task 9 'run'. lines 283-291: { - "gas_used": 39270, + "gas_used": 43351, "status": "Executed" } @@ -24,85 +24,85 @@ task 10 'run'. lines 293-303: task 11 'run'. lines 305-317: { - "gas_used": 181245, + "gas_used": 295543, "status": "Executed" } task 12 'run'. lines 319-331: { - "gas_used": 237953, + "gas_used": 399474, "status": "Executed" } task 13 'run'. lines 333-343: { - "gas_used": 263069, + "gas_used": 467732, "status": "Executed" } task 14 'run'. lines 345-365: { - "gas_used": 83519, + "gas_used": 116167, "status": "Executed" } task 15 'run'. lines 367-377: { - "gas_used": 66269, + "gas_used": 83789, "status": "Executed" } task 16 'run'. lines 379-389: { - "gas_used": 58771, + "gas_used": 73959, "status": "Executed" } task 17 'run'. lines 391-401: { - "gas_used": 89906, + "gas_used": 117337, "status": "Executed" } task 19 'run'. lines 504-512: { - "gas_used": 49972, + "gas_used": 59883, "status": "Executed" } task 20 'run'. lines 514-523: { - "gas_used": 159757, + "gas_used": 212840, "status": "Executed" } task 21 'run'. lines 525-534: { - "gas_used": 184121, + "gas_used": 247698, "status": "Executed" } task 22 'run'. lines 536-545: { - "gas_used": 216663, + "gas_used": 298896, "status": "Executed" } task 23 'run'. lines 547-557: { - "gas_used": 26844, + "gas_used": 30925, "status": "Executed" } task 24 'run'. lines 559-568: { - "gas_used": 91963, + "gas_used": 112398, "status": "Executed" } task 25 'run'. lines 570-580: { - "gas_used": 28739, + "gas_used": 31071, "status": { "MoveAbort": { "location": "Script", @@ -113,6 +113,6 @@ task 25 'run'. lines 570-580: task 32 'run'. lines 595-605: { - "gas_used": 113223, + "gas_used": 138322, "status": "Executed" } diff --git a/integration-tests/list/linked_list.exp b/integration-tests/list/linked_list.exp index 4c717d80..0f097a89 100644 --- a/integration-tests/list/linked_list.exp +++ b/integration-tests/list/linked_list.exp @@ -2,13 +2,13 @@ processed 16 tasks task 9 'run'. lines 386-395: { - "gas_used": 32583, + "gas_used": 34332, "status": "Executed" } task 10 'run'. lines 397-410: { - "gas_used": 113594, + "gas_used": 135748, "status": "Executed" } @@ -20,13 +20,13 @@ task 11 'run'. lines 412-420: task 12 'run'. lines 422-431: { - "gas_used": 36706, + "gas_used": 40204, "status": "Executed" } task 13 'run'. lines 433-445: { - "gas_used": 24191, + "gas_used": 25940, "status": { "MoveAbort": { "location": { @@ -48,6 +48,6 @@ task 14 'run'. lines 447-455: task 15 'run'. lines 457-469: { - "gas_used": 63320, + "gas_used": 65069, "status": "Executed" } diff --git a/integration-tests/math/sum_avg.exp b/integration-tests/math/sum_avg.exp index 8711c0ad..a625d5fa 100644 --- a/integration-tests/math/sum_avg.exp +++ b/integration-tests/math/sum_avg.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-20: { - "gas_used": 443725, + "gas_used": 1150321, "status": "Executed" } diff --git a/integration-tests/move/option.exp b/integration-tests/move/option.exp index 16815f7e..74d19a4b 100644 --- a/integration-tests/move/option.exp +++ b/integration-tests/move/option.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-43: { - "gas_used": 148623, + "gas_used": 221498, "status": "Executed" } diff --git a/integration-tests/natives/signature.exp b/integration-tests/natives/signature.exp index b4b8e5b3..e8324e4c 100644 --- a/integration-tests/natives/signature.exp +++ b/integration-tests/natives/signature.exp @@ -14,19 +14,19 @@ task 3 'run'. lines 28-50: task 4 'run'. lines 52-87: { - "gas_used": 128986, + "gas_used": 170379, "status": "Executed" } task 5 'run'. lines 91-104: { - "gas_used": 50479, + "gas_used": 65054, "status": "Executed" } task 6 'run'. lines 106-119: { - "gas_used": 35065, + "gas_used": 42061, "status": { "MoveAbort": { "location": { @@ -42,7 +42,7 @@ task 6 'run'. lines 106-119: task 7 'run'. lines 121-141: { - "gas_used": 81887, + "gas_used": 103458, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/nft/identifier_nft.exp b/integration-tests/nft/identifier_nft.exp index d413aebc..827525d5 100644 --- a/integration-tests/nft/identifier_nft.exp +++ b/integration-tests/nft/identifier_nft.exp @@ -2,30 +2,30 @@ processed 11 tasks task 5 'run'. lines 127-135: { - "gas_used": 144163, + "gas_used": 151159, "status": "Executed" } task 6 'run'. lines 137-145: { - "gas_used": 161342, + "gas_used": 175917, "status": "Executed" } task 7 'run'. lines 147-155: { - "gas_used": 124539, + "gas_used": 135616, "status": "Executed" } task 8 'run'. lines 158-166: { - "gas_used": 78598, + "gas_used": 95505, "status": "Executed" } task 10 'run'. lines 171-179: { - "gas_used": 184860, + "gas_used": 191856, "status": "Executed" } diff --git a/integration-tests/nft/nft_boxminer.exp b/integration-tests/nft/nft_boxminer.exp index 69cd1700..fdcc0d7c 100644 --- a/integration-tests/nft/nft_boxminer.exp +++ b/integration-tests/nft/nft_boxminer.exp @@ -2,12 +2,12 @@ processed 6 tasks task 4 'run'. lines 59-67: { - "gas_used": 138899, + "gas_used": 144146, "status": "Executed" } task 5 'run'. lines 69-79: { - "gas_used": 246271, + "gas_used": 255599, "status": "Executed" } diff --git a/integration-tests/nft/nft_card.exp b/integration-tests/nft/nft_card.exp index 707972b7..6db4809c 100644 --- a/integration-tests/nft/nft_card.exp +++ b/integration-tests/nft/nft_card.exp @@ -2,30 +2,30 @@ processed 9 tasks task 4 'run'. lines 84-92: { - "gas_used": 239660, + "gas_used": 253652, "status": "Executed" } task 5 'run'. lines 94-104: { - "gas_used": 159814, + "gas_used": 169142, "status": "Executed" } task 6 'run'. lines 106-119: { - "gas_used": 114058, + "gas_used": 123386, "status": "Executed" } task 7 'run'. lines 122-134: { - "gas_used": 377567, + "gas_used": 441697, "status": "Executed" } task 8 'run'. lines 136-148: { - "gas_used": 32831, + "gas_used": 36329, "status": "Executed" } diff --git a/integration-tests/nft/nft_metadata.exp b/integration-tests/nft/nft_metadata.exp index b77c1c72..87525f1c 100644 --- a/integration-tests/nft/nft_metadata.exp +++ b/integration-tests/nft/nft_metadata.exp @@ -2,25 +2,25 @@ processed 10 tasks task 4 'run'. lines 91-99: { - "gas_used": 143842, + "gas_used": 150838, "status": "Executed" } task 5 'run'. lines 101-113: { - "gas_used": 243409, + "gas_used": 260316, "status": "Executed" } task 7 'run'. lines 118-130: { - "gas_used": 280680, + "gas_used": 337814, "status": "Executed" } task 8 'run'. lines 132-152: { - "gas_used": 105874, + "gas_used": 135024, "status": { "MoveAbort": { "location": "Script", @@ -31,6 +31,6 @@ task 8 'run'. lines 132-152: task 9 'run'. lines 155-180: { - "gas_used": 71808, + "gas_used": 77055, "status": "Executed" } diff --git a/integration-tests/nft/test_gallery.exp b/integration-tests/nft/test_gallery.exp index aa4e0761..f80f97fb 100644 --- a/integration-tests/nft/test_gallery.exp +++ b/integration-tests/nft/test_gallery.exp @@ -2,78 +2,78 @@ processed 18 tasks task 5 'run'. lines 71-79: { - "gas_used": 201857, + "gas_used": 210602, "status": "Executed" } task 6 'run'. lines 81-89: { - "gas_used": 84120, + "gas_used": 85869, "status": "Executed" } task 7 'run'. lines 92-106: { - "gas_used": 49403, + "gas_used": 63395, "status": "Executed" } task 8 'run'. lines 108-116: { - "gas_used": 101009, + "gas_used": 108588, "status": "Executed" } task 9 'run'. lines 118-134: { - "gas_used": 87357, + "gas_used": 118839, "status": "Executed" } task 10 'run'. lines 136-144: { - "gas_used": 17124601, + "gas_used": 18640401, "status": "Executed" } task 11 'run'. lines 148-161: { - "gas_used": 2174933, + "gas_used": 3117644, "status": "Executed" } task 12 'run'. lines 164-185: { - "gas_used": 18928360, + "gas_used": 28244700, "status": "Executed" } task 13 'run'. lines 187-206: { - "gas_used": 1843783, + "gas_used": 2312515, "status": "Executed" } task 14 'run'. lines 208-220: { - "gas_used": 20635, + "gas_used": 22384, "status": "Executed" } task 15 'run'. lines 224-234: { - "gas_used": 126484, + "gas_used": 153885, "status": "Executed" } task 16 'run'. lines 237-251: { - "gas_used": 1554530, + "gas_used": 2055910, "status": "Executed" } task 17 'run'. lines 253-267: { - "gas_used": 298636, + "gas_used": 337114, "status": "Executed" } diff --git a/integration-tests/nft/test_genesis_nft.exp b/integration-tests/nft/test_genesis_nft.exp index a23d90df..77e7421b 100644 --- a/integration-tests/nft/test_genesis_nft.exp +++ b/integration-tests/nft/test_genesis_nft.exp @@ -2,7 +2,7 @@ processed 3 tasks task 2 'run'. lines 6-22: { - "gas_used": 72855, + "gas_used": 87430, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/nft/test_nft.exp b/integration-tests/nft/test_nft.exp index 915702fa..b865a27e 100644 --- a/integration-tests/nft/test_nft.exp +++ b/integration-tests/nft/test_nft.exp @@ -2,24 +2,24 @@ processed 8 tasks task 4 'run'. lines 41-52: { - "gas_used": 279900, + "gas_used": 296224, "status": "Executed" } task 5 'run'. lines 54-65: { - "gas_used": 84272, + "gas_used": 86021, "status": "Executed" } task 6 'run'. lines 67-78: { - "gas_used": 158104, + "gas_used": 197748, "status": "Executed" } task 7 'run'. lines 80-91: { - "gas_used": 69542, + "gas_used": 91113, "status": "Executed" } diff --git a/integration-tests/offer/offer.exp b/integration-tests/offer/offer.exp index dddafff7..5f09c5d1 100644 --- a/integration-tests/offer/offer.exp +++ b/integration-tests/offer/offer.exp @@ -2,7 +2,7 @@ processed 10 tasks task 4 'run'. lines 9-32: { - "gas_used": 85567, + "gas_used": 87316, "status": "Executed" } diff --git a/integration-tests/on_chain_config/config.exp b/integration-tests/on_chain_config/config.exp index 54fc6ce2..99396d9f 100644 --- a/integration-tests/on_chain_config/config.exp +++ b/integration-tests/on_chain_config/config.exp @@ -2,31 +2,31 @@ processed 12 tasks task 4 'run'. lines 67-74: { - "gas_used": 63255, + "gas_used": 67336, "status": "Executed" } task 5 'run'. lines 77-84: { - "gas_used": 87827, + "gas_used": 95406, "status": "Executed" } task 6 'run'. lines 86-96: { - "gas_used": 61796, + "gas_used": 67058, "status": "Executed" } task 7 'run'. lines 99-106: { - "gas_used": 34478, + "gas_used": 37976, "status": "Executed" } task 8 'run'. lines 108-118: { - "gas_used": 24120, + "gas_used": 25869, "status": { "MoveAbort": { "location": { @@ -48,12 +48,12 @@ task 9 'run'. lines 120-129: task 10 'run'. lines 132-139: { - "gas_used": 58925, + "gas_used": 63006, "status": "Executed" } task 11 'run'. lines 142-152: { - "gas_used": 61796, + "gas_used": 67058, "status": "Executed" } diff --git a/integration-tests/on_chain_config/test_onchain_config_dao.exp b/integration-tests/on_chain_config/test_onchain_config_dao.exp index 35861e59..a164e7ed 100644 --- a/integration-tests/on_chain_config/test_onchain_config_dao.exp +++ b/integration-tests/on_chain_config/test_onchain_config_dao.exp @@ -2,7 +2,7 @@ processed 14 tasks task 4 'run'. lines 10-21: { - "gas_used": 211680, + "gas_used": 215178, "status": "Executed" } @@ -24,13 +24,13 @@ task 5 'run'. lines 22-31: task 6 'run'. lines 32-42: { - "gas_used": 156824, + "gas_used": 160905, "status": "Executed" } task 8 'run'. lines 47-60: { - "gas_used": 146072, + "gas_used": 147821, "status": "Executed" } @@ -42,6 +42,6 @@ task 11 'run'. lines 67-87: task 13 'run'. lines 92-106: { - "gas_used": 111895, + "gas_used": 118891, "status": "Executed" } diff --git a/integration-tests/oracle/EasyGas.exp b/integration-tests/oracle/EasyGas.exp new file mode 100644 index 00000000..000940fb --- /dev/null +++ b/integration-tests/oracle/EasyGas.exp @@ -0,0 +1,13 @@ +processed 6 tasks + +task 4 'run'. lines 12-19: +{ + "gas_used": 45211, + "status": "Executed" +} + +task 5 'run'. lines 21-33: +{ + "gas_used": 207236, + "status": "Executed" +} diff --git a/integration-tests/oracle/EasyGas.move b/integration-tests/oracle/EasyGas.move new file mode 100644 index 00000000..e543c339 --- /dev/null +++ b/integration-tests/oracle/EasyGas.move @@ -0,0 +1,33 @@ +//# init -n dev + +//# faucet --addr alice + +//# faucet --addr bob + +//# publish +module alice::STAR { + struct STAR has store, copy, drop {} +} + +//# run --signers alice +script { + use StarcoinFramework::EasyGasOracle; + + fun main(signer: signer) { + EasyGasOracle::register_gas_token_entry(&signer, @alice, b"STAR", b"STAR", @bob); + } +} + +//# run --signers bob +script { + use alice::STAR::STAR; + use StarcoinFramework::EasyGasOracle; + + fun main(signer: signer) { + EasyGasOracle::register(&signer, 9); + EasyGasOracle::init_data_source(&signer, 0); + EasyGasOracle::update(&signer, 100); + let star_price= EasyGasOracle::gas_oracle_read(); + assert!(star_price==100,1000); + } +} \ No newline at end of file diff --git a/integration-tests/oracle/oracle.exp b/integration-tests/oracle/oracle.exp index 87c57255..1528f9f7 100644 --- a/integration-tests/oracle/oracle.exp +++ b/integration-tests/oracle/oracle.exp @@ -38,7 +38,7 @@ task 11 'run'. lines 76-84: task 13 'run'. lines 89-103: { - "gas_used": 48457, + "gas_used": 76441, "status": { "MoveAbort": { "location": { @@ -54,7 +54,7 @@ task 13 'run'. lines 89-103: task 14 'run'. lines 106-120: { - "gas_used": 48457, + "gas_used": 76441, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/package_txn_manager/cancel_upgrade_plan.exp b/integration-tests/package_txn_manager/cancel_upgrade_plan.exp index 66d22c36..cda16aa7 100644 --- a/integration-tests/package_txn_manager/cancel_upgrade_plan.exp +++ b/integration-tests/package_txn_manager/cancel_upgrade_plan.exp @@ -8,13 +8,13 @@ task 3 'run'. lines 8-19: task 4 'run'. lines 21-35: { - "gas_used": 143983, + "gas_used": 161473, "status": "Executed" } task 5 'run'. lines 36-46: { - "gas_used": 29039, + "gas_used": 30788, "status": { "MoveAbort": { "location": { @@ -30,12 +30,12 @@ task 5 'run'. lines 36-46: task 6 'run'. lines 48-57: { - "gas_used": 46014, + "gas_used": 50095, "status": "Executed" } task 7 'run'. lines 59-67: { - "gas_used": 31514, + "gas_used": 35012, "status": "Executed" } diff --git a/integration-tests/package_txn_manager/only_new_module.exp b/integration-tests/package_txn_manager/only_new_module.exp index a90099eb..2a3ff721 100644 --- a/integration-tests/package_txn_manager/only_new_module.exp +++ b/integration-tests/package_txn_manager/only_new_module.exp @@ -2,7 +2,7 @@ processed 11 tasks task 3 'run'. lines 7-18: { - "gas_used": 89764, + "gas_used": 97926, "status": "Executed" } diff --git a/integration-tests/package_txn_manager/override_upgrade_plan.exp b/integration-tests/package_txn_manager/override_upgrade_plan.exp index bf6d6a19..9d1d70e0 100644 --- a/integration-tests/package_txn_manager/override_upgrade_plan.exp +++ b/integration-tests/package_txn_manager/override_upgrade_plan.exp @@ -8,30 +8,30 @@ task 3 'run'. lines 7-17: task 4 'run'. lines 19-31: { - "gas_used": 143983, + "gas_used": 161473, "status": "Executed" } task 5 'run'. lines 33-42: { - "gas_used": 46014, + "gas_used": 50095, "status": "Executed" } task 7 'run'. lines 46-55: { - "gas_used": 46014, + "gas_used": 50095, "status": "Executed" } task 9 'run'. lines 59-74: { - "gas_used": 45870, + "gas_used": 51700, "status": "Executed" } task 11 'run'. lines 79-89: { - "gas_used": 45870, + "gas_used": 51700, "status": "Executed" } diff --git a/integration-tests/package_txn_manager/package_txn_manager.exp b/integration-tests/package_txn_manager/package_txn_manager.exp index ba4aa0e0..68afa2ec 100644 --- a/integration-tests/package_txn_manager/package_txn_manager.exp +++ b/integration-tests/package_txn_manager/package_txn_manager.exp @@ -8,13 +8,13 @@ task 3 'run'. lines 8-19: task 4 'run'. lines 21-35: { - "gas_used": 143983, + "gas_used": 161473, "status": "Executed" } task 5 'run'. lines 36-46: { - "gas_used": 29039, + "gas_used": 30788, "status": { "MoveAbort": { "location": { @@ -30,13 +30,13 @@ task 5 'run'. lines 36-46: task 6 'run'. lines 48-59: { - "gas_used": 46014, + "gas_used": 50095, "status": "Executed" } task 7 'run'. lines 60-70: { - "gas_used": 44456, + "gas_used": 50286, "status": { "MoveAbort": { "location": { @@ -52,19 +52,19 @@ task 7 'run'. lines 60-70: task 9 'run'. lines 74-86: { - "gas_used": 45870, + "gas_used": 51700, "status": "Executed" } task 10 'run'. lines 87-97: { - "gas_used": 31514, + "gas_used": 35012, "status": "Executed" } task 11 'run'. lines 98-106: { - "gas_used": 26973, + "gas_used": 28722, "status": { "MoveAbort": { "location": { @@ -80,7 +80,7 @@ task 11 'run'. lines 98-106: task 12 'run'. lines 108-117: { - "gas_used": 30614, + "gas_used": 34695, "status": { "MoveAbort": { "location": { @@ -96,12 +96,12 @@ task 12 'run'. lines 108-117: task 13 'run'. lines 119-128: { - "gas_used": 116190, + "gas_used": 120271, "status": "Executed" } task 14 'run'. lines 132-140: { - "gas_used": 33154, + "gas_used": 37235, "status": "Executed" } diff --git a/integration-tests/ring/rind_set.exp b/integration-tests/ring/rind_set.exp index 012bcb24..aa086b48 100644 --- a/integration-tests/ring/rind_set.exp +++ b/integration-tests/ring/rind_set.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-28: { - "gas_used": 308424, + "gas_used": 504402, "status": "Executed" } diff --git a/integration-tests/ring/ring_add.exp b/integration-tests/ring/ring_add.exp index 6043e070..f9050d53 100644 --- a/integration-tests/ring/ring_add.exp +++ b/integration-tests/ring/ring_add.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-15: { - "gas_used": 97697, + "gas_used": 161827, "status": "Executed" } diff --git a/integration-tests/ring/ring_borrow.exp b/integration-tests/ring/ring_borrow.exp index 138249e0..cd890466 100644 --- a/integration-tests/ring/ring_borrow.exp +++ b/integration-tests/ring/ring_borrow.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-28: { - "gas_used": 282808, + "gas_used": 463613, "status": "Executed" } diff --git a/integration-tests/ring/ring_borrow_mut.exp b/integration-tests/ring/ring_borrow_mut.exp index 8f03e468..18d3800a 100644 --- a/integration-tests/ring/ring_borrow_mut.exp +++ b/integration-tests/ring/ring_borrow_mut.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-33: { - "gas_used": 281876, + "gas_used": 453936, "status": "Executed" } diff --git a/integration-tests/ring/ring_index_of.exp b/integration-tests/ring/ring_index_of.exp index 0a2a0315..440b0d7b 100644 --- a/integration-tests/ring/ring_index_of.exp +++ b/integration-tests/ring/ring_index_of.exp @@ -2,19 +2,19 @@ processed 6 tasks task 2 'run'. lines 5-33: { - "gas_used": 653133, + "gas_used": 1052055, "status": "Executed" } task 3 'run'. lines 35-68: { - "gas_used": 670524, + "gas_used": 1072944, "status": "Executed" } task 4 'run'. lines 71-93: { - "gas_used": 257484, + "gas_used": 414461, "status": { "MoveAbort": { "location": { @@ -30,7 +30,7 @@ task 4 'run'. lines 71-93: task 5 'run'. lines 96-118: { - "gas_used": 257568, + "gas_used": 414545, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/shared_ed25519_public_key/shared_key.exp b/integration-tests/shared_ed25519_public_key/shared_key.exp index 6530ef85..5fa8d387 100644 --- a/integration-tests/shared_ed25519_public_key/shared_key.exp +++ b/integration-tests/shared_ed25519_public_key/shared_key.exp @@ -2,7 +2,7 @@ processed 7 tasks task 2 'run'. lines 6-38: { - "gas_used": 117356, + "gas_used": 132514, "status": "Executed" } diff --git a/integration-tests/signer_capability/create_signer.exp b/integration-tests/signer_capability/create_signer.exp index 3f1ea44d..367708e3 100644 --- a/integration-tests/signer_capability/create_signer.exp +++ b/integration-tests/signer_capability/create_signer.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-16: { - "gas_used": 81473, + "gas_used": 88469, "status": "Executed" } diff --git a/integration-tests/signer_capability/destroy_signer.exp b/integration-tests/signer_capability/destroy_signer.exp index c6e0af2a..6e3805cd 100644 --- a/integration-tests/signer_capability/destroy_signer.exp +++ b/integration-tests/signer_capability/destroy_signer.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-22: { - "gas_used": 76041, + "gas_used": 83037, "status": "Executed" } diff --git a/integration-tests/token/burn_and_destroy.exp b/integration-tests/token/burn_and_destroy.exp index bc4cddc7..9574f3bb 100644 --- a/integration-tests/token/burn_and_destroy.exp +++ b/integration-tests/token/burn_and_destroy.exp @@ -20,7 +20,7 @@ task 6 'run'. lines 57-65: task 7 'run'. lines 67-82: { - "gas_used": 68287, + "gas_used": 70036, "status": { "MoveAbort": { "location": { @@ -42,7 +42,7 @@ task 8 'run'. lines 84-96: task 9 'run'. lines 98-109: { - "gas_used": 81241, + "gas_used": 84739, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/token/create_account_with_token.exp b/integration-tests/token/create_account_with_token.exp index a5b05af4..e9f6e232 100644 --- a/integration-tests/token/create_account_with_token.exp +++ b/integration-tests/token/create_account_with_token.exp @@ -2,12 +2,12 @@ processed 4 tasks task 2 'run'. lines 5-19: { - "gas_used": 322214, + "gas_used": 410247, "status": "Executed" } task 3 'run'. lines 23-37: { - "gas_used": 348347, + "gas_used": 436380, "status": "Executed" } diff --git a/integration-tests/token/mint_stc.exp b/integration-tests/token/mint_stc.exp index 8004b37e..24ef7a2f 100644 --- a/integration-tests/token/mint_stc.exp +++ b/integration-tests/token/mint_stc.exp @@ -19,6 +19,6 @@ task 3 'run'. lines 7-27: task 4 'run'. lines 31-49: { - "gas_used": 111781, + "gas_used": 113530, "status": "Executed" } diff --git a/integration-tests/token/my_token.exp b/integration-tests/token/my_token.exp index 20191a8b..2d5be90f 100644 --- a/integration-tests/token/my_token.exp +++ b/integration-tests/token/my_token.exp @@ -20,12 +20,12 @@ task 7 'run'. lines 78-86: task 8 'run'. lines 89-97: { - "gas_used": 104310, + "gas_used": 106059, "status": "Executed" } task 9 'run'. lines 99-109: { - "gas_used": 59081, + "gas_used": 60830, "status": "Executed" } diff --git a/integration-tests/token/transfer_then_abort.exp b/integration-tests/token/transfer_then_abort.exp index 3ecc3ad3..59023890 100644 --- a/integration-tests/token/transfer_then_abort.exp +++ b/integration-tests/token/transfer_then_abort.exp @@ -2,7 +2,7 @@ processed 5 tasks task 3 'run'. lines 7-18: { - "gas_used": 88299, + "gas_used": 90048, "status": { "MoveAbort": { "location": "Script", diff --git a/integration-tests/transaction_fee/distribute_txn_fee.exp b/integration-tests/transaction_fee/distribute_txn_fee.exp index abf30643..96846fb0 100644 --- a/integration-tests/transaction_fee/distribute_txn_fee.exp +++ b/integration-tests/transaction_fee/distribute_txn_fee.exp @@ -2,7 +2,7 @@ processed 7 tasks task 4 'run'. lines 9-20: { - "gas_used": 72509, + "gas_used": 74258, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/create_account.exp b/integration-tests/transaction_scripts/create_account.exp index 89ac6709..14d65ee8 100644 --- a/integration-tests/transaction_scripts/create_account.exp +++ b/integration-tests/transaction_scripts/create_account.exp @@ -2,6 +2,6 @@ processed 4 tasks task 3 'run'. lines 8-16: { - "gas_used": 355078, + "gas_used": 366738, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/execute_modify_dao_config_proposal.exp b/integration-tests/transaction_scripts/execute_modify_dao_config_proposal.exp index 38878d7b..600162a9 100644 --- a/integration-tests/transaction_scripts/execute_modify_dao_config_proposal.exp +++ b/integration-tests/transaction_scripts/execute_modify_dao_config_proposal.exp @@ -2,13 +2,13 @@ processed 12 tasks task 4 'run'. lines 11-24: { - "gas_used": 157288, + "gas_used": 161369, "status": "Executed" } task 6 'run'. lines 28-47: { - "gas_used": 151011, + "gas_used": 152760, "status": "Executed" } @@ -26,6 +26,6 @@ task 9 'run'. lines 70-86: task 11 'run'. lines 89-101: { - "gas_used": 107409, + "gas_used": 112656, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/execute_on_chain_config_proposal.exp b/integration-tests/transaction_scripts/execute_on_chain_config_proposal.exp index 784408f3..12431747 100644 --- a/integration-tests/transaction_scripts/execute_on_chain_config_proposal.exp +++ b/integration-tests/transaction_scripts/execute_on_chain_config_proposal.exp @@ -2,13 +2,13 @@ processed 12 tasks task 4 'run'. lines 10-20: { - "gas_used": 163350, + "gas_used": 167431, "status": "Executed" } task 6 'run'. lines 23-43: { - "gas_used": 151011, + "gas_used": 152760, "status": "Executed" } @@ -26,6 +26,6 @@ task 9 'run'. lines 66-83: task 11 'run'. lines 87-99: { - "gas_used": 81514, + "gas_used": 86761, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/module_upgrade.exp b/integration-tests/transaction_scripts/module_upgrade.exp index 2df93259..2fb6f89e 100644 --- a/integration-tests/transaction_scripts/module_upgrade.exp +++ b/integration-tests/transaction_scripts/module_upgrade.exp @@ -2,13 +2,13 @@ processed 15 tasks task 5 'run'. lines 27-39: { - "gas_used": 326064, + "gas_used": 330145, "status": "Executed" } task 6 'run'. lines 41-52: { - "gas_used": 143983, + "gas_used": 161473, "status": "Executed" } @@ -20,13 +20,13 @@ task 7 'run'. lines 54-64: task 8 'run'. lines 67-86: { - "gas_used": 158774, + "gas_used": 162855, "status": "Executed" } task 10 'run'. lines 92-109: { - "gas_used": 118835, + "gas_used": 120584, "status": "Executed" } @@ -38,6 +38,6 @@ task 12 'run'. lines 113-126: task 14 'run'. lines 131-140: { - "gas_used": 77775, + "gas_used": 87103, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/peer_to_peer.exp b/integration-tests/transaction_scripts/peer_to_peer.exp index a5da4f6c..3a1d1361 100644 --- a/integration-tests/transaction_scripts/peer_to_peer.exp +++ b/integration-tests/transaction_scripts/peer_to_peer.exp @@ -2,12 +2,12 @@ processed 5 tasks task 3 'run'. lines 9-17: { - "gas_used": 114566, + "gas_used": 116315, "status": "Executed" } task 4 'run'. lines 19-27: { - "gas_used": 110327, + "gas_used": 112076, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/peer_to_peer_with_metadata.exp b/integration-tests/transaction_scripts/peer_to_peer_with_metadata.exp index f1b0013f..51157852 100644 --- a/integration-tests/transaction_scripts/peer_to_peer_with_metadata.exp +++ b/integration-tests/transaction_scripts/peer_to_peer_with_metadata.exp @@ -2,12 +2,12 @@ processed 5 tasks task 3 'run'. lines 8-16: { - "gas_used": 112102, + "gas_used": 113851, "status": "Executed" } task 4 'run'. lines 18-26: { - "gas_used": 107278, + "gas_used": 109027, "status": "Executed" } diff --git a/integration-tests/u256/test_u256_gas.exp b/integration-tests/u256/test_u256_gas.exp index 583fa0f0..fdf9922f 100644 --- a/integration-tests/u256/test_u256_gas.exp +++ b/integration-tests/u256/test_u256_gas.exp @@ -2,48 +2,48 @@ processed 10 tasks task 2 'run'. lines 5-11: { - "gas_used": 20666, + "gas_used": 31743, "status": "Executed" } task 3 'run'. lines 13-20: { - "gas_used": 20632, + "gas_used": 31709, "status": "Executed" } task 4 'run'. lines 23-30: { - "gas_used": 17727, + "gas_used": 28804, "status": "Executed" } task 5 'run'. lines 31-38: { - "gas_used": 18339, + "gas_used": 24169, "status": "Executed" } task 6 'run'. lines 39-48: { - "gas_used": 40610, + "gas_used": 62764, "status": "Executed" } task 7 'run'. lines 49-58: { - "gas_used": 40474, + "gas_used": 62628, "status": "Executed" } task 8 'run'. lines 59-68: { - "gas_used": 40474, + "gas_used": 62628, "status": "Executed" } task 9 'run'. lines 69-78: { - "gas_used": 40616, + "gas_used": 62770, "status": "Executed" } diff --git a/integration-tests/upgrade_module_dao_proposal/basic.exp b/integration-tests/upgrade_module_dao_proposal/basic.exp index 34aa5efa..d5b25842 100644 --- a/integration-tests/upgrade_module_dao_proposal/basic.exp +++ b/integration-tests/upgrade_module_dao_proposal/basic.exp @@ -2,7 +2,7 @@ processed 19 tasks task 5 'run'. lines 25-40: { - "gas_used": 249651, + "gas_used": 253732, "status": "Executed" } @@ -20,7 +20,7 @@ task 7 'run'. lines 58-68: task 8 'run'. lines 70-80: { - "gas_used": 143983, + "gas_used": 161473, "status": "Executed" } @@ -64,13 +64,13 @@ task 11 'run'. lines 110-129: task 12 'run'. lines 131-150: { - "gas_used": 158774, + "gas_used": 162855, "status": "Executed" } task 14 'run'. lines 155-171: { - "gas_used": 146311, + "gas_used": 148060, "status": "Executed" } @@ -82,6 +82,6 @@ task 16 'run'. lines 175-189: task 18 'run'. lines 193-206: { - "gas_used": 97672, + "gas_used": 108749, "status": "Executed" } diff --git a/integration-tests/vector/big_vector.exp b/integration-tests/vector/big_vector.exp index 6a31ab38..d1a01ffd 100644 --- a/integration-tests/vector/big_vector.exp +++ b/integration-tests/vector/big_vector.exp @@ -2,48 +2,48 @@ processed 12 tasks task 4 'run'. lines 75-82: { - "gas_used": 16887880, + "gas_used": 28551961, "status": "Executed" } task 5 'run'. lines 84-91: { - "gas_used": 32075, + "gas_used": 38488, "status": "Executed" } task 6 'run'. lines 93-101: { - "gas_used": 11499781, + "gas_used": 23163862, "status": "Executed" } task 7 'run'. lines 103-110: { - "gas_used": 32075, + "gas_used": 38488, "status": "Executed" } task 8 'run'. lines 112-119: { - "gas_used": 15756305, + "gas_used": 39082718, "status": "Executed" } task 9 'run'. lines 121-129: { - "gas_used": 47063, + "gas_used": 53476, "status": "Executed" } task 10 'run'. lines 131-137: { - "gas_used": 7163948, + "gas_used": 7165697, "status": "Executed" } task 11 'run'. lines 139-146: { - "gas_used": 3604802, + "gas_used": 3608883, "status": "Executed" } diff --git a/integration-tests/vector/contains.exp b/integration-tests/vector/contains.exp index f82fb46e..bddc3bcc 100644 --- a/integration-tests/vector/contains.exp +++ b/integration-tests/vector/contains.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-22: { - "gas_used": 35373, + "gas_used": 72685, "status": "Executed" } diff --git a/integration-tests/vector/index_of.exp b/integration-tests/vector/index_of.exp index 592eba09..3927b859 100644 --- a/integration-tests/vector/index_of.exp +++ b/integration-tests/vector/index_of.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-30: { - "gas_used": 32658, + "gas_used": 60059, "status": "Executed" } diff --git a/integration-tests/vector/remove.exp b/integration-tests/vector/remove.exp index 92c88709..b84f4497 100644 --- a/integration-tests/vector/remove.exp +++ b/integration-tests/vector/remove.exp @@ -2,12 +2,12 @@ processed 4 tasks task 2 'run'. lines 5-24: { - "gas_used": 24677, + "gas_used": 49163, "status": "Executed" } task 3 'run'. lines 26-41: { - "gas_used": 18640, + "gas_used": 33798, "status": "Executed" } diff --git a/integration-tests/vector/reverse.exp b/integration-tests/vector/reverse.exp index c2db29b6..cc6460a0 100644 --- a/integration-tests/vector/reverse.exp +++ b/integration-tests/vector/reverse.exp @@ -2,12 +2,12 @@ processed 4 tasks task 2 'run'. lines 5-25: { - "gas_used": 24452, + "gas_used": 49521, "status": "Executed" } task 3 'run'. lines 27-34: { - "gas_used": 12693, + "gas_used": 14442, "status": "Executed" } diff --git a/integration-tests/vector/spawn_from.exp b/integration-tests/vector/spawn_from.exp index a977c117..ed33b077 100644 --- a/integration-tests/vector/spawn_from.exp +++ b/integration-tests/vector/spawn_from.exp @@ -2,12 +2,12 @@ processed 4 tasks task 2 'run'. lines 5-21: { - "gas_used": 10509017, + "gas_used": 33836596, "status": "Executed" } task 3 'run'. lines 24-43: { - "gas_used": 51718, + "gas_used": 84949, "status": "Executed" } diff --git a/integration-tests/vector/split.exp b/integration-tests/vector/split.exp index 3b8d1081..16eed57a 100644 --- a/integration-tests/vector/split.exp +++ b/integration-tests/vector/split.exp @@ -2,12 +2,12 @@ processed 4 tasks task 2 'run'. lines 5-28: { - "gas_used": 37013, + "gas_used": 94147, "status": "Executed" } task 3 'run'. lines 30-57: { - "gas_used": 44321, + "gas_used": 124192, "status": "Executed" } diff --git a/integration-tests/vector/swap_remove.exp b/integration-tests/vector/swap_remove.exp index 76f63c8b..02d58b3a 100644 --- a/integration-tests/vector/swap_remove.exp +++ b/integration-tests/vector/swap_remove.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-24: { - "gas_used": 23595, + "gas_used": 52745, "status": "Executed" } diff --git a/integration-tests/version/basic.exp b/integration-tests/version/basic.exp index 8f676e56..d8d3b3ae 100644 --- a/integration-tests/version/basic.exp +++ b/integration-tests/version/basic.exp @@ -2,7 +2,7 @@ processed 4 tasks task 2 'run'. lines 5-12: { - "gas_used": 57582, + "gas_used": 61663, "status": "Executed" } diff --git a/integration-tests/yield_farming/basic.exp b/integration-tests/yield_farming/basic.exp index 5c21520e..2ab0bc9e 100644 --- a/integration-tests/yield_farming/basic.exp +++ b/integration-tests/yield_farming/basic.exp @@ -14,7 +14,7 @@ task 9 'run'. lines 110-129: task 10 'run'. lines 134-149: { - "gas_used": 124885, + "gas_used": 126634, "status": "Executed" } diff --git a/integration-tests/yield_farming/cap_local_store.exp b/integration-tests/yield_farming/cap_local_store.exp index 66c6318e..8b374b88 100644 --- a/integration-tests/yield_farming/cap_local_store.exp +++ b/integration-tests/yield_farming/cap_local_store.exp @@ -14,7 +14,7 @@ task 9 'run'. lines 101-120: task 10 'run'. lines 122-137: { - "gas_used": 124885, + "gas_used": 126634, "status": "Executed" } diff --git a/sources/Account.move b/sources/Account.move index 0e15332c..5da8b1ef 100644 --- a/sources/Account.move +++ b/sources/Account.move @@ -13,8 +13,10 @@ module Account { use StarcoinFramework::TransactionFee; use StarcoinFramework::CoreAddresses; use StarcoinFramework::Errors; - use StarcoinFramework::STC::{Self, STC}; + use StarcoinFramework::STC::{Self, STC, is_stc}; use StarcoinFramework::BCS; + use StarcoinFramework::Math; + spec module { pragma verify = false; @@ -159,7 +161,7 @@ module Account { const DUMMY_AUTH_KEY:vector = x"0000000000000000000000000000000000000000000000000000000000000000"; // cannot be dummy key, or empty key const CONTRACT_ACCOUNT_AUTH_KEY_PLACEHOLDER:vector = x"0000000000000000000000000000000000000000000000000000000000000001"; - + /// The address bytes length const ADDRESS_LENGTH: u64 = 16; @@ -196,7 +198,6 @@ module Account { let signer_cap = SignerCapability {addr: Token::token_address() }; signer_cap } - #[test_only] public fun get_genesis_capability_for_test(): SignerCapability { get_genesis_capability() @@ -313,7 +314,7 @@ module Account { native fun create_signer(addr: address): signer; - public entry fun create_account_with_initial_amount(account: signer, fresh_address: address, _auth_key: vector, initial_amount: u128) + public entry fun create_account_with_initial_amount(account: signer, fresh_address: address, _auth_key: vector, initial_amount: u128) acquires Account, Balance, AutoAcceptToken { create_account_with_initial_amount_entry(account, fresh_address, initial_amount); } @@ -363,10 +364,11 @@ module Account { (new_address, Self::remove_signer_capability(&new_signer)) } + spec create_delegate_account { pragma verify = false; //TODO write spec - } + } /// Deposits the `to_deposit` token into the self's account balance public fun deposit_to_self(account: &signer, to_deposit: Token) @@ -406,11 +408,11 @@ module Account { to_deposit: Token, metadata: vector, ) acquires Account, Balance, AutoAcceptToken { - + if (!exists_at(receiver)) { create_account_with_address(receiver); }; - + try_accept_token(receiver); let deposit_value = Token::value(&to_deposit); @@ -979,6 +981,35 @@ module Account { txn_authentication_key_preimage: vector, txn_gas_price: u64, txn_max_gas_units: u64, + ) acquires Account, Balance { + txn_prologue_v2( + account, + txn_sender, + txn_sequence_number, + txn_authentication_key_preimage, + txn_gas_price, + txn_max_gas_units, + 1, + 1, + ) + } + spec txn_prologue { + aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS(); + aborts_if !exists(txn_sender); + aborts_if global(txn_sender).authentication_key == DUMMY_AUTH_KEY && Authenticator::spec_derived_address(Hash::sha3_256(txn_authentication_key_preimage)) != txn_sender; + aborts_if global(txn_sender).authentication_key != DUMMY_AUTH_KEY && Hash::sha3_256(txn_authentication_key_preimage) != global(txn_sender).authentication_key; + aborts_if txn_sequence_number < global(txn_sender).sequence_number; + } + + public fun txn_prologue_v2( + account: &signer, + txn_sender: address, + txn_sequence_number: u64, + txn_authentication_key_preimage: vector, + txn_gas_price: u64, + txn_max_gas_units: u64, + stc_price: u128, + stc_price_scaling: u128 ) acquires Account, Balance { CoreAddresses::assert_genesis_address(account); @@ -1003,48 +1034,31 @@ module Account { Errors::invalid_argument(EPROLOGUE_INVALID_ACCOUNT_AUTH_KEY) ); }; - // Check that the account has enough balance for all of the gas + let (max_transaction_fee_stc,max_transaction_fee_token) = transaction_fee_simulate(txn_gas_price,txn_max_gas_units,0, stc_price, stc_price_scaling); assert!( - (txn_gas_price as u128) * (txn_max_gas_units as u128) <= MAX_U64, + max_transaction_fee_stc <= 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(), - Errors::invalid_argument(EBAD_TRANSACTION_FEE_TOKEN) - ); - - let balance_amount = balance(txn_sender); - assert!(balance_amount >= (max_transaction_fee as u128), Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT)); - + if (max_transaction_fee_stc > 0) { assert!( (txn_sequence_number as u128) < MAX_U64, Errors::limit_exceeded(EPROLOGUE_SEQUENCE_NUMBER_TOO_BIG) ); + let balance_amount_token = balance(txn_sender); + assert!(balance_amount_token >= max_transaction_fee_token, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT)); + if (!is_stc()){ + let balance_amount_stc= balance(CoreAddresses::GENESIS_ADDRESS()); + assert!(balance_amount_stc >= max_transaction_fee_stc, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT)); + } }; - // 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)); - } - spec txn_prologue { - aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS(); - aborts_if !exists(txn_sender); - aborts_if global(txn_sender).authentication_key == DUMMY_AUTH_KEY && Authenticator::spec_derived_address(Hash::sha3_256(txn_authentication_key_preimage)) != txn_sender; - aborts_if global(txn_sender).authentication_key != DUMMY_AUTH_KEY && Hash::sha3_256(txn_authentication_key_preimage) != global(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>(txn_sender); - aborts_if txn_gas_price * txn_max_gas_units > 0 && Token::spec_token_code() != Token::spec_token_code(); - //abort condition for assert!(balance_amount >= max_transaction_fee) - aborts_if txn_gas_price * txn_max_gas_units > 0 && global>(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(txn_sender).sequence_number; - aborts_if txn_sequence_number != global(txn_sender).sequence_number; } + /// The epilogue is invoked at the end of transactions. /// It collects gas and bumps the sequence number public fun txn_epilogue( @@ -1055,13 +1069,25 @@ module Account { txn_max_gas_units: u64, gas_units_remaining: u64, ) acquires Account, Balance { - txn_epilogue_v2(account, txn_sender, txn_sequence_number, Vector::empty(), txn_gas_price, txn_max_gas_units, gas_units_remaining) + txn_epilogue_v3(account, txn_sender, txn_sequence_number, Vector::empty(), txn_gas_price, txn_max_gas_units, gas_units_remaining,1,1) } spec txn_epilogue { pragma verify = false; } + public fun transaction_fee_simulate( + txn_gas_price:u64, + txn_max_gas_units: u64, + gas_units_remaining:u64, + stc_price: u128, + stc_price_scaling: u128, + ): (u128, u128){ + let transaction_fee_stc =(txn_gas_price * (txn_max_gas_units - gas_units_remaining) as u128); + let transaction_fee_token= Math::mul_div((transaction_fee_stc as u128), stc_price, stc_price_scaling); + transaction_fee_token = if (transaction_fee_token == 0 && transaction_fee_stc > 0 ) { 1 } else { transaction_fee_token}; + (transaction_fee_stc, transaction_fee_token) + } /// The epilogue is invoked at the end of transactions. /// It collects gas and bumps the sequence number public fun txn_epilogue_v2( @@ -1073,31 +1099,81 @@ module Account { txn_max_gas_units: u64, gas_units_remaining: u64, ) acquires Account, Balance { - CoreAddresses::assert_genesis_address(account); + txn_epilogue_v3( + account, + txn_sender, + txn_sequence_number, + txn_authentication_key_preimage, + txn_gas_price, + txn_max_gas_units, + gas_units_remaining,1,1) + } - // Load the transaction sender's account and balance resources - let sender_account = borrow_global_mut(txn_sender); - let sender_balance = borrow_global_mut>(txn_sender); + spec txn_epilogue_v2 { + pragma verify = false; // Todo: fix me, cost too much time + aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS(); + aborts_if !exists(txn_sender); + aborts_if !exists>(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>(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>(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>(CoreAddresses::GENESIS_ADDRESS()); + aborts_if txn_gas_price * (txn_max_gas_units - gas_units_remaining) > 0 && + global>(CoreAddresses::GENESIS_ADDRESS()).fee.value + txn_gas_price * (txn_max_gas_units - gas_units_remaining) > max_u128(); + } + /// The epilogue is invoked at the end of transactions. + /// It collects gas and bumps the sequence number + public fun txn_epilogue_v3( + account: &signer, + txn_sender: address, + txn_sequence_number: u64, + txn_authentication_key_preimage: vector, + txn_gas_price: u64, + txn_max_gas_units: u64, + gas_units_remaining: u64, + stc_price: u128, + stc_price_scaling: u128, + ) acquires Account, Balance { + CoreAddresses::assert_genesis_address(account); // Charge for gas - let transaction_fee_amount =(txn_gas_price * (txn_max_gas_units - gas_units_remaining) as u128); + let (transaction_fee_amount_stc,transaction_fee_amount_token) = transaction_fee_simulate( + txn_gas_price, + txn_max_gas_units, + gas_units_remaining, + stc_price, + stc_price_scaling); assert!( - balance_for(sender_balance) >= transaction_fee_amount, + balance(txn_sender) >= transaction_fee_amount_token, Errors::limit_exceeded(EINSUFFICIENT_BALANCE) ); - + if (!is_stc()){ + let genesis_balance_amount_stc=balance(CoreAddresses::GENESIS_ADDRESS()); + assert!(genesis_balance_amount_stc >= transaction_fee_amount_stc, + Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT) + ); + }; + // Load the transaction sender's account and balance resources + let sender_account = borrow_global_mut(txn_sender); // 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 + if (transaction_fee_amount_stc > 0) { + let transaction_fee_token = withdraw_from_balance( + borrow_global_mut>(txn_sender), + transaction_fee_amount_token ); - TransactionFee::pay_fee(transaction_fee); + deposit_to_balance(borrow_global_mut>(CoreAddresses::GENESIS_ADDRESS()), transaction_fee_token); + let stc_fee_token = withdraw_from_balance(borrow_global_mut>(CoreAddresses::GENESIS_ADDRESS()), transaction_fee_amount_stc); + TransactionFee::pay_fee(stc_fee_token); }; } @@ -1106,18 +1182,10 @@ module Account { aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS(); aborts_if !exists(txn_sender); aborts_if !exists>(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>(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>(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>(CoreAddresses::GENESIS_ADDRESS()); - aborts_if txn_gas_price * (txn_max_gas_units - gas_units_remaining) > 0 && - global>(CoreAddresses::GENESIS_ADDRESS()).fee.value + txn_gas_price * (txn_max_gas_units - gas_units_remaining) > max_u128(); - } + aborts_if !exists>(txn_sender); + aborts_if txn_max_gas_units < gas_units_remaining; + } public entry fun remove_zero_balance_entry(account: signer) acquires Balance { remove_zero_balance(&account); diff --git a/sources/EasyGas.move b/sources/EasyGas.move new file mode 100644 index 00000000..9ad5675b --- /dev/null +++ b/sources/EasyGas.move @@ -0,0 +1,88 @@ +address StarcoinFramework { + +module EasyGasOracle { + use StarcoinFramework::Account; + use StarcoinFramework::Signer::address_of; + use StarcoinFramework::TypeInfo::{type_of, module_name, account_address, struct_name}; + use StarcoinFramework::CoreAddresses; + use StarcoinFramework::GenesisSignerCapability; + use StarcoinFramework::PriceOracle; + + //friend StarcoinFramework::StdlibUpgradeScripts; + + struct STCToken has copy, store, drop {} + + struct GasTokenEntry has key, store, drop { + account_address: address, + module_name: vector, + struct_name: vector, + data_source: address, + } + + public fun register(sender: &signer, precision: u8) { + PriceOracle::register_oracle>(sender, precision); + let genesis_account = GenesisSignerCapability::get_genesis_signer(); + //todo:check gas token entry + Account::do_accept_token(&genesis_account); + } + + public fun init_data_source(sender: &signer, init_value: u128) { + PriceOracle::init_data_source>(sender, init_value); + } + + public fun update(sender: &signer, value: u128) { + PriceOracle::update>(sender, value); + } + + public fun get_scaling_factor(): u128 { + PriceOracle::get_scaling_factor>() + } + + public fun gas_oracle_read(): u128 acquires GasTokenEntry { + let data_source = get_data_source_address(); + PriceOracle::read>(data_source) + } + + //TODO: friend to stdlibupgrade + public fun register_gas_token_entry( + _sender: &signer, + account_address: address, + module_name: vector, + struct_name: vector, + data_source: address, + ) acquires GasTokenEntry { + let genesis_account = GenesisSignerCapability::get_genesis_signer(); + let gas_token_entry = GasTokenEntry { account_address, module_name, struct_name, data_source }; + if (exists(address_of(&genesis_account))){ + move_from(address_of(&genesis_account)); + }; + move_to(&genesis_account, gas_token_entry); + } + + fun get_data_source_address(): address acquires GasTokenEntry { + let token_type_info = type_of(); + let genesis = CoreAddresses::GENESIS_ADDRESS(); + let gas_token_entry = borrow_global(genesis); + //TODO:error code define + assert!(module_name(&token_type_info) == *&gas_token_entry.module_name && account_address( + &token_type_info + ) == *&gas_token_entry.account_address && struct_name(&token_type_info) == *&gas_token_entry.struct_name, 100); + gas_token_entry.data_source + } +} + +module EasyGasOracleScript { + use StarcoinFramework::EasyGasOracle; + public entry fun register(sender: signer, precision: u8) { + EasyGasOracle::register(&sender, precision) + } + + public entry fun init_data_source(sender: signer, init_value: u128) { + EasyGasOracle::init_data_source(&sender,init_value); + } + + public entry fun update(sender: signer, value: u128) { + EasyGasOracle::update(&sender,value) + } +} +} \ No newline at end of file diff --git a/sources/GenesisSignerCapability.move b/sources/GenesisSignerCapability.move index 3b4e51a4..e8afffa1 100644 --- a/sources/GenesisSignerCapability.move +++ b/sources/GenesisSignerCapability.move @@ -3,12 +3,13 @@ module StarcoinFramework::GenesisSignerCapability { use StarcoinFramework::CoreAddresses; use StarcoinFramework::Errors; + + friend StarcoinFramework::NFT; friend StarcoinFramework::Oracle; friend StarcoinFramework::Genesis; friend StarcoinFramework::StdlibUpgradeScripts; - - + friend StarcoinFramework::EasyGasOracle; const ENOT_GENESIS_ACCOUNT: u64 = 11; struct GenesisSignerCapability has key { @@ -28,12 +29,10 @@ module StarcoinFramework::GenesisSignerCapability { let cap = borrow_global(CoreAddresses::GENESIS_ADDRESS()); Account::create_signer_with_cap(&cap.cap) } - #[test_only] public fun initialize_for_test(signer: &signer, cap: Account::SignerCapability) { initialize(signer, cap); } - #[test_only] public fun get_genesis_signer_for_test(): signer acquires GenesisSignerCapability { get_genesis_signer() diff --git a/sources/StdlibUpgradeScripts.move b/sources/StdlibUpgradeScripts.move index 85a248f0..cd7a4efa 100644 --- a/sources/StdlibUpgradeScripts.move +++ b/sources/StdlibUpgradeScripts.move @@ -2,7 +2,8 @@ address StarcoinFramework { /// The module for StdlibUpgrade init scripts module StdlibUpgradeScripts { - use StarcoinFramework::CoreAddresses; + use StarcoinFramework::EasyGasOracle; + use StarcoinFramework::CoreAddresses; use StarcoinFramework::STC::{Self, STC}; use StarcoinFramework::Token::{Self, LinearTimeMintKey}; use StarcoinFramework::TreasuryWithdrawDaoProposal; @@ -106,6 +107,10 @@ module StdlibUpgradeScripts { } public fun do_upgrade_from_v11_to_v12(sender: &signer) { { + EasyGasOracle::register_gas_token_entry(sender, + @0x8c109349c6bd91411d6bc962e080c4a3, + b"STAR",b"STAR", + @0x8c109349c6bd91411d6bc962e080c4a3); Block::checkpoints_init(sender); }; } diff --git a/sources/TransactionManager.move b/sources/TransactionManager.move index 70aa0b2b..42f17b7d 100644 --- a/sources/TransactionManager.move +++ b/sources/TransactionManager.move @@ -19,6 +19,8 @@ module TransactionManager { use StarcoinFramework::Epoch; use StarcoinFramework::Hash; use StarcoinFramework::Vector; + use StarcoinFramework::STC; + use StarcoinFramework::EasyGasOracle; spec module { pragma verify = false; @@ -62,13 +64,21 @@ module TransactionManager { // 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( + let (stc_price,scaling_factor)= if (!STC::is_stc()){ + (EasyGasOracle::gas_oracle_read(),EasyGasOracle::get_scaling_factor()) + }else{ + (1,1) + }; + + Account::txn_prologue_v2( &account, txn_sender, txn_sequence_number, txn_authentication_key_preimage, txn_gas_price, txn_max_gas_units, + stc_price, + scaling_factor, ); assert!( TransactionTimeout::is_valid_transaction_timestamp(txn_expiration_time), @@ -109,8 +119,6 @@ module TransactionManager { include Timestamp::AbortsIfTimestampNotExists; include Block::AbortsIfBlockMetadataNotExist; aborts_if txn_gas_price * txn_max_gas_units > 0 && !exists>(txn_sender); - aborts_if txn_gas_price * txn_max_gas_units > 0 && StarcoinFramework::Token::spec_token_code() != StarcoinFramework::Token::spec_token_code(); - aborts_if txn_gas_price * txn_max_gas_units > 0 && global>(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(txn_sender).sequence_number; aborts_if txn_sequence_number != global(txn_sender).sequence_number; @@ -159,7 +167,13 @@ module TransactionManager { success: bool, ) { CoreAddresses::assert_genesis_address(&account); - Account::txn_epilogue_v2( + let (stc_price,scaling_factor) = + if (!STC::is_stc()){ + (EasyGasOracle::gas_oracle_read(),EasyGasOracle::get_scaling_factor()) + }else{ + (1,1) + }; + Account::txn_epilogue_v3( &account, txn_sender, txn_sequence_number, @@ -167,6 +181,8 @@ module TransactionManager { txn_gas_price, txn_max_gas_units, gas_units_remaining, + stc_price, + scaling_factor ); if (txn_payload_type == TXN_PAYLOAD_TYPE_PACKAGE) { PackageTxnManager::package_txn_epilogue( From dad3359ff239b2969d4562608414ebced06c75c6 Mon Sep 17 00:00:00 2001 From: sanlee42 Date: Tue, 1 Aug 2023 13:45:20 +0000 Subject: [PATCH 2/6] Update exp --- build/StarcoinFramework/BuildInfo.yaml | 4 +- .../abis/Account/accept_token.abi | Bin 0 -> 52 bytes .../abis/Account/accept_token_entry.abi | Bin 0 -> 58 bytes .../create_account_with_initial_amount.abi | Bin 0 -> 117 bytes ...eate_account_with_initial_amount_entry.abi | Bin 0 -> 111 bytes .../create_account_with_initial_amount_v2.abi | Bin 0 -> 108 bytes .../Account/remove_zero_balance_entry.abi | Bin 0 -> 65 bytes .../Account/rotate_authentication_key.abi | Bin 0 -> 64 bytes .../rotate_authentication_key_entry.abi | Bin 0 -> 70 bytes .../Account/set_auto_accept_token_entry.abi | Bin 0 -> 64 bytes .../disable_auto_accept_token.abi | Bin 0 -> 143 bytes .../enable_auto_accept_token.abi | Bin 0 -> 141 bytes .../AccountScripts/remove_zero_balance.abi | Bin 0 -> 87 bytes .../abis/Block/checkpoint_entry.abi | Bin 0 -> 43 bytes .../abis/Block/update_state_root_entry.abi | Bin 0 -> 59 bytes .../abis/Dao/destroy_terminated_proposal.abi | Bin 0 -> 141 bytes .../abis/Dao/queue_proposal_action.abi | Bin 0 -> 128 bytes .../abis/DaoVoteScripts/cast_vote.abi | Bin 0 -> 105 bytes .../abis/DaoVoteScripts/flip_vote.abi | Bin 0 -> 144 bytes .../abis/DaoVoteScripts/revoke_vote.abi | Bin 0 -> 122 bytes .../DaoVoteScripts/revoke_vote_of_power.abi | Bin 0 -> 139 bytes .../abis/DaoVoteScripts/unstake_vote.abi | Bin 0 -> 92 bytes .../abis/DummyToken/mint.abi | Bin 0 -> 51 bytes .../abis/EasyGas/init_data_source.abi | Bin 0 -> 80 bytes .../abis/EasyGas/register.abi | Bin 0 -> 71 bytes .../StarcoinFramework/abis/EasyGas/update.abi | Bin 0 -> 65 bytes .../abis/EmptyScripts/empty_script.abi | Bin 0 -> 46 bytes .../abis/Genesis/initialize.abi | Bin 0 -> 939 bytes .../abis/Genesis/initialize_v2.abi | Bin 0 -> 960 bytes .../abis/GenesisNFT/mint.abi | Bin 0 -> 84 bytes .../abis/GenesisNFT/mint_entry.abi | Bin 0 -> 65 bytes .../abis/ModifyDaoConfigProposal/execute.abi | Bin 0 -> 176 bytes .../abis/ModifyDaoConfigProposal/propose.abi | Bin 0 -> 168 bytes .../cancel_upgrade_plan.abi | Bin 0 -> 137 bytes .../execute_module_upgrade_plan_propose.abi | Bin 0 -> 249 bytes .../propose_module_upgrade_v2.abi | Bin 0 -> 135 bytes .../submit_module_upgrade_plan.abi | Bin 0 -> 184 bytes .../submit_upgrade_plan.abi | Bin 0 -> 241 bytes .../update_module_upgrade_strategy.abi | Bin 0 -> 137 bytes ..._module_upgrade_strategy_with_min_time.abi | Bin 0 -> 253 bytes build/StarcoinFramework/abis/NFT/accept.abi | Bin 0 -> 115 bytes .../abis/NFT/accept_entry.abi | Bin 0 -> 125 bytes .../abis/NFT/destroy_empty.abi | Bin 0 -> 101 bytes .../abis/NFT/destroy_empty_entry.abi | Bin 0 -> 104 bytes .../abis/NFT/remove_empty_gallery.abi | Bin 0 -> 113 bytes .../abis/NFT/remove_empty_gallery_entry.abi | Bin 0 -> 112 bytes build/StarcoinFramework/abis/NFT/transfer.abi | Bin 0 -> 148 bytes .../abis/NFT/transfer_entry.abi | Bin 0 -> 119 bytes .../abis/Offer/take_offer.abi | Bin 0 -> 112 bytes .../execute_on_chain_config_proposal.abi | Bin 0 -> 96 bytes .../execute_on_chain_config_proposal_v2.abi | Bin 0 -> 128 bytes .../propose_update_consensus_config.abi | Bin 0 -> 336 bytes .../propose_update_move_language_version.abi | Bin 0 -> 103 bytes .../propose_update_reward_config.abi | Bin 0 -> 96 bytes .../propose_update_txn_publish_option.abi | Bin 0 -> 130 bytes .../propose_update_txn_timeout_config.abi | Bin 0 -> 105 bytes .../propose_update_vm_config.abi | Bin 0 -> 416 bytes .../abis/Oracle/init_data_source.abi | Bin 0 -> 77 bytes .../abis/Oracle/init_data_source_entry.abi | Bin 0 -> 76 bytes .../abis/Oracle/register_oracle.abi | Bin 0 -> 75 bytes .../abis/Oracle/register_oracle_entry.abi | Bin 0 -> 74 bytes .../StarcoinFramework/abis/Oracle/update.abi | Bin 0 -> 62 bytes .../abis/Oracle/update_entry.abi | Bin 0 -> 61 bytes ...t_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2.abi | Bin 0 -> 100 bytes .../take_linear_withdraw_capability.abi | Bin 0 -> 146 bytes .../upgrade_from_v11_to_v12.abi | Bin 0 -> 65 bytes .../upgrade_from_v2_to_v3.abi | Bin 0 -> 117 bytes .../upgrade_from_v5_to_v6.abi | Bin 0 -> 63 bytes .../upgrade_from_v6_to_v7.abi | Bin 0 -> 63 bytes .../upgrade_from_v7_to_v8.abi | Bin 0 -> 63 bytes .../TransferScripts/batch_peer_to_peer.abi | Bin 0 -> 138 bytes .../TransferScripts/batch_peer_to_peer_v2.abi | Bin 0 -> 121 bytes .../abis/TransferScripts/peer_to_peer.abi | Bin 0 -> 93 bytes .../TransferScripts/peer_to_peer_batch.abi | Bin 0 -> 105 bytes .../abis/TransferScripts/peer_to_peer_v2.abi | Bin 0 -> 78 bytes .../peer_to_peer_with_metadata.abi | Bin 0 -> 118 bytes .../peer_to_peer_with_metadata_v2.abi | Bin 0 -> 103 bytes .../execute_withdraw_proposal.abi | Bin 0 -> 101 bytes .../abis/TreasuryScripts/propose_withdraw.abi | Bin 0 -> 99 bytes .../withdraw_and_split_lt_withdraw_cap.abi | Bin 0 -> 113 bytes ..._token_with_linear_withdraw_capability.abi | Bin 0 -> 91 bytes .../StarcoinFramework/bytecode_modules/ACL.mv | Bin 465 -> 435 bytes .../bytecode_modules/Account.mv | Bin 6793 -> 6725 bytes .../bytecode_modules/Authenticator.mv | Bin 873 -> 801 bytes .../StarcoinFramework/bytecode_modules/BCS.mv | Bin 3135 -> 3074 bytes .../bytecode_modules/BlockReward.mv | Bin 1593 -> 1514 bytes .../bytecode_modules/Collection.mv | Bin 842 -> 814 bytes .../bytecode_modules/Collection2.mv | Bin 1924 -> 1860 bytes .../bytecode_modules/Compare.mv | Bin 682 -> 623 bytes .../bytecode_modules/EVMAddress.mv | Bin 476 -> 400 bytes .../bytecode_modules/GasSchedule.mv | Bin 8542 -> 8511 bytes .../bytecode_modules/Genesis.mv | Bin 3629 -> 3627 bytes .../bytecode_modules/Math.mv | Bin 746 -> 688 bytes .../bytecode_modules/MerkleNFTDistributor.mv | Bin 1338 -> 1259 bytes .../bytecode_modules/MerkleProof.mv | Bin 369 -> 322 bytes .../StarcoinFramework/bytecode_modules/NFT.mv | Bin 4041 -> 4087 bytes .../bytecode_modules/NFTGallery.mv | Bin 2260 -> 2178 bytes .../bytecode_modules/Option.mv | Bin 1136 -> 1051 bytes .../bytecode_modules/Oracle.mv | Bin 1982 -> 1893 bytes .../bytecode_modules/PriceOracleAggregator.mv | Bin 570 -> 498 bytes .../bytecode_modules/Ring.mv | Bin 1418 -> 1292 bytes .../bytecode_modules/Secp256k1.mv | Bin 633 -> 604 bytes .../bytecode_modules/SimpleMap.mv | Bin 1281 -> 1160 bytes .../bytecode_modules/StarcoinVerifier.mv | Bin 1988 -> 1910 bytes .../bytecode_modules/String.mv | Bin 936 -> 927 bytes .../bytecode_modules/TransactionManager.mv | Bin 1532 -> 1513 bytes .../bytecode_modules/TransferScripts.mv | Bin 777 -> 719 bytes .../bytecode_modules/TypeInfo.mv | Bin 341 -> 312 bytes .../bytecode_modules/U256.mv | Bin 1196 -> 1125 bytes .../bytecode_modules/VMConfig.mv | Bin 4003 -> 3967 bytes .../bytecode_modules/Vector.mv | Bin 1240 -> 1256 bytes build/StarcoinFramework/docs/ACL.md | 205 + build/StarcoinFramework/docs/Account.md | 3598 +++++++++++++++++ .../StarcoinFramework/docs/AccountScripts.md | 93 + build/StarcoinFramework/docs/Authenticator.md | 448 ++ build/StarcoinFramework/docs/BCS.md | 1599 ++++++++ build/StarcoinFramework/docs/Bitwise.md | 179 + build/StarcoinFramework/docs/Block.md | 941 +++++ build/StarcoinFramework/docs/BlockReward.md | 397 ++ build/StarcoinFramework/docs/ChainId.md | 425 ++ build/StarcoinFramework/docs/Collection.md | 430 ++ build/StarcoinFramework/docs/Collection2.md | 878 ++++ build/StarcoinFramework/docs/Compare.md | 340 ++ build/StarcoinFramework/docs/Config.md | 773 ++++ .../StarcoinFramework/docs/ConsensusConfig.md | 700 ++++ .../docs/ConsensusStrategy.md | 143 + build/StarcoinFramework/docs/CoreAddresses.md | 178 + build/StarcoinFramework/docs/Dao.md | 2330 +++++++++++ .../StarcoinFramework/docs/DaoVoteScripts.md | 197 + build/StarcoinFramework/docs/Debug.md | 72 + build/StarcoinFramework/docs/DummyToken.md | 46 + build/StarcoinFramework/docs/EasyGas.md | 88 + build/StarcoinFramework/docs/EmptyScripts.md | 48 + build/StarcoinFramework/docs/Epoch.md | 1041 +++++ build/StarcoinFramework/docs/Errors.md | 623 +++ build/StarcoinFramework/docs/Event.md | 300 ++ build/StarcoinFramework/docs/EventUtil.md | 175 + build/StarcoinFramework/docs/FixedPoint32.md | 439 ++ build/StarcoinFramework/docs/FromBCS.md | 205 + build/StarcoinFramework/docs/GasSchedule.md | 513 +++ build/StarcoinFramework/docs/Genesis.md | 804 ++++ build/StarcoinFramework/docs/GenesisNFT.md | 49 + .../docs/GenesisSignerCapability.md | 114 + build/StarcoinFramework/docs/Hash.md | 116 + .../StarcoinFramework/docs/LanguageVersion.md | 114 + build/StarcoinFramework/docs/Math.md | 377 ++ build/StarcoinFramework/docs/MerkleNFT.md | 330 ++ .../StarcoinFramework/docs/MintDaoProposal.md | 258 ++ build/StarcoinFramework/docs/MintScripts.md | 10 + .../docs/ModifyDaoConfigProposal.md | 300 ++ .../docs/ModuleUpgradeScripts.md | 314 ++ build/StarcoinFramework/docs/NFT.md | 104 + build/StarcoinFramework/docs/Offer.md | 305 ++ .../docs/OnChainConfigDao.md | 257 ++ .../docs/OnChainConfigScripts.md | 378 ++ build/StarcoinFramework/docs/Option.md | 787 ++++ build/StarcoinFramework/docs/Oracle.md | 88 + .../docs/PackageTxnManager.md | 1454 +++++++ build/StarcoinFramework/docs/README.md | 110 + build/StarcoinFramework/docs/RewardConfig.md | 240 ++ build/StarcoinFramework/docs/Ring.md | 426 ++ build/StarcoinFramework/docs/SIPs.md | 11 + build/StarcoinFramework/docs/STC.md | 403 ++ build/StarcoinFramework/docs/Secp256k1.md | 296 ++ .../docs/SharedEd25519PublicKey.md | 309 ++ build/StarcoinFramework/docs/Signature.md | 154 + .../StarcoinFramework/docs/SignedInteger64.md | 352 ++ build/StarcoinFramework/docs/Signer.md | 94 + build/StarcoinFramework/docs/SimpleMap.md | 543 +++ .../docs/StarcoinVerifier.md | 715 ++++ .../docs/StdlibUpgradeScripts.md | 364 ++ build/StarcoinFramework/docs/String.md | 530 +++ build/StarcoinFramework/docs/Table.md | 831 ++++ build/StarcoinFramework/docs/Timestamp.md | 461 +++ build/StarcoinFramework/docs/Token.md | 1845 +++++++++ .../StarcoinFramework/docs/TransactionFee.md | 245 ++ .../docs/TransactionManager.md | 441 ++ .../docs/TransactionPublishOption.md | 348 ++ .../docs/TransactionTimeout.md | 108 + .../docs/TransactionTimeoutConfig.md | 235 ++ .../StarcoinFramework/docs/TransferScripts.md | 252 ++ build/StarcoinFramework/docs/Treasury.md | 1230 ++++++ .../StarcoinFramework/docs/TreasuryScripts.md | 204 + .../docs/TreasuryWithdrawDaoProposal.md | 320 ++ build/StarcoinFramework/docs/TypeInfo.md | 192 + build/StarcoinFramework/docs/U256.md | 946 +++++ .../docs/UpgradeModuleDaoProposal.md | 350 ++ build/StarcoinFramework/docs/VMConfig.md | 738 ++++ build/StarcoinFramework/docs/Vector.md | 861 ++++ build/StarcoinFramework/docs/Version.md | 146 + build/StarcoinFramework/docs/YieldFarming.md | 886 ++++ .../StarcoinFramework/docs/YieldFarmingV2.md | 1429 +++++++ integration-tests/account/basic.exp | 14 +- .../account/delegate_account.exp | 4 +- .../account/txn_prologue_and_epilogue.exp | 22 +- .../account/withdraw_capability.exp | 14 +- .../account/withdraw_zero_token.exp | 2 +- .../authenticator/authenticator.exp | 18 +- integration-tests/block/block_checkpoints.exp | 8 +- integration-tests/block/checkpoints_test.exp | 8 +- integration-tests/block_reward/basic.exp | 18 +- .../collection2/collection_add_by_other.exp | 8 +- .../collection2/collection_by_owner.exp | 14 +- .../collection2/collection_mut_by_other.exp | 10 +- integration-tests/compare/compare.exp | 2 +- integration-tests/dao/test_dao_config.exp | 16 +- integration-tests/dao/test_dao_failure.exp | 32 +- integration-tests/dao/test_dao_propose.exp | 18 +- .../dao/test_mint_dao_proposal.exp | 10 +- integration-tests/debug/debug.exp | 2 +- .../epoch/adjust_epoch_block_time_max.exp | 2 +- .../epoch/adjust_epoch_block_time_min.exp | 2 +- .../epoch/adjust_epoch_failed.exp | 2 +- integration-tests/epoch/adjust_gas_limit.exp | 2 +- .../incubator/SortedLinkedList.exp | 32 +- integration-tests/list/linked_list.exp | 10 +- integration-tests/math/sum_avg.exp | 2 +- integration-tests/move/option.exp | 2 +- integration-tests/natives/signature.exp | 8 +- integration-tests/nft/identifier_nft.exp | 10 +- integration-tests/nft/nft_boxminer.exp | 4 +- integration-tests/nft/nft_card.exp | 10 +- integration-tests/nft/nft_metadata.exp | 10 +- integration-tests/nft/test_gallery.exp | 26 +- integration-tests/nft/test_genesis_nft.exp | 2 +- integration-tests/nft/test_nft.exp | 8 +- integration-tests/offer/offer.exp | 2 +- integration-tests/on_chain_config/config.exp | 14 +- .../test_onchain_config_dao.exp | 8 +- integration-tests/oracle/oracle.exp | 4 +- .../cancel_upgrade_plan.exp | 8 +- .../package_txn_manager/only_new_module.exp | 2 +- .../override_upgrade_plan.exp | 10 +- .../package_txn_manager.exp | 20 +- integration-tests/ring/rind_set.exp | 2 +- integration-tests/ring/ring_add.exp | 2 +- integration-tests/ring/ring_borrow.exp | 2 +- integration-tests/ring/ring_borrow_mut.exp | 2 +- integration-tests/ring/ring_index_of.exp | 8 +- .../shared_ed25519_public_key/shared_key.exp | 2 +- .../signer_capability/create_signer.exp | 2 +- .../signer_capability/destroy_signer.exp | 2 +- integration-tests/token/burn_and_destroy.exp | 4 +- .../token/create_account_with_token.exp | 4 +- integration-tests/token/mint_stc.exp | 2 +- integration-tests/token/my_token.exp | 4 +- .../token/transfer_then_abort.exp | 2 +- .../transaction_fee/distribute_txn_fee.exp | 2 +- .../transaction_scripts/create_account.exp | 2 +- .../execute_modify_dao_config_proposal.exp | 6 +- .../execute_on_chain_config_proposal.exp | 6 +- .../transaction_scripts/module_upgrade.exp | 10 +- .../transaction_scripts/peer_to_peer.exp | 4 +- .../peer_to_peer_with_metadata.exp | 4 +- integration-tests/u256/test_u256_gas.exp | 16 +- .../upgrade_module_dao_proposal/basic.exp | 10 +- integration-tests/vector/big_vector.exp | 16 +- integration-tests/vector/contains.exp | 2 +- integration-tests/vector/index_of.exp | 2 +- integration-tests/vector/remove.exp | 4 +- integration-tests/vector/reverse.exp | 4 +- integration-tests/vector/spawn_from.exp | 4 +- integration-tests/vector/split.exp | 4 +- integration-tests/vector/swap_remove.exp | 2 +- integration-tests/version/basic.exp | 2 +- integration-tests/yield_farming/basic.exp | 2 +- .../yield_farming/cap_local_store.exp | 2 +- 267 files changed, 40461 insertions(+), 283 deletions(-) create mode 100644 build/StarcoinFramework/abis/Account/accept_token.abi create mode 100644 build/StarcoinFramework/abis/Account/accept_token_entry.abi create mode 100644 build/StarcoinFramework/abis/Account/create_account_with_initial_amount.abi create mode 100644 build/StarcoinFramework/abis/Account/create_account_with_initial_amount_entry.abi create mode 100644 build/StarcoinFramework/abis/Account/create_account_with_initial_amount_v2.abi create mode 100644 build/StarcoinFramework/abis/Account/remove_zero_balance_entry.abi create mode 100644 build/StarcoinFramework/abis/Account/rotate_authentication_key.abi create mode 100644 build/StarcoinFramework/abis/Account/rotate_authentication_key_entry.abi create mode 100644 build/StarcoinFramework/abis/Account/set_auto_accept_token_entry.abi create mode 100644 build/StarcoinFramework/abis/AccountScripts/disable_auto_accept_token.abi create mode 100644 build/StarcoinFramework/abis/AccountScripts/enable_auto_accept_token.abi create mode 100644 build/StarcoinFramework/abis/AccountScripts/remove_zero_balance.abi create mode 100644 build/StarcoinFramework/abis/Block/checkpoint_entry.abi create mode 100644 build/StarcoinFramework/abis/Block/update_state_root_entry.abi create mode 100644 build/StarcoinFramework/abis/Dao/destroy_terminated_proposal.abi create mode 100644 build/StarcoinFramework/abis/Dao/queue_proposal_action.abi create mode 100644 build/StarcoinFramework/abis/DaoVoteScripts/cast_vote.abi create mode 100644 build/StarcoinFramework/abis/DaoVoteScripts/flip_vote.abi create mode 100644 build/StarcoinFramework/abis/DaoVoteScripts/revoke_vote.abi create mode 100644 build/StarcoinFramework/abis/DaoVoteScripts/revoke_vote_of_power.abi create mode 100644 build/StarcoinFramework/abis/DaoVoteScripts/unstake_vote.abi create mode 100644 build/StarcoinFramework/abis/DummyToken/mint.abi create mode 100644 build/StarcoinFramework/abis/EasyGas/init_data_source.abi create mode 100644 build/StarcoinFramework/abis/EasyGas/register.abi create mode 100644 build/StarcoinFramework/abis/EasyGas/update.abi create mode 100644 build/StarcoinFramework/abis/EmptyScripts/empty_script.abi create mode 100644 build/StarcoinFramework/abis/Genesis/initialize.abi create mode 100644 build/StarcoinFramework/abis/Genesis/initialize_v2.abi create mode 100644 build/StarcoinFramework/abis/GenesisNFT/mint.abi create mode 100644 build/StarcoinFramework/abis/GenesisNFT/mint_entry.abi create mode 100644 build/StarcoinFramework/abis/ModifyDaoConfigProposal/execute.abi create mode 100644 build/StarcoinFramework/abis/ModifyDaoConfigProposal/propose.abi create mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/cancel_upgrade_plan.abi create mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/execute_module_upgrade_plan_propose.abi create mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/propose_module_upgrade_v2.abi create mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/submit_module_upgrade_plan.abi create mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/submit_upgrade_plan.abi create mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/update_module_upgrade_strategy.abi create mode 100644 build/StarcoinFramework/abis/ModuleUpgradeScripts/update_module_upgrade_strategy_with_min_time.abi create mode 100644 build/StarcoinFramework/abis/NFT/accept.abi create mode 100644 build/StarcoinFramework/abis/NFT/accept_entry.abi create mode 100644 build/StarcoinFramework/abis/NFT/destroy_empty.abi create mode 100644 build/StarcoinFramework/abis/NFT/destroy_empty_entry.abi create mode 100644 build/StarcoinFramework/abis/NFT/remove_empty_gallery.abi create mode 100644 build/StarcoinFramework/abis/NFT/remove_empty_gallery_entry.abi create mode 100644 build/StarcoinFramework/abis/NFT/transfer.abi create mode 100644 build/StarcoinFramework/abis/NFT/transfer_entry.abi create mode 100644 build/StarcoinFramework/abis/Offer/take_offer.abi create mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal.abi create mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal_v2.abi create mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_consensus_config.abi create mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_move_language_version.abi create mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_reward_config.abi create mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_txn_publish_option.abi create mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_txn_timeout_config.abi create mode 100644 build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_vm_config.abi create mode 100644 build/StarcoinFramework/abis/Oracle/init_data_source.abi create mode 100644 build/StarcoinFramework/abis/Oracle/init_data_source_entry.abi create mode 100644 build/StarcoinFramework/abis/Oracle/register_oracle.abi create mode 100644 build/StarcoinFramework/abis/Oracle/register_oracle_entry.abi create mode 100644 build/StarcoinFramework/abis/Oracle/update.abi create mode 100644 build/StarcoinFramework/abis/Oracle/update_entry.abi create mode 100644 build/StarcoinFramework/abis/PackageTxnManager/convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2.abi create mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/take_linear_withdraw_capability.abi create mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v11_to_v12.abi create mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v2_to_v3.abi create mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v5_to_v6.abi create mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v6_to_v7.abi create mode 100644 build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v7_to_v8.abi create mode 100644 build/StarcoinFramework/abis/TransferScripts/batch_peer_to_peer.abi create mode 100644 build/StarcoinFramework/abis/TransferScripts/batch_peer_to_peer_v2.abi create mode 100644 build/StarcoinFramework/abis/TransferScripts/peer_to_peer.abi create mode 100644 build/StarcoinFramework/abis/TransferScripts/peer_to_peer_batch.abi create mode 100644 build/StarcoinFramework/abis/TransferScripts/peer_to_peer_v2.abi create mode 100644 build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata.abi create mode 100644 build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata_v2.abi create mode 100644 build/StarcoinFramework/abis/TreasuryScripts/execute_withdraw_proposal.abi create mode 100644 build/StarcoinFramework/abis/TreasuryScripts/propose_withdraw.abi create mode 100644 build/StarcoinFramework/abis/TreasuryScripts/withdraw_and_split_lt_withdraw_cap.abi create mode 100644 build/StarcoinFramework/abis/TreasuryScripts/withdraw_token_with_linear_withdraw_capability.abi create mode 100644 build/StarcoinFramework/docs/ACL.md create mode 100644 build/StarcoinFramework/docs/Account.md create mode 100644 build/StarcoinFramework/docs/AccountScripts.md create mode 100644 build/StarcoinFramework/docs/Authenticator.md create mode 100644 build/StarcoinFramework/docs/BCS.md create mode 100644 build/StarcoinFramework/docs/Bitwise.md create mode 100644 build/StarcoinFramework/docs/Block.md create mode 100644 build/StarcoinFramework/docs/BlockReward.md create mode 100644 build/StarcoinFramework/docs/ChainId.md create mode 100644 build/StarcoinFramework/docs/Collection.md create mode 100644 build/StarcoinFramework/docs/Collection2.md create mode 100644 build/StarcoinFramework/docs/Compare.md create mode 100644 build/StarcoinFramework/docs/Config.md create mode 100644 build/StarcoinFramework/docs/ConsensusConfig.md create mode 100644 build/StarcoinFramework/docs/ConsensusStrategy.md create mode 100644 build/StarcoinFramework/docs/CoreAddresses.md create mode 100644 build/StarcoinFramework/docs/Dao.md create mode 100644 build/StarcoinFramework/docs/DaoVoteScripts.md create mode 100644 build/StarcoinFramework/docs/Debug.md create mode 100644 build/StarcoinFramework/docs/DummyToken.md create mode 100644 build/StarcoinFramework/docs/EasyGas.md create mode 100644 build/StarcoinFramework/docs/EmptyScripts.md create mode 100644 build/StarcoinFramework/docs/Epoch.md create mode 100644 build/StarcoinFramework/docs/Errors.md create mode 100644 build/StarcoinFramework/docs/Event.md create mode 100644 build/StarcoinFramework/docs/EventUtil.md create mode 100644 build/StarcoinFramework/docs/FixedPoint32.md create mode 100644 build/StarcoinFramework/docs/FromBCS.md create mode 100644 build/StarcoinFramework/docs/GasSchedule.md create mode 100644 build/StarcoinFramework/docs/Genesis.md create mode 100644 build/StarcoinFramework/docs/GenesisNFT.md create mode 100644 build/StarcoinFramework/docs/GenesisSignerCapability.md create mode 100644 build/StarcoinFramework/docs/Hash.md create mode 100644 build/StarcoinFramework/docs/LanguageVersion.md create mode 100644 build/StarcoinFramework/docs/Math.md create mode 100644 build/StarcoinFramework/docs/MerkleNFT.md create mode 100644 build/StarcoinFramework/docs/MintDaoProposal.md create mode 100644 build/StarcoinFramework/docs/MintScripts.md create mode 100644 build/StarcoinFramework/docs/ModifyDaoConfigProposal.md create mode 100644 build/StarcoinFramework/docs/ModuleUpgradeScripts.md create mode 100644 build/StarcoinFramework/docs/NFT.md create mode 100644 build/StarcoinFramework/docs/Offer.md create mode 100644 build/StarcoinFramework/docs/OnChainConfigDao.md create mode 100644 build/StarcoinFramework/docs/OnChainConfigScripts.md create mode 100644 build/StarcoinFramework/docs/Option.md create mode 100644 build/StarcoinFramework/docs/Oracle.md create mode 100644 build/StarcoinFramework/docs/PackageTxnManager.md create mode 100644 build/StarcoinFramework/docs/README.md create mode 100644 build/StarcoinFramework/docs/RewardConfig.md create mode 100644 build/StarcoinFramework/docs/Ring.md create mode 100644 build/StarcoinFramework/docs/SIPs.md create mode 100644 build/StarcoinFramework/docs/STC.md create mode 100644 build/StarcoinFramework/docs/Secp256k1.md create mode 100644 build/StarcoinFramework/docs/SharedEd25519PublicKey.md create mode 100644 build/StarcoinFramework/docs/Signature.md create mode 100644 build/StarcoinFramework/docs/SignedInteger64.md create mode 100644 build/StarcoinFramework/docs/Signer.md create mode 100644 build/StarcoinFramework/docs/SimpleMap.md create mode 100644 build/StarcoinFramework/docs/StarcoinVerifier.md create mode 100644 build/StarcoinFramework/docs/StdlibUpgradeScripts.md create mode 100644 build/StarcoinFramework/docs/String.md create mode 100644 build/StarcoinFramework/docs/Table.md create mode 100644 build/StarcoinFramework/docs/Timestamp.md create mode 100644 build/StarcoinFramework/docs/Token.md create mode 100644 build/StarcoinFramework/docs/TransactionFee.md create mode 100644 build/StarcoinFramework/docs/TransactionManager.md create mode 100644 build/StarcoinFramework/docs/TransactionPublishOption.md create mode 100644 build/StarcoinFramework/docs/TransactionTimeout.md create mode 100644 build/StarcoinFramework/docs/TransactionTimeoutConfig.md create mode 100644 build/StarcoinFramework/docs/TransferScripts.md create mode 100644 build/StarcoinFramework/docs/Treasury.md create mode 100644 build/StarcoinFramework/docs/TreasuryScripts.md create mode 100644 build/StarcoinFramework/docs/TreasuryWithdrawDaoProposal.md create mode 100644 build/StarcoinFramework/docs/TypeInfo.md create mode 100644 build/StarcoinFramework/docs/U256.md create mode 100644 build/StarcoinFramework/docs/UpgradeModuleDaoProposal.md create mode 100644 build/StarcoinFramework/docs/VMConfig.md create mode 100644 build/StarcoinFramework/docs/Vector.md create mode 100644 build/StarcoinFramework/docs/Version.md create mode 100644 build/StarcoinFramework/docs/YieldFarming.md create mode 100644 build/StarcoinFramework/docs/YieldFarmingV2.md diff --git a/build/StarcoinFramework/BuildInfo.yaml b/build/StarcoinFramework/BuildInfo.yaml index da429949..a43918f7 100644 --- a/build/StarcoinFramework/BuildInfo.yaml +++ b/build/StarcoinFramework/BuildInfo.yaml @@ -9,8 +9,8 @@ compiled_package_info: build_flags: dev_mode: false test_mode: false - generate_docs: false - generate_abis: false + generate_docs: true + generate_abis: true install_dir: ~ force_recompilation: true additional_named_addresses: {} diff --git a/build/StarcoinFramework/abis/Account/accept_token.abi b/build/StarcoinFramework/abis/Account/accept_token.abi new file mode 100644 index 0000000000000000000000000000000000000000..9d200103bba4cab95e514b53ebb285d0c755d619 GIT binary patch literal 52 rcmZSNNlZ>oEhvdE$Z_oEUXM5 literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Account/accept_token_entry.abi b/build/StarcoinFramework/abis/Account/accept_token_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..2b482dca062b2318b5715c6fbd3be6f34420187e GIT binary patch literal 58 wcmZP+N=!~pEhvdE$tTo6?yl?AB`0Jb0ww*UYD literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Account/create_account_with_initial_amount.abi b/build/StarcoinFramework/abis/Account/create_account_with_initial_amount.abi new file mode 100644 index 0000000000000000000000000000000000000000..3a0f339cc353d4570b0cde92a85dbb530355c5fc GIT binary patch literal 117 zcmZQnN-j!GEJ=+|Ois=(%`1s7&n(G^&&21c%u{Or`c n_>#(kRA%0^qSWGy_{5YHAYIJD8J}1RG$}i^l8uoM)jVbZNYf;R literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Account/create_account_with_initial_amount_entry.abi b/build/StarcoinFramework/abis/Account/create_account_with_initial_amount_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..85e0e210662cfb028ed70d85cd0bf586e27de61b GIT binary patch literal 111 zcmZS7NG?iEEJ=+|Ois=(%`1s7&n(G^&&b8nw4&7FjQGTq6d+y9!iQ=SGXTNfBT@hW literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Account/create_account_with_initial_amount_v2.abi b/build/StarcoinFramework/abis/Account/create_account_with_initial_amount_v2.abi new file mode 100644 index 0000000000000000000000000000000000000000..4c1f45295a18a8131e201e656fe1455d6ab3bb48 GIT binary patch literal 108 zcmZQnO)g4JEJ=+|Ois=(%`1s7&n(G^&&FKOw~c literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Account/remove_zero_balance_entry.abi b/build/StarcoinFramework/abis/Account/remove_zero_balance_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..fbf4971e07f1b4f09419d14af5065dc92ff9ac6f GIT binary patch literal 65 zcmZRSEK1GIFH4QDN-fHdPfE;5%u7yod$@!&uB@B#QCHdK@dGRHc H1*r@GXD1P$ literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Account/rotate_authentication_key.abi b/build/StarcoinFramework/abis/Account/rotate_authentication_key.abi new file mode 100644 index 0000000000000000000000000000000000000000..d69bd3711090057f9356eb8be41ea954ddfce013 GIT binary patch literal 64 zcmZRSEXprQEJ=+|EG@}M%`3@FPAtjH&x_Aatzod$@!&uB@7IV?0Ko>ASG;! E08^3>X8-^I literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Account/rotate_authentication_key_entry.abi b/build/StarcoinFramework/abis/Account/rotate_authentication_key_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..81a17ade1bde1b646230c12657146299bc2584b8 GIT binary patch literal 70 zcmZRSFUl`TEJ=+|EG@}M%`3@FPAtjH&x_Aat&9h9iz*pV0VBI(a&mrYUI_yOBYR$I JIY=QJBLMs_68-=H literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Account/set_auto_accept_token_entry.abi b/build/StarcoinFramework/abis/Account/set_auto_accept_token_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..9b5dab255076407f3479733b0c47c4deac06427f GIT binary patch literal 64 zcmZRSE>10pPb@9Tk55caPAw>jFUikN&5KXXD=DgEKn0BKj>*aSrFkU`42*24d5K9m GsSE&O@erf{ literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/AccountScripts/disable_auto_accept_token.abi b/build/StarcoinFramework/abis/AccountScripts/disable_auto_accept_token.abi new file mode 100644 index 0000000000000000000000000000000000000000..3661e68024d18bfd36fc740cc47c41d61d85495b GIT binary patch literal 143 zcmY+8F%H5o5Col;f}U1`dw;X+-|t;CVo=qXG3p{dt=-hn3=p)P6s^Rgl#J3rsBCMvZ0dd Jto_0i!U}23Ei#!e?;@$HJtfE8$^%OmaXJm(3R+_NC8nOh%3w8fzTmYHrJGo*ip8Xe1({T1 IZVzVX4*7pAVgLXD literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/AccountScripts/remove_zero_balance.abi b/build/StarcoinFramework/abis/AccountScripts/remove_zero_balance.abi new file mode 100644 index 0000000000000000000000000000000000000000..f0ffaf791dfb308dd7fb43027e6724298f135c24 GIT binary patch literal 87 zcmZP+E=tYKFH4QDN-fHdPfE;5%u7yXKn09^j>*aSrFkX6$wiq3CB>o&L0~-!AUz6B U5IqWvTqXJ0sd@1wl?AB`03GfbVE_OC literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Block/checkpoint_entry.abi b/build/StarcoinFramework/abis/Block/checkpoint_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..951dc0d50be147f0a28dd610cacc2f651ab344fc GIT binary patch literal 43 kcmZP+NX|%2&MwH$%qxjc%_}LYWIzRstWG)k$=N_b0Pbf9yZ`_I literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Block/update_state_root_entry.abi b/build/StarcoinFramework/abis/Block/update_state_root_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..b9e52802f2acbc99f04bca4b766e0c944707f2b8 GIT binary patch literal 59 zcmZP+FD*z(EJ=+oE&-86`S~UBsd*(ul?Z~d?f4Ej literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Dao/destroy_terminated_proposal.abi b/build/StarcoinFramework/abis/Dao/destroy_terminated_proposal.abi new file mode 100644 index 0000000000000000000000000000000000000000..ce2f1889bbeaf26c89e3660d2ffbbc34dce0c104 GIT binary patch literal 141 zcmY+*!3u*w3kO+tmW@hH5>M^mG;$jwVn9BIf6ea*T<|YgP literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/DaoVoteScripts/revoke_vote_of_power.abi b/build/StarcoinFramework/abis/DaoVoteScripts/revoke_vote_of_power.abi new file mode 100644 index 0000000000000000000000000000000000000000..23389794941963603744099b20158a509fe01b6b GIT binary patch literal 139 zcmZP+DM~HN&rXdm%P&cd&rgdl$S+SVVn79qd@hOkVL%1J$wiq3CB+H~5KRij`MIeI zAf3eu`FRS73I#>^1^LB^IZUi2Kr{2$5|c|Z^YfSmAmXV-@rfxZMXANbEZi`a@tG-1 ItYABt0e5mNhX4Qo literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/DaoVoteScripts/unstake_vote.abi b/build/StarcoinFramework/abis/DaoVoteScripts/unstake_vote.abi new file mode 100644 index 0000000000000000000000000000000000000000..2d215ed5b289f54c3d649a0e8a5be45ebcad09b9 GIT binary patch literal 92 zcmZSNDa|V`Nz6`-FUv1UWk3atd@hOkVLiBuQS27R literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/EasyGas/register.abi b/build/StarcoinFramework/abis/EasyGas/register.abi new file mode 100644 index 0000000000000000000000000000000000000000..f83d9bc9338d553d6061b324f38c8677441420d5 GIT binary patch literal 71 zcmZSNC`wJwEG|hcVn79q!mf$MmF|hf{zZw&IjOS*#g{&4u;?^UR3NQS zF5Z+8?S#hvpuG<0Yw@9%LAwZ@q;6Z3lE^ERk(ofI*uje)x5Yy{%UMCUs*~sd>tc5f zW>$*Q_F|WuG8%%68lnuXj$)^KuR5rVS1+KlOmV0r=>?e-FR9;Fc#TbiDw#OKfUfp~ z*iX^L1a4w3aP#~Yo+WUC;`YRzJ-R}*xAOND_&62Iv8f8dg-4VtajhgUXfcXgin-Z# zEbd7K>?25H{GjX2(fT^E7k#P>Qira+gi3ULEvd0xDa%5w#pJ2< GDT=@P_gq8( literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Genesis/initialize_v2.abi b/build/StarcoinFramework/abis/Genesis/initialize_v2.abi new file mode 100644 index 0000000000000000000000000000000000000000..3c0fe67b2c2780b6544131d0940a2aa7839cede3 GIT binary patch literal 960 zcmaJ=+iu%142@MFE3mdp)+Alf^(nQMMDfMK(Ve&>_Wh zct{oZ=#Wqv{G;LYWA*kcKK#^9M~ti0_lHQ8!4gh7MD$MF1>MU~L8Xlx#D+Xc1CbO+ z>yx9K$1Z5F==2iY5!w-@|Dc@?=qvHDlR-OzR>pQ+>|~5yp(N%8nW%+VJ*1(qe*Oa=T!@(@#+;+)-DdEjCw{!#dGS{1zurY zqe_Mb=+RZa7yB_f+rmvu1#Vv6!;=I~P~4u_vqx8`_E!GB0w2d>IW|^_aN!ZVg}6pW zFldp)ZKT|6GZYU|1?&iS%qH*o!We24jn^xrBD;_*zn<*-^DRC$5W6j_p73 zKrhI1V|>YTx7zwJOkxJMR{2Qc+dqPRz;ntmH_rlHloMGNo_Hgp_+s*S-UL-5U)SPk zRL4J5kn=|im{mNpFKCkmmu$)Y`+AH|^$wY;3#hnbj-83bA)9#xf64e#TFg%*&x)y{ zcsdtgH~96ic{R7-gV9H<6R`a~29@sI((CzeG8nFS@qKF(l`3dyBK zMX7lu3Qz+SKnCb2lw_nTBowFSrKA=mDCCwFmndW;mH~yJW&{8gIVTn*CS~SimQ*I_ HF)#oCI#?`y literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/ModuleUpgradeScripts/execute_module_upgrade_plan_propose.abi b/build/StarcoinFramework/abis/ModuleUpgradeScripts/execute_module_upgrade_plan_propose.abi new file mode 100644 index 0000000000000000000000000000000000000000..0f59d6f0975549ee781be2c645f639e027d95ddb GIT binary patch literal 249 zcmZvW!3x4K42JE{lNS#@K)~zpEj)UXolDomS=`#vq~Kn_=XTm62nPO3`11Wx2YQgr zLV60AN76YC$sp-C8n0stF)*!uNA1rawkznxCKrXD>QqcnOi)emHbFH(KLh7}a`KOA zL2mR#r_2I9kq0v*B5c8UTrvkwU>9fod^vIq*X*sh;E!q};ZDBU)ykv|Vj|}CwrtF( G9X2mP)mEYa literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/ModuleUpgradeScripts/propose_module_upgrade_v2.abi b/build/StarcoinFramework/abis/ModuleUpgradeScripts/propose_module_upgrade_v2.abi new file mode 100644 index 0000000000000000000000000000000000000000..a949b2605f38ed346a7270ad9ac26a181cf615b5 GIT binary patch literal 135 zcmY+*F%E)25Jur$0&0k{vhf<;!^&81COf}Cz@5nq5WT&L+W6}4#gm$-IMPFSnUEIk zj2LM>hyUX7@)5T$xMmx4_7Iy{MwI68`-$1$UhkFiNF7p7-f!Y|h4~<*YVkx)jEP>= K4&^SE!QlH9BYDpOVmEvqQX=Z d!ZzM`t~!S0X!40atw|eE$-DXB#X>ct8W;}oFADZq?VD9Hz^f|{Mcz{mk(GXenAIW2Vn literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/ModuleUpgradeScripts/update_module_upgrade_strategy_with_min_time.abi b/build/StarcoinFramework/abis/ModuleUpgradeScripts/update_module_upgrade_strategy_with_min_time.abi new file mode 100644 index 0000000000000000000000000000000000000000..f8e8ad1c3526deda24b77d0ab2352ce33291f1d6 GIT binary patch literal 253 zcmY+-O%8%E5CvdiWn8%O0JC#rxC0BK8>5jD<7z-UfkxVrwn(^xhZgyXVV0BkzULj9 znrDtsYTi_YO}W*(gGQ`1%ozcHA{uo6~2 literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/NFT/accept.abi b/build/StarcoinFramework/abis/NFT/accept.abi new file mode 100644 index 0000000000000000000000000000000000000000..8e678ebdf6e0745c2c4686c13d2b8b43e6d23750 GIT binary patch literal 115 zcmZQ%OH58qEhu3?1&o4zZXxc8IXS6CmBGnHnFS@qCJLT;nI#H|3JM4*g|z%41&9G4 iQ5zukO)W{(0dbu2Q!4G4IP%g;;&XvwU`7&9i~#_UKOpJ= literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/NFT/accept_entry.abi b/build/StarcoinFramework/abis/NFT/accept_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..6bbac000954dd76372168a442b862c87ca6a029e GIT binary patch literal 125 zcmZSNNlZ>oEhvdk%_}LYWIzRsTz+mL?uj`$sYR9c3Z8kHB?^fO2qA@%dVP;-`6-ol3TgR83JJxjc`2zy2}~S$X(jQwKm}k%5>NpH05b|C;Q#;t literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/NFT/destroy_empty.abi b/build/StarcoinFramework/abis/NFT/destroy_empty.abi new file mode 100644 index 0000000000000000000000000000000000000000..456cb71a6b807e3ff1ded3a0ea1ea4c87edc1257 GIT binary patch literal 101 zcmZSNO-U^-Dax;mPt7eTsboL}j3S;Xsd*)tX_=`-er_Sb$wiq3CB-rdE)YEmU_A;b WYM40k(n{iUQ%e%TjHLXON(KOtS02Ow literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/NFT/destroy_empty_entry.abi b/build/StarcoinFramework/abis/NFT/destroy_empty_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..808b5de8e4b340feeb698404fb44aae9cc74d1c0 GIT binary patch literal 104 zcmZP+PDw2;Dax;mPt7eT0g`zoMU@PwfRWcT1t^}GmYG`Q=N6)%-~!R2P?C|V0M@2} XqJW7bFRdg#H?<@Y%t*>lsbl~EAG9CQ literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/NFT/remove_empty_gallery.abi b/build/StarcoinFramework/abis/NFT/remove_empty_gallery.abi new file mode 100644 index 0000000000000000000000000000000000000000..17b89be0420c216f5af1c708508d8a372ca81587 GIT binary patch literal 113 zcmZP+DN4=FFH4P2%`GUYj89L@$w@7$WIzRsf_`ox?hvWq~GssI20 literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/NFT/remove_empty_gallery_entry.abi b/build/StarcoinFramework/abis/NFT/remove_empty_gallery_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..b1fbfa40febd7d2d8712cf8f229861b1b293a1de GIT binary patch literal 112 zcmZRSDoV}GFH4P2%`GUYj89L@$w@7$j8DxgDXL^Z1&myNZXxav1u6;I6luA22CXT$clK5Pp0GN>k6l4GZS0Ex% literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/NFT/transfer.abi b/build/StarcoinFramework/abis/NFT/transfer.abi new file mode 100644 index 0000000000000000000000000000000000000000..492b218d3f592f9a7ec995649a9e69386ebd4e33 GIT binary patch literal 148 zcmZSNC@D(JD^5!-Vn79qf_`ox?uj`$sYR8+$wiq3CB?1^AyBmnKsg&A_DwBG)B$mv z@>4496v{J8G87UrQxX)?it=+65{gsvQc{Z&6iV_H5{gojQ!~qeJSL93w37H-piVF& Q38<5aDKmwM1Ezun020?NT>t<8 literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/NFT/transfer_entry.abi b/build/StarcoinFramework/abis/NFT/transfer_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..8d60d00add5eb81a28d97db17b8cd7fc533c05a1 GIT binary patch literal 119 zcmZSND=A9MD^5!-icifeDXL^Z1&myNZXxc8IXS6Cm6{46P^Ah$L4~xU{9J{E;?%s9 t)S?81l6-}PqSWNn%rYR4i6bwqBtAE_BoWL=%1^0eV#-Wm;()1O0RX&3Beehk literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/Offer/take_offer.abi b/build/StarcoinFramework/abis/Offer/take_offer.abi new file mode 100644 index 0000000000000000000000000000000000000000..a9ad0fa82daa7b9d54a2bda74f4d8a74d3198b16 GIT binary patch literal 112 zcmZSNDoM;vjn7X@OD$qR1&plzAW;*A5TFVLFk2xpFGZoCv_zpKU!gcNJukILy;#9H nKPM+Oxg;|`&jze0HN{SkksWMeY6>GSm=T|tl2VjfT+9LhZ_FU^ literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal.abi new file mode 100644 index 0000000000000000000000000000000000000000..884f242133a0dfd3c23c4124f88188cc5eb7697a GIT binary patch literal 96 zcmZQnNUcasE-guo&(Dib&PdDzlKFXQnd$KbMfnB!#fdo#sDM$#KhGJY&KayMIJqdZ Vprn|Akprr&gpnJjGd?qg2>_4i9Yz2E literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal_v2.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/execute_on_chain_config_proposal_v2.abi new file mode 100644 index 0000000000000000000000000000000000000000..4fa4c35ae48059c06d426e5a35cd997092d34d6c GIT binary patch literal 128 zcmZQnPOV5yE-guo&(Dib&PdDzlKFXQnd$KbMfnB!#fdrbWkw9BfKkLh&l#lD8LTom wxhS)sq?mz;t0X@=H7~xTvLKZMYDfu_0K}ZsqWHv=l%mw)Vis<=$(bok03miMaR2}S literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_consensus_config.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_consensus_config.abi new file mode 100644 index 0000000000000000000000000000000000000000..543cd101e7edf2498e698efba40846aa2c98e310 GIT binary patch literal 336 zcmZvX-3r1m3`VzlBjSyqf}r>?K7bcKK&ffA1-rJiDRXb{enh7%SK%a_FUik7IPW6L z5WU;@i&U-fw9+Ij4 z@ZG=zHY#Z8F^nsV(?1@K-2$Lxu|e;kdh5WY4jm@}nu>xT8E$1mR=Y;*YO-_bwR+Cr k!{F*?Lu~vWCbpB9QblQ~CKk)c{j+78ukeW=H5%257l6TdQUCw| literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_move_language_version.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_move_language_version.abi new file mode 100644 index 0000000000000000000000000000000000000000..20cc2fa37bdc490fcebd86f4502be32b5f8fb34d GIT binary patch literal 103 zcmY+*y$ygM5C%}7)YcK)!~rZE;BwJVB*8lZ__w{4g|C0MPg#=|(2*9dpj}T;Wbp@k m(1~1viutqMD8t4<29-7VY0e?lVvK7A*LPfl8#674{J0mKfgk<= literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_reward_config.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_reward_config.abi new file mode 100644 index 0000000000000000000000000000000000000000..8a2a050dc4420618735cd693b78e4d566b7c1b55 GIT binary patch literal 96 zcmZRSDJaS>$S+QfFD*z(EJ=+oN-a+;N{LU-&r8cpXFvsvBK~>K8Ht&B&S2T#KWN+zzOs#QwU6cj-_gVKf4 q6r%7(yZL9Qh5ZqT{ikazl(ib;#?(qs5{8QJnW`JGV}yifxZMNGiy+$o literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_vm_config.abi b/build/StarcoinFramework/abis/OnChainConfigScripts/propose_update_vm_config.abi new file mode 100644 index 0000000000000000000000000000000000000000..2a990bca6b7f541e34e8d467df74325ac39c4ee0 GIT binary patch literal 416 zcmZ`#J8r`;47D|M=+G`kk|OBPv*Z9BdH{l!DTjbW3HqdQPhZJ_fdptZXn2qBL-vOd zeej8(gb6dj#ew!>c>{nC*`PF?phu%sM|&g=z}KGRezJ@v1GnJ;vQ z9B1oCwBX43xImx?<5Cl~Pg#BZLw-lzM&29?c<+|{FbVY4zKKr11WB-RlHgGo8PWQg~*y#!4{-;RrDAB-thZsiGK*HM_Vwd{bo?F hftF8T+VdA^Bx XKt>S*10#O{L@+)vC8a2}xR?b1NjV;M literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/StdlibUpgradeScripts/take_linear_withdraw_capability.abi b/build/StarcoinFramework/abis/StdlibUpgradeScripts/take_linear_withdraw_capability.abi new file mode 100644 index 0000000000000000000000000000000000000000..aa00d595bca5c1539c642797b187a94fb93168bb GIT binary patch literal 146 zcmY++F%H5o3_#KJ4(#{@3~&nOiaBzflvtQJik(*6z7kCQ`RPw*$5)QRHDixEdr2Ml zNZ4>;VgH2xrqk?6czLvE$CPL4+}!SfW=f3CS^qj3U7$DLI)*p%Asf$wiq3CB-TV5K#rF o5emg%aRrb`3S~wLCHV?KlNbd`@=FqP;)_d?;}di9OY=&Y0np4ODF6Tf literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v5_to_v6.abi b/build/StarcoinFramework/abis/StdlibUpgradeScripts/upgrade_from_v5_to_v6.abi new file mode 100644 index 0000000000000000000000000000000000000000..4556e0dee177ee7b6fc436f0300a236dbec1203e GIT binary patch literal 63 zcmZP+EiFhdN=!+OPb)m!JNQDcm>@LWBC#(CShi}$nCAcP5r2(*boVX*)>WLRLi!qGy JDQk9%!xsmXDwzNP literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/TransferScripts/batch_peer_to_peer_v2.abi b/build/StarcoinFramework/abis/TransferScripts/batch_peer_to_peer_v2.abi new file mode 100644 index 0000000000000000000000000000000000000000..77a837ee22e0c1774f99ac5ed3c6804d7a0d7b86 GIT binary patch literal 121 zcmZP+O-d|D&WJBaO)ZKq$%oKoMhvKckw2s;F|Rl+wJ12bD6^oXSV6%Fq)nj&Dy&eF vpPiZqBo*>YGE$3*^%%LpBJm}a1*uHz1&NiZsj0dk=a$SpYZe-i literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_batch.abi b/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_batch.abi new file mode 100644 index 0000000000000000000000000000000000000000..0e6a00b00275b6a7d0b4a825ad8e90095b6f20e5 GIT binary patch literal 105 zcmY+2!3uyN5Cs*XqD#@Q)qUCIg(0cvdhqXyIyILWMlT7-B#~b4EY_(%dfGCFav-lZ jpGk_+qePED(h|%-i5q~@>G@0IDvmtbvwGqy)*$8v1hgLr literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_v2.abi b/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_v2.abi new file mode 100644 index 0000000000000000000000000000000000000000..b3e5683aa44a9e5b325dbb3dd40571434908cc07 GIT binary patch literal 78 zcmZSNFGx)-iZ98J2h(Ln45)ySKcpxzuQ)BWC^)$&v!JAyfsv~uKRY!qzNE4sm5H?= Ru`)H4g)K2RzcjCe82}9b6;}WN literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata.abi b/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata.abi new file mode 100644 index 0000000000000000000000000000000000000000..1520ef4a5321644322edccb872cb99758a3116e1 GIT binary patch literal 118 zcmY++I|_g>5Jgc3HHb}mx263s=o3ZqA&y9PuLLZ-&FL-;5lF0oi}$V@JE$z8QvD-4 qCGqEqG|p*{dREkHIN(`xMAJseKx4Vca=oVm*^m(zF0Xa>eGNS!Fe9n} literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata_v2.abi b/build/StarcoinFramework/abis/TransferScripts/peer_to_peer_with_metadata_v2.abi new file mode 100644 index 0000000000000000000000000000000000000000..461b7ede9224195aa646f979d7d4ba2ee548cd4a GIT binary patch literal 103 zcmZRSEl5o*iZ98J2h-)5B^mL#sU?Xii6x2gWkw9BfRR6>C^4@%Ewv~(xhS)sq?mz` kt0X@=H7~xTvLKb2wIH!FHI;=eF*m<7uY{QcW)K@A05a$vaR2}S literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/TreasuryScripts/execute_withdraw_proposal.abi b/build/StarcoinFramework/abis/TreasuryScripts/execute_withdraw_proposal.abi new file mode 100644 index 0000000000000000000000000000000000000000..c718e096beaa6aa06e261b96d12b0fcf14ba2a49 GIT binary patch literal 101 zcmZRSOsz;wE-guoFV8H=NGVDzk1r_7FUT)W%wa$UjQk-*sfop hCHdK@dGRGo0uVi^Me&I#DMhKp#Vp(~Q{ppIm;eMIA9nx% literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/TreasuryScripts/propose_withdraw.abi b/build/StarcoinFramework/abis/TreasuryScripts/propose_withdraw.abi new file mode 100644 index 0000000000000000000000000000000000000000..471d3f1c6edbe320d07b58cdd7f4869564b55421 GIT binary patch literal 99 zcmY+x%L;%X5CzbzuxL~NR(lb>kn|WC$IQQP-8pKBOpy{y39@^(rTJ6y#;_@KT^)xg isZoQ_f!jzwG91DK?zO!r-_q#_4&>VjFP!l>ZEZhEtQ_J1 literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/abis/TreasuryScripts/withdraw_and_split_lt_withdraw_cap.abi b/build/StarcoinFramework/abis/TreasuryScripts/withdraw_and_split_lt_withdraw_cap.abi new file mode 100644 index 0000000000000000000000000000000000000000..2aa691183e004ca09cf0fe6558fe85e5454fcfeb GIT binary patch literal 113 zcmY+&!45z$3;<9=I5_wRzr?+1)``WeOIs0t&q?APpPQ~|8wp;3nLta52Fc)CkEQx^ o<01j|lza9Pi)rP0<2_`sW>{GOi6p4D9UgqskE&~=THdY6H_WWp$Q;Y&^w-`mZ-Z8TAd|~Wi zNNWOfGDbix_pR9YE%Rfe-@|3nK#q srzjT#KLZ~l50f4@lLaFWGYc0hKQ{v-JEI_*IyX>?o7sYikqM{;02rndH~;_u delta 177 zcmdnYe34myq0DP;HUskE*lm%F4h1m_AbU$j`xfLZ2uWWxF$2P@yuju zVdR}VQO`)8laY~uiH(s9NOH6D07-UUK1K#sHg+}+HcmFKiTR3L>|C4-oD7UWa$2WhzF!M08aIx}p XGcd9<3bLtl1Esi`Em#TyfLfp6@fx;<~kT}4B3n%ym-1r3?h^QGm;LuXfOjmzX{qE~C%RVS%?)Lchmpxygd|0~!>gR~NzeJxG za(}dXy&K;x1-OM*EoAB%0L#2NX#;bcQvlq3tC2jfLxY|dU>dmCngOu++tAa)GVj1* zOwbzu2%O(cV&YxMQjYf^UIr%KhwK5cGatY~O6+_HM>ylR5}0*6f$=-(_eTIVWZuW{ z3>}>Ngbt%@catr+2Sm#~bJR$y)^;Y={IxKQpN*q9h;^KgEAjF8M7$nv=#9CJ`Hh8B z{>IX&@VSXvd^$Ysw-?&;ZQY)0FSS=1@k)F!-dGun&-iD;x!8&?w3g%LiI*l8;+OB= zwjwYO`HcCCPg-Eh`{Uw4#{8YTbpNvVy>)!KMdGHz1&IzD;A0}nfoDrxX@!Sc3W@mk zD7h%Q6a+_IOIq5KR*-YKvOFG)qMLxS!7+0&zh|oheP93}6dMCyXdeS$7NC_x6gVXv zV4m>Fa*6^vkA-aj`jQ1lT$HE_5toW-5UygNkWe9p+bG^esIG|Hl4*x#(F1KIr1qsm z&5=sZ^b|7dB|6Pgs5?cKelKH@NCH=^-~g5$e`f(Z6SmVHWva}uC8nz`D55b69kzlz z(_L5wh9G9m>xIVNZmdumfUIJK$WZ30!aUbKSlt!R?!%hrJf1v2?##3L7wBUJ2u^11&pBuf|v(w}m1_92soZcf?}B z^O9tgn0NIcadGqz-DQ|2A#@{YpLFD*36f><*hI-_XN2Y`X*`w}O@Tv%fqas3L`1w} z7s4WlDHpp}$FaU$fd)}f=vkp|k_AAK4XCD#|8K^-Hb)Y{0Y`U~yk0E9N%L8;zP5)L zXK{>bK=w>@Uu3h4sx=OrB9_PW1U6GYWjyAqFj0|6??viQDnk;?B|$Qi-ebLbyRS%PK*ACdm?ax z;3Ta^!Ie_RK_4GdRNQj!dZctL!jui*pHx zNTp1#BurIim|qrGcH-vKN?~iWPMs%xFYM!6;s!V!gvZ5{-@m;a<5E&ui!{&Sa$=&# zZ9R(zo`g1WB@G-ScTv&inVbF>3BGDl4sDwu(KoTQViGqOT z+aTbBp!jGnR>{GWS1l~d3*M;mz#m}g&68D>mZcZVgXK4yK!IJ=-P6DR_1E9y*K>R8 z)uD+m@^__42uT8IrL6~yb3ZY5hhGGK$Nb)~*2Ir#`wVbG2>T%B8P{VT`>_7~5!xZ{$1sg9BtNNN&UCy3p8`7Q%G4EJdi;U>$!O3W{f2DscI(2i!D1a*xgqk=Q)WT6;Vxufx>RW91 z=HKi)yMeDfclN?7=F*vS=gz#8IQ!!HQ^%JUm!H*NC6_Jp^vd%mFPyrWcE2$Olw0eH1&ZP zK#drYU}aTE12hsZhY?U2nqDVRPY{2HL-Dq3feA?za7Pl56j=@WMv#M?{x;}HHKHLy zQq{zpaHm=S8nkwfxPqwsHZnm}ivto3^+L*&5D?W$b0`_$W4bq8-qJ=J@p6EKB*?JQ zK#QaSQw7@e0G`;uld7mMr@M9^EJ;8*Q|%NrgT`o6-B}Redj)3mBsyw^KJtj)C7_q5 zgn+g$jZ@73>kFZ*#yaoOU4xg4kpaFR;`D3sy)5)MFXBPIRaXs-*wO zgfOppwhTLUl%2`$>Wn2OX+v(vv4k~*Dq;R{y_P)>C-lGBCaPRLlk0)1-qSELRi(Aq zX=BeU)@%`D<O^xbmPOXm7vHCT8FUPW6M8Py;trM2?pDE!2^W<{h@=-b{ z8*qdWkzZt8((rfrCj}H)8}CGKtRxD955%w#9tn%Af~yTYcK*H`;wUhNgkuZa%IM#7 z5|i{#uC%&@B34Q!y4ewaEIx`M)Z;oG$0hA13?Dd(V8F*0w*)-9o48z<$&uR(g~;^<$yH3aSaL o9jFmHU8l_IpBwX=;tUO-&4*f%fPf$*)--nPzI6xN{vJOtnNiL^RLP4; z8ez=JITGJ$c8w;~qs4>_W#TE_he)y5N@3nk`)ENo61pYj)YSys4FjUIan} zNIMPav4^&0mwKz_ZvClwO&+Oz*yl1*hJp4t7}kw>Ek)z9fQ2Vb4hd)AQ3s$%$moS^ z2;>l*I8A2$h!1Avs840I3bYjj`UfN@!J!(EV}%uD=vk4dNL#;Q)BtjIYwMYkGzr2l DrMxEN delta 469 zcmW+yO-h_W5Ur}NuAct;=KIV?AZ9iy5+Z~!kVUUu3JG|EVT^+sbw(y*M9^gxSx)8x z@d}cq8;{@ta)6Laq&{oWyw~;mb-lWizcRcV{EGqr5g|}uQ|B3IVFBaEwFq_Y3SN`Ji>+$Gd{P}csg}0vyBnmi$P43y~Y~$Vp{19lH8{0Zk8p**n zzp?{oI;P85140A{n-vsvu)$)zV{H~%?a{`UV%kI*BNdKDRQX&lld(Bs6G;<;mkbV7 z08P?}0R6WCYDhL%oyZhQ*lqr~bU+GbiwCwJG$}qcA^}ZW2k|E% zzY3{N#i202>9q=v!jgU)F2`r#kCcT1L}UbK0q2ku0E#5ITmhyyhQy8$8NgBqIEsL{ zU=y-HN)E^hwnXMGkQZs0Vql6AV7fR~h+9>W0X39>dd^vca-dnjOaZL|+Fo`WunDo=W)#@NdiGCvUatPVIVSxf#{-0){&_9Ui#swbP<&o>@#K6<#j zx3M>p+dJDMxx2G9^6%w+x|8}u&4{jFR0mX<^-pbOe!$~QA~x(7%*nP&Eu73{tYV!Q zr-zyUsczSJd0y8M6Twa40t)%g>SGr>X#92Y>$*Y123NHFfnK5Jxqw%ngg-3=rLmx9 zw){}n?0{E4XAcdt`I!A|+M?xunRmtDZ^HRTx5xd(S~^WrtZuJbVX11t?6$aD}e2K`ayHa`(wOxlDWS41ECF9wg3PC delta 707 zcmY*Xy-!n76hG&@d+&SqzOOzCr7Z;oqHUo<1tV|K!Og@34bjPj6ljD9Ew)voi;0Va z#zd~0(dgh`K-@GMql24qcW^V&+1c}8FrML;bAIP{KJLf;;``#gSCwDB0sxKRk*A#K zCyGB-Kux+jdzj zQwsK_7{jW4E1qJ(UXle$(cX|HO36NwXA6!`e0@G8B5+dSJLK^jj2#N)o?@M1UBxb` zMI1k*UHdTOy#xNE+QErKUfYW<^X7nm;Ev-F``Uezt#H*lR;pHc45t1t<@u>6PZ=~+ zFu>VFPc*94?AIJvpwb|aMj4tGO*v_Rm8!snfe589($N0)%Kp@u{~GWKn|hv7-?sDu rrGb5}=Z4bIhm&qI;6D|j4~ty-U0OABlL32EFsES%yDbLKEJXJ+BITzj|pM+zbm(1Kc6)SHjZdz`d0 zyn_3x4h(-Qn&L-s)xUO=@Yx;d`0;Rad(WKF1qxm&0i%}TNw0_yk3z2PDum>0tU$b0 zH!$ToGWv6E34>9WC1%_M1ORPF+$8 zASgG>r?=YU_yzMAnd}2%2dLI)xipQ61{>mI>}7+k0;KbUmSF2Sbfb`pzF#a^mGRek2CwqJe&AEh6heT$rs sHyEkKNhz_TfzvO0Wzw#gPw;vu1)@X`zC&Qiw+P=h*`A_oP%A}$0dtW#qW}N^ delta 547 zcmXYt&uddb5XX1+=i8m#_wwFLn^S>kYR14ERTA ziZAdQ)K7ZOlQ*g&&((GFRdwytEWYqw0x&}ya-8vwwHP$u>k0cj^E{a4D76 z9J$pg&veD3WfKe3-1EmR7$Uu`t3O#74g`~;*`_Ka^ zhNIKzS@=wMTJm@}-k%;+4#y7%$A|a&gUSAEG#pRO-pOQg@~A(Wg+KJM(WkQq2mQUl z-J@{Ep68w*@leohN~2GpNm$`4DW!R`No`?@3h^x5=IxH@82j(hi&*DdC_EK+Op%eu z;XkkW@RDy>)4@DraYE!SeB!q7Yqd>XiK!Q9=|e86t1rMf yEWHu0AQl=IaLiDlMpqDzVJ@z9t84rn80IYkQe@s0U=xg1F!9klP!dmJl#;*m)ktLk diff --git a/build/StarcoinFramework/bytecode_modules/Collection.mv b/build/StarcoinFramework/bytecode_modules/Collection.mv index 14cb6885c15c02e39d50fe39f2f4d45ea04ee280..306c01fc8c236d304380ad8666cf6810adb50368 100644 GIT binary patch delta 352 zcmW-cJx&8b42AtXzZuVNGP?nq2#G2MeKI770tpHvZh+t#bd*SRX(^Dn01cNwoB%F> z6hXle@Z!Q_&zpJv{O(`;>Us7po`@Py;?$YhmA&oU18%|=zlfh^;Lst<6vN z4b7MH?T_26FDoV@#HEQK?pg;jePY5?Z?U7v?oPZ)du5Q~D5u;;j^n)fSQZ$h5g`ae z56!QKxW?USWPkwICaPqu3xP_UCpxADDuj-}tia9+t*A1ap)o>hVhb&cP?3ZsPY-N# zjQ{~9&jkxQi>x5}Iwk delta 380 zcmX9)J5EC}5ZqbsvmJk4p5F_fB0{3d4HAtT8DQKt>&~g!s%I$Ytl5|3BWw1Fx_8t14?7J*J_iOP{qz^tJfiL|C_ z*o=dTv>_HKERjkISn=#we3LbUL&=MXB~@W{rfkP$x=_PF8B_*|6I#?p@_FPls+zpI jrjI-xRqWY~NETT z_N%;<*<0H;@9o0x|lZLhJRkRs>WL(u_8`7jUv?0Kj^Ho&d+M z@tBr&^;se^&x@tXfO2&lEpOz-A%1|1T(z)xK&U_fG}{iMR7&?eH_|lNa{M)IB$M z;BoibOy`dX%T#Nf7an2=GMC&q_c9jP|Bq58rTb~7M}4f4KIN%*__86$fL^jSI7rqU ieT{#>${FUVE#Z|^vQaoeYXSaRB9B{zq!-;&JNpCJ7&+kp delta 671 zcmZuuJ#Q2-5cP~dcGvdp-fV8O_pz6|B$wRrkw{4BVxkLlbaa$ZrbMEkp-O{9iO~K6 zN`xp-3PeE_XlVEgAW=a{LCg3;Ni%+)XTLYk{**r}PF^*?oDo8FKv=Y;Y<`1!fj9L9 z{)FVM`XbXmN!L72SN0+uyKkxTKhn>-^E%J-_xa0{H)qP$8U*YWg~0s*%iw%SAe0|v zTo+Jr=L$7kuSQl~+lsZQfIHV4uBzNB7~28MsNOW*t+r#oKVpmryNnHOQcZozXjqM^ zhQ_p2r8KFgRBzKxwM(;VkM>CsP)SI0TC{iJY=OpRLK*-_96%<3w_qGbn5-8};)(V< zj6FoS-e=-m;Ri7K^wHxdPtQNf23A3$;+W7svJjL~I&-X{X)w325?)(~dBxpbgNSz32$Q(GlCGN0cR0Zt>^=^w`G3Cz~51lyXw#OWUQ*{S} z@sLCCs?cSkSlL17I1D-4ac#fq!yBPMAH^mkD|p1(2_6hBUJm9papLt3H(mh36|dQvLjiz=VYj``yXaAGVMDvxnE-$`5n%E%t^pYk4~~RScuj< ha*tpC(ixUfwvQX}$}G2>+QUCfmcD|^_JXZ1;7jNu z2v#;0zJil04#}6p`O?gfd+`s?o8Ju+Q3N^bW^Tv%c?p+`_>Oh{Kx)76WYvR=Ua}R= zC_J?0il9LB3_^+tS_T-FdSHyTK+;!(0xXI2zsf`wyp>4)WVJeBufM)M9XdYl7R!DZ z@AlXDs=GN~Uhr8z4E_E1nq#4s1%<}XBPrNulR!e5c5%?kp^)lO_4J7O%8Pm~(;H6E YOxtFbgKH>IHcl5=Wn|<3v&n{j0mO?UN&o-= diff --git a/build/StarcoinFramework/bytecode_modules/EVMAddress.mv b/build/StarcoinFramework/bytecode_modules/EVMAddress.mv index 486a2ad6212e59a89d0807ca7c0d0c46a3600c74..9cb4ecebac2b0c410bd4a101d46305c5b3bb18f7 100644 GIT binary patch delta 173 zcmYL>I|{-;5I|>kXJ^CC21JY&##pF@O^8)ur?MCDB!aC+urUTJD@)JeHN*>e2|ozF z_VM0bA9Q|6pTYnj2&9N~l+Zw#;lzeA+O>F(&Yh6`8E+UrR9*Cm5OlrC>g)W7Az89F z&R7^zw)lL$G;2)FiaUXuE#~1byme&3ncj#hQ^a-#frS`3qve~6@*}6X=yD+f`OcMu{9AXdz}+T#On2FLaZXVnMRLZ1q?uow}s?P*g(yd!87s+DR;F4P1+A_UQf0=$mDue+FL-(T85M zZEKEBHR_^85IOM$dN5+NTr+7V2pgzQ=hhl1QWyym;{r4dm#42aSbwz-p@AOQYN#0% z8Z*#DAP8_$fR+R+q-aag5iSF1o*^m0Sps~K_8Y_WDH!D3%lIL4kI|Zt*k2K-T6h;~ zc<34#dbR*d0`vn-l%)=IUVJ=DCdd*Mn-vM^Y#zQ|f_V|XPk@aw_Z%rUNwHbDObC}2 z3ClY0 zHpLa2<1Sm`7F$)vA(-jO4DVqdbgQaCLffF0x3|0z3$lEFwyS%{2C}>nJJhWVVzcjc z;lRGgavnS3#|%7nsoTl^3LbkPqjF`19FM&Ze3b$6*bg672rCKK1M1l5dJsMY-)vmv z?RlT$2Y-M~Us}I3G0UixB(TpAgJBl0&{YcmzXT^NzJyFj~JOOEy z3-TPCAy`A6vpOXcpPs??WS(z%5n5Gg*jS!#`5D-#GC&?@Ma92G;-NqjeNWFx@w^l- z2$y1mA5G0g+3RR(hU1D$am7enQG(Z;A|JHNG;VT*g19BQ&D9bGymG_ERo5u&=5x+9 z*ZR$i= delta 2490 zcmZ`*TaOe)6t3#a>FLYNPVdg{_Uz2A1Goqg2}U8K;)1Ke8^rMv1cKu3iWgiLgjItg zJ6@ycgKIsQC?V1KVoVIi#3vK>$rlqJ)F&PYiI0-7KY$QUb)TBbG}ZOcQ**xWob%OJ zRXuZI`qK2$cg_DpV2lNv1y)e92X{D6mfZc*-naZJFP*Wg@QwY)+Til!Ky-ETLKB&s zSRxM)O_gn{@ z5Zuc0iS>TqGt0w=zx?%f5B46OTReJv`Jef!d-(NZizoeKZ=QJN(Cp0IYrpQ`XX8c~ zSdq;wUJgo974t4an?-IJg^BJ^t=Z-{<#1X`!vRQ1M{Kvb*gTX#O0Xq2n>uo8A$UrG zpd#m0q@?M-0jp)?+jB)A|sg-b+EHW{hh=)#cgQGO;zZM0w+|YHA1CZGLjj$Mu7_oT&KZXb=gTB zU9VDBN0M!+6B}ToNgq0~5r$2Om>MM$Z-+l=bMq!{5?ksd@($g6v$A$&loqo^gLf)r zm4v{%GV^Y&`R$Eyf*2`%iRtY6CyU%lWY^GpkXAuP$w&P z!mNpaE3+_@PE&1^H4EJWWKQ0J>;%6E^uFs~m1vEVw3o~Ttp73urut$* zrM?RIOOTE}_c8SdY%n3>_i=J;zM%H1s=ZJs>u5ph)CBGM8|LOH>$q4MPdELG3DU7> zZX;GE$ey>%1T6Np84;CR=+d4v6EO9iLgZcTWOngRlN9tCyulxpGz;nryQ!cW$H-EXV?q>8OcGBGdC^r wa}F)~5tf|LwYa>;*fS177V@?wuC&&!DMxL)=g%OEIR33+Wr_2U4RVX!02H_GD*ylh diff --git a/build/StarcoinFramework/bytecode_modules/Genesis.mv b/build/StarcoinFramework/bytecode_modules/Genesis.mv index a993a71d8b20ea01a2e44c32fb6c58080a58ace0..8d67e880e708d6507be92afbb8d77cc790b1d63e 100644 GIT binary patch delta 141 zcmZ20vsy-fq0DP;HU}2;0zNnccA^3Vm;)XKwgc${2cHMk2?+EM5C()1 zfdLGK68H(RFO2~S9ZCT(0RRjjF_XUm9s)HIv)uvU0R#aG2>`Rb1Jnct1!Zk;ba}Ip a2uK44I1UT}I1aP#3pD}0j diff --git a/build/StarcoinFramework/bytecode_modules/Math.mv b/build/StarcoinFramework/bytecode_modules/Math.mv index 2d856ff65174a6b7437c74f959fea73593244c12..034dad6d3ebb46c0a07663fc6820bdfad530c1f9 100644 GIT binary patch delta 190 zcmWm6F%CgN5C-7+cV>6-6ljRNifCy#0F6rJ0P+$Ef{@@Tbt;YQ31}ta04||(1{}g} zCiyb+&tyLOp%0h%8yO<9AjPV#8#UW+WzvE5r5+Dwf-#)Kq6Fhrl%S&=Gp2pz46dKSyx~D6Yq)O2MG=pN2CHa zx-2?UR4_LsSdM?Yef`Kc5{ps954iOP)^x$M603f@zp@&3t&_yA^eT2E%oju^IMZ`VZJ$9@_u_ diff --git a/build/StarcoinFramework/bytecode_modules/MerkleNFTDistributor.mv b/build/StarcoinFramework/bytecode_modules/MerkleNFTDistributor.mv index 9b6c88aad4ff46335891d5a6b5f3c1745f20396d..bb8c651a7e8ad0a5f1660696ce1e189bf69436e8 100644 GIT binary patch delta 498 zcmXZXJ8M)?5C`y?Ij?)qoO|v)ZuXH)G$Dvdnr#F`deB?|3IEQBN>jZEM0XHzUr z#`~v>=?guX&!@)+={s$8JI|*_CoiYtquKFd{A@Cx?9UEoi_^3w;wa>o0Nuzf=dv7C z#1J83o){@26J;erRWJ;J(b0e@3Zk68mR^gSbib88itU4y+YF&}rKKS_n@hN2z(o|B zvQ{0o$cP4l-S)zl0UUc{?OkLJ9Gu)zyZ$+#mI_b$nCMYjhW`bH0C_f1h GFu-59-$7RZ delta 625 zcmXYty>3%M5QS%E|L)ycuYGTf<0N)|EJTO|X(+N%BGFLr1hkeNED?cYD{%l9M3QER;EoNsm=jePpSNSKuf7!WW3jj5Q1~uC1_FP}$s`-rH z(7jh*Df?j>_S&rbH#X;Ymcj@7UDbZ)I{vxXe{}AeUYvNNjtH*R@KTrM0k*wd0IkFb zYE?#ht*yYsRjZtKuG0~nsjqu-&UBYEbZ&ifOROP_dB_SXebbcn71wMui*8viHOVS# z&=VPjNR|O}P?-%E*9XeyQ0?HFB`ck(9$@M@>2e?`sBFkFQ<{`^nid0vP8@IXXV;9z z)7d&FGc=CMIA0Hjh`iFz* zV0iTGXg2r%#QpKvtolMJm9k2}kRVWv7!sz%jY%b9BH08&%oq-UG0-kk(nR7|s$S|% zy9cb2sXprVIh&@}9oAc<7M|8UhJr)x=>US4qe8aJS<;)jZd&Y-5gim^JF1u$5I8#T z_mH`$6;b!h&VLDsguSF#7An?k*d|9B0oLw%vac5Sa;jgdM=7hidWTY8J=7b8_rUHx o$e);uNHzrdCZ!;_+qZg=QOIMGZ&2pSh3-f;0wQ?4<-Nr delta 192 zcmXAjF$%&!5JhKpb|#zMCAc6K5(5%YD?zZZ5NvF0Ej)lA3W|X!c#a&w%6r&(1kYgQ z4NUMi@4fCn)mLTr^y35oA_PNbpvS_~MReJi7q?`;I_Ied| diff --git a/build/StarcoinFramework/bytecode_modules/NFT.mv b/build/StarcoinFramework/bytecode_modules/NFT.mv index 2e48c3516761fc5f56c92358bcfb0387d2982e76..cf97fbd3cd94c264447836e29d3e4e945ae000c7 100644 GIT binary patch delta 654 zcma)(zl#$=6vy9tGqXSD&1`lP44TU&@jy39^b(UxX3yhtprE}9-kmn$Um*4tR)W}U zc_3H|f~2t!tc3VaSc#2=h2UZ5Yy@pY+-BaJ+3%ar_d6fD$KBl*?JpbvfJI0ty(#X0 zBDoYD^;x_Z;mdHTqi`JB(hf=(fj)K!imaj zZ{v3g6{=TteIyghXatjy3@$9M+ri1uS5YD9^vYnvt_%h)E}z=lx2El^FhZ}~I&D-U zSk2?OKqEC+>DV91IckUtm;?KT=0s;bpX)m6NvUE64AHytgQyzhOj#sv(U#v6cQv8S zDzGBT#yisZ=U|%J6EyUj(RR!&&V1VE2WLI3~& delta 612 zcma)2JBw366h7z7%zez6`${mbn`{zAO_1nrHrZruc1a2aOA8fTUxg^z2o@q(34(=< z&Bb1O5hR5o{((hUuvPp6iehK$+`E53rWn4NkMH%jv)7rwZvA8r03w8x(o5p@50d+$ ztA2|;;lKCyb?~f~dM|4``b+IO^4EI9{HcG_(dYKD_*eVg{4I|CT|A9IR}%#P+PHxr zuGi}zZzL1+)J?SD^~a~S2KCJGCIq(@}Uuf^}AB3z=zECVk}Xl(h8N* zj!cf+{tt4gTai0%?5&8=2qq&L$OgruXs{AE_b``qv?@@Kssf(X#mDH%*XrzWnTI0Ut0yTs=EP&lb3!;-QSKhIrE2Rn<&_~z82~jCzqvCG-3FG2; zV$UVCUJfz~veAw-Rn$pzh&J3~u-$c0Lb;ZW=HVfwI>?g^-MWg)<-+1say}jM P(Db67?#KP4pZ4G%i7-uP diff --git a/build/StarcoinFramework/bytecode_modules/NFTGallery.mv b/build/StarcoinFramework/bytecode_modules/NFTGallery.mv index 7b0364a1abd25488c88f8e031c2c94f58b93d5bf..bda70d9e15f10338f3b469feef051e14342bf596 100644 GIT binary patch delta 1019 zcmY*YJ&znk5Ur~In3=Ag-rbw+{kDB)-<^HNAflts*kD^0a)1ya*t8JXU<&{> zLZI-Ry7mL=4{6^#qTi_a%>1RwPpZECyc)W%t1J9VW&Q8fV_QG!+wfig)9c@_@q*T% zwr83OO*;!jt9S7%g1&gJC+|y}b9wL01+ka6S!Wb59r%3@#8kpUVES3_~s}2729w1 z=7Bz19W9FoCx<7ihs$F5{^{}Ew@!8bvB%4YtM``WJIm9<2S;zO!oB6m>GA4=!~1uS z?!CKgpEqxA&uI<_Fl-zQ1_?HG-$6oo=td*0>Q4KWnWAccH0Rbg8&U{}SO`V2#4sjJ zI%Cs?gBL+-Qxq_0E;_gd-Z-<5UI$FZ6N6W*Suq`8vTXK&@peN7B>2qhIhhYGWD!*= z$OVZnUHJmsY`k|qPj21m+0s)kF%`ZruSw=o@6?zo?=qKNa-Pg(_Ev0lXPj7Sljp#~ zy;HMrD_2VODtTXXxli7NS`;b{UbD#>4=B}Kr{Jx5^+_?y)`x-%%0kZXIg!==X@^&P z#Oi4+PYxX2YLaodr59$*fJ}+Wb#a}bExj#h>a{NyqxFUJ(n+ywQ(qb+mX%Xt1I303 zMg%WvBZ5Vepjr|S(uNq^WQD1peNovBB>b=WIaAJ(`BY`X_N9O7+^ClVx1^-k<&Bm!m3g>l`OS-k{T!IQ_-i0UEJEB`KzfLeA% z1xS(P)*!_#P7sB7Umif*s#bVLVQ3ZlaL`s1lw|qP*x)$ zSg?vve*hpBd;qLLd;uF+Ba|h-fCP0riU=dkRp07U=hUgH{;c;~@8-AlUseNvM+g)S z#EqvYzoxg&Rny<8tr~JKWhJFPlqSHuWtUl&{uGbps%h< z1l*Jo#8xdSleE2#sP)bi5#%m5eC};5@wtCx!soRKNA&fp{HzbQwh_cjwNGg;4^!GJ z>)%AM{6M3Drs|t3fp!jmmMkD%Yg0YS~Q6;h-+Za=je;X;u5ukNj*f8#Se^ zma5fqqdmtqLsI~1(<1E)%1paMcMNF`3e*Ms@Hzd7Ud=x~zkIA8&QBj)p0sm0GsXEQ zk4}#7-F^R~_6ylu*Z0mYF3vv9AIvY0KRo^5EZm9Udq+(dQIX*OA!dd{7J5C4QB&$EuGI$K04Y_L zL9g02a08q&>JXg_7&Au}oUqagOGg-Us}5Nw7NmfaXYVF57fgsSlSMRS0_W!@e+{B? z&bT!F1^)pWIkq`Q<1+OQGh4aoF)}1!t%=@|+Otk$2L>3%z}n<&u#COsEn^Flvw9Ji zoVWQQITbutC~R=js#N0<#bxVb&uMl0nV7cP-O6l6sgTWG_OF~UBHg-QBP};9_Q{I> zq#YSB6w868~% zvBIeRKHFOCRo#@hARct4OgCsN-h|h|k;6FVDp%Rx8eb%DNm`tm_?t!C=XK(@6DNX* z>oQk1L*5cA;*_lr8_^WHBo!FQBs1dAkV#aR7-B;Q%PEit3$Y&?hdlfjm@rN$EiBKy I!ip;R7aSvTYybcN diff --git a/build/StarcoinFramework/bytecode_modules/Option.mv b/build/StarcoinFramework/bytecode_modules/Option.mv index 9a0dae2f25d1cc22a2f2e2ccde39c9a13bfcb2f2..340a58f50f415907a26ff143f03e2cab343beaba 100644 GIT binary patch delta 488 zcmYk3y-Gwe5QXO_H<``k?(W@P1;xTf?JV^w2(r31zJc#xAqa{fB8b*<3kxfsNd!fF z01?E(R&cWZrkHSYK9V_;H@TM8o0%8&08k=$@}AS4JC4N#9)(l7M|t3`f965_;Gk!Y z(z(0i@-a~RDO|4YP7m4z0{Kp^6VgXe=}IM0dYA9p^DXeP1(*xv;%#q1J_`Bh+ini= zzB!;B8cK6ZbNvk=LTjk6undVK*VrgeoeU+B60v!q$ev%V>6NyS1NkXMRR*`(BJNb&lB`?UOxMmt g+r(fZ!lDH#il{ctuT0jAP0KQoa_+!}WfKti1VVBw5dZ)H delta 575 zcmYjPJ8l#~5Uo#7cTM;7?9S}$tc@HX5;6h;+_r?|hyV_;;$sO3SzciiIN}5Zs}T_r zk`I6gi3kwffW$X&V9D$aaP0?AJ=yamFu4(J304ElKpC`vIW8fWvuIR~6+7I=i#zef z;mPUi!O5v!~Brm8&-=FUP1D3R;#4Nj-y`3>%*B0#C=10#cfnTjGMS7D%J z1Cq_ENxo8X#Y589}RkyVu&>dwH`et5*)ZgQlHgsutj04nm7FGvvs;h)x|ri4n> z^zDEC*W4c@?8f(ee$QkwvC98VllV4OIpb9B0qI8=Rmp2oYqA)A@vV0B#JPz&({%~l E0M8{mVgLXD diff --git a/build/StarcoinFramework/bytecode_modules/Oracle.mv b/build/StarcoinFramework/bytecode_modules/Oracle.mv index 7e71bf7c213cd864d4ffb5b54a276fb8c2e8935b..348476de27b193dfe2f939586be8033b3bb5aa6e 100644 GIT binary patch delta 510 zcmXX?yKWRg5bWxnnV#9%-P=3Px4!f7I=~NXz<`9!L*ki0YX1WPA}4c1hDatLCbC3? zbRr=jBjFzi2#`QzM1;)Vxr3?hDs^e9zx00ANAIV9q9dXT)Npf0p1p(l0dIff12oC8 z^`Cv?zWL4KuYVjrg{J%(=BD~r4eK}cBrk%PgbZ17q~sM!6g)4`dZOZ_k0)5_QmaZR zaMUwoE*dycO~|_q3sE12RcQd*!6^sPj6(*|ie?|BkuIcGLpQA!v4e4m4klb>qqVx1 z-|3P%-E@k(%u2Ft4Dn9(;w#WClB;>vYsmlD~TgG+bnE?E9ni(e0p3-`%bCb|dmV hir8nab2i9iFVY?jOD_1XHQq)=zfHIG5R%^N?thbVE~R3%Pfd0kZcT{gUX?*AxywI22srf9Yb|9EzKL7M-At5 zXvWB)#f2c$PKv=V%u=0FUeTA>kl2ut_;S$VD?6b>Tn(|=MEJ)wu0u!H8xj=VKr{H8 zt#D}RIG<;(ZU%%Ravio%Jd3IkO++7q)mX-xrtcb2y z^%1<{pay2FMMf}so?yeWxGUCe*cM+9vy^6BJozgt*hvv{%CXGPJhd1Oj=Qp{Vn+_C zsHQR&1?feqe13?T)nX_Uc7J9JU>;-TQ5g6O>Y252;ZxnF83Y9c z3>pksK>-jz6wb6k(M~LocOJ!rkRxDjEvOiiVnRk`oK9Vch@DT+C48VU156HX5FlY^ zbtMC$l*xSlcsL2obX<*^>15edZLeP5j~27}eAXsVS8aY*-;5{MfBwrWo-axY>|qGO zTwuC=6G6IHey LpwNRTg;DSWgf1nZ delta 403 zcmXYtze)o^5XNVAW_NG@+~!V28;gLbAlP3cwiY&`eTd0nf|tvYOORCdc4B8I`UI9f ziSJP*qLv>?*|L>OJDr>w*TW402qWIf})*sz7Dc~r9bf-lPAj5D_Q?RRb&tZ z5HLtklxWld8W6QIED_l1Bx+|Yg7hXbsaFUT(h%)VCw`zZ&JZw{62w*>6^R=~D4jx$ z2?}K;A!{OH>j2qu3{hDVNsKM#xDEhU-U>mzQ3ivc8*-{H*K`d$V#d zoef)APMY~LtEUgW$+)V5p=ciSJ_r;ECYV}qM!(T>*s%LSg51$cH)pjU

6y8iOa!B#7kt89NHBwlBr&>o<3>a`u7uy(606>jUP$6dal3$&($9RI} zXZnfN5x2!V_WlFM@R3PA@mpJeb4C2&avK5xFai*jieLcMFd0S5R!Vp-&LRXIh+ zUeO0Zz(>(qpr%ouTGTjo5*26CC>rb)*J950Q+9pG@nOg{(M2Calvu}Too!+pyBJf8 z&#oIR1EK>%er4@nYo<@{l-pq8Abr6_`i-wG9~>UMNXK+JeWxuSR^?*qWXxmQlk~)# zZ}&t@FqAiJ?|E3HXg1P&v-R}8ChT30f#-b7ZU?{;y6S3x+ZZq>wTrZ?;Q-sXE0a9k zup_G2bOf`QE0;WZm~&@cjU(<$y23Y?GbOvD+6qSP7jve3C!V%iZ8dYA+pfk3A{==n z-mGol(d`f39kAnZetKPj@Jqn85@T%w4tJmFA{oFotC$C4}U80mKKxLS*u1~?d zfi?OHA0R!|PceH%o#ZW9`;NT(M981%rzzgs#DBE05ELq{lmVp>Q$b}ENFdaLi6Oz1 z62UBq={(B?t+9g6oiHdUiIg^-3Y4Z^E!gQxm99$BW49EE?hQ-9deIBh2dTvY$MujS zzmN)|0dc@ZFM3>RHOr&Ok491HbGGc5x$vIZm)!A{_g$Giu6>^h8u+1K@ckEGc5Yx| zbEP4PkU9W~n6^}!D~L(7|IoRjKcBi~B@a=KS~s^~J=q@b&ZmdX6L@?+*&k2t&-ZA2 zFqG4i0Z7$;#%fELiv~Lb@`(gmr zbj^Y@t7d~XoouSA?1EEU;24&^Ya9ymP=CH_}RayQY0PU~1^HeOL}VJ!}M`|6h0 st=a_Pg_9dvy&fu4Iq65}29n*ySk}EzvzW7q%Buc*zUUZq^UbXN0!}kdLI3~& diff --git a/build/StarcoinFramework/bytecode_modules/Secp256k1.mv b/build/StarcoinFramework/bytecode_modules/Secp256k1.mv index a5eebc7a853d9d71538903b6e37234f5bf3caccd..5f0dd612f4273ea6dccb1faa22d56d430200a532 100644 GIT binary patch delta 285 zcmZ{ft4;)A424fG|7E6~VFrGQK@bE2yNi=U{P2MD7ryo zn)dYc%jvhi>*n$J(=q@fWX_|s3telvxh!||MfHcLypz^Hi2JkL4o|A#B`~A_TEJW= zloVRrM^_{qH3hOmSo#`vHv5LUz(!3%U6PAdq|3QhZ-@G?JT{aTI$V5Y7V%f~dWG^6#2BIJfCW7Dz92PMa0}o*&28Le1 z8>fgX8xJPQwW$MI1*|00v>RZ97goBCbV zv;>Ag1K&qb32#wZj+M`2qG53VIj%nR5W^O;U6I)DHJ3jNnsb#rLmB0 zZA42e|A1g2SX!m96)eR6z{)pw67(_q*!|9Y_kHGj98T(+Z&!bbGsg75R9LmNw#%=e zweR2~_%r+h)f?`+4?GN?cqC`c@f-i3-f88U&(-T&d)IN;I50R`8fb3^BkjweomQ4r zaS}odz0iad`l%T-<1|R)ZXNb+lOPay?X}TGPM;zn5zNJ+6oJqO-LvF_7_3dLQVrd2 zc;ENW4jv!uzS!|QFAw*hJU#4AvF*O&^P^cp0Au=XFap^`YA7RDwkHNWEXkD~Wr`?f zQ%BrQn}DdtFO19ah!a8eaKq{m+ducPdPvNM5xSQ)07*TSm&FKdFe9=`K$AO3Bc0b4 zpe-7UnZko}8B6BF%RvFQQ}>frkCXxftn)=3C!i5zMnTPXQEf!)7F*e(|NG10#!5fh z|IioL{TIDlR}mDQvzuy+>RGuFREQjSvYj49SCHlvZLq;z;%l}E9BibCP{C^y@2WBc o7UkPAv!riU+`}Y%KTS>a*^AFr_m$U%vy|%`O02pxBGI(}0G4Ap7ytkO delta 729 zcmY*X%We}f6!rDB$20b1CXdOpAtei70qU}K1MK(&gv2Te)kqYSX4Hh&s$$0uRr!Dl zsh@yYf!Oi`>|lWqtNsMXDMBE5j<4@M$LC&a-XyQ>-FL$a7YQM1Bw`tNcyvbU6J6Io z=^L5P{EOmqU60=D!hX?h_g$;>hyKd74@s1LOiu4qCtTEtgluOKu+waj;HYQ=O}7W^ zQXgph;BdNS!RfVzz&-(a&<*^p?NA+FMI1S6)4XOgo9FeskvH>JUf8zne_C<7A|)DcKV6+3MdffP8b*;pqw z*E1)C6EqNETfe3Adr9?d`FQ$hcJS03E~m@Iyfo#@)$#0LrOSD>dZj{29W9PZw|p_H zrpM)c@w`+aj;lqrQLZ1#CnsJ?%qkxjtZPn?p@zFrW3N)_#2y;+dXK;t zqSFubRPG=rQk5xaoUZ@XC}`M;UE$bAyCfN!*tkmznMu!5Aw@j$W}l=Ev2tQUK9=D} z7+kY3^vSy7VGFL((pU{}y(2u7x9cYc12rnV^bOw(4}*mv H9p39Vqo+=+ diff --git a/build/StarcoinFramework/bytecode_modules/StarcoinVerifier.mv b/build/StarcoinFramework/bytecode_modules/StarcoinVerifier.mv index 1f79c3cc854a84bffd1177410c4789f649e19618..684d44fe5845cdaffafd90109c0a8e06a708ef5c 100644 GIT binary patch delta 600 zcmYLFO=}ZT6ulqsW9Ge?$xJenG|kwg>4%6Qjj0j@#fffQxbg=`yNatqvruqR=tk&H z-c}G@bmO9kAh=N%;t%jg2vyv=_Du-(!g-u`?z#89d%rdQCP#0|-&O&DMKEOAJlGe< z7|0VmL;Z>VaB!+p^--Om`Kqr(=lZ*f&yv&^AP_JJkQzXFXpcYxvqql{ecm@@-&jb1 z$Xg+WJrZT%;>>}+zY&n%Duzg4?poW7GkzHp9S;T-uUtL8#mSd!QtV-Q}>=v zH#^1(G=xMehPsA)tQteT0GYT9=#rr|_gsux6-U}gqc_Ag85=Ni%I=F8-+@S2sp^sI zXh%{87SJMELFAQutKRM+BD$b#*g#dd9r>`|9@bP1mbNXi_Mb02ujGL47w)s{mv@V$ z2`*R@$!{2PcP_7PPmA2rcxQy=2!@OIl(3LzDfu;n5*jT`(A`qEvE!bpd!3562V!^m zWx|lOwm1RzLp|DrNLol#A~Up0v@6ulqw@!rf!@?Jh)+cZhjHpMDpjLK|uVb`uIZfjbKfofZti0H;mSGtnX zm11$@A5dJoP~7`BbS;Po&MTq==W^zrGjj*d{3w5_Jbu&uW)%QfgoKhN_aBK@n9KM0 z8TC(kDxzbZs^|I%n%B{p_r*KrJ6*L{dxmIEH@d2T$xv) zv#J)tGX~7S{caF(t-%NtPC3(+yqeeYG|#xwNjnX0_MUy5uA?$BP*E6FV1|myi~($j zbWp<7Q2hq3`F$K}b!&HLc5w9W1W)jsy1To7XEssW2S-N-55#0Voy3Rtr<1Mi@y?#y zy>~c!7)>YR(bmPwSNtZwUCE6VXb6es49$lLL<`1HJ3=O2jHqL%>leka<{;5V8oeye z%aQ>j9s02tA^8`g+i9&9A)T&-{!=z=z_I@-Zgl7R1y#MjwpG#j$4@=iWRINiw`DhR z(#a}Phy_~yr93-us%~j?VTkP^^iS_s!a_Z(Q^*FC&}hMF|6N|iwqI8pEeC_1xMTq> zq9u$;Ym1KjvD#drMA{H_S!O}1FHtFcgvILyQpzBS%W=vs^1oDDxY!xLpdDI&Q}_P> DRqaba diff --git a/build/StarcoinFramework/bytecode_modules/String.mv b/build/StarcoinFramework/bytecode_modules/String.mv index a718cd408f0896e17de2b6da730b431dfe2a7a7c..4b51f4373525345475828b2193f430dc1ee0f914 100644 GIT binary patch delta 236 zcmW-cy-Gtt5QXPwcW2$%d++Y%DhOgk2)3q6dy%|G5PSx~#)ptRfQXH4s=R}Zy^VdW zLa<2ZCe494=bK^9hrG(|+r_Us08j)^K5%(3kKR5%$sc~B|Kj9+xDPvaanD<7HZRlr zODxU-HzSWgqtmmhJyvZ~O1Uko^(S5rX<{0cfLS8jtb!+zl}&HY6;L2|%XeCgkpcps zQAjW(s!u>aJq*zWH>Bki-_5%lb&5*a7ob>)F1C=Z@d^cI)v;m55f!O9+zQ9gSP{&1 JwK7!e{R1+R8W8{h delta 155 zcmbQwzJlFwq0DP;HUKf&xN(!W-9}Vq~&loLt2u&nPf?7E_!&6B8FB0|O%q zH-i9!1tSyCa0U@W5Qm42iw&q!oY@(uGMZVIotcM`mCJ%4auIc1S*9YzrIH3Yqoq!2CE z5$qCXNNO3=kliwIr4a;i(L~^$%0aGT4rVP_u-^)e8<=he^j+j`oV$Fu*5egCB_k$EXjl>GsQ8c32I~^TJ z)>;7B@*39NQe|DB}fK3DwGltp)^#yK$^&9 zs)#p$j*gas*FXqC2@;}U&&{uq{!icN|1SUJ;A-oKcmRk9b2Cr&@EqwAmhKC_NB(L4 zQuxND|HJotAHwCu!R|ZIexDF9B?cG*0#pW(U}U=-Q%+ZV1ezd2n1%qw%qOJYH9;`f zdkDPMFTmayAm~jj5z;NJko-0lIh!tVXOuN@cZ?u&UxVAj8p0yGaDO?;Re3v9Fxamv zhr-TEsXKgR%|n2;6MDrFmnI^ diff --git a/build/StarcoinFramework/bytecode_modules/TransferScripts.mv b/build/StarcoinFramework/bytecode_modules/TransferScripts.mv index dca83ebaca3cf7db7eab5177d516a9c39ff491cb..5a5eaf79403d771db081c5d3d6720bcae3726783 100644 GIT binary patch delta 296 zcmZXOJx)VG421o+evZ9ah!i@ALIYQLqDu-IXd`hOBs$9QM0$icLe4<}hd|;ItZSN2 z{+SugvwoJxxAWgn05Ak)y_Ne~9`1&Bd?NecQ$6yke(^VU1p)yBqJU7ca8e~Xl%#2L zHguwU1q{!z&O2$|8eluggPF}tOf78xdgDETwH86%|6EOH_%a>w;2W>SOQTIpJ6d0E zeOc9YF|6gnb;L$4+gMg^5E?wvbfDFaiF*U&0T+HPIra+aQOE9qz@U++g0MlyIfw$`FydM->h%(*)k??zN1X*9UAXv z9wssAo3Yz7$*v=F*$)$U5G8V!^%;#$0+nawW57Ngx;jR~+7ZLjfryc^kgpqwRdRG$ NNve_lMa$iW;15nbBU1nX diff --git a/build/StarcoinFramework/bytecode_modules/TypeInfo.mv b/build/StarcoinFramework/bytecode_modules/TypeInfo.mv index 3b23e889b2836e1f749b989b5e9a43d1ea0d785d..1be6ae92597c093fa4c307d0bb65bc4cc57f14f5 100644 GIT binary patch delta 218 zcmYk0Jq`g;6ov2qd-G-_A{vQERJ00-(oYm>Q`o?0Br{r-PA^uVQrLh*ZwFRk6W*xY z>N_{*-gDmcpyRdsNeuu3f{_V_fs91QJ-6QYJ2t};)9i)Q#))bd0s%Mxjs#K*WkCV^ z?bQ&_Gewuv1VNoSG!Lj42rU7OcTq+l)Jq<-UycD2K>z>% delta 224 zcmdnNbd@P{q0DP;HUgCj&Dp7ZVo~M@VHss%KtWKC_c^Fl$JDc4{75SZZ=fe$m8@DJt`Gl~>x%7XzE7%|X^jo7@g(4Qt<^VL|d_}%x# nWn}=gRIiLYRQh@A)B~r|8MadmSxCKm+ecfWA=?osc`5xLF0CWX delta 411 zcmZ{gy-EW?5P)Z9_jYghe!P=t%#V@~B-kh_!WDuRf~CHJ7!d=Ck!bJ*Y(y;1!&1Rg z@BysstOR=>z)A}X8#^cQ2O>Ddvh(dXyR-A`-k8~|@{6Ycz(Y`^q_8I_&(U=*a7Dl3 zDY+jaQpa-M-b>{_$ZHwAr!$=iD)<2c6+?}HC9Q$VQOsa;&@dQdFrhv3GNBoH_VV1f|-(F|*fm4VEPT8(@R(4#~I*d0eN z{v_F|IBRehzvoqHoX`W*6c_6jBA(z+WuKLI%6%3;`gK3#=B5{?yl&+;0{+^PtbPKm CM=lcp diff --git a/build/StarcoinFramework/bytecode_modules/VMConfig.mv b/build/StarcoinFramework/bytecode_modules/VMConfig.mv index ec731ac18d8ecbb2a4900f0aad7b805f55fbfcb7..d4a4038b71b1b7f39be486752cba792c6aef31b6 100644 GIT binary patch literal 3967 zcmds4&2HpG5bhuUjk}%9OtP8DW|v*K01_v}qCJ2V6a?A>5(0z}7t1r#GqL2cBe$I; z99H`h-1f3Z9)K$^fW!gq8*t#jfmfi~Zcl=fIz-w?5iR+rzpAeK`s?a(&&zv%3y%;o zpd?_ykWU{wUo!WrBmXD*vlIO44#VHw_vLf%)fAj4VT2RMC&Y!zgNwlB0}g{t5U`Ta z+=Sy2BEf?m07~zf+kInyBP4`95QO?67z489$&iJNpEnu?6#6uvQQs19ms1KhN5pnRg;8ZauhJrqwe{Z4lPWz`o4(A|)3}YGtH^Xt*Cra!I#^}J zEXm@vS{LP6e4@&Dc2+5{>gr9z_Owi`$NoCaivd zOiWL@(Vz|}n6Kg`a4*W;g<2+cR>jGDUetLNn^D^r)rEnfl?h&@iPH)0r#gn%l?Ts- zIvv2{ILR_~wwJ*2mQ}n`xzd0p?TU|2>RFcRW4^<8 z`5nH;C!8`i<@=m5K7jHInI90&=v}C9Q|0fCJjXTrrD+oOfd{bd2qGPid_OZ=fk+On z!$4AZJn|(K)R_d5x%(ry3+6l!+=H#qw5jBtW8b|&_wrp62DaJeC9o#Jh2st1ZhJtc zb=(l~9>NARZA=(7>~=yj8VDk&U}mUrg(rLwh=B-&5K=@V_c37%T=`$@5H@bxB#Fp* z&~BO|=TjH(XC1p9-gP$vt^fZOw=$dy^_u6K*}~}SiRH!c+or!Q(M!5v{4pGx*LD4| zI5&;oG|zYKX71O|9R!~s_-|H-ew+yL$8@{t`QCJVY+j$)#C?4*J{bNMqUSb(Zy`9g zE(eJJHwZpM@DJ^0qCel<915ZJ@kcFu3I7wpKe7V#kuON)W!tj4+@9TwC`5}_^ zV+5aAIs0sWLHse*FqLnWn(%eMi_9xQeg({*1JnBYylUY~_y-7%<^2PxszW3WhCfIA zZLwYAxjB_}+unZNuZwply}mwJobII8_kRcBzl-44&5QBD;=C@NPZ0hXpIe2)uTR6r cF-Pn%WiAv8-MRX#Jti`0PU6v+jX5L#0&`?Gj{pDw literal 4003 zcmds4OK;>v5blTFesnvTnPfA0?6QvwAaO!~asX*j5NHo@0j&@RERUyWVy(v>`H>}i zSfTwLd*Lr2xO3pf4e<{+aNvN%FQD3EPlA(@h_sO+T5{X{Rdv-@)m=S3-`)OG3POlS ziO>82-~Y(^TG-RiobTyRmixCo@L!0x)eqw5T~MNg5l$>(JA?>$9C!#kE=Y*SVBmwC zNYg3HCL{nYdYgEJ-Z9;4(DA!IA?%(c)UoapMTzwwfa$&?ZDkYck`1AN3FBvt`Ywer zb!pI-xZLKHf{aq3m{8!v_Xu;K^N9QS)1y3_C3ENKI7+fdQ?VKbM|q(?oK6c}mbw&= zbzJ3z`XnkrTvkz5l}tai*RyUX^@uHeMI)ONLr1( zMUsV85oKkxVql!qK(5?PqhhZAC5!7SpUuV%Vd#>$q11UiSVZ3>i+T}e^wHp zjO`dV%OZ(&L$GtQ15+-6?-=+zsS@%Of&~*;Iqqgdb|8bPX{t|mB3R|33gyZoa+y_6-h2FF?fA70x~PbH4$+SO4hUyVbrkO z^2yMXL{iDjRB1~g9qCF>`cg_IgQ0y$7z0)Q2Ro#S1mw(E7v9i1WPm^KSoQF3xSrVR z|6lPo4QGjZ#qp-?hUn)L^NZm(E&uJ-ypT7HKZav*T~!~mbKUrL^L(>80pRrL0%`Z> zEd(DU_%H4JzMTNk@7(qEuRGrBwvWa2aqIZM#*6WMfaG%%!8Z^bTbBbw{|f}4AozQ5 z6Ev+KZ)UEKm*DTN;0yY{Bl!DBK3`tuR}#iyVfbIP{nf&D_d~?n2M9iH)7X#lM?@dX z7M9%`l|}ef-$&w#km@&oAWZA$=eHGn0e=U=b)|GpE zYF-uZZg&0rV0OBjU0?qVg#R{zU)3+h2eb34cs@e-V|;ED4yR7T$1+#y5oI=P7P@u$ R-Fie+(A>O(5gTzv{sC>GIamMy diff --git a/build/StarcoinFramework/bytecode_modules/Vector.mv b/build/StarcoinFramework/bytecode_modules/Vector.mv index ccd5d44b8211f0b9f46c6068eb77bcec872b8cba..fca0c13f9fa22089f35b632ccb13ea8f3c0c1427 100644 GIT binary patch delta 385 zcmYk1F-rqc49Ana_j>PMa@gAH2|XM+wx&KRM1N{RFhPb&7^wpUtJ?040;u7IIoUAORiSrY_{F?$ny)5}OUZ58 zR9_|wOUqj9pg)nGn!1**H?c0xZ6%)L%GXDBb7wg&3Rnt9sn}rWX>L#5aWcoYjY~bX h>0agCnKH4b9ulmnEhhm+r7SL_%C5Lf2MWJ01b;C>E3*Iq delta 394 zcmYk2u}T9$5Qb-FcklLg<}fiAPcfB|gn*>6nbN`+uo5I7h}ilPDp&~0^#MB@3oGBk z+R9cT;0xF|xgun$*>89M*>8V}&tmdCSa1da5rG`tpufZIFvsisfxa*wc5><&sID|hY~hEi3&o+Y z+tsfdkcOu6qnT1=AtAHlZEZ;idu8N83#K(nVJGFwpJ{8~U)U4OOp)_ieDce7=x5=i nT>APpwwe3-P>XPBG90Nwg1*h+GQm`F6<(XPc`|7-BPRF + +# Module `0x1::ACL` + +Access control list (acl) module. An acl is a list of account addresses who +have the access permission to a certain object. +This module uses a vector to represent the list, but can be refactored to +use a "set" instead when it's available in the language in the future. + + +- [Struct `ACL`](#0x1_ACL_ACL) +- [Constants](#@Constants_0) +- [Function `empty`](#0x1_ACL_empty) +- [Function `add`](#0x1_ACL_add) +- [Function `remove`](#0x1_ACL_remove) +- [Function `contains`](#0x1_ACL_contains) +- [Function `assert_contains`](#0x1_ACL_assert_contains) + + +

use 0x1::Errors;
+use 0x1::Vector;
+
+ + + + + +## Struct `ACL` + + + +
struct ACL has copy, drop, store
+
+ + + +
+Fields + + +
+
+list: vector<address> +
+
+ +
+
+ + +
+ + + +## Constants + + + + +The ACL already contains the address. + + +
const ECONTAIN: u64 = 0;
+
+ + + + + +The ACL does not contain the address. + + +
const ENOT_CONTAIN: u64 = 1;
+
+ + + + + +## Function `empty` + +Return an empty ACL. + + +
public fun empty(): ACL::ACL
+
+ + + +
+Implementation + + +
public fun empty(): ACL {
+    ACL{ list: Vector::empty<address>() }
+}
+
+ + + +
+ + + +## Function `add` + +Add the address to the ACL. + + +
public fun add(acl: &mut ACL::ACL, addr: address)
+
+ + + +
+Implementation + + +
public fun add(acl: &mut ACL, addr: address) {
+    assert!(!Vector::contains(&mut acl.list, &addr), Errors::invalid_argument(ECONTAIN));
+    Vector::push_back(&mut acl.list, addr);
+}
+
+ + + +
+ + + +## Function `remove` + +Remove the address from the ACL. + + +
public fun remove(acl: &mut ACL::ACL, addr: address)
+
+ + + +
+Implementation + + +
public fun remove(acl: &mut ACL, addr: address) {
+    let (found, index) = Vector::index_of(&mut acl.list, &addr);
+    assert!(found, Errors::invalid_argument(ENOT_CONTAIN));
+    Vector::remove(&mut acl.list, index);
+}
+
+ + + +
+ + + +## Function `contains` + +Return true iff the ACL contains the address. + + +
public fun contains(acl: &ACL::ACL, addr: address): bool
+
+ + + +
+Implementation + + +
public fun contains(acl: &ACL, addr: address): bool {
+    Vector::contains(&acl.list, &addr)
+}
+
+ + + +
+ + + +## Function `assert_contains` + +assert! that the ACL has the address. + + +
public fun assert_contains(acl: &ACL::ACL, addr: address)
+
+ + + +
+Implementation + + +
public fun assert_contains(acl: &ACL, addr: address) {
+    assert!(contains(acl, addr), Errors::invalid_argument(ENOT_CONTAIN));
+}
+
+ + + +
diff --git a/build/StarcoinFramework/docs/Account.md b/build/StarcoinFramework/docs/Account.md new file mode 100644 index 00000000..a8458251 --- /dev/null +++ b/build/StarcoinFramework/docs/Account.md @@ -0,0 +1,3598 @@ + + + +# 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) +- [Struct `RotateAuthKeyEvent`](#0x1_Account_RotateAuthKeyEvent) +- [Struct `ExtractWithdrawCapEvent`](#0x1_Account_ExtractWithdrawCapEvent) +- [Struct `SignerDelegateEvent`](#0x1_Account_SignerDelegateEvent) +- [Resource `EventStore`](#0x1_Account_EventStore) +- [Constants](#@Constants_0) +- [Function `remove_signer_capability`](#0x1_Account_remove_signer_capability) +- [Function `get_genesis_capability`](#0x1_Account_get_genesis_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 `create_account_with_initial_amount_entry`](#0x1_Account_create_account_with_initial_amount_entry) +- [Function `create_delegate_account`](#0x1_Account_create_delegate_account) +- [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 `rotate_authentication_key_entry`](#0x1_Account_rotate_authentication_key_entry) +- [Function `do_rotate_authentication_key`](#0x1_Account_do_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 `accept_token_entry`](#0x1_Account_accept_token_entry) +- [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_entry`](#0x1_Account_set_auto_accept_token_entry) +- [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_prologue_v2`](#0x1_Account_txn_prologue_v2) +- [Function `txn_epilogue`](#0x1_Account_txn_epilogue) +- [Function `transaction_fee_simulate`](#0x1_Account_transaction_fee_simulate) +- [Function `txn_epilogue_v2`](#0x1_Account_txn_epilogue_v2) +- [Function `txn_epilogue_v3`](#0x1_Account_txn_epilogue_v3) +- [Function `remove_zero_balance_entry`](#0x1_Account_remove_zero_balance_entry) +- [Function `remove_zero_balance`](#0x1_Account_remove_zero_balance) +- [Function `make_event_store_if_not_exist`](#0x1_Account_make_event_store_if_not_exist) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::Authenticator;
+use 0x1::BCS;
+use 0x1::CoreAddresses;
+use 0x1::Errors;
+use 0x1::Event;
+use 0x1::Hash;
+use 0x1::Math;
+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
+
+ + + +
+Fields + + +
+
+authentication_key: vector<u8> +
+
+ The current authentication key. + This can be different than the key used to create the account +
+
+withdrawal_capability: Option::Option<Account::WithdrawCapability> +
+
+ A 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> +
+
+ A 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> +
+
+ event handle for account balance withdraw event +
+
+deposit_events: Event::EventHandle<Account::DepositEvent> +
+
+ event handle for account balance deposit event +
+
+accept_token_events: Event::EventHandle<Account::AcceptTokenEvent> +
+
+ Event handle for accept_token event +
+
+sequence_number: u64 +
+
+ The current sequence number. + Incremented by one each time a transaction is submitted +
+
+ + +
+ + + +## Resource `Balance` + +A resource that holds the tokens stored in this account + + +
struct Balance<TokenType> has key
+
+ + + +
+Fields + + +
+
+token: Token::Token<TokenType> +
+
+ +
+
+ + +
+ + + +## Struct `WithdrawCapability` + +The holder of WithdrawCapability for account_address can withdraw Token from +account_address/Account::Account/balance. +There is at most one WithdrawCapability in existence for a given address. + + +
struct WithdrawCapability has store
+
+ + + +
+Fields + + +
+
+account_address: address +
+
+ +
+
+ + +
+ + + +## Struct `KeyRotationCapability` + +The holder of KeyRotationCapability for account_address can rotate the authentication key for +account_address (i.e., write to account_address/Account::Account/authentication_key). +There is at most one KeyRotationCapability in existence for a given address. + + +
struct KeyRotationCapability has store
+
+ + + +
+Fields + + +
+
+account_address: address +
+
+ +
+
+ + +
+ + + +## Struct `WithdrawEvent` + +Message for balance withdraw event. + + +
struct WithdrawEvent has drop, store
+
+ + + +
+Fields + + +
+
+amount: u128 +
+
+ The amount of Token sent +
+
+token_code: Token::TokenCode +
+
+ The code symbol for the token that was sent +
+
+metadata: vector<u8> +
+
+ Metadata associated with the withdraw +
+
+ + +
+ + + +## Struct `DepositEvent` + +Message for balance deposit event. + + +
struct DepositEvent has drop, store
+
+ + + +
+Fields + + +
+
+amount: u128 +
+
+ The amount of Token sent +
+
+token_code: Token::TokenCode +
+
+ The code symbol for the token that was sent +
+
+metadata: vector<u8> +
+
+ Metadata associated with the deposit +
+
+ + +
+ + + +## Struct `AcceptTokenEvent` + +Message for accept token events + + +
struct AcceptTokenEvent has drop, store
+
+ + + +
+Fields + + +
+
+token_code: Token::TokenCode +
+
+ +
+
+ + +
+ + + +## Resource `SignerDelegated` + + + +
struct SignerDelegated has key
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ + +
+ + + +## Struct `SignerCapability` + + + +
struct SignerCapability has store
+
+ + + +
+Fields + + +
+
+addr: address +
+
+ +
+
+ + +
+ + + +## Resource `AutoAcceptToken` + + + +
struct AutoAcceptToken has key
+
+ + + +
+Fields + + +
+
+enable: bool +
+
+ +
+
+ + +
+ + + +## Struct `RotateAuthKeyEvent` + +Message for rotate_authentication_key events + + +
struct RotateAuthKeyEvent has drop, store
+
+ + + +
+Fields + + +
+
+account_address: address +
+
+ +
+
+new_auth_key: vector<u8> +
+
+ +
+
+ + +
+ + + +## Struct `ExtractWithdrawCapEvent` + +Message for extract_withdraw_capability events + + +
struct ExtractWithdrawCapEvent has drop, store
+
+ + + +
+Fields + + +
+
+account_address: address +
+
+ +
+
+ + +
+ + + +## Struct `SignerDelegateEvent` + +Message for SignerDelegate events + + +
struct SignerDelegateEvent has drop, store
+
+ + + +
+Fields + + +
+
+account_address: address +
+
+ +
+
+ + +
+ + + +## Resource `EventStore` + + + +
struct EventStore has key
+
+ + + +
+Fields + + +
+
+rotate_auth_key_events: Event::EventHandle<Account::RotateAuthKeyEvent> +
+
+ Event handle for rotate_authentication_key event +
+
+extract_withdraw_cap_events: Event::EventHandle<Account::ExtractWithdrawCapEvent> +
+
+ Event handle for extract_withdraw_capability event +
+
+signer_delegate_events: Event::EventHandle<Account::SignerDelegateEvent> +
+
+ Event handle for signer delegated event +
+
+ + +
+ + + +## Constants + + + + + + +
const MAX_U64: u128 = 18446744073709551615;
+
+ + + + + + + +
const EDEPRECATED_FUNCTION: u64 = 19;
+
+ + + + + + + +
const EPROLOGUE_ACCOUNT_DOES_NOT_EXIST: u64 = 0;
+
+ + + + + +The address bytes length + + +
const ADDRESS_LENGTH: u64 = 16;
+
+ + + + + + + +
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
+
+ + + +
+Implementation + + +
public fun remove_signer_capability(signer: &signer): SignerCapability
+acquires Account, EventStore {
+    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 {});
+
+        make_event_store_if_not_exist(signer);
+        let event_store = borrow_global_mut<EventStore>(signer_addr);
+        Event::emit_event<SignerDelegateEvent>(
+            &mut event_store.signer_delegate_events,
+            SignerDelegateEvent {
+                account_address: signer_addr
+            }
+        );
+    };
+
+    let signer_cap = SignerCapability {addr: signer_addr };
+    signer_cap
+}
+
+ + + +
+ + + +## Function `get_genesis_capability` + + + +
public(friend) fun get_genesis_capability(): Account::SignerCapability
+
+ + + +
+Implementation + + +
public (friend) fun get_genesis_capability():SignerCapability{
+    let signer_cap = SignerCapability {addr: Token::token_address<STC>() };
+    signer_cap
+}
+
+ + + +
+ + + +## Function `create_signer_with_cap` + + + +
public fun create_signer_with_cap(cap: &Account::SignerCapability): signer
+
+ + + +
+Implementation + + +
public fun create_signer_with_cap(cap: &SignerCapability): signer {
+    create_signer(cap.addr)
+}
+
+ + + +
+ + + +## Function `destroy_signer_cap` + + + +
public fun destroy_signer_cap(cap: Account::SignerCapability)
+
+ + + +
+Implementation + + +
public fun destroy_signer_cap(cap: SignerCapability) {
+    let SignerCapability {addr: _} = cap;
+}
+
+ + + +
+ + + +## Function `signer_address` + + + +
public fun signer_address(cap: &Account::SignerCapability): address
+
+ + + +
+Implementation + + +
public fun signer_address(cap: &SignerCapability): address {
+    cap.addr
+}
+
+ + + +
+ + + +## Function `is_signer_delegated` + + + +
public fun is_signer_delegated(addr: address): bool
+
+ + + +
+Implementation + + +
public fun is_signer_delegated(addr: address): bool {
+    exists<SignerDelegated>(addr)
+}
+
+ + + +
+ + + +## Function `create_genesis_account` + +Create an genesis account at new_account_address and return signer. +Genesis authentication_key is zero bytes. + + +
public fun create_genesis_account(new_account_address: address): signer
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !Timestamp::is_genesis();
+aborts_if len(DUMMY_AUTH_KEY) != 32;
+aborts_if exists<Account>(new_account_address);
+
+ + + +
+ + + +## Function `release_genesis_signer` + +Release genesis account signer + + +
public fun release_genesis_signer(_genesis_account: signer)
+
+ + + +
+Implementation + + +
public fun release_genesis_signer(_genesis_account: signer){
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `create_account` + +Deprecated since @v5 + + +
public fun create_account<TokenType: store>(_authentication_key: vector<u8>): address
+
+ + + +
+Implementation + + +
public fun create_account<TokenType: store>(_authentication_key: vector<u8>): address {
+    abort Errors::deprecated(EDEPRECATED_FUNCTION)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if true;
+
+ + + +
+ + + +## Function `create_account_with_address` + +Creates a new account at 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)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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>)
+
+ + + +
+Implementation + + +
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});
+    move_to(new_account, EventStore {
+          rotate_auth_key_events: Event::new_event_handle<RotateAuthKeyEvent>(new_account),
+          extract_withdraw_cap_events: Event::new_event_handle<ExtractWithdrawCapEvent>(new_account),
+          signer_delegate_events: Event::new_event_handle<SignerDelegateEvent>(new_account),
+    });
+}
+
+ + + +
+ +
+Specification + + + +
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_signer` + + + +
fun create_signer(addr: address): signer
+
+ + + +
+Implementation + + +
native fun create_signer(addr: address): signer;
+
+ + + +
+ + + +## Function `create_account_with_initial_amount` + + + +
public entry fun create_account_with_initial_amount<TokenType: store>(account: signer, fresh_address: address, _auth_key: vector<u8>, initial_amount: u128)
+
+ + + +
+Implementation + + +
public entry 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_entry<TokenType>(account, fresh_address, initial_amount);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `create_account_with_initial_amount_v2` + + + +
public entry fun create_account_with_initial_amount_v2<TokenType: store>(account: signer, fresh_address: address, initial_amount: u128)
+
+ + + +
+Implementation + + +
public entry fun create_account_with_initial_amount_v2<TokenType: store>(account: signer, fresh_address: address, initial_amount: u128)
+acquires Account, Balance, AutoAcceptToken {
+    create_account_with_initial_amount_entry<TokenType>(account, fresh_address, initial_amount);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `create_account_with_initial_amount_entry` + + + +
public entry fun create_account_with_initial_amount_entry<TokenType: store>(account: signer, fresh_address: address, initial_amount: u128)
+
+ + + +
+Implementation + + +
public entry fun create_account_with_initial_amount_entry<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);
+    };
+}
+
+ + + +
+ + + +## Function `create_delegate_account` + +Generate an new address and create a new account, then delegate the account and return the new account address and SignerCapability + + +
public fun create_delegate_account(sender: &signer): (address, Account::SignerCapability)
+
+ + + +
+Implementation + + +
public fun create_delegate_account(sender: &signer) : (address, SignerCapability) acquires Balance, Account, EventStore {
+    let sender_address = Signer::address_of(sender);
+    let sequence_number = Self::sequence_number(sender_address);
+    // use stc balance as part of seed, just for new address more random.
+    let stc_balance = Self::balance<STC>(sender_address);
+
+    let seed_bytes = BCS::to_bytes(&sender_address);
+    Vector::append(&mut seed_bytes, BCS::to_bytes(&sequence_number));
+    Vector::append(&mut seed_bytes, BCS::to_bytes(&stc_balance));
+
+    let seed_hash = Hash::sha3_256(seed_bytes);
+    let i = 0;
+    let address_bytes = Vector::empty();
+    while (i < ADDRESS_LENGTH) {
+        Vector::push_back(&mut address_bytes, *Vector::borrow(&seed_hash,i));
+        i = i + 1;
+    };
+    let new_address = BCS::to_address(address_bytes);
+    Self::create_account_with_address<STC>(new_address);
+    let new_signer = Self::create_signer(new_address);
+    (new_address, Self::remove_signer_capability(&new_signer))
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deposit_to_self` + +Deposits the to_deposit token into the self's account balance + + +
public fun deposit_to_self<TokenType: store>(account: &signer, to_deposit: Token::Token<TokenType>)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Deposits the 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>)
+
+ + + +
+Implementation + + +
public fun deposit<TokenType: store>(
+    receiver: address,
+    to_deposit: Token<TokenType>,
+) acquires Account, Balance, AutoAcceptToken {
+    deposit_with_metadata<TokenType>(receiver, to_deposit, x"")
+}
+
+ + + +
+ +
+Specification + + + +
include DepositWithMetadataAbortsIf<TokenType>;
+
+ + + +
+ + + +## Function `deposit_with_metadata` + +Deposits the 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>)
+
+ + + +
+Implementation + + +
public fun deposit_with_metadata<TokenType: store>(
+    receiver: address,
+    to_deposit: Token<TokenType>,
+    metadata: vector<u8>,
+) acquires Account, Balance, AutoAcceptToken {
+
+    if (!exists_at(receiver)) {
+        create_account_with_address<TokenType>(receiver);
+    };
+
+    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);
+    };
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Helper to deposit amount to the given account balance + + +
fun deposit_to_balance<TokenType: store>(balance: &mut Account::Balance<TokenType>, token: Token::Token<TokenType>)
+
+ + + +
+Implementation + + +
fun deposit_to_balance<TokenType: store>(balance: &mut Balance<TokenType>, token: Token::Token<TokenType>) {
+    Token::deposit(&mut balance.token, token)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if balance.token.value + token.value > MAX_U128;
+
+ + + +
+ + + +## Function `withdraw_from_balance` + +Helper to withdraw amount from the given account balance and return the withdrawn Token + + +
fun withdraw_from_balance<TokenType: store>(balance: &mut Account::Balance<TokenType>, amount: u128): Token::Token<TokenType>
+
+ + + +
+Implementation + + +
fun withdraw_from_balance<TokenType: store>(balance: &mut Balance<TokenType>, amount: u128): Token<TokenType>{
+    Token::withdraw(&mut balance.token, amount)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if balance.token.value < amount;
+
+ + + +
+ + + +## Function `withdraw` + +Withdraw amount Token from the account balance + + +
public fun withdraw<TokenType: store>(account: &signer, amount: u128): Token::Token<TokenType>
+
+ + + +
+Implementation + + +
public fun withdraw<TokenType: store>(account: &signer, amount: u128): Token<TokenType>
+acquires Account, Balance {
+    withdraw_with_metadata<TokenType>(account, amount, x"")
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Withdraw amount tokens from signer with given metadata. + + +
public fun withdraw_with_metadata<TokenType: store>(account: &signer, amount: u128, metadata: vector<u8>): Token::Token<TokenType>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Withdraw amount Token from the account under cap.account_address with no metadata + + +
public fun withdraw_with_capability<TokenType: store>(cap: &Account::WithdrawCapability, amount: u128): Token::Token<TokenType>
+
+ + + +
+Implementation + + +
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"")
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Withdraw amount Token from the account under cap.account_address with metadata + + +
public fun withdraw_with_capability_and_metadata<TokenType: store>(cap: &Account::WithdrawCapability, amount: u128, metadata: vector<u8>): Token::Token<TokenType>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Return a unique capability granting permission to withdraw from the sender's account balance. + + +
public fun extract_withdraw_capability(sender: &signer): Account::WithdrawCapability
+
+ + + +
+Implementation + + +
public fun extract_withdraw_capability(
+    sender: &signer
+): WithdrawCapability acquires Account, EventStore {
+    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));
+
+    make_event_store_if_not_exist(sender);
+    let event_store = borrow_global_mut<EventStore>(sender_addr);
+    Event::emit_event<ExtractWithdrawCapEvent>(
+        &mut event_store.extract_withdraw_cap_events,
+        ExtractWithdrawCapEvent {
+            account_address: sender_addr,
+        }
+    );
+    let account = borrow_global_mut<Account>(sender_addr);
+    Option::extract(&mut account.withdrawal_capability)
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Return the withdraw capability to the account it originally came from + + +
public fun restore_withdraw_capability(cap: Account::WithdrawCapability)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
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>)
+
+ + + +
+Implementation + + +
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,
+    });
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Account>(account);
+
+ + + +
+ + + +## Function `emit_account_deposit_event` + + + +
fun emit_account_deposit_event<TokenType: store>(account: address, amount: u128, metadata: vector<u8>)
+
+ + + +
+Implementation + + +
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,
+    });
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Account>(account);
+
+ + + +
+ + + +## Function `pay_from_capability` + +Withdraws amount Token using the passed in WithdrawCapability, and deposits it +into the payee'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>)
+
+ + + +
+Implementation + + +
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,
+    );
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Withdraw amount Token from the transaction sender's +account balance and send the token to the payee 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>)
+
+ + + +
+Implementation + + +
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,
+    );
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Withdraw amount Token from the transaction sender's +account balance and send the token to the payee address +Creates the payee account if it does not exist + + +
public fun pay_from<TokenType: store>(account: &signer, payee: address, amount: u128)
+
+ + + +
+Implementation + + +
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"");
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Rotate the authentication key for the account under cap.account_address + + +
public fun rotate_authentication_key_with_capability(cap: &Account::KeyRotationCapability, new_authentication_key: vector<u8>)
+
+ + + +
+Implementation + + +
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;
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Return a unique capability granting permission to rotate the sender's authentication key + + +
public fun extract_key_rotation_capability(account: &signer): Account::KeyRotationCapability
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Return the key rotation capability to the account it originally came from + + +
public fun restore_key_rotation_capability(cap: Account::KeyRotationCapability)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Option::is_some(global<Account>(cap.account_address).key_rotation_capability);
+aborts_if !exists<Account>(cap.account_address);
+
+ + + +
+ + + +## Function `destroy_key_rotation_capability` + + + +
public fun destroy_key_rotation_capability(cap: Account::KeyRotationCapability)
+
+ + + +
+Implementation + + +
public fun destroy_key_rotation_capability(cap: KeyRotationCapability) {
+    let KeyRotationCapability {account_address: _} = cap;
+}
+
+ + + +
+ + + +## Function `rotate_authentication_key` + + + +
public entry fun rotate_authentication_key(account: signer, new_key: vector<u8>)
+
+ + + +
+Implementation + + +
public entry fun rotate_authentication_key(account: signer, new_key: vector<u8>) acquires Account, EventStore {
+    rotate_authentication_key_entry(account, new_key);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `rotate_authentication_key_entry` + + + +
public entry fun rotate_authentication_key_entry(account: signer, new_key: vector<u8>)
+
+ + + +
+Implementation + + +
public entry fun rotate_authentication_key_entry(account: signer, new_key: vector<u8>) acquires Account, EventStore {
+    do_rotate_authentication_key(&account, new_key);
+}
+
+ + + +
+ + + +## Function `do_rotate_authentication_key` + + + +
public fun do_rotate_authentication_key(account: &signer, new_key: vector<u8>)
+
+ + + +
+Implementation + + +
public fun do_rotate_authentication_key(account: &signer, new_key: vector<u8>) acquires Account, EventStore {
+    let key_rotation_capability = extract_key_rotation_capability(account);
+    rotate_authentication_key_with_capability(&key_rotation_capability, copy new_key);
+    restore_key_rotation_capability(key_rotation_capability);
+
+    make_event_store_if_not_exist(account);
+    let signer_addr = Signer::address_of(account);
+    let event_store = borrow_global_mut<EventStore>(signer_addr);
+    Event::emit_event<RotateAuthKeyEvent>(
+        &mut event_store.rotate_auth_key_events,
+        RotateAuthKeyEvent {
+            account_address: signer_addr,
+            new_auth_key: new_key,
+        }
+    );
+}
+
+ + + +
+ + + +## Function `balance_for` + +Helper to return the u128 value of the balance for account + + +
fun balance_for<TokenType: store>(balance: &Account::Balance<TokenType>): u128
+
+ + + +
+Implementation + + +
fun balance_for<TokenType: store>(balance: &Balance<TokenType>): u128 {
+    Token::value<TokenType>(&balance.token)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `balance` + +Return the current TokenType balance of the account at addr. + + +
public fun balance<TokenType: store>(addr: address): u128
+
+ + + +
+Implementation + + +
public fun balance<TokenType: store>(addr: address): u128 acquires Balance {
+    if (exists<Balance<TokenType>>(addr)) {
+        balance_for(borrow_global<Balance<TokenType>>(addr))
+    } else {
+        0u128
+    }
+}
+
+ + + +
+ + + +## Function `do_accept_token` + +Add a balance of Token type to the sending account. + + +
public fun do_accept_token<TokenType: store>(account: &signer)
+
+ + + +
+Implementation + + +
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,
+        },
+    );
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if exists<Balance<TokenType>>(Signer::address_of(account));
+aborts_if !exists<Account>(Signer::address_of(account));
+
+ + + +
+ + + +## Function `accept_token` + + + +
public entry fun accept_token<TokenType: store>(account: signer)
+
+ + + +
+Implementation + + +
public entry fun accept_token<TokenType: store>(account: signer) acquires Account {
+    accept_token_entry<TokenType>(account);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `accept_token_entry` + + + +
public entry fun accept_token_entry<TokenType: store>(account: signer)
+
+ + + +
+Implementation + + +
public entry fun accept_token_entry<TokenType: store>(account: signer) acquires Account {
+    do_accept_token<TokenType>(&account);
+}
+
+ + + +
+ + + +## Function `is_accepts_token` + +This is a alias of is_accept_token + + +
public fun is_accepts_token<TokenType: store>(addr: address): bool
+
+ + + +
+Implementation + + +
public fun is_accepts_token<TokenType: store>(addr: address): bool acquires AutoAcceptToken {
+    Self::is_accept_token<TokenType>(addr)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `is_accept_token` + +Return whether the account at addr accept Token type tokens + + +
public fun is_accept_token<TokenType: store>(addr: address): bool
+
+ + + +
+Implementation + + +
public fun is_accept_token<TokenType: store>(addr: address): bool acquires AutoAcceptToken {
+    if (can_auto_accept_token(addr)) {
+        true
+    } else {
+        exists<Balance<TokenType>>(addr)
+    }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `can_auto_accept_token` + +Check whether the address can auto accept token. + + +
public fun can_auto_accept_token(addr: address): bool
+
+ + + +
+Implementation + + +
public fun can_auto_accept_token(addr: address): bool acquires AutoAcceptToken {
+    if (exists<AutoAcceptToken>(addr)) {
+        borrow_global<AutoAcceptToken>(addr).enable
+    } else {
+        false
+    }
+}
+
+ + + +
+ + + +## Function `set_auto_accept_token_entry` + + + +
public entry fun set_auto_accept_token_entry(account: signer, enable: bool)
+
+ + + +
+Implementation + + +
public entry fun set_auto_accept_token_entry(account: signer, enable: bool) acquires AutoAcceptToken {
+    set_auto_accept_token(&account, enable);
+}
+
+ + + +
+ + + +## Function `set_auto_accept_token` + +Configure whether auto-accept tokens. + + +
public fun set_auto_accept_token(account: &signer, enable: bool)
+
+ + + +
+Implementation + + +
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});
+    };
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `try_accept_token` + +try to accept token for addr. + + +
fun try_accept_token<TokenType: store>(addr: address)
+
+ + + +
+Implementation + + +
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)
+        }
+    };
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `sequence_number_for_account` + +Helper to return the sequence number field for given account + + +
fun sequence_number_for_account(account: &Account::Account): u64
+
+ + + +
+Implementation + + +
fun sequence_number_for_account(account: &Account): u64 {
+    account.sequence_number
+}
+
+ + + +
+ + + +## Function `sequence_number` + +Return the current sequence number at addr + + +
public fun sequence_number(addr: address): u64
+
+ + + +
+Implementation + + +
public fun sequence_number(addr: address): u64 acquires Account {
+    sequence_number_for_account(borrow_global<Account>(addr))
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Account>(addr);
+
+ + + +
+ + + +## Function `authentication_key` + +Return the authentication key for this account + + +
public fun authentication_key(addr: address): vector<u8>
+
+ + + +
+Implementation + + +
public fun authentication_key(addr: address): vector<u8> acquires Account {
+    *&borrow_global<Account>(addr).authentication_key
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Account>(addr);
+
+ + + +
+ + + +## Function `delegated_key_rotation_capability` + +Return true if the account at addr has delegated its key rotation capability + + +
public fun delegated_key_rotation_capability(addr: address): bool
+
+ + + +
+Implementation + + +
public fun delegated_key_rotation_capability(addr: address): bool
+acquires Account {
+    Option::is_none(&borrow_global<Account>(addr).key_rotation_capability)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Account>(addr);
+
+ + + +
+ + + +## Function `delegated_withdraw_capability` + +Return true if the account at addr has delegated its withdraw capability + + +
public fun delegated_withdraw_capability(addr: address): bool
+
+ + + +
+Implementation + + +
public fun delegated_withdraw_capability(addr: address): bool
+acquires Account {
+    Option::is_none(&borrow_global<Account>(addr).withdrawal_capability)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Account>(addr);
+
+ + + +
+ + + +## Function `withdraw_capability_address` + +Return a reference to the address associated with the given withdraw capability + + +
public fun withdraw_capability_address(cap: &Account::WithdrawCapability): &address
+
+ + + +
+Implementation + + +
public fun withdraw_capability_address(cap: &WithdrawCapability): &address {
+    &cap.account_address
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `key_rotation_capability_address` + +Return a reference to the address associated with the given key rotation capability + + +
public fun key_rotation_capability_address(cap: &Account::KeyRotationCapability): &address
+
+ + + +
+Implementation + + +
public fun key_rotation_capability_address(cap: &KeyRotationCapability): &address {
+    &cap.account_address
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `exists_at` + +Checks if an account exists at check_addr + + +
public fun exists_at(check_addr: address): bool
+
+ + + +
+Implementation + + +
public fun exists_at(check_addr: address): bool {
+    exists<Account>(check_addr)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `is_dummy_auth_key` + + + +
fun is_dummy_auth_key(account: &Account::Account): bool
+
+ + + +
+Implementation + + +
fun is_dummy_auth_key(account: &Account): bool {
+    *&account.authentication_key == DUMMY_AUTH_KEY
+}
+
+ + + +
+ + + +## Function `txn_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 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)
+
+ + + +
+Implementation + + +
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 {
+    txn_prologue_v2<TokenType>(
+        account,
+        txn_sender,
+        txn_sequence_number,
+        txn_authentication_key_preimage,
+        txn_gas_price,
+        txn_max_gas_units,
+        1,
+        1,
+    )
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Signer::address_of(account) != CoreAddresses::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_sequence_number < global<Account>(txn_sender).sequence_number;
+
+ + + +
+ + + +## Function `txn_prologue_v2` + + + +
public fun txn_prologue_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, stc_price: u128, stc_price_scaling: u128)
+
+ + + +
+Implementation + + +
public fun txn_prologue_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,
+    stc_price: u128,
+    stc_price_scaling: u128
+) 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
+    let (max_transaction_fee_stc,max_transaction_fee_token) = transaction_fee_simulate(txn_gas_price,txn_max_gas_units,0, stc_price, stc_price_scaling);
+    assert!(
+        max_transaction_fee_stc <= MAX_U64,
+        Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT),
+    );
+    if (max_transaction_fee_stc > 0) {
+        assert!(
+            (txn_sequence_number as u128) < MAX_U64,
+            Errors::limit_exceeded(EPROLOGUE_SEQUENCE_NUMBER_TOO_BIG)
+        );
+        let balance_amount_token = balance<TokenType>(txn_sender);
+        assert!(balance_amount_token >= max_transaction_fee_token, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT));
+        if (!is_stc<TokenType>()){
+            let balance_amount_stc= balance<STC>(CoreAddresses::GENESIS_ADDRESS());
+            assert!(balance_amount_stc >= max_transaction_fee_stc, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT));
+        }
+    };
+    // 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));
+
+}
+
+ + + +
+ + + +## Function `txn_epilogue` + +The epilogue is invoked at the end of transactions. +It collects gas and bumps the sequence number + + +
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)
+
+ + + +
+Implementation + + +
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_v3<TokenType>(account, txn_sender, txn_sequence_number, Vector::empty(), txn_gas_price, txn_max_gas_units, gas_units_remaining,1,1)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `transaction_fee_simulate` + + + +
public fun transaction_fee_simulate(txn_gas_price: u64, txn_max_gas_units: u64, gas_units_remaining: u64, stc_price: u128, stc_price_scaling: u128): (u128, u128)
+
+ + + +
+Implementation + + +
public fun transaction_fee_simulate(
+    txn_gas_price:u64,
+    txn_max_gas_units: u64,
+    gas_units_remaining:u64,
+    stc_price: u128,
+    stc_price_scaling: u128,
+): (u128, u128){
+    let transaction_fee_stc =(txn_gas_price * (txn_max_gas_units - gas_units_remaining) as u128);
+    let transaction_fee_token= Math::mul_div((transaction_fee_stc as u128), stc_price, stc_price_scaling);
+    transaction_fee_token = if (transaction_fee_token == 0 && transaction_fee_stc > 0 ) { 1 } else { transaction_fee_token};
+    (transaction_fee_stc, transaction_fee_token)
+}
+
+ + + +
+ + + +## Function `txn_epilogue_v2` + +The epilogue is invoked at the end of transactions. +It collects gas and bumps the sequence number + + +
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)
+
+ + + +
+Implementation + + +
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 {
+    txn_epilogue_v3<TokenType>(
+        account,
+        txn_sender,
+        txn_sequence_number,
+        txn_authentication_key_preimage,
+        txn_gas_price,
+        txn_max_gas_units,
+        gas_units_remaining,1,1)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+aborts_if Signer::address_of(account) != CoreAddresses::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::GENESIS_ADDRESS());
+aborts_if txn_gas_price * (txn_max_gas_units - gas_units_remaining) > 0 &&
+          global<TransactionFee::TransactionFee<TokenType>>(CoreAddresses::GENESIS_ADDRESS()).fee.value + txn_gas_price * (txn_max_gas_units - gas_units_remaining) > max_u128();
+
+ + + + +
pragma verify = false;
+aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+aborts_if !exists<Account>(txn_sender);
+aborts_if !exists<Balance<TokenType>>(txn_sender);
+aborts_if txn_sequence_number + 1 > max_u64();
+aborts_if !exists<Balance<TokenType>>(txn_sender);
+aborts_if txn_max_gas_units < gas_units_remaining;
+
+ + + +
+ + + +## Function `txn_epilogue_v3` + +The epilogue is invoked at the end of transactions. +It collects gas and bumps the sequence number + + +
public fun txn_epilogue_v3<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, stc_price: u128, stc_price_scaling: u128)
+
+ + + +
+Implementation + + +
public fun txn_epilogue_v3<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,
+    stc_price: u128,
+    stc_price_scaling: u128,
+) acquires Account, Balance {
+    CoreAddresses::assert_genesis_address(account);
+    // Charge for gas
+    let (transaction_fee_amount_stc,transaction_fee_amount_token) = transaction_fee_simulate(
+        txn_gas_price,
+        txn_max_gas_units,
+        gas_units_remaining,
+        stc_price,
+        stc_price_scaling);
+    assert!(
+        balance<TokenType>(txn_sender) >= transaction_fee_amount_token,
+        Errors::limit_exceeded(EINSUFFICIENT_BALANCE)
+    );
+    if (!is_stc<TokenType>()){
+        let genesis_balance_amount_stc=balance<STC>(CoreAddresses::GENESIS_ADDRESS());
+        assert!(genesis_balance_amount_stc >= transaction_fee_amount_stc,
+            Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT)
+        );
+    };
+    // Load the transaction sender's account and balance resources
+    let sender_account = borrow_global_mut<Account>(txn_sender);
+    // 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_stc > 0) {
+        let transaction_fee_token = withdraw_from_balance(
+        borrow_global_mut<Balance<TokenType>>(txn_sender),
+            transaction_fee_amount_token
+        );
+        deposit_to_balance(borrow_global_mut<Balance<TokenType>>(CoreAddresses::GENESIS_ADDRESS()), transaction_fee_token);
+        let stc_fee_token = withdraw_from_balance(borrow_global_mut<Balance<STC>>(CoreAddresses::GENESIS_ADDRESS()), transaction_fee_amount_stc);
+        TransactionFee::pay_fee(stc_fee_token);
+    };
+}
+
+ + + +
+ + + +## Function `remove_zero_balance_entry` + + + +
public entry fun remove_zero_balance_entry<TokenType: store>(account: signer)
+
+ + + +
+Implementation + + +
public entry fun remove_zero_balance_entry<TokenType: store>(account: signer) acquires Balance {
+    remove_zero_balance<TokenType>(&account);
+}
+
+ + + +
+ + + +## Function `remove_zero_balance` + +Remove zero Balance + + +
public fun remove_zero_balance<TokenType: store>(account: &signer)
+
+ + + +
+Implementation + + +
public fun remove_zero_balance<TokenType: store>(account: &signer) acquires Balance {
+    let addr: address = Signer::address_of(account);
+    let Balance<TokenType> { token } = move_from<Balance<TokenType>>(addr);
+    Token::destroy_zero<TokenType>(token);
+}
+
+ + + +
+ +
+Specification + + + +
let addr = Signer::address_of(account);
+aborts_if !exists<Balance<TokenType>>(addr);
+ensures !exists<Balance<TokenType>>(addr);
+
+ + + +
+ + + +## Function `make_event_store_if_not_exist` + +Make a event store if it's not exist. + + +
fun make_event_store_if_not_exist(account: &signer)
+
+ + + +
+Implementation + + +
fun make_event_store_if_not_exist(account: &signer) {
+    if (!exists<EventStore>(Signer::address_of(account))) {
+        move_to(account, EventStore {
+          rotate_auth_key_events: Event::new_event_handle<RotateAuthKeyEvent>(account),
+          extract_withdraw_cap_events: Event::new_event_handle<ExtractWithdrawCapEvent>(account),
+          signer_delegate_events: Event::new_event_handle<SignerDelegateEvent>(account),
+        })
+    };
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/AccountScripts.md b/build/StarcoinFramework/docs/AccountScripts.md new file mode 100644 index 00000000..0b0181fa --- /dev/null +++ b/build/StarcoinFramework/docs/AccountScripts.md @@ -0,0 +1,93 @@ + + + +# 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) +- [Function `remove_zero_balance`](#0x1_AccountScripts_remove_zero_balance) + + +
use 0x1::Account;
+
+ + + + + +## Function `enable_auto_accept_token` + +Enable account's auto-accept-token feature. +The script function is reenterable. + + +
public entry fun enable_auto_accept_token(account: signer)
+
+ + + +
+Implementation + + +
public entry fun enable_auto_accept_token(account: signer) {
+    Account::set_auto_accept_token_entry(account, true);
+}
+
+ + + +
+ + + +## Function `disable_auto_accept_token` + +Disable account's auto-accept-token feature. +The script function is reenterable. + + +
public entry fun disable_auto_accept_token(account: signer)
+
+ + + +
+Implementation + + +
public entry fun disable_auto_accept_token(account: signer) {
+    Account::set_auto_accept_token_entry(account, false);
+}
+
+ + + +
+ + + +## Function `remove_zero_balance` + +Remove zero Balance + + +
public entry fun remove_zero_balance<TokenType: store>(account: signer)
+
+ + + +
+Implementation + + +
public entry fun remove_zero_balance<TokenType: store>(account: signer) {
+    Account::remove_zero_balance_entry<TokenType>(account);
+}
+
+ + + +
diff --git a/build/StarcoinFramework/docs/Authenticator.md b/build/StarcoinFramework/docs/Authenticator.md new file mode 100644 index 00000000..baad0a7d --- /dev/null +++ b/build/StarcoinFramework/docs/Authenticator.md @@ -0,0 +1,448 @@ + + + +# Module `0x1::Authenticator` + +Move representation of the authenticator types +- Ed25519 (single-sig) +- MultiEd25519 (K-of-N multisig) + + +- [Struct `MultiEd25519PublicKey`](#0x1_Authenticator_MultiEd25519PublicKey) +- [Constants](#@Constants_0) +- [Function `create_multi_ed25519`](#0x1_Authenticator_create_multi_ed25519) +- [Function `ed25519_authentication_key`](#0x1_Authenticator_ed25519_authentication_key) +- [Function `derived_address`](#0x1_Authenticator_derived_address) +- [Function `multi_ed25519_authentication_key`](#0x1_Authenticator_multi_ed25519_authentication_key) +- [Function `public_keys`](#0x1_Authenticator_public_keys) +- [Function `threshold`](#0x1_Authenticator_threshold) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+public_keys: vector<vector<u8>> +
+
+ vector of ed25519 public keys +
+
+threshold: u8 +
+
+ approval threshold +
+
+ + +
+ + + +## Constants + + + + + + +
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
+
+ + + +
+Implementation + + +
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 }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if threshold == 0;
+aborts_if threshold > Vector::length(public_keys);
+aborts_if Vector::length(public_keys) > 32;
+
+ + + +
+ + + +## Function `ed25519_authentication_key` + +Compute an authentication key for the ed25519 public key public_key + + +
public fun ed25519_authentication_key(public_key: vector<u8>): vector<u8>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
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` + +convert authentication key to address + + +
public fun derived_address(authentication_key: vector<u8>): address
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Compute a multied25519 account authentication key for the policy k + + +
public fun multi_ed25519_authentication_key(k: &Authenticator::MultiEd25519PublicKey): vector<u8>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `public_keys` + +Return the public keys involved in the multisig policy k + + +
public fun public_keys(k: &Authenticator::MultiEd25519PublicKey): &vector<vector<u8>>
+
+ + + +
+Implementation + + +
public fun public_keys(k: &MultiEd25519PublicKey): &vector<vector<u8>> {
+    &k.public_keys
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `threshold` + +Return the threshold for the multisig policy k + + +
public fun threshold(k: &Authenticator::MultiEd25519PublicKey): u8
+
+ + + +
+Implementation + + +
public fun threshold(k: &MultiEd25519PublicKey): u8 {
+    *&k.threshold
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/BCS.md b/build/StarcoinFramework/docs/BCS.md new file mode 100644 index 00000000..9e684aac --- /dev/null +++ b/build/StarcoinFramework/docs/BCS.md @@ -0,0 +1,1599 @@ + + + +# 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. + + +- [Constants](#@Constants_0) +- [Function `to_bytes`](#0x1_BCS_to_bytes) +- [Function `to_address`](#0x1_BCS_to_address) +- [Function `deserialize_option_bytes_vector`](#0x1_BCS_deserialize_option_bytes_vector) +- [Function `deserialize_bytes_vector`](#0x1_BCS_deserialize_bytes_vector) +- [Function `deserialize_u64_vector`](#0x1_BCS_deserialize_u64_vector) +- [Function `deserialize_u128_vector`](#0x1_BCS_deserialize_u128_vector) +- [Function `deserialize_option_bytes`](#0x1_BCS_deserialize_option_bytes) +- [Function `deserialize_address`](#0x1_BCS_deserialize_address) +- [Function `deserialize_16_bytes`](#0x1_BCS_deserialize_16_bytes) +- [Function `deserialize_bytes`](#0x1_BCS_deserialize_bytes) +- [Function `deserialize_u128`](#0x1_BCS_deserialize_u128) +- [Function `deserialize_u64`](#0x1_BCS_deserialize_u64) +- [Function `deserialize_u32`](#0x1_BCS_deserialize_u32) +- [Function `deserialize_u16`](#0x1_BCS_deserialize_u16) +- [Function `deserialize_u8`](#0x1_BCS_deserialize_u8) +- [Function `deserialize_option_tag`](#0x1_BCS_deserialize_option_tag) +- [Function `deserialize_len`](#0x1_BCS_deserialize_len) +- [Function `deserialize_bool`](#0x1_BCS_deserialize_bool) +- [Function `get_byte`](#0x1_BCS_get_byte) +- [Function `get_n_bytes`](#0x1_BCS_get_n_bytes) +- [Function `get_n_bytes_as_u128`](#0x1_BCS_get_n_bytes_as_u128) +- [Function `deserialize_uleb128_as_u32`](#0x1_BCS_deserialize_uleb128_as_u32) +- [Function `serialize_u32_as_uleb128`](#0x1_BCS_serialize_u32_as_uleb128) +- [Function `skip_option_bytes_vector`](#0x1_BCS_skip_option_bytes_vector) +- [Function `skip_option_bytes`](#0x1_BCS_skip_option_bytes) +- [Function `skip_bytes_vector`](#0x1_BCS_skip_bytes_vector) +- [Function `skip_bytes`](#0x1_BCS_skip_bytes) +- [Function `skip_n_bytes`](#0x1_BCS_skip_n_bytes) +- [Function `skip_u64_vector`](#0x1_BCS_skip_u64_vector) +- [Function `skip_u128_vector`](#0x1_BCS_skip_u128_vector) +- [Function `skip_u256`](#0x1_BCS_skip_u256) +- [Function `skip_u128`](#0x1_BCS_skip_u128) +- [Function `skip_u64`](#0x1_BCS_skip_u64) +- [Function `skip_u32`](#0x1_BCS_skip_u32) +- [Function `skip_u16`](#0x1_BCS_skip_u16) +- [Function `skip_address`](#0x1_BCS_skip_address) +- [Function `skip_bool`](#0x1_BCS_skip_bool) +- [Function `can_skip`](#0x1_BCS_can_skip) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::Errors;
+use 0x1::Option;
+
+ + + + + +## Constants + + + + + + +
const ERR_INPUT_NOT_LARGE_ENOUGH: u64 = 201;
+
+ + + + + + + +
const ERR_INVALID_ULEB128_NUMBER_UNEXPECTED_ZERO_DIGIT: u64 = 207;
+
+ + + + + + + +
const ERR_OVERFLOW_PARSING_ULEB128_ENCODED_UINT32: u64 = 206;
+
+ + + + + + + +
const ERR_UNEXPECTED_BOOL_VALUE: u64 = 205;
+
+ + + + + + + +
const INTEGER32_MAX_VALUE: u64 = 2147483647;
+
+ + + + + +## Function `to_bytes` + +Return the binary representation of v in BCS (Starcoin Canonical Serialization) format + + +
public fun to_bytes<MoveValue>(v: &MoveValue): vector<u8>
+
+ + + +
+Implementation + + +
native public fun to_bytes<MoveValue>(v: &MoveValue): vector<u8>;
+
+ + + +
+ + + +## Function `to_address` + +Return the address of key bytes + + +
public fun to_address(key_bytes: vector<u8>): address
+
+ + + +
+Implementation + + +
native public fun to_address(key_bytes: vector<u8>): address;
+
+ + + +
+ + + +## Function `deserialize_option_bytes_vector` + + + +
public fun deserialize_option_bytes_vector(input: &vector<u8>, offset: u64): (vector<Option::Option<vector<u8>>>, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_option_bytes_vector(input: &vector<u8>, offset: u64): (vector<Option::Option<vector<u8>>>, u64) {
+    let (len, new_offset) = deserialize_len(input, offset);
+    let i = 0;
+    let vec = Vector::empty<Option::Option<vector<u8>>>();
+    while (i < len) {
+        let (opt_bs, o) = deserialize_option_bytes(input, new_offset);
+        Vector::push_back(&mut vec, opt_bs);
+        new_offset = o;
+        i = i + 1;
+    };
+    (vec, new_offset)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_bytes_vector` + + + +
public fun deserialize_bytes_vector(input: &vector<u8>, offset: u64): (vector<vector<u8>>, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_bytes_vector(input: &vector<u8>, offset: u64): (vector<vector<u8>>, u64) {
+    let (len, new_offset) = deserialize_len(input, offset);
+    let i = 0;
+    let vec = Vector::empty<vector<u8>>();
+    while (i < len) {
+        let (opt_bs, o) = deserialize_bytes(input, new_offset);
+        Vector::push_back(&mut vec, opt_bs);
+        new_offset = o;
+        i = i + 1;
+    };
+    (vec, new_offset)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_u64_vector` + + + +
public fun deserialize_u64_vector(input: &vector<u8>, offset: u64): (vector<u64>, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_u64_vector(input: &vector<u8>, offset: u64): (vector<u64>, u64) {
+    let (len, new_offset) = deserialize_len(input, offset);
+    let i = 0;
+    let vec = Vector::empty<u64>();
+    while (i < len) {
+        let (opt_bs, o) = deserialize_u64(input, new_offset);
+        Vector::push_back(&mut vec, opt_bs);
+        new_offset = o;
+        i = i + 1;
+    };
+    (vec, new_offset)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_u128_vector` + + + +
public fun deserialize_u128_vector(input: &vector<u8>, offset: u64): (vector<u128>, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_u128_vector(input: &vector<u8>, offset: u64): (vector<u128>, u64) {
+    let (len, new_offset) = deserialize_len(input, offset);
+    let i = 0;
+    let vec = Vector::empty<u128>();
+    while (i < len) {
+        let (opt_bs, o) = deserialize_u128(input, new_offset);
+        Vector::push_back(&mut vec, opt_bs);
+        new_offset = o;
+        i = i + 1;
+    };
+    (vec, new_offset)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_option_bytes` + + + +
public fun deserialize_option_bytes(input: &vector<u8>, offset: u64): (Option::Option<vector<u8>>, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_option_bytes(input: &vector<u8>, offset: u64): (Option::Option<vector<u8>>, u64) {
+    let (tag, new_offset) = deserialize_option_tag(input, offset);
+    if (!tag) {
+        return (Option::none<vector<u8>>(), new_offset)
+    } else {
+        let (bs, new_offset) = deserialize_bytes(input, new_offset);
+        return (Option::some<vector<u8>>(bs), new_offset)
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_address` + + + +
public fun deserialize_address(input: &vector<u8>, offset: u64): (address, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_address(input: &vector<u8>, offset: u64): (address, u64) {
+    let (content, new_offset) = deserialize_16_bytes(input, offset);
+    (BCS::to_address(content), new_offset)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_16_bytes` + + + +
public fun deserialize_16_bytes(input: &vector<u8>, offset: u64): (vector<u8>, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_16_bytes(input: &vector<u8>, offset: u64): (vector<u8>, u64) {
+    let content = get_n_bytes(input, offset, 16);
+    (content, offset + 16)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_bytes` + + + +
public fun deserialize_bytes(input: &vector<u8>, offset: u64): (vector<u8>, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_bytes(input: &vector<u8>, offset: u64): (vector<u8>, u64) {
+    let (len, new_offset) = deserialize_len(input, offset);
+    let content = get_n_bytes(input, new_offset, len);
+    (content, new_offset + len)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_u128` + + + +
public fun deserialize_u128(input: &vector<u8>, offset: u64): (u128, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_u128(input: &vector<u8>, offset: u64): (u128, u64) {
+    let u = get_n_bytes_as_u128(input, offset, 16);
+    (u, offset + 16)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_u64` + + + +
public fun deserialize_u64(input: &vector<u8>, offset: u64): (u64, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_u64(input: &vector<u8>, offset: u64): (u64, u64) {
+    let u = get_n_bytes_as_u128(input, offset, 8);
+    ((u as u64), offset + 8)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_u32` + + + +
public fun deserialize_u32(input: &vector<u8>, offset: u64): (u64, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_u32(input: &vector<u8>, offset: u64): (u64, u64) {
+    let u = get_n_bytes_as_u128(input, offset, 4);
+    ((u as u64), offset + 4)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_u16` + + + +
public fun deserialize_u16(input: &vector<u8>, offset: u64): (u64, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_u16(input: &vector<u8>, offset: u64): (u64, u64) {
+    let u = get_n_bytes_as_u128(input, offset, 2);
+    ((u as u64), offset + 2)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_u8` + + + +
public fun deserialize_u8(input: &vector<u8>, offset: u64): (u8, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_u8(input: &vector<u8>, offset: u64): (u8, u64) {
+    let u = get_byte(input, offset);
+    (u, offset + 1)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_option_tag` + + + +
public fun deserialize_option_tag(input: &vector<u8>, offset: u64): (bool, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_option_tag(input: &vector<u8>, offset: u64): (bool, u64) {
+    deserialize_bool(input, offset)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_len` + + + +
public fun deserialize_len(input: &vector<u8>, offset: u64): (u64, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_len(input: &vector<u8>, offset: u64): (u64, u64) {
+    deserialize_uleb128_as_u32(input, offset)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_bool` + + + +
public fun deserialize_bool(input: &vector<u8>, offset: u64): (bool, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_bool(input: &vector<u8>, offset: u64): (bool, u64) {
+    let b = get_byte(input, offset);
+    if (b == 1) {
+        return (true, offset + 1)
+    } else if (b == 0) {
+        return (false, offset + 1)
+    } else {
+        abort ERR_UNEXPECTED_BOOL_VALUE
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `get_byte` + + + +
fun get_byte(input: &vector<u8>, offset: u64): u8
+
+ + + +
+Implementation + + +
fun get_byte(input: &vector<u8>, offset: u64): u8 {
+    assert!(((offset + 1) <= Vector::length(input)) && (offset < offset + 1), Errors::invalid_state(ERR_INPUT_NOT_LARGE_ENOUGH));
+    *Vector::borrow(input, offset)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `get_n_bytes` + + + +
fun get_n_bytes(input: &vector<u8>, offset: u64, n: u64): vector<u8>
+
+ + + +
+Implementation + + +
fun get_n_bytes(input: &vector<u8>, offset: u64, n: u64): vector<u8> {
+    assert!(((offset + n) <= Vector::length(input)) && (offset < offset + n), Errors::invalid_state(ERR_INPUT_NOT_LARGE_ENOUGH));
+    let i = 0;
+    let content = Vector::empty<u8>();
+    while (i < n) {
+        let b = *Vector::borrow(input, offset + i);
+        Vector::push_back(&mut content, b);
+        i = i + 1;
+    };
+    content
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `get_n_bytes_as_u128` + + + +
fun get_n_bytes_as_u128(input: &vector<u8>, offset: u64, n: u64): u128
+
+ + + +
+Implementation + + +
fun get_n_bytes_as_u128(input: &vector<u8>, offset: u64, n: u64): u128 {
+    assert!(((offset + n) <= Vector::length(input)) && (offset < offset + n), Errors::invalid_state(ERR_INPUT_NOT_LARGE_ENOUGH));
+    let number: u128 = 0;
+    let i = 0;
+    while (i < n) {
+        let byte = *Vector::borrow(input, offset + i);
+        let s = (i as u8) * 8;
+        number = number + ((byte as u128) << s);
+        i = i + 1;
+    };
+    number
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `deserialize_uleb128_as_u32` + + + +
public fun deserialize_uleb128_as_u32(input: &vector<u8>, offset: u64): (u64, u64)
+
+ + + +
+Implementation + + +
public fun deserialize_uleb128_as_u32(input: &vector<u8>, offset: u64): (u64, u64) {
+    let value: u64 = 0;
+    let shift = 0;
+    let new_offset = offset;
+    while (shift < 32) {
+        let x = get_byte(input, new_offset);
+        new_offset = new_offset + 1;
+        let digit: u8 = x & 0x7F;
+        value = value | (digit as u64) << shift;
+        if ((value < 0) || (value > INTEGER32_MAX_VALUE)) {
+            abort ERR_OVERFLOW_PARSING_ULEB128_ENCODED_UINT32
+        };
+        if (digit == x) {
+            if (shift > 0 && digit == 0) {
+                abort ERR_INVALID_ULEB128_NUMBER_UNEXPECTED_ZERO_DIGIT
+            };
+            return (value, new_offset)
+        };
+        shift = shift + 7
+    };
+    abort ERR_OVERFLOW_PARSING_ULEB128_ENCODED_UINT32
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+pragma verify = false;
+
+ + + +
+ + + +## Function `serialize_u32_as_uleb128` + + + +
fun serialize_u32_as_uleb128(value: u64): vector<u8>
+
+ + + +
+Implementation + + +
fun serialize_u32_as_uleb128(value: u64): vector<u8> {
+    let output = Vector::empty<u8>();
+    while ((value >> 7) != 0) {
+        Vector::push_back(&mut output, (((value & 0x7f) | 0x80) as u8));
+        value = value >> 7;
+    };
+    Vector::push_back(&mut output, (value as u8));
+    output
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_option_bytes_vector` + + + +
public fun skip_option_bytes_vector(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_option_bytes_vector(input: &vector<u8>, offset: u64): u64 {
+    let (len, new_offset) = deserialize_len(input, offset);
+    let i = 0;
+    while (i < len) {
+        new_offset = skip_option_bytes(input, new_offset);
+        i = i + 1;
+    };
+    new_offset
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_option_bytes` + + + +
public fun skip_option_bytes(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_option_bytes(input: &vector<u8>, offset: u64):  u64 {
+    let (tag, new_offset) = deserialize_option_tag(input, offset);
+    if (!tag) {
+        new_offset
+    } else {
+        skip_bytes(input, new_offset)
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_bytes_vector` + + + +
public fun skip_bytes_vector(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_bytes_vector(input: &vector<u8>, offset: u64): u64 {
+    let (len, new_offset) = deserialize_len(input, offset);
+    let i = 0;
+    while (i < len) {
+        new_offset = skip_bytes(input, new_offset);
+        i = i + 1;
+    };
+    new_offset
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_bytes` + + + +
public fun skip_bytes(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_bytes(input: &vector<u8>, offset: u64): u64 {
+    let (len, new_offset) = deserialize_len(input, offset);
+    new_offset + len
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_n_bytes` + + + +
public fun skip_n_bytes(input: &vector<u8>, offset: u64, n: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_n_bytes(input: &vector<u8>, offset: u64, n:u64): u64 {
+    can_skip(input, offset, n );
+    offset + n
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_u64_vector` + + + +
public fun skip_u64_vector(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_u64_vector(input: &vector<u8>, offset: u64): u64 {
+    let (len, new_offset) = deserialize_len(input, offset);
+    can_skip(input, new_offset, len * 8);
+    new_offset + len * 8
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_u128_vector` + + + +
public fun skip_u128_vector(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_u128_vector(input: &vector<u8>, offset: u64): u64 {
+    let (len, new_offset) = deserialize_len(input, offset);
+    can_skip(input, new_offset, len * 16);
+    new_offset + len * 16
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_u256` + + + +
public fun skip_u256(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_u256(input: &vector<u8>, offset: u64): u64 {
+    can_skip(input, offset, 32 );
+    offset + 32
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_u128` + + + +
public fun skip_u128(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_u128(input: &vector<u8>, offset: u64): u64 {
+    can_skip(input, offset, 16 );
+    offset + 16
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_u64` + + + +
public fun skip_u64(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_u64(input: &vector<u8>, offset: u64): u64 {
+    can_skip(input, offset, 8 );
+    offset + 8
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_u32` + + + +
public fun skip_u32(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_u32(input: &vector<u8>, offset: u64): u64 {
+    can_skip(input, offset, 4 );
+    offset + 4
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_u16` + + + +
public fun skip_u16(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_u16(input: &vector<u8>, offset: u64): u64 {
+    can_skip(input, offset, 2 );
+    offset + 2
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_address` + + + +
public fun skip_address(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_address(input: &vector<u8>, offset: u64): u64 {
+    skip_n_bytes(input, offset, 16)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `skip_bool` + + + +
public fun skip_bool(input: &vector<u8>, offset: u64): u64
+
+ + + +
+Implementation + + +
public fun skip_bool(input: &vector<u8>, offset: u64):  u64{
+    can_skip(input, offset, 1);
+    offset + 1
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `can_skip` + + + +
fun can_skip(input: &vector<u8>, offset: u64, n: u64)
+
+ + + +
+Implementation + + +
fun can_skip(input: &vector<u8>, offset: u64, n: u64){
+    assert!(((offset + n) <= Vector::length(input)) && (offset < offset + n), Errors::invalid_state(ERR_INPUT_NOT_LARGE_ENOUGH));
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
+ + + + + + + +
native fun serialize<MoveValue>(v: &MoveValue): vector<u8>;
+
diff --git a/build/StarcoinFramework/docs/Bitwise.md b/build/StarcoinFramework/docs/Bitwise.md new file mode 100644 index 00000000..74d8a7ca --- /dev/null +++ b/build/StarcoinFramework/docs/Bitwise.md @@ -0,0 +1,179 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_0) + + +
+ + + + + +## Function `and` + +bit and: x & y + + +
public fun and(x: u64, y: u64): u64
+
+ + + +
+Implementation + + +
public fun and(x: u64, y: u64): u64 {
+    (x & y as u64)
+}
+
+ + + +
+ + + +## Function `or` + +bit or: x | y + + +
public fun or(x: u64, y: u64): u64
+
+ + + +
+Implementation + + +
public fun or(x: u64, y: u64): u64 {
+    (x | y as u64)
+}
+
+ + + +
+ + + +## Function `xor` + +bit xor: x ^ y + + +
public fun xor(x: u64, y: u64): u64
+
+ + + +
+Implementation + + +
public fun xor(x: u64, y: u64): u64 {
+    (x ^ y as u64)
+}
+
+ + + +
+ + + +## Function `not` + +bit not: !x + + +
public fun not(x: u64): u64
+
+ + + +
+Implementation + + +
public fun not(x: u64): u64 {
+   (x ^ 18446744073709551615u64 as u64)
+}
+
+ + + +
+ + + +## Function `lshift` + +left shift n bits. + + +
public fun lshift(x: u64, n: u8): u64
+
+ + + +
+Implementation + + +
public fun lshift(x: u64, n: u8): u64 {
+    (x << n  as u64)
+}
+
+ + + +
+ + + +## Function `rshift` + +right shift n bits. + + +
public fun rshift(x: u64, n: u8): u64
+
+ + + +
+Implementation + + +
public fun rshift(x: u64, n: u8): u64 {
+    (x >> n  as u64)
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+
diff --git a/build/StarcoinFramework/docs/Block.md b/build/StarcoinFramework/docs/Block.md new file mode 100644 index 00000000..534f285d --- /dev/null +++ b/build/StarcoinFramework/docs/Block.md @@ -0,0 +1,941 @@ + + + +# Module `0x1::Block` + +Block module provide metadata for generated blocks. + + +- [Resource `BlockMetadata`](#0x1_Block_BlockMetadata) +- [Struct `NewBlockEvent`](#0x1_Block_NewBlockEvent) +- [Struct `Checkpoint`](#0x1_Block_Checkpoint) +- [Resource `Checkpoints`](#0x1_Block_Checkpoints) +- [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) +- [Function `checkpoints_init`](#0x1_Block_checkpoints_init) +- [Function `checkpoint_entry`](#0x1_Block_checkpoint_entry) +- [Function `checkpoint`](#0x1_Block_checkpoint) +- [Function `base_checkpoint`](#0x1_Block_base_checkpoint) +- [Function `latest_state_root`](#0x1_Block_latest_state_root) +- [Function `base_latest_state_root`](#0x1_Block_base_latest_state_root) +- [Function `update_state_root_entry`](#0x1_Block_update_state_root_entry) +- [Function `update_state_root`](#0x1_Block_update_state_root) +- [Function `base_update_state_root`](#0x1_Block_base_update_state_root) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::BCS;
+use 0x1::CoreAddresses;
+use 0x1::Errors;
+use 0x1::Event;
+use 0x1::Hash;
+use 0x1::Option;
+use 0x1::Ring;
+use 0x1::Timestamp;
+use 0x1::Vector;
+
+ + + + + +## Resource `BlockMetadata` + +Block metadata struct. + + +
struct BlockMetadata has key
+
+ + + +
+Fields + + +
+
+number: u64 +
+
+ number of the current block +
+
+parent_hash: vector<u8> +
+
+ Hash of the parent block. +
+
+author: address +
+
+ Author of the current block. +
+
+uncles: u64 +
+
+ number of uncles. +
+
+new_block_events: Event::EventHandle<Block::NewBlockEvent> +
+
+ Handle of events when new blocks are emitted +
+
+ + +
+ + + +## Struct `NewBlockEvent` + +Events emitted when new block generated. + + +
struct NewBlockEvent has drop, store
+
+ + + +
+Fields + + +
+
+number: u64 +
+
+ +
+
+author: address +
+
+ +
+
+timestamp: u64 +
+
+ +
+
+uncles: u64 +
+
+ +
+
+ + +
+ + + +## Struct `Checkpoint` + + + +
struct Checkpoint has copy, drop, store
+
+ + + +
+Fields + + +
+
+block_number: u64 +
+
+ +
+
+block_hash: vector<u8> +
+
+ +
+
+state_root: Option::Option<vector<u8>> +
+
+ +
+
+ + +
+ + + +## Resource `Checkpoints` + + + +
struct Checkpoints has store, key
+
+ + + +
+Fields + + +
+
+checkpoints: Ring::Ring<Block::Checkpoint> +
+
+ +
+
+index: u64 +
+
+ +
+
+last_number: u64 +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
const BLOCK_HEADER_LENGTH: u64 = 247;
+
+ + + + + + + +
const BLOCK_INTERVAL_NUMBER: u64 = 5;
+
+ + + + + + + +
const CHECKPOINT_LENGTH: u64 = 60;
+
+ + + + + + + +
const EBLOCK_NUMBER_MISMATCH: u64 = 17;
+
+ + + + + + + +
const ERROR_INTERVAL_TOO_LITTLE: u64 = 20;
+
+ + + + + + + +
const ERROR_NOT_BLOCK_HEADER: u64 = 19;
+
+ + + + + + + +
const ERROR_NO_HAVE_CHECKPOINT: u64 = 18;
+
+ + + + + +## Function `initialize` + +This can only be invoked by the GENESIS_ACCOUNT at genesis + + +
public fun initialize(account: &signer, parent_hash: vector<u8>)
+
+ + + +
+Implementation + + +
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),
+        });
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !Timestamp::is_genesis();
+aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+aborts_if exists<BlockMetadata>(Signer::address_of(account));
+
+ + + +
+ + + +## Function `get_current_block_number` + +Get the current block number + + +
public fun get_current_block_number(): u64
+
+ + + +
+Implementation + + +
public fun get_current_block_number(): u64 acquires BlockMetadata {
+  borrow_global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).number
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `get_parent_hash` + +Get the hash of the parent block. + + +
public fun get_parent_hash(): vector<u8>
+
+ + + +
+Implementation + + +
public fun get_parent_hash(): vector<u8> acquires BlockMetadata {
+  *&borrow_global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).parent_hash
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `get_current_author` + +Gets the address of the author of the current block + + +
public fun get_current_author(): address
+
+ + + +
+Implementation + + +
public fun get_current_author(): address acquires BlockMetadata {
+  borrow_global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).author
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `process_block_metadata` + +Call at block prologue + + +
public fun process_block_metadata(account: &signer, parent_hash: vector<u8>, author: address, timestamp: u64, uncles: u64, number: u64)
+
+ + + +
+Implementation + + +
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,
+      }
+    );
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
+aborts_if number != global<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS()).number + 1;
+
+ + + + + + + +
schema AbortsIfBlockMetadataNotExist {
+    aborts_if !exists<BlockMetadata>(CoreAddresses::GENESIS_ADDRESS());
+}
+
+ + + +
+ + + +## Function `checkpoints_init` + + + +
public fun checkpoints_init(account: &signer)
+
+ + + +
+Implementation + + +
public fun checkpoints_init(account: &signer){
+    CoreAddresses::assert_genesis_address(account);
+
+    let checkpoints = Ring::create_with_capacity<Checkpoint>(CHECKPOINT_LENGTH);
+    move_to<Checkpoints>(
+        account,
+        Checkpoints {
+           checkpoints,
+           index        : 0,
+           last_number  : 0,
+    });
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `checkpoint_entry` + + + +
public entry fun checkpoint_entry(_account: signer)
+
+ + + +
+Implementation + + +
public entry fun checkpoint_entry(_account: signer) acquires BlockMetadata, Checkpoints {
+    checkpoint();
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `checkpoint` + + + +
public fun checkpoint()
+
+ + + +
+Implementation + + +
public fun checkpoint() acquires BlockMetadata, Checkpoints{
+    let parent_block_number = get_current_block_number() - 1;
+    let parent_block_hash   = get_parent_hash();
+
+    let checkpoints = borrow_global_mut<Checkpoints>(CoreAddresses::GENESIS_ADDRESS());
+    base_checkpoint(checkpoints, parent_block_number, parent_block_hash);
+
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `base_checkpoint` + + + +
fun base_checkpoint(checkpoints: &mut Block::Checkpoints, parent_block_number: u64, parent_block_hash: vector<u8>)
+
+ + + +
+Implementation + + +
fun base_checkpoint(checkpoints: &mut Checkpoints, parent_block_number: u64, parent_block_hash:vector<u8>){
+    assert!(checkpoints.last_number + BLOCK_INTERVAL_NUMBER <= parent_block_number || checkpoints.last_number == 0, Errors::invalid_argument(ERROR_INTERVAL_TOO_LITTLE));
+
+    checkpoints.index = checkpoints.index + 1;
+    checkpoints.last_number = parent_block_number;
+    let op_checkpoint = Ring::push<Checkpoint>(&mut checkpoints.checkpoints, Checkpoint {
+                                                            block_number: parent_block_number,
+                                                            block_hash: parent_block_hash,
+                                                            state_root: Option::none<vector<u8>>(),
+                                                        } );
+    if(Option::is_some(&op_checkpoint)){
+        Option::destroy_some(op_checkpoint);
+    }else{
+        Option::destroy_none(op_checkpoint);
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `latest_state_root` + + + +
public fun latest_state_root(): (u64, vector<u8>)
+
+ + + +
+Implementation + + +
public fun latest_state_root():(u64,vector<u8>) acquires  Checkpoints{
+    let checkpoints = borrow_global<Checkpoints>(CoreAddresses::GENESIS_ADDRESS());
+    base_latest_state_root(checkpoints)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `base_latest_state_root` + + + +
fun base_latest_state_root(checkpoints: &Block::Checkpoints): (u64, vector<u8>)
+
+ + + +
+Implementation + + +
fun base_latest_state_root(checkpoints: &Checkpoints):(u64,vector<u8>){
+    let len = Ring::capacity<Checkpoint>(&checkpoints.checkpoints);
+    let j = if(checkpoints.index < len - 1){
+        checkpoints.index
+    }else{
+        len
+    };
+    let i = checkpoints.index;
+    while( j > 0){
+        let op_checkpoint = Ring::borrow(&checkpoints.checkpoints, i - 1 );
+        if( Option::is_some(op_checkpoint) && Option::is_some(&Option::borrow(op_checkpoint).state_root) ) {
+            let state_root = Option::borrow(&Option::borrow(op_checkpoint).state_root);
+            return (Option::borrow(op_checkpoint).block_number, *state_root)
+        };
+        j = j - 1;
+        i = i - 1;
+    };
+
+    abort Errors::invalid_state(ERROR_NO_HAVE_CHECKPOINT)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `update_state_root_entry` + + + +
public entry fun update_state_root_entry(_account: signer, header: vector<u8>)
+
+ + + +
+Implementation + + +
public entry fun update_state_root_entry(_account: signer , header: vector<u8>)
+acquires Checkpoints {
+    update_state_root(header);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `update_state_root` + + + +
public fun update_state_root(header: vector<u8>)
+
+ + + +
+Implementation + + +
public fun update_state_root(header: vector<u8>) acquires  Checkpoints {
+    let checkpoints = borrow_global_mut<Checkpoints>(CoreAddresses::GENESIS_ADDRESS());
+    base_update_state_root(checkpoints, header);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `base_update_state_root` + + + +
fun base_update_state_root(checkpoints: &mut Block::Checkpoints, header: vector<u8>)
+
+ + + +
+Implementation + + +
fun base_update_state_root(checkpoints: &mut Checkpoints, header: vector<u8>){
+    let prefix = Hash::sha3_256(b"STARCOIN::BlockHeader");
+
+    //parent_hash
+    let new_offset = BCS::skip_bytes(&header,0);
+    //timestamp
+    let new_offset = BCS::skip_u64(&header,new_offset);
+    //number
+    let (number,new_offset) = BCS::deserialize_u64(&header,new_offset);
+    //author
+    new_offset = BCS::skip_address(&header,new_offset);
+    //author_auth_key
+    new_offset = BCS::skip_option_bytes(&header,new_offset);
+    //txn_accumulator_root
+    new_offset = BCS::skip_bytes(&header,new_offset);
+    //block_accumulator_root
+    new_offset = BCS::skip_bytes(&header,new_offset);
+    //state_root
+    let (state_root,_new_offset) = BCS::deserialize_bytes(&header,new_offset);
+
+    Vector::append(&mut prefix,header);
+    let block_hash = Hash::sha3_256(prefix);
+
+    let len = Ring::capacity<Checkpoint>(&checkpoints.checkpoints);
+    let j = if(checkpoints.index < len - 1){
+        checkpoints.index
+    }else{
+        len
+    };
+    let i = checkpoints.index;
+    while( j > 0){
+        let op_checkpoint = Ring::borrow_mut(&mut checkpoints.checkpoints, i - 1);
+
+        if( Option::is_some(op_checkpoint) && &Option::borrow(op_checkpoint).block_hash == &block_hash && Option::borrow<Checkpoint>(op_checkpoint).block_number == number) {
+
+            let op_state_root = &mut Option::borrow_mut<Checkpoint>(op_checkpoint).state_root;
+            if(Option::is_some(op_state_root)){
+                Option::swap(op_state_root, state_root);
+            }else{
+                Option::fill(op_state_root, state_root);
+            };
+            return
+        };
+        j = j - 1;
+        i = i - 1;
+    };
+
+    abort Errors::invalid_state(ERROR_NO_HAVE_CHECKPOINT)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/BlockReward.md b/build/StarcoinFramework/docs/BlockReward.md new file mode 100644 index 00000000..213d255d --- /dev/null +++ b/build/StarcoinFramework/docs/BlockReward.md @@ -0,0 +1,397 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+reward_number: u64 +
+
+ How many block rewards has been handled. +
+
+infos: vector<BlockReward::RewardInfo> +
+
+ informations about the reward distribution. +
+
+reward_events: Event::EventHandle<BlockReward::BlockRewardEvent> +
+
+ event handle used to emit block reward event. +
+
+ + +
+ + + +## Struct `RewardInfo` + +Reward info of miners. + + +
struct RewardInfo has store
+
+ + + +
+Fields + + +
+
+number: u64 +
+
+ number of the block miner minted. +
+
+reward: u128 +
+
+ how many stc rewards. +
+
+miner: address +
+
+ miner who mint the block. +
+
+gas_fees: Token::Token<STC::STC> +
+
+ store the gas fee that users consumed. +
+
+ + +
+ + + +## Struct `BlockRewardEvent` + +block reward event + + +
struct BlockRewardEvent has drop, store
+
+ + + +
+Fields + + +
+
+block_number: u64 +
+
+ block number +
+
+block_reward: u128 +
+
+ STC reward. +
+
+gas_fees: u128 +
+
+ gas fees in STC. +
+
+miner: address +
+
+ block miner +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
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),
+    });
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Process the given block rewards. + + +
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>)
+
+ + + +
+Implementation + + +
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);
+
+}
+
+ + + +
+ +
+Specification + + + +
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;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/ChainId.md b/build/StarcoinFramework/docs/ChainId.md new file mode 100644 index 00000000..89ab9fd3 --- /dev/null +++ b/build/StarcoinFramework/docs/ChainId.md @@ -0,0 +1,425 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::CoreAddresses;
+use 0x1::Timestamp;
+
+ + + + + +## Resource `ChainId` + +chain id data structure. + + +
struct ChainId has key
+
+ + + +
+Fields + + +
+
+id: u8 +
+
+ real id. +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
public fun initialize(account: &signer, id: u8) {
+    Timestamp::assert_genesis();
+    CoreAddresses::assert_genesis_address(account);
+    move_to(account, ChainId { id });
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !Timestamp::is_genesis();
+aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+aborts_if exists<ChainId>(Signer::address_of(account));
+ensures exists<ChainId>(Signer::address_of(account));
+
+ + + +
+ + + +## Function `get` + +Return the chain ID of this chain + + +
public fun get(): u8
+
+ + + +
+Implementation + + +
public fun get(): u8 acquires ChainId {
+    borrow_global<ChainId>(CoreAddresses::GENESIS_ADDRESS()).id
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `is_dev` + + + +
public fun is_dev(): bool
+
+ + + +
+Implementation + + +
public fun is_dev(): bool acquires ChainId {
+    get() == DEV_CHAIN_ID
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `is_test` + + + +
public fun is_test(): bool
+
+ + + +
+Implementation + + +
public fun is_test(): bool acquires ChainId {
+    get() == TEST_CHAIN_ID
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `is_halley` + + + +
public fun is_halley(): bool
+
+ + + +
+Implementation + + +
public fun is_halley(): bool acquires ChainId {
+    get() == HALLEY_CHAIN_ID
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `is_proxima` + + + +
public fun is_proxima(): bool
+
+ + + +
+Implementation + + +
public fun is_proxima(): bool acquires ChainId {
+    get() == PROXIMA_CHAIN_ID
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `is_barnard` + + + +
public fun is_barnard(): bool
+
+ + + +
+Implementation + + +
public fun is_barnard(): bool acquires ChainId {
+    get() == BARNARD_CHAIN_ID
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `is_main` + + + +
public fun is_main(): bool
+
+ + + +
+Implementation + + +
public fun is_main(): bool acquires ChainId {
+    get() == MAIN_CHAIN_ID
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+ensures exists<ChainId>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/Collection.md b/build/StarcoinFramework/docs/Collection.md new file mode 100644 index 00000000..6716cbb4 --- /dev/null +++ b/build/StarcoinFramework/docs/Collection.md @@ -0,0 +1,430 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::Errors;
+use 0x1::Option;
+use 0x1::Signer;
+use 0x1::Vector;
+
+ + + + + +## Struct `Collection` + +Collection in memory, can not drop & store. + + +
struct Collection<T>
+
+ + + +
+Fields + + +
+
+items: vector<T> +
+
+ +
+
+owner: address +
+
+ the owner of Collection. +
+
+ + +
+ + + +## Resource `CollectionStore` + +Collection in global store. + + +
struct CollectionStore<T: store> has key
+
+ + + +
+Fields + + +
+
+items: Option::Option<vector<T>> +
+
+ items in the CollectionStore. + use Option at here is for temporary take away from store to construct Collection. +
+
+ + +
+ + + +## Constants + + + + + + +
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 ith element of the collection c. +Aborts if i is out of bounds. + + +
public fun borrow<T>(c: &Collection::Collection<T>, i: u64): &T
+
+ + + +
+Implementation + + +
public fun borrow<T>(c: &Collection<T>, i: u64): &T{
+    Vector::borrow(&c.items, i)
+}
+
+ + + +
+ + + +## Function `pop_back` + +Pop an element from the end of vector v. +Aborts if v is empty. + + +
public fun pop_back<T>(account: &signer, c: &mut Collection::Collection<T>): T
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `exists_at` + +check the Collection exists in addr + + +
fun exists_at<T: store>(addr: address): bool
+
+ + + +
+Implementation + + +
fun exists_at<T: store>(addr: address): bool{
+    exists<CollectionStore<T>>(addr)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `put` + +Deprecated since @v3 +Put items to account's Collection last position. + + +
public fun put<T: store>(_account: &signer, _item: T)
+
+ + + +
+Implementation + + +
public fun put<T: store>(_account: &signer, _item: T) {
+    abort Errors::deprecated(EDEPRECATED_FUNCTION)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `take` + +Take last item from account's Collection of T. + + +
public fun take<T: store>(account: &signer): T
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `borrow_collection` + +Borrow collection of T from addr + + +
public fun borrow_collection<T: store>(addr: address): Collection::Collection<T>
+
+ + + +
+Implementation + + +
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
+    }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `return_collection` + +Return the Collection of T + + +
public fun return_collection<T: store>(c: Collection::Collection<T>)
+
+ + + +
+Implementation + + +
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);
+    }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `destroy_empty` + + + +
fun destroy_empty<T: store>(c: Collection::CollectionStore<T>)
+
+ + + +
+Implementation + + +
fun destroy_empty<T: store>(c: CollectionStore<T>){
+    let CollectionStore{ items } = c;
+    Option::destroy_none(items);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = false;
+
diff --git a/build/StarcoinFramework/docs/Collection2.md b/build/StarcoinFramework/docs/Collection2.md new file mode 100644 index 00000000..42e6ff21 --- /dev/null +++ b/build/StarcoinFramework/docs/Collection2.md @@ -0,0 +1,878 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::Errors;
+use 0x1::Option;
+use 0x1::Signer;
+use 0x1::Vector;
+
+ + + + + +## Struct `Collection` + +Collection in memory, can not drop & store. + + +
struct Collection<T>
+
+ + + +
+Fields + + +
+
+items: vector<T> +
+
+ +
+
+owner: address +
+
+ +
+
+can_put: bool +
+
+ +
+
+can_mut: bool +
+
+ +
+
+can_take: bool +
+
+ +
+
+ + +
+ + + +## Resource `CollectionStore` + +Collection in global store. + + +
struct CollectionStore<T: store> has key
+
+ + + +
+Fields + + +
+
+items: Option::Option<vector<T>> +
+
+ items in the CollectionStore. + use Option at here is for temporary take away from store to construct Collection. +
+
+anyone_can_put: bool +
+
+ +
+
+anyone_can_mut: bool +
+
+ +
+
+ + +
+ + + +## Constants + + + + +The operator require the collection owner or collection set anyone_can_put to true. + + +
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
+
+ + + +
+Implementation + + +
public fun length<T>(c: &Collection<T>): u64{
+    Vector::length(&c.items)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `borrow` + +Acquire an immutable reference to the ith element of the collection c. +Aborts if i is out of bounds. + + +
public fun borrow<T>(c: &Collection2::Collection<T>, i: u64): &T
+
+ + + +
+Implementation + + +
public fun borrow<T>(c: &Collection<T>, i: u64): &T{
+    Vector::borrow(&c.items, i)
+}
+
+ + + +
+ + + +## Function `push_back` + +Add item v to the end of the collection c. +require owner of Collection. + + +
public fun push_back<T>(c: &mut Collection2::Collection<T>, t: T)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ + + +## Function `borrow_mut` + +Return a mutable reference to the ith 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
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `pop_back` + +Pop an element from the end of vector v. +Aborts if v is empty. + + +
public fun pop_back<T>(c: &mut Collection2::Collection<T>): T
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `remove` + + + +
public fun remove<T>(c: &mut Collection2::Collection<T>, i: u64): T
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `append` + + + +
public fun append<T>(c: &mut Collection2::Collection<T>, other: T)
+
+ + + +
+Implementation + + +
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))
+}
+
+ + + +
+ + + +## Function `append_all` + + + +
public fun append_all<T>(c: &mut Collection2::Collection<T>, other: vector<T>)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `exists_at` + +check the Collection exists in addr + + +
public fun exists_at<T: store>(addr: address): bool
+
+ + + +
+Implementation + + +
public fun exists_at<T: store>(addr: address): bool{
+    exists<CollectionStore<T>>(addr)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `is_accept` + +check 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
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `accept` + +signer allow other send T to self +create a Collection of T and set anyone_can_put to true +if the Collection exists, just update anyone_can_put to true + + +
public fun accept<T: store>(signer: &signer)
+
+ + + +
+Implementation + + +
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;
+    }
+}
+
+ + + +
+ + + +## Function `put` + +Put items to to_addr's Collection of T +put = borrow_collection + append + return_collection. + + +
public fun put<T: store>(signer: &signer, owner: address, item: T)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `put_all` + +Put all items to owner's collection of T. + + +
public fun put_all<T: store>(signer: &signer, owner: address, items: vector<T>)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `take` + +Take last item from signer's Collection of T. + + +
public fun take<T: store>(signer: &signer): T
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `create_collection` + + + +
public fun create_collection<T: store>(signer: &signer, anyone_can_put: bool, anyone_can_mut: bool)
+
+ + + +
+Implementation + + +
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})
+}
+
+ + + +
+ + + +## Function `length_of` + +Return the length of Collection from owner, if collection do not exist, return 0. + + +
public fun length_of<T: store>(owner: address): u64
+
+ + + +
+Implementation + + +
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
+    }
+}
+
+ + + +
+ + + +## Function `borrow_collection` + +Borrow collection of T from 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>
+
+ + + +
+Implementation + + +
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,
+    }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `return_collection` + +Return the Collection of T + + +
public fun return_collection<T: store>(c: Collection2::Collection<T>)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `destroy_collection` + + + +
public fun destroy_collection<T: store>(signer: &signer)
+
+ + + +
+Implementation + + +
public fun destroy_collection<T: store>(signer: &signer) acquires CollectionStore{
+    let c = move_from<CollectionStore<T>>(Signer::address_of(signer));
+    destroy_empty(c);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `destroy_empty` + + + +
fun destroy_empty<T: store>(c: Collection2::CollectionStore<T>)
+
+ + + +
+Implementation + + +
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);
+    }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = false;
+
diff --git a/build/StarcoinFramework/docs/Compare.md b/build/StarcoinFramework/docs/Compare.md new file mode 100644 index 00000000..998884cc --- /dev/null +++ b/build/StarcoinFramework/docs/Compare.md @@ -0,0 +1,340 @@ + + + +# Module `0x1::Compare` + + + +- [Constants](#@Constants_0) +- [Function `cmp_bcs_bytes`](#0x1_Compare_cmp_bcs_bytes) +- [Function `cmp_bytes`](#0x1_Compare_cmp_bytes) +- [Function `cmp_u64`](#0x1_Compare_cmp_u64) +- [Function `is_equal`](#0x1_Compare_is_equal) +- [Function `is_less_than`](#0x1_Compare_is_less_than) +- [Function `is_greater_than`](#0x1_Compare_is_greater_than) +- [Module Specification](#@Module_Specification_1) + + +
+ + + + + +## 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
+
+ + + +
+Implementation + + +
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 v1 = *Vector::borrow(v1, i1);
+        let v2 = *Vector::borrow(v2, i2);
+        let elem_cmp = if (v1 == v2) EQUAL
+            else if (v1 < v2) LESS_THAN
+            else GREATER_THAN;
+        if (elem_cmp != 0) return elem_cmp
+        // else, compare next element
+    };
+    // all compared elements equal; use length comparison to break the tie
+    len_cmp
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `cmp_bytes` + + + +
public fun cmp_bytes(v1: &vector<u8>, v2: &vector<u8>): u8
+
+ + + +
+Implementation + + +
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 i = 0;
+    while (i < l1 && i < l2) {
+        let v1 = *Vector::borrow(v1, i);
+        let v2 = *Vector::borrow(v2, i);
+        let elem_cmp = if (v1 == v2) EQUAL
+            else if (v1 < v2) LESS_THAN
+            else GREATER_THAN;
+        if (elem_cmp != 0) {
+            return elem_cmp
+        };
+        // else, compare next element
+        i = i + 1;
+    };
+    // all compared elements equal; use length comparison to break the tie
+    len_cmp
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `cmp_u64` + + + +
fun cmp_u64(i1: u64, i2: u64): u8
+
+ + + +
+Implementation + + +
fun cmp_u64(i1: u64, i2: u64): u8 {
+    if (i1 == i2) EQUAL
+    else if (i1 < i2) LESS_THAN
+    else GREATER_THAN
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `is_equal` + + + +
public fun is_equal(result: u8): bool
+
+ + + +
+Implementation + + +
public fun is_equal(result: u8): bool {
+    result == EQUAL
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `is_less_than` + + + +
public fun is_less_than(result: u8): bool
+
+ + + +
+Implementation + + +
public fun is_less_than(result: u8): bool {
+    result == LESS_THAN
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `is_greater_than` + + + +
public fun is_greater_than(result: u8): bool
+
+ + + +
+Implementation + + +
public fun is_greater_than(result: u8): bool {
+    result == GREATER_THAN
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/Config.md b/build/StarcoinFramework/docs/Config.md new file mode 100644 index 00000000..cdffd8bb --- /dev/null +++ b/build/StarcoinFramework/docs/Config.md @@ -0,0 +1,773 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+payload: ConfigValue +
+
+ +
+
+ + +
+ + + +## Struct `ModifyConfigCapability` + +Accounts with this privilege can modify config of type ConfigValue under account_address + + +
struct ModifyConfigCapability<ConfigValue: copy, drop, store> has store
+
+ + + +
+Fields + + +
+
+account_address: address +
+
+ +
+
+events: Event::EventHandle<Config::ConfigChangeEvent<ConfigValue>> +
+
+ +
+
+ + +
+ + + +## Resource `ModifyConfigCapabilityHolder` + +A holder for ModifyConfigCapability, for extraction and restoration of ModifyConfigCapability. + + +
struct ModifyConfigCapabilityHolder<ConfigValue: copy, drop, store> has store, key
+
+ + + +
+Fields + + +
+
+cap: Option::Option<Config::ModifyConfigCapability<ConfigValue>> +
+
+ +
+
+ + +
+ + + +## Struct `ConfigChangeEvent` + +Event emitted when config value is changed. + + +
struct ConfigChangeEvent<ConfigValue: copy, drop, store> has drop, store
+
+ + + +
+Fields + + +
+
+account_address: address +
+
+ +
+
+value: ConfigValue +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Config<ConfigValue>>(addr);
+ensures exists<Config<ConfigValue>>(addr);
+ensures result == spec_get<ConfigValue>(addr);
+
+ + + +
+ + + +## Function `config_exist_by_address` + +Check whether the config of ConfigValue type exists under addr. + + +
public fun config_exist_by_address<ConfigValue: copy, drop, store>(addr: address): bool
+
+ + + +
+Implementation + + +
public fun config_exist_by_address<ConfigValue: copy + drop + store>(addr: address): bool {
+    exists<Config<ConfigValue>>(addr)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == exists<Config<ConfigValue>>(addr);
+
+ + + +
+ + + +## Function `set` + +Set a config item to a new value with capability stored under signer + + +
public fun set<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
let addr = Signer::address_of(account);
+let cap_opt = spec_cap<ConfigValue>(addr);
+let cap = Option::borrow(spec_cap<ConfigValue>(Signer::address_of(account)));
+aborts_if !exists<ModifyConfigCapabilityHolder<ConfigValue>>(addr);
+aborts_if Option::is_none<ModifyConfigCapability<ConfigValue>>(cap_opt);
+ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(addr);
+pragma aborts_if_is_partial;
+ensures exists<Config<ConfigValue>>(
+    Option::borrow(spec_cap<ConfigValue>(Signer::address_of(account))).account_address,
+);
+ensures global<Config<ConfigValue>>(
+    Option::borrow(spec_cap<ConfigValue>(Signer::address_of(account))).account_address,
+).payload == payload;
+
+ + + + + + + +
fun spec_cap<ConfigValue>(addr: address): Option<ModifyConfigCapability<ConfigValue>> {
+   global<ModifyConfigCapabilityHolder<ConfigValue>>(addr).cap
+}
+
+ + + +
+ + + +## Function `set_with_capability` + +Set a config item to a new value with cap. + + +
public fun set_with_capability<ConfigValue: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<ConfigValue>, payload: ConfigValue)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Config<ConfigValue>>(cap.account_address);
+ensures exists<Config<ConfigValue>>(cap.account_address);
+ensures global<Config<ConfigValue>>(cap.account_address).payload == payload;
+
+ + + +
+ + + +## Function `publish_new_config_with_capability` + +Publish a new config item. The caller will use the returned ModifyConfigCapability to specify the access control +policy for who can modify the config. + + +
public fun publish_new_config_with_capability<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue): Config::ModifyConfigCapability<ConfigValue>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
include PublishNewConfigAbortsIf<ConfigValue>;
+ensures exists<Config<ConfigValue>>(Signer::address_of(account));
+ensures global<Config<ConfigValue>>(Signer::address_of(account)).payload == payload;
+ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
+ensures Option::is_none(global<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account)).cap);
+
+ + + +
+ + + +## Function `publish_new_config` + +Publish a new config item under account address. + + +
public fun publish_new_config<ConfigValue: copy, drop, store>(account: &signer, payload: ConfigValue)
+
+ + + +
+Implementation + + +
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)});
+}
+
+ + + +
+ +
+Specification + + + +
include PublishNewConfigAbortsIf<ConfigValue>;
+ensures exists<Config<ConfigValue>>(Signer::address_of(account));
+ensures global<Config<ConfigValue>>(Signer::address_of(account)).payload == payload;
+ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account));
+ensures Option::is_some(global<ModifyConfigCapabilityHolder<ConfigValue>>(Signer::address_of(account)).cap);
+
+ + + + + + + +
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));
+}
+
+ + + + + + + +
schema AbortsIfCapNotExist<ConfigValue> {
+    address: address;
+    aborts_if !exists<ModifyConfigCapabilityHolder<ConfigValue>>(address);
+    aborts_if Option::is_none<ModifyConfigCapability<ConfigValue>>(
+        global<ModifyConfigCapabilityHolder<ConfigValue>>(address).cap,
+    );
+}
+
+ + + +
+ + + +## Function `extract_modify_config_capability` + +Extract account's ModifyConfigCapability for ConfigValue type + + +
public fun extract_modify_config_capability<ConfigValue: copy, drop, store>(account: &signer): Config::ModifyConfigCapability<ConfigValue>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
let address = Signer::address_of(account);
+include AbortsIfCapNotExist<ConfigValue>;
+ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(address);
+ensures Option::is_none<ModifyConfigCapability<ConfigValue>>(
+    global<ModifyConfigCapabilityHolder<ConfigValue>>(address).cap
+);
+ensures result == old(Option::borrow(global<ModifyConfigCapabilityHolder<ConfigValue>>(address).cap));
+
+ + + +
+ + + +## Function `restore_modify_config_capability` + +Restore account's ModifyConfigCapability + + +
public fun restore_modify_config_capability<ConfigValue: copy, drop, store>(cap: Config::ModifyConfigCapability<ConfigValue>)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address);
+aborts_if Option::is_some(global<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address).cap);
+ensures exists<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address);
+ensures Option::is_some(global<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address).cap);
+ensures Option::borrow(global<ModifyConfigCapabilityHolder<ConfigValue>>(cap.account_address).cap) == cap;
+
+ + + +
+ + + +## Function `destroy_modify_config_capability` + +Destroy the given ModifyConfigCapability + + +
public fun destroy_modify_config_capability<ConfigValue: copy, drop, store>(cap: Config::ModifyConfigCapability<ConfigValue>)
+
+ + + +
+Implementation + + +
public fun destroy_modify_config_capability<ConfigValue: copy + drop + store>(
+    cap: ModifyConfigCapability<ConfigValue>,
+) {
+    let ModifyConfigCapability{account_address:_, events} = cap;
+    Event::destroy_handle(events)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `account_address` + +Return the address of the given ModifyConfigCapability + + +
public fun account_address<ConfigValue: copy, drop, store>(cap: &Config::ModifyConfigCapability<ConfigValue>): address
+
+ + + +
+Implementation + + +
public fun account_address<ConfigValue: copy + drop + store>(cap: &ModifyConfigCapability<ConfigValue>): address {
+    cap.account_address
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == cap.account_address;
+
+ + + +
+ + + +## Function `emit_config_change_event` + +Emit a config change event. + + +
fun emit_config_change_event<ConfigValue: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<ConfigValue>, value: ConfigValue)
+
+ + + +
+Implementation + + +
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,
+        },
+    );
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
+ + + + + + + +
fun spec_get<ConfigValue>(addr: address): ConfigValue {
+   global<Config<ConfigValue>>(addr).payload
+}
+
diff --git a/build/StarcoinFramework/docs/ConsensusConfig.md b/build/StarcoinFramework/docs/ConsensusConfig.md new file mode 100644 index 00000000..fc33060d --- /dev/null +++ b/build/StarcoinFramework/docs/ConsensusConfig.md @@ -0,0 +1,700 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+uncle_rate_target: u64 +
+
+ Uncle block rate per epoch +
+
+base_block_time_target: u64 +
+
+ Average target time to calculate a block's difficulty +
+
+base_reward_per_block: u128 +
+
+ Rewards per block +
+
+base_reward_per_uncle_percent: u64 +
+
+ Percentage of base_reward_per_block to reward a uncle block +
+
+epoch_block_count: u64 +
+
+ Blocks each epoch +
+
+base_block_difficulty_window: u64 +
+
+ How many ancestor blocks which use to calculate next block's difficulty +
+
+min_block_time_target: u64 +
+
+ Minimum target time to calculate a block's difficulty +
+
+max_block_time_target: u64 +
+
+ Maximum target time to calculate a block's difficulty +
+
+base_max_uncles_per_block: u64 +
+
+ Maximum number of uncle block per block +
+
+base_block_gas_limit: u64 +
+
+ Maximum gases per block +
+
+strategy: u8 +
+
+ Strategy to calculate difficulty +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
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,
+        ),
+    );
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !Timestamp::is_genesis();
+aborts_if Signer::address_of(account) != CoreAddresses::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` + +Create a new consensus config mainly used in DAO. + + +
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
+
+ + + +
+Implementation + + +
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,
+    }
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Get config data. + + +
public fun get_config(): ConsensusConfig::ConsensusConfig
+
+ + + +
+Implementation + + +
public fun get_config(): ConsensusConfig {
+    Config::get_by_address<ConsensusConfig>(CoreAddresses::GENESIS_ADDRESS())
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Config::Config<ConsensusConfig>>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + + + + + +
fun spec_get_config(): ConsensusConfig {
+   global<Config::Config<ConsensusConfig>>(CoreAddresses::GENESIS_ADDRESS()).payload
+}
+
+ + + +
+ + + +## Function `uncle_rate_target` + +Get uncle_rate_target + + +
public fun uncle_rate_target(config: &ConsensusConfig::ConsensusConfig): u64
+
+ + + +
+Implementation + + +
public fun uncle_rate_target(config: &ConsensusConfig): u64 {
+    config.uncle_rate_target
+}
+
+ + + +
+ + + +## Function `base_block_time_target` + +Get base_block_time_target + + +
public fun base_block_time_target(config: &ConsensusConfig::ConsensusConfig): u64
+
+ + + +
+Implementation + + +
public fun base_block_time_target(config: &ConsensusConfig): u64 {
+    config.base_block_time_target
+}
+
+ + + +
+ + + +## Function `base_reward_per_block` + +Get base_reward_per_block + + +
public fun base_reward_per_block(config: &ConsensusConfig::ConsensusConfig): u128
+
+ + + +
+Implementation + + +
public fun base_reward_per_block(config: &ConsensusConfig): u128 {
+    config.base_reward_per_block
+}
+
+ + + +
+ + + +## Function `epoch_block_count` + +Get epoch_block_count + + +
public fun epoch_block_count(config: &ConsensusConfig::ConsensusConfig): u64
+
+ + + +
+Implementation + + +
public fun epoch_block_count(config: &ConsensusConfig): u64 {
+    config.epoch_block_count
+}
+
+ + + +
+ + + +## Function `base_block_difficulty_window` + +Get base_block_difficulty_window + + +
public fun base_block_difficulty_window(config: &ConsensusConfig::ConsensusConfig): u64
+
+ + + +
+Implementation + + +
public fun base_block_difficulty_window(config: &ConsensusConfig): u64 {
+    config.base_block_difficulty_window
+}
+
+ + + +
+ + + +## Function `base_reward_per_uncle_percent` + +Get base_reward_per_uncle_percent + + +
public fun base_reward_per_uncle_percent(config: &ConsensusConfig::ConsensusConfig): u64
+
+ + + +
+Implementation + + +
public fun base_reward_per_uncle_percent(config: &ConsensusConfig): u64 {
+    config.base_reward_per_uncle_percent
+}
+
+ + + +
+ + + +## Function `min_block_time_target` + +Get min_block_time_target + + +
public fun min_block_time_target(config: &ConsensusConfig::ConsensusConfig): u64
+
+ + + +
+Implementation + + +
public fun min_block_time_target(config: &ConsensusConfig): u64 {
+    config.min_block_time_target
+}
+
+ + + +
+ + + +## Function `max_block_time_target` + +Get max_block_time_target + + +
public fun max_block_time_target(config: &ConsensusConfig::ConsensusConfig): u64
+
+ + + +
+Implementation + + +
public fun max_block_time_target(config: &ConsensusConfig): u64 {
+    config.max_block_time_target
+}
+
+ + + +
+ + + +## Function `base_max_uncles_per_block` + +Get base_max_uncles_per_block + + +
public fun base_max_uncles_per_block(config: &ConsensusConfig::ConsensusConfig): u64
+
+ + + +
+Implementation + + +
public fun base_max_uncles_per_block(config: &ConsensusConfig): u64 {
+    config.base_max_uncles_per_block
+}
+
+ + + +
+ + + +## Function `base_block_gas_limit` + +Get base_block_gas_limit + + +
public fun base_block_gas_limit(config: &ConsensusConfig::ConsensusConfig): u64
+
+ + + +
+Implementation + + +
public fun base_block_gas_limit(config: &ConsensusConfig): u64 {
+    config.base_block_gas_limit
+}
+
+ + + +
+ + + +## Function `strategy` + +Get strategy + + +
public fun strategy(config: &ConsensusConfig::ConsensusConfig): u8
+
+ + + +
+Implementation + + +
public fun strategy(config: &ConsensusConfig): u8 {
+    config.strategy
+}
+
+ + + +
+ + + +## Function `compute_reward_per_block` + +Compute block reward given the new_epoch_block_time_target. + + +
public fun compute_reward_per_block(new_epoch_block_time_target: u64): u128
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Config::Config<ConsensusConfig>>(CoreAddresses::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` + +Compute block reward given the 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
+
+ + + +
+Implementation + + +
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))
+}
+
+ + + +
+ +
+Specification + + + +
include Math::MulDivAbortsIf{x: config.base_reward_per_block, y: new_epoch_block_time_target, z: config.base_block_time_target};
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/ConsensusStrategy.md b/build/StarcoinFramework/docs/ConsensusStrategy.md new file mode 100644 index 00000000..f8f72b50 --- /dev/null +++ b/build/StarcoinFramework/docs/ConsensusStrategy.md @@ -0,0 +1,143 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_0) + + +
use 0x1::Config;
+use 0x1::CoreAddresses;
+use 0x1::Timestamp;
+
+ + + + + +## Struct `ConsensusStrategy` + +ConsensusStrategy data. + + +
struct ConsensusStrategy has copy, drop, store
+
+ + + +
+Fields + + +
+
+value: u8 +
+
+ Value of strategy +
+
+ + +
+ + + +## Function `initialize` + +Publish the chain ID under the genesis account + + +
public fun initialize(account: &signer, consensus_strategy: u8)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !Timestamp::is_genesis();
+aborts_if Signer::address_of(account) != CoreAddresses::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` + +Return the consensus strategy type of this chain + + +
public fun get(): u8
+
+ + + +
+Implementation + + +
public fun get(): u8 {
+    Config::get_by_address<ConsensusStrategy>(CoreAddresses::GENESIS_ADDRESS()).value
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Config::Config<ConsensusStrategy>>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/CoreAddresses.md b/build/StarcoinFramework/docs/CoreAddresses.md new file mode 100644 index 00000000..70f433be --- /dev/null +++ b/build/StarcoinFramework/docs/CoreAddresses.md @@ -0,0 +1,178 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Implementation + + +
public fun GENESIS_ADDRESS(): address {
+    @0x1
+}
+
+ + + +
+ + + +## Function `assert_genesis_address` + +Assert signer is genesis. + + +
public fun assert_genesis_address(account: &signer)
+
+ + + +
+Implementation + + +
public fun assert_genesis_address(account: &signer) {
+    assert!(Signer::address_of(account) == GENESIS_ADDRESS(),
+            Errors::requires_address(ENOT_GENESIS_ACCOUNT))
+}
+
+ + + +
+ +
+Specification + + + +
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) != GENESIS_ADDRESS();
+}
+
+ + + +
+ + + +## Function `ASSOCIATION_ROOT_ADDRESS` + +The address of the root association account. This account is +created in genesis, and cannot be changed. This address has +ultimate authority over the permissions granted (or removed) from +accounts on-chain. + + +
public fun ASSOCIATION_ROOT_ADDRESS(): address
+
+ + + +
+Implementation + + +
public fun ASSOCIATION_ROOT_ADDRESS(): address {
+    @0xA550C18
+}
+
+ + + +
+ + + +## Function `VM_RESERVED_ADDRESS` + +The reserved address for transactions inserted by the VM into blocks (e.g. +block metadata transactions). Because the transaction is sent from +the VM, an account _cannot_ exist at the 0x0 address since there +is no signer for the transaction. + + +
public fun VM_RESERVED_ADDRESS(): address
+
+ + + +
+Implementation + + +
public fun VM_RESERVED_ADDRESS(): address {
+    @0x0
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/Dao.md b/build/StarcoinFramework/docs/Dao.md new file mode 100644 index 00000000..db025649 --- /dev/null +++ b/build/StarcoinFramework/docs/Dao.md @@ -0,0 +1,2330 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+next_proposal_id: u64 +
+
+ next proposal id. +
+
+proposal_create_event: Event::EventHandle<Dao::ProposalCreatedEvent> +
+
+ proposal creating event. +
+
+vote_changed_event: Event::EventHandle<Dao::VoteChangedEvent> +
+
+ voting event. +
+
+ + +
+ + + +## Struct `DaoConfig` + +Configuration of the Token's DAO. + + +
struct DaoConfig<TokenT: copy, drop, store> has copy, drop, store
+
+ + + +
+Fields + + +
+
+voting_delay: u64 +
+
+ after proposal created, how long use should wait before he can vote (in milliseconds) +
+
+voting_period: u64 +
+
+ how long the voting window is (in milliseconds). +
+
+voting_quorum_rate: u8 +
+
+ the quorum rate to agree on the proposal. + if 50% votes needed, then the voting_quorum_rate should be 50. + it should between (0, 100]. +
+
+min_action_delay: u64 +
+
+ how long the proposal should wait before it can be executed (in milliseconds). +
+
+ + +
+ +
+Specification + + + +
invariant voting_quorum_rate > 0 && voting_quorum_rate <= 100;
+invariant voting_delay > 0;
+invariant voting_period > 0;
+invariant min_action_delay > 0;
+
+ + + +
+ + + +## Struct `ProposalCreatedEvent` + +emitted when proposal created. + + +
struct ProposalCreatedEvent has drop, store
+
+ + + +
+Fields + + +
+
+proposal_id: u64 +
+
+ the proposal id. +
+
+proposer: address +
+
+ proposer is the user who create the proposal. +
+
+ + +
+ + + +## Struct `VoteChangedEvent` + +emitted when user vote/revoke_vote. + + +
struct VoteChangedEvent has drop, store
+
+ + + +
+Fields + + +
+
+proposal_id: u64 +
+
+ the proposal id. +
+
+voter: address +
+
+ the voter. +
+
+proposer: address +
+
+ creator of the proposal. +
+
+agree: bool +
+
+ agree with the proposal or not +
+
+vote: u128 +
+
+ latest vote count of the voter. +
+
+ + +
+ + + +## Resource `Proposal` + +Proposal data struct. + + +
struct Proposal<Token: store, Action: store> has key
+
+ + + +
+Fields + + +
+
+id: u64 +
+
+ id of the proposal +
+
+proposer: address +
+
+ creator of the proposal +
+
+start_time: u64 +
+
+ when voting begins. +
+
+end_time: u64 +
+
+ when voting ends. +
+
+for_votes: u128 +
+
+ count of voters who agree with the proposal +
+
+against_votes: u128 +
+
+ count of voters who're against the proposal +
+
+eta: u64 +
+
+ executable after this time. +
+
+action_delay: u64 +
+
+ after how long, the agreed proposal can be executed. +
+
+quorum_votes: u128 +
+
+ how many votes to reach to make the proposal pass. +
+
+action: Option::Option<Action> +
+
+ proposal action. +
+
+ + +
+ + + +## Resource `Vote` + +User vote info. + + +
struct Vote<TokenT: store> has key
+
+ + + +
+Fields + + +
+
+proposer: address +
+
+ vote for the proposal under the proposer. +
+
+id: u64 +
+
+ proposal id. +
+
+stake: Token::Token<TokenT> +
+
+ how many tokens to stake. +
+
+agree: bool +
+
+ vote for or vote against. +
+
+ + +
+ + + +## Constants + + + + + + +
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 have 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)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
let sender = Signer::address_of(signer);
+aborts_if sender != Token::SPEC_TOKEN_TEST_ADDRESS();
+include NewDaoConfigParamSchema<TokenT>;
+include Config::PublishNewConfigAbortsIf<DaoConfig<TokenT>>{account: signer};
+aborts_if exists<DaoGlobalInfo<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::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` + +create a 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>
+
+ + + +
+Implementation + + +
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 }
+}
+
+ + + +
+ +
+Specification + + + +
include NewDaoConfigParamSchema<TokenT>;
+
+ + + + + + + +
schema NewDaoConfigParamSchema<TokenT> {
+    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;
+}
+
+ + + +
+ + + +## Function `propose` + +propose a proposal. +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)
+
+ + + +
+Implementation + + +
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,
+        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 },
+    );
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+let proposer = Signer::address_of(signer);
+include GenerateNextProposalIdSchema<TokenT>;
+pragma addition_overflow_unchecked = true;
+include AbortIfDaoConfigNotExist<TokenT>;
+include AbortIfDaoInfoNotExist<TokenT>;
+aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::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` + +votes for a proposal. +User can only vote once, then the stake is locked, +which can only be unstaked by user after the proposal is expired, or cancelled, or executed. +So think twice before casting 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)
+
+ + + +
+Implementation + + +
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,
+        },
+    );
+}
+
+ + + +
+ +
+Specification + + + +
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>)
+
+ + + +
+Implementation + + +
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;
+    };
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Let user change their vote during the voting time. + + +
public fun change_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64, agree: bool)
+
+ + + +
+Implementation + + +
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,
+            },
+        );
+    };
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+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
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
include CheckFlipVote<TokenT, ActionT>;
+ensures my_vote.agree == !old(my_vote).agree;
+
+ + + +
+ + + +## Function `revoke_vote` + +Revoke some voting powers from vote on 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>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+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>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Retrieve back my staked token voted for a proposal. + + +
public fun unstake_votes<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64): Token::Token<TokenT>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+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` + +queue agreed proposal to execute. + + +
public entry fun queue_proposal_action<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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;
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+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` + +extract proposal action to execute. + + +
public fun extract_proposal_action<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64): ActionT
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
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` + +remove terminated proposal from proposer + + +
public entry fun destroy_terminated_proposal<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
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` + +check whether a proposal exists in 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
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Get the proposal state. + + +
public fun proposal_state<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address, proposal_id: u64): u8
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
include AbortIfTimestampNotExist;
+aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::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 `do_proposal_state` + + + +
fun do_proposal_state<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposal: &Dao::Proposal<TokenT, ActionT>, current_time: u64): u8
+
+ + + +
+Implementation + + +
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
+    }
+}
+
+ + + +
+ + + +## Function `proposal_info` + +get proposal's information. +return: (id, start_time, end_time, for_votes, against_votes). + + +
public fun proposal_info<TokenT: copy, drop, store, ActionT: copy, drop, store>(proposer_address: address): (u64, u64, u64, u128, u128)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Proposal<TokenT, ActionT>>(proposer_address);
+
+ + + +
+ + + +## Function `vote_of` + +Get voter's vote info on proposal with proposal_id of proposer_address. + + +
public fun vote_of<TokenT: copy, drop, store>(voter: address, proposer_address: address, proposal_id: u64): (bool, u128)
+
+ + + +
+Implementation + + +
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))
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Vote<TokenT>>(voter);
+let vote = global<Vote<TokenT>>(voter);
+include CheckVoteOnProposal<TokenT>{vote, proposer_address, proposal_id};
+
+ + + +
+ + + +## Function `has_vote` + +Check whether voter has voted on proposal with proposal_id of proposer_address. + + +
public fun has_vote<TokenT: copy, drop, store>(voter: address, proposer_address: address, proposal_id: u64): bool
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `generate_next_proposal_id` + + + +
fun generate_next_proposal_id<TokenT: store>(): u64
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
include GenerateNextProposalIdSchema<TokenT>;
+ensures result == old(global<DaoGlobalInfo<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS()).next_proposal_id);
+
+ + + + + + + +
schema GenerateNextProposalIdSchema<TokenT> {
+    aborts_if global<DaoGlobalInfo<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS()).next_proposal_id >= MAX_U64;
+    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;
+}
+
+ + + +
+ + + +## Function `voting_delay` + +get default voting delay of the DAO. + + +
public fun voting_delay<TokenT: copy, drop, store>(): u64
+
+ + + +
+Implementation + + +
public fun voting_delay<TokenT: copy + drop + store>(): u64 {
+    get_config<TokenT>().voting_delay
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `voting_period` + +get the default voting period of the DAO. + + +
public fun voting_period<TokenT: copy, drop, store>(): u64
+
+ + + +
+Implementation + + +
public fun voting_period<TokenT: copy + drop + store>(): u64 {
+    get_config<TokenT>().voting_period
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `quorum_votes` + +Quorum votes to make proposal pass. + + +
public fun quorum_votes<TokenT: copy, drop, store>(): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+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` + +Get the quorum rate in percent. + + +
public fun voting_quorum_rate<TokenT: copy, drop, store>(): u8
+
+ + + +
+Implementation + + +
public fun voting_quorum_rate<TokenT: copy + drop + store>(): u8 {
+    get_config<TokenT>().voting_quorum_rate
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == global<Config::Config<DaoConfig<TokenT>>>((Token::SPEC_TOKEN_TEST_ADDRESS())).payload.voting_quorum_rate;
+
+ + + +
+ + + +## Function `min_action_delay` + +Get the min_action_delay of the DAO. + + +
public fun min_action_delay<TokenT: copy, drop, store>(): u64
+
+ + + +
+Implementation + + +
public fun min_action_delay<TokenT: copy + drop + store>(): u64 {
+    get_config<TokenT>().min_action_delay
+}
+
+ + + +
+ +
+Specification + + + +
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>
+
+ + + +
+Implementation + + +
fun get_config<TokenT: copy + drop + store>(): DaoConfig<TokenT> {
+    let token_issuer = Token::token_address<TokenT>();
+    Config::get_by_address<DaoConfig<TokenT>>(token_issuer)
+}
+
+ + + +
+ +
+Specification + + + +
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` + +update function, modify dao config. +if any param is 0, it means no change to that param. + + +
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)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
include CheckModifyConfigWithCap<TokenT>;
+aborts_if voting_quorum_rate > 0 && voting_quorum_rate > 100;
+
+ + + +
+ + + +## Function `set_voting_delay` + +set voting delay + + +
public fun set_voting_delay<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
include CheckModifyConfigWithCap<TokenT>;
+aborts_if value == 0;
+
+ + + +
+ + + +## Function `set_voting_period` + +set voting period + + +
public fun set_voting_period<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
include CheckModifyConfigWithCap<TokenT>;
+aborts_if value == 0;
+
+ + + +
+ + + +## Function `set_voting_quorum_rate` + +set voting quorum rate + + +
public fun set_voting_quorum_rate<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u8)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !(value > 0 && value <= 100);
+include CheckModifyConfigWithCap<TokenT>;
+
+ + + +
+ + + +## Function `set_min_action_delay` + +set min action delay + + +
public fun set_min_action_delay<TokenT: copy, drop, store>(cap: &mut Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>>, value: u64)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if value == 0;
+include CheckModifyConfigWithCap<TokenT>;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/DaoVoteScripts.md b/build/StarcoinFramework/docs/DaoVoteScripts.md new file mode 100644 index 00000000..7bd67431 --- /dev/null +++ b/build/StarcoinFramework/docs/DaoVoteScripts.md @@ -0,0 +1,197 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_0) + + +
use 0x1::Account;
+use 0x1::Dao;
+use 0x1::Signer;
+use 0x1::Token;
+
+ + + + + +## Function `cast_vote` + + + +
public entry fun cast_vote<Token: copy, drop, store, ActionT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64, agree: bool, votes: u128)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ + + +## Function `revoke_vote` + +revoke all votes on a proposal + + +
public entry fun revoke_vote<Token: copy, drop, store, Action: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ + + +## Function `flip_vote` + +Let user change their vote during the voting time. + + +
public entry fun flip_vote<TokenT: copy, drop, store, ActionT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ + + +## Function `revoke_vote_of_power` + +revoke some votes on a proposal + + +
public entry fun revoke_vote_of_power<Token: copy, drop, store, Action: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64, power: u128)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ + + +## Function `unstake_vote` + + + +
public entry fun unstake_vote<Token: copy, drop, store, Action: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_partial = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/Debug.md b/build/StarcoinFramework/docs/Debug.md new file mode 100644 index 00000000..9d714ba9 --- /dev/null +++ b/build/StarcoinFramework/docs/Debug.md @@ -0,0 +1,72 @@ + + + +# Module `0x1::Debug` + +The module provide debug print for Move. + + +- [Function `print`](#0x1_Debug_print) +- [Function `print_stack_trace`](#0x1_Debug_print_stack_trace) +- [Module Specification](#@Module_Specification_0) + + +
+ + + + + +## Function `print` + +Print data of Type T. + + +
public fun print<T: store>(x: &T)
+
+ + + +
+Implementation + + +
native public fun print<T: store>(x: &T);
+
+ + + +
+ + + +## Function `print_stack_trace` + +Print current stack. + + +
public fun print_stack_trace()
+
+ + + +
+Implementation + + +
native public fun print_stack_trace();
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/DummyToken.md b/build/StarcoinFramework/docs/DummyToken.md new file mode 100644 index 00000000..ebf1331d --- /dev/null +++ b/build/StarcoinFramework/docs/DummyToken.md @@ -0,0 +1,46 @@ + + + +# Module `0x1::DummyTokenScripts` + + + +- [Function `mint`](#0x1_DummyTokenScripts_mint) + + +
use 0x1::Account;
+use 0x1::DummyToken;
+use 0x1::Signer;
+use 0x1::Token;
+
+ + + + + +## Function `mint` + + + +
public entry fun mint(sender: signer, amount: u128)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
diff --git a/build/StarcoinFramework/docs/EasyGas.md b/build/StarcoinFramework/docs/EasyGas.md new file mode 100644 index 00000000..fc860c05 --- /dev/null +++ b/build/StarcoinFramework/docs/EasyGas.md @@ -0,0 +1,88 @@ + + + +# Module `0x1::EasyGasOracleScript` + + + +- [Function `register`](#0x1_EasyGasOracleScript_register) +- [Function `init_data_source`](#0x1_EasyGasOracleScript_init_data_source) +- [Function `update`](#0x1_EasyGasOracleScript_update) + + +
use 0x1::EasyGasOracle;
+
+ + + + + +## Function `register` + + + +
public entry fun register<TokenType: store>(sender: signer, precision: u8)
+
+ + + +
+Implementation + + +
public entry fun register<TokenType: store>(sender: signer, precision: u8) {
+    EasyGasOracle::register<TokenType>(&sender, precision)
+}
+
+ + + +
+ + + +## Function `init_data_source` + + + +
public entry fun init_data_source<TokenType: store>(sender: signer, init_value: u128)
+
+ + + +
+Implementation + + +
public entry fun init_data_source<TokenType: store>(sender: signer, init_value: u128) {
+    EasyGasOracle::init_data_source<TokenType>(&sender,init_value);
+}
+
+ + + +
+ + + +## Function `update` + + + +
public entry fun update<TokenType: store>(sender: signer, value: u128)
+
+ + + +
+Implementation + + +
public entry fun update<TokenType: store>(sender: signer, value: u128) {
+    EasyGasOracle::update<TokenType>(&sender,value)
+}
+
+ + + +
diff --git a/build/StarcoinFramework/docs/EmptyScripts.md b/build/StarcoinFramework/docs/EmptyScripts.md new file mode 100644 index 00000000..08c13a3c --- /dev/null +++ b/build/StarcoinFramework/docs/EmptyScripts.md @@ -0,0 +1,48 @@ + + + +# Module `0x1::EmptyScripts` + + + +- [Function `empty_script`](#0x1_EmptyScripts_empty_script) +- [Module Specification](#@Module_Specification_0) + + +
+ + + + + +## Function `empty_script` + + + +
public entry fun empty_script()
+
+ + + +
+Implementation + + +
public entry fun empty_script() {
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_partial = false;
+pragma aborts_if_is_strict = false;
+
diff --git a/build/StarcoinFramework/docs/Epoch.md b/build/StarcoinFramework/docs/Epoch.md new file mode 100644 index 00000000..17ac2e3c --- /dev/null +++ b/build/StarcoinFramework/docs/Epoch.md @@ -0,0 +1,1041 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+number: u64 +
+
+ Number of current epoch +
+
+start_time: u64 +
+
+ Start time of current epoch +
+
+start_block_number: u64 +
+
+ Start block's number of current epoch +
+
+end_block_number: u64 +
+
+ End block's number of current epoch +
+
+block_time_target: u64 +
+
+ Average target time to calculate a block's difficulty in current epoch +
+
+reward_per_block: u128 +
+
+ Rewards per block in current epoch +
+
+reward_per_uncle_percent: u64 +
+
+ Percentage of reward_per_block to reward a uncle block in current epoch +
+
+block_difficulty_window: u64 +
+
+ How many ancestor blocks which use to calculate next block's difficulty in current epoch +
+
+max_uncles_per_block: u64 +
+
+ Maximum number of uncle block per block in current epoch +
+
+block_gas_limit: u64 +
+
+ Maximum gases per block in current epoch +
+
+strategy: u8 +
+
+ Strategy to calculate difficulty in current epoch +
+
+new_epoch_events: Event::EventHandle<Epoch::NewEpochEvent> +
+
+ Switch Epoch Event +
+
+ + +
+ + + +## Struct `NewEpochEvent` + +New epoch event. + + +
struct NewEpochEvent has drop, store
+
+ + + +
+Fields + + +
+
+number: u64 +
+
+ Epoch::number +
+
+start_time: u64 +
+
+ Epoch::start_time +
+
+start_block_number: u64 +
+
+ Epoch::start_block_number +
+
+end_block_number: u64 +
+
+ Epoch::end_block_number +
+
+block_time_target: u64 +
+
+ Epoch::block_time_target +
+
+reward_per_block: u128 +
+
+ Epoch::reward_per_block +
+
+previous_epoch_total_reward: u128 +
+
+ Total rewards during previous epoch +
+
+ + +
+ + + +## Resource `EpochData` + +Epoch data. + + +
struct EpochData has key
+
+ + + +
+Fields + + +
+
+uncles: u64 +
+
+ Up to now, Number of uncle block during current epoch +
+
+total_reward: u128 +
+
+ Up to now, Total rewards during current epoch +
+
+total_gas: u128 +
+
+ Up to now, Total gases during current epoch +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
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 });
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !Timestamp::is_genesis();
+aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
+aborts_if !exists<Config::Config<ConsensusConfig>>(CoreAddresses::GENESIS_ADDRESS());
+aborts_if exists<Epoch>(Signer::address_of(account));
+aborts_if exists<EpochData>(Signer::address_of(account));
+
+ + + +
+ + + +## Function `compute_next_block_time_target` + +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
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `adjust_epoch` + +adjust_epoch try to advance to next epoch if current epoch ends. + + +
public fun adjust_epoch(account: &signer, block_number: u64, timestamp: u64, uncles: u64, parent_gas_used: u64): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+aborts_if Signer::address_of(account) != CoreAddresses::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)
+
+ + + +
+Implementation + + +
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);
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `compute_gas_limit` + +Compute block's gas limit of next epoch. + + +
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>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
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
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
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)
+
+ + + +
+Implementation + + +
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);
+    }
+}
+
+ + + +
+ +
+Specification + + + +
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)
+
+ + + +
+Implementation + + +
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,
+        },
+    );
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `start_time` + +Get start time of current epoch + + +
public fun start_time(): u64
+
+ + + +
+Implementation + + +
public fun start_time(): u64 acquires Epoch {
+    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+    epoch_ref.start_time
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `uncles` + +Get uncles number of current epoch + + +
public fun uncles(): u64
+
+ + + +
+Implementation + + +
public fun uncles(): u64 acquires EpochData {
+    let epoch_data = borrow_global<EpochData>(CoreAddresses::GENESIS_ADDRESS());
+    epoch_data.uncles
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<EpochData>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `total_gas` + +Get total gas of current epoch + + +
public fun total_gas(): u128
+
+ + + +
+Implementation + + +
public fun total_gas(): u128 acquires EpochData {
+    let epoch_data = borrow_global<EpochData>(CoreAddresses::GENESIS_ADDRESS());
+    epoch_data.total_gas
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<EpochData>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `block_gas_limit` + +Get block's gas_limit of current epoch + + +
public fun block_gas_limit(): u64
+
+ + + +
+Implementation + + +
public fun block_gas_limit(): u64 acquires Epoch {
+    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+    epoch_ref.block_gas_limit
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `start_block_number` + +Get start block's number of current epoch + + +
public fun start_block_number(): u64
+
+ + + +
+Implementation + + +
public fun start_block_number(): u64 acquires Epoch {
+    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+    epoch_ref.start_block_number
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `end_block_number` + +Get end block's number of current epoch + + +
public fun end_block_number(): u64
+
+ + + +
+Implementation + + +
public fun end_block_number(): u64 acquires Epoch {
+    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+    epoch_ref.end_block_number
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `number` + +Get current epoch number + + +
public fun number(): u64
+
+ + + +
+Implementation + + +
public fun number(): u64 acquires Epoch {
+    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+    epoch_ref.number
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `block_time_target` + +Get current block time target + + +
public fun block_time_target(): u64
+
+ + + +
+Implementation + + +
public fun block_time_target(): u64 acquires Epoch {
+    let epoch_ref = borrow_global<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+    epoch_ref.block_time_target
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Epoch>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/Errors.md b/build/StarcoinFramework/docs/Errors.md new file mode 100644 index 00000000..75b214eb --- /dev/null +++ b/build/StarcoinFramework/docs/Errors.md @@ -0,0 +1,623 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
+ + + + + +## 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
+
+ + + +
+Implementation + + +
fun make(category: u8, reason: u64): u64 {
+    (category as u64) + (reason << 8)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+pragma verify = false;
+aborts_if [abstract] false;
+ensures [abstract] result == category;
+
+ + + +
+ + + +## Function `invalid_state` + +Create an error of invalid_state + + +
public fun invalid_state(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun invalid_state(reason: u64): u64 { make(INVALID_STATE, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == INVALID_STATE;
+
+ + + +
+ + + +## Function `requires_address` + +Create an error of requires_address. + + +
public fun requires_address(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun requires_address(reason: u64): u64 { make(REQUIRES_ADDRESS, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == REQUIRES_ADDRESS;
+
+ + + +
+ + + +## Function `requires_role` + +Create an error of requires_role. + + +
public fun requires_role(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun requires_role(reason: u64): u64 { make(REQUIRES_ROLE, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == REQUIRES_ROLE;
+
+ + + +
+ + + +## Function `requires_capability` + +Create an error of requires_capability. + + +
public fun requires_capability(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun requires_capability(reason: u64): u64 { make(REQUIRES_CAPABILITY, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == REQUIRES_CAPABILITY;
+
+ + + +
+ + + +## Function `not_published` + +Create an error of not_published. + + +
public fun not_published(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun not_published(reason: u64): u64 { make(NOT_PUBLISHED, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == NOT_PUBLISHED;
+
+ + + +
+ + + +## Function `already_published` + +Create an error of already_published. + + +
public fun already_published(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun already_published(reason: u64): u64 { make(ALREADY_PUBLISHED, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == ALREADY_PUBLISHED;
+
+ + + +
+ + + +## Function `invalid_argument` + +Create an error of invalid_argument. + + +
public fun invalid_argument(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun invalid_argument(reason: u64): u64 { make(INVALID_ARGUMENT, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == INVALID_ARGUMENT;
+
+ + + +
+ + + +## Function `limit_exceeded` + +Create an error of limit_exceeded. + + +
public fun limit_exceeded(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun limit_exceeded(reason: u64): u64 { make(LIMIT_EXCEEDED, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == LIMIT_EXCEEDED;
+
+ + + +
+ + + +## Function `internal` + +Create an error of internal. + + +
public fun internal(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun internal(reason: u64): u64 { make(INTERNAL, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == INTERNAL;
+
+ + + +
+ + + +## Function `deprecated` + +Create an error of deprecated. + + +
public fun deprecated(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun deprecated(reason: u64): u64 { make(DEPRECATED, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == DEPRECATED;
+
+ + + +
+ + + +## Function `custom` + +Create an error of custom. + + +
public fun custom(reason: u64): u64
+
+ + + +
+Implementation + + +
public fun custom(reason: u64): u64 { make(CUSTOM, reason) }
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == CUSTOM;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/Event.md b/build/StarcoinFramework/docs/Event.md new file mode 100644 index 00000000..aed6dda1 --- /dev/null +++ b/build/StarcoinFramework/docs/Event.md @@ -0,0 +1,300 @@ + + + +# Module `0x1::Event` + +The Event module defines an EventHandleGenerator that is used to create +EventHandles with unique GUIDs. It contains a counter for the number +of EventHandles 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) +- [Module Specification](#@Module_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
+
+ + + +
+Fields + + +
+
+counter: u64 +
+
+ +
+
+addr: address +
+
+ +
+
+ + +
+ + + +## Struct `EventHandle` + +A handle for an event such that: +1. Other modules can emit events to this handle. +2. Storage can use this handle to prove the total number of events that happened in the past. + + +
struct EventHandle<T: drop, store> has store
+
+ + + +
+Fields + + +
+
+counter: u64 +
+
+ Total number of events emitted to this event stream. +
+
+guid: vector<u8> +
+
+ A globally unique ID for this event stream. +
+
+ + +
+ + + +## Constants + + + + +The event generator resource was in an invalid state + + +
const EEVENT_GENERATOR: u64 = 0;
+
+ + + + + +## Function `publish_generator` + +Publishs a new event handle generator. + + +
public fun publish_generator(account: &signer)
+
+ + + +
+Implementation + + +
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 })
+}
+
+ + + +
+ + + +## Function `fresh_guid` + +Derive a fresh unique id by using sender's EventHandleGenerator. The generated vector is indeed unique because it +was derived from the hash(sender's EventHandleGenerator || sender_address). This module guarantees that the +EventHandleGenerator is only going to be monotonically increased and there's no way to revert it or destroy it. Thus +such counter is going to give distinct value for each of the new event stream under each sender. And since we +hash it with the sender's address, the result is guaranteed to be globally unique. + + +
fun fresh_guid(counter: &mut Event::EventHandleGenerator): vector<u8>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `new_event_handle` + +Use EventHandleGenerator to generate a unique event handle for sig + + +
public fun new_event_handle<T: drop, store>(account: &signer): Event::EventHandle<T>
+
+ + + +
+Implementation + + +
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))
+    }
+}
+
+ + + +
+ + + +## Function `emit_event` + +Emit an event with payload msg by using handle_ref's key and counter. + + +
public fun emit_event<T: drop, store>(handle_ref: &mut Event::EventHandle<T>, msg: T)
+
+ + + +
+Implementation + + +
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;
+}
+
+ + + +
+ + + +## Function `write_to_event_store` + +Native procedure that writes to the actual event stream in Event store +This will replace the "native" portion of EmitEvent bytecode + + +
fun write_to_event_store<T: drop, store>(guid: vector<u8>, count: u64, msg: T)
+
+ + + +
+Implementation + + +
native fun write_to_event_store<T: drop + store>(guid: vector<u8>, count: u64, msg: T);
+
+ + + +
+ + + +## Function `destroy_handle` + +Destroy a unique handle. + + +
public fun destroy_handle<T: drop, store>(handle: Event::EventHandle<T>)
+
+ + + +
+Implementation + + +
public fun destroy_handle<T: drop + store>(handle: EventHandle<T>) {
+    EventHandle<T> { counter: _, guid: _ } = handle;
+}
+
+ + + +
+ + + +## Module Specification + + + +Functions of the event module are mocked out using the intrinsic +pragma. They are implemented in the prover's prelude. + + +
pragma intrinsic = true;
+
diff --git a/build/StarcoinFramework/docs/EventUtil.md b/build/StarcoinFramework/docs/EventUtil.md new file mode 100644 index 00000000..420e3c6f --- /dev/null +++ b/build/StarcoinFramework/docs/EventUtil.md @@ -0,0 +1,175 @@ + + + +# Module `0x1::EventUtil` + + + +- [Resource `EventHandleWrapper`](#0x1_EventUtil_EventHandleWrapper) +- [Constants](#@Constants_0) +- [Function `init_event`](#0x1_EventUtil_init_event) +- [Function `uninit_event`](#0x1_EventUtil_uninit_event) +- [Function `emit_event`](#0x1_EventUtil_emit_event) +- [Function `exist_event`](#0x1_EventUtil_exist_event) + + +
use 0x1::Errors;
+use 0x1::Event;
+use 0x1::Signer;
+
+ + + + + +## Resource `EventHandleWrapper` + + + +
struct EventHandleWrapper<EventT: drop, store> has key
+
+ + + +
+Fields + + +
+
+handle: Event::EventHandle<EventT> +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
const ERR_INIT_REPEATE: u64 = 101;
+
+ + + + + + + +
const ERR_RESOURCE_NOT_EXISTS: u64 = 102;
+
+ + + + + +## Function `init_event` + + + +
public fun init_event<EventT: drop, store>(sender: &signer)
+
+ + + +
+Implementation + + +
public fun init_event<EventT: store + drop>(sender: &signer) {
+    let broker = Signer::address_of(sender);
+    assert!(!exists<EventHandleWrapper<EventT>>(broker), Errors::invalid_state(ERR_INIT_REPEATE));
+    move_to(sender, EventHandleWrapper<EventT> {
+        handle: Event::new_event_handle<EventT>(sender)
+    });
+}
+
+ + + +
+ + + +## Function `uninit_event` + + + +
public fun uninit_event<EventT: drop, store>(sender: &signer)
+
+ + + +
+Implementation + + +
public fun uninit_event<EventT: store + drop>(sender: &signer) acquires EventHandleWrapper {
+    let broker = Signer::address_of(sender);
+    assert!(exists<EventHandleWrapper<EventT>>(broker), Errors::invalid_state(ERR_RESOURCE_NOT_EXISTS));
+    let EventHandleWrapper<EventT> { handle } = move_from<EventHandleWrapper<EventT>>(broker);
+    Event::destroy_handle<EventT>(handle);
+}
+
+ + + +
+ + + +## Function `emit_event` + + + +
public fun emit_event<EventT: drop, store>(broker: address, event: EventT)
+
+ + + +
+Implementation + + +
public fun emit_event<EventT: store + drop>(broker: address, event: EventT) acquires EventHandleWrapper {
+    let event_handle = borrow_global_mut<EventHandleWrapper<EventT>>(broker);
+    Event::emit_event(&mut event_handle.handle, event);
+}
+
+ + + +
+ + + +## Function `exist_event` + + + +
public fun exist_event<EventT: drop, store>(broker: address): bool
+
+ + + +
+Implementation + + +
public fun exist_event<EventT: store + drop>(broker: address): bool {
+    exists<EventHandleWrapper<EventT>>(broker)
+}
+
+ + + +
diff --git a/build/StarcoinFramework/docs/FixedPoint32.md b/build/StarcoinFramework/docs/FixedPoint32.md new file mode 100644 index 00000000..16bc13d8 --- /dev/null +++ b/build/StarcoinFramework/docs/FixedPoint32.md @@ -0,0 +1,439 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+value: u64 +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + +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;
+include MultiplyAbortsIf;
+ensures result == spec_multiply_u64(val, multiplier);
+
+ + + + + + + +
schema MultiplyAbortsIf {
+    val: num;
+    multiplier: FixedPoint32;
+    aborts_if spec_multiply_u64(val, multiplier) > MAX_U64 with Errors::LIMIT_EXCEEDED;
+}
+
+ + + + + + + +
fun spec_multiply_u64(val: num, multiplier: FixedPoint32): num {
+   (val * multiplier.value) >> 32
+}
+
+ + + +
+ + + +## Function `divide_u64` + +Divide a u64 integer by a fixed-point number, truncating any +fractional part of the quotient. This will abort if the divisor +is zero or if the quotient overflows. + + +
public fun divide_u64(val: u64, divisor: FixedPoint32::FixedPoint32): u64
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + +See comment at Self::multiply_64. + + +
pragma opaque = true;
+include DivideAbortsIf;
+ensures result == spec_divide_u64(val, divisor);
+
+ + + + + + + +
schema DivideAbortsIf {
+    val: num;
+    divisor: FixedPoint32;
+    aborts_if divisor.value == 0 with Errors::INVALID_ARGUMENT;
+    aborts_if spec_divide_u64(val, divisor) > MAX_U64 with Errors::LIMIT_EXCEEDED;
+}
+
+ + + + + + + +
fun spec_divide_u64(val: num, divisor: FixedPoint32): num {
+   (val << 32) / divisor.value
+}
+
+ + + +
+ + + +## Function `create_from_rational` + +Create a fixed-point value from a rational number specified by its +numerator and denominator. This function is for convenience; it is also +perfectly fine to create a fixed-point value by directly specifying the +raw value. This will abort if the denominator is zero or if the ratio is +not in the range 2^-32 .. 2^32-1. + + +
public fun create_from_rational(numerator: u64, denominator: u64): FixedPoint32::FixedPoint32
+
+ + + +
+Implementation + + +
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) }
+}
+
+ + + +
+ +
+Specification + + +See comment at Self::multiply_64. + + +
pragma verify = false;
+pragma opaque = true;
+include CreateFromRationalAbortsIf;
+ensures result == spec_create_from_rational(numerator, denominator);
+
+ + + + + + + +
schema CreateFromRationalAbortsIf {
+    numerator: u64;
+    denominator: u64;
+    let scaled_numerator = numerator << 64;
+    let scaled_denominator = denominator << 32;
+    let quotient = scaled_numerator / scaled_denominator;
+    aborts_if scaled_denominator == 0 with Errors::INVALID_ARGUMENT;
+    aborts_if quotient == 0 && scaled_numerator != 0 with Errors::INVALID_ARGUMENT;
+    aborts_if quotient > MAX_U64 with Errors::LIMIT_EXCEEDED;
+}
+
+ + + + + + + +
fun spec_create_from_rational(numerator: num, denominator: num): FixedPoint32 {
+   FixedPoint32{value: (numerator << 64) / (denominator << 32)}
+}
+
+ + + +
+ + + +## Function `create_from_raw_value` + +create a fixedpoint 32 from u64. + + +
public fun create_from_raw_value(value: u64): FixedPoint32::FixedPoint32
+
+ + + +
+Implementation + + +
public fun create_from_raw_value(value: u64): FixedPoint32 {
+    FixedPoint32 { value }
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if false;
+ensures result.value == value;
+
+ + + +
+ + + +## Function `get_raw_value` + +Accessor for the raw u64 value. Other less common operations, such as +adding or subtracting FixedPoint32 values, can be done using the raw +values directly. + + +
public fun get_raw_value(num: FixedPoint32::FixedPoint32): u64
+
+ + + +
+Implementation + + +
public fun get_raw_value(num: FixedPoint32): u64 {
+    num.value
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/FromBCS.md b/build/StarcoinFramework/docs/FromBCS.md new file mode 100644 index 00000000..c9094f7c --- /dev/null +++ b/build/StarcoinFramework/docs/FromBCS.md @@ -0,0 +1,205 @@ + + + +# Module `0x1::FromBCS` + +This module provides a number of functions to convert _primitive_ types from their representation in std::bcs +to values. This is the opposite of bcs::to_bytes. Note that it is not safe to define a generic public from_bytes +function because this can violate implicit struct invariants, therefore only primitive types are offerred. If +a general conversion back-and-force is needed, consider the StarcoinFramework::Any type which preserves invariants. + +Example: +``` +use std::bcs; +use StarcoinFramework::from_bcs; + +assert!(from_bcs::to_address(bcs::to_bytes(&@0xabcdef)) == @0xabcdef, 0); +``` + + +- [Constants](#@Constants_0) +- [Function `to_bool`](#0x1_FromBCS_to_bool) +- [Function `to_u8`](#0x1_FromBCS_to_u8) +- [Function `to_u64`](#0x1_FromBCS_to_u64) +- [Function `to_u128`](#0x1_FromBCS_to_u128) +- [Function `to_address`](#0x1_FromBCS_to_address) +- [Function `from_bytes`](#0x1_FromBCS_from_bytes) + + +
+ + + + + +## Constants + + + + +UTF8 check failed in conversion from bytes to string + + +
const EINVALID_UTF8: u64 = 1;
+
+ + + + + +## Function `to_bool` + + + +
public fun to_bool(v: vector<u8>): bool
+
+ + + +
+Implementation + + +
public fun to_bool(v: vector<u8>): bool {
+    from_bytes<bool>(v)
+}
+
+ + + +
+ + + +## Function `to_u8` + + + +
public fun to_u8(v: vector<u8>): u8
+
+ + + +
+Implementation + + +
public fun to_u8(v: vector<u8>): u8 {
+    from_bytes<u8>(v)
+}
+
+ + + +
+ + + +## Function `to_u64` + + + +
public fun to_u64(v: vector<u8>): u64
+
+ + + +
+Implementation + + +
public fun to_u64(v: vector<u8>): u64 {
+    from_bytes<u64>(v)
+}
+
+ + + +
+ + + +## Function `to_u128` + + + +
public fun to_u128(v: vector<u8>): u128
+
+ + + +
+Implementation + + +
public fun to_u128(v: vector<u8>): u128 {
+    from_bytes<u128>(v)
+}
+
+ + + +
+ + + +## Function `to_address` + + + +
public fun to_address(v: vector<u8>): address
+
+ + + +
+Implementation + + +
public fun to_address(v: vector<u8>): address {
+    from_bytes<address>(v)
+}
+
+ + + +
+ + + +## Function `from_bytes` + +Package private native function to deserialize a type T. + +Note that this function does not put any constraint on T. If code uses this function to +deserialize a linear value, its their responsibility that the data they deserialize is +owned. + + +
public(friend) fun from_bytes<T>(bytes: vector<u8>): T
+
+ + + +
+Implementation + + +
public(friend) native fun from_bytes<T>(bytes: vector<u8>): T;
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+
+ + + +
diff --git a/build/StarcoinFramework/docs/GasSchedule.md b/build/StarcoinFramework/docs/GasSchedule.md new file mode 100644 index 00000000..c88ffa45 --- /dev/null +++ b/build/StarcoinFramework/docs/GasSchedule.md @@ -0,0 +1,513 @@ + + + +# Module `0x1::GasSchedule` + +Gas schedule configuration. + + +- [Struct `GasEntry`](#0x1_GasSchedule_GasEntry) +- [Resource `GasSchedule`](#0x1_GasSchedule_GasSchedule) +- [Function `gas_schedule`](#0x1_GasSchedule_gas_schedule) +- [Function `new_gas_entry`](#0x1_GasSchedule_new_gas_entry) +- [Function `new_constant_entry`](#0x1_GasSchedule_new_constant_entry) +- [Function `initialize`](#0x1_GasSchedule_initialize) +- [Function `new_gas_schedule_for_test`](#0x1_GasSchedule_new_gas_schedule_for_test) +- [Module Specification](#@Module_Specification_0) + + +
use 0x1::ChainId;
+use 0x1::Config;
+use 0x1::CoreAddresses;
+
+ + + + + +## Struct `GasEntry` + + + +
struct GasEntry has copy, drop, store
+
+ + + +
+Fields + + +
+
+key: vector<u8> +
+
+ +
+
+val: u64 +
+
+ +
+
+ + +
+ + + +## Resource `GasSchedule` + + + +
struct GasSchedule has copy, drop, store, key
+
+ + + +
+Fields + + +
+
+entries: vector<GasSchedule::GasEntry> +
+
+ +
+
+ + +
+ + + +## Function `gas_schedule` + +The 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 + + +
public fun gas_schedule(): vector<GasSchedule::GasEntry>
+
+ + + +
+Implementation + + +
public fun gas_schedule(): vector<GasEntry> {
+    let table = Vector::empty();
+
+    // instruction_schedule
+    // POP
+    Vector::push_back(&mut table, new_gas_entry(b"instr.pop", 1, 1));
+    // RET
+    Vector::push_back(&mut table, new_gas_entry(b"instr.ret", 638, 1));
+    // BR_TRUE
+    Vector::push_back(&mut table, new_gas_entry(b"instr.br_true", 1, 1));
+    // BR_FALSE
+    Vector::push_back(&mut table, new_gas_entry(b"instr.br_false", 1, 1));
+    // BRANCH
+    Vector::push_back(&mut table, new_gas_entry(b"instr.branch", 1, 1));
+    // LD_U64
+    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_u64", 1, 1));
+    // LD_CONST
+    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_const.per_byte", 1, 1));
+    // LD_TRUE
+    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_true", 1, 1));
+    // LD_FALSE
+    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_false", 1, 1));
+    // COPY_LOC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.copy_loc.per_abs_mem_unit", 1, 1));
+    // MOVE_LOC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.move_loc.per_abs_mem_unit", 1, 1));
+    // ST_LOC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.st_loc.per_abs_mem_unit", 1, 1));
+    // MUT_BORROW_LOC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.mut_borrow_loc", 2, 1));
+    // IMM_BORROW_LOC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.imm_borrow_loc", 1, 1));
+    // MUT_BORROW_FIELD
+    Vector::push_back(&mut table, new_gas_entry(b"instr.mut_borrow_field", 1, 1));
+    // IMM_BORROW_FIELD
+    Vector::push_back(&mut table, new_gas_entry(b"instr.imm_borrow_field", 1, 1));
+    // CALL
+    Vector::push_back(&mut table, new_gas_entry(b"instr.call.per_arg", 1132, 1));
+    // PACK
+    Vector::push_back(&mut table, new_gas_entry(b"instr.pack.per_abs_mem_unit", 2, 1));
+    // UNPACK
+    Vector::push_back(&mut table, new_gas_entry(b"instr.unpack.per_abs_mem_unit", 2, 1));
+    // READ_REF
+    Vector::push_back(&mut table, new_gas_entry(b"instr.read_ref.per_abs_mem_unit", 1, 1));
+    // WRITE_REF
+    Vector::push_back(&mut table, new_gas_entry(b"instr.write_ref.per_abs_mem_unit", 1, 1));
+    // ADD
+    Vector::push_back(&mut table, new_gas_entry(b"instr.add", 1, 1));
+    // SUB
+    Vector::push_back(&mut table, new_gas_entry(b"instr.sub", 1, 1));
+    // MUL
+    Vector::push_back(&mut table, new_gas_entry(b"instr.mul", 1, 1));
+    // MOD
+    Vector::push_back(&mut table, new_gas_entry(b"instr.mod", 1, 1));
+    // DIV
+    Vector::push_back(&mut table, new_gas_entry(b"instr.div", 3, 1));
+    // BIT_OR
+    Vector::push_back(&mut table, new_gas_entry(b"instr.bit_or", 2, 1));
+    // BIT_AND
+    Vector::push_back(&mut table, new_gas_entry(b"instr.bit_and", 2, 1));
+    // XOR
+    Vector::push_back(&mut table, new_gas_entry(b"instr.xor", 1, 1));
+    // OR
+    Vector::push_back(&mut table, new_gas_entry(b"instr.or", 2, 1));
+    // AND
+    Vector::push_back(&mut table, new_gas_entry(b"instr.and", 1, 1));
+    // NOT
+    Vector::push_back(&mut table, new_gas_entry(b"instr.not", 1, 1));
+    // EQ
+    Vector::push_back(&mut table, new_gas_entry(b"instr.eq.per_abs_mem_unit", 1, 1));
+    // NEQ
+    Vector::push_back(&mut table, new_gas_entry(b"instr.neq.per_abs_mem_unit", 1, 1));
+    // LT
+    Vector::push_back(&mut table, new_gas_entry(b"instr.lt", 1, 1));
+    // GT
+    Vector::push_back(&mut table, new_gas_entry(b"instr.gt", 1, 1));
+    // LE
+    Vector::push_back(&mut table, new_gas_entry(b"instr.le", 2, 1));
+    // GE
+    Vector::push_back(&mut table, new_gas_entry(b"instr.ge", 1, 1));
+    // ABORT
+    Vector::push_back(&mut table, new_gas_entry(b"instr.abort", 1, 1));
+    // NOP
+    Vector::push_back(&mut table, new_gas_entry(b"instr.nop", 1, 1));
+    // EXISTS
+    Vector::push_back(&mut table, new_gas_entry(b"instr.exists.per_abs_mem_unit", 41, 1));
+    // MUT_BORROW_GLOBAL
+    Vector::push_back(&mut table, new_gas_entry(b"instr.mut_borrow_global.per_abs_mem_unit", 21, 1));
+    // IML_BORROW_GLOBAL
+    Vector::push_back(&mut table, new_gas_entry(b"instr.imm_borrow_global.per_abs_mem_unit", 23, 1));
+    // MOVE_FROM
+    Vector::push_back(&mut table, new_gas_entry(b"instr.move_from.per_abs_mem_unit", 459, 1));
+    // MOVE_TO
+    Vector::push_back(&mut table, new_gas_entry(b"instr.move_to.per_abs_mem_unit", 13, 1));
+    // FREEZE_REF
+    Vector::push_back(&mut table, new_gas_entry(b"instr.freeze_ref", 1, 1));
+    // SHL
+    Vector::push_back(&mut table, new_gas_entry(b"instr.shl", 2, 1));
+    // SHR
+    Vector::push_back(&mut table, new_gas_entry(b"instr.shr", 1, 1));
+    // LD_U8
+    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_u8", 1, 1));
+    // LD_U128
+    Vector::push_back(&mut table, new_gas_entry(b"instr.ld_u128", 1, 1));
+
+    // CAST_U8
+    Vector::push_back(&mut table, new_gas_entry(b"instr.cast_u8", 2, 1));
+    // CAST_U64
+    Vector::push_back(&mut table, new_gas_entry(b"instr.cast_u64", 1, 1));
+    // CAST_U128
+    Vector::push_back(&mut table, new_gas_entry(b"instr.cast_u128", 1, 1));
+    // MUT_BORORW_FIELD_GENERIC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.mut_borrow_field_generic.base", 1, 1));
+    // IMM_BORORW_FIELD_GENERIC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.imm_borrow_field_generic.base", 1, 1));
+    // CALL_GENERIC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.call_generic.per_arg", 582, 1));
+    // PACK_GENERIC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.pack_generic.per_abs_mem_unit", 2, 1));
+    // UNPACK_GENERIC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.unpack_generic.per_abs_mem_unit", 2, 1));
+    // EXISTS_GENERIC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.exists_generic.per_abs_mem_unit", 34, 1));
+    // MUT_BORROW_GLOBAL_GENERIC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.mut_borrow_global_generic.per_abs_mem_unit", 15, 1));
+    // IMM_BORROW_GLOBAL_GENERIC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.imm_borrow_global_generic.per_abs_mem_unit", 14, 1));
+    // MOVE_FROM_GENERIC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.move_from_generic.per_abs_mem_unit", 13, 1));
+    // MOVE_TO_GENERIC
+    Vector::push_back(&mut table, new_gas_entry(b"instr.move_to_generic.per_abs_mem_unit", 27, 1));
+
+    // VEC_PACK
+    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_pack.per_elem", 84, 1));
+    // VEC_LEN
+    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_len.base", 98, 1));
+    // VEC_IMM_BORROW
+    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_imm_borrow.base", 1334, 1));
+    // VEC_MUT_BORROW
+    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_mut_borrow.base", 1902, 1));
+    // VEC_PUSH_BACK
+    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_push_back.per_abs_mem_unit", 53, 1));
+    // VEC_POP_BACK
+    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_pop_back.base", 227, 1));
+    // VEC_UNPACK
+    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_unpack.per_expected_elem", 572, 1));
+    // VEC_SWAP
+    Vector::push_back(&mut table, new_gas_entry(b"instr.vec_swap.base", 1436, 1));
+
+    Vector::push_back(&mut table, new_constant_entry(b"instr.ld_u16", 3));
+    Vector::push_back(&mut table, new_constant_entry(b"instr.ld_u32", 2));
+    Vector::push_back(&mut table, new_constant_entry(b"instr.ld_u256", 3));
+    Vector::push_back(&mut table, new_constant_entry(b"instr.cast_u16", 3));
+    Vector::push_back(&mut table, new_constant_entry(b"instr.cast_u32", 2));
+    Vector::push_back(&mut table, new_constant_entry(b"instr.cast_u256", 3));
+
+    // native_schedule
+    //Hash::sha2_256 0
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.hash.sha2_256.per_byte", 21, 1));
+    //Hash::sha3_256 1
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.hash.sha3_256.per_byte", 64, 1));
+    //Signature::ed25519_verify 2
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.signature.ed25519_verify.per_byte", 61, 1));
+    //ED25519_THRESHOLD_VERIFY 3 this native funciton is deprecated
+    Vector::push_back(&mut table, new_gas_entry(b"", 3351, 1));
+    //BSC::to_bytes 4
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.bcs.to_bytes.per_byte_serialized", 181, 1));
+    //Vector::length 5
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.length.base", 98, 1));
+    //Vector::empty 6
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.empty.base", 84, 1));
+    //Vector::borrow 7
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.borrow.base", 1334, 1));
+    //Vector::borrow_mut 8
+    Vector::push_back(&mut table, new_gas_entry(b"", 1902, 1));
+    //Vector::push_back 9
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.push_back.legacy_per_abstract_memory_unit", 53, 1));
+    //Vector::pop_back 10
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.pop_back.base", 227, 1));
+    //Vector::destory_empty 11
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.destroy_empty.base", 572, 1));
+    //Vector::swap 12
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.swap.base", 1436, 1));
+    //Signature::ed25519_validate_pubkey 13
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.signature.ed25519_validate_key.per_byte", 26, 1));
+    //Signer::borrow_address 14
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.signer.borrow_address.base", 353, 1));
+    //Account::creator_signer 15
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.account.create_signer.base", 24, 1));
+    //Account::destroy_signer 16
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.account.destroy_signer.base", 212, 1));
+    //Event::emit_event 17
+    Vector::push_back(&mut table, new_gas_entry(b"nursery.event.write_to_event_store.unit_cost", 52, 1));
+    //BCS::to_address 18
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.bcs.to_address.per_byte", 26, 1));
+    //Token::name_of 19
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.token.name_of.base", 2002, 1));
+    //Hash::keccak_256 20
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.hash.keccak256.per_byte", 64, 1));
+    //Hash::ripemd160 21
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.hash.ripemd160.per_byte", 64, 1));
+    //Signature::native_ecrecover 22
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.signature.ec_recover.per_byte", 128, 1));
+    //U256::from_bytes 23
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.from_bytes.per_byte", 2, 1));
+    //U256::add 24
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.add.base", 4, 1));
+    //U256::sub 25
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.sub.base", 4, 1));
+    //U256::mul 26
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.mul.base", 4, 1));
+    //U256::div 27
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.div.base", 10, 1));
+    // U256::rem 28
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.rem.base", 4, 1));
+    // U256::pow 29
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.u256.pow.base", 8, 1));
+    // TODO: settle down the gas cost
+    // Vector::append 30
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.append.legacy_per_abstract_memory_unit", 40, 1));
+    // Vector::remove 31
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.remove.legacy_per_abstract_memory_unit", 20, 1));
+    // Vector::reverse 32
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.reverse.legacy_per_abstract_memory_unit", 10, 1));
+    // Table::new_table_handle 33
+    Vector::push_back(&mut table, new_gas_entry(b"table.new_table_handle.base", 4, 1));
+    // Table::add_box 34
+    Vector::push_back(&mut table, new_gas_entry(b"table.add_box.per_byte_serialized", 4, 1));
+    // Table::borrow_box 35
+    Vector::push_back(&mut table, new_gas_entry(b"table.borrow_box.per_byte_serialized", 10, 1));
+    // Table::remove_box 36
+    Vector::push_back(&mut table, new_gas_entry(b"table.remove_box.per_byte_serialized", 8, 1));
+    // Table::contains_box 37
+    Vector::push_back(&mut table, new_gas_entry(b"table.contains_box.per_byte_serialized", 40, 1));
+    // Table::destroy_empty_box 38
+    Vector::push_back(&mut table, new_gas_entry(b"table.destroy_empty_box.base", 20, 1));
+    // Table::drop_unchecked_box 39
+    Vector::push_back(&mut table, new_gas_entry(b"table.drop_unchecked_box.base", 73, 1));
+    // string.check_utf8 40
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.string.check_utf8.per_byte", 4, 1));
+    // string.sub_str 41
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.string.sub_string.per_byte", 4, 1));
+    // string.is_char_boundary 42
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.string.is_char_boundary.base", 4, 1));
+    // Table::string.index_of 43
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.string.index_of.per_byte_searched", 4, 1));
+    // Table::string.index_of 44
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.frombcs.base", 4, 1));
+    // Table::string.index_of 45
+    Vector::push_back(&mut table, new_gas_entry(b"starcoin_natives.secp256k1.base", 4, 1));
+    // Table::string.index_of 46
+    Vector::push_back(&mut table, new_gas_entry(b"move_stdlib.vector.spawn_from.legacy_per_abstract_memory_unit", 4, 1));
+
+    Vector::push_back(&mut table, new_constant_entry(b"nursery.debug.print.base_cost", 1));
+    Vector::push_back(&mut table, new_constant_entry(b"nursery.debug.print_stack_trace.base_cost", 1));
+    Vector::push_back(&mut table, new_constant_entry(b"move_stdlib.hash.sha2_256.legacy_min_input_len", 1));
+    Vector::push_back(&mut table, new_constant_entry(b"move_stdlib.hash.sha3_256.legacy_min_input_len", 1));
+    Vector::push_back(&mut table, new_constant_entry(b"move_stdlib.bcs.to_bytes.failure", 182));
+    Vector::push_back(&mut table, new_constant_entry(b"move_stdlib.bcs.to_bytes.legacy_min_output_size", 1));
+
+    // constant config values
+    Vector::push_back(&mut table, new_constant_entry(b"txn.global_memory_per_byte_cost", 4));
+    Vector::push_back(&mut table, new_constant_entry(b"txn.global_memory_per_byte_write_cost", 9));
+    Vector::push_back(&mut table, new_constant_entry(b"txn.min_transaction_gas_units", 600));
+    Vector::push_back(&mut table, new_constant_entry(b"txn.large_transaction_cutoff", 600));
+    Vector::push_back(&mut table, new_constant_entry(b"txn.intrinsic_gas_per_byte", 8));
+    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
+    };
+    Vector::push_back(&mut table, new_constant_entry(b"txn.maximum_number_of_gas_units", maximum_number_of_gas_units));
+    Vector::push_back(&mut table, new_constant_entry(b"txn.min_price_per_gas_unit", if (ChainId::is_test()) { 0 }  else { 1 }));
+    Vector::push_back(&mut table, new_constant_entry(b"txn.max_price_per_gas_unit", 10000));
+    Vector::push_back(&mut table, new_constant_entry(b"txn.max_transaction_size_in_bytes", 1024 * 128));
+    Vector::push_back(&mut table, new_constant_entry(b"txn.gas_unit_scaling_factor", 1));
+    Vector::push_back(&mut table, new_constant_entry(b"txn.default_account_size", 800));
+
+    table
+}
+
+ + + +
+ + + +## Function `new_gas_entry` + + + +
public fun new_gas_entry(key: vector<u8>, instr_gas: u64, mem_gas: u64): GasSchedule::GasEntry
+
+ + + +
+Implementation + + +
public fun new_gas_entry(key: vector<u8>, instr_gas: u64, mem_gas: u64): GasEntry {
+    GasEntry {
+        key,
+        val: instr_gas + mem_gas,
+    }
+}
+
+ + + +
+ + + +## Function `new_constant_entry` + + + +
fun new_constant_entry(key: vector<u8>, val: u64): GasSchedule::GasEntry
+
+ + + +
+Implementation + + +
fun new_constant_entry(key: vector<u8>, val: u64): GasEntry {
+    GasEntry {
+        key,
+        val,
+    }
+}
+
+ + + +
+ + + +## Function `initialize` + +Initialize the gas schedule under the genesis account + + +
public fun initialize(account: &signer, gas_schedule: GasSchedule::GasSchedule)
+
+ + + +
+Implementation + + +
public fun initialize(account: &signer, gas_schedule: GasSchedule) {
+    CoreAddresses::assert_genesis_address(account);
+    Config::publish_new_config<GasSchedule>(
+        account,
+        gas_schedule,
+    );
+}
+
+ + + +
+ + + +## Function `new_gas_schedule_for_test` + + + +
public fun new_gas_schedule_for_test(): GasSchedule::GasSchedule
+
+ + + +
+Implementation + + +
public fun new_gas_schedule_for_test(): GasSchedule {
+    let entry = GasEntry {
+        key: Vector::empty(),
+        val: 1,
+    };
+    let entries = Vector::empty();
+    Vector::push_back(&mut entries, entry);
+
+    GasSchedule {
+        entries,
+    }
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/Genesis.md b/build/StarcoinFramework/docs/Genesis.md new file mode 100644 index 00000000..9cbc23f7 --- /dev/null +++ b/build/StarcoinFramework/docs/Genesis.md @@ -0,0 +1,804 @@ + + + +# Module `0x1::Genesis` + +The module for init Genesis + + +- [Function `initialize`](#0x1_Genesis_initialize) +- [Function `initialize_v2`](#0x1_Genesis_initialize_v2) +- [Function `initialize_v3`](#0x1_Genesis_initialize_v3) +- [Function `do_initialize`](#0x1_Genesis_do_initialize) +- [Function `initialize_for_unit_tests`](#0x1_Genesis_initialize_for_unit_tests) +- [Module Specification](#@Module_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::GasSchedule;
+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 entry 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)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ + + +## Function `initialize_v2` + + + +
public entry 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)
+
+ + + +
+Implementation + + +
public entry 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,
+) {
+    // create genesis account
+    let genesis_account = Account::create_genesis_account(CoreAddresses::GENESIS_ADDRESS());
+
+    Self::do_initialize(
+    &genesis_account,
+    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,
+    );
+
+    Account::release_genesis_signer(genesis_account);
+}
+
+ + + +
+ + + +## Function `initialize_v3` + + + +
public entry fun initialize_v3(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, gas_schedule: GasSchedule::GasSchedule)
+
+ + + +
+Implementation + + +
public entry fun initialize_v3(
+    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,
+    gas_schedule: GasSchedule,
+) {
+    // create genesis account
+    let genesis_account = Account::create_genesis_account(CoreAddresses::GENESIS_ADDRESS());
+
+    Self::do_initialize(
+    &genesis_account,
+    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,
+    );
+
+    GasSchedule::initialize(&genesis_account, gas_schedule);
+    Account::release_genesis_signer(genesis_account);
+}
+
+ + + +
+ + + +## Function `do_initialize` + + + +
fun do_initialize(genesis_account: &signer, 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)
+
+ + + +
+Implementation + + +
fun do_initialize(
+    genesis_account: &signer,
+    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();
+
+    //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, 6);
+
+    //v11 -> v12
+    {
+
+    };
+    StdlibUpgradeScripts::do_upgrade_from_v11_to_v12(genesis_account);
+    //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(association);
+}
+
+ + + +
+ + + +## Function `initialize_for_unit_tests` + +Init the genesis for unit tests + + +
public fun initialize_for_unit_tests()
+
+ + + +
+Implementation + + +
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;
+
+    // create genesis account
+    let genesis_account = Account::create_genesis_account(CoreAddresses::GENESIS_ADDRESS());
+
+    Self::do_initialize(
+        &genesis_account,
+        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,
+    );
+
+    Account::release_genesis_signer(genesis_account);
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_partial = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/GenesisNFT.md b/build/StarcoinFramework/docs/GenesisNFT.md new file mode 100644 index 00000000..5f4ab2de --- /dev/null +++ b/build/StarcoinFramework/docs/GenesisNFT.md @@ -0,0 +1,49 @@ + + + +# Module `0x1::GenesisNFTScripts` + + + +- [Function `mint`](#0x1_GenesisNFTScripts_mint) +- [Module Specification](#@Module_Specification_0) + + +
use 0x1::GenesisNFT;
+
+ + + + + +## Function `mint` + +Mint a GenesisNFT + + +
public entry fun mint(sender: signer, index: u64, merkle_proof: vector<vector<u8>>)
+
+ + + +
+Implementation + + +
public entry fun mint(sender: signer, index: u64, merkle_proof:vector<vector<u8>>) {
+    GenesisNFT::mint_entry(sender, index, merkle_proof);
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+
diff --git a/build/StarcoinFramework/docs/GenesisSignerCapability.md b/build/StarcoinFramework/docs/GenesisSignerCapability.md new file mode 100644 index 00000000..5ffea8c8 --- /dev/null +++ b/build/StarcoinFramework/docs/GenesisSignerCapability.md @@ -0,0 +1,114 @@ + + + +# 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
+
+ + + +
+Fields + + +
+
+cap: Account::SignerCapability +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
const ENOT_GENESIS_ACCOUNT: u64 = 11;
+
+ + + + + +## Function `initialize` + + + +
public(friend) fun initialize(signer: &signer, cap: Account::SignerCapability)
+
+ + + +
+Implementation + + +
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});
+}
+
+ + + +
+ + + +## Function `get_genesis_signer` + + + +
public(friend) fun get_genesis_signer(): signer
+
+ + + +
+Implementation + + +
public(friend) fun get_genesis_signer(): signer acquires GenesisSignerCapability {
+    let cap = borrow_global<GenesisSignerCapability>(CoreAddresses::GENESIS_ADDRESS());
+    Account::create_signer_with_cap(&cap.cap)
+}
+
+ + + +
diff --git a/build/StarcoinFramework/docs/Hash.md b/build/StarcoinFramework/docs/Hash.md new file mode 100644 index 00000000..47f83022 --- /dev/null +++ b/build/StarcoinFramework/docs/Hash.md @@ -0,0 +1,116 @@ + + + +# Module `0x1::Hash` + +The module provide sha-hash functionality for Move. + + +- [Function `sha2_256`](#0x1_Hash_sha2_256) +- [Function `sha3_256`](#0x1_Hash_sha3_256) +- [Function `keccak_256`](#0x1_Hash_keccak_256) +- [Function `ripemd160`](#0x1_Hash_ripemd160) +- [Module Specification](#@Module_Specification_0) + + +
+ + + + + +## Function `sha2_256` + + + +
public fun sha2_256(data: vector<u8>): vector<u8>
+
+ + + +
+Implementation + + +
native public fun sha2_256(data: vector<u8>): vector<u8>;
+
+ + + +
+ + + +## Function `sha3_256` + + + +
public fun sha3_256(data: vector<u8>): vector<u8>
+
+ + + +
+Implementation + + +
native public fun sha3_256(data: vector<u8>): vector<u8>;
+
+ + + +
+ + + +## Function `keccak_256` + + + +
public fun keccak_256(data: vector<u8>): vector<u8>
+
+ + + +
+Implementation + + +
native public fun keccak_256(data: vector<u8>): vector<u8>;
+
+ + + +
+ + + +## Function `ripemd160` + + + +
public fun ripemd160(data: vector<u8>): vector<u8>
+
+ + + +
+Implementation + + +
native public fun ripemd160(data: vector<u8>): vector<u8>;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/LanguageVersion.md b/build/StarcoinFramework/docs/LanguageVersion.md new file mode 100644 index 00000000..1c8bb89d --- /dev/null +++ b/build/StarcoinFramework/docs/LanguageVersion.md @@ -0,0 +1,114 @@ + + + +# Module `0x1::LanguageVersion` + + + +- [Struct `LanguageVersion`](#0x1_LanguageVersion_LanguageVersion) +- [Function `new`](#0x1_LanguageVersion_new) +- [Function `version`](#0x1_LanguageVersion_version) + + +
+ + + + + +## Struct `LanguageVersion` + + + +
struct LanguageVersion has copy, drop, store
+
+ + + +
+Fields + + +
+
+major: u64 +
+
+ +
+
+ + +
+ + + +## Function `new` + + + +
public fun new(version: u64): LanguageVersion::LanguageVersion
+
+ + + +
+Implementation + + +
public fun new(version: u64): LanguageVersion {
+    LanguageVersion {major: version}
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `version` + + + +
public fun version(version: &LanguageVersion::LanguageVersion): u64
+
+ + + +
+Implementation + + +
public fun version(version: &LanguageVersion): u64 {
+    version.major
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
diff --git a/build/StarcoinFramework/docs/Math.md b/build/StarcoinFramework/docs/Math.md new file mode 100644 index 00000000..73b4eab0 --- /dev/null +++ b/build/StarcoinFramework/docs/Math.md @@ -0,0 +1,377 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
+ + + + + +## Constants + + + + + + +
const U128_MAX: u128 = 340282366920938463463374607431768211455;
+
+ + + + + + + +
const U64_MAX: u64 = 18446744073709551615;
+
+ + + + + +## Function `u64_max` + +u64::MAX + + +
public fun u64_max(): u64
+
+ + + +
+Implementation + + +
public fun u64_max(): u64 {
+    U64_MAX
+}
+
+ + + +
+ + + +## Function `u128_max` + +u128::MAX + + +
public fun u128_max(): u128
+
+ + + +
+Implementation + + +
public fun u128_max(): u128 {
+    U128_MAX
+}
+
+ + + +
+ + + +## Function `sqrt` + +babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) + + +
public fun sqrt(y: u128): u64
+
+ + + +
+Implementation + + +
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)
+    }
+}
+
+ + + +
+ +
+Specification + + + +
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` + +calculate the y pow of x. + + +
public fun pow(x: u64, y: u64): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
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` + +https://medium.com/coinmonks/math-in-solidity-part-3-percents-and-proportions-4db014e080b1 +calculate x * y /z with as little loss of precision as possible and avoid overflow + + +
public fun mul_div(x: u128, y: u128, z: u128): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
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;
+
+ + + +
+ + + +## Function `sum` + +calculate sum of nums + + +
public fun sum(nums: &vector<u128>): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `avg` + +calculate average of nums + + +
public fun avg(nums: &vector<u128>): u128
+
+ + + +
+Implementation + + +
public fun avg(nums: &vector<u128>): u128{
+    let len = Vector::length(nums);
+    let sum = sum(nums);
+    sum/(len as u128)
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/MerkleNFT.md b/build/StarcoinFramework/docs/MerkleNFT.md new file mode 100644 index 00000000..95bae1b9 --- /dev/null +++ b/build/StarcoinFramework/docs/MerkleNFT.md @@ -0,0 +1,330 @@ + + + +# 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
+
+ + + +
+Fields + + +
+
+merkle_root: vector<u8> +
+
+ +
+
+claimed_bitmap: vector<u128> +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `mint_with_cap` + + + +
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>
+
+ + + +
+Implementation + + +
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
+    }
+
+ + + +
+ + + +## Function `encode_leaf` + + + +
fun encode_leaf(index: &u64, account: &address): vector<u8>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `set_minted_` + + + +
fun set_minted_<NFTMeta: copy, drop, store>(distribution: &mut MerkleNFTDistributor::MerkleNFTDistribution<NFTMeta>, index: u64)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+pragma opaque;
+
+ + + +
+ + + +## Function `verify_proof` + + + +
public fun verify_proof<NFTMeta: copy, drop, store>(account: address, creator: address, index: u64, merkle_proof: vector<vector<u8>>): bool
+
+ + + +
+Implementation + + +
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))
+    }
+
+ + + +
+ + + +## Function `is_minted` + + + +
public fun is_minted<NFTMeta: copy, drop, store>(creator: address, index: u64): bool
+
+ + + +
+Implementation + + +
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)
+    }
+
+ + + +
+ + + +## Function `is_minted_` + + + +
fun is_minted_<NFTMeta: copy, drop, store>(distribution: &MerkleNFTDistributor::MerkleNFTDistribution<NFTMeta>, index: u64): bool
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+pragma opaque;
+
+ + + +
diff --git a/build/StarcoinFramework/docs/MintDaoProposal.md b/build/StarcoinFramework/docs/MintDaoProposal.md new file mode 100644 index 00000000..7bf5a984 --- /dev/null +++ b/build/StarcoinFramework/docs/MintDaoProposal.md @@ -0,0 +1,258 @@ + + + +# Module `0x1::MintDaoProposal` + +MintDaoProposal is a dao proposal for mint extra tokens. + + +- [Resource `WrappedMintCapability`](#0x1_MintDaoProposal_WrappedMintCapability) +- [Struct `MintToken`](#0x1_MintDaoProposal_MintToken) +- [Constants](#@Constants_0) +- [Function `plugin`](#0x1_MintDaoProposal_plugin) +- [Function `propose_mint_to`](#0x1_MintDaoProposal_propose_mint_to) +- [Function `execute_mint_proposal`](#0x1_MintDaoProposal_execute_mint_proposal) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+cap: Token::MintCapability<TokenType> +
+
+ +
+
+ + +
+ + + +## Struct `MintToken` + +MintToken request. + + +
struct MintToken has copy, drop, store
+
+ + + +
+Fields + + +
+
+receiver: address +
+
+ the receiver of minted tokens. +
+
+amount: u128 +
+
+ how many tokens to mint. +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
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 });
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Entrypoint for the proposal. + + +
public fun propose_mint_to<TokenT: copy, drop, store>(signer: &signer, receiver: address, amount: u128, exec_delay: u64)
+
+ + + +
+Implementation + + +
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,
+    );
+}
+
+ + + +
+ +
+Specification + + + +
pragma aborts_if_is_partial = false;
+include Dao::AbortIfDaoConfigNotExist<TokenT>;
+include Dao::AbortIfDaoInfoNotExist<TokenT>;
+aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::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` + +Once the proposal is agreed, anyone can call the method to make the proposal happen. + + +
public fun execute_mint_proposal<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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());
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict;
+pragma aborts_if_is_partial;
+
diff --git a/build/StarcoinFramework/docs/MintScripts.md b/build/StarcoinFramework/docs/MintScripts.md new file mode 100644 index 00000000..dbbdd845 --- /dev/null +++ b/build/StarcoinFramework/docs/MintScripts.md @@ -0,0 +1,10 @@ + + + +# Module `0x1::MintScripts` + + + + + +
diff --git a/build/StarcoinFramework/docs/ModifyDaoConfigProposal.md b/build/StarcoinFramework/docs/ModifyDaoConfigProposal.md new file mode 100644 index 00000000..1afc8c43 --- /dev/null +++ b/build/StarcoinFramework/docs/ModifyDaoConfigProposal.md @@ -0,0 +1,300 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+cap: Config::ModifyConfigCapability<Dao::DaoConfig<TokenT>> +
+
+ +
+
+ + +
+ + + +## Struct `DaoConfigUpdate` + +a proposal action to update dao config. +if any field is 0, that means the proposal want to update. + + +
struct DaoConfigUpdate has copy, drop, store
+
+ + + +
+Fields + + +
+
+voting_delay: u64 +
+
+ new voting delay setting. +
+
+voting_period: u64 +
+
+ new voting period setting. +
+
+voting_quorum_rate: u8 +
+
+ new voting quorum rate setting. +
+
+min_action_delay: u64 +
+
+ new min action delay setting. +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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>>{address: 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` + +Entrypoint for the proposal. + + +
public entry 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)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
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::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` + +Once the proposal is agreed, anyone can call the method to make the proposal happen. + + +
public entry fun execute<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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,
+    );
+}
+
+ + + +
+ +
+Specification + + + +
pragma aborts_if_is_partial = true;
+aborts_if !exists<DaoConfigModifyCapability<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict;
+pragma aborts_if_is_partial;
+
diff --git a/build/StarcoinFramework/docs/ModuleUpgradeScripts.md b/build/StarcoinFramework/docs/ModuleUpgradeScripts.md new file mode 100644 index 00000000..4ac2a7f2 --- /dev/null +++ b/build/StarcoinFramework/docs/ModuleUpgradeScripts.md @@ -0,0 +1,314 @@ + + + +# Module `0x1::ModuleUpgradeScripts` + + + +- [Constants](#@Constants_0) +- [Function `propose_module_upgrade_v2`](#0x1_ModuleUpgradeScripts_propose_module_upgrade_v2) +- [Function `update_module_upgrade_strategy`](#0x1_ModuleUpgradeScripts_update_module_upgrade_strategy) +- [Function `update_module_upgrade_strategy_with_min_time`](#0x1_ModuleUpgradeScripts_update_module_upgrade_strategy_with_min_time) +- [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) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::Config;
+use 0x1::Errors;
+use 0x1::Option;
+use 0x1::PackageTxnManager;
+use 0x1::Signer;
+use 0x1::UpgradeModuleDaoProposal;
+use 0x1::Version;
+
+ + + + + +## Constants + + + + + + +
const ERR_WRONG_UPGRADE_STRATEGY: u64 = 100;
+
+ + + + + +## Function `propose_module_upgrade_v2` + + + +
public entry 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)
+
+ + + +
+Implementation + + +
public entry 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
+    );
+}
+
+ + + +
+ + + +## Function `update_module_upgrade_strategy` + +Update sender's module upgrade strategy to strategy + + +
public entry fun update_module_upgrade_strategy(sender: signer, strategy: u8)
+
+ + + +
+Implementation + + +
public entry 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>(),
+    );
+}
+
+ + + +
+ + + +## Function `update_module_upgrade_strategy_with_min_time` + +Update sender's module upgrade strategy to strategy with min_time_limit. +This can only be invoked when strategy is STRATEGY_TWO_PHASE. + + +
public entry fun update_module_upgrade_strategy_with_min_time(sender: signer, strategy: u8, min_time_limit: u64)
+
+ + + +
+Implementation + + +
public entry fun update_module_upgrade_strategy_with_min_time(
+    sender: signer,
+    strategy: u8,
+    min_time_limit: u64,
+){
+    // 1. check version
+    assert!(strategy == PackageTxnManager::get_strategy_two_phase(), Errors::invalid_argument(ERR_WRONG_UPGRADE_STRATEGY));
+    // 2. update strategy
+    PackageTxnManager::update_module_upgrade_strategy(
+        &sender,
+        strategy,
+        Option::some<u64>(min_time_limit),
+    );
+}
+
+ + + +
+ + + +## Function `submit_module_upgrade_plan` + +a alias of execute_module_upgrade_plan_propose, will deprecated in the future. + + +
public entry fun submit_module_upgrade_plan<Token: copy, drop, store>(sender: signer, proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ + + +## Function `execute_module_upgrade_plan_propose` + +Execute module upgrade plan propose by submit module upgrade plan, the propose must been agreed, and anyone can execute this function. + + +
public entry fun execute_module_upgrade_plan_propose<Token: copy, drop, store>(_sender: signer, proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `submit_upgrade_plan` + +Directly submit a upgrade plan, the sender's module upgrade plan must been PackageTxnManager::STRATEGY_TWO_PHASE and have UpgradePlanCapability + + +
public entry fun submit_upgrade_plan(sender: signer, package_hash: vector<u8>, version: u64, enforced: bool)
+
+ + + +
+Implementation + + +
public entry fun submit_upgrade_plan(sender: signer, package_hash: vector<u8>, version:u64, enforced: bool) {
+    PackageTxnManager::submit_upgrade_plan_v2(&sender, package_hash, version, enforced);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `cancel_upgrade_plan` + +Cancel current upgrade plan, the sender must have UpgradePlanCapability. + + +
public entry fun cancel_upgrade_plan(signer: signer)
+
+ + + +
+Implementation + + +
public entry fun cancel_upgrade_plan(
+    signer: signer,
+) {
+    PackageTxnManager::cancel_upgrade_plan(&signer);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_partial = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/NFT.md b/build/StarcoinFramework/docs/NFT.md new file mode 100644 index 00000000..b257544e --- /dev/null +++ b/build/StarcoinFramework/docs/NFT.md @@ -0,0 +1,104 @@ + + + +# Module `0x1::NFTGalleryScripts` + + + +- [Function `accept`](#0x1_NFTGalleryScripts_accept) +- [Function `transfer`](#0x1_NFTGalleryScripts_transfer) +- [Function `remove_empty_gallery`](#0x1_NFTGalleryScripts_remove_empty_gallery) +- [Module Specification](#@Module_Specification_0) + + +
use 0x1::NFTGallery;
+
+ + + + + +## Function `accept` + +Init a NFTGallery for accept NFT + + +
public entry fun accept<NFTMeta: copy, drop, store, NFTBody: store>(sender: signer)
+
+ + + +
+Implementation + + +
public entry fun accept<NFTMeta: copy + store + drop, NFTBody: store>(sender: signer) {
+    NFTGallery::accept_entry<NFTMeta, NFTBody>(sender);
+}
+
+ + + +
+ + + +## Function `transfer` + +Transfer NFT with id from sender to receiver + + +
public entry fun transfer<NFTMeta: copy, drop, store, NFTBody: store>(sender: signer, id: u64, receiver: address)
+
+ + + +
+Implementation + + +
public entry fun transfer<NFTMeta: copy + store + drop, NFTBody: store>(
+    sender: signer,
+    id: u64, receiver: address
+) {
+    NFTGallery::transfer_entry<NFTMeta, NFTBody>(sender, id, receiver);
+}
+
+ + + +
+ + + +## Function `remove_empty_gallery` + +Remove empty NFTGallery. + + +
public entry fun remove_empty_gallery<NFTMeta: copy, drop, store, NFTBody: store>(sender: signer)
+
+ + + +
+Implementation + + +
public entry fun remove_empty_gallery<NFTMeta: copy + store + drop, NFTBody: store>(sender: signer) {
+    NFTGallery::remove_empty_gallery_entry<NFTMeta, NFTBody>(sender);
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+
diff --git a/build/StarcoinFramework/docs/Offer.md b/build/StarcoinFramework/docs/Offer.md new file mode 100644 index 00000000..59f75057 --- /dev/null +++ b/build/StarcoinFramework/docs/Offer.md @@ -0,0 +1,305 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+offered: Offered +
+
+ +
+
+for: address +
+
+ +
+
+time_lock: u64 +
+
+ +
+
+ + +
+ + + +## Constants + + + + +An offer of the specified type for the account does not match + + +
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)
+
+ + + +
+Implementation + + +
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 });
+}
+
+ + + +
+ +
+Specification + + + +
include Timestamp::AbortsIfTimestampNotExists;
+aborts_if Timestamp::now_seconds() + lock_period > max_u64();
+aborts_if exists<Offer<Offered>>(Signer::address_of(account));
+
+ + + +
+ + + +## Function `redeem` + +Claim the value of type 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
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Returns true if an offer of type Offered exists at offer_address. + + +
public fun exists_at<Offered: store>(offer_address: address): bool
+
+ + + +
+Implementation + + +
public fun exists_at<Offered: store>(offer_address: address): bool {
+    exists<Offer<Offered>>(offer_address)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `address_of` + +Returns the address of the Offered type stored at offer_address. +Fails if no such Offer exists. + + +
public fun address_of<Offered: store>(offer_address: address): address
+
+ + + +
+Implementation + + +
public fun address_of<Offered: store>(offer_address: address): address acquires Offer {
+    borrow_global<Offer<Offered>>(offer_address).for
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Offer<Offered>>(offer_address);
+
+ + + +
+ + + +## Function `take_offer` + +Take Offer and put to signer's Collection. + + +
public entry fun take_offer<Offered: store>(signer: signer, offer_address: address)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = true;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/OnChainConfigDao.md b/build/StarcoinFramework/docs/OnChainConfigDao.md new file mode 100644 index 00000000..1fc075ec --- /dev/null +++ b/build/StarcoinFramework/docs/OnChainConfigDao.md @@ -0,0 +1,257 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+cap: Config::ModifyConfigCapability<ConfigT> +
+
+ +
+
+ + +
+ + + +## Struct `OnChainConfigUpdate` + +request of updating configuration. + + +
struct OnChainConfigUpdate<ConfigT: copy, drop, store> has copy, drop, store
+
+ + + +
+Fields + + +
+
+value: ConfigT +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma aborts_if_is_partial = false;
+let sender = Signer::address_of(signer);
+aborts_if sender != Token::SPEC_TOKEN_TEST_ADDRESS();
+include Config::AbortsIfCapNotExist<ConfigT>{address: sender};
+aborts_if exists<WrappedConfigModifyCapability<TokenT, ConfigT>>(sender);
+ensures exists<WrappedConfigModifyCapability<TokenT, ConfigT>>(sender);
+
+ + + +
+ + + +## Function `propose_update` + +issue a proposal to update config of ConfigT goved by TokenT + + +
public fun propose_update<TokenT: copy, drop, store, ConfigT: copy, drop, store>(signer: &signer, new_config: ConfigT, exec_delay: u64)
+
+ + + +
+Implementation + + +
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,
+    );
+}
+
+ + + +
+ +
+Specification + + + +
pragma aborts_if_is_partial = false;
+include Dao::AbortIfDaoConfigNotExist<TokenT>;
+include Dao::AbortIfDaoInfoNotExist<TokenT>;
+aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::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` + +Once the proposal is agreed, anyone can call the method to make the proposal happen. +Caller need to make sure that the proposal of 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)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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());
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict;
+pragma aborts_if_is_partial;
+
diff --git a/build/StarcoinFramework/docs/OnChainConfigScripts.md b/build/StarcoinFramework/docs/OnChainConfigScripts.md new file mode 100644 index 00000000..f2072a84 --- /dev/null +++ b/build/StarcoinFramework/docs/OnChainConfigScripts.md @@ -0,0 +1,378 @@ + + + +# 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) + + +
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 entry 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)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `propose_update_reward_config` + + + +
public entry fun propose_update_reward_config(account: signer, reward_delay: u64, exec_delay: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `propose_update_txn_publish_option` + + + +
public entry fun propose_update_txn_publish_option(account: signer, script_allowed: bool, module_publishing_allowed: bool, exec_delay: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `propose_update_txn_timeout_config` + + + +
public entry fun propose_update_txn_timeout_config(account: signer, duration_seconds: u64, exec_delay: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `propose_update_vm_config` + + + +
public entry 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)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `propose_update_move_language_version` + + + +
public entry fun propose_update_move_language_version(account: signer, new_version: u64, exec_delay: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `execute_on_chain_config_proposal` + + + +
public entry fun execute_on_chain_config_proposal<ConfigT: copy, drop, store>(account: signer, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `execute_on_chain_config_proposal_v2` + + + +
public entry fun execute_on_chain_config_proposal_v2<TokenType: copy, drop, store, ConfigT: copy, drop, store>(proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
diff --git a/build/StarcoinFramework/docs/Option.md b/build/StarcoinFramework/docs/Option.md new file mode 100644 index 00000000..4f518c53 --- /dev/null +++ b/build/StarcoinFramework/docs/Option.md @@ -0,0 +1,787 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + - [Helper Schema](#@Helper_Schema_2) + + +
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
+
+ + + +
+Fields + + +
+
+vec: vector<Element> +
+
+ +
+
+ + +
+ +
+Specification + + +The size of vector is always less than equal to 1 +because it's 0 for "none" or 1 for "some". + + +
invariant len(vec) <= 1;
+
+ + + +
+ + + +## Constants + + + + +The Option is in an invalid state for the operation attempted. +The Option is Some while it should be None. + + +
const EOPTION_IS_SET: u64 = 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>
+
+ + + +
+Implementation + + +
public fun none<Element>(): Option<Element> {
+    Option { vec: Vector::empty() }
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if false;
+ensures result == spec_none<Element>();
+
+ + + + + + + +
fun spec_none<Element>(): Option<Element> {
+   Option{ vec: vec() }
+}
+
+ + + +
+ + + +## Function `some` + +Return an Option containing e + + +
public fun some<Element>(e: Element): Option::Option<Element>
+
+ + + +
+Implementation + + +
public fun some<Element>(e: Element): Option<Element> {
+    Option { vec: Vector::singleton(e) }
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Return true if t does not hold a value + + +
public fun is_none<Element>(t: &Option::Option<Element>): bool
+
+ + + +
+Implementation + + +
public fun is_none<Element>(t: &Option<Element>): bool {
+    Vector::is_empty(&t.vec)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if false;
+ensures result == is_none(t);
+
+ + + +
+ + + +## Function `is_some` + +Return true if t holds a value + + +
public fun is_some<Element>(t: &Option::Option<Element>): bool
+
+ + + +
+Implementation + + +
public fun is_some<Element>(t: &Option<Element>): bool {
+    !Vector::is_empty(&t.vec)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if false;
+ensures result == is_some(t);
+
+ + + +
+ + + +## Function `contains` + +Return true if the value in 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
+
+ + + +
+Implementation + + +
public fun contains<Element>(t: &Option<Element>, e_ref: &Element): bool {
+    Vector::contains(&t.vec, e_ref)
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Return an immutable reference to the value inside t +Aborts if t does not hold a value + + +
public fun borrow<Element>(t: &Option::Option<Element>): &Element
+
+ + + +
+Implementation + + +
public fun borrow<Element>(t: &Option<Element>): &Element {
+    assert!(is_some(t), Errors::invalid_argument(EOPTION_NOT_SET));
+    Vector::borrow(&t.vec, 0)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+include AbortsIfNone<Element>;
+ensures result == borrow(t);
+
+ + + +
+ + + +## Function `borrow_with_default` + +Return a reference to the value inside 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
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if false;
+ensures result == (if (is_some(t)) borrow(t) else default_ref);
+
+ + + +
+ + + +## Function `get_with_default` + +Return the value inside 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
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if false;
+ensures result == (if (is_some(t)) borrow(t) else default);
+
+ + + +
+ + + +## Function `fill` + +Convert the none option 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)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if is_some(t) with Errors::INVALID_ARGUMENT;
+ensures is_some(t);
+ensures borrow(t) == e;
+
+ + + +
+ + + +## Function `extract` + +Convert a 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
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+include AbortsIfNone<Element>;
+ensures result == borrow(old(t));
+ensures is_none(t);
+
+ + + +
+ + + +## Function `borrow_mut` + +Return a mutable reference to the value inside t +Aborts if t does not hold a value + + +
public fun borrow_mut<Element>(t: &mut Option::Option<Element>): &mut Element
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+include AbortsIfNone<Element>;
+ensures result == borrow(t);
+
+ + + +
+ + + +## Function `swap` + +Swap the old value inside 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
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+include AbortsIfNone<Element>;
+ensures result == borrow(old(t));
+ensures is_some(t);
+ensures borrow(t) == e;
+
+ + + +
+ + + +## Function `destroy_with_default` + +Destroys 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
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if false;
+ensures result == (if (is_some(t)) borrow(t) else default);
+
+ + + +
+ + + +## Function `destroy_some` + +Unpack t and return its contents +Aborts if t does not hold a value + + +
public fun destroy_some<Element>(t: Option::Option<Element>): Element
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+include AbortsIfNone<Element>;
+ensures result == borrow(t);
+
+ + + +
+ + + +## Function `destroy_none` + +Unpack t +Aborts if t holds a value + + +
public fun destroy_none<Element>(t: Option::Option<Element>)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if is_some(t) with Errors::INVALID_ARGUMENT;
+
+ + + +
+ + + +## Module Specification + + + + +
pragma aborts_if_is_strict;
+
+ + + + + +### Helper Schema + + + + + + +
schema AbortsIfNone<Element> {
+    t: Option<Element>;
+    aborts_if is_none(t) with Errors::INVALID_ARGUMENT;
+}
+
diff --git a/build/StarcoinFramework/docs/Oracle.md b/build/StarcoinFramework/docs/Oracle.md new file mode 100644 index 00000000..b3dcdb3b --- /dev/null +++ b/build/StarcoinFramework/docs/Oracle.md @@ -0,0 +1,88 @@ + + + +# 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 entry fun register_oracle<OracleT: copy, drop, store>(sender: signer, precision: u8)
+
+ + + +
+Implementation + + +
public entry fun register_oracle<OracleT: copy+store+drop>(sender: signer, precision: u8){
+    PriceOracle::register_oracle_entry<OracleT>(sender, precision);
+}
+
+ + + +
+ + + +## Function `init_data_source` + + + +
public entry fun init_data_source<OracleT: copy, drop, store>(sender: signer, init_value: u128)
+
+ + + +
+Implementation + + +
public entry fun init_data_source<OracleT: copy+store+drop>(sender: signer, init_value: u128){
+    PriceOracle::init_data_source_entry<OracleT>(sender, init_value);
+}
+
+ + + +
+ + + +## Function `update` + + + +
public entry fun update<OracleT: copy, drop, store>(sender: signer, value: u128)
+
+ + + +
+Implementation + + +
public entry fun update<OracleT: copy+store+drop>(sender: signer, value: u128){
+    PriceOracle::update_entry<OracleT>(sender, value);
+}
+
+ + + +
diff --git a/build/StarcoinFramework/docs/PackageTxnManager.md b/build/StarcoinFramework/docs/PackageTxnManager.md new file mode 100644 index 00000000..328505ed --- /dev/null +++ b/build/StarcoinFramework/docs/PackageTxnManager.md @@ -0,0 +1,1454 @@ + + + +# Module `0x1::PackageTxnManager` + +The module provides strategies for module upgrading. + + +- [Struct `UpgradePlan`](#0x1_PackageTxnManager_UpgradePlan) +- [Resource `UpgradePlanCapability`](#0x1_PackageTxnManager_UpgradePlanCapability) +- [Struct `UpgradePlanV2`](#0x1_PackageTxnManager_UpgradePlanV2) +- [Resource `ModuleUpgradeStrategy`](#0x1_PackageTxnManager_ModuleUpgradeStrategy) +- [Resource `TwoPhaseUpgrade`](#0x1_PackageTxnManager_TwoPhaseUpgrade) +- [Struct `TwoPhaseUpgradeConfig`](#0x1_PackageTxnManager_TwoPhaseUpgradeConfig) +- [Resource `TwoPhaseUpgradeV2`](#0x1_PackageTxnManager_TwoPhaseUpgradeV2) +- [Struct `UpgradeEvent`](#0x1_PackageTxnManager_UpgradeEvent) +- [Constants](#@Constants_0) +- [Function `get_strategy_arbitrary`](#0x1_PackageTxnManager_get_strategy_arbitrary) +- [Function `get_strategy_two_phase`](#0x1_PackageTxnManager_get_strategy_two_phase) +- [Function `get_strategy_new_module`](#0x1_PackageTxnManager_get_strategy_new_module) +- [Function `get_strategy_freeze`](#0x1_PackageTxnManager_get_strategy_freeze) +- [Function `get_default_min_time_limit`](#0x1_PackageTxnManager_get_default_min_time_limit) +- [Function `update_module_upgrade_strategy`](#0x1_PackageTxnManager_update_module_upgrade_strategy) +- [Function `account_address`](#0x1_PackageTxnManager_account_address) +- [Function `destroy_upgrade_plan_cap`](#0x1_PackageTxnManager_destroy_upgrade_plan_cap) +- [Function `extract_submit_upgrade_plan_cap`](#0x1_PackageTxnManager_extract_submit_upgrade_plan_cap) +- [Function `convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2`](#0x1_PackageTxnManager_convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2) +- [Function `submit_upgrade_plan_v2`](#0x1_PackageTxnManager_submit_upgrade_plan_v2) +- [Function `submit_upgrade_plan_with_cap_v2`](#0x1_PackageTxnManager_submit_upgrade_plan_with_cap_v2) +- [Function `cancel_upgrade_plan`](#0x1_PackageTxnManager_cancel_upgrade_plan) +- [Function `cancel_upgrade_plan_with_cap`](#0x1_PackageTxnManager_cancel_upgrade_plan_with_cap) +- [Function `get_module_upgrade_strategy`](#0x1_PackageTxnManager_get_module_upgrade_strategy) +- [Function `get_upgrade_plan`](#0x1_PackageTxnManager_get_upgrade_plan) +- [Function `get_upgrade_plan_v2`](#0x1_PackageTxnManager_get_upgrade_plan_v2) +- [Function `check_package_txn`](#0x1_PackageTxnManager_check_package_txn) +- [Function `check_package_txn_v2`](#0x1_PackageTxnManager_check_package_txn_v2) +- [Function `finish_upgrade_plan`](#0x1_PackageTxnManager_finish_upgrade_plan) +- [Function `package_txn_prologue`](#0x1_PackageTxnManager_package_txn_prologue) +- [Function `package_txn_prologue_v2`](#0x1_PackageTxnManager_package_txn_prologue_v2) +- [Function `package_txn_epilogue`](#0x1_PackageTxnManager_package_txn_epilogue) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+package_hash: vector<u8> +
+
+ +
+
+active_after_time: u64 +
+
+ +
+
+version: u64 +
+
+ +
+
+ + +
+ + + +## Resource `UpgradePlanCapability` + +The holder of UpgradePlanCapability for account_address can submit UpgradePlan for account_address. + + +
struct UpgradePlanCapability has store, key
+
+ + + +
+Fields + + +
+
+account_address: address +
+
+ +
+
+ + +
+ + + +## Struct `UpgradePlanV2` + + + +
struct UpgradePlanV2 has copy, drop, store
+
+ + + +
+Fields + + +
+
+package_hash: vector<u8> +
+
+ +
+
+active_after_time: u64 +
+
+ +
+
+version: u64 +
+
+ +
+
+enforced: bool +
+
+ +
+
+ + +
+ + + +## Resource `ModuleUpgradeStrategy` + +module upgrade strategy + + +
struct ModuleUpgradeStrategy has store, key
+
+ + + +
+Fields + + +
+
+strategy: u8 +
+
+ 0 arbitrary + 1 two phase upgrade + 2 only new module + 3 freeze +
+
+ + +
+ + + +## Resource `TwoPhaseUpgrade` + +data of two phase upgrade strategy. + + +
struct TwoPhaseUpgrade has key
+
+ + + +
+Fields + + +
+
+config: PackageTxnManager::TwoPhaseUpgradeConfig +
+
+ +
+
+plan: Option::Option<PackageTxnManager::UpgradePlan> +
+
+ +
+
+version_cap: Config::ModifyConfigCapability<Version::Version> +
+
+ +
+
+upgrade_event: Event::EventHandle<PackageTxnManager::UpgradeEvent> +
+
+ +
+
+ + +
+ + + +## Struct `TwoPhaseUpgradeConfig` + +config of two phase upgrade strategy. + + +
struct TwoPhaseUpgradeConfig has copy, drop, store
+
+ + + +
+Fields + + +
+
+min_time_limit: u64 +
+
+ +
+
+ + +
+ + + +## Resource `TwoPhaseUpgradeV2` + +data of two phase upgrade strategy. + + +
struct TwoPhaseUpgradeV2 has key
+
+ + + +
+Fields + + +
+
+config: PackageTxnManager::TwoPhaseUpgradeConfig +
+
+ +
+
+plan: Option::Option<PackageTxnManager::UpgradePlanV2> +
+
+ +
+
+version_cap: Config::ModifyConfigCapability<Version::Version> +
+
+ +
+
+upgrade_event: Event::EventHandle<PackageTxnManager::UpgradeEvent> +
+
+ +
+
+ + +
+ + + +## Struct `UpgradeEvent` + +module upgrade event. + + +
struct UpgradeEvent has drop, store
+
+ + + +
+Fields + + +
+
+package_address: address +
+
+ +
+
+package_hash: vector<u8> +
+
+ +
+
+version: u64 +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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
+
+ + + +
+Implementation + + +
public fun get_strategy_arbitrary(): u8 { STRATEGY_ARBITRARY }
+
+ + + +
+ + + +## Function `get_strategy_two_phase` + +two phase stragegy + + +
public fun get_strategy_two_phase(): u8
+
+ + + +
+Implementation + + +
public fun get_strategy_two_phase(): u8 { STRATEGY_TWO_PHASE }
+
+ + + +
+ + + +## Function `get_strategy_new_module` + +new module strategy + + +
public fun get_strategy_new_module(): u8
+
+ + + +
+Implementation + + +
public fun get_strategy_new_module(): u8 { STRATEGY_NEW_MODULE }
+
+ + + +
+ + + +## Function `get_strategy_freeze` + +freezed strategy + + +
public fun get_strategy_freeze(): u8
+
+ + + +
+Implementation + + +
public fun get_strategy_freeze(): u8 { STRATEGY_FREEZE }
+
+ + + +
+ + + +## Function `get_default_min_time_limit` + +default min time limit + + +
public fun get_default_min_time_limit(): u64
+
+ + + +
+Implementation + + +
public fun get_default_min_time_limit(): u64 { DEFAULT_MIN_TIME_LIMIT }
+
+ + + +
+ + + +## Function `update_module_upgrade_strategy` + +Update account's ModuleUpgradeStrategy + + +
public fun update_module_upgrade_strategy(account: &signer, strategy: u8, min_time: Option::Option<u64>)
+
+ + + +
+Implementation + + +
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);
+        };
+    };
+}
+
+ + + +
+ +
+Specification + + + +
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 `account_address` + +Get account address of UpgradePlanCapability + + +
public fun account_address(cap: &PackageTxnManager::UpgradePlanCapability): address
+
+ + + +
+Implementation + + +
public fun account_address(cap: &UpgradePlanCapability): address {
+    cap.account_address
+}
+
+ + + +
+ + + +## Function `destroy_upgrade_plan_cap` + +destroy the given UpgradePlanCapability + + +
public fun destroy_upgrade_plan_cap(cap: PackageTxnManager::UpgradePlanCapability)
+
+ + + +
+Implementation + + +
public fun destroy_upgrade_plan_cap(cap: UpgradePlanCapability){
+    let UpgradePlanCapability{account_address:_} = cap;
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `extract_submit_upgrade_plan_cap` + +extract out UpgradePlanCapability from signer. + + +
public fun extract_submit_upgrade_plan_cap(account: &signer): PackageTxnManager::UpgradePlanCapability
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
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 entry fun convert_TwoPhaseUpgrade_to_TwoPhaseUpgradeV2(account: signer, package_address: address)
+
+ + + +
+Implementation + + +
public entry 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
+        });
+    };
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `submit_upgrade_plan_v2` + + + +
public fun submit_upgrade_plan_v2(account: &signer, package_hash: vector<u8>, version: u64, enforced: bool)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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)
+
+ + + +
+Implementation + + +
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 });
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Cancel a module upgrade plan. + + +
public fun cancel_upgrade_plan(account: &signer)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Cancel a module upgrade plan with given cap. + + +
public fun cancel_upgrade_plan_with_cap(cap: &PackageTxnManager::UpgradePlanCapability)
+
+ + + +
+Implementation + + +
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>();
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Get module upgrade strategy of an module address. + + +
public fun get_module_upgrade_strategy(module_address: address): u8
+
+ + + +
+Implementation + + +
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
+    }
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Get module upgrade plan of an address. + + +
public fun get_upgrade_plan(_module_address: address): Option::Option<PackageTxnManager::UpgradePlan>
+
+ + + +
+Implementation + + +
public fun get_upgrade_plan(_module_address: address): Option<UpgradePlan> {
+    // DEPRECATED_CODE
+    Option::none<UpgradePlan>()
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `get_upgrade_plan_v2` + +Get module upgrade plan of an address. + + +
public fun get_upgrade_plan_v2(module_address: address): Option::Option<PackageTxnManager::UpgradePlanV2>
+
+ + + +
+Implementation + + +
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>()
+    }
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Check againest on the given package data. + + +
public fun check_package_txn(package_address: address, package_hash: vector<u8>)
+
+ + + +
+Implementation + + +
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){
+        Errors::invalid_argument(ESTRATEGY_FREEZED);
+    };
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+include CheckPackageTxnAbortsIf;
+
+ + + +
+ + + +## Function `check_package_txn_v2` + + + +
public fun check_package_txn_v2(txn_sender: address, package_address: address, package_hash: vector<u8>)
+
+ + + +
+Implementation + + +
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){
+        Errors::invalid_argument(ESTRATEGY_FREEZED);
+    };
+}
+
+ + + +
+ + + +## Function `finish_upgrade_plan` + + + +
fun finish_upgrade_plan(package_address: address)
+
+ + + +
+Implementation + + +
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>();
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Prologue of package transaction. + + +
public fun package_txn_prologue(account: &signer, package_address: address, package_hash: vector<u8>)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+include CheckPackageTxnAbortsIf{};
+
+ + + +
+ + + +## Function `package_txn_prologue_v2` + + + +
public fun package_txn_prologue_v2(account: &signer, txn_sender: address, package_address: address, package_hash: vector<u8>)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ + + +## Function `package_txn_epilogue` + +Package txn finished, and clean UpgradePlan + + +
public fun package_txn_epilogue(account: &signer, _txn_sender: address, package_address: address, success: bool)
+
+ + + +
+Implementation + + +
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);
+        };
+    };
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Signer::address_of(account) != CoreAddresses::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);
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/README.md b/build/StarcoinFramework/docs/README.md new file mode 100644 index 00000000..4ef739e7 --- /dev/null +++ b/build/StarcoinFramework/docs/README.md @@ -0,0 +1,110 @@ + + + +# Move StarcoinFramework Modules + + +This is the root document for the Move StarcoinFramework module documentation. The Move StarcoinFramework provides modules that can be used to access or interact with Starcoin blockchain. + + + + +## Index + + +- [`0x1::ACL`](ACL.md#0x1_ACL) +- [`0x1::Account`](Account.md#0x1_Account) +- [`0x1::AccountScripts`](AccountScripts.md#0x1_AccountScripts) +- [`0x1::Arith`](U256.md#0x1_Arith) +- [`0x1::Authenticator`](Authenticator.md#0x1_Authenticator) +- [`0x1::BCS`](BCS.md#0x1_BCS) +- [`0x1::BitOperators`](Bitwise.md#0x1_BitOperators) +- [`0x1::Block`](Block.md#0x1_Block) +- [`0x1::BlockReward`](BlockReward.md#0x1_BlockReward) +- [`0x1::ChainId`](ChainId.md#0x1_ChainId) +- [`0x1::Collection`](Collection.md#0x1_Collection) +- [`0x1::Collection2`](Collection2.md#0x1_Collection2) +- [`0x1::Compare`](Compare.md#0x1_Compare) +- [`0x1::Config`](Config.md#0x1_Config) +- [`0x1::ConsensusConfig`](ConsensusConfig.md#0x1_ConsensusConfig) +- [`0x1::ConsensusStrategy`](ConsensusStrategy.md#0x1_ConsensusStrategy) +- [`0x1::CoreAddresses`](CoreAddresses.md#0x1_CoreAddresses) +- [`0x1::Dao`](Dao.md#0x1_Dao) +- [`0x1::DaoVoteScripts`](DaoVoteScripts.md#0x1_DaoVoteScripts) +- [`0x1::Debug`](Debug.md#0x1_Debug) +- [`0x1::DummyToken`](DummyToken.md#0x1_DummyToken) +- [`0x1::DummyTokenScripts`](DummyToken.md#0x1_DummyTokenScripts) +- [`0x1::EVMAddress`](Signature.md#0x1_EVMAddress) +- [`0x1::EasyGasOracle`](EasyGas.md#0x1_EasyGasOracle) +- [`0x1::EasyGasOracleScript`](EasyGas.md#0x1_EasyGasOracleScript) +- [`0x1::EmptyScripts`](EmptyScripts.md#0x1_EmptyScripts) +- [`0x1::Epoch`](Epoch.md#0x1_Epoch) +- [`0x1::Errors`](Errors.md#0x1_Errors) +- [`0x1::Event`](Event.md#0x1_Event) +- [`0x1::EventUtil`](EventUtil.md#0x1_EventUtil) +- [`0x1::FixedPoint32`](FixedPoint32.md#0x1_FixedPoint32) +- [`0x1::FromBCS`](FromBCS.md#0x1_FromBCS) +- [`0x1::GasSchedule`](GasSchedule.md#0x1_GasSchedule) +- [`0x1::Genesis`](Genesis.md#0x1_Genesis) +- [`0x1::GenesisNFT`](GenesisNFT.md#0x1_GenesisNFT) +- [`0x1::GenesisNFTScripts`](GenesisNFT.md#0x1_GenesisNFTScripts) +- [`0x1::GenesisSignerCapability`](GenesisSignerCapability.md#0x1_GenesisSignerCapability) +- [`0x1::Hash`](Hash.md#0x1_Hash) +- [`0x1::IdentifierNFT`](NFT.md#0x1_IdentifierNFT) +- [`0x1::IdentifierNFTScripts`](NFT.md#0x1_IdentifierNFTScripts) +- [`0x1::LanguageVersion`](LanguageVersion.md#0x1_LanguageVersion) +- [`0x1::Math`](Math.md#0x1_Math) +- [`0x1::MerkleNFTDistributor`](MerkleNFT.md#0x1_MerkleNFTDistributor) +- [`0x1::MerkleProof`](MerkleNFT.md#0x1_MerkleProof) +- [`0x1::MintDaoProposal`](MintDaoProposal.md#0x1_MintDaoProposal) +- [`0x1::MintScripts`](MintScripts.md#0x1_MintScripts) +- [`0x1::ModifyDaoConfigProposal`](ModifyDaoConfigProposal.md#0x1_ModifyDaoConfigProposal) +- [`0x1::ModuleUpgradeScripts`](ModuleUpgradeScripts.md#0x1_ModuleUpgradeScripts) +- [`0x1::NFT`](NFT.md#0x1_NFT) +- [`0x1::NFTGallery`](NFT.md#0x1_NFTGallery) +- [`0x1::NFTGalleryScripts`](NFT.md#0x1_NFTGalleryScripts) +- [`0x1::Offer`](Offer.md#0x1_Offer) +- [`0x1::OnChainConfigDao`](OnChainConfigDao.md#0x1_OnChainConfigDao) +- [`0x1::OnChainConfigScripts`](OnChainConfigScripts.md#0x1_OnChainConfigScripts) +- [`0x1::Option`](Option.md#0x1_Option) +- [`0x1::Oracle`](Oracle.md#0x1_Oracle) +- [`0x1::PackageTxnManager`](PackageTxnManager.md#0x1_PackageTxnManager) +- [`0x1::PriceOracle`](Oracle.md#0x1_PriceOracle) +- [`0x1::PriceOracleAggregator`](Oracle.md#0x1_PriceOracleAggregator) +- [`0x1::PriceOracleScripts`](Oracle.md#0x1_PriceOracleScripts) +- [`0x1::RewardConfig`](RewardConfig.md#0x1_RewardConfig) +- [`0x1::Ring`](Ring.md#0x1_Ring) +- [`0x1::SIP_2`](SIPs.md#0x1_SIP_2) +- [`0x1::SIP_3`](SIPs.md#0x1_SIP_3) +- [`0x1::STC`](STC.md#0x1_STC) +- [`0x1::STCUSDOracle`](Oracle.md#0x1_STCUSDOracle) +- [`0x1::Secp256k1`](Secp256k1.md#0x1_Secp256k1) +- [`0x1::SharedEd25519PublicKey`](SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey) +- [`0x1::Signature`](Signature.md#0x1_Signature) +- [`0x1::SignedInteger64`](SignedInteger64.md#0x1_SignedInteger64) +- [`0x1::Signer`](Signer.md#0x1_Signer) +- [`0x1::SimpleMap`](SimpleMap.md#0x1_SimpleMap) +- [`0x1::StarcoinVerifier`](StarcoinVerifier.md#0x1_StarcoinVerifier) +- [`0x1::StdlibUpgradeScripts`](StdlibUpgradeScripts.md#0x1_StdlibUpgradeScripts) +- [`0x1::String`](String.md#0x1_String) +- [`0x1::StructuredHash`](StarcoinVerifier.md#0x1_StructuredHash) +- [`0x1::Table`](Table.md#0x1_Table) +- [`0x1::Timestamp`](Timestamp.md#0x1_Timestamp) +- [`0x1::Token`](Token.md#0x1_Token) +- [`0x1::TransactionFee`](TransactionFee.md#0x1_TransactionFee) +- [`0x1::TransactionManager`](TransactionManager.md#0x1_TransactionManager) +- [`0x1::TransactionPublishOption`](TransactionPublishOption.md#0x1_TransactionPublishOption) +- [`0x1::TransactionTimeout`](TransactionTimeout.md#0x1_TransactionTimeout) +- [`0x1::TransactionTimeoutConfig`](TransactionTimeoutConfig.md#0x1_TransactionTimeoutConfig) +- [`0x1::TransferScripts`](TransferScripts.md#0x1_TransferScripts) +- [`0x1::Treasury`](Treasury.md#0x1_Treasury) +- [`0x1::TreasuryScripts`](TreasuryScripts.md#0x1_TreasuryScripts) +- [`0x1::TreasuryWithdrawDaoProposal`](TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal) +- [`0x1::TypeInfo`](TypeInfo.md#0x1_TypeInfo) +- [`0x1::U256`](U256.md#0x1_U256) +- [`0x1::UpgradeModuleDaoProposal`](UpgradeModuleDaoProposal.md#0x1_UpgradeModuleDaoProposal) +- [`0x1::VMConfig`](VMConfig.md#0x1_VMConfig) +- [`0x1::Vector`](Vector.md#0x1_Vector) +- [`0x1::Version`](Version.md#0x1_Version) +- [`0x1::YieldFarming`](YieldFarming.md#0x1_YieldFarming) +- [`0x1::YieldFarmingV2`](YieldFarmingV2.md#0x1_YieldFarmingV2) diff --git a/build/StarcoinFramework/docs/RewardConfig.md b/build/StarcoinFramework/docs/RewardConfig.md new file mode 100644 index 00000000..4c300f5d --- /dev/null +++ b/build/StarcoinFramework/docs/RewardConfig.md @@ -0,0 +1,240 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::Config;
+use 0x1::CoreAddresses;
+use 0x1::Timestamp;
+
+ + + + + +## Struct `RewardConfig` + +Reward configuration + + +
struct RewardConfig has copy, drop, store
+
+ + + +
+Fields + + +
+
+reward_delay: u64 +
+
+ how many blocks delay reward distribution. +
+
+ + +
+ + + +## Constants + + + + + + +
const EINVALID_ARGUMENT: u64 = 18;
+
+ + + + + +## Function `initialize` + +Module initialization. + + +
public fun initialize(account: &signer, reward_delay: u64)
+
+ + + +
+Implementation + + +
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)
+    );
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Create a new reward config mainly used in DAO. + + +
public fun new_reward_config(reward_delay: u64): RewardConfig::RewardConfig
+
+ + + +
+Implementation + + +
public fun new_reward_config(reward_delay: u64) : RewardConfig {
+    RewardConfig {reward_delay: reward_delay}
+}
+
+ + + +
+ +
+Specification + + + +
+ + + +## Function `get_reward_config` + +Get reward configuration. + + +
public fun get_reward_config(): RewardConfig::RewardConfig
+
+ + + +
+Implementation + + +
public fun get_reward_config(): RewardConfig {
+    Config::get_by_address<RewardConfig>(CoreAddresses::GENESIS_ADDRESS())
+}
+
+ + + +
+ +
+Specification + + + +
include GetRewardConfigAbortsIf;
+
+ + + + + + + +
schema GetRewardConfigAbortsIf {
+    aborts_if !exists<Config::Config<RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());
+}
+
+ + + +
+ + + +## Function `reward_delay` + +Get reward delay. + + +
public fun reward_delay(): u64
+
+ + + +
+Implementation + + +
public fun reward_delay() :u64 {
+    let reward_config = get_reward_config();
+    reward_config.reward_delay
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Config::Config<RewardConfig>>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/Ring.md b/build/StarcoinFramework/docs/Ring.md new file mode 100644 index 00000000..074de19a --- /dev/null +++ b/build/StarcoinFramework/docs/Ring.md @@ -0,0 +1,426 @@ + + + +# Module `0x1::Ring` + +A ring-shaped container that can hold any type, indexed from 0 +The capacity is fixed at creation time, and the accessible index is constantly growing + + +- [Struct `Ring`](#0x1_Ring_Ring) +- [Constants](#@Constants_0) +- [Function `create_with_capacity`](#0x1_Ring_create_with_capacity) +- [Function `is_full`](#0x1_Ring_is_full) +- [Function `capacity`](#0x1_Ring_capacity) +- [Function `push`](#0x1_Ring_push) +- [Function `borrow`](#0x1_Ring_borrow) +- [Function `borrow_mut`](#0x1_Ring_borrow_mut) +- [Function `index_of`](#0x1_Ring_index_of) +- [Function `destroy`](#0x1_Ring_destroy) + + +
use 0x1::Errors;
+use 0x1::Option;
+
+ + + + + +## Struct `Ring` + + + +
struct Ring<Element> has store
+
+ + + +
+Fields + + +
+
+data: vector<Option::Option<Element>> +
+
+ +
+
+insertion_index: u64 +
+
+ +
+
+external_index: u64 +
+
+ +
+
+ + +
+ + + +## Constants + + + + +The index into the vector is out of bounds + + +
const ERROR_RING_INDEX_OUT_OF_BOUNDS: u64 = 101;
+
+ + + + + +## Function `create_with_capacity` + +Create a Ring with capacity. + + +
public fun create_with_capacity<Element>(len: u64): Ring::Ring<Element>
+
+ + + +
+Implementation + + +
public fun create_with_capacity<Element>( len: u64 ):Ring<Element>{
+    let data = Vector::empty<Option::Option<Element>>();
+    let i = 0;
+    while(i < len){
+        Vector::push_back(&mut data , Option::none<Element>());
+        i = i + 1;
+    };
+    Ring {
+        data             : data,
+        insertion_index  : 0,
+        external_index   : 0,
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `is_full` + +is Ring full + + +
public fun is_full<Element>(r: &Ring::Ring<Element>): bool
+
+ + + +
+Implementation + + +
public fun is_full<Element>(r: &Ring<Element>):bool{
+    Option::is_some(Vector::borrow(&r.data, r.insertion_index))
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `capacity` + +Return the capacity of the Ring. + + +
public fun capacity<Element>(r: &Ring::Ring<Element>): u64
+
+ + + +
+Implementation + + +
public fun capacity<Element>(r: &Ring<Element>): u64{
+    Vector::length( &r.data )
+}
+
+ + + +
+ +
+Specification + + + +
+ + + +## Function `push` + +Add element e to the insertion_index of the Ring r. + + +
public fun push<Element>(r: &mut Ring::Ring<Element>, e: Element): Option::Option<Element>
+
+ + + +
+Implementation + + +
public fun push<Element> (r: &mut Ring<Element> , e: Element):Option::Option<Element>{
+    let op_e = Vector::borrow_mut<Option::Option<Element>>(&mut r.data, r.insertion_index);
+    let res = if(  Option::is_none<Element>(op_e) ){
+        Option::fill( op_e, e);
+        Option::none<Element>()
+    }else{
+       Option::some<Element>( Option::swap( op_e, e) )
+    };
+    r.insertion_index = ( r.insertion_index + 1 ) % Vector::length(&r.data);
+    r.external_index = r.external_index + 1;
+    res
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `borrow` + +Return a reference to the ith element in the Ring r. + + +
public fun borrow<Element>(r: &Ring::Ring<Element>, i: u64): &Option::Option<Element>
+
+ + + +
+Implementation + + +
public fun borrow<Element>(r:& Ring<Element>, i: u64):&Option::Option<Element>{
+    let len = capacity<Element>(r);
+    if( r.external_index > len - 1) {
+        assert!( i >= r.external_index - len && i < r.external_index , Errors::invalid_argument(ERROR_RING_INDEX_OUT_OF_BOUNDS));
+        Vector::borrow(&r.data, i % len)
+    }else {
+        assert!( i < len , Errors::invalid_argument(ERROR_RING_INDEX_OUT_OF_BOUNDS));
+        Vector::borrow(&r.data, i )
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `borrow_mut` + +Return a mutable reference to the ith element in the Ring r. + + +
public fun borrow_mut<Element>(r: &mut Ring::Ring<Element>, i: u64): &mut Option::Option<Element>
+
+ + + +
+Implementation + + +
public fun borrow_mut<Element>(r: &mut Ring<Element>, i: u64):&mut Option::Option<Element>{
+    let len = capacity<Element>(r);
+    if( r.external_index > len - 1) {
+        assert!( i >= r.external_index - len && i < r.external_index , Errors::invalid_argument(ERROR_RING_INDEX_OUT_OF_BOUNDS));
+        Vector::borrow_mut(&mut r.data, i % len)
+    }else {
+        assert!( i < len , Errors::invalid_argument(ERROR_RING_INDEX_OUT_OF_BOUNDS));
+        Vector::borrow_mut(&mut r.data, i )
+    }
+
+}
+
+ + + +
+ +
+Specification + + + +
+ + + +## Function `index_of` + +Return Option::Option<u64> if e is in the Ring r at index i. +Otherwise, returns Option::none<u64>. + + +
public fun index_of<Element>(r: &Ring::Ring<Element>, e: &Element): Option::Option<u64>
+
+ + + +
+Implementation + + +
public fun index_of<Element>(r: &Ring<Element>, e: &Element):Option::Option<u64>{
+    let i = 0;
+    let len = capacity<Element>(r);
+    while ( i < len ) {
+        if ( Option::borrow(Vector::borrow( &r.data, i )) == e) return Option::some(i + r.external_index - len);
+        i = i + 1;
+    };
+    Option::none<u64>()
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `destroy` + +Destroy the Ring r. +Returns the vector saved by ring + + +
public fun destroy<Element>(r: Ring::Ring<Element>): vector<Element>
+
+ + + +
+Implementation + + +
public fun destroy<Element>(r: Ring<Element>):vector<Element>{
+    let Ring {
+        data            : data ,
+        insertion_index : _,
+        external_index  : _,
+    } = r ;
+    let len = Vector::length(&data);
+    let i = 0;
+    let vec = Vector::empty<Element>();
+    while ( i < len ) {
+        let op_e = Vector::pop_back( &mut data );
+        if ( Option::is_some(&op_e) ) {
+            Vector::push_back(&mut vec, Option::destroy_some(op_e))
+        }else {
+           Option::destroy_none(op_e)
+        };
+        i = i + 1;
+    };
+    Vector::destroy_empty(data);
+    vec
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
diff --git a/build/StarcoinFramework/docs/SIPs.md b/build/StarcoinFramework/docs/SIPs.md new file mode 100644 index 00000000..b466bfe7 --- /dev/null +++ b/build/StarcoinFramework/docs/SIPs.md @@ -0,0 +1,11 @@ + + + +# Module `0x1::SIP_3` + +https://github.com/starcoinorg/SIPs/tree/master/sip-3 + + + + +
diff --git a/build/StarcoinFramework/docs/STC.md b/build/StarcoinFramework/docs/STC.md new file mode 100644 index 00000000..b22272d5 --- /dev/null +++ b/build/StarcoinFramework/docs/STC.md @@ -0,0 +1,403 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ + +
+ + + +## Resource `SharedBurnCapability` + +Burn capability of STC. + + +
struct SharedBurnCapability has store, key
+
+ + + +
+Fields + + +
+
+cap: Token::BurnCapability<STC::STC> +
+
+ +
+
+ + +
+ + + +## Constants + + + + +precision of STC token. + + +
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)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `initialize_v2` + +STC initialization. + + +
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>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
include Token::RegisterTokenAbortsIf<STC>{precision: PRECISION};
+
+ + + +
+ + + +## Function `is_stc` + +Returns true if TokenType is STC::STC + + +
public fun is_stc<TokenType: store>(): bool
+
+ + + +
+Implementation + + +
public fun is_stc<TokenType: store>(): bool {
+    Token::is_same_token<STC, TokenType>()
+}
+
+ + + +
+ +
+Specification + + + +
+ + + +## Function `burn` + +Burn STC tokens. +It can be called by anyone. + + +
public fun burn(token: Token::Token<STC::STC>)
+
+ + + +
+Implementation + + +
public fun burn(token: Token<STC>) acquires SharedBurnCapability {
+    let cap = borrow_global<SharedBurnCapability>(token_address());
+    Token::burn_with_capability(&cap.cap, token);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Token::spec_abstract_total_value<STC>() - token.value < 0;
+aborts_if !exists<SharedBurnCapability>(Token::SPEC_TOKEN_TEST_ADDRESS());
+
+ + + +
+ + + +## Function `token_address` + +Return STC token address. + + +
public fun token_address(): address
+
+ + + +
+Implementation + + +
public fun token_address(): address {
+    Token::token_address<STC>()
+}
+
+ + + +
+ +
+Specification + + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/Secp256k1.md b/build/StarcoinFramework/docs/Secp256k1.md new file mode 100644 index 00000000..bb6b5bbb --- /dev/null +++ b/build/StarcoinFramework/docs/Secp256k1.md @@ -0,0 +1,296 @@ + + + +# Module `0x1::Secp256k1` + +This module implements ECDSA signatures based on the prime-order secp256k1 ellptic curve (i.e., cofactor is 1). + + +- [Struct `ECDSARawPublicKey`](#0x1_Secp256k1_ECDSARawPublicKey) +- [Struct `ECDSASignature`](#0x1_Secp256k1_ECDSASignature) +- [Constants](#@Constants_0) +- [Function `ecdsa_signature_from_bytes`](#0x1_Secp256k1_ecdsa_signature_from_bytes) +- [Function `ecdsa_raw_public_key_from_64_bytes`](#0x1_Secp256k1_ecdsa_raw_public_key_from_64_bytes) +- [Function `ecdsa_raw_public_key_to_bytes`](#0x1_Secp256k1_ecdsa_raw_public_key_to_bytes) +- [Function `ecdsa_signature_to_bytes`](#0x1_Secp256k1_ecdsa_signature_to_bytes) +- [Function `ecdsa_recover`](#0x1_Secp256k1_ecdsa_recover) +- [Function `ecdsa_recover_internal`](#0x1_Secp256k1_ecdsa_recover_internal) + + +
use 0x1::Errors;
+use 0x1::Option;
+
+ + + + + +## Struct `ECDSARawPublicKey` + +A 64-byte ECDSA public key. + + +
struct ECDSARawPublicKey has copy, drop, store
+
+ + + +
+Fields + + +
+
+bytes: vector<u8> +
+
+ +
+
+ + +
+ + + +## Struct `ECDSASignature` + +A 64-byte ECDSA signature. + + +
struct ECDSASignature has copy, drop, store
+
+ + + +
+Fields + + +
+
+bytes: vector<u8> +
+
+ +
+
+ + +
+ + + +## Constants + + + + +An error occurred while deserializing, for example due to wrong input size. + + +
const E_DESERIALIZE: u64 = 1;
+
+ + + + + +The size of a secp256k1-based ECDSA public key, in bytes. + + +
const RAW_PUBLIC_KEY_NUM_BYTES: u64 = 64;
+
+ + + + + +The size of a secp256k1-based ECDSA signature, in bytes. + + +
const SIGNATURE_NUM_BYTES: u64 = 64;
+
+ + + + + +## Function `ecdsa_signature_from_bytes` + +Constructs an ECDSASignature struct from the given 64 bytes. + + +
public fun ecdsa_signature_from_bytes(bytes: vector<u8>): Secp256k1::ECDSASignature
+
+ + + +
+Implementation + + +
public fun ecdsa_signature_from_bytes(bytes: vector<u8>): ECDSASignature {
+    assert!(Vector::length(&bytes) == SIGNATURE_NUM_BYTES, Errors::invalid_argument(E_DESERIALIZE));
+    ECDSASignature { bytes }
+}
+
+ + + +
+ + + +## Function `ecdsa_raw_public_key_from_64_bytes` + +Constructs an ECDSARawPublicKey struct, given a 64-byte raw representation. + + +
public fun ecdsa_raw_public_key_from_64_bytes(bytes: vector<u8>): Secp256k1::ECDSARawPublicKey
+
+ + + +
+Implementation + + +
public fun ecdsa_raw_public_key_from_64_bytes(bytes: vector<u8>): ECDSARawPublicKey {
+    assert!(Vector::length(&bytes) == RAW_PUBLIC_KEY_NUM_BYTES, Errors::invalid_argument(E_DESERIALIZE));
+    ECDSARawPublicKey { bytes }
+}
+
+ + + +
+ + + +## Function `ecdsa_raw_public_key_to_bytes` + +Serializes an ECDSARawPublicKey struct to 64-bytes. + + +
public fun ecdsa_raw_public_key_to_bytes(pk: &Secp256k1::ECDSARawPublicKey): vector<u8>
+
+ + + +
+Implementation + + +
public fun ecdsa_raw_public_key_to_bytes(pk: &ECDSARawPublicKey): vector<u8> {
+    *&pk.bytes
+}
+
+ + + +
+ + + +## Function `ecdsa_signature_to_bytes` + +Serializes an ECDSASignature struct to 64-bytes. + + +
public fun ecdsa_signature_to_bytes(sig: &Secp256k1::ECDSASignature): vector<u8>
+
+ + + +
+Implementation + + +
public fun ecdsa_signature_to_bytes(sig: &ECDSASignature): vector<u8> {
+    *&sig.bytes
+}
+
+ + + +
+ + + +## Function `ecdsa_recover` + +Recovers the signer's raw (64-byte) public key from a secp256k1 ECDSA signature given the recovery_id and the signed +message (32 byte digest). + +Note that an invalid signature, or a signature from a different message, will result in the recovery of an +incorrect public key. This recovery algorithm can only be used to check validity of a signature if the signer's +public key (or its hash) is known beforehand. + + +
public fun ecdsa_recover(message: vector<u8>, recovery_id: u8, signature: &Secp256k1::ECDSASignature): Option::Option<Secp256k1::ECDSARawPublicKey>
+
+ + + +
+Implementation + + +
public fun ecdsa_recover(
+    message: vector<u8>,
+    recovery_id: u8,
+    signature: &ECDSASignature,
+): Option<ECDSARawPublicKey> {
+    let (pk, success) = ecdsa_recover_internal(message, recovery_id, *&signature.bytes);
+    if (success) {
+        Option::some(ecdsa_raw_public_key_from_64_bytes(pk))
+    } else {
+        Option::none<ECDSARawPublicKey>()
+    }
+}
+
+ + + +
+ + + +## Function `ecdsa_recover_internal` + +Returns (public_key, true) if signature verifies on message under the recovered public_key +and returns ([], false) otherwise. + + +
fun ecdsa_recover_internal(message: vector<u8>, recovery_id: u8, signature: vector<u8>): (vector<u8>, bool)
+
+ + + +
+Implementation + + +
native fun ecdsa_recover_internal(
+    message: vector<u8>,
+    recovery_id: u8,
+    signature: vector<u8>
+): (vector<u8>, bool);
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+
+ + + +
diff --git a/build/StarcoinFramework/docs/SharedEd25519PublicKey.md b/build/StarcoinFramework/docs/SharedEd25519PublicKey.md new file mode 100644 index 00000000..f19c8fb2 --- /dev/null +++ b/build/StarcoinFramework/docs/SharedEd25519PublicKey.md @@ -0,0 +1,309 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+key: vector<u8> +
+
+ 32 byte ed25519 public key +
+
+rotation_cap: Account::KeyRotationCapability +
+
+ rotation capability for an account whose authentication key is always derived from key +
+
+ + +
+ + + +## Constants + + + + + + +
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>)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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>)
+
+ + + +
+Implementation + + +
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;
+}
+
+ + + +
+ +
+Specification + + + +
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` + +(1) rotate the public key stored 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>)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Return the public key stored under addr. +Aborts if addr does not hold a SharedEd25519PublicKey resource. + + +
public fun key(addr: address): vector<u8>
+
+ + + +
+Implementation + + +
public fun key(addr: address): vector<u8> acquires SharedEd25519PublicKey {
+    *&borrow_global<SharedEd25519PublicKey>(addr).key
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<SharedEd25519PublicKey>(addr);
+
+ + + +
+ + + +## Function `exists_at` + +Returns true if addr holds a SharedEd25519PublicKey resource. + + +
public fun exists_at(addr: address): bool
+
+ + + +
+Implementation + + +
public fun exists_at(addr: address): bool {
+    exists<SharedEd25519PublicKey>(addr)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/Signature.md b/build/StarcoinFramework/docs/Signature.md new file mode 100644 index 00000000..e819d8cf --- /dev/null +++ b/build/StarcoinFramework/docs/Signature.md @@ -0,0 +1,154 @@ + + + +# 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) +- [Function `secp256k1_verify`](#0x1_Signature_secp256k1_verify) +- [Module Specification](#@Module_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
+
+ + + +
+Implementation + + +
native public fun ed25519_validate_pubkey(public_key: vector<u8>): bool;
+
+ + + +
+ + + +## Function `ed25519_verify` + + + +
public fun ed25519_verify(signature: vector<u8>, public_key: vector<u8>, message: vector<u8>): bool
+
+ + + +
+Implementation + + +
native public fun ed25519_verify(signature: vector<u8>, public_key: vector<u8>, message: vector<u8>): bool;
+
+ + + +
+ + + +## Function `native_ecrecover` + +recover address from ECDSA signature, if recover fail, return an empty vector + + +
fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>
+
+ + + +
+Implementation + + +
native fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>;
+
+ + + +
+ + + +## Function `ecrecover` + +recover address from ECDSA signature, if recover fail, return None + + +
public fun ecrecover(hash: vector<u8>, signature: vector<u8>): Option::Option<EVMAddress::EVMAddress>
+
+ + + +
+Implementation + + +
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))
+    }
+}
+
+ + + +
+ + + +## Function `secp256k1_verify` + + + +
public fun secp256k1_verify(signature: vector<u8>, addr: vector<u8>, message: vector<u8>): bool
+
+ + + +
+Implementation + + +
public fun secp256k1_verify(signature: vector<u8>, addr: vector<u8>, message: vector<u8>) : bool{
+  let receover_address_opt:Option<EVMAddress>  = ecrecover(message, signature);
+  let expect_address =  EVMAddress::new(addr);
+  &Option::destroy_some<EVMAddress>(receover_address_opt) == &expect_address
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma intrinsic = true;
+
diff --git a/build/StarcoinFramework/docs/SignedInteger64.md b/build/StarcoinFramework/docs/SignedInteger64.md new file mode 100644 index 00000000..5d4c8fc2 --- /dev/null +++ b/build/StarcoinFramework/docs/SignedInteger64.md @@ -0,0 +1,352 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_0) + + +
+ + + + + +## Struct `SignedInteger64` + +Define a signed integer type with two 32 bits. + + +
struct SignedInteger64 has copy, drop, store
+
+ + + +
+Fields + + +
+
+value: u64 +
+
+ +
+
+is_negative: bool +
+
+ +
+
+ + +
+ + + +## Function `multiply_u64` + +Multiply a u64 integer by a signed integer number. + + +
public fun multiply_u64(num: u64, multiplier: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
+
+ + + +
+Implementation + + +
public fun multiply_u64(num: u64, multiplier: SignedInteger64): SignedInteger64 {
+    let product = multiplier.value * num;
+    SignedInteger64 { value: product, is_negative: multiplier.is_negative }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if multiplier.value * num > max_u64();
+
+ + + +
+ + + +## Function `divide_u64` + +Divide a u64 integer by a signed integer number. + + +
public fun divide_u64(num: u64, divisor: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
+
+ + + +
+Implementation + + +
public fun divide_u64(num: u64, divisor: SignedInteger64): SignedInteger64 {
+    let quotient = num / divisor.value;
+    SignedInteger64 { value: quotient, is_negative: divisor.is_negative }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if divisor.value == 0;
+
+ + + +
+ + + +## Function `sub_u64` + +Sub: num - minus + + +
public fun sub_u64(num: u64, minus: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
+
+ + + +
+Implementation + + +
public fun sub_u64(num: u64, minus: SignedInteger64): SignedInteger64 {
+    if (minus.is_negative) {
+        let result = num + minus.value;
+        SignedInteger64 { value: result, is_negative: false }
+    } else {
+        if (num >= minus.value) {
+            let result = num - minus.value;
+            SignedInteger64 { value: result, is_negative: false }
+        }else {
+            let result = minus.value - num;
+            SignedInteger64 { value: result, is_negative: true }
+        }
+    }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if minus.is_negative && num + minus.value > max_u64();
+
+ + + +
+ + + +## Function `add_u64` + +Add: num + addend + + +
public fun add_u64(num: u64, addend: SignedInteger64::SignedInteger64): SignedInteger64::SignedInteger64
+
+ + + +
+Implementation + + +
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, is_negative: false }
+        }else {
+            let result = addend.value - num;
+            SignedInteger64 { value: result, is_negative: true }
+        }
+    } else {
+        let result = num + addend.value;
+        SignedInteger64 { value: result, is_negative: false }
+    }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !addend.is_negative && num + addend.value > max_u64();
+
+ + + +
+ + + +## Function `create_from_raw_value` + +Create a signed integer value from a unsigned integer + + +
public fun create_from_raw_value(value: u64, is_negative: bool): SignedInteger64::SignedInteger64
+
+ + + +
+Implementation + + +
public fun create_from_raw_value(value: u64, is_negative: bool): SignedInteger64 {
+    SignedInteger64 { value, is_negative }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == SignedInteger64 { value, is_negative };
+
+ + + +
+ + + +## Function `get_value` + +Get value part of i64 ignore sign part. + + +
public fun get_value(num: SignedInteger64::SignedInteger64): u64
+
+ + + +
+Implementation + + +
public fun get_value(num: SignedInteger64): u64 {
+    num.value
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == num.value;
+
+ + + +
+ + + +## Function `is_negative` + +Check if the given num is negative. + + +
public fun is_negative(num: SignedInteger64::SignedInteger64): bool
+
+ + + +
+Implementation + + +
public fun is_negative(num: SignedInteger64): bool {
+    num.is_negative
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == num.is_negative;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/Signer.md b/build/StarcoinFramework/docs/Signer.md new file mode 100644 index 00000000..8f0f1d8c --- /dev/null +++ b/build/StarcoinFramework/docs/Signer.md @@ -0,0 +1,94 @@ + + + +# Module `0x1::Signer` + +Provide access methods for Signer. + + +- [Function `borrow_address`](#0x1_Signer_borrow_address) +- [Function `address_of`](#0x1_Signer_address_of) +- [Module Specification](#@Module_Specification_0) + + +
+ + + + + +## 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
+
+ + + +
+Implementation + + +
native public fun borrow_address(s: &signer): &address;
+
+ + + +
+ + + +## Function `address_of` + +Copies the address of the signer + + +
public fun address_of(s: &signer): address
+
+ + + +
+Implementation + + +
public fun address_of(s: &signer): address {
+    *borrow_address(s)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+ensures result == address_of(s);
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/SimpleMap.md b/build/StarcoinFramework/docs/SimpleMap.md new file mode 100644 index 00000000..7e47f32f --- /dev/null +++ b/build/StarcoinFramework/docs/SimpleMap.md @@ -0,0 +1,543 @@ + + + +# Module `0x1::SimpleMap` + +This module provides a solution for sorted maps, that is it has the properties that +1) Keys point to Values +2) Each Key must be unique +3) A Key can be found within O(N) time +4) The keys are unsorted. +5) Adds and removals take O(N) time + + +- [Struct `SimpleMap`](#0x1_SimpleMap_SimpleMap) +- [Struct `Element`](#0x1_SimpleMap_Element) +- [Constants](#@Constants_0) +- [Function `length`](#0x1_SimpleMap_length) +- [Function `create`](#0x1_SimpleMap_create) +- [Function `borrow`](#0x1_SimpleMap_borrow) +- [Function `borrow_mut`](#0x1_SimpleMap_borrow_mut) +- [Function `contains_key`](#0x1_SimpleMap_contains_key) +- [Function `destroy_empty`](#0x1_SimpleMap_destroy_empty) +- [Function `add`](#0x1_SimpleMap_add) +- [Function `upsert`](#0x1_SimpleMap_upsert) +- [Function `remove`](#0x1_SimpleMap_remove) +- [Function `find`](#0x1_SimpleMap_find) + + +
use 0x1::Errors;
+use 0x1::Option;
+use 0x1::Vector;
+
+ + + + + +## Struct `SimpleMap` + + + +
struct SimpleMap<Key, Value> has copy, drop, store
+
+ + + +
+Fields + + +
+
+data: vector<SimpleMap::Element<Key, Value>> +
+
+ +
+
+ + +
+ + + +## Struct `Element` + + + +
struct Element<Key, Value> has copy, drop, store
+
+ + + +
+Fields + + +
+
+key: Key +
+
+ +
+
+value: Value +
+
+ +
+
+ + +
+ + + +## Constants + + + + +Map key already exists + + +
const EKEY_ALREADY_EXISTS: u64 = 1;
+
+ + + + + +Map key is not found + + +
const EKEY_NOT_FOUND: u64 = 2;
+
+ + + + + +## Function `length` + + + +
public fun length<Key: store, Value: store>(map: &SimpleMap::SimpleMap<Key, Value>): u64
+
+ + + +
+Implementation + + +
public fun length<Key: store, Value: store>(map: &SimpleMap<Key, Value>): u64 {
+    Vector::length(&map.data)
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `create` + + + +
public fun create<Key: store, Value: store>(): SimpleMap::SimpleMap<Key, Value>
+
+ + + +
+Implementation + + +
public fun create<Key: store, Value: store>(): SimpleMap<Key, Value> {
+    SimpleMap {
+        data: Vector::empty(),
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `borrow` + + + +
public fun borrow<Key: store, Value: store>(map: &SimpleMap::SimpleMap<Key, Value>, key: &Key): &Value
+
+ + + +
+Implementation + + +
public fun borrow<Key: store, Value: store>(
+    map: &SimpleMap<Key, Value>,
+    key: &Key,
+): &Value {
+    let maybe_idx = find(map, key);
+    assert!(Option::is_some(&maybe_idx), Errors::invalid_argument(EKEY_NOT_FOUND));
+    let idx = Option::extract(&mut maybe_idx);
+    &Vector::borrow(&map.data, idx).value
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `borrow_mut` + + + +
public fun borrow_mut<Key: store, Value: store>(map: &mut SimpleMap::SimpleMap<Key, Value>, key: &Key): &mut Value
+
+ + + +
+Implementation + + +
public fun borrow_mut<Key: store, Value: store>(
+    map: &mut SimpleMap<Key, Value>,
+    key: &Key,
+): &mut Value {
+    let maybe_idx = find(map, key);
+    assert!(Option::is_some(&maybe_idx), Errors::invalid_argument(EKEY_NOT_FOUND));
+    let idx = Option::extract(&mut maybe_idx);
+    &mut Vector::borrow_mut(&mut map.data, idx).value
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `contains_key` + + + +
public fun contains_key<Key: store, Value: store>(map: &SimpleMap::SimpleMap<Key, Value>, key: &Key): bool
+
+ + + +
+Implementation + + +
public fun contains_key<Key: store, Value: store>(
+    map: &SimpleMap<Key, Value>,
+    key: &Key,
+): bool {
+    let maybe_idx = find(map, key);
+    Option::is_some(&maybe_idx)
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `destroy_empty` + + + +
public fun destroy_empty<Key: store, Value: store>(map: SimpleMap::SimpleMap<Key, Value>)
+
+ + + +
+Implementation + + +
public fun destroy_empty<Key: store, Value: store>(map: SimpleMap<Key, Value>) {
+    let SimpleMap { data } = map;
+    Vector::destroy_empty(data);
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `add` + + + +
public fun add<Key: store, Value: store>(map: &mut SimpleMap::SimpleMap<Key, Value>, key: Key, value: Value)
+
+ + + +
+Implementation + + +
public fun add<Key: store, Value: store>(
+    map: &mut SimpleMap<Key, Value>,
+    key: Key,
+    value: Value,
+) {
+    let maybe_idx = find(map, &key);
+    assert!(Option::is_none(&maybe_idx), Errors::invalid_argument(EKEY_ALREADY_EXISTS));
+
+    Vector::push_back(&mut map.data, Element { key, value });
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `upsert` + +Insert key/value pair or update an existing key to a new value + + +
public fun upsert<Key: store, Value: store>(map: &mut SimpleMap::SimpleMap<Key, Value>, key: Key, value: Value): (Option::Option<Key>, Option::Option<Value>)
+
+ + + +
+Implementation + + +
public fun upsert<Key: store, Value: store>(
+    map: &mut SimpleMap<Key, Value>,
+    key: Key,
+    value: Value
+): (Option::Option<Key>, Option::Option<Value>) {
+    let data = &mut map.data;
+    let len = Vector::length(data);
+    let i = 0;
+    while (i < len) {
+        let element = Vector::borrow(data, i);
+        if (&element.key == &key) {
+            Vector::push_back(data, Element { key, value });
+            Vector::swap(data, i, len);
+            let Element { key, value } = Vector::pop_back(data);
+            return (Option::some(key), Option::some(value))
+        };
+        i = i + 1;
+    };
+    Vector::push_back(&mut map.data, Element { key, value });
+    (Option::none(), Option::none())
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify=false;
+
+ + + +
+ + + +## Function `remove` + + + +
public fun remove<Key: store, Value: store>(map: &mut SimpleMap::SimpleMap<Key, Value>, key: &Key): (Key, Value)
+
+ + + +
+Implementation + + +
public fun remove<Key: store, Value: store>(
+    map: &mut SimpleMap<Key, Value>,
+    key: &Key,
+): (Key, Value) {
+    let maybe_idx = find(map, key);
+    assert!(Option::is_some(&maybe_idx), Errors::invalid_argument(EKEY_NOT_FOUND));
+    let placement = Option::extract(&mut maybe_idx);
+    let Element { key, value } = Vector::swap_remove(&mut map.data, placement);
+    (key, value)
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `find` + + + +
fun find<Key: store, Value: store>(map: &SimpleMap::SimpleMap<Key, Value>, key: &Key): Option::Option<u64>
+
+ + + +
+Implementation + + +
fun find<Key: store, Value: store>(
+    map: &SimpleMap<Key, Value>,
+    key: &Key,
+): Option::Option<u64> {
+    let leng = Vector::length(&map.data);
+    let i = 0;
+    while (i < leng) {
+        let element = Vector::borrow(&map.data, i);
+        if (&element.key == key) {
+            return Option::some(i)
+        };
+        i = i + 1;
+    };
+    Option::none<u64>()
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify=false;
+
+ + + +
diff --git a/build/StarcoinFramework/docs/StarcoinVerifier.md b/build/StarcoinFramework/docs/StarcoinVerifier.md new file mode 100644 index 00000000..cb7c6a28 --- /dev/null +++ b/build/StarcoinFramework/docs/StarcoinVerifier.md @@ -0,0 +1,715 @@ + + + +# Module `0x1::StarcoinVerifier` + + + +- [Struct `AccountState`](#0x1_StarcoinVerifier_AccountState) +- [Struct `StateProof`](#0x1_StarcoinVerifier_StateProof) +- [Struct `SparseMerkleProof`](#0x1_StarcoinVerifier_SparseMerkleProof) +- [Struct `SMTNode`](#0x1_StarcoinVerifier_SMTNode) +- [Constants](#@Constants_0) +- [Function `bcs_deserialize_account_state`](#0x1_StarcoinVerifier_bcs_deserialize_account_state) +- [Function `new_state_proof`](#0x1_StarcoinVerifier_new_state_proof) +- [Function `new_sparse_merkle_proof`](#0x1_StarcoinVerifier_new_sparse_merkle_proof) +- [Function `new_smt_node`](#0x1_StarcoinVerifier_new_smt_node) +- [Function `empty_smt_node`](#0x1_StarcoinVerifier_empty_smt_node) +- [Function `verify_state_proof`](#0x1_StarcoinVerifier_verify_state_proof) +- [Function `verify_smp`](#0x1_StarcoinVerifier_verify_smp) +- [Function `compute_smp_root_by_path_and_node_hash`](#0x1_StarcoinVerifier_compute_smp_root_by_path_and_node_hash) +- [Function `placeholder`](#0x1_StarcoinVerifier_placeholder) +- [Function `create_literal_hash`](#0x1_StarcoinVerifier_create_literal_hash) +- [Function `hash_key`](#0x1_StarcoinVerifier_hash_key) +- [Function `hash_value`](#0x1_StarcoinVerifier_hash_value) +- [Function `count_common_prefix`](#0x1_StarcoinVerifier_count_common_prefix) +- [Function `get_bit_at_from_msb`](#0x1_StarcoinVerifier_get_bit_at_from_msb) + + +
use 0x1::BCS;
+use 0x1::Hash;
+use 0x1::Option;
+use 0x1::StructuredHash;
+
+ + + + + +## Struct `AccountState` + + + +
struct AccountState has copy, drop, store
+
+ + + +
+Fields + + +
+
+storage_roots: vector<Option::Option<vector<u8>>> +
+
+ +
+
+ + +
+ + + +## Struct `StateProof` + + + +
struct StateProof has copy, drop, store
+
+ + + +
+Fields + + +
+
+account_proof: StarcoinVerifier::SparseMerkleProof +
+
+ + * Account state's proof for global state root. + +
+
+account_state: vector<u8> +
+
+ + * Account state including storage roots. + +
+
+proof: StarcoinVerifier::SparseMerkleProof +
+
+ + * State's proof for account storage root. + +
+
+ + +
+ + + +## Struct `SparseMerkleProof` + + + +
struct SparseMerkleProof has copy, drop, store
+
+ + + +
+Fields + + +
+
+siblings: vector<vector<u8>> +
+
+ +
+
+leaf: StarcoinVerifier::SMTNode +
+
+ +
+
+ + +
+ + + +## Struct `SMTNode` + + + +
struct SMTNode has copy, drop, store
+
+ + + +
+Fields + + +
+
+hash1: vector<u8> +
+
+ +
+
+hash2: vector<u8> +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
const ACCOUNT_STORAGE_INDEX_RESOURCE: u64 = 1;
+
+ + + + + + + +
const BLOB_HASH_PREFIX: vector<u8> = [66, 108, 111, 98];
+
+ + + + + + + +
const DEFAULT_VALUE: vector<u8> = [];
+
+ + + + + + + +
const ERROR_ACCOUNT_STORAGE_ROOTS: u64 = 101;
+
+ + + + + + + +
const ERROR_LITERAL_HASH_WRONG_LENGTH: u64 = 102;
+
+ + + + + + + +
const HASH_LEN_IN_BITS: u64 = 256;
+
+ + + + + + + +
const SPARSE_MERKLE_INTERNAL_NODE: vector<u8> = [83, 112, 97, 114, 115, 101, 77, 101, 114, 107, 108, 101, 73, 110, 116, 101, 114, 110, 97, 108, 78, 111, 100, 101];
+
+ + + + + + + +
const SPARSE_MERKLE_LEAF_NODE: vector<u8> = [83, 112, 97, 114, 115, 101, 77, 101, 114, 107, 108, 101, 76, 101, 97, 102, 78, 111, 100, 101];
+
+ + + + + + + +
const SPARSE_MERKLE_PLACEHOLDER_HASH_LITERAL: vector<u8> = [83, 80, 65, 82, 83, 69, 95, 77, 69, 82, 75, 76, 69, 95, 80, 76, 65, 67, 69, 72, 79, 76, 68, 69, 82, 95, 72, 65, 83, 72];
+
+ + + + + +## Function `bcs_deserialize_account_state` + + + +
public fun bcs_deserialize_account_state(data: &vector<u8>): StarcoinVerifier::AccountState
+
+ + + +
+Implementation + + +
public fun bcs_deserialize_account_state(data: &vector<u8>): AccountState {
+    let (vec, _) = BCS::deserialize_option_bytes_vector(data, 0);
+    AccountState{
+        storage_roots: vec
+    }
+}
+
+ + + +
+ + + +## Function `new_state_proof` + + + +
public fun new_state_proof(account_proof: StarcoinVerifier::SparseMerkleProof, account_state: vector<u8>, proof: StarcoinVerifier::SparseMerkleProof): StarcoinVerifier::StateProof
+
+ + + +
+Implementation + + +
public fun new_state_proof(account_proof: SparseMerkleProof, account_state: vector<u8>, proof: SparseMerkleProof): StateProof {
+    StateProof{
+        account_proof,
+        account_state,
+        proof,
+    }
+}
+
+ + + +
+ + + +## Function `new_sparse_merkle_proof` + + + +
public fun new_sparse_merkle_proof(siblings: vector<vector<u8>>, leaf: StarcoinVerifier::SMTNode): StarcoinVerifier::SparseMerkleProof
+
+ + + +
+Implementation + + +
public fun new_sparse_merkle_proof(siblings: vector<vector<u8>>, leaf: SMTNode): SparseMerkleProof {
+    SparseMerkleProof{
+        siblings,
+        leaf,
+    }
+}
+
+ + + +
+ + + +## Function `new_smt_node` + + + +
public fun new_smt_node(hash1: vector<u8>, hash2: vector<u8>): StarcoinVerifier::SMTNode
+
+ + + +
+Implementation + + +
public fun new_smt_node(hash1: vector<u8>, hash2: vector<u8>): SMTNode {
+    SMTNode{
+        hash1,
+        hash2,
+    }
+}
+
+ + + +
+ + + +## Function `empty_smt_node` + + + +
public fun empty_smt_node(): StarcoinVerifier::SMTNode
+
+ + + +
+Implementation + + +
public fun empty_smt_node(): SMTNode {
+    SMTNode{
+        hash1: Vector::empty(),
+        hash2: Vector::empty(),
+    }
+}
+
+ + + +
+ + + +## Function `verify_state_proof` + + + +
public fun verify_state_proof(state_proof: &StarcoinVerifier::StateProof, state_root: &vector<u8>, account_address: address, resource_struct_tag: &vector<u8>, state: &vector<u8>): bool
+
+ + + +
+Implementation + + +
public fun verify_state_proof(state_proof: &StateProof, state_root: &vector<u8>,
+                                       account_address: address, resource_struct_tag: &vector<u8>,
+                                       state: &vector<u8>): bool {
+    let accountState: AccountState = bcs_deserialize_account_state(&state_proof.account_state);
+    assert!(Vector::length(&accountState.storage_roots) > ACCOUNT_STORAGE_INDEX_RESOURCE, ERROR_ACCOUNT_STORAGE_ROOTS);
+
+    // First, verify state for storage root.
+    let storageRoot = Option::borrow(Vector::borrow(&accountState.storage_roots, ACCOUNT_STORAGE_INDEX_RESOURCE));
+    let ok: bool = verify_smp(&state_proof.proof.siblings,
+        &state_proof.proof.leaf,
+        storageRoot,
+        resource_struct_tag, // resource struct tag BCS serialized as key
+        state);
+    if (!ok) {
+        return false
+    };
+
+    // Then, verify account state for global state root.
+    ok = verify_smp(&state_proof.account_proof.siblings,
+        &state_proof.account_proof.leaf,
+        state_root,
+        &BCS::to_bytes<address>(&account_address), // account address as key
+        &state_proof.account_state,
+    );
+    ok
+}
+
+ + + +
+ + + +## Function `verify_smp` + +Verify sparse merkle proof by key and value. + + +
public fun verify_smp(sibling_nodes: &vector<vector<u8>>, leaf_data: &StarcoinVerifier::SMTNode, expected_root: &vector<u8>, key: &vector<u8>, value: &vector<u8>): bool
+
+ + + +
+Implementation + + +
public fun verify_smp(sibling_nodes: &vector<vector<u8>>, leaf_data: &SMTNode, expected_root: &vector<u8>, key: &vector<u8>, value: &vector<u8>): bool {
+    let path = hash_key(key);
+    let current_hash: vector<u8>;
+    if (*value == DEFAULT_VALUE) {
+        // Non-membership proof.
+        if (empty_smt_node() == *leaf_data) {
+            current_hash = placeholder();
+        } else {
+            if (*&leaf_data.hash1 == *&path) {
+                return false
+            };
+            if (!(count_common_prefix(&leaf_data.hash1, &path) >= Vector::length(sibling_nodes))) {
+                return false
+            };
+            current_hash = StructuredHash::hash(SPARSE_MERKLE_LEAF_NODE, leaf_data);
+        };
+    } else {
+        // Membership proof.
+        if (empty_smt_node() == *leaf_data) {
+            return false
+        };
+        if (*&leaf_data.hash1 != *&path) {
+            return false
+        };
+        let value_hash = hash_value(value);
+        if (*&leaf_data.hash2 != value_hash) {
+            return false
+        };
+        current_hash = StructuredHash::hash(SPARSE_MERKLE_LEAF_NODE, leaf_data);
+    };
+
+    current_hash = compute_smp_root_by_path_and_node_hash(sibling_nodes, &path, ¤t_hash);
+    current_hash == *expected_root
+}
+
+ + + +
+ + + +## Function `compute_smp_root_by_path_and_node_hash` + + + +
public fun compute_smp_root_by_path_and_node_hash(sibling_nodes: &vector<vector<u8>>, path: &vector<u8>, node_hash: &vector<u8>): vector<u8>
+
+ + + +
+Implementation + + +
public fun compute_smp_root_by_path_and_node_hash(sibling_nodes: &vector<vector<u8>>, path: &vector<u8>, node_hash: &vector<u8>): vector<u8> {
+    let current_hash = *node_hash;
+    let i = 0;
+    let proof_length = Vector::length(sibling_nodes);
+    while (i < proof_length) {
+        let sibling = *Vector::borrow(sibling_nodes, i);
+        let bit = get_bit_at_from_msb(path, proof_length - i - 1);
+        let internal_node = if (bit) {
+            SMTNode{ hash1: sibling, hash2: current_hash }
+        } else {
+            SMTNode{ hash1: current_hash, hash2: sibling }
+        };
+        current_hash = StructuredHash::hash(SPARSE_MERKLE_INTERNAL_NODE, &internal_node);
+        i = i + 1;
+    };
+    current_hash
+}
+
+ + + +
+ + + +## Function `placeholder` + + + +
public fun placeholder(): vector<u8>
+
+ + + +
+Implementation + + +
public fun placeholder(): vector<u8> {
+    create_literal_hash(&SPARSE_MERKLE_PLACEHOLDER_HASH_LITERAL)
+}
+
+ + + +
+ + + +## Function `create_literal_hash` + + + +
public fun create_literal_hash(word: &vector<u8>): vector<u8>
+
+ + + +
+Implementation + + +
public fun create_literal_hash(word: &vector<u8>): vector<u8> {
+    if (Vector::length(word)  <= 32) {
+        let lenZero = 32 - Vector::length(word);
+        let i = 0;
+        let r = *word;
+        while (i < lenZero) {
+            Vector::push_back(&mut r, 0);
+            i = i + 1;
+        };
+        return r
+    };
+    abort ERROR_LITERAL_HASH_WRONG_LENGTH
+}
+
+ + + +
+ + + +## Function `hash_key` + + + +
fun hash_key(key: &vector<u8>): vector<u8>
+
+ + + +
+Implementation + + +
fun hash_key(key: &vector<u8>): vector<u8> {
+    Hash::sha3_256(*key)
+}
+
+ + + +
+ + + +## Function `hash_value` + + + +
fun hash_value(value: &vector<u8>): vector<u8>
+
+ + + +
+Implementation + + +
fun hash_value(value: &vector<u8>): vector<u8> {
+    StructuredHash::hash(BLOB_HASH_PREFIX, value)
+}
+
+ + + +
+ + + +## Function `count_common_prefix` + + + +
fun count_common_prefix(data1: &vector<u8>, data2: &vector<u8>): u64
+
+ + + +
+Implementation + + +
fun count_common_prefix(data1: &vector<u8>, data2: &vector<u8>): u64 {
+    let count = 0;
+    let i = 0;
+    while ( i < Vector::length(data1) * 8) {
+        if (get_bit_at_from_msb(data1, i) == get_bit_at_from_msb(data2, i)) {
+            count = count + 1;
+        } else {
+            break
+        };
+        i = i + 1;
+    };
+    count
+}
+
+ + + +
+ + + +## Function `get_bit_at_from_msb` + + + +
fun get_bit_at_from_msb(data: &vector<u8>, index: u64): bool
+
+ + + +
+Implementation + + +
fun get_bit_at_from_msb(data: &vector<u8>, index: u64): bool {
+    let pos = index / 8;
+    let bit = (7 - index % 8);
+    (*Vector::borrow(data, pos) >> (bit as u8)) & 1u8 != 0
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+pragma opaque;
+
+ + + +
diff --git a/build/StarcoinFramework/docs/StdlibUpgradeScripts.md b/build/StarcoinFramework/docs/StdlibUpgradeScripts.md new file mode 100644 index 00000000..d2f4df95 --- /dev/null +++ b/build/StarcoinFramework/docs/StdlibUpgradeScripts.md @@ -0,0 +1,364 @@ + + + +# 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) +- [Function `upgrade_from_v11_to_v12`](#0x1_StdlibUpgradeScripts_upgrade_from_v11_to_v12) +- [Function `do_upgrade_from_v11_to_v12`](#0x1_StdlibUpgradeScripts_do_upgrade_from_v11_to_v12) +- [Module Specification](#@Module_Specification_0) + + +
use 0x1::Account;
+use 0x1::Block;
+use 0x1::Collection;
+use 0x1::Config;
+use 0x1::CoreAddresses;
+use 0x1::EasyGasOracle;
+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 entry fun upgrade_from_v2_to_v3(account: signer, total_stc_amount: u128)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ + + +## Function `take_linear_withdraw_capability` + +association account should call this script after upgrade from v2 to v3. + + +
public entry fun take_linear_withdraw_capability(signer: signer)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ + + +## Function `do_upgrade_from_v5_to_v6` + + + +
public fun do_upgrade_from_v5_to_v6(sender: &signer)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ + + +## Function `upgrade_from_v5_to_v6` + + + +
public entry fun upgrade_from_v5_to_v6(sender: signer)
+
+ + + +
+Implementation + + +
public entry fun upgrade_from_v5_to_v6(sender: signer) {
+   Self::do_upgrade_from_v5_to_v6(&sender)
+}
+
+ + + +
+ + + +## Function `upgrade_from_v6_to_v7` + + + +
public entry fun upgrade_from_v6_to_v7(sender: signer)
+
+ + + +
+Implementation + + +
public entry fun upgrade_from_v6_to_v7(sender: signer) {
+    Self::do_upgrade_from_v6_to_v7_with_language_version(&sender, 2);
+}
+
+ + + +
+ + + +## Function `do_upgrade_from_v6_to_v7` + +deprecated, use do_upgrade_from_v6_to_v7_with_language_version. + + +
public fun do_upgrade_from_v6_to_v7(sender: &signer)
+
+ + + +
+Implementation + + +
public fun do_upgrade_from_v6_to_v7(sender: &signer) {
+   do_upgrade_from_v6_to_v7_with_language_version(sender, 2);
+}
+
+ + + +
+ + + +## Function `do_upgrade_from_v6_to_v7_with_language_version` + + + +
public fun do_upgrade_from_v6_to_v7_with_language_version(sender: &signer, language_version: u64)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ + + +## Function `upgrade_from_v7_to_v8` + + + +
public entry fun upgrade_from_v7_to_v8(sender: signer)
+
+ + + +
+Implementation + + +
public entry fun upgrade_from_v7_to_v8(sender: signer) {
+    do_upgrade_from_v7_to_v8(&sender);
+}
+
+ + + +
+ + + +## Function `do_upgrade_from_v7_to_v8` + + + +
public fun do_upgrade_from_v7_to_v8(sender: &signer)
+
+ + + +
+Implementation + + +
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);
+    };
+}
+
+ + + +
+ + + +## Function `upgrade_from_v11_to_v12` + + + +
public entry fun upgrade_from_v11_to_v12(sender: signer)
+
+ + + +
+Implementation + + +
public entry fun upgrade_from_v11_to_v12(sender: signer) {
+    do_upgrade_from_v11_to_v12(&sender);
+}
+
+ + + +
+ + + +## Function `do_upgrade_from_v11_to_v12` + + + +
public fun do_upgrade_from_v11_to_v12(sender: &signer)
+
+ + + +
+Implementation + + +
public fun do_upgrade_from_v11_to_v12(sender: &signer) {
+    {
+        EasyGasOracle::register_gas_token_entry(sender,
+            @0x8c109349c6bd91411d6bc962e080c4a3,
+            b"STAR",b"STAR",
+            @0x8c109349c6bd91411d6bc962e080c4a3);
+        Block::checkpoints_init(sender);
+    };
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/String.md b/build/StarcoinFramework/docs/String.md new file mode 100644 index 00000000..856a29b2 --- /dev/null +++ b/build/StarcoinFramework/docs/String.md @@ -0,0 +1,530 @@ + + + +# Module `0x1::String` + +The string module defines the String type which represents UTF8 encoded strings. + + +- [Struct `String`](#0x1_String_String) +- [Constants](#@Constants_0) +- [Function `utf8`](#0x1_String_utf8) +- [Function `try_utf8`](#0x1_String_try_utf8) +- [Function `bytes`](#0x1_String_bytes) +- [Function `is_empty`](#0x1_String_is_empty) +- [Function `length`](#0x1_String_length) +- [Function `append`](#0x1_String_append) +- [Function `append_utf8`](#0x1_String_append_utf8) +- [Function `insert`](#0x1_String_insert) +- [Function `sub_string`](#0x1_String_sub_string) +- [Function `index_of`](#0x1_String_index_of) +- [Function `internal_check_utf8`](#0x1_String_internal_check_utf8) +- [Function `internal_is_char_boundary`](#0x1_String_internal_is_char_boundary) +- [Function `internal_sub_string`](#0x1_String_internal_sub_string) +- [Function `internal_index_of`](#0x1_String_internal_index_of) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::Errors;
+use 0x1::Option;
+use 0x1::Vector;
+
+ + + + + +## Struct `String` + +A String holds a sequence of bytes which is guaranteed to be in utf8 format. + + +
struct String has copy, drop, store
+
+ + + +
+Fields + + +
+
+bytes: vector<u8> +
+
+ +
+
+ + +
+ + + +## Constants + + + + +An invalid UTF8 encoding. + + +
const EINVALID_UTF8: u64 = 1;
+
+ + + + + +Index out of range. + + +
const EINVALID_INDEX: u64 = 2;
+
+ + + + + +## Function `utf8` + +Creates a new string from a sequence of bytes. Aborts if the bytes do not represent valid utf8. + + +
public fun utf8(bytes: vector<u8>): String::String
+
+ + + +
+Implementation + + +
public fun utf8(bytes: vector<u8>): String {
+    assert!(internal_check_utf8(&bytes), Errors::invalid_state(EINVALID_UTF8));
+    String{bytes}
+}
+
+ + + +
+ + + +## Function `try_utf8` + +Tries to create a new string from a sequence of bytes. + + +
public fun try_utf8(bytes: vector<u8>): Option::Option<String::String>
+
+ + + +
+Implementation + + +
public fun try_utf8(bytes: vector<u8>): Option<String> {
+    if (internal_check_utf8(&bytes)) {
+        Option::some(String{bytes})
+    } else {
+        Option::none()
+    }
+}
+
+ + + +
+ + + +## Function `bytes` + +Returns a reference to the underlying byte vector. + + +
public fun bytes(s: &String::String): &vector<u8>
+
+ + + +
+Implementation + + +
public fun bytes(s: &String): &vector<u8> {
+    &s.bytes
+}
+
+ + + +
+ + + +## Function `is_empty` + +Checks whether this string is empty. + + +
public fun is_empty(s: &String::String): bool
+
+ + + +
+Implementation + + +
public fun is_empty(s: &String): bool {
+    Vector::is_empty(&s.bytes)
+}
+
+ + + +
+ + + +## Function `length` + +Returns the length of this string, in bytes. + + +
public fun length(s: &String::String): u64
+
+ + + +
+Implementation + + +
public fun length(s: &String): u64 {
+    Vector::length(&s.bytes)
+}
+
+ + + +
+ + + +## Function `append` + +Appends a string. + + +
public fun append(s: &mut String::String, r: String::String)
+
+ + + +
+Implementation + + +
public fun append(s: &mut String, r: String) {
+    Vector::append(&mut s.bytes, *&r.bytes)
+}
+
+ + + +
+ + + +## Function `append_utf8` + +Appends bytes which must be in valid utf8 format. + + +
public fun append_utf8(s: &mut String::String, bytes: vector<u8>)
+
+ + + +
+Implementation + + +
public fun append_utf8(s: &mut String, bytes: vector<u8>) {
+    append(s, utf8(bytes))
+}
+
+ + + +
+ + + +## Function `insert` + +Insert the other string at the byte index in given string. The index must be at a valid utf8 char +boundary. + + +
public fun insert(s: &mut String::String, at: u64, o: String::String)
+
+ + + +
+Implementation + + +
public fun insert(s: &mut String, at: u64, o: String) {
+    let bytes = &s.bytes;
+    assert!(at <= Vector::length(bytes) && internal_is_char_boundary(bytes, at), Errors::invalid_state(EINVALID_INDEX));
+    let l = length(s);
+    let front = sub_string(s, 0, at);
+    let end = sub_string(s, at, l);
+    append(&mut front, o);
+    append(&mut front, end);
+    *s = front;
+}
+
+ + + +
+ + + +## Function `sub_string` + +Returns a sub-string using the given byte indices, where i is the first byte position and j is the start +of the first byte not included (or the length of the string). The indices must be at valid utf8 char boundaries, +guaranteeing that the result is valid utf8. + + +
public fun sub_string(s: &String::String, i: u64, j: u64): String::String
+
+ + + +
+Implementation + + +
public fun sub_string(s: &String, i: u64, j: u64): String {
+    let bytes = &s.bytes;
+    let l = Vector::length(bytes);
+    assert!(
+        j <= l && i <= j && internal_is_char_boundary(bytes, i) && internal_is_char_boundary(bytes, j),
+        Errors::invalid_state(EINVALID_INDEX)
+    );
+    String{bytes: internal_sub_string(bytes, i, j)}
+}
+
+ + + +
+ + + +## Function `index_of` + +Computes the index of the first occurrence of a string. Returns length(s) if no occurrence found. + + +
public fun index_of(s: &String::String, r: &String::String): u64
+
+ + + +
+Implementation + + +
public fun index_of(s: &String, r: &String): u64 {
+    internal_index_of(&s.bytes, &r.bytes)
+}
+
+ + + +
+ + + +## Function `internal_check_utf8` + + + +
fun internal_check_utf8(v: &vector<u8>): bool
+
+ + + +
+Implementation + + +
native fun internal_check_utf8(v: &vector<u8>): bool;
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if [abstract] false;
+ensures [abstract] result == spec_internal_check_utf8(v);
+
+ + + +
+ + + +## Function `internal_is_char_boundary` + + + +
fun internal_is_char_boundary(v: &vector<u8>, i: u64): bool
+
+ + + +
+Implementation + + +
native fun internal_is_char_boundary(v: &vector<u8>, i: u64): bool;
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if [abstract] false;
+ensures [abstract] result == spec_internal_is_char_boundary(v, i);
+
+ + + +
+ + + +## Function `internal_sub_string` + + + +
fun internal_sub_string(v: &vector<u8>, i: u64, j: u64): vector<u8>
+
+ + + +
+Implementation + + +
native fun internal_sub_string(v: &vector<u8>, i: u64, j: u64): vector<u8>;
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if [abstract] false;
+ensures [abstract] result == spec_internal_sub_string(v, i, j);
+
+ + + +
+ + + +## Function `internal_index_of` + + + +
fun internal_index_of(v: &vector<u8>, r: &vector<u8>): u64
+
+ + + +
+Implementation + + +
native fun internal_index_of(v: &vector<u8>, r: &vector<u8>): u64;
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if [abstract] false;
+ensures [abstract] result == spec_internal_index_of(v, r);
+
+ + + + + + + +
fun spec_internal_check_utf8(v: vector<u8>): bool;
+
+fun spec_internal_is_char_boundary(v: vector<u8>, i: u64): bool;
+
+fun spec_internal_sub_string(v: vector<u8>, i: u64, j: u64): vector<u8>;
+
+fun spec_internal_index_of(v: vector<u8>, r: vector<u8>): u64;
+
+ + + +
+ + + +## Module Specification + + + + + + +
fun spec_utf8(bytes: vector<u8>): String {
+   String{bytes}
+}
+
diff --git a/build/StarcoinFramework/docs/Table.md b/build/StarcoinFramework/docs/Table.md new file mode 100644 index 00000000..f7c4a3f5 --- /dev/null +++ b/build/StarcoinFramework/docs/Table.md @@ -0,0 +1,831 @@ + + + +# Module `0x1::Table` + +Type of large-scale storage tables. + + +- [Struct `Table`](#0x1_Table_Table) +- [Resource `Box`](#0x1_Table_Box) +- [Constants](#@Constants_0) +- [Function `new`](#0x1_Table_new) +- [Function `destroy_empty`](#0x1_Table_destroy_empty) +- [Function `add`](#0x1_Table_add) +- [Function `borrow`](#0x1_Table_borrow) +- [Function `borrow_with_default`](#0x1_Table_borrow_with_default) +- [Function `borrow_mut`](#0x1_Table_borrow_mut) +- [Function `length`](#0x1_Table_length) +- [Function `empty`](#0x1_Table_empty) +- [Function `borrow_mut_with_default`](#0x1_Table_borrow_mut_with_default) +- [Function `upsert`](#0x1_Table_upsert) +- [Function `remove`](#0x1_Table_remove) +- [Function `contains`](#0x1_Table_contains) +- [Function `new_table_handle`](#0x1_Table_new_table_handle) +- [Function `add_box`](#0x1_Table_add_box) +- [Function `borrow_box`](#0x1_Table_borrow_box) +- [Function `borrow_box_mut`](#0x1_Table_borrow_box_mut) +- [Function `contains_box`](#0x1_Table_contains_box) +- [Function `remove_box`](#0x1_Table_remove_box) +- [Function `destroy_empty_box`](#0x1_Table_destroy_empty_box) +- [Function `drop_unchecked_box`](#0x1_Table_drop_unchecked_box) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::Errors;
+
+ + + + + +## Struct `Table` + +Type of tables + + +
struct Table<K: copy, drop, V> has store
+
+ + + +
+Fields + + +
+
+handle: address +
+
+ +
+
+length: u64 +
+
+ +
+
+ + +
+ +
+Specification + + + +
pragma intrinsic = map,
+map_new = new,
+map_destroy_empty = destroy_empty,
+map_len = length,
+map_is_empty = empty,
+map_has_key = contains,
+map_add_no_override = add,
+map_del_must_exist = remove,
+map_borrow = borrow,
+map_borrow_mut = borrow_mut,
+map_spec_get = spec_get,
+map_spec_set = spec_set,
+map_spec_del = spec_remove,
+map_spec_len = spec_len,
+map_spec_has_key = spec_contains;
+
+ + + +
+ + + +## Resource `Box` + +Wrapper for values. Required for making values appear as resources in the implementation. + + +
struct Box<V> has drop, store, key
+
+ + + +
+Fields + + +
+
+val: V +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
const EALREADY_EXISTS: u64 = 100;
+
+ + + + + + + +
const ENOT_EMPTY: u64 = 102;
+
+ + + + + + + +
const ENOT_FOUND: u64 = 101;
+
+ + + + + +## Function `new` + +Create a new Table. + + +
public fun new<K: copy, drop, V: store>(): Table::Table<K, V>
+
+ + + +
+Implementation + + +
public fun new<K: copy + drop, V: store>(): Table<K, V> {
+    Table{
+        handle: new_table_handle<K, V>(),
+        length: 0,
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic;
+
+ + + +
+ + + +## Function `destroy_empty` + +Destroy a table. The table must be empty to succeed. + + +
public fun destroy_empty<K: copy, drop, V>(table: Table::Table<K, V>)
+
+ + + +
+Implementation + + +
public fun destroy_empty<K: copy + drop, V>(table: Table<K, V>) {
+    assert!(table.length == 0, Errors::invalid_state(ENOT_EMPTY));
+    destroy_empty_box<K, V, Box<V>>(&table);
+    drop_unchecked_box<K, V, Box<V>>(table)
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic;
+
+ + + +
+ + + +## Function `add` + +Add a new entry to the table. Aborts if an entry for this +key already exists. The entry itself is not stored in the +table, and cannot be discovered from it. + + +
public fun add<K: copy, drop, V>(table: &mut Table::Table<K, V>, key: K, val: V)
+
+ + + +
+Implementation + + +
public fun add<K: copy + drop, V>(table: &mut Table<K, V>, key: K, val: V) {
+    add_box<K, V, Box<V>>(table, key, Box{val});
+    table.length = table.length + 1
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic;
+
+ + + +
+ + + +## Function `borrow` + +Acquire an immutable reference to the value which key maps to. +Aborts if there is no entry for key. + + +
public fun borrow<K: copy, drop, V>(table: &Table::Table<K, V>, key: K): &V
+
+ + + +
+Implementation + + +
public fun borrow<K: copy + drop, V>(table: &Table<K, V>, key: K): &V {
+    &borrow_box<K, V, Box<V>>(table, key).val
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic;
+
+ + + +
+ + + +## Function `borrow_with_default` + +Acquire an immutable reference to the value which key maps to. +Returns specified default value if there is no entry for key. + + +
public fun borrow_with_default<K: copy, drop, V>(table: &Table::Table<K, V>, key: K, default: &V): &V
+
+ + + +
+Implementation + + +
public fun borrow_with_default<K: copy + drop, V>(table: &Table<K, V>, key: K, default: &V): &V {
+    if (!contains(table, copy key)) {
+        default
+    } else {
+        borrow(table, copy key)
+    }
+}
+
+ + + +
+ + + +## Function `borrow_mut` + +Acquire a mutable reference to the value which key maps to. +Aborts if there is no entry for key. + + +
public fun borrow_mut<K: copy, drop, V>(table: &mut Table::Table<K, V>, key: K): &mut V
+
+ + + +
+Implementation + + +
public fun borrow_mut<K: copy + drop, V>(table: &mut Table<K, V>, key: K): &mut V {
+    &mut borrow_box_mut<K, V, Box<V>>(table, key).val
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic;
+
+ + + +
+ + + +## Function `length` + +Returns the length of the table, i.e. the number of entries. + + +
public fun length<K: copy, drop, V>(table: &Table::Table<K, V>): u64
+
+ + + +
+Implementation + + +
public fun length<K: copy + drop, V>(table: &Table<K, V>): u64 {
+    table.length
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic;
+
+ + + +
+ + + +## Function `empty` + +Returns true if this table is empty. + + +
public fun empty<K: copy, drop, V>(table: &Table::Table<K, V>): bool
+
+ + + +
+Implementation + + +
public fun empty<K: copy + drop, V>(table: &Table<K, V>): bool {
+    table.length == 0
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic;
+
+ + + +
+ + + +## Function `borrow_mut_with_default` + +Acquire a mutable reference to the value which key maps to. +Insert the pair (key, default) first if there is no entry for key. + + +
public fun borrow_mut_with_default<K: copy, drop, V: drop>(table: &mut Table::Table<K, V>, key: K, default: V): &mut V
+
+ + + +
+Implementation + + +
public fun borrow_mut_with_default<K: copy + drop, V: drop>(table: &mut Table<K, V>, key: K, default: V): &mut V {
+    if (!contains(table, copy key)) {
+        add(table, copy key, default)
+    };
+    borrow_mut(table, key)
+}
+
+ + + +
+ +
+Specification + + + +
pragma opaque, verify=false;
+aborts_if false;
+
+ + + +
+ + + +## Function `upsert` + +Insert the pair (key, value) if there is no entry for key. +update the value of the entry for key to value otherwise + + +
public fun upsert<K: copy, drop, V: drop>(table: &mut Table::Table<K, V>, key: K, value: V)
+
+ + + +
+Implementation + + +
public fun upsert<K: copy + drop, V: drop>(table: &mut Table<K, V>, key: K, value: V) {
+    if (!contains(table, copy key)) {
+        add(table, copy key, value)
+    } else {
+        let ref = borrow_mut(table, key);
+        *ref = value;
+    };
+}
+
+ + + +
+ + + +## Function `remove` + +Remove from table and return the value which key maps to. +Aborts if there is no entry for key. + + +
public fun remove<K: copy, drop, V>(table: &mut Table::Table<K, V>, key: K): V
+
+ + + +
+Implementation + + +
public fun remove<K: copy + drop, V>(table: &mut Table<K, V>, key: K): V {
+    let Box{val} = remove_box<K, V, Box<V>>(table, key);
+    table.length = table.length - 1;
+    val
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic;
+
+ + + +
+ + + +## Function `contains` + +Returns true iff table contains an entry for key. + + +
public fun contains<K: copy, drop, V>(table: &Table::Table<K, V>, key: K): bool
+
+ + + +
+Implementation + + +
public fun contains<K: copy + drop, V>(table: &Table<K, V>, key: K): bool {
+    contains_box<K, V, Box<V>>(table, key)
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic;
+
+ + + +
+ + + +## Function `new_table_handle` + + + +
fun new_table_handle<K, V>(): address
+
+ + + +
+Implementation + + +
native fun new_table_handle<K, V>(): address;
+
+ + + +
+ + + +## Function `add_box` + + + +
fun add_box<K: copy, drop, V, B>(table: &mut Table::Table<K, V>, key: K, val: Table::Box<V>)
+
+ + + +
+Implementation + + +
native fun add_box<K: copy + drop, V, B>(table: &mut Table<K, V>, key: K, val: Box<V>);
+
+ + + +
+ + + +## Function `borrow_box` + + + +
fun borrow_box<K: copy, drop, V, B>(table: &Table::Table<K, V>, key: K): &Table::Box<V>
+
+ + + +
+Implementation + + +
native fun borrow_box<K: copy + drop, V, B>(table: &Table<K, V>, key: K): &Box<V>;
+
+ + + +
+ + + +## Function `borrow_box_mut` + + + +
fun borrow_box_mut<K: copy, drop, V, B>(table: &mut Table::Table<K, V>, key: K): &mut Table::Box<V>
+
+ + + +
+Implementation + + +
native fun borrow_box_mut<K: copy + drop, V, B>(table: &mut Table<K, V>, key: K): &mut Box<V>;
+
+ + + +
+ + + +## Function `contains_box` + + + +
fun contains_box<K: copy, drop, V, B>(table: &Table::Table<K, V>, key: K): bool
+
+ + + +
+Implementation + + +
native fun contains_box<K: copy + drop, V, B>(table: &Table<K, V>, key: K): bool;
+
+ + + +
+ + + +## Function `remove_box` + + + +
fun remove_box<K: copy, drop, V, B>(table: &mut Table::Table<K, V>, key: K): Table::Box<V>
+
+ + + +
+Implementation + + +
native fun remove_box<K: copy + drop, V, B>(table: &mut Table<K, V>, key: K): Box<V>;
+
+ + + +
+ + + +## Function `destroy_empty_box` + + + +
fun destroy_empty_box<K: copy, drop, V, B>(table: &Table::Table<K, V>)
+
+ + + +
+Implementation + + +
native fun destroy_empty_box<K: copy + drop, V, B>(table: &Table<K, V>);
+
+ + + +
+ + + +## Function `drop_unchecked_box` + + + +
fun drop_unchecked_box<K: copy, drop, V, B>(table: Table::Table<K, V>)
+
+ + + +
+Implementation + + +
native fun drop_unchecked_box<K: copy + drop, V, B>(table: Table<K, V>);
+
+ + + +
+ + + +## Module Specification + + + + + + +
native fun spec_len<K, V>(t: Table<K, V>): num;
+
+ + + + + + + +
native fun spec_contains<K, V>(t: Table<K, V>, k: K): bool;
+
+ + + + + + + +
native fun spec_set<K, V>(t: Table<K, V>, k: K, v: V): Table<K, V>;
+
+ + + + + + + +
native fun spec_remove<K, V>(t: Table<K, V>, k: K): Table<K, V>;
+
+ + + + + + + +
native fun spec_get<K, V>(t: Table<K, V>, k: K): V;
+
diff --git a/build/StarcoinFramework/docs/Timestamp.md b/build/StarcoinFramework/docs/Timestamp.md new file mode 100644 index 00000000..a4af9aaa --- /dev/null +++ b/build/StarcoinFramework/docs/Timestamp.md @@ -0,0 +1,461 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::CoreAddresses;
+use 0x1::Errors;
+
+ + + + + +## Resource `CurrentTimeMilliseconds` + + + +
struct CurrentTimeMilliseconds has key
+
+ + + +
+Fields + + +
+
+milliseconds: u64 +
+
+ +
+
+ + +
+ + + +## Resource `TimeHasStarted` + +A singleton resource used to determine whether time has started. This +is called at the end of genesis. + + +
struct TimeHasStarted has key
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Signer::address_of(account) != CoreAddresses::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)
+
+ + + +
+Implementation + + +
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;
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+aborts_if !exists<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
+aborts_if timestamp <= global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds;
+ensures global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds == timestamp;
+
+ + + +
+ + + +## Function `now_seconds` + + + +
public fun now_seconds(): u64
+
+ + + +
+Implementation + + +
public fun now_seconds(): u64 acquires CurrentTimeMilliseconds {
+    now_milliseconds() / MILLI_CONVERSION_FACTOR
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
+ensures result == now_milliseconds() / MILLI_CONVERSION_FACTOR;
+
+ + + + + + + +
fun spec_now_seconds(): u64 {
+   global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds / MILLI_CONVERSION_FACTOR
+}
+
+ + + +
+ + + +## Function `now_milliseconds` + + + +
public fun now_milliseconds(): u64
+
+ + + +
+Implementation + + +
public fun now_milliseconds(): u64 acquires CurrentTimeMilliseconds {
+    borrow_global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
+ensures result == global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds;
+
+ + + + + + + +
fun spec_now_millseconds(): u64 {
+   global<CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS()).milliseconds
+}
+
+ + + +
+ + + +## Function `set_time_has_started` + +Marks that time has started and genesis has finished. This can only be called from genesis. + + +
public fun set_time_has_started(account: &signer)
+
+ + + +
+Implementation + + +
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{});
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Signer::address_of(account) != CoreAddresses::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` + +Helper function to determine if the blockchain is in genesis state. + + +
public fun is_genesis(): bool
+
+ + + +
+Implementation + + +
public fun is_genesis(): bool {
+    !exists<TimeHasStarted>(CoreAddresses::GENESIS_ADDRESS())
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == !exists<TimeHasStarted>(CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `assert_genesis` + +Helper function to assert genesis state. + + +
public fun assert_genesis()
+
+ + + +
+Implementation + + +
public fun assert_genesis() {
+    assert!(is_genesis(), Errors::invalid_state(ENOT_GENESIS));
+}
+
+ + + +
+ +
+Specification + + + +
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::GENESIS_ADDRESS());
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/Token.md b/build/StarcoinFramework/docs/Token.md new file mode 100644 index 00000000..a32c5fb7 --- /dev/null +++ b/build/StarcoinFramework/docs/Token.md @@ -0,0 +1,1845 @@ + + + +# 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 `type_of`](#0x1_Token_type_of) +- [Function `name_of`](#0x1_Token_name_of) +- [Function `name_of_token`](#0x1_Token_name_of_token) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+value: u128 +
+
+ +
+
+ + +
+ + + +## Struct `TokenCode` + +Token Code which identify a unique Token. + + +
struct TokenCode has copy, drop, store
+
+ + + +
+Fields + + +
+
+addr: address +
+
+ address who define the module contains the Token Type. +
+
+module_name: vector<u8> +
+
+ module which contains the Token Type. +
+
+name: vector<u8> +
+
+ name of the token. may nested if the token is an instantiated generic token type. +
+
+ + +
+ + + +## Resource `MintCapability` + +A minting capability allows tokens of type TokenType to be minted + + +
struct MintCapability<TokenType> has store, key
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ + +
+ + + +## Resource `FixedTimeMintKey` + +A fixed time mint key which can mint token until global time > end_time + + +
struct FixedTimeMintKey<TokenType> has store, key
+
+ + + +
+Fields + + +
+
+total: u128 +
+
+ +
+
+end_time: u64 +
+
+ +
+
+ + +
+ + + +## Resource `LinearTimeMintKey` + +A linear time mint key which can mint token in a period by time-based linear release. + + +
struct LinearTimeMintKey<TokenType> has store, key
+
+ + + +
+Fields + + +
+
+total: u128 +
+
+ +
+
+minted: u128 +
+
+ +
+
+start_time: u64 +
+
+ +
+
+period: u64 +
+
+ +
+
+ + +
+ + + +## Resource `BurnCapability` + +A burn capability allows tokens of type TokenType to be burned. + + +
struct BurnCapability<TokenType> has store, key
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ + +
+ + + +## Struct `MintEvent` + +Event emitted when token minted. + + +
struct MintEvent has drop, store
+
+ + + +
+Fields + + +
+
+amount: u128 +
+
+ funds added to the system +
+
+token_code: Token::TokenCode +
+
+ full info of Token. +
+
+ + +
+ + + +## Struct `BurnEvent` + +Event emitted when token burned. + + +
struct BurnEvent has drop, store
+
+ + + +
+Fields + + +
+
+amount: u128 +
+
+ funds removed from the system +
+
+token_code: Token::TokenCode +
+
+ full info of Token +
+
+ + +
+ + + +## Resource `TokenInfo` + +Token information. + + +
struct TokenInfo<TokenType> has key
+
+ + + +
+Fields + + +
+
+total_value: u128 +
+
+ The total value for the token represented by + TokenType. Mutable. +
+
+scaling_factor: u128 +
+
+ The scaling factor for the coin (i.e. the amount to divide by + to get to the human-readable representation for this currency). + e.g. 10^6 for Coin1 +
+
+mint_events: Event::EventHandle<Token::MintEvent> +
+
+ event stream for minting +
+
+burn_events: Event::EventHandle<Token::BurnEvent> +
+
+ event stream for burning +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
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),
+        },
+    );
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Remove mint capability from signer. + + +
public fun remove_mint_capability<TokenType: store>(signer: &signer): Token::MintCapability<TokenType>
+
+ + + +
+Implementation + + +
public fun remove_mint_capability<TokenType: store>(signer: &signer): MintCapability<TokenType>
+acquires MintCapability {
+    move_from<MintCapability<TokenType>>(Signer::address_of(signer))
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<MintCapability<TokenType>>(Signer::address_of(signer));
+ensures !exists<MintCapability<TokenType>>(Signer::address_of(signer));
+
+ + + +
+ + + +## Function `add_mint_capability` + +Add mint capability to signer. + + +
public fun add_mint_capability<TokenType: store>(signer: &signer, cap: Token::MintCapability<TokenType>)
+
+ + + +
+Implementation + + +
public fun add_mint_capability<TokenType: store>(signer: &signer, cap: MintCapability<TokenType>) {
+    move_to(signer, cap)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if exists<MintCapability<TokenType>>(Signer::address_of(signer));
+ensures exists<MintCapability<TokenType>>(Signer::address_of(signer));
+
+ + + +
+ + + +## Function `destroy_mint_capability` + +Destroy the given mint capability. + + +
public fun destroy_mint_capability<TokenType: store>(cap: Token::MintCapability<TokenType>)
+
+ + + +
+Implementation + + +
public fun destroy_mint_capability<TokenType: store>(cap: MintCapability<TokenType>) {
+    let MintCapability<TokenType> {} = cap;
+}
+
+ + + +
+ +
+Specification + + + +
+ + + +## Function `remove_burn_capability` + +remove the token burn capability from signer. + + +
public fun remove_burn_capability<TokenType: store>(signer: &signer): Token::BurnCapability<TokenType>
+
+ + + +
+Implementation + + +
public fun remove_burn_capability<TokenType: store>(signer: &signer): BurnCapability<TokenType>
+acquires BurnCapability {
+    move_from<BurnCapability<TokenType>>(Signer::address_of(signer))
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<BurnCapability<TokenType>>(Signer::address_of(signer));
+ensures !exists<BurnCapability<TokenType>>(Signer::address_of(signer));
+
+ + + +
+ + + +## Function `add_burn_capability` + +Add token burn capability to signer. + + +
public fun add_burn_capability<TokenType: store>(signer: &signer, cap: Token::BurnCapability<TokenType>)
+
+ + + +
+Implementation + + +
public fun add_burn_capability<TokenType: store>(signer: &signer, cap: BurnCapability<TokenType>) {
+    move_to(signer, cap)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if exists<BurnCapability<TokenType>>(Signer::address_of(signer));
+ensures exists<BurnCapability<TokenType>>(Signer::address_of(signer));
+
+ + + +
+ + + +## Function `destroy_burn_capability` + +Destroy the given burn capability. + + +
public fun destroy_burn_capability<TokenType: store>(cap: Token::BurnCapability<TokenType>)
+
+ + + +
+Implementation + + +
public fun destroy_burn_capability<TokenType: store>(cap: BurnCapability<TokenType>) {
+    let BurnCapability<TokenType> {} = cap;
+}
+
+ + + +
+ +
+Specification + + + +
+ + + +## Function `mint` + +Return amount tokens. +Fails if the sender does not have a published MintCapability. + + +
public fun mint<TokenType: store>(account: &signer, amount: u128): Token::Token<TokenType>
+
+ + + +
+Implementation + + +
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,
+    )
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if spec_abstract_total_value<TokenType>() + amount > MAX_U128;
+aborts_if !exists<MintCapability<TokenType>>(Signer::address_of(account));
+
+ + + +
+ + + +## Function `mint_with_capability` + +Mint a new Token::Token worth 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>
+
+ + + +
+Implementation + + +
public fun mint_with_capability<TokenType: store>(
+    _capability: &MintCapability<TokenType>,
+    amount: u128,
+): Token<TokenType> acquires TokenInfo {
+    do_mint(amount)
+}
+
+ + + +
+ +
+Specification + + + +
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>
+
+ + + +
+Implementation + + +
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 }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS());
+aborts_if spec_abstract_total_value<TokenType>() + amount > MAX_U128;
+
+ + + +
+ + + +## Function `issue_fixed_mint_key` + +Deprecated since @v3 +Issue a FixedTimeMintKey with given MintCapability. + + +
public fun issue_fixed_mint_key<TokenType: store>(_capability: &Token::MintCapability<TokenType>, _amount: u128, _period: u64): Token::FixedTimeMintKey<TokenType>
+
+ + + +
+Implementation + + +
public fun issue_fixed_mint_key<TokenType: store>(
+    _capability: &MintCapability<TokenType>,
+    _amount: u128,
+    _period: u64,
+): FixedTimeMintKey<TokenType> {
+    abort Errors::deprecated(EDEPRECATED_FUNCTION)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if true;
+
+ + + +
+ + + +## Function `issue_linear_mint_key` + +Deprecated since @v3 +Issue a LinearTimeMintKey with given MintCapability. + + +
public fun issue_linear_mint_key<TokenType: store>(_capability: &Token::MintCapability<TokenType>, _amount: u128, _period: u64): Token::LinearTimeMintKey<TokenType>
+
+ + + +
+Implementation + + +
public fun issue_linear_mint_key<TokenType: store>(
+    _capability: &MintCapability<TokenType>,
+    _amount: u128,
+    _period: u64,
+): LinearTimeMintKey<TokenType> {
+    abort Errors::deprecated(EDEPRECATED_FUNCTION)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if true;
+
+ + + +
+ + + +## Function `destroy_linear_time_key` + +Destroy LinearTimeMintKey, for deprecated + + +
public fun destroy_linear_time_key<TokenType: store>(key: Token::LinearTimeMintKey<TokenType>): (u128, u128, u64, u64)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `read_linear_time_key` + + + +
public fun read_linear_time_key<TokenType: store>(key: &Token::LinearTimeMintKey<TokenType>): (u128, u128, u64, u64)
+
+ + + +
+Implementation + + +
public fun read_linear_time_key<TokenType: store>(key: &LinearTimeMintKey<TokenType>): (u128, u128, u64, u64) {
+    (key.total, key.minted, key.start_time, key.period)
+}
+
+ + + +
+ + + +## Function `burn` + +Burn some tokens of signer. + + +
public fun burn<TokenType: store>(account: &signer, tokens: Token::Token<TokenType>)
+
+ + + +
+Implementation + + +
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,
+    )
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if spec_abstract_total_value<TokenType>() - tokens.value < 0;
+aborts_if !exists<BurnCapability<TokenType>>(Signer::address_of(account));
+
+ + + +
+ + + +## Function `burn_with_capability` + +Burn tokens with the given BurnCapability. + + +
public fun burn_with_capability<TokenType: store>(_capability: &Token::BurnCapability<TokenType>, tokens: Token::Token<TokenType>)
+
+ + + +
+Implementation + + +
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 },
+        },
+    );
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Create a new Token::Token with a value of 0 + + +
public fun zero<TokenType: store>(): Token::Token<TokenType>
+
+ + + +
+Implementation + + +
public fun zero<TokenType: store>(): Token<TokenType> {
+    Token<TokenType> { value: 0 }
+}
+
+ + + +
+ +
+Specification + + + +
ensures result.value == 0;
+
+ + + +
+ + + +## Function `value` + +Public accessor for the value of a token + + +
public fun value<TokenType: store>(token: &Token::Token<TokenType>): u128
+
+ + + +
+Implementation + + +
public fun value<TokenType: store>(token: &Token<TokenType>): u128 {
+    token.value
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == token.value;
+
+ + + +
+ + + +## Function `split` + +Splits the given token into two and returns them both + + +
public fun split<TokenType: store>(token: Token::Token<TokenType>, value: u128): (Token::Token<TokenType>, Token::Token<TokenType>)
+
+ + + +
+Implementation + + +
public fun split<TokenType: store>(
+    token: Token<TokenType>,
+    value: u128,
+): (Token<TokenType>, Token<TokenType>) {
+    let rest = withdraw(&mut token, value);
+    (token, rest)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if token.value < value;
+ensures token.value == result_1.value + result_2.value;
+
+ + + +
+ + + +## Function `withdraw` + +"Divides" the given token into two, where the original token is modified in place. +The original token will have value = original value - 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>
+
+ + + +
+Implementation + + +
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 }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if token.value < value;
+ensures result.value == value;
+ensures token.value == old(token).value - value;
+
+ + + +
+ + + +## Function `join` + +Merges two tokens of the same token and returns a new token whose +value is equal to the sum of the two inputs + + +
public fun join<TokenType: store>(token1: Token::Token<TokenType>, token2: Token::Token<TokenType>): Token::Token<TokenType>
+
+ + + +
+Implementation + + +
public fun join<TokenType: store>(
+    token1: Token<TokenType>,
+    token2: Token<TokenType>,
+): Token<TokenType> {
+    deposit(&mut token1, token2);
+    token1
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if token1.value + token2.value > max_u128();
+ensures token1.value + token2.value == result.value;
+
+ + + +
+ + + +## Function `deposit` + +"Merges" the two tokens +The token passed in by reference will have a value equal to the sum of the two tokens +The check token is consumed in the process + + +
public fun deposit<TokenType: store>(token: &mut Token::Token<TokenType>, check: Token::Token<TokenType>)
+
+ + + +
+Implementation + + +
public fun deposit<TokenType: store>(token: &mut Token<TokenType>, check: Token<TokenType>) {
+    let Token { value } = check;
+    token.value = token.value + value;
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if token.value + check.value > max_u128();
+ensures old(token).value + check.value == token.value;
+
+ + + +
+ + + +## Function `destroy_zero` + +Destroy a token +Fails if the value is non-zero +The amount of Token in the system is a tightly controlled property, +so you cannot "burn" any non-zero amount of Token + + +
public fun destroy_zero<TokenType: store>(token: Token::Token<TokenType>)
+
+ + + +
+Implementation + + +
public fun destroy_zero<TokenType: store>(token: Token<TokenType>) {
+    let Token { value } = token;
+    assert!(value == 0, Errors::invalid_state(EDESTROY_TOKEN_NON_ZERO))
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if token.value > 0;
+
+ + + +
+ + + +## Function `scaling_factor` + +Returns the scaling_factor for the TokenType token. + + +
public fun scaling_factor<TokenType: store>(): u128
+
+ + + +
+Implementation + + +
public fun scaling_factor<TokenType: store>(): u128 acquires TokenInfo {
+    let token_address = token_address<TokenType>();
+    borrow_global<TokenInfo<TokenType>>(token_address).scaling_factor
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == global<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS()).scaling_factor;
+
+ + + +
+ + + +## Function `market_cap` + +Return the total amount of token of type TokenType. + + +
public fun market_cap<TokenType: store>(): u128
+
+ + + +
+Implementation + + +
public fun market_cap<TokenType: store>(): u128 acquires TokenInfo {
+    let token_address = token_address<TokenType>();
+    borrow_global<TokenInfo<TokenType>>(token_address).total_value
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == global<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS()).total_value;
+
+ + + +
+ + + +## Function `is_registered_in` + +Return true if the type TokenType is a registered in token_address. + + +
public fun is_registered_in<TokenType: store>(token_address: address): bool
+
+ + + +
+Implementation + + +
public fun is_registered_in<TokenType: store>(token_address: address): bool {
+    exists<TokenInfo<TokenType>>(token_address)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == exists<TokenInfo<TokenType>>(token_address);
+
+ + + +
+ + + +## Function `is_same_token` + +Return true if the type TokenType1 is same with TokenType2 + + +
public fun is_same_token<TokenType1: store, TokenType2: store>(): bool
+
+ + + +
+Implementation + + +
public fun is_same_token<TokenType1: store, TokenType2: store>(): bool {
+    return token_code<TokenType1>() == token_code<TokenType2>()
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `token_address` + +Return the TokenType's address + + +
public fun token_address<TokenType: store>(): address
+
+ + + +
+Implementation + + +
public fun token_address<TokenType: store>(): address {
+    let (addr, _, _) = name_of<TokenType>();
+    addr
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Return the token code for the registered token. + + +
public fun token_code<TokenType: store>(): Token::TokenCode
+
+ + + +
+Implementation + + +
public fun token_code<TokenType: store>(): TokenCode {
+    let (addr, module_name, name) = name_of<TokenType>();
+    TokenCode {
+        addr,
+        module_name,
+        name
+    }
+}
+
+ + + +
+ +
+Specification + + + +
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 `type_of` + + + +
public(friend) fun type_of<T>(): (address, vector<u8>, vector<u8>)
+
+ + + +
+Implementation + + +
public (friend) fun type_of<T>(): (address, vector<u8>, vector<u8>){
+    name_of<T>()
+}
+
+ + + +
+ + + +## Function `name_of` + +Return Token's module address, module name, and type name of TokenType. + + +
fun name_of<TokenType>(): (address, vector<u8>, vector<u8>)
+
+ + + +
+Implementation + + +
native fun name_of<TokenType>(): (address, vector<u8>, vector<u8>);
+
+ + + +
+ +
+Specification + + + +
pragma opaque = true;
+aborts_if false;
+
+ + + +
+ + + +## Function `name_of_token` + + + +
fun name_of_token<TokenType: store>(): (address, vector<u8>, vector<u8>)
+
+ + + +
+Implementation + + +
fun name_of_token<TokenType: store>(): (address, vector<u8>, vector<u8>) {
+    name_of<TokenType>()
+}
+
+ + + +
+ +
+Specification + + + +
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>(): num {
+   global<TokenInfo<TokenType>>(SPEC_TOKEN_TEST_ADDRESS()).total_value
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/TransactionFee.md b/build/StarcoinFramework/docs/TransactionFee.md new file mode 100644 index 00000000..b6dcc89b --- /dev/null +++ b/build/StarcoinFramework/docs/TransactionFee.md @@ -0,0 +1,245 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_0) + + +
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
+
+ + + +
+Fields + + +
+
+fee: Token::Token<TokenType> +
+
+ +
+
+ + +
+ + + +## Function `initialize` + +Called in genesis. Sets up the needed resources to collect transaction fees from the +TransactionFee resource with the TreasuryCompliance account. + + +
public fun initialize(account: &signer)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !Timestamp::is_genesis();
+aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+aborts_if exists<TransactionFee<STC>>(Signer::address_of(account));
+
+ + + +
+ + + +## Function `add_txn_fee_token` + +publishing a wrapper of the Preburn<TokenType> resource under fee_account + + +
fun add_txn_fee_token<TokenType: store>(account: &signer)
+
+ + + +
+Implementation + + +
fun add_txn_fee_token<TokenType: store>(
+    account: &signer,
+) {
+    move_to(
+        account,
+        TransactionFee<TokenType> {
+            fee: Token::zero(),
+        }
+    )
+ }
+
+ + + +
+ +
+Specification + + + +
aborts_if exists<TransactionFee<TokenType>>(Signer::address_of(account));
+
+ + + +
+ + + +## Function `pay_fee` + +Deposit token into the transaction fees bucket + + +
public fun pay_fee<TokenType: store>(token: Token::Token<TokenType>)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<TransactionFee<TokenType>>(CoreAddresses::GENESIS_ADDRESS());
+aborts_if global<TransactionFee<TokenType>>(CoreAddresses::GENESIS_ADDRESS()).fee.value + token.value > max_u128();
+
+ + + +
+ + + +## Function `distribute_transaction_fees` + +Distribute the transaction fees collected in the 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>
+
+ + + +
+Implementation + + +
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>()
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/TransactionManager.md b/build/StarcoinFramework/docs/TransactionManager.md new file mode 100644 index 00000000..c869fe31 --- /dev/null +++ b/build/StarcoinFramework/docs/TransactionManager.md @@ -0,0 +1,441 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::Account;
+use 0x1::Block;
+use 0x1::BlockReward;
+use 0x1::ChainId;
+use 0x1::CoreAddresses;
+use 0x1::EasyGasOracle;
+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;
+
+ + + + + +## 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)
+
+ + + +
+Implementation + + +
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));
+    let (stc_price,scaling_factor)= if (!STC::is_stc<TokenType>()){
+        (EasyGasOracle::gas_oracle_read<TokenType>(),EasyGasOracle::get_scaling_factor<TokenType>())
+    }else{
+        (1,1)
+    };
+
+    Account::txn_prologue_v2<TokenType>(
+        &account,
+        txn_sender,
+        txn_sequence_number,
+        txn_authentication_key_preimage,
+        txn_gas_price,
+        txn_max_gas_units,
+        stc_price,
+        scaling_factor,
+    );
+    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
+}
+
+ + + +
+ +
+Specification + + + +
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 && 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` + +The epilogue is invoked at the end of transactions. +It collects gas and bumps the sequence number + + +
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)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+include CoreAddresses::AbortsIfNotGenesisAddress;
+aborts_if Signer::address_of(account) != CoreAddresses::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 `epilogue_v2` + +The epilogue is invoked at the end of transactions. +It collects gas and bumps the sequence number + + +
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)
+
+ + + +
+Implementation + + +
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);
+    let (stc_price,scaling_factor) =
+    if (!STC::is_stc<TokenType>()){
+        (EasyGasOracle::gas_oracle_read<TokenType>(),EasyGasOracle::get_scaling_factor<TokenType>())
+    }else{
+        (1,1)
+    };
+    Account::txn_epilogue_v3<TokenType>(
+        &account,
+        txn_sender,
+        txn_sequence_number,
+        txn_authentication_key_preimage,
+        txn_gas_price,
+        txn_max_gas_units,
+        gas_units_remaining,
+        stc_price,
+        scaling_factor
+    );
+    if (txn_payload_type == TXN_PAYLOAD_TYPE_PACKAGE) {
+        PackageTxnManager::package_txn_epilogue(
+            &account,
+            txn_sender,
+            txn_package_address,
+            success,
+        );
+    }
+}
+
+ + + +
+ + + +## Function `block_prologue` + +Set the metadata for the current block and distribute transaction fees and block rewards. +The runtime always runs this before executing the transactions in a block. + + +
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)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/TransactionPublishOption.md b/build/StarcoinFramework/docs/TransactionPublishOption.md new file mode 100644 index 00000000..9507c62a --- /dev/null +++ b/build/StarcoinFramework/docs/TransactionPublishOption.md @@ -0,0 +1,348 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+script_allowed: bool +
+
+ +
+
+module_publishing_allowed: bool +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
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,
+    );
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !Timestamp::is_genesis();
+aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+include Config::PublishNewConfigAbortsIf<TransactionPublishOption>;
+include Config::PublishNewConfigEnsures<TransactionPublishOption>;
+
+ + + +
+ + + +## Function `new_transaction_publish_option` + +Create a new option. Mainly used in DAO. + + +
public fun new_transaction_publish_option(script_allowed: bool, module_publishing_allowed: bool): TransactionPublishOption::TransactionPublishOption
+
+ + + +
+Implementation + + +
public fun new_transaction_publish_option(
+    script_allowed: bool,
+    module_publishing_allowed: bool,
+): TransactionPublishOption {
+    TransactionPublishOption { script_allowed, module_publishing_allowed }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `is_script_allowed` + +Check if sender can execute script with + + +
public fun is_script_allowed(account: address): bool
+
+ + + +
+Implementation + + +
public fun is_script_allowed(account: address): bool {
+    let publish_option = Config::get_by_address<TransactionPublishOption>(account);
+    publish_option.script_allowed
+}
+
+ + + +
+ +
+Specification + + + +
include Config::AbortsIfConfigNotExist<TransactionPublishOption>{
+    addr: account
+};
+
+ + + +
+ + + +## Function `is_module_allowed` + +Check if a sender can publish a module + + +
public fun is_module_allowed(account: address): bool
+
+ + + +
+Implementation + + +
public fun is_module_allowed(account: address): bool {
+    let publish_option = Config::get_by_address<TransactionPublishOption>(account);
+    publish_option.module_publishing_allowed
+}
+
+ + + +
+ +
+Specification + + + +
include Config::AbortsIfConfigNotExist<TransactionPublishOption>{
+    addr: account
+};
+
+ + + + + + + +
schema AbortsIfTxnPublishOptionNotExist {
+    include Config::AbortsIfConfigNotExist<TransactionPublishOption>{
+        addr: CoreAddresses::GENESIS_ADDRESS()
+    };
+}
+
+ + + + + + + +
schema AbortsIfTxnPublishOptionNotExistWithBool {
+    is_script_or_package : bool;
+    aborts_if is_script_or_package && !exists<Config::Config<TransactionPublishOption>>(CoreAddresses::GENESIS_ADDRESS());
+}
+
+ + + +
+ + + +## Module Specification + + + +
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
+}
+
diff --git a/build/StarcoinFramework/docs/TransactionTimeout.md b/build/StarcoinFramework/docs/TransactionTimeout.md new file mode 100644 index 00000000..9e5baaf1 --- /dev/null +++ b/build/StarcoinFramework/docs/TransactionTimeout.md @@ -0,0 +1,108 @@ + + + +# Module `0x1::TransactionTimeout` + +A module used to check expiration time of transactions. + + +- [Function `is_valid_transaction_timestamp`](#0x1_TransactionTimeout_is_valid_transaction_timestamp) +- [Module Specification](#@Module_Specification_0) + + +
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
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
+aborts_if !exists<Block::BlockMetadata>(CoreAddresses::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::GENESIS_ADDRESS());
+
+ + + + + + + +
schema AbortsIfTimestampNotValid {
+    aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(CoreAddresses::GENESIS_ADDRESS());
+    aborts_if !exists<Block::BlockMetadata>(CoreAddresses::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::GENESIS_ADDRESS());
+}
+
+ + + +
+ + + +## Module Specification + + + +
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())
+ }
+}
+
diff --git a/build/StarcoinFramework/docs/TransactionTimeoutConfig.md b/build/StarcoinFramework/docs/TransactionTimeoutConfig.md new file mode 100644 index 00000000..e0488861 --- /dev/null +++ b/build/StarcoinFramework/docs/TransactionTimeoutConfig.md @@ -0,0 +1,235 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_0) + + +
use 0x1::Config;
+use 0x1::CoreAddresses;
+use 0x1::Timestamp;
+
+ + + + + +## Struct `TransactionTimeoutConfig` + +config structs. + + +
struct TransactionTimeoutConfig has copy, drop, store
+
+ + + +
+Fields + + +
+
+duration_seconds: u64 +
+
+ timeout in second. +
+
+ + +
+ + + +## Function `initialize` + +Initialize function. Should only be called in genesis. + + +
public fun initialize(account: &signer, duration_seconds: u64)
+
+ + + +
+Implementation + + +
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)
+    );
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !Timestamp::is_genesis();
+aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+include Config::PublishNewConfigAbortsIf<TransactionTimeoutConfig>;
+include Config::PublishNewConfigEnsures<TransactionTimeoutConfig>;
+
+ + + +
+ + + +## Function `new_transaction_timeout_config` + +Create a new timeout config used in dao proposal. + + +
public fun new_transaction_timeout_config(duration_seconds: u64): TransactionTimeoutConfig::TransactionTimeoutConfig
+
+ + + +
+Implementation + + +
public fun new_transaction_timeout_config(duration_seconds: u64) : TransactionTimeoutConfig {
+    TransactionTimeoutConfig {duration_seconds: duration_seconds}
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `get_transaction_timeout_config` + +Get current timeout config. + + +
public fun get_transaction_timeout_config(): TransactionTimeoutConfig::TransactionTimeoutConfig
+
+ + + +
+Implementation + + +
public fun get_transaction_timeout_config(): TransactionTimeoutConfig {
+    Config::get_by_address<TransactionTimeoutConfig>(CoreAddresses::GENESIS_ADDRESS())
+}
+
+ + + +
+ +
+Specification + + + +
include Config::AbortsIfConfigNotExist<TransactionTimeoutConfig>{
+    addr: CoreAddresses::GENESIS_ADDRESS()
+};
+
+ + + +
+ + + +## Function `duration_seconds` + +Get current txn timeout in seconds. + + +
public fun duration_seconds(): u64
+
+ + + +
+Implementation + + +
public fun duration_seconds() :u64 {
+    let config = get_transaction_timeout_config();
+    config.duration_seconds
+}
+
+ + + +
+ +
+Specification + + + +
include Config::AbortsIfConfigNotExist<TransactionTimeoutConfig>{
+    addr: CoreAddresses::GENESIS_ADDRESS()
+};
+
+ + + + + + + +
schema AbortsIfTxnTimeoutConfigNotExist {
+    include Config::AbortsIfConfigNotExist<TransactionTimeoutConfig>{
+        addr: CoreAddresses::GENESIS_ADDRESS()
+    };
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/docs/TransferScripts.md b/build/StarcoinFramework/docs/TransferScripts.md new file mode 100644 index 00000000..f9227cb6 --- /dev/null +++ b/build/StarcoinFramework/docs/TransferScripts.md @@ -0,0 +1,252 @@ + + + +# 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;
+
+ + + + + +## Constants + + + + + + +
const EDEPRECATED_FUNCTION: u64 = 19;
+
+ + + + + + + +
const EADDRESS_AND_AUTH_KEY_MISMATCH: u64 = 101;
+
+ + + + + + + +
const ELENGTH_MISMATCH: u64 = 102;
+
+ + + + + +## Function `peer_to_peer` + + + +
public entry fun peer_to_peer<TokenType: store>(account: signer, payee: address, _payee_auth_key: vector<u8>, amount: u128)
+
+ + + +
+Implementation + + +
public entry 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)
+}
+
+ + + +
+ + + +## Function `peer_to_peer_v2` + + + +
public entry fun peer_to_peer_v2<TokenType: store>(account: signer, payee: address, amount: u128)
+
+ + + +
+Implementation + + +
public entry 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)
+}
+
+ + + +
+ + + +## Function `batch_peer_to_peer` + +Batch transfer token to others. + + +
public entry fun batch_peer_to_peer<TokenType: store>(account: signer, payeees: vector<address>, _payee_auth_keys: vector<vector<u8>>, amounts: vector<u128>)
+
+ + + +
+Implementation + + +
public entry 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)
+}
+
+ + + +
+ + + +## Function `batch_peer_to_peer_v2` + +Batch transfer token to others. + + +
public entry fun batch_peer_to_peer_v2<TokenType: store>(account: signer, payeees: vector<address>, amounts: vector<u128>)
+
+ + + +
+Implementation + + +
public entry 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;
+    }
+}
+
+ + + +
+ + + +## Function `peer_to_peer_batch` + + + +
public entry fun peer_to_peer_batch<TokenType: store>(_account: signer, _payeees: vector<u8>, _payee_auth_keys: vector<u8>, _amount: u128)
+
+ + + +
+Implementation + + +
public entry fun peer_to_peer_batch<TokenType: store>(_account: signer, _payeees: vector<u8>, _payee_auth_keys: vector<u8>, _amount: u128) {
+    abort Errors::deprecated(EDEPRECATED_FUNCTION)
+}
+
+ + + +
+ + + +## Function `peer_to_peer_with_metadata` + + + +
public entry fun peer_to_peer_with_metadata<TokenType: store>(account: signer, payee: address, _payee_auth_key: vector<u8>, amount: u128, metadata: vector<u8>)
+
+ + + +
+Implementation + + +
public entry 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)
+}
+
+ + + +
+ + + +## Function `peer_to_peer_with_metadata_v2` + + + +
public entry fun peer_to_peer_with_metadata_v2<TokenType: store>(account: signer, payee: address, amount: u128, metadata: vector<u8>)
+
+ + + +
+Implementation + + +
public entry 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)
+}
+
+ + + +
diff --git a/build/StarcoinFramework/docs/Treasury.md b/build/StarcoinFramework/docs/Treasury.md new file mode 100644 index 00000000..09400578 --- /dev/null +++ b/build/StarcoinFramework/docs/Treasury.md @@ -0,0 +1,1230 @@ + + + +# Module `0x1::Treasury` + +The module for the Treasury of DAO, which can hold the token of DAO. + + +- [Resource `Treasury`](#0x1_Treasury_Treasury) +- [Resource `WithdrawCapability`](#0x1_Treasury_WithdrawCapability) +- [Resource `LinearWithdrawCapability`](#0x1_Treasury_LinearWithdrawCapability) +- [Struct `WithdrawEvent`](#0x1_Treasury_WithdrawEvent) +- [Struct `DepositEvent`](#0x1_Treasury_DepositEvent) +- [Constants](#@Constants_0) +- [Function `initialize`](#0x1_Treasury_initialize) +- [Function `exists_at`](#0x1_Treasury_exists_at) +- [Function `balance`](#0x1_Treasury_balance) +- [Function `deposit`](#0x1_Treasury_deposit) +- [Function `do_withdraw`](#0x1_Treasury_do_withdraw) +- [Function `withdraw_with_capability`](#0x1_Treasury_withdraw_with_capability) +- [Function `withdraw`](#0x1_Treasury_withdraw) +- [Function `issue_linear_withdraw_capability`](#0x1_Treasury_issue_linear_withdraw_capability) +- [Function `withdraw_with_linear_capability`](#0x1_Treasury_withdraw_with_linear_capability) +- [Function `withdraw_by_linear`](#0x1_Treasury_withdraw_by_linear) +- [Function `split_linear_withdraw_cap`](#0x1_Treasury_split_linear_withdraw_cap) +- [Function `withdraw_amount_of_linear_cap`](#0x1_Treasury_withdraw_amount_of_linear_cap) +- [Function `is_empty_linear_withdraw_cap`](#0x1_Treasury_is_empty_linear_withdraw_cap) +- [Function `remove_withdraw_capability`](#0x1_Treasury_remove_withdraw_capability) +- [Function `add_withdraw_capability`](#0x1_Treasury_add_withdraw_capability) +- [Function `destroy_withdraw_capability`](#0x1_Treasury_destroy_withdraw_capability) +- [Function `add_linear_withdraw_capability`](#0x1_Treasury_add_linear_withdraw_capability) +- [Function `remove_linear_withdraw_capability`](#0x1_Treasury_remove_linear_withdraw_capability) +- [Function `destroy_linear_withdraw_capability`](#0x1_Treasury_destroy_linear_withdraw_capability) +- [Function `is_empty_linear_withdraw_capability`](#0x1_Treasury_is_empty_linear_withdraw_capability) +- [Function `get_linear_withdraw_capability_total`](#0x1_Treasury_get_linear_withdraw_capability_total) +- [Function `get_linear_withdraw_capability_withdraw`](#0x1_Treasury_get_linear_withdraw_capability_withdraw) +- [Function `get_linear_withdraw_capability_period`](#0x1_Treasury_get_linear_withdraw_capability_period) +- [Function `get_linear_withdraw_capability_start_time`](#0x1_Treasury_get_linear_withdraw_capability_start_time) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+balance: Token::Token<TokenT> +
+
+ +
+
+withdraw_events: Event::EventHandle<Treasury::WithdrawEvent> +
+
+ event handle for treasury withdraw event +
+
+deposit_events: Event::EventHandle<Treasury::DepositEvent> +
+
+ event handle for treasury deposit event +
+
+ + +
+ +
+Specification + + + +
+ + + +## Resource `WithdrawCapability` + +A withdraw capability allows tokens of type TokenT to be withdraw from Treasury. + + +
struct WithdrawCapability<TokenT> has store, key
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ + +
+ + + +## Resource `LinearWithdrawCapability` + +A linear time withdraw capability which can withdraw token from Treasury in a period by time-based linear release. + + +
struct LinearWithdrawCapability<TokenT> has store, key
+
+ + + +
+Fields + + +
+
+total: u128 +
+
+ The total amount of tokens that can be withdrawn by this capability +
+
+withdraw: u128 +
+
+ The amount of tokens that have been withdrawn by this capability +
+
+start_time: u64 +
+
+ The time-based linear release start time, timestamp in seconds. +
+
+period: u64 +
+
+ The time-based linear release period in seconds +
+
+ + +
+ + + +## Struct `WithdrawEvent` + +Message for treasury withdraw event. + + +
struct WithdrawEvent has drop, store
+
+ + + +
+Fields + + +
+
+amount: u128 +
+
+ +
+
+ + +
+ + + +## Struct `DepositEvent` + +Message for treasury deposit event. + + +
struct DepositEvent has drop, store
+
+ + + +
+Fields + + +
+
+amount: u128 +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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>
+
+ + + +
+Implementation + + +
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>{}
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Signer::address_of(signer) != Token::SPEC_TOKEN_TEST_ADDRESS();
+aborts_if exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
+ensures exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
+ensures result == WithdrawCapability<TokenT>{};
+
+ + + +
+ + + +## Function `exists_at` + +Check the Treasury of TokenT is exists. + + +
public fun exists_at<TokenT: store>(): bool
+
+ + + +
+Implementation + + +
public fun exists_at<TokenT: store>(): bool {
+    let token_issuer = Token::token_address<TokenT>();
+    exists<Treasury<TokenT>>(token_issuer)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
+
+ + + +
+ + + +## Function `balance` + +Get the balance of TokenT's Treasury +if the Treasury do not exists, return 0. + + +
public fun balance<TokenT: store>(): u128
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures if (exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS()))
+            result == spec_balance<TokenT>()
+        else
+            result == 0;
+
+ + + +
+ + + +## Function `deposit` + + + +
public fun deposit<TokenT: store>(token: Token::Token<TokenT>)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
+aborts_if spec_balance<TokenT>() + token.value > MAX_U128;
+ensures spec_balance<TokenT>() == old(spec_balance<TokenT>()) + token.value;
+
+ + + +
+ + + +## Function `do_withdraw` + + + +
fun do_withdraw<TokenT: store>(amount: u128): Token::Token<TokenT>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
include WithdrawSchema<TokenT>;
+
+ + + + + + + +
schema WithdrawSchema<TokenT> {
+    amount: u64;
+    aborts_if amount <= 0;
+    aborts_if !exists<Treasury<TokenT>>(Token::SPEC_TOKEN_TEST_ADDRESS());
+    aborts_if spec_balance<TokenT>() < amount;
+    ensures spec_balance<TokenT>() ==
+        old(spec_balance<TokenT>()) - amount;
+}
+
+ + + +
+ + + +## Function `withdraw_with_capability` + +Withdraw tokens with given LinearWithdrawCapability. + + +
public fun withdraw_with_capability<TokenT: store>(_cap: &mut Treasury::WithdrawCapability<TokenT>, amount: u128): Token::Token<TokenT>
+
+ + + +
+Implementation + + +
public fun withdraw_with_capability<TokenT: store>(
+    _cap: &mut WithdrawCapability<TokenT>,
+    amount: u128,
+): Token<TokenT> acquires Treasury {
+    do_withdraw(amount)
+}
+
+ + + +
+ +
+Specification + + + +
include WithdrawSchema<TokenT>;
+
+ + + +
+ + + +## Function `withdraw` + +Withdraw from TokenT's treasury, the signer must have WithdrawCapability + + +
public fun withdraw<TokenT: store>(signer: &signer, amount: u128): Token::Token<TokenT>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
+include WithdrawSchema<TokenT>;
+
+ + + +
+ + + +## Function `issue_linear_withdraw_capability` + +Issue a LinearWithdrawCapability with given WithdrawCapability. + + +
public fun issue_linear_withdraw_capability<TokenT: store>(_capability: &mut Treasury::WithdrawCapability<TokenT>, amount: u128, period: u64): Treasury::LinearWithdrawCapability<TokenT>
+
+ + + +
+Implementation + + +
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,
+    }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if period == 0;
+aborts_if amount == 0;
+aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(StarcoinFramework::CoreAddresses::GENESIS_ADDRESS());
+
+ + + +
+ + + +## Function `withdraw_with_linear_capability` + +Withdraw tokens with given LinearWithdrawCapability. + + +
public fun withdraw_with_linear_capability<TokenT: store>(cap: &mut Treasury::LinearWithdrawCapability<TokenT>): Token::Token<TokenT>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma aborts_if_is_partial;
+
+ + + +
+ + + +## Function `withdraw_by_linear` + +Withdraw from TokenT's treasury, the signer must have LinearWithdrawCapability + + +
public fun withdraw_by_linear<TokenT: store>(signer: &signer): Token::Token<TokenT>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma aborts_if_is_partial;
+aborts_if !exists<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
+
+ + + +
+ + + +## Function `split_linear_withdraw_cap` + +Split the given LinearWithdrawCapability. + + +
public fun split_linear_withdraw_cap<TokenT: store>(cap: &mut Treasury::LinearWithdrawCapability<TokenT>, amount: u128): (Token::Token<TokenT>, Treasury::LinearWithdrawCapability<TokenT>)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma aborts_if_is_partial;
+ensures old(cap.total - cap.withdraw) ==
+    result_1.value + (result_2.total - result_2.withdraw) + (cap.total - cap.withdraw);
+
+ + + +
+ + + +## Function `withdraw_amount_of_linear_cap` + +Returns the amount of the LinearWithdrawCapability can mint now. + + +
public fun withdraw_amount_of_linear_cap<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u128
+
+ + + +
+Implementation + + +
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
+    }
+}
+
+ + + +
+ +
+Specification + + + +
pragma aborts_if_is_partial;
+aborts_if !exists<Timestamp::CurrentTimeMilliseconds>(StarcoinFramework::CoreAddresses::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;
+ensures [abstract] result <= cap.total - cap.withdraw;
+
+ + + +
+ + + +## Function `is_empty_linear_withdraw_cap` + +Check if the given LinearWithdrawCapability is empty. + + +
public fun is_empty_linear_withdraw_cap<TokenT: store>(key: &Treasury::LinearWithdrawCapability<TokenT>): bool
+
+ + + +
+Implementation + + +
public fun is_empty_linear_withdraw_cap<TokenT:store>(key: &LinearWithdrawCapability<TokenT>) : bool {
+    key.total == key.withdraw
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == (key.total == key.withdraw);
+
+ + + +
+ + + +## Function `remove_withdraw_capability` + +Remove mint capability from signer. + + +
public fun remove_withdraw_capability<TokenT: store>(signer: &signer): Treasury::WithdrawCapability<TokenT>
+
+ + + +
+Implementation + + +
public fun remove_withdraw_capability<TokenT: store>(signer: &signer): WithdrawCapability<TokenT>
+acquires WithdrawCapability {
+    move_from<WithdrawCapability<TokenT>>(Signer::address_of(signer))
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
+ensures !exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
+
+ + + +
+ + + +## Function `add_withdraw_capability` + +Save mint capability to signer. + + +
public fun add_withdraw_capability<TokenT: store>(signer: &signer, cap: Treasury::WithdrawCapability<TokenT>)
+
+ + + +
+Implementation + + +
public fun add_withdraw_capability<TokenT: store>(signer: &signer, cap: WithdrawCapability<TokenT>) {
+    move_to(signer, cap)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
+ensures exists<WithdrawCapability<TokenT>>(Signer::address_of(signer));
+
+ + + +
+ + + +## Function `destroy_withdraw_capability` + +Destroy the given mint capability. + + +
public fun destroy_withdraw_capability<TokenT: store>(cap: Treasury::WithdrawCapability<TokenT>)
+
+ + + +
+Implementation + + +
public fun destroy_withdraw_capability<TokenT: store>(cap: WithdrawCapability<TokenT>) {
+    let WithdrawCapability<TokenT> {} = cap;
+}
+
+ + + +
+ +
+Specification + + + +
+ + + +## Function `add_linear_withdraw_capability` + +Add LinearWithdrawCapability to signer, a address only can have one LinearWithdrawCapability + + +
public fun add_linear_withdraw_capability<TokenT: store>(signer: &signer, cap: Treasury::LinearWithdrawCapability<TokenT>)
+
+ + + +
+Implementation + + +
public fun add_linear_withdraw_capability<TokenT: store>(signer: &signer, cap: LinearWithdrawCapability<TokenT>) {
+    move_to(signer, cap)
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if exists<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
+ensures exists<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
+
+ + + +
+ + + +## Function `remove_linear_withdraw_capability` + +Remove LinearWithdrawCapability from signer. + + +
public fun remove_linear_withdraw_capability<TokenT: store>(signer: &signer): Treasury::LinearWithdrawCapability<TokenT>
+
+ + + +
+Implementation + + +
public fun remove_linear_withdraw_capability<TokenT: store>(signer: &signer): LinearWithdrawCapability<TokenT>
+acquires LinearWithdrawCapability {
+    move_from<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer))
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
+ensures !exists<LinearWithdrawCapability<TokenT>>(Signer::address_of(signer));
+
+ + + +
+ + + +## Function `destroy_linear_withdraw_capability` + +Destroy LinearWithdrawCapability. + + +
public fun destroy_linear_withdraw_capability<TokenT: store>(cap: Treasury::LinearWithdrawCapability<TokenT>)
+
+ + + +
+Implementation + + +
public fun destroy_linear_withdraw_capability<TokenT: store>(cap: LinearWithdrawCapability<TokenT>) {
+    let LinearWithdrawCapability{ total: _, withdraw: _, start_time: _, period: _ } = cap;
+}
+
+ + + +
+ + + +## Function `is_empty_linear_withdraw_capability` + + + +
public fun is_empty_linear_withdraw_capability<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): bool
+
+ + + +
+Implementation + + +
public fun is_empty_linear_withdraw_capability<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): bool {
+    cap.total == cap.withdraw
+}
+
+ + + +
+ + + +## Function `get_linear_withdraw_capability_total` + +Get LinearWithdrawCapability total amount + + +
public fun get_linear_withdraw_capability_total<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u128
+
+ + + +
+Implementation + + +
public fun get_linear_withdraw_capability_total<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): u128 {
+    cap.total
+}
+
+ + + +
+ + + +## Function `get_linear_withdraw_capability_withdraw` + +Get LinearWithdrawCapability withdraw amount + + +
public fun get_linear_withdraw_capability_withdraw<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u128
+
+ + + +
+Implementation + + +
public fun get_linear_withdraw_capability_withdraw<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): u128 {
+    cap.withdraw
+}
+
+ + + +
+ + + +## Function `get_linear_withdraw_capability_period` + +Get LinearWithdrawCapability period in seconds + + +
public fun get_linear_withdraw_capability_period<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u64
+
+ + + +
+Implementation + + +
public fun get_linear_withdraw_capability_period<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): u64 {
+    cap.period
+}
+
+ + + +
+ + + +## Function `get_linear_withdraw_capability_start_time` + +Get LinearWithdrawCapability start_time in seconds + + +
public fun get_linear_withdraw_capability_start_time<TokenT: store>(cap: &Treasury::LinearWithdrawCapability<TokenT>): u64
+
+ + + +
+Implementation + + +
public fun get_linear_withdraw_capability_start_time<TokenT: store>(cap: &LinearWithdrawCapability<TokenT>): u64 {
+    cap.start_time
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
+ + + + + + + +
fun spec_balance<TokenType>(): num {
+   global<Treasury<TokenType>>(Token::SPEC_TOKEN_TEST_ADDRESS()).balance.value
+}
+
diff --git a/build/StarcoinFramework/docs/TreasuryScripts.md b/build/StarcoinFramework/docs/TreasuryScripts.md new file mode 100644 index 00000000..68c60d2f --- /dev/null +++ b/build/StarcoinFramework/docs/TreasuryScripts.md @@ -0,0 +1,204 @@ + + + +# 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) + + +
use 0x1::Account;
+use 0x1::Offer;
+use 0x1::Token;
+use 0x1::Treasury;
+use 0x1::TreasuryWithdrawDaoProposal;
+
+ + + + + +## Function `withdraw_and_split_lt_withdraw_cap` + + + +
public entry fun withdraw_and_split_lt_withdraw_cap<TokenT: store>(signer: signer, for_address: address, amount: u128, lock_period: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `withdraw_token_with_linear_withdraw_capability` + + + +
public entry fun withdraw_token_with_linear_withdraw_capability<TokenT: store>(signer: signer)
+
+ + + +
+Implementation + + +
public entry 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);
+    };
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `propose_withdraw` + + + +
public entry fun propose_withdraw<TokenT: copy, drop, store>(signer: signer, receiver: address, amount: u128, period: u64, exec_delay: u64)
+
+ + + +
+Implementation + + +
public entry 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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `execute_withdraw_proposal` + + + +
public entry fun execute_withdraw_proposal<TokenT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
public entry 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);
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
diff --git a/build/StarcoinFramework/docs/TreasuryWithdrawDaoProposal.md b/build/StarcoinFramework/docs/TreasuryWithdrawDaoProposal.md new file mode 100644 index 00000000..0e13d8cc --- /dev/null +++ b/build/StarcoinFramework/docs/TreasuryWithdrawDaoProposal.md @@ -0,0 +1,320 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+cap: Treasury::WithdrawCapability<TokenT> +
+
+ +
+
+ + +
+ + + +## Struct `WithdrawToken` + +WithdrawToken request. + + +
struct WithdrawToken has copy, drop, store
+
+ + + +
+Fields + + +
+
+receiver: address +
+
+ the receiver of withdraw tokens. +
+
+amount: u128 +
+
+ how many tokens to mint. +
+
+period: u64 +
+
+ How long in milliseconds does it take for the token to be released +
+
+ + +
+ + + +## Constants + + + + + + +
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>)
+
+ + + +
+Implementation + + +
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 });
+}
+
+ + + +
+ +
+Specification + + + +
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` + +Entrypoint for the proposal. + + +
public fun propose_withdraw<TokenT: copy, drop, store>(signer: &signer, receiver: address, amount: u128, period: u64, exec_delay: u64)
+
+ + + +
+Implementation + + +
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,
+    );
+}
+
+ + + +
+ +
+Specification + + + +
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::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` + +Once the proposal is agreed, anyone can call the method to make the proposal happen. + + +
public fun execute_withdraw_proposal<TokenT: copy, drop, store>(signer: &signer, proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ +
+Specification + + + +
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());
+
+ + + +
+ + + +## Function `withdraw_for_block_reward` + +Provider a port for get block reward STC from Treasury, only genesis account can invoke this function. +The TreasuryWithdrawCapability is locked in TreasuryWithdrawDaoProposal, and only can withdraw by DAO proposal. +This approach is not graceful, but restricts the operation to genesis accounts only, so there are no security issues either. + + +
public fun withdraw_for_block_reward<TokenT: store>(signer: &signer, reward: u128): Token::Token<TokenT>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict;
+pragma aborts_if_is_partial;
+
diff --git a/build/StarcoinFramework/docs/TypeInfo.md b/build/StarcoinFramework/docs/TypeInfo.md new file mode 100644 index 00000000..be768667 --- /dev/null +++ b/build/StarcoinFramework/docs/TypeInfo.md @@ -0,0 +1,192 @@ + + + +# Module `0x1::TypeInfo` + + + +- [Struct `TypeInfo`](#0x1_TypeInfo_TypeInfo) +- [Function `account_address`](#0x1_TypeInfo_account_address) +- [Function `module_name`](#0x1_TypeInfo_module_name) +- [Function `struct_name`](#0x1_TypeInfo_struct_name) +- [Function `type_of`](#0x1_TypeInfo_type_of) +- [Function `size_of_val`](#0x1_TypeInfo_size_of_val) + + +
use 0x1::BCS;
+use 0x1::Token;
+
+ + + + + +## Struct `TypeInfo` + + + +
struct TypeInfo has copy, drop, store
+
+ + + +
+Fields + + +
+
+account_address: address +
+
+ +
+
+module_name: vector<u8> +
+
+ +
+
+struct_name: vector<u8> +
+
+ +
+
+ + +
+ + + +## Function `account_address` + + + +
public fun account_address(type_info: &TypeInfo::TypeInfo): address
+
+ + + +
+Implementation + + +
public fun account_address(type_info: &TypeInfo): address {
+    type_info.account_address
+}
+
+ + + +
+ + + +## Function `module_name` + + + +
public fun module_name(type_info: &TypeInfo::TypeInfo): vector<u8>
+
+ + + +
+Implementation + + +
public fun module_name(type_info: &TypeInfo): vector<u8> {
+    *&type_info.module_name
+}
+
+ + + +
+ + + +## Function `struct_name` + + + +
public fun struct_name(type_info: &TypeInfo::TypeInfo): vector<u8>
+
+ + + +
+Implementation + + +
public fun struct_name(type_info: &TypeInfo): vector<u8> {
+    *&type_info.struct_name
+}
+
+ + + +
+ + + +## Function `type_of` + + + +
public fun type_of<T>(): TypeInfo::TypeInfo
+
+ + + +
+Implementation + + +
public fun type_of<T>(): TypeInfo {
+    let (account_address, module_name, struct_name) = Token::type_of<T>();
+    TypeInfo {
+        account_address,
+        module_name,
+        struct_name
+    }
+}
+
+ + + +
+ + + +## Function `size_of_val` + +Return the BCS size, in bytes, of value at val_ref. + +See the [BCS spec](https://github.com/diem/bcs) + +See test_size_of_val() for an analysis of common types and +nesting patterns, as well as test_size_of_val_vectors() for an +analysis of vector size dynamism. + + +
public fun size_of_val<T: store>(val_ref: &T): u64
+
+ + + +
+Implementation + + +
public fun size_of_val<T: store>(val_ref: &T): u64 {
+    // Return vector length of vectorized BCS representation.
+    Vector::length(&BCS::to_bytes<T>(val_ref))
+}
+
+ + + +
diff --git a/build/StarcoinFramework/docs/U256.md b/build/StarcoinFramework/docs/U256.md new file mode 100644 index 00000000..7b3f3368 --- /dev/null +++ b/build/StarcoinFramework/docs/U256.md @@ -0,0 +1,946 @@ + + + +# 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 `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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+bits: vector<u64> +
+
+ little endian representation +
+
+ + +
+ +
+Specification + + + +
invariant len(bits) == 4;
+
+ + + + + + + +
fun value_of_U256(a: U256): num {
+   a.bits[0] +
+   a.bits[1] * P64 +
+   a.bits[2] * P64 * P64 +
+   a.bits[3] * P64 * P64 * P64
+}
+
+ + + +
+ + + +## Constants + + + + + + +
const P32: u64 = 4294967296;
+
+ + + + + + + +
const P64: u128 = 18446744073709551616;
+
+ + + + + + + +
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
+
+ + + +
+Implementation + + +
public fun zero(): U256 {
+    from_u128(0u128)
+}
+
+ + + +
+ + + +## Function `one` + + + +
public fun one(): U256::U256
+
+ + + +
+Implementation + + +
public fun one(): U256 {
+    from_u128(1u128)
+}
+
+ + + +
+ + + +## Function `from_u64` + + + +
public fun from_u64(v: u64): U256::U256
+
+ + + +
+Implementation + + +
public fun from_u64(v: u64): U256 {
+    from_u128((v as u128))
+}
+
+ + + +
+ + + +## Function `from_u128` + + + +
public fun from_u128(v: u128): U256::U256
+
+ + + +
+Implementation + + +
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 }
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+pragma opaque;
+ensures value_of_U256(result) == v;
+
+ + + +
+ + + +## Function `from_big_endian` + + + +
public fun from_big_endian(data: vector<u8>): U256::U256
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `from_little_endian` + + + +
public fun from_little_endian(data: vector<u8>): U256::U256
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+
+ + + +
+ + + +## Function `to_u128` + + + +
public fun to_u128(v: &U256::U256): u128
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+pragma opaque;
+aborts_if value_of_U256(v) >= P64 * P64;
+ensures value_of_U256(v) == result;
+
+ + + +
+ + + +## Function `compare` + + + +
public fun compare(a: &U256::U256, b: &U256::U256): u8
+
+ + + +
+Implementation + + +
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
+            }
+        }
+    };
+    return EQUAL
+}
+
+ + + +
+ + + +## Function `add` + + + +
public fun add(a: U256::U256, b: U256::U256): U256::U256
+
+ + + +
+Implementation + + +
public fun add(a: U256, b: U256): U256 {
+    native_add(&mut a, &b);
+    a
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if value_of_U256(a) + value_of_U256(b) >= P64 * P64 * P64 * P64;
+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
+
+ + + +
+Implementation + + +
public fun sub(a: U256, b: U256): U256 {
+    native_sub(&mut a, &b);
+    a
+}
+
+ + + +
+ +
+Specification + + + +
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
+
+ + + +
+Implementation + + +
public fun mul(a: U256, b: U256): U256 {
+    native_mul(&mut a, &b);
+    a
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+pragma timeout = 200;
+aborts_if value_of_U256(a) * value_of_U256(b) >= P64 * P64 * P64 * P64;
+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
+
+ + + +
+Implementation + + +
public fun div(a: U256, b: U256): U256 {
+    native_div(&mut a, &b);
+    a
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+pragma timeout = 160;
+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
+
+ + + +
+Implementation + + +
public fun rem(a: U256, b: U256): U256 {
+    native_rem(&mut a, &b);
+    a
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+pragma timeout = 160;
+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
+
+ + + +
+Implementation + + +
public fun pow(a: U256, b: U256): U256 {
+    native_pow(&mut a, &b);
+    a
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+pragma opaque;
+pragma timeout = 600;
+let p = pow_spec(value_of_U256(a), value_of_U256(b));
+aborts_if p >= P64 * P64 * P64 * P64;
+ensures value_of_U256(result) == p;
+
+ + + +
+ + + +## Function `from_bytes` + + + +
fun from_bytes(data: &vector<u8>, be: bool): U256::U256
+
+ + + +
+Implementation + + +
native fun from_bytes(data: &vector<u8>, be: bool): U256;
+
+ + + +
+ + + +## Function `native_add` + + + +
fun native_add(a: &mut U256::U256, b: &U256::U256)
+
+ + + +
+Implementation + + +
native fun native_add(a: &mut U256, b: &U256);
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if value_of_U256(a) + value_of_U256(b) >= P64 * P64 * P64 * P64;
+ensures value_of_U256(a) == value_of_U256(old(a)) + value_of_U256(b);
+
+ + + +
+ + + +## Function `native_sub` + + + +
fun native_sub(a: &mut U256::U256, b: &U256::U256)
+
+ + + +
+Implementation + + +
native fun native_sub(a: &mut U256, b: &U256);
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if value_of_U256(a) - value_of_U256(b) < 0;
+ensures value_of_U256(a) == value_of_U256(old(a)) - value_of_U256(b);
+
+ + + +
+ + + +## Function `native_mul` + + + +
fun native_mul(a: &mut U256::U256, b: &U256::U256)
+
+ + + +
+Implementation + + +
native fun native_mul(a: &mut U256, b: &U256);
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if value_of_U256(a) * value_of_U256(b) >= P64 * P64 * P64 * P64;
+ensures value_of_U256(a) == value_of_U256(old(a)) * value_of_U256(b);
+
+ + + +
+ + + +## Function `native_div` + + + +
fun native_div(a: &mut U256::U256, b: &U256::U256)
+
+ + + +
+Implementation + + +
native fun native_div(a: &mut U256, b: &U256);
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if value_of_U256(b) == 0;
+ensures value_of_U256(a) == value_of_U256(old(a)) / value_of_U256(b);
+
+ + + +
+ + + +## Function `native_rem` + + + +
fun native_rem(a: &mut U256::U256, b: &U256::U256)
+
+ + + +
+Implementation + + +
native fun native_rem(a: &mut U256, b: &U256);
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if value_of_U256(b) == 0;
+ensures value_of_U256(a) == value_of_U256(old(a)) % value_of_U256(b);
+
+ + + +
+ + + +## Function `native_pow` + + + +
fun native_pow(a: &mut U256::U256, b: &U256::U256)
+
+ + + +
+Implementation + + +
native fun native_pow(a: &mut U256, b: &U256);
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+aborts_if pow_spec(value_of_U256(a), value_of_U256(b)) >= P64 * P64 * P64 * P64;
+ensures value_of_U256(a) == pow_spec(value_of_U256(old(a)), value_of_U256(b));
+
+ + + + + + + +
fun pow_spec(base: num, expon: num): num {
+   // This actually doesn't follow a strict definition as 0^0 is undefined
+   // mathematically. But the U256::pow of Rust is defined to be like this:
+   // Link: https://docs.rs/uint/0.9.3/src/uint/uint.rs.html#1000-1003
+   if (expon > 0) {
+       let x = pow_spec(base, expon / 2);
+       if (expon % 2 == 0) { x * x } else { x * x * base }
+   } else {
+       1
+   }
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = true;
+
diff --git a/build/StarcoinFramework/docs/UpgradeModuleDaoProposal.md b/build/StarcoinFramework/docs/UpgradeModuleDaoProposal.md new file mode 100644 index 00000000..add8f904 --- /dev/null +++ b/build/StarcoinFramework/docs/UpgradeModuleDaoProposal.md @@ -0,0 +1,350 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
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
+
+ + + +
+Fields + + +
+
+cap: PackageTxnManager::UpgradePlanCapability +
+
+ +
+
+ + +
+ + + +## Struct `UpgradeModule` + +request of upgrading module contract code. + + +
struct UpgradeModule has copy, drop, store
+
+ + + +
+Fields + + +
+
+module_address: address +
+
+ +
+
+package_hash: vector<u8> +
+
+ +
+
+version: u64 +
+
+ +
+
+ + +
+ + + +## Struct `UpgradeModuleV2` + + + +
struct UpgradeModuleV2 has copy, drop, store
+
+ + + +
+Fields + + +
+
+module_address: address +
+
+ +
+
+package_hash: vector<u8> +
+
+ +
+
+version: u64 +
+
+ +
+
+enforced: bool +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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)
+
+ + + +
+Implementation + + +
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 })
+}
+
+ + + +
+ +
+Specification + + + +
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)
+
+ + + +
+Implementation + + +
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,
+    );
+}
+
+ + + +
+ +
+Specification + + + +
pragma aborts_if_is_partial = true;
+include AbortIfUnableUpgrade<TokenT>;
+
+ + + +
+ + + +## Function `submit_module_upgrade_plan` + +Once the proposal is agreed, anyone can call this method to generate the upgrading plan. + + +
public fun submit_module_upgrade_plan<TokenT: copy, drop, store>(proposer_address: address, proposal_id: u64)
+
+ + + +
+Implementation + + +
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,
+    );
+}
+
+ + + +
+ +
+Specification + + + +
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};
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict;
+pragma aborts_if_is_partial;
+
diff --git a/build/StarcoinFramework/docs/VMConfig.md b/build/StarcoinFramework/docs/VMConfig.md new file mode 100644 index 00000000..973bf229 --- /dev/null +++ b/build/StarcoinFramework/docs/VMConfig.md @@ -0,0 +1,738 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_0) + + +
use 0x1::ChainId;
+use 0x1::Config;
+use 0x1::CoreAddresses;
+
+ + + + + +## 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
+
+ + + +
+Fields + + +
+
+gas_schedule: VMConfig::GasSchedule +
+
+ +
+
+ + +
+ + + +## Struct `GasSchedule` + +The gas schedule keeps two separate schedules for the gas: +* The instruction_schedule: This holds the gas for each bytecode instruction. +* The native_schedule: This holds the gas for used (per-byte operated over) for each native +function. +A couple notes: +1. In the case that an instruction is deleted from the bytecode, that part of the cost schedule +still needs to remain the same; once a slot in the table is taken by an instruction, that is its +slot for the rest of time (since that instruction could already exist in a module on-chain). +2. The initialization of the module will publish the instruction table to the genesis +address, and will preload the vector with the gas schedule for instructions. The VM will then +load this into memory at the startup of each block. + + +
struct GasSchedule has copy, drop, store
+
+ + + +
+Fields + + +
+
+instruction_schedule: vector<u8> +
+
+ +
+
+native_schedule: vector<u8> +
+
+ +
+
+gas_constants: VMConfig::GasConstants +
+
+ +
+
+ + +
+ + + +## Struct `GasConstants` + +The gas constants contains all kind of constants used in gas calculation. + + +
struct GasConstants has copy, drop, store
+
+ + + +
+Fields + + +
+
+global_memory_per_byte_cost: u64 +
+
+ The cost per-byte written to global storage. +
+
+global_memory_per_byte_write_cost: u64 +
+
+ The cost per-byte written to storage. +
+
+min_transaction_gas_units: u64 +
+
+ We charge one unit of gas per-byte for the first 600 bytes +
+
+large_transaction_cutoff: u64 +
+
+ Any transaction over this size will be charged INTRINSIC_GAS_PER_BYTE per byte +
+
+instrinsic_gas_per_byte: u64 +
+
+ The units of gas that should be charged per byte for every transaction. +
+
+maximum_number_of_gas_units: u64 +
+
+ 1 nanosecond should equal one unit of computational gas. We bound the maximum + computational time of any given transaction at 10 milliseconds. We want this number and + MAX_PRICE_PER_GAS_UNIT to always satisfy the inequality that + MAXIMUM_NUMBER_OF_GAS_UNITS * MAX_PRICE_PER_GAS_UNIT < min(u64::MAX, GasUnits::MAX) +
+
+min_price_per_gas_unit: u64 +
+
+ The minimum gas price that a transaction can be submitted with. +
+
+max_price_per_gas_unit: u64 +
+
+ The maximum gas unit price that a transaction can be submitted with. +
+
+max_transaction_size_in_bytes: u64 +
+
+ The max transaction size in bytes that a transaction can have. +
+
+gas_unit_scaling_factor: u64 +
+
+ gas unit scaling factor. +
+
+default_account_size: u64 +
+
+ default account size. +
+
+ + +
+ + + +## Struct `GasCost` + +The 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
+
+ + + +
+Fields + + +
+
+instruction_gas: u64 +
+
+ +
+
+memory_gas: u64 +
+
+ +
+
+ + +
+ + + +## Function `instruction_schedule` + + + +
public fun instruction_schedule(): vector<VMConfig::GasCost>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `native_schedule` + + + +
public fun native_schedule(): vector<VMConfig::GasCost>
+
+ + + +
+Implementation + + +
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::new_table_handle 33
+    Vector::push_back(&mut table, new_gas_cost(4, 1));
+    // Table::add_box 34
+    Vector::push_back(&mut table, new_gas_cost(4, 1));
+    // Table::borrow_box 35
+    Vector::push_back(&mut table, new_gas_cost(10, 1));
+    // Table::remove_box 36
+    Vector::push_back(&mut table, new_gas_cost(8, 1));
+    // Table::contains_box 37
+    Vector::push_back(&mut table, new_gas_cost(40, 1));
+    // Table::destroy_empty_box 38
+    Vector::push_back(&mut table, new_gas_cost(20, 1));
+    // Table::drop_unchecked_box 39
+    Vector::push_back(&mut table, new_gas_cost(73, 1));
+    // string.check_utf8 40
+    Vector::push_back(&mut table, new_gas_cost(4, 1));
+    // string.sub_str 41
+    Vector::push_back(&mut table, new_gas_cost(4, 1));
+    // string.is_char_boundary 42
+    Vector::push_back(&mut table, new_gas_cost(4, 1));
+    // Table::string.index_of 43
+    Vector::push_back(&mut table, new_gas_cost(4, 1));
+    // FromBCS::from_bytes 44
+    Vector::push_back(&mut table, new_gas_cost(4, 1));
+    // Secp256k1::ecdsa_recover_internal 45
+    Vector::push_back(&mut table, new_gas_cost(4, 1));
+    // Vector::spawn_from 46
+    Vector::push_back(&mut table, new_gas_cost(4, 1));
+
+    table
+}
+
+ + + +
+ + + +## Function `gas_constants` + + + +
public fun gas_constants(): VMConfig::GasConstants
+
+ + + +
+Implementation + + +
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,
+    }
+}
+
+ + + +
+ + + +## Function `new_gas_cost` + + + +
fun new_gas_cost(instr_gas: u64, mem_gas: u64): VMConfig::GasCost
+
+ + + +
+Implementation + + +
fun new_gas_cost(instr_gas: u64, mem_gas: u64): GasCost {
+    GasCost {
+        instruction_gas: instr_gas,
+        memory_gas: mem_gas,
+    }
+}
+
+ + + +
+ + + +## Function `new_vm_config` + +Create a new vm config, mainly used in DAO. + + +
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
+
+ + + +
+Implementation + + +
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 },
+    }
+}
+
+ + + +
+ + + +## Function `initialize` + +Initialize the table under the genesis account + + +
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)
+
+ + + +
+Implementation + + +
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,
+        ),
+    );
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if Signer::address_of(account) != CoreAddresses::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),
+    );
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/Vector.md b/build/StarcoinFramework/docs/Vector.md new file mode 100644 index 00000000..5ad6187f --- /dev/null +++ b/build/StarcoinFramework/docs/Vector.md @@ -0,0 +1,861 @@ + + + +# 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 `spawn_from`](#0x1_Vector_spawn_from) +- [Function `spawn_from_vec`](#0x1_Vector_spawn_from_vec) +- [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) +- [Module Specification](#@Module_Specification_1) + - [Helper Functions](#@Helper_Functions_2) + + +
+ + + + + +## 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>
+
+ + + +
+Implementation + + +
native public fun empty<Element>(): vector<Element>;
+
+ + + +
+ + + +## Function `length` + +Return the length of the vector. + + +
public fun length<Element>(v: &vector<Element>): u64
+
+ + + +
+Implementation + + +
native public fun length<Element>(v: &vector<Element>): u64;
+
+ + + +
+ + + +## Function `borrow` + +Acquire an immutable reference to the ith element of the vector v. +Aborts if i is out of bounds. + + +
public fun borrow<Element>(v: &vector<Element>, i: u64): &Element
+
+ + + +
+Implementation + + +
native public fun borrow<Element>(v: &vector<Element>, i: u64): ∈
+
+ + + +
+ + + +## Function `push_back` + +Add element e to the end of the vector v. + + +
public fun push_back<Element>(v: &mut vector<Element>, e: Element)
+
+ + + +
+Implementation + + +
native public fun push_back<Element>(v: &mut vector<Element>, e: Element);
+
+ + + +
+ + + +## Function `borrow_mut` + +Return a mutable reference to the ith 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
+
+ + + +
+Implementation + + +
native public fun borrow_mut<Element>(v: &mut vector<Element>, i: u64): &mut Element;
+
+ + + +
+ + + +## Function `pop_back` + +Pop an element from the end of vector v. +Aborts if v is empty. + + +
public fun pop_back<Element>(v: &mut vector<Element>): Element
+
+ + + +
+Implementation + + +
native public fun pop_back<Element>(v: &mut vector<Element>): Element;
+
+ + + +
+ + + +## Function `destroy_empty` + +Destroy the vector v. +Aborts if v is not empty. + + +
public fun destroy_empty<Element>(v: vector<Element>)
+
+ + + +
+Implementation + + +
native public fun destroy_empty<Element>(v: vector<Element>);
+
+ + + +
+ + + +## Function `spawn_from` + +Spawn a sub vector from a vector + + +
fun spawn_from<Element>(v: &vector<Element>, offset: u64, size: u64): vector<Element>
+
+ + + +
+Implementation + + +
native fun spawn_from<Element>(v: &vector<Element>, offset: u64, size: u64): vector<Element>;
+
+ + + +
+ +
+Specification + + + +
pragma opaque;
+ensures [abstract] result == v[offset..offset+size];
+
+ + + +
+ + + +## Function `spawn_from_vec` + + + +
public fun spawn_from_vec<Element: copy>(v: &vector<Element>, offset: u64, size: u64): vector<Element>
+
+ + + +
+Implementation + + +
public fun spawn_from_vec<Element: copy>(v: &vector<Element>, offset: u64, size: u64): vector<Element> {
+    let len = length(v);
+    let end_idx = (offset + size);
+    assert!(end_idx <= len, EINDEX_OUT_OF_BOUNDS);
+    assert!(size > 0, EINDEX_OUT_OF_BOUNDS);
+    if (offset == 0 && end_idx == len) {
+        return *v
+    };
+    spawn_from(v, offset, size)
+}
+
+ + + +
+ + + +## Function `swap` + +Swaps the elements at the ith and jth indices in the vector v. +Aborts if ior j is out of bounds. + + +
public fun swap<Element>(v: &mut vector<Element>, i: u64, j: u64)
+
+ + + +
+Implementation + + +
native public fun swap<Element>(v: &mut vector<Element>, i: u64, j: u64);
+
+ + + +
+ + + +## Function `singleton` + +Return an vector of size one containing element e. + + +
public fun singleton<Element>(e: Element): vector<Element>
+
+ + + +
+Implementation + + +
public fun singleton<Element>(e: Element): vector<Element> {
+    let v = empty();
+    push_back(&mut v, e);
+    v
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+ensures result == vec(e);
+
+ + + + + + + +
fun spec_singleton<Element>(e: Element): vector<Element> {
+   vec(e)
+}
+
+ + + +
+ + + +## Function `reverse` + +Reverses the order of the elements in the vector v in place. + + +
public fun reverse<Element>(v: &mut vector<Element>)
+
+ + + +
+Implementation + + +
public fun reverse<Element>(v: &mut vector<Element>) {
+    native_reverse(v)
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `native_reverse` + + + +
fun native_reverse<Element>(this: &mut vector<Element>)
+
+ + + +
+Implementation + + +
native fun native_reverse<Element>(this: &mut vector<Element>);
+
+ + + +
+ + + +## Function `append` + +Pushes all of the elements of the other vector into the lhs vector. + + +
public fun append<Element>(lhs: &mut vector<Element>, other: vector<Element>)
+
+ + + +
+Implementation + + +
public fun append<Element>(lhs: &mut vector<Element>, other: vector<Element>) {
+    native_append(lhs, other);
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `native_append` + + + +
fun native_append<Element>(lhs: &mut vector<Element>, other: vector<Element>)
+
+ + + +
+Implementation + + +
native fun native_append<Element>(lhs: &mut vector<Element>, other: vector<Element>);
+
+ + + +
+ + + +## Function `is_empty` + +Return true if the vector v has no elements and false otherwise. + + +
public fun is_empty<Element>(v: &vector<Element>): bool
+
+ + + +
+Implementation + + +
public fun is_empty<Element>(v: &vector<Element>): bool {
+    length(v) == 0
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `contains` + +Return true if e is in the vector v. + + +
public fun contains<Element>(v: &vector<Element>, e: &Element): bool
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `index_of` + +Return (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)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `remove` + +Remove the ith 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
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `native_remove` + + + +
fun native_remove<Element>(this: &mut vector<Element>, i: u64): Element
+
+ + + +
+Implementation + + +
native fun native_remove<Element>(this: &mut vector<Element>, i: u64): Element;
+
+ + + +
+ + + +## Function `swap_remove` + +Swap the ith 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
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ +
+Specification + + + +
pragma intrinsic = true;
+
+ + + +
+ + + +## Function `split` + +Split a vector into sub-vectors of size sub_len, + + +
public fun split<Element: copy, drop, store>(v: &vector<Element>, sub_len: u64): vector<vector<Element>>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ +
+Specification + + + +
pragma verify = false;
+aborts_if sub_len == 0;
+
+ + + +
+ + + +## Module Specification + + + + + +### Helper Functions + +Check whether a vector contains an element. + + + + + +
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)]
+}
+
diff --git a/build/StarcoinFramework/docs/Version.md b/build/StarcoinFramework/docs/Version.md new file mode 100644 index 00000000..64012d09 --- /dev/null +++ b/build/StarcoinFramework/docs/Version.md @@ -0,0 +1,146 @@ + + + +# 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) +- [Module Specification](#@Module_Specification_1) + + +
use 0x1::Config;
+
+ + + + + +## Struct `Version` + +Version. + + +
struct Version has copy, drop, store
+
+ + + +
+Fields + + +
+
+major: u64 +
+
+ major number. +
+
+ + +
+ + + +## Constants + + + + + + +
const EMAJOR_TO_OLD: u64 = 101;
+
+ + + + + +## Function `new_version` + +Create a new version. + + +
public fun new_version(major: u64): Version::Version
+
+ + + +
+Implementation + + +
public fun new_version(major: u64): Version {
+    Version { major }
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if false;
+
+ + + +
+ + + +## Function `get` + +Get version under addr. + + +
public fun get(addr: address): u64
+
+ + + +
+Implementation + + +
public fun get(addr: address): u64 {
+    let version = Config::get_by_address<Self::Version>(addr);
+    version.major
+}
+
+ + + +
+ +
+Specification + + + +
aborts_if !exists<Config::Config<Version>>(addr);
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify;
+pragma aborts_if_is_strict;
+
diff --git a/build/StarcoinFramework/docs/YieldFarming.md b/build/StarcoinFramework/docs/YieldFarming.md new file mode 100644 index 00000000..e1535fd0 --- /dev/null +++ b/build/StarcoinFramework/docs/YieldFarming.md @@ -0,0 +1,886 @@ + + + +# 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) +- [Module Specification](#@Module_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
+
+ + + +
+Fields + + +
+
+treasury_token: Token::Token<RewardTokenT> +
+
+ +
+
+ + +
+ + + +## Resource `FarmingAsset` + + + +
struct FarmingAsset<PoolType, AssetT> has store, key
+
+ + + +
+Fields + + +
+
+asset_total_weight: u128 +
+
+ +
+
+harvest_index: u128 +
+
+ +
+
+last_update_timestamp: u64 +
+
+ +
+
+release_per_second: u128 +
+
+ +
+
+start_time: u64 +
+
+ +
+
+ + +
+ + + +## Resource `ParameterModifyCapability` + +Capability to modify parameter such as period and release amount + + +
struct ParameterModifyCapability<PoolType, AssetT> has store, key
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ + +
+ + + +## Resource `Stake` + +To store user's asset token + + +
struct Stake<PoolType, AssetT> has store, key
+
+ + + +
+Fields + + +
+
+asset: AssetT +
+
+ +
+
+asset_weight: u128 +
+
+ +
+
+last_harvest_index: u128 +
+
+ +
+
+gain: u128 +
+
+ +
+
+ + +
+ + + +## Struct `Exp` + + + +
struct Exp has copy, drop, store
+
+ + + +
+Fields + + +
+
+mantissa: u128 +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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
+
+ + + +
+Implementation + + +
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
+    }
+}
+
+ + + +
+ + + +## Function `mul_u128` + + + +
fun mul_u128(a: u128, b: u128): u128
+
+ + + +
+Implementation + + +
fun mul_u128(a: u128, b: u128): u128 {
+    if (a == 0 || b == 0) {
+        return 0
+    };
+
+    a * b
+}
+
+ + + +
+ + + +## Function `div_u128` + + + +
fun div_u128(a: u128, b: u128): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `truncate` + + + +
fun truncate(exp: YieldFarming::Exp): u128
+
+ + + +
+Implementation + + +
fun truncate(exp: Exp): u128 {
+    return exp.mantissa / EXP_SCALE
+}
+
+ + + +
+ + + +## Function `initialize` + +Called by token issuer +this will declare a yield farming pool + + +
public fun initialize<PoolType: store, RewardTokenT: store>(_account: &signer, _treasury_token: Token::Token<RewardTokenT>)
+
+ + + +
+Implementation + + +
public fun initialize<
+    PoolType: store,
+    RewardTokenT: store>(_account: &signer,
+                         _treasury_token: Token::Token<RewardTokenT>) {
+    abort Errors::deprecated(EDEPRECATED_FUNCTION)
+}
+
+ + + +
+ + + +## Function `initialize_asset` + + + +
public fun initialize_asset<PoolType: store, AssetT: store>(_account: &signer, _release_per_second: u128, _delay: u64): YieldFarming::ParameterModifyCapability<PoolType, AssetT>
+
+ + + +
+Implementation + + +
public fun initialize_asset<PoolType: store, AssetT: store>(
+    _account: &signer,
+    _release_per_second: u128,
+    _delay: u64): ParameterModifyCapability<PoolType, AssetT> {
+    abort Errors::deprecated(EDEPRECATED_FUNCTION)
+}
+
+ + + +
+ + + +## Function `modify_parameter` + + + +
public fun modify_parameter<PoolType: store, RewardTokenT: store, AssetT: store>(_cap: &YieldFarming::ParameterModifyCapability<PoolType, AssetT>, _broker: address, _release_per_second: u128)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `stake` + +Call by stake user, staking amount of asset in order to get yield farming token + + +
public fun stake<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address, _asset: AssetT, _asset_weight: u128)
+
+ + + +
+Implementation + + +
public fun stake<PoolType: store, RewardTokenT: store, AssetT: store>(
+    _account: &signer,
+    _broker: address,
+    _asset: AssetT,
+    _asset_weight: u128) {
+    abort Errors::deprecated(EDEPRECATED_FUNCTION)
+}
+
+ + + +
+ + + +## Function `unstake` + +Unstake asset from farming pool + + +
public fun unstake<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address): (AssetT, Token::Token<RewardTokenT>)
+
+ + + +
+Implementation + + +
public fun unstake<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address)
+: (AssetT, Token::Token<RewardTokenT>) {
+    abort Errors::deprecated(EDEPRECATED_FUNCTION)
+}
+
+ + + +
+ + + +## Function `harvest` + +Harvest yield farming token from stake + + +
public fun harvest<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address, _amount: u128): Token::Token<RewardTokenT>
+
+ + + +
+Implementation + + +
public fun harvest<PoolType: store,
+                   RewardTokenT: store,
+                   AssetT: store>(
+    _account: &signer,
+    _broker: address,
+    _amount: u128): Token::Token<RewardTokenT> {
+    abort Errors::deprecated(EDEPRECATED_FUNCTION)
+}
+
+ + + +
+ + + +## Function `query_gov_token_amount` + +The user can quering all yield farming amount in any time and scene + + +
public fun query_gov_token_amount<PoolType: store, RewardTokenT: store, AssetT: store>(_account: &signer, _broker: address): u128
+
+ + + +
+Implementation + + +
public fun query_gov_token_amount<PoolType: store,
+                                  RewardTokenT: store,
+                                  AssetT: store>(_account: &signer, _broker: address): u128 {
+    0
+}
+
+ + + +
+ + + +## Function `query_total_stake` + +Query total stake count from yield farming resource + + +
public fun query_total_stake<PoolType: store, AssetT: store>(_broker: address): u128
+
+ + + +
+Implementation + + +
public fun query_total_stake<PoolType: store,
+                             AssetT: store>(_broker: address): u128 {
+    0
+}
+
+ + + +
+ + + +## Function `query_stake` + +Query stake weight from user staking objects. + + +
public fun query_stake<PoolType: store, AssetT: store>(_account: &signer): u128
+
+ + + +
+Implementation + + +
public fun query_stake<PoolType: store,
+                       AssetT: store>(_account: &signer): u128 {
+    0
+}
+
+ + + +
+ + + +## Function `calculate_harvest_index_with_asset` + +Update farming asset + + +
fun calculate_harvest_index_with_asset<PoolType, AssetT>(_farming_asset: &YieldFarming::FarmingAsset<PoolType, AssetT>, _now_seconds: u64): u128
+
+ + + +
+Implementation + + +
fun calculate_harvest_index_with_asset<PoolType, AssetT>(_farming_asset: &FarmingAsset<PoolType, AssetT>, _now_seconds: u64): u128 {
+    0
+}
+
+ + + +
+ + + +## Function `calculate_harvest_index_weight_zero` + +There is calculating from harvest index and global parameters without asset_total_weight + + +
public fun calculate_harvest_index_weight_zero(_harvest_index: u128, _last_update_timestamp: u64, _now_seconds: u64, _release_per_second: u128): u128
+
+ + + +
+Implementation + + +
public fun calculate_harvest_index_weight_zero(_harvest_index: u128,
+                                               _last_update_timestamp: u64,
+                                               _now_seconds: u64,
+                                               _release_per_second: u128): u128 {
+    0
+}
+
+ + + +
+ + + +## Function `calculate_harvest_index` + +There is calculating from harvest index and global parameters + + +
public fun calculate_harvest_index(_harvest_index: u128, _asset_total_weight: u128, _last_update_timestamp: u64, _now_seconds: u64, _release_per_second: u128): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `calculate_withdraw_amount` + +This function will return a gain index + + +
public fun calculate_withdraw_amount(_harvest_index: u128, _last_harvest_index: u128, _asset_weight: u128): u128
+
+ + + +
+Implementation + + +
public fun calculate_withdraw_amount(_harvest_index: u128,
+                                     _last_harvest_index: u128,
+                                     _asset_weight: u128): u128 {
+    0
+}
+
+ + + +
+ + + +## Function `exists_at` + +Check the Farming of TokenT is exists. + + +
public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool
+
+ + + +
+Implementation + + +
public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool {
+    exists<Farming<PoolType, RewardTokenT>>(broker)
+}
+
+ + + +
+ + + +## Function `exists_asset_at` + +Check the Farming of AsssetT is exists. + + +
public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool
+
+ + + +
+Implementation + + +
public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool {
+    exists<FarmingAsset<PoolType, AssetT>>(broker)
+}
+
+ + + +
+ + + +## Function `exists_stake_at_address` + +Check stake at address exists. + + +
public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool
+
+ + + +
+Implementation + + +
public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool {
+    exists<Stake<PoolType, AssetT>>(account)
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+
diff --git a/build/StarcoinFramework/docs/YieldFarmingV2.md b/build/StarcoinFramework/docs/YieldFarmingV2.md new file mode 100644 index 00000000..f6d77651 --- /dev/null +++ b/build/StarcoinFramework/docs/YieldFarmingV2.md @@ -0,0 +1,1429 @@ + + + +# 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) +- [Module Specification](#@Module_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
+
+ + + +
+Fields + + +
+
+mantissa: u128 +
+
+ +
+
+ + +
+ + + +## Resource `Farming` + +The object of yield farming +RewardTokenT meaning token of yield farming + + +
struct Farming<PoolType, RewardTokenT> has store, key
+
+ + + +
+Fields + + +
+
+treasury_token: Token::Token<RewardTokenT> +
+
+ +
+
+ + +
+ + + +## Resource `FarmingAsset` + + + +
struct FarmingAsset<PoolType, AssetT> has store, key
+
+ + + +
+Fields + + +
+
+asset_total_weight: u128 +
+
+ +
+
+harvest_index: u128 +
+
+ +
+
+last_update_timestamp: u64 +
+
+ +
+
+release_per_second: u128 +
+
+ +
+
+start_time: u64 +
+
+ +
+
+alive: bool +
+
+ +
+
+ + +
+ + + +## Resource `Stake` + +To store user's asset token + + +
struct Stake<PoolType, AssetT> has store, key
+
+ + + +
+Fields + + +
+
+asset: AssetT +
+
+ +
+
+asset_weight: u128 +
+
+ +
+
+last_harvest_index: u128 +
+
+ +
+
+gain: u128 +
+
+ +
+
+ + +
+ + + +## Resource `ParameterModifyCapability` + +Capability to modify parameter such as period and release amount + + +
struct ParameterModifyCapability<PoolType, AssetT> has store, key
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ + +
+ + + +## Resource `HarvestCapability` + +Harvest ability to harvest + + +
struct HarvestCapability<PoolType, AssetT> has store, key
+
+ + + +
+Fields + + +
+
+trigger: address +
+
+ +
+
+ + +
+ + + +## Constants + + + + + + +
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
+
+ + + +
+Implementation + + +
fun exp_direct(num: u128): Exp {
+    Exp {
+        mantissa: num
+    }
+}
+
+ + + +
+ + + +## Function `exp_direct_expand` + + + +
fun exp_direct_expand(num: u128): YieldFarmingV2::Exp
+
+ + + +
+Implementation + + +
fun exp_direct_expand(num: u128): Exp {
+    Exp {
+        mantissa: mul_u128(num, EXP_SCALE)
+    }
+}
+
+ + + +
+ + + +## Function `mantissa` + + + +
fun mantissa(a: YieldFarmingV2::Exp): u128
+
+ + + +
+Implementation + + +
fun mantissa(a: Exp): u128 {
+    a.mantissa
+}
+
+ + + +
+ + + +## Function `add_exp` + + + +
fun add_exp(a: YieldFarmingV2::Exp, b: YieldFarmingV2::Exp): YieldFarmingV2::Exp
+
+ + + +
+Implementation + + +
fun add_exp(a: Exp, b: Exp): Exp {
+    Exp {
+        mantissa: add_u128(a.mantissa, b.mantissa)
+    }
+}
+
+ + + +
+ + + +## Function `exp` + + + +
fun exp(num: u128, denom: u128): YieldFarmingV2::Exp
+
+ + + +
+Implementation + + +
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
+    }
+}
+
+ + + +
+ + + +## Function `add_u128` + + + +
fun add_u128(a: u128, b: u128): u128
+
+ + + +
+Implementation + + +
fun add_u128(a: u128, b: u128): u128 {
+    a + b
+}
+
+ + + +
+ + + +## Function `sub_u128` + + + +
fun sub_u128(a: u128, b: u128): u128
+
+ + + +
+Implementation + + +
fun sub_u128(a: u128, b: u128): u128 {
+    a - b
+}
+
+ + + +
+ + + +## Function `mul_u128` + + + +
fun mul_u128(a: u128, b: u128): u128
+
+ + + +
+Implementation + + +
fun mul_u128(a: u128, b: u128): u128 {
+    if (a == 0 || b == 0) {
+        return 0
+    };
+    a * b
+}
+
+ + + +
+ + + +## Function `div_u128` + + + +
fun div_u128(a: u128, b: u128): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `truncate` + + + +
fun truncate(exp: YieldFarmingV2::Exp): u128
+
+ + + +
+Implementation + + +
fun truncate(exp: Exp): u128 {
+    return exp.mantissa / EXP_SCALE
+}
+
+ + + +
+ + + +## Function `initialize` + +Called by token issuer +this will declare a yield farming pool + + +
public fun initialize<PoolType: store, RewardTokenT: store>(signer: &signer, treasury_token: Token::Token<RewardTokenT>)
+
+ + + +
+Implementation + + +
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,
+    });
+}
+
+ + + +
+ + + +## Function `add_asset` + +Add asset pools + + +
public fun add_asset<PoolType: store, AssetT: store>(signer: &signer, release_per_second: u128, delay: u64): YieldFarmingV2::ParameterModifyCapability<PoolType, AssetT>
+
+ + + +
+Implementation + + +
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> {}
+}
+
+ + + +
+ + + +## Function `modify_parameter` + +Remove asset for make this pool to the state of not alive +Please make sure all user unstaking from this pool + + +
public fun modify_parameter<PoolType: store, RewardTokenT: store, AssetT: store>(_cap: &YieldFarmingV2::ParameterModifyCapability<PoolType, AssetT>, broker: address, release_per_second: u128, alive: bool)
+
+ + + +
+Implementation + + +
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;
+}
+
+ + + +
+ + + +## Function `stake` + +Call by stake user, staking amount of asset in order to get yield farming token + + +
public fun stake<PoolType: store, RewardTokenT: store, AssetT: store>(signer: &signer, broker: address, asset: AssetT, asset_weight: u128, _cap: &YieldFarmingV2::ParameterModifyCapability<PoolType, AssetT>)
+
+ + + +
+Implementation + + +
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);
+}
+
+ + + +
+ + + +## Function `stake_for_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>
+
+ + + +
+Implementation + + +
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 }
+}
+
+ + + +
+ + + +## Function `unstake` + +Unstake asset from farming pool + + +
public fun unstake<PoolType: store, RewardTokenT: store, AssetT: store>(signer: &signer, broker: address): (AssetT, Token::Token<RewardTokenT>)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `unstake_with_cap` + + + +
public fun unstake_with_cap<PoolType: store, RewardTokenT: store, AssetT: store>(broker: address, cap: YieldFarmingV2::HarvestCapability<PoolType, AssetT>): (AssetT, Token::Token<RewardTokenT>)
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `harvest` + +Harvest yield farming token from stake + + +
public fun harvest<PoolType: store, RewardTokenT: store, AssetT: store>(signer: &signer, broker: address, amount: u128): Token::Token<RewardTokenT>
+
+ + + +
+Implementation + + +
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)
+}
+
+ + + +
+ + + +## Function `harvest_with_cap` + + + +
public fun harvest_with_cap<PoolType: store, RewardTokenT: store, AssetT: store>(broker: address, amount: u128, _cap: &YieldFarmingV2::HarvestCapability<PoolType, AssetT>): Token::Token<RewardTokenT>
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `query_gov_token_amount` + +The user can quering all yield farming amount in any time and scene + + +
public fun query_gov_token_amount<PoolType: store, RewardTokenT: store, AssetT: store>(account: address, broker: address): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `query_total_stake` + +Query total stake count from yield farming resource + + +
public fun query_total_stake<PoolType: store, AssetT: store>(broker: address): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `query_stake` + +Query stake weight from user staking objects. + + +
public fun query_stake<PoolType: store, AssetT: store>(account: address): u128
+
+ + + +
+Implementation + + +
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
+}
+
+ + + +
+ + + +## Function `query_info` + +Queyry pool info from pool type +return value: (alive, release_per_second, asset_total_weight, harvest_index) + + +
public fun query_info<PoolType: store, AssetT: store>(broker: address): (bool, u128, u128, u128)
+
+ + + +
+Implementation + + +
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
+    )
+}
+
+ + + +
+ + + +## Function `calculate_harvest_index_with_asset` + +Update farming asset + + +
fun calculate_harvest_index_with_asset<PoolType, AssetT>(farming_asset: &YieldFarmingV2::FarmingAsset<PoolType, AssetT>, now_seconds: u64): u128
+
+ + + +
+Implementation + + +
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
+        )
+    }
+}
+
+ + + +
+ + + +## Function `calculate_harvest_index_weight_zero` + +There is calculating from harvest index and global parameters without asset_total_weight + + +
public fun calculate_harvest_index_weight_zero(harvest_index: u128, last_update_timestamp: u64, now_seconds: u64, release_per_second: u128): u128
+
+ + + +
+Implementation + + +
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))
+}
+
+ + + +
+ + + +## Function `calculate_harvest_index` + +There is calculating from harvest index and global parameters + + +
public fun calculate_harvest_index(harvest_index: u128, asset_total_weight: u128, last_update_timestamp: u64, now_seconds: u64, release_per_second: u128): u128
+
+ + + +
+Implementation + + +
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))
+}
+
+ + + +
+ + + +## Function `calculate_withdraw_amount` + +This function will return a gain index + + +
public fun calculate_withdraw_amount(harvest_index: u128, last_harvest_index: u128, asset_weight: u128): u128
+
+ + + +
+Implementation + + +
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))
+}
+
+ + + +
+ + + +## Function `exists_at` + +Check the Farming of TokenT is exists. + + +
public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool
+
+ + + +
+Implementation + + +
public fun exists_at<PoolType: store, RewardTokenT: store>(broker: address): bool {
+    exists<Farming<PoolType, RewardTokenT>>(broker)
+}
+
+ + + +
+ + + +## Function `exists_asset_at` + +Check the Farming of AsssetT is exists. + + +
public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool
+
+ + + +
+Implementation + + +
public fun exists_asset_at<PoolType: store, AssetT: store>(broker: address): bool {
+    exists<FarmingAsset<PoolType, AssetT>>(broker)
+}
+
+ + + +
+ + + +## Function `exists_stake_at_address` + +Check stake at address exists. + + +
public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool
+
+ + + +
+Implementation + + +
public fun exists_stake_at_address<PoolType: store, AssetT: store>(account: address): bool {
+    exists<Stake<PoolType, AssetT>>(account)
+}
+
+ + + +
+ + + +## Module Specification + + + +
pragma verify = false;
+
diff --git a/integration-tests/account/basic.exp b/integration-tests/account/basic.exp index 809ee7b7..7e282ee2 100644 --- a/integration-tests/account/basic.exp +++ b/integration-tests/account/basic.exp @@ -2,13 +2,13 @@ processed 14 tasks task 5 'run'. lines 30-41: { - "gas_used": 138618, + "gas_used": 129290, "status": "Executed" } task 6 'run'. lines 44-55: { - "gas_used": 43037, + "gas_used": 36041, "status": { "MoveAbort": { "location": { @@ -24,7 +24,7 @@ task 6 'run'. lines 44-55: task 7 'run'. lines 58-74: { - "gas_used": 58822, + "gas_used": 51826, "status": { "MoveAbort": { "location": { @@ -40,13 +40,13 @@ task 7 'run'. lines 58-74: task 8 'run'. lines 76-95: { - "gas_used": 129244, + "gas_used": 110588, "status": "Executed" } task 9 'run'. lines 98-110: { - "gas_used": 153692, + "gas_used": 144364, "status": "Executed" } @@ -58,7 +58,7 @@ task 10 'run'. lines 112-121: task 11 'run'. lines 123-135: { - "gas_used": 396498, + "gas_used": 308465, "status": "Executed" } @@ -70,6 +70,6 @@ task 12 'run'. lines 138-147: task 13 'run'. lines 150-159: { - "gas_used": 52883, + "gas_used": 51134, "status": "Executed" } diff --git a/integration-tests/account/delegate_account.exp b/integration-tests/account/delegate_account.exp index fa633220..5441bc8c 100644 --- a/integration-tests/account/delegate_account.exp +++ b/integration-tests/account/delegate_account.exp @@ -2,12 +2,12 @@ processed 7 tasks task 5 'run'. lines 27-44: { - "gas_used": 617389, + "gas_used": 522360, "status": "Executed" } task 6 'run'. lines 47-62: { - "gas_used": 139450, + "gas_used": 137701, "status": "Executed" } diff --git a/integration-tests/account/txn_prologue_and_epilogue.exp b/integration-tests/account/txn_prologue_and_epilogue.exp index 9fdbe5db..04cb8928 100644 --- a/integration-tests/account/txn_prologue_and_epilogue.exp +++ b/integration-tests/account/txn_prologue_and_epilogue.exp @@ -2,13 +2,13 @@ processed 15 tasks task 3 'run'. lines 7-28: { - "gas_used": 619661, + "gas_used": 527547, "status": "Executed" } task 4 'run'. lines 30-62: { - "gas_used": 180711, + "gas_used": 97925, "status": { "MoveAbort": { "location": { @@ -24,7 +24,7 @@ task 4 'run'. lines 30-62: task 5 'run'. lines 66-92: { - "gas_used": 330596, + "gas_used": 169688, "status": { "MoveAbort": { "location": { @@ -40,7 +40,7 @@ task 5 'run'. lines 66-92: task 6 'run'. lines 96-124: { - "gas_used": 306926, + "gas_used": 146018, "status": { "MoveAbort": { "location": { @@ -56,7 +56,7 @@ task 6 'run'. lines 96-124: task 7 'run'. lines 128-158: { - "gas_used": 354875, + "gas_used": 193967, "status": { "MoveAbort": { "location": { @@ -72,13 +72,13 @@ task 7 'run'. lines 128-158: task 8 'run'. lines 162-207: { - "gas_used": 477794, + "gas_used": 313388, "status": "Executed" } task 9 'run'. lines 211-241: { - "gas_used": 354743, + "gas_used": 193835, "status": { "MoveAbort": { "location": { @@ -94,7 +94,7 @@ task 9 'run'. lines 211-241: task 10 'run'. lines 245-276: { - "gas_used": 197255, + "gas_used": 112720, "status": { "MoveAbort": { "location": { @@ -110,7 +110,7 @@ task 10 'run'. lines 245-276: task 11 'run'. lines 280-311: { - "gas_used": 175156, + "gas_used": 90621, "status": { "MoveAbort": { "location": { @@ -126,7 +126,7 @@ task 11 'run'. lines 280-311: task 12 'run'. lines 313-349: { - "gas_used": 358789, + "gas_used": 197881, "status": { "MoveAbort": { "location": { @@ -142,7 +142,7 @@ task 12 'run'. lines 313-349: task 13 'run'. lines 351-401: { - "gas_used": 516751, + "gas_used": 351985, "status": "Executed" } diff --git a/integration-tests/account/withdraw_capability.exp b/integration-tests/account/withdraw_capability.exp index 2680f580..9013ab6c 100644 --- a/integration-tests/account/withdraw_capability.exp +++ b/integration-tests/account/withdraw_capability.exp @@ -2,13 +2,13 @@ processed 12 tasks task 5 'run'. lines 25-38: { - "gas_used": 60415, + "gas_used": 55168, "status": "Executed" } task 6 'run'. lines 41-55: { - "gas_used": 25450, + "gas_used": 23701, "status": { "MoveAbort": { "location": { @@ -24,7 +24,7 @@ task 6 'run'. lines 41-55: task 7 'run'. lines 58-73: { - "gas_used": 25450, + "gas_used": 23701, "status": { "MoveAbort": { "location": { @@ -40,24 +40,24 @@ task 7 'run'. lines 58-73: task 8 'run'. lines 76-88: { - "gas_used": 138618, + "gas_used": 129290, "status": "Executed" } task 9 'run'. lines 91-103: { - "gas_used": 157632, + "gas_used": 148304, "status": "Executed" } task 10 'run'. lines 106-117: { - "gas_used": 95571, + "gas_used": 93822, "status": "Executed" } task 11 'run'. lines 120-132: { - "gas_used": 145818, + "gas_used": 136490, "status": "Executed" } diff --git a/integration-tests/account/withdraw_zero_token.exp b/integration-tests/account/withdraw_zero_token.exp index 9c1df52a..cf58db63 100644 --- a/integration-tests/account/withdraw_zero_token.exp +++ b/integration-tests/account/withdraw_zero_token.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 6-16: { - "gas_used": 35796, + "gas_used": 34047, "status": "Executed" } diff --git a/integration-tests/authenticator/authenticator.exp b/integration-tests/authenticator/authenticator.exp index 3bd338d3..253a3a06 100644 --- a/integration-tests/authenticator/authenticator.exp +++ b/integration-tests/authenticator/authenticator.exp @@ -2,13 +2,13 @@ processed 11 tasks task 2 'run'. lines 6-50: { - "gas_used": 447357, + "gas_used": 342616, "status": "Executed" } task 3 'run'. lines 52-67: { - "gas_used": 14885, + "gas_used": 11387, "status": { "MoveAbort": { "location": { @@ -24,7 +24,7 @@ task 3 'run'. lines 52-67: task 4 'run'. lines 69-84: { - "gas_used": 14958, + "gas_used": 11460, "status": { "MoveAbort": { "location": { @@ -40,7 +40,7 @@ task 4 'run'. lines 69-84: task 5 'run'. lines 86-106: { - "gas_used": 100127, + "gas_used": 17341, "status": { "MoveAbort": { "location": { @@ -56,7 +56,7 @@ task 5 'run'. lines 86-106: task 6 'run'. lines 109-128: { - "gas_used": 19159, + "gas_used": 13329, "status": { "MoveAbort": { "location": { @@ -72,7 +72,7 @@ task 6 'run'. lines 109-128: task 7 'run'. lines 131-150: { - "gas_used": 19086, + "gas_used": 13256, "status": { "MoveAbort": { "location": { @@ -88,19 +88,19 @@ task 7 'run'. lines 131-150: task 8 'run'. lines 153-182: { - "gas_used": 75335, + "gas_used": 56679, "status": "Executed" } task 9 'run'. lines 184-196: { - "gas_used": 396498, + "gas_used": 308465, "status": "Executed" } task 10 'run'. lines 198-206: { - "gas_used": 11900, + "gas_used": 10151, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/block/block_checkpoints.exp b/integration-tests/block/block_checkpoints.exp index dcba77a2..71b9d7c2 100644 --- a/integration-tests/block/block_checkpoints.exp +++ b/integration-tests/block/block_checkpoints.exp @@ -2,24 +2,24 @@ processed 7 tasks task 3 'run'. lines 157-166: { - "gas_used": 442964, + "gas_used": 196355, "status": "Executed" } task 4 'run'. lines 168-179: { - "gas_used": 73744, + "gas_used": 55656, "status": "Executed" } task 5 'run'. lines 182-192: { - "gas_used": 565558, + "gas_used": 343988, "status": "Executed" } task 6 'run'. lines 194-205: { - "gas_used": 95791, + "gas_used": 70139, "status": "Executed" } diff --git a/integration-tests/block/checkpoints_test.exp b/integration-tests/block/checkpoints_test.exp index 38529241..7612f5bc 100644 --- a/integration-tests/block/checkpoints_test.exp +++ b/integration-tests/block/checkpoints_test.exp @@ -2,13 +2,13 @@ processed 13 tasks task 4 'run'. lines 9-27: { - "gas_used": 114496, + "gas_used": 96408, "status": "Executed" } task 7 'run'. lines 33-46: { - "gas_used": 532055, + "gas_used": 323909, "status": { "MoveAbort": { "location": { @@ -24,12 +24,12 @@ task 7 'run'. lines 33-46: task 10 'run'. lines 53-64: { - "gas_used": 577411, + "gas_used": 355841, "status": "Executed" } task 12 'run'. lines 68-81: { - "gas_used": 103912, + "gas_used": 78260, "status": "Executed" } diff --git a/integration-tests/block_reward/basic.exp b/integration-tests/block_reward/basic.exp index f82eeca7..4045d172 100644 --- a/integration-tests/block_reward/basic.exp +++ b/integration-tests/block_reward/basic.exp @@ -2,13 +2,13 @@ processed 12 tasks task 3 'run'. lines 7-21: { - "gas_used": 202015, + "gas_used": 192672, "status": "Executed" } task 4 'run'. lines 24-40: { - "gas_used": 30790, + "gas_used": 29041, "status": { "MoveAbort": { "location": { @@ -24,13 +24,13 @@ task 4 'run'. lines 24-40: task 5 'run'. lines 43-58: { - "gas_used": 35540, + "gas_used": 33791, "status": "Executed" } task 6 'run'. lines 61-76: { - "gas_used": 36780, + "gas_used": 33282, "status": { "MoveAbort": { "location": { @@ -46,30 +46,30 @@ task 6 'run'. lines 61-76: task 7 'run'. lines 80-96: { - "gas_used": 596183, + "gas_used": 500556, "status": "Executed" } task 8 'run'. lines 99-115: { - "gas_used": 472722, + "gas_used": 455217, "status": "Executed" } task 9 'run'. lines 118-133: { - "gas_used": 209215, + "gas_used": 199872, "status": "Executed" } task 10 'run'. lines 136-150: { - "gas_used": 95550, + "gas_used": 86207, "status": "Executed" } task 11 'run'. lines 153-167: { - "gas_used": 209215, + "gas_used": 199872, "status": "Executed" } diff --git a/integration-tests/collection2/collection_add_by_other.exp b/integration-tests/collection2/collection_add_by_other.exp index 0848f2bb..f467ab53 100644 --- a/integration-tests/collection2/collection_add_by_other.exp +++ b/integration-tests/collection2/collection_add_by_other.exp @@ -2,25 +2,25 @@ processed 9 tasks task 5 'run'. lines 33-42: { - "gas_used": 24244, + "gas_used": 18414, "status": "Executed" } task 6 'run'. lines 45-58: { - "gas_used": 76271, + "gas_used": 62862, "status": "Executed" } task 7 'run'. lines 61-73: { - "gas_used": 64111, + "gas_used": 51285, "status": "Executed" } task 8 'run'. lines 76-93: { - "gas_used": 40551, + "gas_used": 35304, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/collection2/collection_by_owner.exp b/integration-tests/collection2/collection_by_owner.exp index 742e8283..b9e41d45 100644 --- a/integration-tests/collection2/collection_by_owner.exp +++ b/integration-tests/collection2/collection_by_owner.exp @@ -2,37 +2,37 @@ processed 13 tasks task 5 'run'. lines 29-42: { - "gas_used": 104541, + "gas_used": 83553, "status": "Executed" } task 6 'run'. lines 45-61: { - "gas_used": 89801, + "gas_used": 72894, "status": "Executed" } task 7 'run'. lines 64-81: { - "gas_used": 107668, + "gas_used": 88429, "status": "Executed" } task 8 'run'. lines 84-107: { - "gas_used": 102383, + "gas_used": 82561, "status": "Executed" } task 9 'run'. lines 110-124: { - "gas_used": 79438, + "gas_used": 66029, "status": "Executed" } task 10 'run'. lines 127-142: { - "gas_used": 40875, + "gas_used": 35628, "status": { "MoveAbort": { "location": { @@ -48,7 +48,7 @@ task 10 'run'. lines 127-142: task 11 'run'. lines 146-170: { - "gas_used": 163842, + "gas_used": 133526, "status": "Executed" } diff --git a/integration-tests/collection2/collection_mut_by_other.exp b/integration-tests/collection2/collection_mut_by_other.exp index 68481537..8064ccae 100644 --- a/integration-tests/collection2/collection_mut_by_other.exp +++ b/integration-tests/collection2/collection_mut_by_other.exp @@ -2,13 +2,13 @@ processed 10 tasks task 5 'run'. lines 35-44: { - "gas_used": 24244, + "gas_used": 18414, "status": "Executed" } task 6 'run'. lines 47-63: { - "gas_used": 43449, + "gas_used": 38202, "status": { "MoveAbort": { "location": { @@ -24,18 +24,18 @@ task 6 'run'. lines 47-63: task 7 'run'. lines 66-79: { - "gas_used": 69071, + "gas_used": 55662, "status": "Executed" } task 8 'run'. lines 82-95: { - "gas_used": 77854, + "gas_used": 65013, "status": "Executed" } task 9 'run'. lines 98-111: { - "gas_used": 69502, + "gas_used": 56093, "status": "Executed" } diff --git a/integration-tests/compare/compare.exp b/integration-tests/compare/compare.exp index 8bbf6742..789701d3 100644 --- a/integration-tests/compare/compare.exp +++ b/integration-tests/compare/compare.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-62: { - "gas_used": 1790663, + "gas_used": 1028099, "status": "Executed" } diff --git a/integration-tests/dao/test_dao_config.exp b/integration-tests/dao/test_dao_config.exp index e54381f3..7eff71ad 100644 --- a/integration-tests/dao/test_dao_config.exp +++ b/integration-tests/dao/test_dao_config.exp @@ -2,19 +2,19 @@ processed 18 tasks task 4 'run'. lines 25-43: { - "gas_used": 253732, + "gas_used": 249651, "status": "Executed" } task 5 'run'. lines 46-67: { - "gas_used": 210879, + "gas_used": 203300, "status": "Executed" } task 6 'run'. lines 70-85: { - "gas_used": 38469, + "gas_used": 34971, "status": { "MoveAbort": { "location": { @@ -30,7 +30,7 @@ task 6 'run'. lines 70-85: task 7 'run'. lines 88-103: { - "gas_used": 38469, + "gas_used": 34971, "status": { "MoveAbort": { "location": { @@ -46,7 +46,7 @@ task 7 'run'. lines 88-103: task 8 'run'. lines 106-121: { - "gas_used": 38574, + "gas_used": 35076, "status": { "MoveAbort": { "location": { @@ -62,7 +62,7 @@ task 8 'run'. lines 106-121: task 9 'run'. lines 124-139: { - "gas_used": 38469, + "gas_used": 34971, "status": { "MoveAbort": { "location": { @@ -94,13 +94,13 @@ task 10 'run'. lines 142-152: task 11 'run'. lines 155-195: { - "gas_used": 131313, + "gas_used": 123734, "status": "Executed" } task 12 'run'. lines 199-226: { - "gas_used": 52139, + "gas_used": 48641, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/dao/test_dao_failure.exp b/integration-tests/dao/test_dao_failure.exp index a42dde63..a545eef0 100644 --- a/integration-tests/dao/test_dao_failure.exp +++ b/integration-tests/dao/test_dao_failure.exp @@ -2,7 +2,7 @@ processed 43 tasks task 5 'run'. lines 12-29: { - "gas_used": 311858, + "gas_used": 306611, "status": "Executed" } @@ -24,19 +24,19 @@ task 6 'run'. lines 31-41: task 7 'run'. lines 44-54: { - "gas_used": 161219, + "gas_used": 157138, "status": "Executed" } task 8 'run'. lines 58-68: { - "gas_used": 161219, + "gas_used": 157138, "status": "Executed" } task 9 'run'. lines 71-81: { - "gas_used": 124438, + "gas_used": 120357, "status": { "ExecutionFailure": { "location": { @@ -53,19 +53,19 @@ task 9 'run'. lines 71-81: task 11 'run'. lines 86-104: { - "gas_used": 148463, + "gas_used": 146714, "status": "Executed" } task 12 'run'. lines 107-127: { - "gas_used": 161878, + "gas_used": 160129, "status": "Executed" } task 13 'run'. lines 131-155: { - "gas_used": 149055, + "gas_used": 147306, "status": { "MoveAbort": { "location": { @@ -81,7 +81,7 @@ task 13 'run'. lines 131-155: task 14 'run'. lines 158-176: { - "gas_used": 93841, + "gas_used": 92092, "status": { "MoveAbort": { "location": { @@ -97,7 +97,7 @@ task 14 'run'. lines 158-176: task 15 'run'. lines 179-197: { - "gas_used": 76500, + "gas_used": 74751, "status": { "MoveAbort": { "location": { @@ -221,7 +221,7 @@ task 24 'run'. lines 327-341: task 25 'run'. lines 344-364: { - "gas_used": 102307, + "gas_used": 100558, "status": { "MoveAbort": { "location": { @@ -275,13 +275,13 @@ task 28 'run'. lines 406-424: task 30 'run'. lines 430-452: { - "gas_used": 162456, + "gas_used": 155460, "status": "Executed" } task 32 'run'. lines 456-470: { - "gas_used": 76650, + "gas_used": 69654, "status": "Executed" } @@ -303,19 +303,19 @@ task 33 'run'. lines 473-488: task 34 'run'. lines 491-505: { - "gas_used": 74702, + "gas_used": 67706, "status": "Executed" } task 35 'run'. lines 508-519: { - "gas_used": 161219, + "gas_used": 157138, "status": "Executed" } task 37 'run'. lines 525-545: { - "gas_used": 107898, + "gas_used": 106149, "status": { "MoveAbort": { "location": { @@ -363,7 +363,7 @@ task 39 'run'. lines 570-583: task 40 'run'. lines 586-606: { - "gas_used": 161876, + "gas_used": 160127, "status": "Executed" } diff --git a/integration-tests/dao/test_dao_propose.exp b/integration-tests/dao/test_dao_propose.exp index eee46e4a..e76d8c48 100644 --- a/integration-tests/dao/test_dao_propose.exp +++ b/integration-tests/dao/test_dao_propose.exp @@ -2,13 +2,13 @@ processed 21 tasks task 4 'run'. lines 10-24: { - "gas_used": 215178, + "gas_used": 211680, "status": "Executed" } task 5 'run'. lines 27-37: { - "gas_used": 161219, + "gas_used": 157138, "status": "Executed" } @@ -20,13 +20,13 @@ task 6 'run'. lines 40-62: task 8 'run'. lines 68-84: { - "gas_used": 147821, + "gas_used": 146072, "status": "Executed" } task 9 'run'. lines 87-103: { - "gas_used": 140121, + "gas_used": 138372, "status": "Executed" } @@ -38,13 +38,13 @@ task 11 'run'. lines 109-127: task 12 'run'. lines 131-151: { - "gas_used": 154178, + "gas_used": 152429, "status": "Executed" } task 13 'run'. lines 154-187: { - "gas_used": 501780, + "gas_used": 498282, "status": "Executed" } @@ -56,7 +56,7 @@ task 15 'run'. lines 194-216: task 17 'run'. lines 223-235: { - "gas_used": 32327, + "gas_used": 30578, "status": { "MoveAbort": { "location": { @@ -72,12 +72,12 @@ task 17 'run'. lines 223-235: task 18 'run'. lines 238-254: { - "gas_used": 162456, + "gas_used": 155460, "status": "Executed" } task 20 'run'. lines 261-275: { - "gas_used": 76650, + "gas_used": 69654, "status": "Executed" } diff --git a/integration-tests/dao/test_mint_dao_proposal.exp b/integration-tests/dao/test_mint_dao_proposal.exp index 18770d66..8876d796 100644 --- a/integration-tests/dao/test_mint_dao_proposal.exp +++ b/integration-tests/dao/test_mint_dao_proposal.exp @@ -20,7 +20,7 @@ task 7 'run'. lines 71-82: task 8 'run'. lines 85-98: { - "gas_used": 119474, + "gas_used": 117725, "status": "Executed" } @@ -58,19 +58,19 @@ task 10 'run'. lines 113-124: task 11 'run'. lines 127-137: { - "gas_used": 163287, + "gas_used": 159206, "status": "Executed" } task 12 'run'. lines 140-150: { - "gas_used": 149810, + "gas_used": 145729, "status": "Executed" } task 14 'run'. lines 156-172: { - "gas_used": 141103, + "gas_used": 139354, "status": "Executed" } @@ -82,6 +82,6 @@ task 16 'run'. lines 177-198: task 18 'run'. lines 204-222: { - "gas_used": 160785, + "gas_used": 153789, "status": "Executed" } diff --git a/integration-tests/debug/debug.exp b/integration-tests/debug/debug.exp index e7c5034b..0f034da4 100644 --- a/integration-tests/debug/debug.exp +++ b/integration-tests/debug/debug.exp @@ -2,6 +2,6 @@ processed 4 tasks task 3 'run'. lines 42-51: { - "gas_used": 32136, + "gas_used": 23391, "status": "Executed" } diff --git a/integration-tests/epoch/adjust_epoch_block_time_max.exp b/integration-tests/epoch/adjust_epoch_block_time_max.exp index 557c38f3..28237215 100644 --- a/integration-tests/epoch/adjust_epoch_block_time_max.exp +++ b/integration-tests/epoch/adjust_epoch_block_time_max.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-40: { - "gas_used": 26784493, + "gas_used": 26693545, "status": "Executed" } diff --git a/integration-tests/epoch/adjust_epoch_block_time_min.exp b/integration-tests/epoch/adjust_epoch_block_time_min.exp index 26d69a66..48ce10b5 100644 --- a/integration-tests/epoch/adjust_epoch_block_time_min.exp +++ b/integration-tests/epoch/adjust_epoch_block_time_min.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 6-37: { - "gas_used": 26510451, + "gas_used": 26475471, "status": "Executed" } diff --git a/integration-tests/epoch/adjust_epoch_failed.exp b/integration-tests/epoch/adjust_epoch_failed.exp index 290eedb7..101e63fe 100644 --- a/integration-tests/epoch/adjust_epoch_failed.exp +++ b/integration-tests/epoch/adjust_epoch_failed.exp @@ -72,6 +72,6 @@ task 7 'run'. lines 70-83: task 8 'run'. lines 86-99: { - "gas_used": 172234, + "gas_used": 168736, "status": "Executed" } diff --git a/integration-tests/epoch/adjust_gas_limit.exp b/integration-tests/epoch/adjust_gas_limit.exp index 86456c65..a62af53b 100644 --- a/integration-tests/epoch/adjust_gas_limit.exp +++ b/integration-tests/epoch/adjust_gas_limit.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-45: { - "gas_used": 218956, + "gas_used": 189806, "status": "Executed" } diff --git a/integration-tests/incubator/SortedLinkedList.exp b/integration-tests/incubator/SortedLinkedList.exp index a9c13f13..89d0b2e3 100644 --- a/integration-tests/incubator/SortedLinkedList.exp +++ b/integration-tests/incubator/SortedLinkedList.exp @@ -2,7 +2,7 @@ processed 33 tasks task 9 'run'. lines 283-291: { - "gas_used": 43351, + "gas_used": 39270, "status": "Executed" } @@ -24,85 +24,85 @@ task 10 'run'. lines 293-303: task 11 'run'. lines 305-317: { - "gas_used": 295543, + "gas_used": 181245, "status": "Executed" } task 12 'run'. lines 319-331: { - "gas_used": 399474, + "gas_used": 237953, "status": "Executed" } task 13 'run'. lines 333-343: { - "gas_used": 467732, + "gas_used": 263069, "status": "Executed" } task 14 'run'. lines 345-365: { - "gas_used": 116167, + "gas_used": 83519, "status": "Executed" } task 15 'run'. lines 367-377: { - "gas_used": 83789, + "gas_used": 66269, "status": "Executed" } task 16 'run'. lines 379-389: { - "gas_used": 73959, + "gas_used": 58771, "status": "Executed" } task 17 'run'. lines 391-401: { - "gas_used": 117337, + "gas_used": 89906, "status": "Executed" } task 19 'run'. lines 504-512: { - "gas_used": 59883, + "gas_used": 49972, "status": "Executed" } task 20 'run'. lines 514-523: { - "gas_used": 212840, + "gas_used": 159757, "status": "Executed" } task 21 'run'. lines 525-534: { - "gas_used": 247698, + "gas_used": 184121, "status": "Executed" } task 22 'run'. lines 536-545: { - "gas_used": 298896, + "gas_used": 216663, "status": "Executed" } task 23 'run'. lines 547-557: { - "gas_used": 30925, + "gas_used": 26844, "status": "Executed" } task 24 'run'. lines 559-568: { - "gas_used": 112398, + "gas_used": 91963, "status": "Executed" } task 25 'run'. lines 570-580: { - "gas_used": 31071, + "gas_used": 28739, "status": { "MoveAbort": { "location": "Script", @@ -113,6 +113,6 @@ task 25 'run'. lines 570-580: task 32 'run'. lines 595-605: { - "gas_used": 138322, + "gas_used": 113223, "status": "Executed" } diff --git a/integration-tests/list/linked_list.exp b/integration-tests/list/linked_list.exp index 0f097a89..4c717d80 100644 --- a/integration-tests/list/linked_list.exp +++ b/integration-tests/list/linked_list.exp @@ -2,13 +2,13 @@ processed 16 tasks task 9 'run'. lines 386-395: { - "gas_used": 34332, + "gas_used": 32583, "status": "Executed" } task 10 'run'. lines 397-410: { - "gas_used": 135748, + "gas_used": 113594, "status": "Executed" } @@ -20,13 +20,13 @@ task 11 'run'. lines 412-420: task 12 'run'. lines 422-431: { - "gas_used": 40204, + "gas_used": 36706, "status": "Executed" } task 13 'run'. lines 433-445: { - "gas_used": 25940, + "gas_used": 24191, "status": { "MoveAbort": { "location": { @@ -48,6 +48,6 @@ task 14 'run'. lines 447-455: task 15 'run'. lines 457-469: { - "gas_used": 65069, + "gas_used": 63320, "status": "Executed" } diff --git a/integration-tests/math/sum_avg.exp b/integration-tests/math/sum_avg.exp index a625d5fa..8711c0ad 100644 --- a/integration-tests/math/sum_avg.exp +++ b/integration-tests/math/sum_avg.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-20: { - "gas_used": 1150321, + "gas_used": 443725, "status": "Executed" } diff --git a/integration-tests/move/option.exp b/integration-tests/move/option.exp index 74d19a4b..16815f7e 100644 --- a/integration-tests/move/option.exp +++ b/integration-tests/move/option.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-43: { - "gas_used": 221498, + "gas_used": 148623, "status": "Executed" } diff --git a/integration-tests/natives/signature.exp b/integration-tests/natives/signature.exp index e8324e4c..b4b8e5b3 100644 --- a/integration-tests/natives/signature.exp +++ b/integration-tests/natives/signature.exp @@ -14,19 +14,19 @@ task 3 'run'. lines 28-50: task 4 'run'. lines 52-87: { - "gas_used": 170379, + "gas_used": 128986, "status": "Executed" } task 5 'run'. lines 91-104: { - "gas_used": 65054, + "gas_used": 50479, "status": "Executed" } task 6 'run'. lines 106-119: { - "gas_used": 42061, + "gas_used": 35065, "status": { "MoveAbort": { "location": { @@ -42,7 +42,7 @@ task 6 'run'. lines 106-119: task 7 'run'. lines 121-141: { - "gas_used": 103458, + "gas_used": 81887, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/nft/identifier_nft.exp b/integration-tests/nft/identifier_nft.exp index 827525d5..d413aebc 100644 --- a/integration-tests/nft/identifier_nft.exp +++ b/integration-tests/nft/identifier_nft.exp @@ -2,30 +2,30 @@ processed 11 tasks task 5 'run'. lines 127-135: { - "gas_used": 151159, + "gas_used": 144163, "status": "Executed" } task 6 'run'. lines 137-145: { - "gas_used": 175917, + "gas_used": 161342, "status": "Executed" } task 7 'run'. lines 147-155: { - "gas_used": 135616, + "gas_used": 124539, "status": "Executed" } task 8 'run'. lines 158-166: { - "gas_used": 95505, + "gas_used": 78598, "status": "Executed" } task 10 'run'. lines 171-179: { - "gas_used": 191856, + "gas_used": 184860, "status": "Executed" } diff --git a/integration-tests/nft/nft_boxminer.exp b/integration-tests/nft/nft_boxminer.exp index fdcc0d7c..69cd1700 100644 --- a/integration-tests/nft/nft_boxminer.exp +++ b/integration-tests/nft/nft_boxminer.exp @@ -2,12 +2,12 @@ processed 6 tasks task 4 'run'. lines 59-67: { - "gas_used": 144146, + "gas_used": 138899, "status": "Executed" } task 5 'run'. lines 69-79: { - "gas_used": 255599, + "gas_used": 246271, "status": "Executed" } diff --git a/integration-tests/nft/nft_card.exp b/integration-tests/nft/nft_card.exp index 6db4809c..707972b7 100644 --- a/integration-tests/nft/nft_card.exp +++ b/integration-tests/nft/nft_card.exp @@ -2,30 +2,30 @@ processed 9 tasks task 4 'run'. lines 84-92: { - "gas_used": 253652, + "gas_used": 239660, "status": "Executed" } task 5 'run'. lines 94-104: { - "gas_used": 169142, + "gas_used": 159814, "status": "Executed" } task 6 'run'. lines 106-119: { - "gas_used": 123386, + "gas_used": 114058, "status": "Executed" } task 7 'run'. lines 122-134: { - "gas_used": 441697, + "gas_used": 377567, "status": "Executed" } task 8 'run'. lines 136-148: { - "gas_used": 36329, + "gas_used": 32831, "status": "Executed" } diff --git a/integration-tests/nft/nft_metadata.exp b/integration-tests/nft/nft_metadata.exp index 87525f1c..b77c1c72 100644 --- a/integration-tests/nft/nft_metadata.exp +++ b/integration-tests/nft/nft_metadata.exp @@ -2,25 +2,25 @@ processed 10 tasks task 4 'run'. lines 91-99: { - "gas_used": 150838, + "gas_used": 143842, "status": "Executed" } task 5 'run'. lines 101-113: { - "gas_used": 260316, + "gas_used": 243409, "status": "Executed" } task 7 'run'. lines 118-130: { - "gas_used": 337814, + "gas_used": 280680, "status": "Executed" } task 8 'run'. lines 132-152: { - "gas_used": 135024, + "gas_used": 105874, "status": { "MoveAbort": { "location": "Script", @@ -31,6 +31,6 @@ task 8 'run'. lines 132-152: task 9 'run'. lines 155-180: { - "gas_used": 77055, + "gas_used": 71808, "status": "Executed" } diff --git a/integration-tests/nft/test_gallery.exp b/integration-tests/nft/test_gallery.exp index f80f97fb..aa4e0761 100644 --- a/integration-tests/nft/test_gallery.exp +++ b/integration-tests/nft/test_gallery.exp @@ -2,78 +2,78 @@ processed 18 tasks task 5 'run'. lines 71-79: { - "gas_used": 210602, + "gas_used": 201857, "status": "Executed" } task 6 'run'. lines 81-89: { - "gas_used": 85869, + "gas_used": 84120, "status": "Executed" } task 7 'run'. lines 92-106: { - "gas_used": 63395, + "gas_used": 49403, "status": "Executed" } task 8 'run'. lines 108-116: { - "gas_used": 108588, + "gas_used": 101009, "status": "Executed" } task 9 'run'. lines 118-134: { - "gas_used": 118839, + "gas_used": 87357, "status": "Executed" } task 10 'run'. lines 136-144: { - "gas_used": 18640401, + "gas_used": 17124601, "status": "Executed" } task 11 'run'. lines 148-161: { - "gas_used": 3117644, + "gas_used": 2174933, "status": "Executed" } task 12 'run'. lines 164-185: { - "gas_used": 28244700, + "gas_used": 18928360, "status": "Executed" } task 13 'run'. lines 187-206: { - "gas_used": 2312515, + "gas_used": 1843783, "status": "Executed" } task 14 'run'. lines 208-220: { - "gas_used": 22384, + "gas_used": 20635, "status": "Executed" } task 15 'run'. lines 224-234: { - "gas_used": 153885, + "gas_used": 126484, "status": "Executed" } task 16 'run'. lines 237-251: { - "gas_used": 2055910, + "gas_used": 1554530, "status": "Executed" } task 17 'run'. lines 253-267: { - "gas_used": 337114, + "gas_used": 298636, "status": "Executed" } diff --git a/integration-tests/nft/test_genesis_nft.exp b/integration-tests/nft/test_genesis_nft.exp index 77e7421b..a23d90df 100644 --- a/integration-tests/nft/test_genesis_nft.exp +++ b/integration-tests/nft/test_genesis_nft.exp @@ -2,7 +2,7 @@ processed 3 tasks task 2 'run'. lines 6-22: { - "gas_used": 87430, + "gas_used": 72855, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/nft/test_nft.exp b/integration-tests/nft/test_nft.exp index b865a27e..915702fa 100644 --- a/integration-tests/nft/test_nft.exp +++ b/integration-tests/nft/test_nft.exp @@ -2,24 +2,24 @@ processed 8 tasks task 4 'run'. lines 41-52: { - "gas_used": 296224, + "gas_used": 279900, "status": "Executed" } task 5 'run'. lines 54-65: { - "gas_used": 86021, + "gas_used": 84272, "status": "Executed" } task 6 'run'. lines 67-78: { - "gas_used": 197748, + "gas_used": 158104, "status": "Executed" } task 7 'run'. lines 80-91: { - "gas_used": 91113, + "gas_used": 69542, "status": "Executed" } diff --git a/integration-tests/offer/offer.exp b/integration-tests/offer/offer.exp index 5f09c5d1..dddafff7 100644 --- a/integration-tests/offer/offer.exp +++ b/integration-tests/offer/offer.exp @@ -2,7 +2,7 @@ processed 10 tasks task 4 'run'. lines 9-32: { - "gas_used": 87316, + "gas_used": 85567, "status": "Executed" } diff --git a/integration-tests/on_chain_config/config.exp b/integration-tests/on_chain_config/config.exp index 99396d9f..54fc6ce2 100644 --- a/integration-tests/on_chain_config/config.exp +++ b/integration-tests/on_chain_config/config.exp @@ -2,31 +2,31 @@ processed 12 tasks task 4 'run'. lines 67-74: { - "gas_used": 67336, + "gas_used": 63255, "status": "Executed" } task 5 'run'. lines 77-84: { - "gas_used": 95406, + "gas_used": 87827, "status": "Executed" } task 6 'run'. lines 86-96: { - "gas_used": 67058, + "gas_used": 61796, "status": "Executed" } task 7 'run'. lines 99-106: { - "gas_used": 37976, + "gas_used": 34478, "status": "Executed" } task 8 'run'. lines 108-118: { - "gas_used": 25869, + "gas_used": 24120, "status": { "MoveAbort": { "location": { @@ -48,12 +48,12 @@ task 9 'run'. lines 120-129: task 10 'run'. lines 132-139: { - "gas_used": 63006, + "gas_used": 58925, "status": "Executed" } task 11 'run'. lines 142-152: { - "gas_used": 67058, + "gas_used": 61796, "status": "Executed" } diff --git a/integration-tests/on_chain_config/test_onchain_config_dao.exp b/integration-tests/on_chain_config/test_onchain_config_dao.exp index a164e7ed..35861e59 100644 --- a/integration-tests/on_chain_config/test_onchain_config_dao.exp +++ b/integration-tests/on_chain_config/test_onchain_config_dao.exp @@ -2,7 +2,7 @@ processed 14 tasks task 4 'run'. lines 10-21: { - "gas_used": 215178, + "gas_used": 211680, "status": "Executed" } @@ -24,13 +24,13 @@ task 5 'run'. lines 22-31: task 6 'run'. lines 32-42: { - "gas_used": 160905, + "gas_used": 156824, "status": "Executed" } task 8 'run'. lines 47-60: { - "gas_used": 147821, + "gas_used": 146072, "status": "Executed" } @@ -42,6 +42,6 @@ task 11 'run'. lines 67-87: task 13 'run'. lines 92-106: { - "gas_used": 118891, + "gas_used": 111895, "status": "Executed" } diff --git a/integration-tests/oracle/oracle.exp b/integration-tests/oracle/oracle.exp index 1528f9f7..87c57255 100644 --- a/integration-tests/oracle/oracle.exp +++ b/integration-tests/oracle/oracle.exp @@ -38,7 +38,7 @@ task 11 'run'. lines 76-84: task 13 'run'. lines 89-103: { - "gas_used": 76441, + "gas_used": 48457, "status": { "MoveAbort": { "location": { @@ -54,7 +54,7 @@ task 13 'run'. lines 89-103: task 14 'run'. lines 106-120: { - "gas_used": 76441, + "gas_used": 48457, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/package_txn_manager/cancel_upgrade_plan.exp b/integration-tests/package_txn_manager/cancel_upgrade_plan.exp index cda16aa7..66d22c36 100644 --- a/integration-tests/package_txn_manager/cancel_upgrade_plan.exp +++ b/integration-tests/package_txn_manager/cancel_upgrade_plan.exp @@ -8,13 +8,13 @@ task 3 'run'. lines 8-19: task 4 'run'. lines 21-35: { - "gas_used": 161473, + "gas_used": 143983, "status": "Executed" } task 5 'run'. lines 36-46: { - "gas_used": 30788, + "gas_used": 29039, "status": { "MoveAbort": { "location": { @@ -30,12 +30,12 @@ task 5 'run'. lines 36-46: task 6 'run'. lines 48-57: { - "gas_used": 50095, + "gas_used": 46014, "status": "Executed" } task 7 'run'. lines 59-67: { - "gas_used": 35012, + "gas_used": 31514, "status": "Executed" } diff --git a/integration-tests/package_txn_manager/only_new_module.exp b/integration-tests/package_txn_manager/only_new_module.exp index 2a3ff721..a90099eb 100644 --- a/integration-tests/package_txn_manager/only_new_module.exp +++ b/integration-tests/package_txn_manager/only_new_module.exp @@ -2,7 +2,7 @@ processed 11 tasks task 3 'run'. lines 7-18: { - "gas_used": 97926, + "gas_used": 89764, "status": "Executed" } diff --git a/integration-tests/package_txn_manager/override_upgrade_plan.exp b/integration-tests/package_txn_manager/override_upgrade_plan.exp index 9d1d70e0..bf6d6a19 100644 --- a/integration-tests/package_txn_manager/override_upgrade_plan.exp +++ b/integration-tests/package_txn_manager/override_upgrade_plan.exp @@ -8,30 +8,30 @@ task 3 'run'. lines 7-17: task 4 'run'. lines 19-31: { - "gas_used": 161473, + "gas_used": 143983, "status": "Executed" } task 5 'run'. lines 33-42: { - "gas_used": 50095, + "gas_used": 46014, "status": "Executed" } task 7 'run'. lines 46-55: { - "gas_used": 50095, + "gas_used": 46014, "status": "Executed" } task 9 'run'. lines 59-74: { - "gas_used": 51700, + "gas_used": 45870, "status": "Executed" } task 11 'run'. lines 79-89: { - "gas_used": 51700, + "gas_used": 45870, "status": "Executed" } diff --git a/integration-tests/package_txn_manager/package_txn_manager.exp b/integration-tests/package_txn_manager/package_txn_manager.exp index 68afa2ec..ba4aa0e0 100644 --- a/integration-tests/package_txn_manager/package_txn_manager.exp +++ b/integration-tests/package_txn_manager/package_txn_manager.exp @@ -8,13 +8,13 @@ task 3 'run'. lines 8-19: task 4 'run'. lines 21-35: { - "gas_used": 161473, + "gas_used": 143983, "status": "Executed" } task 5 'run'. lines 36-46: { - "gas_used": 30788, + "gas_used": 29039, "status": { "MoveAbort": { "location": { @@ -30,13 +30,13 @@ task 5 'run'. lines 36-46: task 6 'run'. lines 48-59: { - "gas_used": 50095, + "gas_used": 46014, "status": "Executed" } task 7 'run'. lines 60-70: { - "gas_used": 50286, + "gas_used": 44456, "status": { "MoveAbort": { "location": { @@ -52,19 +52,19 @@ task 7 'run'. lines 60-70: task 9 'run'. lines 74-86: { - "gas_used": 51700, + "gas_used": 45870, "status": "Executed" } task 10 'run'. lines 87-97: { - "gas_used": 35012, + "gas_used": 31514, "status": "Executed" } task 11 'run'. lines 98-106: { - "gas_used": 28722, + "gas_used": 26973, "status": { "MoveAbort": { "location": { @@ -80,7 +80,7 @@ task 11 'run'. lines 98-106: task 12 'run'. lines 108-117: { - "gas_used": 34695, + "gas_used": 30614, "status": { "MoveAbort": { "location": { @@ -96,12 +96,12 @@ task 12 'run'. lines 108-117: task 13 'run'. lines 119-128: { - "gas_used": 120271, + "gas_used": 116190, "status": "Executed" } task 14 'run'. lines 132-140: { - "gas_used": 37235, + "gas_used": 33154, "status": "Executed" } diff --git a/integration-tests/ring/rind_set.exp b/integration-tests/ring/rind_set.exp index aa086b48..012bcb24 100644 --- a/integration-tests/ring/rind_set.exp +++ b/integration-tests/ring/rind_set.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-28: { - "gas_used": 504402, + "gas_used": 308424, "status": "Executed" } diff --git a/integration-tests/ring/ring_add.exp b/integration-tests/ring/ring_add.exp index f9050d53..6043e070 100644 --- a/integration-tests/ring/ring_add.exp +++ b/integration-tests/ring/ring_add.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-15: { - "gas_used": 161827, + "gas_used": 97697, "status": "Executed" } diff --git a/integration-tests/ring/ring_borrow.exp b/integration-tests/ring/ring_borrow.exp index cd890466..138249e0 100644 --- a/integration-tests/ring/ring_borrow.exp +++ b/integration-tests/ring/ring_borrow.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-28: { - "gas_used": 463613, + "gas_used": 282808, "status": "Executed" } diff --git a/integration-tests/ring/ring_borrow_mut.exp b/integration-tests/ring/ring_borrow_mut.exp index 18d3800a..8f03e468 100644 --- a/integration-tests/ring/ring_borrow_mut.exp +++ b/integration-tests/ring/ring_borrow_mut.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-33: { - "gas_used": 453936, + "gas_used": 281876, "status": "Executed" } diff --git a/integration-tests/ring/ring_index_of.exp b/integration-tests/ring/ring_index_of.exp index 440b0d7b..0a2a0315 100644 --- a/integration-tests/ring/ring_index_of.exp +++ b/integration-tests/ring/ring_index_of.exp @@ -2,19 +2,19 @@ processed 6 tasks task 2 'run'. lines 5-33: { - "gas_used": 1052055, + "gas_used": 653133, "status": "Executed" } task 3 'run'. lines 35-68: { - "gas_used": 1072944, + "gas_used": 670524, "status": "Executed" } task 4 'run'. lines 71-93: { - "gas_used": 414461, + "gas_used": 257484, "status": { "MoveAbort": { "location": { @@ -30,7 +30,7 @@ task 4 'run'. lines 71-93: task 5 'run'. lines 96-118: { - "gas_used": 414545, + "gas_used": 257568, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/shared_ed25519_public_key/shared_key.exp b/integration-tests/shared_ed25519_public_key/shared_key.exp index 5fa8d387..6530ef85 100644 --- a/integration-tests/shared_ed25519_public_key/shared_key.exp +++ b/integration-tests/shared_ed25519_public_key/shared_key.exp @@ -2,7 +2,7 @@ processed 7 tasks task 2 'run'. lines 6-38: { - "gas_used": 132514, + "gas_used": 117356, "status": "Executed" } diff --git a/integration-tests/signer_capability/create_signer.exp b/integration-tests/signer_capability/create_signer.exp index 367708e3..3f1ea44d 100644 --- a/integration-tests/signer_capability/create_signer.exp +++ b/integration-tests/signer_capability/create_signer.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-16: { - "gas_used": 88469, + "gas_used": 81473, "status": "Executed" } diff --git a/integration-tests/signer_capability/destroy_signer.exp b/integration-tests/signer_capability/destroy_signer.exp index 6e3805cd..c6e0af2a 100644 --- a/integration-tests/signer_capability/destroy_signer.exp +++ b/integration-tests/signer_capability/destroy_signer.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-22: { - "gas_used": 83037, + "gas_used": 76041, "status": "Executed" } diff --git a/integration-tests/token/burn_and_destroy.exp b/integration-tests/token/burn_and_destroy.exp index 9574f3bb..bc4cddc7 100644 --- a/integration-tests/token/burn_and_destroy.exp +++ b/integration-tests/token/burn_and_destroy.exp @@ -20,7 +20,7 @@ task 6 'run'. lines 57-65: task 7 'run'. lines 67-82: { - "gas_used": 70036, + "gas_used": 68287, "status": { "MoveAbort": { "location": { @@ -42,7 +42,7 @@ task 8 'run'. lines 84-96: task 9 'run'. lines 98-109: { - "gas_used": 84739, + "gas_used": 81241, "status": { "MoveAbort": { "location": { diff --git a/integration-tests/token/create_account_with_token.exp b/integration-tests/token/create_account_with_token.exp index e9f6e232..a5b05af4 100644 --- a/integration-tests/token/create_account_with_token.exp +++ b/integration-tests/token/create_account_with_token.exp @@ -2,12 +2,12 @@ processed 4 tasks task 2 'run'. lines 5-19: { - "gas_used": 410247, + "gas_used": 322214, "status": "Executed" } task 3 'run'. lines 23-37: { - "gas_used": 436380, + "gas_used": 348347, "status": "Executed" } diff --git a/integration-tests/token/mint_stc.exp b/integration-tests/token/mint_stc.exp index 24ef7a2f..8004b37e 100644 --- a/integration-tests/token/mint_stc.exp +++ b/integration-tests/token/mint_stc.exp @@ -19,6 +19,6 @@ task 3 'run'. lines 7-27: task 4 'run'. lines 31-49: { - "gas_used": 113530, + "gas_used": 111781, "status": "Executed" } diff --git a/integration-tests/token/my_token.exp b/integration-tests/token/my_token.exp index 2d5be90f..20191a8b 100644 --- a/integration-tests/token/my_token.exp +++ b/integration-tests/token/my_token.exp @@ -20,12 +20,12 @@ task 7 'run'. lines 78-86: task 8 'run'. lines 89-97: { - "gas_used": 106059, + "gas_used": 104310, "status": "Executed" } task 9 'run'. lines 99-109: { - "gas_used": 60830, + "gas_used": 59081, "status": "Executed" } diff --git a/integration-tests/token/transfer_then_abort.exp b/integration-tests/token/transfer_then_abort.exp index 59023890..3ecc3ad3 100644 --- a/integration-tests/token/transfer_then_abort.exp +++ b/integration-tests/token/transfer_then_abort.exp @@ -2,7 +2,7 @@ processed 5 tasks task 3 'run'. lines 7-18: { - "gas_used": 90048, + "gas_used": 88299, "status": { "MoveAbort": { "location": "Script", diff --git a/integration-tests/transaction_fee/distribute_txn_fee.exp b/integration-tests/transaction_fee/distribute_txn_fee.exp index 96846fb0..abf30643 100644 --- a/integration-tests/transaction_fee/distribute_txn_fee.exp +++ b/integration-tests/transaction_fee/distribute_txn_fee.exp @@ -2,7 +2,7 @@ processed 7 tasks task 4 'run'. lines 9-20: { - "gas_used": 74258, + "gas_used": 72509, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/create_account.exp b/integration-tests/transaction_scripts/create_account.exp index 14d65ee8..89ac6709 100644 --- a/integration-tests/transaction_scripts/create_account.exp +++ b/integration-tests/transaction_scripts/create_account.exp @@ -2,6 +2,6 @@ processed 4 tasks task 3 'run'. lines 8-16: { - "gas_used": 366738, + "gas_used": 355078, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/execute_modify_dao_config_proposal.exp b/integration-tests/transaction_scripts/execute_modify_dao_config_proposal.exp index 600162a9..38878d7b 100644 --- a/integration-tests/transaction_scripts/execute_modify_dao_config_proposal.exp +++ b/integration-tests/transaction_scripts/execute_modify_dao_config_proposal.exp @@ -2,13 +2,13 @@ processed 12 tasks task 4 'run'. lines 11-24: { - "gas_used": 161369, + "gas_used": 157288, "status": "Executed" } task 6 'run'. lines 28-47: { - "gas_used": 152760, + "gas_used": 151011, "status": "Executed" } @@ -26,6 +26,6 @@ task 9 'run'. lines 70-86: task 11 'run'. lines 89-101: { - "gas_used": 112656, + "gas_used": 107409, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/execute_on_chain_config_proposal.exp b/integration-tests/transaction_scripts/execute_on_chain_config_proposal.exp index 12431747..784408f3 100644 --- a/integration-tests/transaction_scripts/execute_on_chain_config_proposal.exp +++ b/integration-tests/transaction_scripts/execute_on_chain_config_proposal.exp @@ -2,13 +2,13 @@ processed 12 tasks task 4 'run'. lines 10-20: { - "gas_used": 167431, + "gas_used": 163350, "status": "Executed" } task 6 'run'. lines 23-43: { - "gas_used": 152760, + "gas_used": 151011, "status": "Executed" } @@ -26,6 +26,6 @@ task 9 'run'. lines 66-83: task 11 'run'. lines 87-99: { - "gas_used": 86761, + "gas_used": 81514, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/module_upgrade.exp b/integration-tests/transaction_scripts/module_upgrade.exp index 2fb6f89e..2df93259 100644 --- a/integration-tests/transaction_scripts/module_upgrade.exp +++ b/integration-tests/transaction_scripts/module_upgrade.exp @@ -2,13 +2,13 @@ processed 15 tasks task 5 'run'. lines 27-39: { - "gas_used": 330145, + "gas_used": 326064, "status": "Executed" } task 6 'run'. lines 41-52: { - "gas_used": 161473, + "gas_used": 143983, "status": "Executed" } @@ -20,13 +20,13 @@ task 7 'run'. lines 54-64: task 8 'run'. lines 67-86: { - "gas_used": 162855, + "gas_used": 158774, "status": "Executed" } task 10 'run'. lines 92-109: { - "gas_used": 120584, + "gas_used": 118835, "status": "Executed" } @@ -38,6 +38,6 @@ task 12 'run'. lines 113-126: task 14 'run'. lines 131-140: { - "gas_used": 87103, + "gas_used": 77775, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/peer_to_peer.exp b/integration-tests/transaction_scripts/peer_to_peer.exp index 3a1d1361..a5da4f6c 100644 --- a/integration-tests/transaction_scripts/peer_to_peer.exp +++ b/integration-tests/transaction_scripts/peer_to_peer.exp @@ -2,12 +2,12 @@ processed 5 tasks task 3 'run'. lines 9-17: { - "gas_used": 116315, + "gas_used": 114566, "status": "Executed" } task 4 'run'. lines 19-27: { - "gas_used": 112076, + "gas_used": 110327, "status": "Executed" } diff --git a/integration-tests/transaction_scripts/peer_to_peer_with_metadata.exp b/integration-tests/transaction_scripts/peer_to_peer_with_metadata.exp index 51157852..f1b0013f 100644 --- a/integration-tests/transaction_scripts/peer_to_peer_with_metadata.exp +++ b/integration-tests/transaction_scripts/peer_to_peer_with_metadata.exp @@ -2,12 +2,12 @@ processed 5 tasks task 3 'run'. lines 8-16: { - "gas_used": 113851, + "gas_used": 112102, "status": "Executed" } task 4 'run'. lines 18-26: { - "gas_used": 109027, + "gas_used": 107278, "status": "Executed" } diff --git a/integration-tests/u256/test_u256_gas.exp b/integration-tests/u256/test_u256_gas.exp index fdf9922f..583fa0f0 100644 --- a/integration-tests/u256/test_u256_gas.exp +++ b/integration-tests/u256/test_u256_gas.exp @@ -2,48 +2,48 @@ processed 10 tasks task 2 'run'. lines 5-11: { - "gas_used": 31743, + "gas_used": 20666, "status": "Executed" } task 3 'run'. lines 13-20: { - "gas_used": 31709, + "gas_used": 20632, "status": "Executed" } task 4 'run'. lines 23-30: { - "gas_used": 28804, + "gas_used": 17727, "status": "Executed" } task 5 'run'. lines 31-38: { - "gas_used": 24169, + "gas_used": 18339, "status": "Executed" } task 6 'run'. lines 39-48: { - "gas_used": 62764, + "gas_used": 40610, "status": "Executed" } task 7 'run'. lines 49-58: { - "gas_used": 62628, + "gas_used": 40474, "status": "Executed" } task 8 'run'. lines 59-68: { - "gas_used": 62628, + "gas_used": 40474, "status": "Executed" } task 9 'run'. lines 69-78: { - "gas_used": 62770, + "gas_used": 40616, "status": "Executed" } diff --git a/integration-tests/upgrade_module_dao_proposal/basic.exp b/integration-tests/upgrade_module_dao_proposal/basic.exp index d5b25842..34aa5efa 100644 --- a/integration-tests/upgrade_module_dao_proposal/basic.exp +++ b/integration-tests/upgrade_module_dao_proposal/basic.exp @@ -2,7 +2,7 @@ processed 19 tasks task 5 'run'. lines 25-40: { - "gas_used": 253732, + "gas_used": 249651, "status": "Executed" } @@ -20,7 +20,7 @@ task 7 'run'. lines 58-68: task 8 'run'. lines 70-80: { - "gas_used": 161473, + "gas_used": 143983, "status": "Executed" } @@ -64,13 +64,13 @@ task 11 'run'. lines 110-129: task 12 'run'. lines 131-150: { - "gas_used": 162855, + "gas_used": 158774, "status": "Executed" } task 14 'run'. lines 155-171: { - "gas_used": 148060, + "gas_used": 146311, "status": "Executed" } @@ -82,6 +82,6 @@ task 16 'run'. lines 175-189: task 18 'run'. lines 193-206: { - "gas_used": 108749, + "gas_used": 97672, "status": "Executed" } diff --git a/integration-tests/vector/big_vector.exp b/integration-tests/vector/big_vector.exp index d1a01ffd..6a31ab38 100644 --- a/integration-tests/vector/big_vector.exp +++ b/integration-tests/vector/big_vector.exp @@ -2,48 +2,48 @@ processed 12 tasks task 4 'run'. lines 75-82: { - "gas_used": 28551961, + "gas_used": 16887880, "status": "Executed" } task 5 'run'. lines 84-91: { - "gas_used": 38488, + "gas_used": 32075, "status": "Executed" } task 6 'run'. lines 93-101: { - "gas_used": 23163862, + "gas_used": 11499781, "status": "Executed" } task 7 'run'. lines 103-110: { - "gas_used": 38488, + "gas_used": 32075, "status": "Executed" } task 8 'run'. lines 112-119: { - "gas_used": 39082718, + "gas_used": 15756305, "status": "Executed" } task 9 'run'. lines 121-129: { - "gas_used": 53476, + "gas_used": 47063, "status": "Executed" } task 10 'run'. lines 131-137: { - "gas_used": 7165697, + "gas_used": 7163948, "status": "Executed" } task 11 'run'. lines 139-146: { - "gas_used": 3608883, + "gas_used": 3604802, "status": "Executed" } diff --git a/integration-tests/vector/contains.exp b/integration-tests/vector/contains.exp index bddc3bcc..f82fb46e 100644 --- a/integration-tests/vector/contains.exp +++ b/integration-tests/vector/contains.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-22: { - "gas_used": 72685, + "gas_used": 35373, "status": "Executed" } diff --git a/integration-tests/vector/index_of.exp b/integration-tests/vector/index_of.exp index 3927b859..592eba09 100644 --- a/integration-tests/vector/index_of.exp +++ b/integration-tests/vector/index_of.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-30: { - "gas_used": 60059, + "gas_used": 32658, "status": "Executed" } diff --git a/integration-tests/vector/remove.exp b/integration-tests/vector/remove.exp index b84f4497..92c88709 100644 --- a/integration-tests/vector/remove.exp +++ b/integration-tests/vector/remove.exp @@ -2,12 +2,12 @@ processed 4 tasks task 2 'run'. lines 5-24: { - "gas_used": 49163, + "gas_used": 24677, "status": "Executed" } task 3 'run'. lines 26-41: { - "gas_used": 33798, + "gas_used": 18640, "status": "Executed" } diff --git a/integration-tests/vector/reverse.exp b/integration-tests/vector/reverse.exp index cc6460a0..c2db29b6 100644 --- a/integration-tests/vector/reverse.exp +++ b/integration-tests/vector/reverse.exp @@ -2,12 +2,12 @@ processed 4 tasks task 2 'run'. lines 5-25: { - "gas_used": 49521, + "gas_used": 24452, "status": "Executed" } task 3 'run'. lines 27-34: { - "gas_used": 14442, + "gas_used": 12693, "status": "Executed" } diff --git a/integration-tests/vector/spawn_from.exp b/integration-tests/vector/spawn_from.exp index ed33b077..a977c117 100644 --- a/integration-tests/vector/spawn_from.exp +++ b/integration-tests/vector/spawn_from.exp @@ -2,12 +2,12 @@ processed 4 tasks task 2 'run'. lines 5-21: { - "gas_used": 33836596, + "gas_used": 10509017, "status": "Executed" } task 3 'run'. lines 24-43: { - "gas_used": 84949, + "gas_used": 51718, "status": "Executed" } diff --git a/integration-tests/vector/split.exp b/integration-tests/vector/split.exp index 16eed57a..3b8d1081 100644 --- a/integration-tests/vector/split.exp +++ b/integration-tests/vector/split.exp @@ -2,12 +2,12 @@ processed 4 tasks task 2 'run'. lines 5-28: { - "gas_used": 94147, + "gas_used": 37013, "status": "Executed" } task 3 'run'. lines 30-57: { - "gas_used": 124192, + "gas_used": 44321, "status": "Executed" } diff --git a/integration-tests/vector/swap_remove.exp b/integration-tests/vector/swap_remove.exp index 02d58b3a..76f63c8b 100644 --- a/integration-tests/vector/swap_remove.exp +++ b/integration-tests/vector/swap_remove.exp @@ -2,6 +2,6 @@ processed 3 tasks task 2 'run'. lines 5-24: { - "gas_used": 52745, + "gas_used": 23595, "status": "Executed" } diff --git a/integration-tests/version/basic.exp b/integration-tests/version/basic.exp index d8d3b3ae..8f676e56 100644 --- a/integration-tests/version/basic.exp +++ b/integration-tests/version/basic.exp @@ -2,7 +2,7 @@ processed 4 tasks task 2 'run'. lines 5-12: { - "gas_used": 61663, + "gas_used": 57582, "status": "Executed" } diff --git a/integration-tests/yield_farming/basic.exp b/integration-tests/yield_farming/basic.exp index 2ab0bc9e..5c21520e 100644 --- a/integration-tests/yield_farming/basic.exp +++ b/integration-tests/yield_farming/basic.exp @@ -14,7 +14,7 @@ task 9 'run'. lines 110-129: task 10 'run'. lines 134-149: { - "gas_used": 126634, + "gas_used": 124885, "status": "Executed" } diff --git a/integration-tests/yield_farming/cap_local_store.exp b/integration-tests/yield_farming/cap_local_store.exp index 8b374b88..66c6318e 100644 --- a/integration-tests/yield_farming/cap_local_store.exp +++ b/integration-tests/yield_farming/cap_local_store.exp @@ -14,7 +14,7 @@ task 9 'run'. lines 101-120: task 10 'run'. lines 122-137: { - "gas_used": 126634, + "gas_used": 124885, "status": "Executed" } From 35a4bde78a9af3acaa8aae25748b1ba25bc0900d Mon Sep 17 00:00:00 2001 From: sanlee42 Date: Mon, 7 Aug 2023 10:13:44 +0000 Subject: [PATCH 3/6] easygas setting gas fee address custom --- build/StarcoinFramework/BuildInfo.yaml | 2 +- .../bytecode_modules/Account.mv | Bin 6725 -> 7000 bytes .../bytecode_modules/EasyGas.mv | Bin 0 -> 373 bytes .../bytecode_modules/EasyGasOracle.mv | Bin 894 -> 921 bytes .../GenesisSignerCapability.mv | Bin 470 -> 480 bytes .../bytecode_modules/StdlibUpgradeScripts.mv | Bin 2036 -> 2101 bytes .../bytecode_modules/TransactionManager.mv | Bin 1513 -> 2601 bytes build/StarcoinFramework/docs/Account.md | 134 ++++++- build/StarcoinFramework/docs/EasyGas.md | 4 +- build/StarcoinFramework/docs/README.md | 1 + .../docs/StdlibUpgradeScripts.md | 4 + .../docs/TransactionManager.md | 337 +++++++++++++++++- .../source_maps/Account.mvsm | Bin 51351 -> 53565 bytes .../source_maps/EasyGas.mvsm | Bin 0 -> 1352 bytes .../source_maps/EasyGasOracle.mvsm | Bin 4946 -> 4946 bytes .../source_maps/EasyGasOracleScript.mvsm | Bin 1082 -> 1082 bytes .../source_maps/GenesisSignerCapability.mvsm | Bin 1176 -> 1176 bytes .../source_maps/StdlibUpgradeScripts.mvsm | Bin 6351 -> 6477 bytes .../source_maps/TransactionManager.mvsm | Bin 9981 -> 19414 bytes integration-tests/oracle/EasyGas.move | 14 +- sources/Account.move | 32 +- sources/EasyGas.move | 65 +++- sources/GenesisSignerCapability.move | 1 + sources/StdlibUpgradeScripts.move | 4 + sources/TransactionManager.move | 156 +++++++- 25 files changed, 729 insertions(+), 25 deletions(-) create mode 100644 build/StarcoinFramework/bytecode_modules/EasyGas.mv create mode 100644 build/StarcoinFramework/source_maps/EasyGas.mvsm diff --git a/build/StarcoinFramework/BuildInfo.yaml b/build/StarcoinFramework/BuildInfo.yaml index a43918f7..541b178e 100644 --- a/build/StarcoinFramework/BuildInfo.yaml +++ b/build/StarcoinFramework/BuildInfo.yaml @@ -5,7 +5,7 @@ compiled_package_info: StarcoinAssociation: "0x0000000000000000000000000a550c18" StarcoinFramework: "0x00000000000000000000000000000001" VMReserved: "0x00000000000000000000000000000000" - source_digest: 637209FA52731CFA47D4139FE4B6A885FAF533D29D4582C33D7B099E4400275D + source_digest: 6EF08DF52A858E24C0F8C3B770B8ECC8CB41BAB3A358E07D9BD54871EFB2AFC4 build_flags: dev_mode: false test_mode: false diff --git a/build/StarcoinFramework/bytecode_modules/Account.mv b/build/StarcoinFramework/bytecode_modules/Account.mv index 02b8a9665681ac4e08d770dcfd82edb6439bb334..6e8e0c9c37df7b201a8b77b402a6fa339c9db5a0 100644 GIT binary patch delta 2871 zcmZWrNpKuz75?Arzt_K~XL_b*(LN)|k}X-1TO*BHOSCxhB3tqnC-M?Yk)^RMV#$t{ zV6#m~Sb`0N&_HqE!kMEFKvg(W6{>RK#tAr5#RZB3AzXN`CA$Jl&3yg-_rL$`|Lghf z$RBErpSS*18A1pTL_4-$)pq_QrTi4sKPuAw zXXUe8>hGiN-Ul^Ie^^5S0)-}|(1jsPVF_C}LJ3!-geTG>L;ArI!lz%>0+P-VC!kf{ zXb4e|LKKNnqGuC5n`xtk=vG6xDM{k)UD9crAcX#=1Osfx6rxQ4NYS2P2Wmo;Q4*t~ zGj<~B>C%wMZe+P5CS#Aq*qh){+Y#azl6}#K1pSKOIG-C}7<5^5D8+app+k@9;WT44 zL(Yu&1fw>uYgr=4a!f`EjOG+!DVa{;!2+2m3CTQ z?I3uyOz>KTU|CVb*E+j|xZX(8bEBJW+&segdJp5RUdEN9jH}1`2;b-@7uSw6d3%6y zeUNcuh_QZx(0x2i$(LVhYZLaDsZP@Qij4xlI;w&2zBUFRjE1HOdgzxZtMM*G z1_*a>oGiKTK_5T90rZsa9hd;Ae-owv4EZe}wbr*`E+pyq0jRd}JIvFc0Hw@&3gOEj z^zVW_4~F$UI8EBk@54DMfhY9^dIxoB!7L5jo)Q=LY^2fXdKVj$G)eGbR zgr!i13*q^&RJB7hJQ`}%C0uH|P+O8_^-AVSkPlx8E1@4wh1swADd zEYDugET6m{+^CkrTfwc&%IwO_%H+!Q%E^^eec_q#Y`A=CAY9D^tHDgDh4tEeIA6U} zoeMX^mN34jJx%EjqTvG4SJ&cyX;(mx7vv|o?A4vM?cKHYz0C*POKaO}ck4UP^7^M( z$ZymiKG@ydTituGdVB5u+V*;V_3hzjDQgMx!RGGj#{SmUpSgHGra*I)1)(~Nvat#lZ2ey!?J(P6zEeCbfc38&R zWi<8}9Rp!sHyJF%ef@0*ZG8W&xIF5|(+#o5{m8XPo5m+aTeDew#jPu7C@nxdo zd`{bdCCCB z)6=HX=ztZqVl!C+u$3Ss7P-@`FssX`4O`-^T(Q9u2{a{+0k*Mm%p_WX^rp+w(v@lZ z*LoFQ!?cV#kR}$H$L1tn7RsIwL&tE) zgSnbfCXzoDY3Pbwbo`sWiRVc8I=u%Wei+O+y(9x!-iUu4w2dDPsSR6?^59mit_ zygpK+(9?owfO-fN^-<(w-{EGQ&gUEb>Z&Nj z6ECtj)A5Dk#OzG6b^a1b-=^a;}K~Vr#KehMpFUmR(z~+ODl^IjJ=NV*Kx7e{N$+s8m$&H>Svb zG!{iT8;_Tw##~}}={>&Ox9JkKQiIy2^6%2+;YRUv-}Jdl=-RoC;|%(p@(647?>SJB z9eOwUXQrr|^?-sqqxh z4H`uH2apV!ObX|jq@84lPGH}u|Cy^3c>2Fj58#=EaWVc?Q>%M6p)Zvwd5iI%n~HEP M{G@ALw7&zp|Xad%r2U@7D|V&+9)W|F;A0p!uMo zf)5)%F6I8&?hhZ$5+6k%ut0$Z8ys-K10M_okb@BN!tDYS_#e5*wndhdcvt3cMRfqW zc+sr@s{HL?MUB_JHUxoU^WY9Mx()*9y9#aeJO`i;5Eaxj>?aFgfD{WFTChpXGiVVn zhe+&(9l;S-a5Td)&j%Qn(2sQlCk(@+oI5Ts6^Ln^6FdV~d;uQc+dS!q`i~yF%X8m%8D;3tC5~J0wZh$pD-+^_HSvIP|ve_fJRTDhT zse&^eGi+zhcCy=^l@QLA8P4}IToBmpW4K6lfTt=9m->18^Z>)2;mciaGy$$;iFjsE zh_4O_UK z9szxQ#zF`m%p!vQ4a)+0Xc3ri^49&F**Z$Ne70YY6)L=&hse{s1?b*?AMU6{xqw%z9hQ)H~VwT|N)t z5AiHJ&b`OZnCyMg;E#~Q3T~Wd{}^}2D&C6E#GUSz7d!E2Y_)c1r+&7*qny@mVYgh4 zFUE~Hij%k)_ry=dm*S`6y<~4`Z+UO!N?~vHO8J@AKzzM?y|BNszr3I9FYT}HZ;Zzq z@n*cYF&W<|+$b-_R(!j?7O%DLv{vF5<64XXphll>h_2@(91IInevs z5Wa$eta6n5n8xCarAyJ9mD6K9om`R7K$HtGM2Di`^rPr*FulN{?ZEM!XeK>dY!=Q1 zHuwJFFQBz{`mk7AZI`#&hR5THyelBxYcM(=SiY5nzQv@2Jkr zGYA%vMFn5{kxxmfp?m`g>c9XRGMJQ!r$($)FI)AdFPBbrD$IwSsI$C>3-EyIY z(1)bwB&Ji6YL(QfmbS{>9hqaa3>-t^Y33F#WGu+M`G#_}alGjAm_a_Rk^!n` z?x~jDSBwf`l;gWPWwGNZd}RN=k3~CaWao6!q<(%Y(Mkr39`OT#WE*DC%1%Ehhf58S zND#>oH967Tp-_ObLroey3eV8clV!osFdGp+kn8QVSt$os$FgvU@mjiG+4M(*q$tAl zy-K|^dYFHqHCz*?D>+VMhq7_QG77D7GR4J4!v#+w8vlP~{0ZeTi34fkun@yfTvIgo zaVCnK2^RNdJ&93gn!Ab%<`vBpyW%<$4>+Lxs4%*$eYcV$`NKo5`jSmT8tXbXwYQJFRyQ&CYSa z{J3PEW@%n>B$ig07I=MT_%QX|)j65UIqpssJ)6GOy}yufDf!`yd{}~pl0nj0+m)i{ zq@A+CPLNJYx-FD)acn%nJ=HcYrn}X}&Qhk@xy05txq#Z(#xZWR5CnnoF`4y)QB}|- z$Bk}{C90tYqJzZq&8X_r15UuV<&MR`|KwBP`}wfq`*GA%)1j5jH3Cn!y}&b`S~6C2 z&iI@iy~6aqN$sA2(!nyAT+$UCEOUs-LXyyOn)D=hR3c_VpV&)S9#yaE2O=v- zLy!?!Q+4zsbn+~rQ->Ad&NIj(71Qd`faYjTI)yd!tV=VKd!AzWA45j|G5`Po diff --git a/build/StarcoinFramework/bytecode_modules/EasyGas.mv b/build/StarcoinFramework/bytecode_modules/EasyGas.mv new file mode 100644 index 0000000000000000000000000000000000000000..6d4adfde8adf5a186d7e03dff6f7bad600198a40 GIT binary patch literal 373 zcmZ8dF;2rk5Zv4IImSLGafk#+v=j&^NgpM~qM_hKZC&ujIw?x5J2&|O4Ugb05wGC` zl$;ZgP_|j^?Cy+aJ}$qK5CCEZ5k>)*7vgHzyWg?sn+@YP6!IM>=?-!5i3ki3I0PX2 z0HL3thXCxP!($KgM0kt|45h#bB$F(ZW7SqGvv_H0t1D8k)-a0C*I0{}+I5`nRua{>n}2?2p4AApEM5L+T7 z^%0N|)g)g}CB0X_;Z+|t?Y;~ENW*Gqv6njjNYh>WPpZB`(fbYz z0>eSz5uhj%&`}Z!sz3yhpak1?|G9E7PLj9h?N^--GG-z@3kT>}?$C;%i6ufm8V!sj z+bY>sIWk+_aW0-zX8X2cNd5S6J{nF|)4SQ##r$@0IlY-&FJ|-A@?GhPQr|a`2a$)K Lm`2ZA-ZAh8H6gw08{%cR~tDnXIWTHqZ)#_27*{3(I{m4J5zqQXN9on;gvHP?-ri7q^BEjGVsGUkP z2PPmD84}t2b6X*}(=kg5c{&z)Bc$6LlXaZk#-Gh{1M73p5Tv8+I@+#_u)SKM1@F4B c(|sq<>C0iWf8ds-PqQpTma9bJ_3lHC7r_V>Q2+n{ diff --git a/build/StarcoinFramework/bytecode_modules/GenesisSignerCapability.mv b/build/StarcoinFramework/bytecode_modules/GenesisSignerCapability.mv index b64a53612704e6fad056b08d4b4244e793daee86..0dc3f994ed869cf0d25e86ec70afc8eff1f6a388 100644 GIT binary patch delta 106 zcmcb{{D66axK|4k$0;TOwp&bGTu+$TcwRA?@h)Iy;$Otf!@$PC&cMOI$-u_Jz{t(Q zz`(`8$iTqE#K6GB$H2_M$j`#az$C!Rz`!WT!py)dG%-<(gWWZ;xY9kbcw@OFBO~wR KiHxpHtPB93sSn`* delta 94 zcmV~$u@wP96o%37e{W`tv13QV(TENtx=_isuzMuvLJLX|h&FK4A#m@<-#+e6Kjo*j x^s-WBOWoHF_3GB&y%0$($i$3FfF**JfmIx>gRnk=T5xymP!nh0;-^k4}eTPS7BoX%Iz(M3XXd zOG6I`DWX6qqC@-{lt{D`l+1SQYCe71`K`2?{S$tUcHi}W`!)c$2s1Xz`JE-2J03j_$~Vca<4x?QJ)NPj6&Vd=)CSW{9e%4gJh`3$wrdv&173o^faiRW0NymRc~-o zeZsF&K3tYB50>Z8*e^`m>tgk^d{L|yt7W-(QWT5j@$tGS%kx9wv)GF0H~wF|I zP##E-NE@_I&b0DD*BH{^Fz`T|3aKJ0?Stg@%KR%WDRf-@wX?ls4j#;r?lqYiz49pA rQs{w?x=qKa?l21l1YrQWTOG)$9|WeEDOZoGS2Dw`>Me0pUC8}^it;}S delta 526 zcmWlWyKWRQ6o$`ld&V=i=i-^&?0t8#*=%NkT)1WzUV*2e;SnfOq(VX>MbHR|mWl_6 z5Q>zB=RnjHv{V#`V_WC*uXFxmOUGZ!KgIFq>2DhoQ3`5ByOJ+|Kz$M8=)1Uu{wv=n z$y-;(AKe>wmEC?g*<7Znraae#R#A1|f#6RAr6dqlkAkLN(EWhDfPr8PgBnT3IAEd} z)1YPnb4I*~K%!w^w9m+vjN*V{g3`+vlwPiMLh3LDv|AH|*7_)TH)JVU^5Z5b+_QYi z1LS0nixR3jsQ@LqF&_2SbXUutPr0M_hY0o`C%MlxuQ3Vt2WNrt0}@4ppxg zoUkt%;7rv?&rGtZpVf1}UoYzezpB^%$hR3{MejR>^mzLglJKdaCTQal-_w_}X vr8Vr`b1-D#2b>=Ik%*uuD{}JV?w#J)j0Xb0aH(&)JKf;0`^jv&fBO7CGJi2) diff --git a/build/StarcoinFramework/bytecode_modules/TransactionManager.mv b/build/StarcoinFramework/bytecode_modules/TransactionManager.mv index 49d595fd4a4c37b26208bed9fdc7b0e24c66c785..a105af2dcb1f27243683f998b522f98174a9d33c 100644 GIT binary patch literal 2601 zcmZ`*%W~T`6a`3tAOVsRDMfbTryN_3-8M~}N0mO(x`~r!k~W#h(?w@899o2B#*(O# zR1*I{|Dnr%LRVdM)m?U-eneOOfG*n$N@CQe#f+f?;NsqM4j{olEdL=4gph^NuC~kd z>%U|2y|zk!(tgG4JMuF#e-TyVH}NO7UpqglNQ^Y3BZ4S05JM)i5Jv*p$U!cupepi^ zk7}r1trCo|<1mEI!5-AmFeYe0SN$SU{dubT3kLMYl8F&r#*k};bL6d>HYSxd2P1vm z#mH(_s)%fO7&#Yl9TRgCSE1ihz1=#8k-Kd+kZ}n&5Z{6QwOw9E{yU92vfo|6$bSzI zzI^@y!tXa=3%>#}>?%a#y(J)d4VLTIm+Kgb8!Iaa-&}>s57vMJZm$D7@0JZc{!nH4 z2s-{T?AJb7f&I4|5dUd|BTHz$>sS1$PkicM@GpopYs0_jZ-`B?>036}bP9jErXy}s z9h$~9iUnXb{qK=lw2avzA?6Gdq7i|xiLqg04eJWQ*g~3N>xKb!RB{RfXkaV=0);1A zEJRdOhT9a}r^Tn@L5a$0A+=eRAdm(d+(MXZ8tm67%oGtig!+eRILyLs9w);u!(rHy zDckRMlkqTj_Q&~&9OiL1%#)OU-cP!xqUfK>mth*QJ11d0d=NQzl2q^>Y z2P1lzoXVj)$MT+(i*v&#JOzSjx;FkD?Ifd;R1n><2k8Za|qX7#U3X4rCreNN9)A^Kq5~DX_8r z&zQ704Fh;&dAHIFvmhxv4^kOMK5z=ME>Ifwf@3)6B(0Ao&Ij`<`BX!Y99Qlie09)y z&80mswsI&vWlHbsAWnraF!4s499~b znbx6FG#(7jf)Flsa4OH#dBda}jPf%xI|;7^dpB-2)K(QSz4maWRP5r*I6sNf@MUnE zCWBx~1u~qA;6O6qlP7btY!sd;LY905XAidJH6^sT*+C@xvIl}9XLeJ-v|LsqnZ_?9 z+?&Z=^514r`Ijd60iSPJH{VG65_HK>hhMb);pPIy~y6Wg{0b@yhr%!s}r$_ft7x1rX{@|e^{t8jrJ+a|!tlTPS? zw&)ehwuD7)LX_^UdrdC(X72g9S$)5+oS@ZkCN z*b&_Yc{H6Y$?Z524?P|Af5W(|>hYDTp2#IlcVl!DWW^QbRt7-?>2yp zn}KD)WZ=-!I#ya065^C&PC658N-w8e;g3D2X_SxYK^Aqd)9`$ lCA#yPy0|5~n$5Q$P3w}-kUeL#YKq=GV@2%Bp5~On;4c_XN;?1m diff --git a/build/StarcoinFramework/docs/Account.md b/build/StarcoinFramework/docs/Account.md index a8458251..0259d708 100644 --- a/build/StarcoinFramework/docs/Account.md +++ b/build/StarcoinFramework/docs/Account.md @@ -41,6 +41,10 @@ The module for the account resource that governs every account - [Function `deposit`](#0x1_Account_deposit) - [Function `deposit_with_metadata`](#0x1_Account_deposit_with_metadata) - [Function `deposit_to_balance`](#0x1_Account_deposit_to_balance) +- [Function `deposit_to_balance_v2`](#0x1_Account_deposit_to_balance_v2) +- [Function `withdraw_from_balance_v2`](#0x1_Account_withdraw_from_balance_v2) +- [Function `set_sequence_number`](#0x1_Account_set_sequence_number) +- [Function `set_authentication_key`](#0x1_Account_set_authentication_key) - [Function `withdraw_from_balance`](#0x1_Account_withdraw_from_balance) - [Function `withdraw`](#0x1_Account_withdraw) - [Function `withdraw_with_metadata`](#0x1_Account_withdraw_with_metadata) @@ -80,6 +84,7 @@ The module for the account resource that governs every account - [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 `is_dummy_auth_key_v2`](#0x1_Account_is_dummy_auth_key_v2) - [Function `txn_prologue`](#0x1_Account_txn_prologue) - [Function `txn_prologue_v2`](#0x1_Account_txn_prologue_v2) - [Function `txn_epilogue`](#0x1_Account_txn_epilogue) @@ -1574,6 +1579,106 @@ Helper to deposit amount to the given account balance + + + + +## Function `deposit_to_balance_v2` + + + +
public(friend) fun deposit_to_balance_v2<TokenType: store>(sender: address, token: Token::Token<TokenType>)
+
+ + + +
+Implementation + + +
public (friend) fun deposit_to_balance_v2<TokenType: store>(sender:address, token: Token::Token<TokenType>) acquires Balance {
+    let balance = borrow_global_mut<Balance<TokenType>>(sender);
+    Token::deposit(&mut balance.token, token)
+}
+
+ + + +
+ + + +## Function `withdraw_from_balance_v2` + + + +
public(friend) fun withdraw_from_balance_v2<TokenType: store>(sender: address, amount: u128): Token::Token<TokenType>
+
+ + + +
+Implementation + + +
public (friend) fun withdraw_from_balance_v2<TokenType: store>(sender:address, amount: u128): Token<TokenType> acquires Balance {
+    let balance = borrow_global_mut<Balance<TokenType>>(sender);
+    Token::withdraw(&mut balance.token, amount)
+}
+
+ + + +
+ + + +## Function `set_sequence_number` + + + +
public(friend) fun set_sequence_number(sender: address, sequence_number: u64)
+
+ + + +
+Implementation + + +
public (friend) fun set_sequence_number(sender: address, sequence_number: u64) acquires Account {
+    let account = borrow_global_mut<Account>(sender);
+    account.sequence_number = sequence_number;
+}
+
+ + + +
+ + + +## Function `set_authentication_key` + + + +
public(friend) fun set_authentication_key(sender: address, auth_key: vector<u8>)
+
+ + + +
+Implementation + + +
public (friend) fun set_authentication_key(sender:address,auth_key:vector<u8>) acquires Account{
+    let account = borrow_global_mut<Account>(sender);
+    account.authentication_key = auth_key;
+}
+
+ + +
@@ -1583,7 +1688,7 @@ Helper to deposit amount to the given account balance Helper to withdraw amount from the given account balance and return the withdrawn Token -
fun withdraw_from_balance<TokenType: store>(balance: &mut Account::Balance<TokenType>, amount: u128): Token::Token<TokenType>
+
public fun withdraw_from_balance<TokenType: store>(balance: &mut Account::Balance<TokenType>, amount: u128): Token::Token<TokenType>
 
@@ -1592,7 +1697,7 @@ Helper to withdraw amount from the given account balance and return Implementation -
fun withdraw_from_balance<TokenType: store>(balance: &mut Balance<TokenType>, amount: u128): Token<TokenType>{
+
public fun withdraw_from_balance<TokenType: store>(balance: &mut Balance<TokenType>, amount: u128): Token<TokenType>{
     Token::withdraw(&mut balance.token, amount)
 }
 
@@ -3124,6 +3229,31 @@ Checks if an account exists at check_addr + + + + +## Function `is_dummy_auth_key_v2` + + + +
public fun is_dummy_auth_key_v2(account: address): bool
+
+ + + +
+Implementation + + +
public fun is_dummy_auth_key_v2(account: address): bool acquires Account {
+    let account = borrow_global_mut<Account>(account);
+    account.authentication_key == DUMMY_AUTH_KEY
+}
+
+ + +
diff --git a/build/StarcoinFramework/docs/EasyGas.md b/build/StarcoinFramework/docs/EasyGas.md index fc860c05..c2d98220 100644 --- a/build/StarcoinFramework/docs/EasyGas.md +++ b/build/StarcoinFramework/docs/EasyGas.md @@ -55,7 +55,7 @@
public entry fun init_data_source<TokenType: store>(sender: signer, init_value: u128) {
-    EasyGasOracle::init_data_source<TokenType>(&sender,init_value);
+    EasyGasOracle::init_data_source<TokenType>(&sender, init_value);
 }
 
@@ -79,7 +79,7 @@
public entry fun update<TokenType: store>(sender: signer, value: u128) {
-    EasyGasOracle::update<TokenType>(&sender,value)
+    EasyGasOracle::update<TokenType>(&sender, value)
 }
 
diff --git a/build/StarcoinFramework/docs/README.md b/build/StarcoinFramework/docs/README.md index 4ef739e7..f08273aa 100644 --- a/build/StarcoinFramework/docs/README.md +++ b/build/StarcoinFramework/docs/README.md @@ -35,6 +35,7 @@ This is the root document for the Move StarcoinFramework module documentation. T - [`0x1::DummyToken`](DummyToken.md#0x1_DummyToken) - [`0x1::DummyTokenScripts`](DummyToken.md#0x1_DummyTokenScripts) - [`0x1::EVMAddress`](Signature.md#0x1_EVMAddress) +- [`0x1::EasyGas`](EasyGas.md#0x1_EasyGas) - [`0x1::EasyGasOracle`](EasyGas.md#0x1_EasyGasOracle) - [`0x1::EasyGasOracleScript`](EasyGas.md#0x1_EasyGasOracleScript) - [`0x1::EmptyScripts`](EmptyScripts.md#0x1_EmptyScripts) diff --git a/build/StarcoinFramework/docs/StdlibUpgradeScripts.md b/build/StarcoinFramework/docs/StdlibUpgradeScripts.md index d2f4df95..f7b13d91 100644 --- a/build/StarcoinFramework/docs/StdlibUpgradeScripts.md +++ b/build/StarcoinFramework/docs/StdlibUpgradeScripts.md @@ -25,6 +25,7 @@ The module for StdlibUpgrade init scripts use 0x1::Collection; use 0x1::Config; use 0x1::CoreAddresses; +use 0x1::EasyGas; use 0x1::EasyGasOracle; use 0x1::GenesisNFT; use 0x1::GenesisSignerCapability; @@ -344,6 +345,9 @@ deprecated, use do_upgrade_from_v6_to_v7_with_language_version. @0x8c109349c6bd91411d6bc962e080c4a3, b"STAR",b"STAR", @0x8c109349c6bd91411d6bc962e080c4a3); + //TODO: + EasyGas::register_gas_fee_address(sender,@0x3); + Block::checkpoints_init(sender); }; } diff --git a/build/StarcoinFramework/docs/TransactionManager.md b/build/StarcoinFramework/docs/TransactionManager.md index c869fe31..076a2f98 100644 --- a/build/StarcoinFramework/docs/TransactionManager.md +++ b/build/StarcoinFramework/docs/TransactionManager.md @@ -13,17 +13,22 @@ - [Function `epilogue`](#0x1_TransactionManager_epilogue) - [Function `epilogue_v2`](#0x1_TransactionManager_epilogue_v2) - [Function `block_prologue`](#0x1_TransactionManager_block_prologue) +- [Function `txn_prologue_v2`](#0x1_TransactionManager_txn_prologue_v2) +- [Function `txn_epilogue_v3`](#0x1_TransactionManager_txn_epilogue_v3) - [Module Specification](#@Module_Specification_1)
use 0x1::Account;
+use 0x1::Authenticator;
 use 0x1::Block;
 use 0x1::BlockReward;
 use 0x1::ChainId;
 use 0x1::CoreAddresses;
+use 0x1::EasyGas;
 use 0x1::EasyGasOracle;
 use 0x1::Epoch;
 use 0x1::Errors;
+use 0x1::Hash;
 use 0x1::PackageTxnManager;
 use 0x1::STC;
 use 0x1::Signer;
@@ -32,6 +37,7 @@
 use 0x1::TransactionFee;
 use 0x1::TransactionPublishOption;
 use 0x1::TransactionTimeout;
+use 0x1::Vector;
 
@@ -41,6 +47,24 @@ ## Constants + + + + +
const MAX_U64: u128 = 18446744073709551615;
+
+ + + + + + + +
const EDEPRECATED_FUNCTION: u64 = 19;
+
+ + + @@ -50,6 +74,150 @@ + + + + +
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;
+
+ + + @@ -155,12 +323,12 @@ It verifies: // specified by the transaction assert!(ChainId::get() == chain_id, Errors::invalid_argument(EPROLOGUE_BAD_CHAIN_ID)); let (stc_price,scaling_factor)= if (!STC::is_stc<TokenType>()){ - (EasyGasOracle::gas_oracle_read<TokenType>(),EasyGasOracle::get_scaling_factor<TokenType>()) + (EasyGasOracle::gas_oracle_read<TokenType>(), EasyGasOracle::get_scaling_factor<TokenType>()) }else{ (1,1) }; - Account::txn_prologue_v2<TokenType>( + txn_prologue_v2<TokenType>( &account, txn_sender, txn_sequence_number, @@ -335,7 +503,7 @@ It collects gas and bumps the sequence number }else{ (1,1) }; - Account::txn_epilogue_v3<TokenType>( + txn_epilogue_v3<TokenType>( &account, txn_sender, txn_sequence_number, @@ -428,6 +596,157 @@ The runtime always runs this before executing the transactions in a block. + + + + +## Function `txn_prologue_v2` + + + +
public fun txn_prologue_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, stc_price: u128, stc_price_scaling: u128)
+
+ + + +
+Implementation + + +
public fun txn_prologue_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,
+    stc_price: u128,
+    stc_price_scaling: u128
+)  {
+    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 (Account::is_dummy_auth_key_v2(txn_sender)){
+        // 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) == Account::authentication_key(txn_sender),
+            Errors::invalid_argument(EPROLOGUE_INVALID_ACCOUNT_AUTH_KEY)
+        );
+    };
+    // Check that the account has enough balance for all of the gas
+    let (max_transaction_fee_stc,max_transaction_fee_token) = transaction_fee_simulate(txn_gas_price,txn_max_gas_units,0, stc_price, stc_price_scaling);
+    assert!(
+        max_transaction_fee_stc <= MAX_U64,
+        Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT),
+    );
+    if (max_transaction_fee_stc > 0) {
+        assert!(
+            (txn_sequence_number as u128) < MAX_U64,
+            Errors::limit_exceeded(EPROLOGUE_SEQUENCE_NUMBER_TOO_BIG)
+        );
+        let balance_amount_token = balance<TokenType>(txn_sender);
+        assert!(balance_amount_token >= max_transaction_fee_token, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT));
+        let gas_fee_address = EasyGas::get_gas_fee_address();
+        if (!is_stc<TokenType>()){
+            let balance_amount_stc= balance<STC>(gas_fee_address);
+            assert!(balance_amount_stc >= max_transaction_fee_stc, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT));
+        }
+    };
+    // Check that the transaction sequence number matches the sequence number of the account
+    assert!(txn_sequence_number >= Account::sequence_number(txn_sender), Errors::invalid_argument(EPROLOGUE_SEQUENCE_NUMBER_TOO_OLD));
+    assert!(txn_sequence_number == Account::sequence_number(txn_sender), Errors::invalid_argument(EPROLOGUE_SEQUENCE_NUMBER_TOO_NEW));
+
+}
+
+ + + +
+ + + +## Function `txn_epilogue_v3` + +The epilogue is invoked at the end of transactions. +It collects gas and bumps the sequence number + + +
public fun txn_epilogue_v3<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, stc_price: u128, stc_price_scaling: u128)
+
+ + + +
+Implementation + + +
public fun txn_epilogue_v3<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,
+    stc_price: u128,
+    stc_price_scaling: u128,
+) {
+    CoreAddresses::assert_genesis_address(account);
+    // Charge for gas
+    let (transaction_fee_amount_stc,transaction_fee_amount_token) = transaction_fee_simulate(
+        txn_gas_price,
+        txn_max_gas_units,
+        gas_units_remaining,
+        stc_price,
+        stc_price_scaling);
+    assert!(
+        balance<TokenType>(txn_sender) >= transaction_fee_amount_token,
+        Errors::limit_exceeded(EINSUFFICIENT_BALANCE)
+    );
+    let gas_fee_address = EasyGas::get_gas_fee_address();
+    if (!is_stc<TokenType>()){
+        let genesis_balance_amount_stc=balance<STC>(gas_fee_address);
+        assert!(genesis_balance_amount_stc >= transaction_fee_amount_stc,
+            Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT)
+        );
+    };
+    // Bump the sequence number
+    Account::set_sequence_number(txn_sender,txn_sequence_number+1);
+    // Set auth key when user send transaction first.
+    if (Account::is_dummy_auth_key_v2(txn_sender) && !Vector::is_empty(&txn_authentication_key_preimage)){
+        Account::set_authentication_key(txn_sender, Hash::sha3_256(txn_authentication_key_preimage));
+    };
+
+    if (transaction_fee_amount_stc > 0) {
+        let transaction_fee_token = Account::withdraw_from_balance_v2<TokenType>(
+            txn_sender,
+            transaction_fee_amount_token
+        );
+        if(!is_stc<TokenType>()) {
+            Account::deposit_to_balance_v2<TokenType>(gas_fee_address, transaction_fee_token);
+            let stc_fee_token = Account::withdraw_from_balance_v2<STC>(gas_fee_address, transaction_fee_amount_stc);
+            TransactionFee::pay_fee(stc_fee_token);
+        }else{
+            TransactionFee::pay_fee(transaction_fee_token);
+        }
+    };
+}
+
+ + +
@@ -439,3 +758,15 @@ The runtime always runs this before executing the transactions in a block.
pragma verify = false;
 pragma aborts_if_is_strict = true;
 
+ + + + +
pragma verify = false;
+aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS();
+aborts_if !exists<Account>(txn_sender);
+aborts_if !exists<Balance<TokenType>>(txn_sender);
+aborts_if txn_sequence_number + 1 > max_u64();
+aborts_if !exists<Balance<TokenType>>(txn_sender);
+aborts_if txn_max_gas_units < gas_units_remaining;
+
diff --git a/build/StarcoinFramework/source_maps/Account.mvsm b/build/StarcoinFramework/source_maps/Account.mvsm index d79f2407ee4b23d2a2a3f2fd5207f17d338eb58f..6c006a98a4020127bd95fa5b0d2446d44ac7802d 100644 GIT binary patch literal 53565 zcmbuIcYGC9-iId%AtY2G0Tsa{bdWA0RYGzhfizR7folj?2&4c>kRTmF5D-CKz=DVf z0*cZsbTOcUqUcgqlwzgWzz({;&jDt4-+jyXT$a!0`G?Ol=ggcrzf*oQck)Dor&_$b z{hOaQrF}ZK?xm;RE&cA~qFFC?`Qy@x5s5S3J9u=M<2VHn0RQ?gAS5Oyr?8};xQgRE zA<9@=)p53h6QIn)SSKMsmRS_!IOD+yQDp{|bDRiJ-jZO)SqI7+7vebcL3uynl&he< zJe=_s-VvO$7T&B-$5{k{@(fp8=QtZd-AA!jZm$jM7m))lg2D zdvgIRfb$HIWzMVQILkqo`3lxvs36O%LhX^}JOkDJ z>4en_ls5<`7eb|3hq!2N6-6DfxI;=+nN=%0&P|}>Vi;CFsC&5?XQzc%nQzoZ(J3+5DR$_ewdd_#xQ_s4;Qr;h+=Sa6qi%W`} z={U{6k4|$7dOLGS$dK&3?1CJ*;_Qm-0jrT@2I5>(y6g-0VJ!sR7xJ(k28$b)HJ@n% zEJI=p>R7M}i8Y9AAEIoFkl2g6&lD`1VI9^c(9Pi1uS4P@<^3IWNF2jD4LT%@S)Qxc zOIG(hbw{sHc}+ks@!T>kB64Q~=3($7Bo3e-F^AOfW|tHX_Z1Z9=42P=78ZC%`byR4 zcaj5t0ITq5-q3MkK=+FqvAToq7vWb;n_JV!arS^8ZL=5sJ#$FqyT|y7hI`Ef?JFu$ zt#Xt@zA%SXEb!gqwOqqhZR|KVf@878Y=(C`=$5R5)d6%%y7lV_OQpOl&=EEmD-U#p z#bV`yo^)1Yy$(7SpTjb?o}N}<{Q){^zrZ>VI%?m?x&V5+72U*fT7cd}gbQH5)8?^?SFHiUU8o zz^_Jc#~IspfiUFjz`rg~nenZM(R-@(t$973o?fYs>q0OA4@o3h(KjI|7OXI_r=66ns{ z2Wvg(&TOm=U@<>VY0qN{a01E~`3i>mWR7Gp@=^$`e09O*9a38ClgqYR9UZ4W1mvpu zq8wH*Tv^}QEeb!uKMi4KO<0sWtUzB!Mkg{;5LV>#4Yj+5@*Nzf8iZaxWO#PbaCI&3 zWB(1RTxna|HSQ(TzPCG0)gs^M5+6HhZ$U}^5PeOza!f2#EGo|NT5iJM#Qy*s1^{(A zH{&$`-Ty0LH3Z%N-D}nTKa284fbRc2uttI&%-t5#OXJg&_cQ3h{1DbJpa*le?e$ph5+=Dk?+AWE7~VXcN}X|BOq3-zS= z5Z3chUz+o;nhm6xi}?aHl;%#XUC>CHZ(x-{V`;vQwHum9b1T+1Xev!p^B!m>%}ZDn zSQp$P&2yNcn9Zf>E>BuWvm@nsprtfxVD*4j(k#K60v%3B1t zO7m5$H=vy~mtd8_ZPJ{BwFfNnKaK10S^$u&{g=$5?UF5?BL{+CX~|U_u)$PWL9e|g z;Vm&0$ZLKB>oDlG*Ji9Epx0jRnd-IIx0H7g^xErptg!kv8|hP+6*2YND*`JLES4(G z$w_rIc`3VxoSjhbxSYmv0`%&pVifZM@Bk<$dz4yNM`JcHHg`ha-T{b%Kz9UV4gr08 z6R~o@Vl~!zG1Y@*vkgWaVsw`6^3t{-?f`vh&tSa-x{oi%Is&>87GfO*i-qR0C62Ql zEE{15>TaXkG{TLKu{;6Y2tioYKsQ1lRy)v*aDmgj4bx%`oz%^7GQf{qP$v3d2&^#1 zm*dMFtGBeHu*X4IaiMppZ&YDXu1q-3L4OpiT01y~u>y2!SH-#kbZghfstdZcKj$=W z#vzh&frIDcR}v~fwm9iQ;_>WaItx5RE=7rF~@>cJHLqdGU#?*gS8EGJMX}H z19Uq-j#UO0ySRh|x+wV3&R+E45NMe~8;yGp*fsN1%$Z=OR5^lvkN7j_X5NQ&40JPB z>&1=*bTik-Y65zd5P;PbEH=xtI_s#X1W*jb^NKV3Bod-JOX8 z{0O<8=&2B7J+lwN9sz#D+(h*Ip+df|ID2SzakiSGoV3s{}ekFLEN4F?ERkhG}daqCa8vqf8y5aaf6f*5pW?vky^nlKZ z-+`41Iww8~Ydq+jcof#XpmX9MV0{ESC;lz4Ctd@q4d|S>x#wNM;*xevcAOJnmsmK7`I)h8HlFRLkPrbql7(U23VI}KgVh%F zNM>s81Qs`|G>Vt1z^)DEV$L_VO&c6QJP5iC)?@7l-3D)C?E~Egrsfa8q8kpH#oK@2 z#}u89KGqy!yDFZHJkuP&6wQ9nn^QPcPMra>N!5YPo0gj>d#fp5u7i(aeGj^^w_{xZ z-Pq4#Z3I1aR^fVX0X=oPSFfke<&?J?^wc>YYYphBvlwdz=&3XC0Uld`o;pWjm4Kc) zJ7L`idg?sLInKw_Q>U>W0*lf1!D%!T*l+sQVsC&DlkT^8AA37)83fis_KqnmzVaqF z`Q7Xxxp}$8@`dg{I5>PdZF%JlmCGAOwSujEAG<|hUX)SNp0c}wj;C5!cYuy3_ndV+ z6;a+C(D5`6YYFIhO2B#ybUc+|9RnRtE3iHW9Z$iudnM5E^cCe*#?xYbfZY=|2B7<*(nPBu8U@Ai*G9t{B% z|K)vkH7)Jpfc>VHnmXuD;eBN)ki)|Ptka;ow_CsN-bI60*MaWdnOKuSckc`=W9#mn zi1j+?uDA$mC+My?6>AshuISdTyW&~O`yO;xdUt1jq0LMhg> zp!W#hV*LhskFXJ|g4bq`5Mye_)ahyuRx0RpbyKWPpwrbOvF3qJR}aK`5S*K3$eq0z zEfV-=F@g7pWOM-?%Pp{SK*w@E);+*!sA1>#c?8IVRB!)0 zX@%Y19AVS8a}gf~-L|8#rh#tTrC6_m4&rTC`#`tYYgk)Bhr6lWlxgvslbC4U5e3UY z%S7#ObejoiF5*L=8@3p0Jm`is<^pgU$e5}11Zx_wdkWbev!k&&30ZV5Vjk!#8;&)> z6x&c1+OHWoRd53R`Ep7DN0dT!|G!@|m&2AqK(&AWJ%yUv+ug#iV1OUt$jkbW8oo5O zNV5#JHptlt6{nT5E2Pp4R&|8YpSbqV%rFaf&Bj_!~yI3bcZz+Z}cbqYxw-gPrrh$I! zP#$YK=q*LX7G&o@Zz;x=AJJGivgu| z5#RX(Kk^G5(PP2-!D}XR76gyVF7?T`>?nYTyLqK;UA65bAZZ!0& zsk>1_%tFxJ$h~?!{;#6E=RuGETd;P49{&$u9R@xAmtvg)J^mZ(Q?OV7blx6&u^#I+(7};~RR%gZjI{?W*8JBu zU~LYhy1c`D1-_!(BHJ$$x8$%p%%SuJIi|)VrWjdoF7Bw!ANl~guif|X`XLX7Yks@= zzMFUz68w3)c?}hAHfI^BFMdDXLC`VtD%J;}W5%st$INe(SB|UGG4lmxFs6=~&oPay zW9DP5PL!#8Z5^x*pqKO^SRFwx>D}7(l70u}m4RN;FU8sedP(p0E1l^3gYqKk*d+RD zVRZ(b==+c|yI|@>-$<-!pc8$)v8IDg^ew@93Us3HX{?Q)({~H77K2XTox=JGbo%ZM ztka;=cMa>Z*$17ztAKR_==9wm-r?aU#zccUw^2TXIwo-`YA zfhk>@Bd`{Nz8l7R7%aYLcW@Ffae&?9)bp4>8k@;eo^R%4ek2e2%8WT2bnoei)f;s0 znS!+fbnjV-wHow#pa^RXSbY6&-(4&+z^+}t#5`kcn|4jfW_JL(U5z;ebi3Y)DgoVYJ+a1u zZZ~7y15R6cgL~XVo(i16Ad5U>Ddq&IdHK}~zyI{mQV!h&0kzy0!E-MEm0>S`p{KB9 zjQ-PJr#bjfuz6BcXPo0ig1!aDYz4Yu1F>p=9!A_V)x*ea%3B6{7#WZCH0Tt^vskM@ zr#O~ltpJ_k7=v{R^mc7G)(OztwbfWBL2uXG+Vytr`cl?Opr6&8qvk+Ny6=S+^t^^p@%8&IOrktHLP8rhfrgF2zm%Lrm0;Ip~gA^ zPJ7u*wHGjdfc@H|HTLaL-dB)4Bu_qK&#iv$6-z|h36C&+?_j2Jv;mx>Iq=T zl2^JAZwctGGa2hK&|SwpUEOtdQC=D7uJat$I?!Eb1=iGsHeKfsW*DZPQ-iTW4YEBy zrOY2pxzcp+l1{)jrsfu)6R_7~)dfAH8?yoE8Qqwsc0HpTt0m|eJrgSn^o(ABRSbGY zABR#}#;oWfyrzjmg#9-@kIqDY(uYm7hKC z@{uL{*-ZJ0&3C4@jSP3DuFFTT=g!aOPi_{-1wvJhi-u71=fAAZvlVs+xb7cEc#Cqf z^DOF0;HUvm&gR#Vqc)L%1Kc)hm6M0JA8Hhj$u20$&bj>8lJEBUyquysb~-2Y7l`=x zW39eteug9e4m?Ma9b*aJO3=M+4c1oBBf}1?gP=!-ZCKkuj|{7@o&!BHEXFzpdSq~0 zS&s}=xsTDHS7KGLnt@)4HOIOQ^h)e@tOU?2F$b#`=#`k;NAya}^!XW}S7NiV9ss=( zn~60G^h(T)IK2{kkn)}ey%Jl2WujQG#Fk?{19~Oqo~M2o?T!ojVe}emUJLqRv|FZr z#JrjE_JMxH?3NiR$B+!l%Y`Uu9>zKY(b7DJC)ke4uW|Xll-&HEZ-3J7MJo#~W6HM9C9E6nvdZf<6GPWM6`(aIg#A>9*Tnl=n zUV!yH=#hFJRw=dX@wX4w2+-qiH>{DM$KQ@uO+Ee|<2+A*9)I7(IthCGb^C}Oe=BpI z;h@Lg3)CEesmEV)&+h}Li|lsqyu_a!0zabbZ|I*wdD|BOenh?mVP-vQ_ji7)tmkDS zsBz^Gzy1zwGmh&D{w2#Gh zX*RRkV(=rNmY^?(5Zi#-guE5}2&e<-N8wrm>Kw=Y9d0(k_&N1)sh2U2U_A|bw0se37wFOQ0M;qc zqvdy4zk(hu%kScKZP24-0p(qfsYgrq&gs$8?I?Qp)Qg%kK<}Q~V`YNgJ@v;b0ljw#t6pi zVu+NBjufoBAWE9d7)c!a4@^rFj(VZ_q%R&tR>GhF0e5n2oGVbDoW* z*^UV|7Me=aOviE1%*r$q_bt*KfHfYPOEUq>l-WX>@mR)gDNT2QajP_Mro7Y8PMX`X zJ_h|Z+d8aIK)>ho0M=sAuQwQTE$Aou#x%9-hrGr*4*Kz`+e$h~_A}*GV|Al<|243} zL2pN{!>SJ58=)gNVC=+ zdK~nW=6Pxk#Eh3_N30Y`kmhm9OvUUa&F8S*g5J`cg|!3{rMVyL3rLdY7_2WLS(-m$ z-AG?bk*4W!4Z)&=hA(3(1V47xQRq#>zmVzA5qE?CAydLpGr>Ng^eFaHQb$z@mTkP z9#=+T%>X^F49D6HdbC)EwF~rUaX;4UphpY0cAd6qOuM%Mowfvh^DSWA$%++gbk}+>n-f7Uum@QamKqq4!$2tr8MW%1Deg&PjIfwNP=(No=tc=w*iIaL* z9?*%CFsvS+6DMx%I&osoF%xv+GQ~-;237``vJ+OKjWSLE|4z06EoD^Zs z1f4h;gEb#?;$$J#63~g0hp-laPMq||x&W#2+IM4p26swxE!O9dCQY~YbZNGDfw+VW zY1YQ-0GZMphBXEHNOLIG-OyK>J+ZdJKxsaX^%`VJa~jqb7$i-%_QBFTKzXOYE6sPY zjD43h-^SWcbYx5O2CNP+M4FYbIzo;#M_^5bq0$_Nl?y&;CSq+fwltr>+5#h_IUQ>& zjFhHZd!97oU!=!DzBIkYf&wdZBIYP*W?>D6(bDXOwG~RFxfts;7%R=mSX7ccZ%LeJ_42>B>oijG?+Yzywt=L$4LjB(8O8k^IV=i3W033MAIU=1?G>Xlzk67M8} zA0494W#QGI<$GC{alPrslaoE&s z`mkO&_v*#O41P3p4tgF0mbd%KLJ97@VA;+yQ0IVotRXw!kBApRxAOt46QJ8UqBj`^ z&;i&4t0k0^=NXLE3M@7#AM_!;1b*C+bLc;U)i=n>_a&tdmbW7kwINt_`^ONU1bsW6 z!g?0;?O27i2K4R7#aas%d%K4H*;#=fjhu*{2|+;?Bj_;15n$QKQ&H~+>#yL?M_vR0 zwu9a0$mf8(w(P9o14zPxzKh0e1p3~5OWl8h4i)!IgXMYlr{*lsk133q2m0Yd0ah{S zhYw@1CV_tV&<1NV=!Xw$u-1cq_^=6U3+Q)7XJc&zix)te-^p46{D_J;^dzwUi#mOf z2Z3c|3`Z>h>&O_3JP86Ty04oL9Xdw6Yrc;I4uSjZ&vFG3kj66|;8B3=tmi2H0_dPR ziuD8Nq0v2U9e%fSma(A2uR2ye(BbD^y$-))l=mg*r-a+Fz5*Sn+pvtS19cNtlXRO< z`4h7drhcM#2D34yexm2ruAk_&r@StppXkM4bqD=KuPatJ&`jc}^O#Kom~($l?(p5&ex@pRs}%%r6L-k8jccyDh{|3D|)6X!`y z^Tftvc;dW0GLvI75>k>w`0undZ$?UQPqH^TCBqvN8|z8UsNqC-Vp9^5y&RH~o{-^9 zNcRr#q@|SS{}YnaGkf$%h)wV$XL!5EB*rAidMY?Kdb-ENc{9>tlG9@@m+bA~@mwi4 z*tyBnk)F^q*^}mtNlf#^#Pz4-L{Cq1F4dhno}`$>9w})_oR~RZ3QpiOIX!dcVNP8R zxN>nZ$yW^X|K6m8^rV=K*!UoX)U=eul%AO$Z)^-_l^WCE+cPHJJ^M;dwnozsA;Ea_J}xb$Z%iW1m>SbPAu%C?9(47FdHP*0#S<6q TH1(MFPfN+Ta+Cf)In?S@6AMm3Rp;AS7eRT$@;lBXP+sSPjx!LHcL?Vl3$INf?gUhQ z8*p}5c)bcc&JYNdHD;G`oavyS%L7=8Axze}kCqQZNa5tH5y8yl@uPz3#@<9fYlcM=xqx5Xk3ii^kFt(4 z5|noa=W8e+%?C?6&IZuWW&xSWBUhtn+=w=C@`fhpKxo!ZlU| z#WH&HnX};*DNaQyi$ZN z54X9_3RtzFn5^>yp7>=mK4k2+Eao_EK|RZvI14Pi^EekFMpv0V+i|9VhiPsq`W#cF zVBq@7sV;jF@=7q%uDr+dh!;%l(%g%65%l_CtWUwB($M=Ir!08rk85_D2%dSkV1ptZ`tWR$lBljll`Y7f4GRtsZp~)aFKKZIc%~1#t%GTN{Rz z3;NcEVl4-~zz?}$TBsdnI8JBqFetj9_b^4Qx~(tfKx2p1s&TvO5(1Qri2XCBK2 zScb%0)CFJ_5(g0Po=@EtA@Kq3C#GWA4TrH#fbIsjeH{{|xytgOL*fTob})5F7_$nd z-m<#asRw#n>Wc!s#dGVlh{y%C9A^!92#JT$H<%)2{DIt@VZqFt^wdC3dRC@?L~y*C z{WeqZ09b{`HN=v&ZN|kHn58iFxVUh`w0Jb*>oEUSqM}2q}#rZu&UHoA9RE@#A*XN z!b)Sc1-4TQ5)9SSLV7?F(41fR5TnvG#*LZheRKJLp5yX{xfE2VX2!FVMmFJD1rTQwN{1`hdl#e!RKk90w0W z-~{?92(ujmA0U4U-iE-pl(+^SA85fA>^H%LpM0Q`5a)t^pgpnXfqtMXu{MH!pig6M z0{uXr#Ci(!Y`PRHw582#`X=TX(6i~gSeHQ0rk`W|6ZCAl3+rdlv#Gh8FtAX^Fy>c- zhrzrCeLYwY=I4-K1aE_RA0|kbEQ07QRB9Df`#cpia{Da5m1m(8v@|}+J3xuSr_2Mkn zyKsGfXSXTb+S+k;LlLtl%uXMgsqdq18{QB=k?deF&F&t~wIXE)h4YFG3uF&d_woey z@hlX--nX`U+&Agp_n|~~@SfZtCux6XZpL7JPldR+3J{*1lj^rTgs;Zm01gv?x}6`m zre8si|BtY)f*$|wz3TDbgsW^1di+OV-359wcY924jdxSuG0>CwQ&`7APv&ml>&g5l z>dVJK(v$gTnE6fk$fxNJXT3G9LVXQEZ;jhw#X)h|dSk43C?U-fSP4*4n!~WhLMds^ z###)er8ypJ36zm$AFQQNR+{^;jzT$UZoxVR<)!IPH5H_Jp8DR0Tcqhu#TBLb8}$`o z0*;WTyAV{8W+m#o)gaBPSPh}FG%I6OF-Ws4*5go3nh96|h?HhF)+DGd&B<6(poTQl zu%<#yX{O#VYe};m<}|1+&Ba(tppG<`W37O?(p-wQ3~rO=gIEipo-|F%E1|wL-^4l( z4Wzjb>wRb_O?P|JNSejjkyM1n()^5;BQTptGZrfuZkJ{YtQ2S}O?UUyOqzqJZv-@# z=6tN>&_bFSSSz5VH2qjB!6N_jb9END8fGV4=5Lur+bvrKO4b8UX~{7Zm}Z(Rr1xHN zc*9Hs@}3uAtp~mLnu)am^xn(8QoZ-uLw!d<@4b#=y$gEpwFT=O=)KoPtZ%_$t8(pj zcJd}KW%rV^2x{@XG?o*hcQ@y%@$L|K0hAgTrS{d|Vg6`ro`ih7w?#5JfgT9PydCu8 zt%TJSEOukbOL&88t5^;6YE>ho$xf)6|mT7ZeL1* z4lFz2H0n8{+jK(HWlU_KJE0O*UC^BnffWb36N+HPgT)>?vIEV7hg{HY=uIKC(CA=l zFnx?Z(#BwSgCaRu{<8i}*3<-oAkKHR#^{7VCS^y}cdl2e3GY z{Lz_#*~L?DmqL$#P}>*sHIVB;{v7kssG7BWm|elDpJyP>1>Mh+u@-{v=S5h{LHBbO z)(WsV#r1E?eg!;?>XGQV5NeyQpNxDTco@_R(N{r8i5ssxZ8s*DDRdQ>+U5LPvK{#& z&=2W%YPw(@63S|Uy0%?JqfSM7Y7LT1&aZjJCi*RcvzzELtkKu z*zSs#BR^sautanG@TX>_$)&U6edNf&=EJ@d)cuaBUoM?junJMD?(9>TMKE<|AHqBi zdg-i9eKDYyPWSHh(z%oR_JdwJH)0(Cy>!mUdKmQ588ORoe4v-k8CVa1UOJPo)_`6* zzu+1-V(O*SSWkk*yu4vD-30cBzJu7uprFYvTYUa|3imvORzUWT&dRy|;V|jMz~JhtU>to4v@PrI>x1RYP6>GztTJK`e+%cl# zX&Lpc1-%s=hcyTEx$;A-0@G}^qFu34KyO8Ju_l7vik8Ki2YM^|4A;37Q*T9$wG1rw zcq<1v&hy}58GZqM4_JSGcNqC~C}8(_?^)Cj!1|DU3Hci^16|HBsR73s4tkF1g4GA~ z9J35-E9g1q4Xl%(=a_G>iVn7!V-z1081z zco=J2(RYINSUZS(3@pdmDb)ACdaPYQz6@4lZIIt_hJqezKCGUg$J!FCEnqR$uug)- zSi>qh$ZD)%RR=xRwozw8Og+}JF&kl8j5VyrKw3*}JL;|EkK%#7f9kMc>Ikd7N^=Ud zH-+e3*+M#EHt2`j2g?uo;TkgsEWS`$H^m~3IF2b_z((gjzrDyT7&MD zYFKSR_ln!T#gM1I_dyT&XRtm1y@lI^Wo$jG!4k<;gYGbkInFQ+tbrXM||1c+lzUT39VXpAjCy+5`HGP@o_6fj%P~ zr@m^K`i#&AvmT~SR}a7%20C5c5i1FFx_SoIdeG_WY^)7n@qz7*s*dv}nExym@N(7o z))90p|4yY%G4)c_7ON9DRpkUxb}orV@UR=MiQdo@vHB5>mYA)LZSx} z_v6hs6-#q8)&rnB&TU^$f)7*QTF{fATc@7d&Qae7pf{`guwDhdS#?`?s>yEp<$fxh z<7p@qMlWrOSPg|rm{q|%33)X+h~rGv(oDh{Z>o)y>W-D1%fNoSdK~+0Q-Y;QR(}QY zXVBODEmo0LHbe588>SwT#i{RB&_gmDs~G5Y*|cuzwD`2YWOZf|upA6EQR^DrW|HiO z=m*`g(O9vdW8Ij8z~XNa8n0m81tu|zuU-={6OC;%%%>sF1bt^yv6h%>Yszt0r#{C{ z;K$Sc_Q|)}fwrSW7bxxhCq4R6ECWJH{;fT$!*0F?Y!iULOOUs`VI89H@XoMALy?%ZpBIf{guX2tj9oS&$6)Ag8oCfD_FmQ{zJLL zSl2-Rpgx>Er5V5qLJeugVhsVkfHcQy1GQwG zP56WbZj)vetbR~Wnp?1TL49e?z}gKBq&bVbIfB_x zn)hIigGSPPjrxv)#X~B8nEe3QZ+n|#w=pG{O68T@i#Q$hx;zYP2IzG;1*;$EbvYT! z*m_;=j`hV6n{DqJ%*R2W+450eIOsFmS?Vi_sdoj#vF-uAE4UMDH0WKy5v(^r?+R97 zy$O0(u%0{m08{S@mSC<1y(=*0ht#Qe1@6<-YrT2qUxLLX6`REp4j$4WiRk^n`sH8- zat`Dl6&N3sUxLlXoDY_-5+6lf4_4>Z!lT$!fezf#SQS7AZbhuBpaVA&t0w5c{frx` zg{jZ0#;Oe#t4tu3#{eE4buRj3$QNdD3|xq~80;SNHq4j7@-ZJneG9DL7=MKPIfN9* z`v_6~u1$+H764$vkn?{Q-e}OnCs@&jNO9FJkH z2g~5tj=C4DgX0b4(_kAMHPYE~f=zJ5?q#m>JAY&$j)s z);}m#ycR_n3vy1afLO)I`oL1W5^EkXeC>WBtPXNRxalu&lWt|KfR`_D$J5|UbCuQf z&9B0H40O!Q###$HX5995%)CZ@?|_b(7qCu(j+y7NjICp46IK!WR*%}RFbkQdAP3WF z%)*#@OYgR>xAYHC-(t{P`V6ckpttnyxYCKf6V!JR^ydE(R(NHbMBh5hqL@0-*BYw_ z=tN%xRwC#`-!QC9(22fLSkpnL?*?HF1)aXzg7p&U^xYz?mqDlRe!?QpW|6)-gZVk= z^j&A_%LJXi+l6%)boy>8)>)_~I4>wMX`W)k$*^;!0Dyyvr$At3c1_N3h-kJ)=K~bqMr~{v%e!S8Zl= zV?}^P_Al)qKaU0;p2lSK*`|o?(^!bS987n}K7J4J0_dl)8|xzIr(vv5!6L``#RL|v zdr_@krxwO6YHXV~@EM4sK;M}$r-B|miCC$iN6!kZ-Jtgad$IO|-Ve;fIsg_K;ZORr zHwC+X{R1;(fMvf9MH~*gUyV5dbia1P8UVUqmtk!O-LE^b_JHo!Iaqta;wS0aPT~j$ z_J0%C6MF#I{!QFa+)UE~ogt(5AmTC5&*B8uJD{WYajcV|pPI2wfyEE>eUDaZvX_1< zja?CJ`>h6UJ=20szfDA(3A*2AVLbr4-~3n$K=+%m9t4Y@D;${3{dKLTTR0o}0? zSoJ|qBkq;zX=E++Z3jJ#EW+9WI>oUEYai$o$4;!>pi>-kv3>=8Tsw#LGw9>meym?W zAJ^R0^>M99E?Za7$F(r52+-eU7_%Yh-xB6tj=KZOQGS5xKObC+^rI7RiiVa z@U?_b?^65Lx|5#B9)aXUrL<+UBy- zW)Co5fc+XBi`^Xx1TzDJN6KlgA8G(Xtv+>Kh`Gd6o|=_8Bz>s*^zJ*n8zVo1G+gGp-gPv`7W360ZGuwWRSshc)p_Q>BLC>LAsWTi? zC*0hpq!Vr(sIL>~gj*A=mY`>FW3~f5gB#Pdu4iy#bp}0yXJF-kp225f%?CY$kHLBX z^b8)v8VPy^H{)m(Sp3@Zu=&g`U_WKd#GVJ1Q^r!%)usWP-RXJ6i=e~$64qCs!}>7R z*Pz4NSl@ufPfu@;B(A~klz9a6n6YhEhVK!70^JA3ylSewL(Z4^o+AYbPX1y!<1+n2 z1KIvjqto@iwl-y&K`B!zBQP$nWG??in0$90MX5w6W7^6q!Dc!mz&|gRDOZ93<#M2~ z`KL~-u5&u}JSg>734eBKV5CJ`t10yidOJW-Epx-jNb?SFV1(}g<1^w>Gt+Se(LpE@YyC71Ub!oW`RF`HutVF0G z%{o{~;Ixuz=?7^VJiLRbf!@Fru{!azz`WDgmLDOU$NdBd1bOib@s^mnrJ0L$FX)*% z2g}%crXGd0dZEosy$|ys=$ZN{tV5t@>h)L;(Yl_0GqI+Fo_~8|%>X_BCf+dh{QCpf z`7`MG_fxE2K+nJK7}4`@Ev~Zx==rw@RzuM9uX*Ncz`0WnyDHC+hXxPPRUf@M6tI26 z*9kceikSVV-M?u#2z@w|xn9K6zqvPwatp!Rruk7yJOkc0&ATXd0&Zs0{2t}L0W+fI zvugb;f6oPaGKt2D13j4}U=0R6nWSN5gWmS#Voe722_EqjBfA{P}R`u!Oa9zJIZy3swNo! z_n+8u*bAm-1cu5)q@Ow_gSWt3LW#BDJutUWYCqgeV7^7U3t$zPZMQj2H0Z$Wfz=Om zV5VbD1Ra=jv7Q1Qm@i`;0v(udV_g6pnBQULd)_86^J5hN9he1;1v)Ux(t2S`r;QBE zUE9g$fQP_5j(!pf+Xm((FCd`1h>Q z^&k7RNj%-R({Ub!TmM59R{5vLs9-nTT=r_hKE4qEr;FakB-2Vi(6ePDtp1>9%S%{4 zfSxTwc9CrWJzG}8Y6g0?jKb;)dbaG1l@59v^9pw}98=Gh?vvBAr8`jc>1houZvcII znuE0w^yz66))COBrzf$V27P+U!794j=1lYzW(cOvNu9zB#nd?|w{@M9sziN_K#!2Gq-j9-SuwjI}Fw2reiJEHi(p_yAD*BW_cEw+n|Ot8(=krn$oO?RUc|e z^C#{m470YCSq8I?m1(ZCt~6(3Eroj0G|TZasBdMOg}Z??pTRl-4W+pn%hcIOnyavk z-B_CL219>Rau4;jW;Jdh>nwrQ2wFAWbvk#(~pTszX-uSM=cFWSxyZ5v+5_3y_zBhm-Y_ z=-c3CPS&qd?kxPbC+p9sqre)kC+k}&aT|C)S+}B8ESTJhd~WLyp8|aldl_p#=!4js zSf7ACh+V-d@vzN7tTI+T&gFc82!5RwsAU1(J8jb1b73KR!>GsDw zg-j@VI25u?MpZ_x2_8b`4)iFvnUG1Q+)(&$LuL$hECp}Ls7;jE4&FoN2&K+~eM0Fo z>?@`%&)+RMYbga`70hQ@|DLX~_{J!41Nj4}_dcy?lyU1u{}e2-ZgQ_mLfVwS8`m|XAt0L%4_LsCi8dE1ux?l|foj7TXH57E>#BE(CPNq`da?pvBRamP* zCr(yitpuGonTS>AX`95!tC(j&Cr%DweGEErauMq?=)}nmVkSz{Z9PevQ>kw*Bug^`YaXOXa|hPj&{LW(VQq(A(p-sE>?vN_O7m;X zaLoSFJc(HpbAUA6)(1+n8uc{;zcj028GDd4D`8b8Is(!hfjJKbOLHLBd`Ok%Zmf48 zO`1Efc0o{@k6;z&j?$(14Q5fy;nF;XSqyW8G~L!mN^=$UJqsDq+={giGOf%vF-J-B zIjk*kk2Duy72Cuo+0y(HGaPe_H2;BF6mzUJ-PXrRvnus9h4IpCi4_AAtjuK0iPCI_ z)dD6-vjWy4m?F(Atc5UDnmw@|f@#upTc0jXbB&9^;;qo@UHRn^@Q@%sjs78o+GhJc zNB$Npe`)k8DvK`v<i)_AaZsa9b*V;mf--)Cxu z+0xituDssCh(XYO5Wvbc)pn4TPK;$-f`@^z2z@n#791QH8OThPU)?@|ya_A^#$nVG zU^OuEF^a-LcgmksSqf7Rj51giK@W^?sWSr8VuSx>B26cG>gX`^qG0t?HdPQK!LpNE zp|%IBPTq$2BIr(j8EX&dPTq%g0CXo$!#W5SXQTEh>}kNmXih`VfUvOCz$leho`N_X zEIWB6>Z4%&W6B$mH$#YRXk9}N>q*}f)$>OKyvCrPqA~9R{cH+gRREppcCS>wLc53h zazMXAGv-XtsqR@=^FgP&7ho*|o$Bt2wH$P+`vBHa(5dbdSZ{;=LUAqDJ7AFq@WpX* z0uNEqA3X@x|1d))axPd###Gcz9?ke5NImwy-d6AF9{?wcmd^{Qe#`3NBKEZ5I4 zydt23>IxSUj;W_c_p){Pb*H|5pu?{oRvXaa=ia>zzaOaY576(VPGS8CI#5qy8CwVH z39P6Dn^38Mbr4Cq z74&Dn4Y1O{DPJ%ys<%I-W%F`Q@u--XL|;;pznd?qo`TP136AJMEW8;%jI(3STj`hVS`#VN;i;9o-6>=hc9iw9W$%#?%Nl|$< z`#br3*Xzyi+-llLitQZlOY}!|OY}v>^r7Z%zRu=aN;{Q(aZ%kmB_zgiVdi?NIF`%g z^30VNajH<@`prefUpLJE_s7L1#YH7YcL_u2o|w=rp>vAQA05S2b&u-f?;MrnUVTxg z+FvzvPwCh#Haf3-Y&DxsW&ZZRdD>i=phHoj+6w^(lc#$~yWwAkOJ|J1vs zoLbx^&m}tV+2-AsTYwo=Ooq$l`c@=zntR)!O`7=ANDNkN zB&Kdc3`|l(87vlIFqs%lV(}w7u>5+-ck1VPukSsT!ueaHRGr_+jMw)QgJZRP_F}5v zh^#(7FT8k}(W|6L6B+XNF|4es%QLRV4;6C8o-J~W#9;Co>K>W=(90f?JM{g8IFI&< z3?YO5+c~HuWKvm!s-qB<)nD1h>)&zxcnX&?Ek`RqrvmoT($Ia#UUs#USITj7xj<>n z=0-3xjm-4FK}Y$;pv=Y_7=8G8t@4##(T?kRYbC$P=8BlvLekB*whecN_|{sd@~yq% zybshtxAp|}iTHk7-y%%U9LB9DP=v|>s7Yi|8H2J>l*%yFE{aiEfLceLR4S+q6sK|) jY7up{B{v}xR31T{pd^*2P)%f0c>r~YQdHhR-6D}MqVUd2 literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/source_maps/EasyGasOracle.mvsm b/build/StarcoinFramework/source_maps/EasyGasOracle.mvsm index 0bcc1849f84bee50a0606009d8a115232e6d7fd2..8de0452decee222fe62f388b2e146f7689bcfca8 100644 GIT binary patch literal 4946 zcmb7`+iO%;6o>arG82=SCb6Za)+ClR#?)GxD&|EZRD!*E!$48c<6-6~L*kj~oSD)I z2o(j5`l#j~sJ7N(E7nR7L`FnPDWz5MhCX;NeP~Njd@1zXm;-(L?K$wheS7WOI(x10 z!s$P%t>Xq3^v^O0hF30)6!P|l}>fr6fIRFW{m#^5zcaUft$&Uu%NTm>{ zO--R!?GPo#u^aS}R#V3O3N}7gESSnW3xNhcn3tFF#DUktQF5H?|<4&=Q zs@=&veZ3d)Zh$`hIBHU6?%%{~XWezu9KafadTGXIk&@;i;vIpsH0>Q8g$8MUgLM{W zNb@+>C1{l9*VAT`G{3|=2F=opvvQ_19~18xv`F(OtR&g{f;4Af&9-?i%?2#{_q0hf zJ#Ds2vko%_v!ofH(rhQw{<$5}9K>1)uSjzt)_X8Vnyaxk!K>0-g=N<{SDGJ9o1M~p zAM-=#lBPXRJA02bcVgx-`=mLF6~Y2(#xeV)Ss~tDc*Ds&h)MlYkL?hJZf$M#aUJ@` z=k<|dttKdA9=EoBPI*U78`Mzs+R^7gG93kBHYlpq^x*bGQ!dPvyifhHvg}Hhpbvq4 z=H+g8;Y@(8NBgl3fxe=(ScgF$ptUB!p&*^0wfVs|a_;Tf8T9kude%SU{sN7KVvxy2 zxqPT@=O*?&NVIMX!XU~;o}bC&%V9|k9Ii8F1gLQGihA)Dg1(|fSW7`)(LXGD5K~{# z$5^{Tw+!)~bjxs!c#lB045zRjgKinD^*b0n{Ukl@x3;fMHF$1+;S~0HXq~=Z&(CIy zK@_QLzRZ}r(7ZjLEsq6W=x>+5?-P9XYnr1{v79M6jd>aWH9IEjmwYeEmx~!W&mjK0 zkgT;$zQ~{}P;1VA#+W@|UeY#4ZyeKQe1FVPOkW442uHQoqW%D%pIdCnTmvDcE nlv8(d9rHFgbtfJ4VO^k~fq7WHpr3(1nS4H`eg>@72gdvddB&w| literal 4946 zcmb7{TWAzl9EZj=b9ZTi1Ip8Dn}O0ssFc8VB8A zV#p1K%WkgdC5<^LD&4as@Jy{TJFwQrsJI2^%@|$|$B*Gn;(Q1Rxt7mZ%N!(9+e>>r zfBVEfPc7;!`b9fLiBatay`>lGjJXa~Oyhg>1z0=_HJ2CajTr>JBg0sSAcoqKGNuoz znDqwq0Wh^SYgYHFS-+7s<~HE=#c_Kw#$-p`zzOYPI-VbvC)BuKnay3uE{+N50H@%; zT~gyJjG446>CngfF5U^yyB}3e%Fdmm-gT&v<~=OKF4jsj+KW1A?xfx*)JxNz;T~v^ zrjKwQQ`v$$lYrCGq-3mIufUAbJEpHlA(G)i+C>jE@M^D@>=$Vzh_%f3A; zr1|ZV`IIy-VqSu$r5Wwgv$0J3=B|?F1D>41d`_DGV5TvfrMUvD9a^NB#j^8km1fhD z`MfkUn2pdTO}n4=>8qu=6|)z!Q=03rUV$!YMm4*oxrutO!`fKp4otFy`q*yfqT5#8 z{WyaD*5duhWvw1Cj(N)3`g5ABrTw9bTW=+LDnP|W+Jr0UbY%Df>u=DJ!CH5~=*OQU)Ba#{ZC!&C?=8HA{Rd>1 zj@NPX`LY)T>X;ueW*MPBGgiu1ik{=UWAgQF!GGC~3BqzE7seVhfIno%NcN zlh4_WzXy`l#^gH;dI;6_{0w7Gfq6#v{4CxA=$?Yi`pU26s1^KDq&pnJXtYa{5U z>&My(y5}FW?mg1X5_C*1U`>IJ$s<_1K*!`^tQ(+X@@cGj&@uUQtjnNd z^2b;+pkuN%uYiupe_`DR9g`norTE*WWAZPUf5J+6Bc!R9v47=sGtF|lehF1vn_r=S v197j-dEBc|7b~6oh8R&pg#lu^6)N9{TZ-UHyHB-{jAE0 diff --git a/build/StarcoinFramework/source_maps/EasyGasOracleScript.mvsm b/build/StarcoinFramework/source_maps/EasyGasOracleScript.mvsm index 018e56b33a30b94dba48424c12ec2532d74367c4..f830934aa4f499af0f2fbf4e1949be132a110363 100644 GIT binary patch literal 1082 zcmb7?Jxjw-6hLqK1r^gp(JqP~gKI%>5_E}<9ooT33Gs>1n1-Y&v>+}nogG{SMd_eU z3I!(zXIB>oaq}-Ycse@WG;p@_-sPT`Ui9?ynx5AC)wRK;y}WvU;0)L2ty1vu+4%OV zwcAONAz1SNv!)z3>2AA8J$AjoG`!f4+L9OPDHmSYBG+J*o2_FLHoKA0j@+Q%L#~vV zaNoq5|BU+r6MpEo_d0Hnsw3Xe-$A6HuV7b1romE|oxxgwoN9hCd=WFRnj>ooGK~M_ z;R;+lM(ZMa1+uoD#hrt46dTV^{8p&F&I)!7M!TxZdWc7$rw*`E&{J<>bs&SfL1zcX o2)Kn_hpYj2aCf1Y=|4ThJb_H{t`P4)k2k=206pFr)+31g0ny29lmGw# literal 1082 zcmb7?J4*vW6h`mnA;ec>Aq2$2LXlKTEG-1Fv`G4}Y}T;4*(|#;A(Bco*aU)=l@JSm zg{78Sh>t2hu&}ik#IvQ<9S2T#W-i}%XE^^9t(+fUu739hyX}0p-#&X8o!%dA9F>as zkEN5^gvbF{^7mLXn|9pUvg7T@c6_(wL|)jGw8&6-urw*+fR!sZ_S~S{30>_<6}=9r zvDgi&Zlw7w+%AlJf!D0GY=2)J(L*1ANJfuvi}(PR8uk(E6;i5sf%OJy)l95+Fc^Qu z;;xhBnRk7Ieg~#qKjV%d7e=n*#a<)Ow)2Vo1xZ#l>;gfTL9e=iRRq0i!CC_Y^#?68 p^{)c6=+j_Y;4JPOWR3pmB4z=M%BvvmfL>k=%Ll!@b*wsw`~q3+tU3Sy diff --git a/build/StarcoinFramework/source_maps/GenesisSignerCapability.mvsm b/build/StarcoinFramework/source_maps/GenesisSignerCapability.mvsm index ac7d5129aa86a003497fbb2d08fc8c243b4e63ab..6b3a1d46dec5bae7ef9f83744b3921dee2b38c60 100644 GIT binary patch literal 1176 zcma*lze>YU6oB!Qq;~L6Yq20Wh>NI$gQJTep`;y5hExziN-IGkQcB|@7AK)ls0w`u z(M4T#Qe4`}$u|%xw4&kz_*D?xj+cDfk8{c4c5>;71$WwcZNJ<)t)toVcCTA+HR^K@ zUyGlQwTmecSt5h}9%Ir8%0U!Hez;Q(s&=tbEQNdF{sFL~%zVc52LlaFiYa0dpGL1N zk$W1Pn9k=hSu)hY1}Z_ODkIb(S*r9=HTuW(EBt$w#EeHjtJW5g1AAm`7b}|G#BB|R zOHyCiCGeW`l^vsQNMBhO)gygnPpCe{)a8DlQoMvARlXtLDXz*p)CMz$Rk@5>qY+ik zpj;YNg%YZ4pqi9aWfgTo>oq%*FUFE|-D0lX+-Rpo;X5*C+Y!DN>PG@N;VEW;5V>bw={ZZc+CnpX>_Np{RJ=N7M%mh_Z`%pqMDnQ5GM;peV;tvos{i zFE;0p!=n6s`-muQ_OcWgWd&6uQER<4i%N+`|P%UCijMgerl}4kDMr{@}@u8b349mo2cikO8ZHZ}s zRITWPZ86fm;4SKdiK*4p7Zq)+CNm z4tdfX$C`wEX-;813s*>U4(n4Wkfy;p4q<6lRvS|Xh0?6YS_?(e{GE}TF;_|Reylzy zmgZ)x2Vu1|U93R}@H#t)UJnG0)mG%YZ39!PW3?A?8g#52tmi<->TRrdLC5M4)=|*0 zx`?#`I#xem*$t&*)r{2+I##7v8$icu1*>39kXYS``4s3_RncD~=vd9s-x(;80la|K zMxSe>X{~k$@Z#Sja34e9sLmswunkCnoJe_@F*Ts0T8C8+I;!Uwya7{3)mn`ZKs zvT9zygTO;hL3zSS#z&mE8yj^qSud4TC&&{tdd7}K8I$X`jQA($^(!r>HiBNii}crm zsn_ot%vMaj)#tHJfZpm8Sf7L5>TMOqbb#LKm+0?mOuf~u)d>L}=@YaCs|LLqoJC%O zP=3FYRw<~gG^QFTB{Brp^@NYd7c+oWwc> zIs`|tPJ<4?dD|a%IDL(%!K$^lJ^e_t?B-)&1S@<$LVObrgY8FxTMW&wH0 zj=*85+z7F103DeotZvYe`H8W&VCu-^W~w9O)88)8>pPA$2|6IJ%okW+fsV`^ z*4LmTbIw}4p;GydtW|6;KKhZm$zasxFla66MSj>e;BCo?Oe5|G9hMB%0nlNw)iQDiKM+p4880Pk z#{}xrP@MIhj34v8VONbXhQ0?1{##^a4`B{N$>pqQl(mV0>ChqFjCUL8kXB&b4mzac zSW}=Y+Fq;~&=qYb){CGkTJGuf_WzasYFJ!d(cZ(X#ncromrY&K?xMf#pg($|SiPV> zdTzk#1O3r6jr9)bkDgq{b>+=PyG)kG+?FhtW^MyiNOO^=IS-Z6{1EE`M5Gy_F4aSo zG;@WcTAB&^8;2TcK8ZC6wbGoz+6Q&gwEbDTUYgTbFF=DdXRuy^Mrj_#dL5diIg51& z)=G0f)&XdiW)IdI&?3#;nba!H>LTU{>!jI&)d}mRxy&4|!EBS}DXax(m*yhYGHj6M zA6QM?Nw1V+CC%gX*^0SQn$}te0ZQ#Q{)yRP|BVTHdy65vwgG3DoX9NV9O#2_ zH`dFxTV3-%Lpy8Lpi^E%{?Rtzh?G;lj(>1&0zKs}tXn{z<$p7HH>N(zt+fRL9B2>l jIqzQ1e*lBX3ELpZz56iYE1;KQ66;ma%V4e7z?gplvl0f5 literal 6351 zcmb7|U2IfE7=~wC+HFgr3oWIE7K?y@QCn|JlxR}Lh`|`KDy&4e$KBKAXuG@Y9$0!) zL{TqH6fw~ou}b_&Fi|jwrLjeYn3&j@*dRvmLQyY>f0X|ggU^_3;@vxL^4vW$XU@z! z-^|(3@y_)veb>fceDvY5kGr>zY`-fQ-r8~Vf#usiyW!_cv9>kF7#||=-(RGmD@^qU zk3E=6=e?BQmCOgZuwbSeGb(!AQE$v1Fp<>15A_V0M?sOA?qa=&Wolg( z_7r9WQ!ngstRJCTMqnXU3TmYJ7uE%sF3ka~15hi?BUo2phBU2(=Cbh561dmFIjV!m zZ`%eWKn~c?zT$=uK2N+n70^LvWTJ z8!>eVO3&9JxQG7k2OWY3u-1YO!7{9MphK_+YcJ@7d?(gE&>=XCbrN*FpTIf;4zEgxsU$Vf{sias~dD=mSTCJBl9lS`=BE;fb{|B$c$k90yE{zTkBVFc%>#TzU}tj z?^=sGkZ-aLSS>k_05JzTEcaq<1RWM@<-uVU2DwM<2U8aHlF96*OsLZR5%wn#3$vlu zn<#|IgxBZN@CzD!3sv>KLB{v;iDD3LNaej^!l7hGqsGjG>b@WoCZ6#73u>ItRT#4a zDs2nB!Bb>6rTH4x5vZ5u4_N1*L7Jt)F-MxKsC98@l;(P@ZkQ`g4=W8#(zN|q zyIGn6Ru<+-vw*c3=1a35>uG3_W)W)(v`RCFwGkFbvlZ(ZxJsI(GpS9Qr|It!ER^OH zR{XWmqOnYyAxlrFIGb z#N1;4jd8ubtw8Ry4LHN(K#GV1pby4%SX*tky5_%ycF?M>Lmo!{)HdLVltZ4ue=-fA zhunxY7xY>F9S?89)MvT1n!({fyN>VaPWzSaIt{lYud)qX?%n-}PlBF?Zmeyfr@>lJ HfieF8Z?k0h diff --git a/build/StarcoinFramework/source_maps/TransactionManager.mvsm b/build/StarcoinFramework/source_maps/TransactionManager.mvsm index e0537422c1c17a2f67caefe77bb5b2feb95b0d0c..60380e6ceb8920785bc626c666f8f7fdc741e086 100644 GIT binary patch literal 19414 zcmbuGd303e8HaCx5LO|82q7r42#D;Wq9{xzH_5p%8=v3^7Dig#|jZRM};e5&T_`ybx>)lK7v-1FSkFRn5S<95h^6aUNT z7OjgV>tpd$Wlgd;mW<6$)ER9JW4M?vZ;)Yxz-XTpi^ppkk|{M}I(7^?*2d}*$&|Gq zR=+@vsmE`G_NmJ1M13k&U8_c{#l8*N#u`!!YU-4}1@%wR$=0n!iA$};iMSf{Bm-Wt z*Jwz_s}l7}{|NPwU>~(K zN3r%r&{~>#Sd*cRG$&$tAXAz{u$DrWG!s~tLpy2uv3>>ZrRl8RL7In{??2E{nvY|B z4V|Rv-1*MZEFNMQC2*27OR?ra7io^fia}RtuEW{@+0xvCwFA0I^GU4dp}RES!rBi# zr1>wbBXF`b+wlGD06nF-$es`L6lqSvDuQ0poQxHM-qH+X&43(f&ccdAA897AQjjan zv#=VVuQZ)K?^J2NzwP{1&UtnT9b? zn)hL5Vh)m~ZM6j#8-1d;VN^p#`)JLgL^675t$gAn(Jz4xZfla2$gAxE_9Lx6k*v^< z=R482K=(f%0Y{sx`xvG!xSwyrWR&uSkdK80+1RCR1g)5wNoWlB~a z-!kf?9FDcAB(O(Vb%|=Kipu1C^+fK=xKYs6UbQxMX;n?E!b-Wg2@@Fuy z=!)iHtfxR%G|ynY1iGU6n%n*|ri+_Yo@*Etkj8G5Ku-j-!y?uGYCPPk%^%R~yQx^PwfX znvZcaA?;ml5rZy=U$U#MWc(&*$*%S&<6Z!_yIQ+bDV3p3>p=rXt2?+7al&crK!XO1 zaqFH`ACFb>9I@unJJ3P9h9#Cl`}$Pe-D59-odl{MxiuBzm4M!s2V+eGy)Cc8x(oES zd;^wk>uuS&(0W_m&V2hoZ_E3!x^naMw(P8~x6l#HHxl#~Itptv=uqgau49?=S<$h~ z`HbjTmgE>0gN|iaW32)m%hqE(2s)PS#M%owmi-g!DCk(0*^l`^$FhM~=Yo!9CRPA+ zESrh75Ogdn;A~QuI+k6DbtC9lwhrq7(6Q{dSib`u%Nnuj*=uwxJBs-|=vbD`e0@O2 zvf)^hK*zE$RypWcwu@t2fT?4dbM7uSyBS&JaY&;Osz9#>*M-m($SWX?Lg@GCcS1`F zp>2$N27YNFw1+v4KzfBxr*?cZA^k#V2&2YB(>W)W)K=Ct7jJg6Ts_8%7&il4cbOL= z*FoBq(=rCFhMbni!3_+51X@x!y~wzI;HnUMse@r$)zMuc>627$r?-_0iIt!+ftU=kFUG2ev!yu`D=XVD#!2&i%tLUFG>>5QJc;Nf%`Y$y!+Fwt2kSfL952lk zSgYWCY1U)?1}>0hA=YY`Ak8zeK7)&-`54waFj1O!VeN%U(sWk$NVBL5Z!95Cnsc$L zz$?v0tTm7?&5c+)!IWkvtldx`P1||_3Z=OZ>vJfQ=3%T(T@Ax0%|n=9!enW_i)DY~ zrbu%oE3W~+G#6vt2*uJIhqW03(#*yB213$&8S4|6D$N~O2O%s?XZ46Q?Q7W%Tom8Q z^XbJx8WFw`{aSGSYpLF-P_V=|=d$j5r(8kMLeb zMWH3{GUAL|4DOTUHQ1{l`&bj+`k{-j+65aJ^&n)rd7ZFrBE|S5!ifFanIDQ-F5lcf ze4$}H0XeDTKS^vJUv2-u(Bi1oah^JXrzqt9%oHj6rvz$}@k~$xC;xa7SEF}x=KFxX zT7GE{a!J1g9oL`6It)6lU%`=I4?3>jf^{G0xc+CX-JsuFyp44Lbg=&%s}*-!2m5l& z)|fijJ9kb8d*_3qgZ(&Go(MYF_s5z9I@sr9%>n%bIS-Z>bPJ#})@IPb{u-=XKnMFI z)~%p}y|cOw_D?e30nowT*$;HEKg4{Q7r6=cpJUp#e!p@MD}$X(zh9Ze%0bZ0g0Wa3 z(9MFYu{MBi7A(iQ3iSJx*;q$FzcqOl>m$$&h(BU|47vf~tgagney;j7&<%)Etc9Q( z5R0&?KsO-l`D|M^AVy+UgKj{)iuEq&288|Wd=GR3!g=l*MldLZa^Hsw4dC% z0kI#`wsix-IZoXIc!>F~V|CpE$j1tRZUI>LoE0e3Fn+4Bfz74uruovrd(9ME7unvK47EH|JGY`615W-prx>?W*YZ2&X z!BVV^pqmBG_0-LR518*T=w`t)SVurN3+&H(S8!3Pb{oMfd`Ke(_eUQF?cDyP??U8! zNFxT9qQ{^mF*wDzYvGs1;C0Ng4bpp){X8Syg!E(ZM~wOk+(+50k=$oUKg#xF)M#j( zZaf`(E?<2(#r_TUkE5ZBY&!33+Ah%he~ot)EgKnq6BzS!w5;J27lV$LKCDYXN6S~S z-US^kpT&9)bhLaNtIsGmf$`s%y)kuQ`~WitQwK(8bsZR&Gv9Tf17kJT^`HY|6_#!5 zz*vFx4ColR3F|4)Z-Q50Jq105L0VYT7&=^_SV9tIr)AH_NX zItDtc>lnC|V|*NR415CXRnRf;HLTY`$G|;UAHZ-K2liuq0s4*gtyo`zeq-%CIrSTB z=P9k@YWHzmOVDw31lBmvadjBhaL{q}JI;FrrVgPqu`UB0LcLg*gASq2>Np{>VbPLw~phM_ttg7?egwVGzKLH&=-^4l$I)r|O^*v0IpZOzLM?r_s$FR!I zaT6_vVEI5t%WSO4prfU;x{j7>nQsH=Xt^Bg51^yv3t0aE9W9^3+6_8d-j8)URlQ%{ zqYSLmK)+r7m^u4l>bJ|z>Or}>$$W9p@1dQXGF8sGnE6&hSegx3wjGh?#aMIs#zm$1 zIOfYxBF(K>ufQ~EX0UQED3#`S%*RG&lu7ddW(0G(G{<61g&ES!!3x7nX*#RVlIHu& zcL-)nv&(pDPq3tUg!ytX=ScGl%)=0q<{qpv=8Q{o9M&|bkY+AcDI}!ntUgbg3z=^z z%$MdZSesyhG?!y-hDvERVl9J((wvKR0IH<o+lojSr+nz&HQf0sZ5w3HX{+s z6KI~n9%mK%BE_Dlw}>}_$0zW5xPn|7tI!j1u5<^Z-?14&C3$|Iw`sgD;0*>MzDShg z$v`=F5Ztd|3De{U%}CRUnq^q+jDA14xIbJB=g#*wPCq_N#GG1Uav!ZgNpT(*CK?P{ zc|LxFD4c*<+C@1*e|}e^|M9hafoUGUk8AV8k=s|rLyqs!#%%$=iAnqo$D5C@98zh z3_>1U|1WQRENv$usBD%q}n`MRq*i(V5JuiYKu5LTSoQ zJISooYG+zi%?tR)pd_1UcQRSKJ*6tnV4s6RyEEI`kyiS7)OX=VSGP7f-PV_#xGFN$ z6hL8TGT!E7ls*%+#?_OZ?He6=NQ+QE2gUJLJCU>!&1(HHaty|Ncwt-YjMbTOWZgz; zHbZ`4+WCr|mi`xNjA@3VY**5Hz;V=ZU7TagWpFQ-a^Jxjf;?%yjCBF>rMZc{yJ3_x zw_)vo0%>l+`YPNY%{bOeP$bPktQVnJnvY-|g%W9cyN{OUZF7zJ6qHKyzwEpa^G0cU z-+Y-gce36dD3|8rSl@v$()<$EUKlIQ*Rg&FmrPorr{S-2o=(tfHe&!Nb^># zdGHBoF2xGLL}@#V1_iuV^u0;xUw^u$jan#2UW|UVmK1G z6;|45CsibpE$WFJrEVjPb$3nK-EAFqvz7JnC2XeXYcRzczC!VIB9*l|(yS5RM7s2q z`@TW_b1;07y+XUWIqhWRNuQwZw@{SnjK_WW<&$Zw;6B*o{ac5)3Up3cjkOMRPT7Ff z20EuCv9^KEDLq(^fzBztSo@$*p8I~RAA?RbFJk=ybfS3`>rbE)&7ZL@flf64#>$)G zC(+!7nUCq?OWK9@B;?SI`q2lW)NeQX5%Mv}p&R`Q{Va^68x2wSADH3(PTl#3sVot< z-9d185=y0=L_5D&)hR|#HKrDF>uO7>2t)2&?S87-U?g2_D|Nk)b65K=MbE>>>1xNR ze-lR1)&54^2jI7>EuO}M779jH&zh&c!Q+U@>2#p#S@Zq6<(atM#&g7afOiLa(B97$ zhoB^rjr)7-^lXS&*0Vtmg&VQrpoc=@PyRYYysZRTSw20fOAvF-ysmbGGS1wEGS#_9t-mR;tI zp25^(nRo6!n%#~!DvAW?-X?nZQljh^B_cY9x=CfEog}bEr4AucyAkAK^ zPmkp}C>+;N`*!qao5ZDlo^53xy4I!&3*jV2XD>RiK`J^EbToqUmy1`7nw%Y1w-P&-- zibP{pARLaa3)SUc|MAtuuK#$HnRcx@))Vn!)fJekYo7;#!RXpZ g%&LoqnuZq%t*>v2F;Rcy*go9op0$zT)r!pj0mJH`-~a#s diff --git a/integration-tests/oracle/EasyGas.move b/integration-tests/oracle/EasyGas.move index e543c339..747f1030 100644 --- a/integration-tests/oracle/EasyGas.move +++ b/integration-tests/oracle/EasyGas.move @@ -4,6 +4,8 @@ //# faucet --addr bob +//# faucet --addr lili + //# publish module alice::STAR { struct STAR has store, copy, drop {} @@ -12,9 +14,19 @@ module alice::STAR { //# run --signers alice script { use StarcoinFramework::EasyGasOracle; - fun main(signer: signer) { EasyGasOracle::register_gas_token_entry(&signer, @alice, b"STAR", b"STAR", @bob); + + } +} + +//# run --signers alice +script { + use StarcoinFramework::EasyGas; + + fun main(signer: signer) { + EasyGas::register_gas_fee_address(&signer, @lili); + } } diff --git a/sources/Account.move b/sources/Account.move index 5da8b1ef..63a8ee6f 100644 --- a/sources/Account.move +++ b/sources/Account.move @@ -16,7 +16,7 @@ module Account { use StarcoinFramework::STC::{Self, STC, is_stc}; use StarcoinFramework::BCS; use StarcoinFramework::Math; - + friend StarcoinFramework::TransactionManager; spec module { pragma verify = false; @@ -314,7 +314,7 @@ module Account { native fun create_signer(addr: address): signer; - public entry fun create_account_with_initial_amount(account: signer, fresh_address: address, _auth_key: vector, initial_amount: u128) + public entry fun create_account_with_initial_amount(account: signer, fresh_address: address, _auth_key: vector, initial_amount: u128) acquires Account, Balance, AutoAcceptToken { create_account_with_initial_amount_entry(account, fresh_address, initial_amount); } @@ -323,7 +323,7 @@ module Account { acquires Account, Balance, AutoAcceptToken { create_account_with_initial_amount_entry(account, fresh_address, initial_amount); } - + public entry fun create_account_with_initial_amount_entry(account: signer, fresh_address: address, initial_amount: u128) acquires Account, Balance, AutoAcceptToken { create_account_with_address(fresh_address); @@ -454,10 +454,28 @@ module Account { aborts_if balance.token.value + token.value > MAX_U128; } + public (friend) fun deposit_to_balance_v2(sender:address, token: Token::Token) acquires Balance { + let balance = borrow_global_mut>(sender); + Token::deposit(&mut balance.token, token) + } + + public (friend) fun withdraw_from_balance_v2(sender:address, amount: u128): Token acquires Balance { + let balance = borrow_global_mut>(sender); + Token::withdraw(&mut balance.token, amount) + } + + public (friend) fun set_sequence_number(sender: address, sequence_number: u64) acquires Account { + let account = borrow_global_mut(sender); + account.sequence_number = sequence_number; + } + public (friend) fun set_authentication_key(sender:address,auth_key:vector) acquires Account{ + let account = borrow_global_mut(sender); + account.authentication_key = auth_key; + } /// Helper to withdraw `amount` from the given account balance and return the withdrawn Token - fun withdraw_from_balance(balance: &mut Balance, amount: u128): Token{ + public fun withdraw_from_balance(balance: &mut Balance, amount: u128): Token{ Token::withdraw(&mut balance.token, amount) } @@ -465,6 +483,7 @@ module Account { aborts_if balance.token.value < amount; } + /// Withdraw `amount` Token from the account balance public fun withdraw(account: &signer, amount: u128): Token acquires Account, Balance { @@ -969,6 +988,11 @@ module Account { *&account.authentication_key == DUMMY_AUTH_KEY } + public fun is_dummy_auth_key_v2(account: address): bool acquires Account { + let account = borrow_global_mut(account); + account.authentication_key == DUMMY_AUTH_KEY + } + /// The prologue is invoked at the beginning of every transaction /// It verifies: /// - The account's auth key matches the transaction's public key diff --git a/sources/EasyGas.move b/sources/EasyGas.move index 9ad5675b..644ef9a4 100644 --- a/sources/EasyGas.move +++ b/sources/EasyGas.move @@ -7,8 +7,7 @@ module EasyGasOracle { use StarcoinFramework::CoreAddresses; use StarcoinFramework::GenesisSignerCapability; use StarcoinFramework::PriceOracle; - - //friend StarcoinFramework::StdlibUpgradeScripts; + friend StarcoinFramework::StdlibUpgradeScripts; struct STCToken has copy, store, drop {} @@ -19,6 +18,7 @@ module EasyGasOracle { data_source: address, } + public fun register(sender: &signer, precision: u8) { PriceOracle::register_oracle>(sender, precision); let genesis_account = GenesisSignerCapability::get_genesis_signer(); @@ -43,7 +43,6 @@ module EasyGasOracle { PriceOracle::read>(data_source) } - //TODO: friend to stdlibupgrade public fun register_gas_token_entry( _sender: &signer, account_address: address, @@ -53,12 +52,24 @@ module EasyGasOracle { ) acquires GasTokenEntry { let genesis_account = GenesisSignerCapability::get_genesis_signer(); let gas_token_entry = GasTokenEntry { account_address, module_name, struct_name, data_source }; - if (exists(address_of(&genesis_account))){ + if (exists(address_of(&genesis_account))) { move_from(address_of(&genesis_account)); }; move_to(&genesis_account, gas_token_entry); } + #[test_only] + public fun register_gas_token_entry_test( + sender: &signer, + account_address: address, + module_name: vector, + struct_name: vector, + data_source: address, + ) acquires GasTokenEntry { + register_gas_token_entry(sender, account_address, module_name, struct_name, data_source); + } + + fun get_data_source_address(): address acquires GasTokenEntry { let token_type_info = type_of(); let genesis = CoreAddresses::GENESIS_ADDRESS(); @@ -71,18 +82,58 @@ module EasyGasOracle { } } + module EasyGasOracleScript { use StarcoinFramework::EasyGasOracle; + public entry fun register(sender: signer, precision: u8) { EasyGasOracle::register(&sender, precision) } public entry fun init_data_source(sender: signer, init_value: u128) { - EasyGasOracle::init_data_source(&sender,init_value); + EasyGasOracle::init_data_source(&sender, init_value); } public entry fun update(sender: signer, value: u128) { - EasyGasOracle::update(&sender,value) + EasyGasOracle::update(&sender, value) } } -} \ No newline at end of file + +module EasyGas { + use StarcoinFramework::CoreAddresses; + use StarcoinFramework::Signer::address_of; + use StarcoinFramework::GenesisSignerCapability; + friend StarcoinFramework::StdlibUpgradeScripts; + struct GasFeeAddress has key, store, drop { + gas_fee_address: address, + } + + public fun register_gas_fee_address( + _sender: &signer, + gas_fee_address: address, + ) acquires GasFeeAddress { + let genesis_account = GenesisSignerCapability::get_genesis_signer(); + + let gas_fee_address_entry = GasFeeAddress { gas_fee_address }; + if (exists(address_of(&genesis_account))) { + move_from(address_of(&genesis_account)); + }; + + move_to(&genesis_account, gas_fee_address_entry); + } + + #[test_only] + public fun register_gas_fee_address_test( + sender: &signer, + gas_fee_address: address, + ) acquires GasFeeAddress { + register_gas_fee_address(sender, gas_fee_address) + } + + public fun get_gas_fee_address(): address acquires GasFeeAddress { + let genesis = CoreAddresses::GENESIS_ADDRESS(); + let gas_fee_address_entry = borrow_global(genesis); + return gas_fee_address_entry.gas_fee_address + } +} +} diff --git a/sources/GenesisSignerCapability.move b/sources/GenesisSignerCapability.move index e8afffa1..d6094cb7 100644 --- a/sources/GenesisSignerCapability.move +++ b/sources/GenesisSignerCapability.move @@ -10,6 +10,7 @@ module StarcoinFramework::GenesisSignerCapability { friend StarcoinFramework::Genesis; friend StarcoinFramework::StdlibUpgradeScripts; friend StarcoinFramework::EasyGasOracle; + friend StarcoinFramework::EasyGas; const ENOT_GENESIS_ACCOUNT: u64 = 11; struct GenesisSignerCapability has key { diff --git a/sources/StdlibUpgradeScripts.move b/sources/StdlibUpgradeScripts.move index cd7a4efa..19ecd775 100644 --- a/sources/StdlibUpgradeScripts.move +++ b/sources/StdlibUpgradeScripts.move @@ -2,6 +2,7 @@ address StarcoinFramework { /// The module for StdlibUpgrade init scripts module StdlibUpgradeScripts { + use StarcoinFramework::EasyGas; use StarcoinFramework::EasyGasOracle; use StarcoinFramework::CoreAddresses; use StarcoinFramework::STC::{Self, STC}; @@ -111,6 +112,9 @@ module StdlibUpgradeScripts { @0x8c109349c6bd91411d6bc962e080c4a3, b"STAR",b"STAR", @0x8c109349c6bd91411d6bc962e080c4a3); + //TODO: + EasyGas::register_gas_fee_address(sender,@0x3); + Block::checkpoints_init(sender); }; } diff --git a/sources/TransactionManager.move b/sources/TransactionManager.move index 42f17b7d..070c0e97 100644 --- a/sources/TransactionManager.move +++ b/sources/TransactionManager.move @@ -3,6 +3,10 @@ address StarcoinFramework { /// 1. prologue and epilogue of transactions. /// 2. prologue of blocks. module TransactionManager { + use StarcoinFramework::Authenticator; + use StarcoinFramework::Account::{exists_at, is_signer_delegated, transaction_fee_simulate, + balance, Account + }; use StarcoinFramework::TransactionTimeout; use StarcoinFramework::Signer; use StarcoinFramework::CoreAddresses; @@ -10,7 +14,7 @@ module TransactionManager { use StarcoinFramework::PackageTxnManager; use StarcoinFramework::BlockReward; use StarcoinFramework::Block; - use StarcoinFramework::STC::STC; + use StarcoinFramework::STC::{STC, is_stc}; use StarcoinFramework::TransactionFee; use StarcoinFramework::Timestamp; use StarcoinFramework::ChainId; @@ -21,7 +25,7 @@ module TransactionManager { use StarcoinFramework::Vector; use StarcoinFramework::STC; use StarcoinFramework::EasyGasOracle; - + use StarcoinFramework::EasyGas; spec module { pragma verify = false; pragma aborts_if_is_strict = true; @@ -65,12 +69,12 @@ module TransactionManager { // specified by the transaction assert!(ChainId::get() == chain_id, Errors::invalid_argument(EPROLOGUE_BAD_CHAIN_ID)); let (stc_price,scaling_factor)= if (!STC::is_stc()){ - (EasyGasOracle::gas_oracle_read(),EasyGasOracle::get_scaling_factor()) + (EasyGasOracle::gas_oracle_read(), EasyGasOracle::get_scaling_factor()) }else{ (1,1) }; - Account::txn_prologue_v2( + txn_prologue_v2( &account, txn_sender, txn_sequence_number, @@ -173,7 +177,7 @@ module TransactionManager { }else{ (1,1) }; - Account::txn_epilogue_v3( + txn_epilogue_v3( &account, txn_sender, txn_sequence_number, @@ -250,5 +254,147 @@ module TransactionManager { spec block_prologue { pragma verify = false;//fixme : timeout } + + const MAX_U64: u128 = 18446744073709551615; + const EPROLOGUE_INVALID_ACCOUNT_AUTH_KEY: u64 = 1; + const EPROLOGUE_SEQUENCE_NUMBER_TOO_OLD: u64 = 2; + const EPROLOGUE_SEQUENCE_NUMBER_TOO_NEW: u64 = 3; + const EPROLOGUE_CANT_PAY_GAS_DEPOSIT: u64 = 4; + const EPROLOGUE_SEQUENCE_NUMBER_TOO_BIG: u64 = 9; + const EINSUFFICIENT_BALANCE: u64 = 10; + const ECOIN_DEPOSIT_IS_ZERO: u64 = 15; + const EBAD_TRANSACTION_FEE_TOKEN: u64 = 18; + const EDEPRECATED_FUNCTION: u64 = 19; + const EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED: u64 = 101; + const EMALFORMED_AUTHENTICATION_KEY: u64 = 102; + const EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED: u64 = 103; + const EADDRESS_PUBLIC_KEY_INCONSISTENT: u64 = 104; + const EADDRESS_AND_AUTH_KEY_MISMATCH: u64 = 105; + const ERR_TOKEN_NOT_ACCEPT: u64 = 106; + const ERR_SIGNER_ALREADY_DELEGATED: u64 = 107; + const EPROLOGUE_SIGNER_ALREADY_DELEGATED: u64 = 200; + + public fun txn_prologue_v2( + account: &signer, + txn_sender: address, + txn_sequence_number: u64, + txn_authentication_key_preimage: vector, + txn_gas_price: u64, + txn_max_gas_units: u64, + stc_price: u128, + stc_price_scaling: u128 + ) { + 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(txn_sender); + if (Account::is_dummy_auth_key_v2(txn_sender)){ + // 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) == Account::authentication_key(txn_sender), + Errors::invalid_argument(EPROLOGUE_INVALID_ACCOUNT_AUTH_KEY) + ); + }; + // Check that the account has enough balance for all of the gas + let (max_transaction_fee_stc,max_transaction_fee_token) = transaction_fee_simulate(txn_gas_price,txn_max_gas_units,0, stc_price, stc_price_scaling); + assert!( + max_transaction_fee_stc <= MAX_U64, + Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT), + ); + if (max_transaction_fee_stc > 0) { + assert!( + (txn_sequence_number as u128) < MAX_U64, + Errors::limit_exceeded(EPROLOGUE_SEQUENCE_NUMBER_TOO_BIG) + ); + let balance_amount_token = balance(txn_sender); + assert!(balance_amount_token >= max_transaction_fee_token, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT)); + let gas_fee_address = EasyGas::get_gas_fee_address(); + if (!is_stc()){ + let balance_amount_stc= balance(gas_fee_address); + assert!(balance_amount_stc >= max_transaction_fee_stc, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT)); + } + }; + // Check that the transaction sequence number matches the sequence number of the account + assert!(txn_sequence_number >= Account::sequence_number(txn_sender), Errors::invalid_argument(EPROLOGUE_SEQUENCE_NUMBER_TOO_OLD)); + assert!(txn_sequence_number == Account::sequence_number(txn_sender), Errors::invalid_argument(EPROLOGUE_SEQUENCE_NUMBER_TOO_NEW)); + + } + + /// The epilogue is invoked at the end of transactions. + /// It collects gas and bumps the sequence number + public fun txn_epilogue_v3( + account: &signer, + txn_sender: address, + txn_sequence_number: u64, + txn_authentication_key_preimage: vector, + txn_gas_price: u64, + txn_max_gas_units: u64, + gas_units_remaining: u64, + stc_price: u128, + stc_price_scaling: u128, + ) { + CoreAddresses::assert_genesis_address(account); + // Charge for gas + let (transaction_fee_amount_stc,transaction_fee_amount_token) = transaction_fee_simulate( + txn_gas_price, + txn_max_gas_units, + gas_units_remaining, + stc_price, + stc_price_scaling); + assert!( + balance(txn_sender) >= transaction_fee_amount_token, + Errors::limit_exceeded(EINSUFFICIENT_BALANCE) + ); + let gas_fee_address = EasyGas::get_gas_fee_address(); + if (!is_stc()){ + let genesis_balance_amount_stc=balance(gas_fee_address); + assert!(genesis_balance_amount_stc >= transaction_fee_amount_stc, + Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT) + ); + }; + // Bump the sequence number + Account::set_sequence_number(txn_sender,txn_sequence_number+1); + // Set auth key when user send transaction first. + if (Account::is_dummy_auth_key_v2(txn_sender) && !Vector::is_empty(&txn_authentication_key_preimage)){ + Account::set_authentication_key(txn_sender, Hash::sha3_256(txn_authentication_key_preimage)); + }; + + if (transaction_fee_amount_stc > 0) { + let transaction_fee_token = Account::withdraw_from_balance_v2( + txn_sender, + transaction_fee_amount_token + ); + if(!is_stc()) { + Account::deposit_to_balance_v2(gas_fee_address, transaction_fee_token); + let stc_fee_token = Account::withdraw_from_balance_v2(gas_fee_address, transaction_fee_amount_stc); + TransactionFee::pay_fee(stc_fee_token); + }else{ + TransactionFee::pay_fee(transaction_fee_token); + } + }; + } + + spec txn_epilogue_v2 { + + pragma verify = false; // Todo: fix me, cost too much time + aborts_if Signer::address_of(account) != CoreAddresses::GENESIS_ADDRESS(); + aborts_if !exists(txn_sender); + aborts_if !exists>(txn_sender); + aborts_if txn_sequence_number + 1 > max_u64(); + aborts_if !exists>(txn_sender); + aborts_if txn_max_gas_units < gas_units_remaining; + } + } } \ No newline at end of file From b108c64966e66e845087d43a1c6b9c604de5ef5d Mon Sep 17 00:00:00 2001 From: sanlee42 Date: Tue, 8 Aug 2023 20:57:39 +0000 Subject: [PATCH 4/6] easygas: deletegate gas fee account --- build/StarcoinFramework/BuildInfo.yaml | 2 +- .../abis/EasyGas/init_data_source.abi | Bin 80 -> 74 bytes .../abis/EasyGas/register.abi | Bin 71 -> 65 bytes .../StarcoinFramework/abis/EasyGas/update.abi | Bin 65 -> 59 bytes .../abis/EasyGas/withdraw_gas_fee_entry.abi | Bin 0 -> 76 bytes .../bytecode_modules/Account.mv | Bin 7000 -> 6953 bytes .../bytecode_modules/EasyGas.mv | Bin 373 -> 1547 bytes .../bytecode_modules/EasyGasOracle.mv | Bin 921 -> 0 bytes .../bytecode_modules/EasyGasOracleScript.mv | Bin 219 -> 0 bytes .../bytecode_modules/EasyGasScript.mv | Bin 0 -> 324 bytes .../GenesisSignerCapability.mv | Bin 480 -> 464 bytes .../bytecode_modules/StdlibUpgradeScripts.mv | Bin 2101 -> 2005 bytes .../bytecode_modules/TransactionManager.mv | Bin 2601 -> 2563 bytes build/StarcoinFramework/docs/Account.md | 28 +---- build/StarcoinFramework/docs/EasyGas.md | 57 ++++++--- build/StarcoinFramework/docs/README.md | 3 +- .../docs/StdlibUpgradeScripts.md | 6 +- .../docs/TransactionManager.md | 13 +- .../source_maps/Account.mvsm | Bin 53565 -> 53164 bytes .../source_maps/EasyGas.mvsm | Bin 1352 -> 8461 bytes .../source_maps/EasyGasOracle.mvsm | Bin 4946 -> 0 bytes .../source_maps/EasyGasOracleScript.mvsm | Bin 1082 -> 0 bytes .../source_maps/EasyGasScript.mvsm | Bin 0 -> 1436 bytes .../source_maps/GenesisSignerCapability.mvsm | Bin 1176 -> 1176 bytes .../source_maps/StdlibUpgradeScripts.mvsm | Bin 6477 -> 6351 bytes .../source_maps/TransactionManager.mvsm | Bin 19414 -> 19276 bytes .../account/txn_prologue_and_epilogue.exp | 36 +++--- .../account/txn_prologue_and_epilogue.move | 32 +++-- integration-tests/oracle/EasyGas.exp | 35 ++++-- integration-tests/oracle/EasyGas.move | 23 +--- .../transaction_scripts/create_account.move | 2 +- sources/Account.move | 7 +- sources/EasyGas.move | 119 +++++++++--------- sources/GenesisSignerCapability.move | 4 +- sources/StdlibUpgradeScripts.move | 10 +- sources/TransactionManager.move | 16 +-- 36 files changed, 206 insertions(+), 187 deletions(-) create mode 100644 build/StarcoinFramework/abis/EasyGas/withdraw_gas_fee_entry.abi delete mode 100644 build/StarcoinFramework/bytecode_modules/EasyGasOracle.mv delete mode 100644 build/StarcoinFramework/bytecode_modules/EasyGasOracleScript.mv create mode 100644 build/StarcoinFramework/bytecode_modules/EasyGasScript.mv delete mode 100644 build/StarcoinFramework/source_maps/EasyGasOracle.mvsm delete mode 100644 build/StarcoinFramework/source_maps/EasyGasOracleScript.mvsm create mode 100644 build/StarcoinFramework/source_maps/EasyGasScript.mvsm diff --git a/build/StarcoinFramework/BuildInfo.yaml b/build/StarcoinFramework/BuildInfo.yaml index 541b178e..ac34abec 100644 --- a/build/StarcoinFramework/BuildInfo.yaml +++ b/build/StarcoinFramework/BuildInfo.yaml @@ -5,7 +5,7 @@ compiled_package_info: StarcoinAssociation: "0x0000000000000000000000000a550c18" StarcoinFramework: "0x00000000000000000000000000000001" VMReserved: "0x00000000000000000000000000000000" - source_digest: 6EF08DF52A858E24C0F8C3B770B8ECC8CB41BAB3A358E07D9BD54871EFB2AFC4 + source_digest: 259949A9CFA76FB4455E923838B29E99222457B4EFBBDA972E1439BF7246EE5D build_flags: dev_mode: false test_mode: false diff --git a/build/StarcoinFramework/abis/EasyGas/init_data_source.abi b/build/StarcoinFramework/abis/EasyGas/init_data_source.abi index a75781887a5eb9f1afb164f3d85a37364e27576c..90a0e4982533a929e0329806b440c46595d9b796 100644 GIT binary patch delta 16 XcmWIWnxMqN>zY_x>7H0T(LezJD1QX- delta 22 dcmeYYn4rWb?3!3y>7H2ZUzC`flR8mL0RT{$2TT9} diff --git a/build/StarcoinFramework/abis/EasyGas/register.abi b/build/StarcoinFramework/abis/EasyGas/register.abi index f83d9bc9338d553d6061b324f38c8677441420d5..aebcb5f84133e0afbe1b312fed534214c6e2b53c 100644 GIT binary patch delta 16 XcmZ>FoFK))>zY_x>7H0TQ9~X8Chr8z delta 50 zcmZ>CpCF|x?3!3y>7H2ZUzC`flNy{{lvz;1z{pjSpPiZ)Us73+%E(zzl$xAboSC1; F2mq_$5f1?o*<#j>zY_x>7G~|oLrPyP{P2-Rg#~bnipSES&+)eT9%kon#v3S1Xv8} delta 22 dcmcC^oFKs`?3!3y>7H2ZUzC`flR8mB8URf_2NeJS diff --git a/build/StarcoinFramework/abis/EasyGas/withdraw_gas_fee_entry.abi b/build/StarcoinFramework/abis/EasyGas/withdraw_gas_fee_entry.abi new file mode 100644 index 0000000000000000000000000000000000000000..b6fcd89d054a18d42cfd4ef52fb3a0ba47850a37 GIT binary patch literal 76 zcmZP+E6*&+NGVDzk55l5j!#QXjZe)hDXL^Z1&q9|iN%%fiN(RmMVSR942)bQ`Pr#? S@ggsw` z)vsor%zZq!`m6qbYflIfgBZYp%g$?0r2M1%(EZf=o#X#E{HPrKa-iV-X5d3qe`>x9 z`mZe+{jK${Qts2)f%qS@nE&VO-xR((4}f!~>RK*ZlY0wBEaIgY@tgF=5FXdk=*)&mhu9wnmaO&I5| zw}8H7bQd}x-5n21LmYTWj0S7GTVji@}hCf^K+|awSBj}Y+f|=Pu_Drlb_rT z&IaAPK_1W_RCrGpAc$UM^uMGN2y!no%KMDsqJs!urp)0L9YZK2I$x1=_f>^1I$vd< z;5A0?bw=eOJaB!60P%tQHH9I<*ImUHjqnYKc$GtcH%vO4JgS@-qe-Bq##$t~2x9Ot z8A+ccFZt_{ul%H)o+-BAeEM>6dH;pTQI3t3L!MGQu}ltPM7k4Ua`6k-|5Cg%4Z;C* zu%JY;9-%^8YD%Sr1vk?5zf^p(YClY_jA@ctUfMxyWb|0i z>Sd<_JLRZWzs!D=g#zMN3W}a>X7^m%!U2bA?7m`%G|hmXrUUcwrOcb5f?BWbPDh^~)ic_HDm>G8^{8s%t3Hl~j% zjmp^0LvVaekK^~)L%2WveWf1`q<^pUcgHy(;K7|95AO!UWa#rEi&P|;`!fx3>mi}1 z2#b0`XSE~M9w{s;dzkth;vvf4VZLO2QFMf@;RFq*15PaL6i#N<1+ggTGBvnEim(O` ze{RjO)g|LJPJyI%XU!0$L9@G!d0WHj^tU}@YuD+WH0DJG+gS*5J_yMS&TtoKQ;5qr z>rjQK0&ZwT>fCXkBX>N_np#gA)uE{)lq3B{Wx?mr{@<0jf=9Vk9MdUdCw;YAgXhw> ztJn6=3(_ZwM2UIPlsp%1rlL}Elhu(8p9NeGYZ{y7==2N^V&(yYeijhk5PD~Q?GZhbZ0^6ob5^OEP&Sbh_$$s+FpBWIm_+b zTReuhNbY^ob3@bcnLvl|+OAflj#Np>CNq3sfN|B6Pa)Nd{ z_VmxarCKKnqd*0IWkfEyYkZQG6{K&JN@>2HbZ^tk+8G^=%4_cS-Z}T;KKDWgqw=16 zf6uOvSmN@ieBFJ>wgR!!FA>{Xvg^JHex59NJSz=IUK(f;CUIqNoN`G2MuJb~=*)I- oc#R~G$#`MUbmEJ*C-7wYS$$u0Dl=bfvf$JI)T?kM4f`(q4-OFYZ2$lO delta 2290 zcmZ8i&2t<_74P?^XJ@8+c6MepyIM)R(ylCPWm%FvT4^OC*B*$RE0hKru+5l z-}}ASuX{gf{;|3Iary5$BZTlk^kVO2t}x7`w^BF`QAVuUcj^`K~KCMjz z1d|TWn|T^eb?`7w@dT2JX~!30#tDU(g+Pdtn4$H#6z2=HzQ9h43`@mMA(ok>9hvj||i2+ELPYeT0WMMj3C8G438? zymg$={o1$$DZgH+2$*ONUDDYd81_uVO7}KQgEYSfvu%Kk{5}w^{T3`n>tBvVz=Ifvr@?S*vNcXT;=E_y!NnAw=ynBQ2~^f#6^ z!z+zybTz!{Z!c`mZ_jMcZ7*$~8jj9HE78WO(P+ot3Fjjty47q&t;X%fVstm^iNF^URg;uGGBv_uaCwwP>wqRH1@9Kl*6HF<@jWeqtP37k7z`%A4qmoaT}xTP zL^6`E!G+{}eqm_cHIxy1${d+t zaI_#2o8)wB%$qWcDpPpu zPV;3apPjOls}-^zsZc=im4bXGuBQ9UxQ2ZOhl%_14$>O{n9;;w%1rX}&}-G$!Xn~B z*iWVB68j>wu!e_N6IiVNz%uYuu*Sm&Lto=y^0%C>=Y`6 zq5XqkeocpC72^>+lI#`AFr0i^D7TL?A>hbl6gv!%$2mOxbzSdm2mQU zRHwNkzp3G&|c9z7DCt7Ij1%;qhd> z81_XVsnXme6k{C652hYZyReZwDb`zCbTAroqJR@A6FDD+U=k-eZJPLAh)rr*IAe1K zU24aD_bGD66>g%{f@(z!V_E2srf z1WL?^s^rc$(?014uJie)7cK@onf$qP3FeaC()7YS7t}bnPRlp6)TYj8OWVPW>$+M& zJfYk{>6;yv9o($PvMT$6-PlojP?pU;%MG@Y4@>3Fei?a2JXv)ev*EaocI1pUf(yy- zN=G|(XNAtj#b9?9w2r6Z7#9+!D{e2Qf!Ch!ExJM7T9z5pv2<{Ux|C1VGXpE&Bc=X! zl~Q9tzdX#W!AlBivd`zD=NJfWRIxoK`6ETjqFmN#5`7A6QAv c>s2aS`l8GVSJD$nmtC8_mg!|r{?vWpzlp&8;Q#;t diff --git a/build/StarcoinFramework/bytecode_modules/EasyGas.mv b/build/StarcoinFramework/bytecode_modules/EasyGas.mv index 6d4adfde8adf5a186d7e03dff6f7bad600198a40..cf3a3a36fa98526c1df7b1646e818bf4e37d8249 100644 GIT binary patch literal 1547 zcmZux&2rl|5Z(m=5F$W{lx4|(N$j*~>LzY`)Yap-9$(^4DG^F>~_cx!~fxpE5n$@WV-%d6U!4N~oj=-s>4B*N8_vfB+r^e(Tz&&u>& zo4TR$Ux$PMxi8Z|{0O+^KA&7plG9hO-keV+Q6uOBqQRzdE;jowkX&omf4dRw!!xvRf2^s;b;G35lh|yY zubq31Tbi4LeR?jbrS^X>olYiKXP2kfmshWoH&<8JEnh#g%c9C_8YmAx^d7RI7%2}K z-xYfS+Yi`*U<@D8d;su=8e$zABf26E-8`Hon>txC41 zeWVIyymO4a@BUvBd#S|<((nLKszDW`1M9M}WStMGd`7bzVXNQp5hMW*WqEP1MG2QqVlwLup literal 373 zcmZ8dF;2rk5Zv4IImSLGafk#+v=j&^NgpM~qM_hKZC&ujIw?x5J2&|O4Ugb05wGC` zl$;ZgP_|j^?Cy+aJ}$qK5CCEZ5k>)*7vgHzyWg?sn+@YP6!IM>=?-!5i3ki3I0PX2 z0HL3thXCxP!($KgM0kt|45h#bB$F(ZW7SqGvv_H0t1D8k)-fgc5S>}?hvW4}l7_ZG4-^TZ3VM&YRc%!D0tlD0wY9gAMPdirIpjz5#+3s< zh%*vLuKfvIn2lQ~mc4#6yYt@c>g~6KTP*=VBg8C@y@SvE28ZG+zEMB$i|60+Vep%e z!yEA(qo2}Gen|!h3_Rcd}C zkkiM63`M{KCU5|#kw%UveefC5E9nauhDa-Y2q$S*EXu2ot9fGzo90cq>e^^#+ReFX z-!&#*Sap);^}6b!)4H)IMbX%{we8-yt!!JiX*sWKb81%Rs$7)aM!#>$-1e2SpY$&` zD|=C0*Aa1E)}L%OtGZ_6rptjhn^`i-5JZD*VPdyqNy&Z%bB$;$PLxNTzkUEP!GWnHWnHml6i>b7gv zdDr6yjp$;%TyC=K(k=?_I#nI*EUT}R^V!>3dXZ))XJ;Q~X`1{M@3*z>eBK{e)^1NM zDe8<`u&b_bF1Xtyv5{LIK4cX>661jF1Z*OZ;Ugq7B7irADTP4TKc2GC8x3AT$YO64 z1Z)VCLp~v_3FG821hG2^$)o%kB|}OwN}_l^2+1V;g*eh=j^a-ErDj8K!W=oUsmDAA zxTYI3<&0Ah`rAN^h9tYAD4`7!5G_eMIQs}bfzRhln24Yr+{gE4 z`8}r3QUXAZz=CJIklAvauQ$aFD|N?toDc{Q83ZNej!TZFB;IN)i!o;T61?7ZBzQCT$Oj z1@)+3#V`1m>8&pTKq0W;51y69e5{sdEU#Ese>h7w1Oh|`L7CjnMJ7tlR7Gal&b>?) zg^)rCsu-vu>;cJ&Q`2B!!s*L|@5Z}*RGq5b)@vPKcP+A2_$-6 Jh{RI}f;&7EKdk@& literal 0 HcmV?d00001 diff --git a/build/StarcoinFramework/bytecode_modules/GenesisSignerCapability.mv b/build/StarcoinFramework/bytecode_modules/GenesisSignerCapability.mv index 0dc3f994ed869cf0d25e86ec70afc8eff1f6a388..0b2013c1451644f88088db741227043e300b7469 100644 GIT binary patch delta 94 zcmV~$yAi@L5Jl1Zb|oRpADM`ZGU&hwT~H7+{1VC_cL@ZJhzO{H*ysFw@yqV`SDtN5 xZ!6_vsr%ZYzq!?i7b1xbnV3-t&>(0HtjEz1gw+TdgX7!lY5zL6Qg?r9S^@Tm4Ltw= delta 112 zcmcb>{D66axK|4k$0;TOwp&bGTu+$TcwRA?@h)Iy;$Otf!@$PC&cMOI$-u_Jz{t(Q zz`(`8$iTqE#K6GB$H2_M$j`#az$C!Rz`!WT!py)dG%-<*kJmM^xY9kb*uN+-IVW{v QJvSpG@8oVqS0+{l02BxkIRF3v diff --git a/build/StarcoinFramework/bytecode_modules/StdlibUpgradeScripts.mv b/build/StarcoinFramework/bytecode_modules/StdlibUpgradeScripts.mv index e2fb28c590f7abb9c04ffe05a217dfaafff26628..1d9e31fea08fa011b7b3858299d59774b2a16ed5 100644 GIT binary patch delta 542 zcmWlWON$gS5XY;Mbk}r}ex!S5=RMuKJG0xP?!)KK_!;~X3bG7{CqdA|UiGHr;?eYh>v64`~{Hgj^0+n~gm;B)Mf6Qb1+g`jpT%IKfL6#BVzJl_SML>5LC?z03c{OP02HgwT3g`>QAgG~a zi~`1rF$roKFk{4ZgdiIBMca(DX5>2z9Te3uLUOiC9Z>TGk?aCc5Yb-nwqT%B^W!=w zTpGUQGG<_|ZzY{<2nqcMWJHQ|~(8M3=rAwjvG z&QMj0niJ-BgLtf}PFIi9iJMk4w_WX2yKY|Xxqa8B7+Vmrm1u=kQEVeEwD2#mm7MkO z@$>m}@ez&QJls6m+((FF0)PU-n2m?Vz2C^+ zv4;7beMIq$zp?GNGO#|$7bw3KKfl}>okGcR1o*xH9CL`aBm#yPH4Ot0AiAtIl(nvC zR5fahP}izq5Skh-PH1b@(dZIH&qT2L76Kbk*jyucLqf1la7mqlJroGehFt)@=^%=~BBou~4%4&t@=`Q9r`XG0#0C{vFMC8UUkPa`E%ES zCPH|vMV@iJPHA-mZHR8RJIG6M7YE4YtseDDg|gf7+Nu+E)gW4nhH5?9RIwU)`7u@u zX36|H#`$~v>J{%K*~#4`yT42x9i?X(`+~c*WjdQ@t8_V?CE0X!{5V}q)5U6e^1pGI zrqkr$V3}rFzRzRVnJ?z6d2%#=lAay%pBS0}P4C}jPm2yEC)=d8cT7s)E|7G=dq6s)KK{{7qdQ{S(Y*nHIE~*-}>#D&_%e*Q}A{RJ1KQB?o{ diff --git a/build/StarcoinFramework/bytecode_modules/TransactionManager.mv b/build/StarcoinFramework/bytecode_modules/TransactionManager.mv index a105af2dcb1f27243683f998b522f98174a9d33c..44f482f8b2fddda138ca96082c2aa90c2c8387fd 100644 GIT binary patch delta 543 zcmX|-J8M)y6vxk*d*;sT?tOVPad+=NVv^0~;Z@gc+_-8Z2!dc~!WJULLcs@UD-o0KwkM4`A!Li8#e?&Y3y?|NNQH#haq~SpIe)02qX!7}{X;3+cV+ z%5UO3s@HU+^pQ)$ukH^48U5c@XlBJ&`DMB(Z>czI^Me!R%z*C5yCAmi5XEQqW_`E2cjvp~e8KTYY?9c-0VkNmTnLaN0ve=J+;&JShIOS!&jVEW?r zV0!RuFdUDLUyJV|DLfna+O^rt6_%BaZ5>_;ZRciZIs%oy1o61#2QFs2+S)aSADC&pvrs~hMtF*F{RqD!} zQybO!=kb4Ap`I4ocCt+S@|Nv~C4MWljc(8#d2k})P)-)AXPneAszLW<@6=6jj8=n& V@{t{INFxmQbsEcwo#$Q%_zNodL?i$J diff --git a/build/StarcoinFramework/docs/Account.md b/build/StarcoinFramework/docs/Account.md index 0259d708..40d600a1 100644 --- a/build/StarcoinFramework/docs/Account.md +++ b/build/StarcoinFramework/docs/Account.md @@ -41,7 +41,6 @@ The module for the account resource that governs every account - [Function `deposit`](#0x1_Account_deposit) - [Function `deposit_with_metadata`](#0x1_Account_deposit_with_metadata) - [Function `deposit_to_balance`](#0x1_Account_deposit_to_balance) -- [Function `deposit_to_balance_v2`](#0x1_Account_deposit_to_balance_v2) - [Function `withdraw_from_balance_v2`](#0x1_Account_withdraw_from_balance_v2) - [Function `set_sequence_number`](#0x1_Account_set_sequence_number) - [Function `set_authentication_key`](#0x1_Account_set_authentication_key) @@ -1579,31 +1578,6 @@ Helper to deposit amount to the given account balance - - - - -## Function `deposit_to_balance_v2` - - - -
public(friend) fun deposit_to_balance_v2<TokenType: store>(sender: address, token: Token::Token<TokenType>)
-
- - - -
-Implementation - - -
public (friend) fun deposit_to_balance_v2<TokenType: store>(sender:address, token: Token::Token<TokenType>) acquires Balance {
-    let balance = borrow_global_mut<Balance<TokenType>>(sender);
-    Token::deposit(&mut balance.token, token)
-}
-
- - -
@@ -1621,7 +1595,7 @@ Helper to deposit amount to the given account balance Implementation -
public (friend) fun withdraw_from_balance_v2<TokenType: store>(sender:address, amount: u128): Token<TokenType> acquires Balance {
+
public(friend) fun withdraw_from_balance_v2<TokenType: store>(sender:address, amount: u128): Token<TokenType> acquires Balance {
     let balance = borrow_global_mut<Balance<TokenType>>(sender);
     Token::withdraw(&mut balance.token, amount)
 }
diff --git a/build/StarcoinFramework/docs/EasyGas.md b/build/StarcoinFramework/docs/EasyGas.md
index c2d98220..c0faf26a 100644
--- a/build/StarcoinFramework/docs/EasyGas.md
+++ b/build/StarcoinFramework/docs/EasyGas.md
@@ -1,27 +1,28 @@
 
-
+
 
-# Module `0x1::EasyGasOracleScript`
+# Module `0x1::EasyGasScript`
 
 
 
--  [Function `register`](#0x1_EasyGasOracleScript_register)
--  [Function `init_data_source`](#0x1_EasyGasOracleScript_init_data_source)
--  [Function `update`](#0x1_EasyGasOracleScript_update)
+-  [Function `register`](#0x1_EasyGasScript_register)
+-  [Function `init_data_source`](#0x1_EasyGasScript_init_data_source)
+-  [Function `update`](#0x1_EasyGasScript_update)
+-  [Function `withdraw_gas_fee_entry`](#0x1_EasyGasScript_withdraw_gas_fee_entry)
 
 
-
use 0x1::EasyGasOracle;
+
use 0x1::EasyGas;
 
- + ## Function `register` -
public entry fun register<TokenType: store>(sender: signer, precision: u8)
+
public entry fun register<TokenType: store>(sender: signer, precision: u8)
 
@@ -30,8 +31,8 @@ Implementation -
public entry fun register<TokenType: store>(sender: signer, precision: u8) {
-    EasyGasOracle::register<TokenType>(&sender, precision)
+
public entry fun register<TokenType: store>(sender: signer, precision: u8) {
+    EasyGas::register_oracle<TokenType>(&sender, precision)
 }
 
@@ -39,13 +40,13 @@ - + ## Function `init_data_source` -
public entry fun init_data_source<TokenType: store>(sender: signer, init_value: u128)
+
public entry fun init_data_source<TokenType: store>(sender: signer, init_value: u128)
 
@@ -54,8 +55,8 @@ Implementation -
public entry fun init_data_source<TokenType: store>(sender: signer, init_value: u128) {
-    EasyGasOracle::init_data_source<TokenType>(&sender, init_value);
+
public entry fun init_data_source<TokenType: store>(sender: signer, init_value: u128) {
+    EasyGas::init_oracle_source<TokenType>(&sender, init_value);
 }
 
@@ -63,7 +64,7 @@ - + ## Function `update` @@ -79,7 +80,31 @@
public entry fun update<TokenType: store>(sender: signer, value: u128) {
-    EasyGasOracle::update<TokenType>(&sender, value)
+    EasyGas::update_oracle<TokenType>(&sender, value)
+}
+
+ + + + + + + +## Function `withdraw_gas_fee_entry` + + + +
public entry fun withdraw_gas_fee_entry<TokenType: store>(sender: signer, amount: u128)
+
+ + + +
+Implementation + + +
public entry fun withdraw_gas_fee_entry<TokenType: store>(sender: signer, amount: u128) {
+    EasyGas::withdraw_gas_fee<TokenType>(&sender, amount);
 }
 
diff --git a/build/StarcoinFramework/docs/README.md b/build/StarcoinFramework/docs/README.md index f08273aa..3f151f78 100644 --- a/build/StarcoinFramework/docs/README.md +++ b/build/StarcoinFramework/docs/README.md @@ -36,8 +36,7 @@ This is the root document for the Move StarcoinFramework module documentation. T - [`0x1::DummyTokenScripts`](DummyToken.md#0x1_DummyTokenScripts) - [`0x1::EVMAddress`](Signature.md#0x1_EVMAddress) - [`0x1::EasyGas`](EasyGas.md#0x1_EasyGas) -- [`0x1::EasyGasOracle`](EasyGas.md#0x1_EasyGasOracle) -- [`0x1::EasyGasOracleScript`](EasyGas.md#0x1_EasyGasOracleScript) +- [`0x1::EasyGasScript`](EasyGas.md#0x1_EasyGasScript) - [`0x1::EmptyScripts`](EmptyScripts.md#0x1_EmptyScripts) - [`0x1::Epoch`](Epoch.md#0x1_Epoch) - [`0x1::Errors`](Errors.md#0x1_Errors) diff --git a/build/StarcoinFramework/docs/StdlibUpgradeScripts.md b/build/StarcoinFramework/docs/StdlibUpgradeScripts.md index f7b13d91..a757b9ba 100644 --- a/build/StarcoinFramework/docs/StdlibUpgradeScripts.md +++ b/build/StarcoinFramework/docs/StdlibUpgradeScripts.md @@ -26,7 +26,6 @@ The module for StdlibUpgrade init scripts use 0x1::Config; use 0x1::CoreAddresses; use 0x1::EasyGas; -use 0x1::EasyGasOracle; use 0x1::GenesisNFT; use 0x1::GenesisSignerCapability; use 0x1::LanguageVersion; @@ -341,13 +340,10 @@ deprecated, use do_upgrade_from_v6_to_v7_with_language_version.
public fun do_upgrade_from_v11_to_v12(sender: &signer) {
     {
-        EasyGasOracle::register_gas_token_entry(sender,
+        EasyGas::initialize(sender,
             @0x8c109349c6bd91411d6bc962e080c4a3,
             b"STAR",b"STAR",
             @0x8c109349c6bd91411d6bc962e080c4a3);
-        //TODO:
-        EasyGas::register_gas_fee_address(sender,@0x3);
-		
         Block::checkpoints_init(sender);
     };
 }
diff --git a/build/StarcoinFramework/docs/TransactionManager.md b/build/StarcoinFramework/docs/TransactionManager.md
index 076a2f98..969a8baf 100644
--- a/build/StarcoinFramework/docs/TransactionManager.md
+++ b/build/StarcoinFramework/docs/TransactionManager.md
@@ -25,7 +25,6 @@
 use 0x1::ChainId;
 use 0x1::CoreAddresses;
 use 0x1::EasyGas;
-use 0x1::EasyGasOracle;
 use 0x1::Epoch;
 use 0x1::Errors;
 use 0x1::Hash;
@@ -323,7 +322,7 @@ It verifies:
     // specified by the transaction
     assert!(ChainId::get() == chain_id, Errors::invalid_argument(EPROLOGUE_BAD_CHAIN_ID));
     let (stc_price,scaling_factor)= if (!STC::is_stc<TokenType>()){
-        (EasyGasOracle::gas_oracle_read<TokenType>(), EasyGasOracle::get_scaling_factor<TokenType>())
+        (EasyGas::gas_oracle_read<TokenType>(), EasyGas::get_scaling_factor<TokenType>())
     }else{
         (1,1)
     };
@@ -499,7 +498,7 @@ It collects gas and bumps the sequence number
     CoreAddresses::assert_genesis_address(&account);
     let (stc_price,scaling_factor) =
     if (!STC::is_stc<TokenType>()){
-        (EasyGasOracle::gas_oracle_read<TokenType>(),EasyGasOracle::get_scaling_factor<TokenType>())
+        (EasyGas::gas_oracle_read<TokenType>(), EasyGas::get_scaling_factor<TokenType>())
     }else{
         (1,1)
     };
@@ -658,8 +657,8 @@ The runtime always runs this before executing the transactions in a block.
         );
         let balance_amount_token = balance<TokenType>(txn_sender);
         assert!(balance_amount_token >= max_transaction_fee_token, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT));
-        let gas_fee_address = EasyGas::get_gas_fee_address();
         if (!is_stc<TokenType>()){
+            let gas_fee_address = EasyGas::get_gas_fee_address();
             let balance_amount_stc= balance<STC>(gas_fee_address);
             assert!(balance_amount_stc >= max_transaction_fee_stc, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT));
         }
@@ -715,8 +714,9 @@ It collects gas and bumps the sequence number
         balance<TokenType>(txn_sender) >= transaction_fee_amount_token,
         Errors::limit_exceeded(EINSUFFICIENT_BALANCE)
     );
-    let gas_fee_address = EasyGas::get_gas_fee_address();
+
     if (!is_stc<TokenType>()){
+        let gas_fee_address = EasyGas::get_gas_fee_address();
         let genesis_balance_amount_stc=balance<STC>(gas_fee_address);
         assert!(genesis_balance_amount_stc >= transaction_fee_amount_stc,
             Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT)
@@ -735,7 +735,8 @@ It collects gas and bumps the sequence number
             transaction_fee_amount_token
         );
         if(!is_stc<TokenType>()) {
-            Account::deposit_to_balance_v2<TokenType>(gas_fee_address, transaction_fee_token);
+            let gas_fee_address = EasyGas::get_gas_fee_address();
+            Account::deposit<TokenType>(gas_fee_address, transaction_fee_token);
             let stc_fee_token = Account::withdraw_from_balance_v2<STC>(gas_fee_address, transaction_fee_amount_stc);
             TransactionFee::pay_fee(stc_fee_token);
         }else{
diff --git a/build/StarcoinFramework/source_maps/Account.mvsm b/build/StarcoinFramework/source_maps/Account.mvsm
index 6c006a98a4020127bd95fa5b0d2446d44ac7802d..afe77bad85e6f4753d5625df59d9faaca25f9372 100644
GIT binary patch
literal 53164
zcmbuIcX(A*+P8NIkc18)Akq>#B25Ho0*BHyLdK`bDsL(v%#5fx-CD3!3H0Oj3}lM4~jtW8`rw~C^USY4ouEHjao>~H#pjEQkr4?$U3W>zJ~84S8i
z*DNQ?j4A6lZ9tcqh}8$m%Q7pLcbrSQPpt+Ak19dt65^IWLIz
zD34qftlA?JaeygZwnqo7`$4ydu?B*L8oGq81Wrgv|KP!6)UB?Ddb`n?+vEuc5OYCa
zS}In5(3h5iH5K#(pM2A_P#gV;kr9IE6fMy2F^5<+TQ|%&V}~}Z-&(ctD8y28Xku0;
z%3X;2xG7kgMOc$SH?dp4ZsHFp?RwKzQ#79i&vM>;W
zl3cxBvbyJ~J9<6JYYcjc=ay*^k$W0C&N~o9NE|~yWe$n-`NtLw3ltRP=J<6?^G1&20o^Zd$LbEcUsSzmTHKnojUDG81kpB!(BCzOlpiuCP&mwI
zCg?z6p=yvBgY^bj#3Gil_4Kp~>o?F*dmigM&{6vy)>Y8kt$Ixzrv>OuR2WuE
z&|4#8wE~Na&%MiW=0Ol~F(3U2C~3PvS%Lfl1Q$meIARw>6pu_cM*I;_8oV5IH9A_Bl;2VxL9(3?c#F_&-_?lzQ1s#0GdKfHv^}BbI
zii04!z%`?{<&15+KpEu95L_3i$q`K;$Q#;*Lp)%@Pu|cqh_8dbp);|zg1(^#v5tej
zp(n9Ufxe+9us#Gmn!bV6qMglXdL1(qQ;(*lu&RI_O{-$n13j8vp!WKhdNegx(-JJy
z7wPjyAc)R<6#YZ6?#ySA&qHvX`7%fR3PE<}FhVT~tVX9t5Eq-+l->Sutd*cU^K)1m
zL3iffSern1W@Bvzi}`W-Jv^oWC!};?pkQ!7=17(yuYid1Hy3QaK@*Dta@khBqvJGy
zkX$uil*B3pH`aG{i^4PbUqTtPCM?VyTA;5ZvlCe)C{q{+47R(5(j6S95=0aqGR$8%
zOkK-+*dIfM8*OX5#=UOZx4q+3EDVeu8(=5xD;S$UNMF<491{y=3yX4mmYeW5@jn2E
z0YF_&UA%^%`+qsCMxgt@d#$?v51_o^p!GuHD^
zS(;n0_COVBzJRqCBBl8d)*Db&nwPMCfGBC6#`+PeNz)x_s!KDRfiePalcqZq*N|po
z%4-L=OVgbQYDzPK@)DtzG<#xYLv3j$VfBDI((H!yE<{UnGS&i!k>)d4YoMMq*J7=M
z`qEs4wH_KsbKy<1p)_+bUxr4~+=I0j8cTCO)&XcD%{Q?2K~rh&#M%XSNYm7O5SmHz
zI#xLAf;**o2{Qt-xisD7NegLqq&zRQlx8GWJhYPLSgh<AF^W8E}_0-PKbYY0js-
zrEs@2w_)vvw$faVbpYB)a~{?~u*m;3sn2TxK(hAVGK;oLwnUEX4?(3RU*dqxrpj==
z_IeO+xv4;2^M0(8px0inVVwfK_Hxfuuf4vdyk9`Cy?(_i)4*mU{TXIiOuhDs!iolq
zrAl*hQXNfR%I+a&C)BRRX)Gs1uWri5FdqO9fO7n!)VjJJW5ej$q6|
zpl@$7Rt{LK#yT#gql0C$4M2Us=q%girENpp1^UvS#d-yFA76>}A?QX}gmn@u7Md%T
z@hT-)Ho`8{y+*fbgxi+0fiZ>s5+Ad70-^)54
z7~19d+Zitw^i67t6$knzx%KOtG?MZj1ii+{z?uenjggLJY@Odp#o7gWjj;x6Bk26j
zqgb0j=XZ>?8FYTfJx`srIYxPBKxb{vVO<2ht~rGD73i#uu`Yo{I;3@X#wiFQma23&8f;a&Yw3{z6Z55)^S#WQ&Wd%
zNxX8PL-ZF;q&%h$(VsDmtwZz&tiF_~Lo^O68FYx&#!3MlqSLVEfDX|dtht~=^i`}q
zphNT}ti7N^)V-fN1$&J0{suaj&tm-pbTFUBIs-bG-^RMvYZJ_YINl%uor3L()eCeA
zb`;hm&?(p$tjVBLupeN30y+hI8tWqH6znCee}YcIuE+WwbPCp3KY&ibHs=1c2AzV9
z#JUS~3fA27E?{x-yC0-8f!#j#Eaqp%w%O;joyL1sphvQBth+#uWUa7TgC5CD%^kqv
zwoZ)U9Uic2gZY>XjcwBg#}MBK-3FVmj(~21!&q;FZUa;E2Vl`*`_EzagdnEq5$Hwc
z5ZhJpROH#_0H$cRAHJNCgXPru2Y$p{F2Ul(zRkGXP5E*id=l$h(2czl>k8<`UW>H}
z^we37>$wB;)ahQmo;p`j-b?$FzBSkzAp!kJ|;tiu(!Pc0?lO$kjkWtc>vO9y0rzos@LC2GO&N`k(Q{Ka%
z<7pn&Qqb{~fVB*CJnh5!7<4>6hxG~QcnYQ6%Ycrj^ORTC*zz8A#PWcSr^Z;_LC2HZ
zM|3<*p}aYum!bo)MuOf~9>n?@^is6dY{%&YdMVl;YY^zA=r7bf8dEPtAH$rCsh6V0
zngSMUylFW+1cD%@;lH3i57w{Wtw-JhrR`qt-HmzxtT)L=kxzi>=(7JN4Q4w5dW>m-
z)fMy@GX-lY=rQJ1tR0}om=jo6L60#`fVKiX#w@42NK8G(48W{v%9ZVDtSGS9B~11^
z&JqZsuPsGi3D$jW4e~~?>}xww-vH~rb{P46und3EH4~Sh``R+fi^SA@EgQ3{DOdM3tSBI@rIsC)o?`R^*8Vxe0y!hB)+)Di
zKm&6Stt)FtL(B$!bGu@BLEl_s_5+JIl;%!i{SEfJq1D(MAn1hu_Z$>DnW`+dL^bfD
zLAOe2tQgR(;?{4`l)&bC6eleD@b(en_D}0JgM?P)J!_*72LzrQhdST|)
zt`}yVD6a?Tg;_LKYtRd`0M^5x7iL*lkATIyb#eV2#|PH0lIJ3igpjiT_Ik7$Dt2?g
zVN**r9rWk$&YKG4@Ng9C3((!$tzUQV(F0i5f$rWJSW`iF?{q9<>+anHYY*tI_ypEp
zL3hPzSi3=YMYnd{6~CmsZ$Wp(x3MmR-Xk=1rcPJKVx@vkS2w}x06JZri!~2)x;h(cK3Ke9`&C`EXyBj41Rfvl
zIDXKv+yW~HbS&p%jR&W$93Xy~&-lN9>g_+MRR%rM9Afnmjarz|#&%SQ?NAqVikgJIJbU12+pFsIiLqYw@f{>?WMc}pcktzV66kaSaoZsN2(d(>7i5JIsHAo|jGSrc8@h`)i;zH>&l6krvo(%@Hn+eNwiRnT=x{f+n=&na4B@HAD~VtkXj!P)Mz@)O
z<|8fw-LOSilR!7DF&BfyuQ#HeWK9EhPa)f4wl_8>A;WPf;&9McHUw*uDYl_3v~M%M
za|cd|U_R7Qz!4LnO7Ndcna^P>Af(cNzP_&p^tN}h;|G58AusDVHGE-ek>&xc3!rrRYz2LqKmS60wGY-cq>t
zQ*S9Ap}Z$RZz)D&EdjlySdFy>^p@fstaG5Z6oZ_?UV}!m%xbN;ZfGpcuPCn`W)o>n$C?LCrJ05`AMTLmXINiDGiknx^$px9&8=L~
zHO%JHd=7IBw2e+X^KwR{?sK_S*8
z(5r%YtjVBP1@}?=Bba(s&T8
zVEy1V1GyiR8s(oDkZ;-LV~zpK$FvWj&I7Cc>Se?qK?m+NtlvNf?jKmC3T*;6466+2
zztOvf
z{t)sp2q|6sf~WjuP|cyt*1&)v$Nwz6zM#8NKdc8pccUDvJkaC+pqr-dMh!6YL3bnf
z>h<{l0_Cj*J^pXQ+6{XAKZ>m2Cu-&mi5#Zsx`2;TdFAOhn)^nPId-NZcP
zLa+;tKVi-T%ivgnx(cj=<5lEcU>h6}c}!4X6C8Krbpjn6_hQ9@4vu)NG|<7}y=m&;
zsDjxGba1#=uY+SQjJ4R-_Sro
zpfI=4_CvTWIjpNWl)fOx)I`KIBkOHQ*P8rY384GheSWPk@<6!dx0`3za-1h2n75nP
zQsHanETi?sAHjPcbj)nS`T%syxb^Fp`I+)ca&D_*%6Mer?UQ}(HL|=8R&Y%;0$0_q(
zOr7W(fi)9!qOT{`EYOL*A;(OTnK_#!hMAPnK{JvCu3hBe+O1O%`R{8mmcY6-B^dfBBxi0R%&XR*8csKJJ8#hLu~IxXXIEg%^`cz9K?mDbZHL5S_JxT
z7;7&G%1azz_c--3=2c_cJb}-6kguqKzA|GD0o{ArVkx
zdSEoxYOwe$-CI6>rw(@Q`Z?wWW81WA$^+~UK)0(g9{}C1cVWeXZr3STD?qpFO04HW
zx9do(RbcTEzk1VIl7ap24Lf7Ug6;1OQ*blEG=_}HHHaHQ-;2#y+d)U~!&o~&-!)_H
z1dC4^euVauQLR7Da}E0sux+=989WsRt9BcNI2?4lyFkz+>Dv
z@>JlI2(`#Fj>nt?)rw!e2>LJGJjJ1#A*8zdB6v>mAGP)I2Vq8z9g`yy)L(G$Z(#GJ
zsOETz=wZY?Q$38#p}ZBKhmi?b&wx&GJdgDP=oH6Ftmig3Dskdv!jKtL2HDj9E^>)oz&B19S
zN8#`OjP?XrzE_G`%INfHS#}QMP|#tLjFk;~q-uqg3l<-Pt;(gfG?!<+`fP=Lk2!)9
zkyn?Fm<{^sjG1eSZ7U0H(v$D1fK$TqZz*&|_CmOM+s)>i0IA5m!MagqAkPINUY`Do
zcbTvAxn0MMR-d=cb%zN
z%RqM>_jGmF*-d%-KzE%NvDSm`I?rKETWr&Hj$?*n>NzzOD-86U`YC082RZ@k-X)!Y
zZA8s?f=<9z!>R>(MmJ`C&@;L*P3?L{H&%1dGkOMAKhQIJ9@ZGpGx`9mLeMjMPpov%
zGrH+V)4{n%22$!mW*e{{GKOQ12FoF1GU^Od0nsAQW*_3)pu_qo)(4=&dOg;0&|z(?
z6X3L$Cz{%WR3})^yn~R3L9l;er;uZ2g7pNv8hHcQOu+Bp9XEx`>)njCA9QoO_3P%o
zMtNaOY0%6Cl;7+)(GX$&+LYCKw!ppzD*x*UUtx|v&!Vmbj_L~~
zZGIhDu!RI1;NGQHIm7V|LuAnye?g%?r}&Ta4haN&oT55*1}F4qi2BcCtv;W9fg^tf
zo+HVQu@r9==-##(Ydh$XVHeiBpht!sSUW+F3@>242zq2#g7q=zk-=?cJu;N%K1PFH
ziIu}@3VJ2h4C`*tE3tN137}VEzjNJ*n0h7V_7S}jGkty*=#|(Uthu09VzaUS1bQXr
zMx0)W&8NI)K(EA}!!l82gdbzDvwu_>fnLQNVzm*j
ziCNd!mhURR)tZXk&0I)(lzl(u~l;41RZP{yoB?f$H6xs5zMg2)?(1odZ6
zn{r%d2yW5blOy^<@Qdc595n%MWzjr`!fL2b0TKKZ71ju47eT#jgjG
zN?3J4FZ*J!T7Vu*T48xW4<@l#y+JSg`e5}1J?vy-^#eWZ9HEu^V>6QDe%S*-
z1k_UWl@MkdP@9prLl6OV6#XRJNLCb0y;3;VP%01%p9yypab(k
ztc9Qh^J%P&paXLg)@IOwxdrQ0(1E#^_IwS~=^_Jj=q~;~6$BBOgl%9xhP)ht
z2+Z~9ufweb=3$OI4gYOmUZRXLe+@P;qdB5E1Rt24IVuHiB`^nY+(@ubGd+ks2ZB#C
zE#;`yP|7CF6tj;X*TKL3xO-0VODigC)cFm*=Lom|XV&P(_m*uEPpx-5PEV-yzZ7AW
ze@do+VQ_2Nt490T%7K%pmoW~tgn=F{KcVfzG4(R$F|21mkCrcE?FKzs9>qEbdbIoo
z>qpR|Wyw9XFzC@TkMgQv>e14@b9%INJBr>tB~o)b=-pFWtPIe*r#@JPpm$H1SiM2-
zo}#g~f!-4>!+IHXPHG0$E1+{yZtXfJ^(N(g0y-yk2+P>|=NbF3F6_1Wc}5ggThQNO
z3CC&&`iC6Dv1WtLoejmx1)V#K!#WN6=NTKY-T|FETY_~AbneWpUH?2|7~}OA&{?(=
ztbq_CmnZH#ptEfIDDOk4FU$N0>tkpj&68NCprJIM#o7Rktjs-_jjc>`o=v3Lh6&aK
zcSzGr$K9csm1!pKJEhqdYXUTvW&)NevxPL{v5ehPn(hMQZfVx0ye~k%qqY<46KE&P
zT#xlP&@U~_#aaUTIlVF0fPQpqOjEmlXlks}pcBh(E9pJ`_mo$G)s5a{RK}_TU1fV#
z#Hs|{qmQ`wOLGq8Er#yW^ka>ISZS`p+6!^g?1FU+ywY@6i}BKoIzTUm1ZiHT
zW(PA-n(eVtAW531DKizbhcsWrIs`qX`6sNUkSxu^SpR?&X^z7B98#ru73((oQkpbP
zk81!HUAf9LOs^2c&blso6R^%9cSQC;5IgHk^nq|IJL}OLHyi%jo%Q3Cu^EC(dA-FE
zA42du>(4pr2Qax4d5cq5k~jjr5zE2K2fY!SjP)q!jo4FIJ3(*64r84Jy%GBy>j%&q
zvCwC!8T3Z13RWcOjaVaUu7hbYrmuLO-3SB`GOwU-g>c(s)M4cJAc&Cp2l_W~DBA9&A^4Cf%dSxKi~6UVi{Ru6#>d)WX!`$^@*LpvRR0
ztXZJPl_6MrL5~(Iuy%tUEgr(!1A4S@Yu9O;Mznh?&}o}0Sgk>)Z7O3KTc>Rzu<}7C
zW0J5&fPR$S1}hJA+QzM2r)@r_ynldB+w8`A7j)Xj?e#isQ|cwk1O2Uxe^PT*Or4Cm
zjQJ7)uahxvQr;J!lQG+{E`UzPEXVp1^ovYiWBmv^ZF3Rp66mzebgcB%Hi?rMtXR;A
zlW?p!(1{bbcAYpe=a>OHaq=_PZQMmdo
zP2%Kx%qo~Vaq>6JNKBnLackF!lRHg$pc5zYSP7sLCvm1cW6Pf01ncDE3_nnx+`9QdSp1k2bD
zNb^ms!$gN)n$@xHfkDzNgVi2#q&W<08Vr_Z0Ba}&q}c;&2joigFId}PxHM;AZHE!k
zbZgI(X8bG6#gH$}`>{qqft5KKbCfjuVGV%M((Hn@9mYy?3D#B^C(Wr?+hDvj-P$Ke
z^9bdgg^AMqJJuDLWMw+M**is==P2(pm@3WvSY0S{nlx)-b%yEEEP-_|%#fyA`%Gz?
zbLvnd*m{eW{1
z_|OV#D(Hs~tFbnKe)zB%Ya8fyM(1E{2aAkHvtBIPAc&~wj@}cj|DsMNa(}Rlj3KCb
zU>zAn$Wx$1S@#=>g9ndM@0!2G0ms38_Gh_*_=7{r-$&E(9e7p6McgZ(gX$#Kcc6zx
z_q28Rwc{*3pu?{cRt)IybFW^9-^Y~qIq0W^JF(7#4%8i3#@2zl8LM%+O{n~a*$`7d
z(Yt`z2va}Nb8FX6^x9HhC(uvyx?*(${Y0-bRu|Au^jc%(gMOlyhLr>QiC*uUrhcO5
zmZ_iUt)R>`pr7ci!`cM;iQX2houHrSjmO#r`iWkf3?dHn6TMihB+xHnSHbE5PPMQU
zPhVeFySt;D3ZA&QbZKrG^2VkmrTRD|Eh8z@mz3e_=S@#5
z&HpE*W@N?3C&eatQ!{qdlSsLRB>v1Q#{G>Y3V7Pm^ohxPU18CAnm41kQM`Sz$~rOsqhxsR%kpyJzSOLg?p#%7TAHtWQbGmg
zqYxAs

literal 53565
zcmbuIcYGC9-iId%AtY2G0Tsa{bdWA0RYGzhfizR7folj?2&4c>kRTmF5D-CKz=DVf
z0*cZsbTOcUqUcgqlwzgWzz({;&jDt4-+jyXT$a!0`G?Ol=ggcrzf*oQck)Dor&_$b
z{hOaQrF}ZK?xm;RE&cA~qFFC?`Qy@x5s5S3J9u=M<2VHn0RQ?gAS5Oyr?8};xQgRE
zA<9@=)p53h6QIn)SSKMsmRS_!IOD+yQDp{|bDRiJ-jZO)SqI7+7vebcL3uynl&he<
zJe=_s-VvO$7T&B-$5{k{@(fp8=QtZd-AA!jZm$jM7m))lg2D
zdvgIRfb$HIWzMVQILkqo`3lxvs36O%LhX^}JOkDJ
z>4en_ls5<`7eb|3hq!2N6-6DfxI;=+nN=%0&P|}>Vi;CFsC&5?XQzc%nQzoZ(J3+5DR$_ewdd_#xQ_s4;Qr;h+=Sa6qi%W`}
z={U{6k4|$7dOLGS$dK&3?1CJ*;_Qm-0jrT@2I5>(y6g-0VJ!sR7xJ(k28$b)HJ@n%
zEJI=p>R7M}i8Y9AAEIoFkl2g6&lD`1VI9^c(9Pi1uS4P@<^3IWNF2jD4LT%@S)Qxc
zOIG(hbw{sHc}+ks@!T>kB64Q~=3($7Bo3e-F^AOfW|tHX_Z1Z9=42P=78ZC%`byR4
zcaj5t0ITq5-q3MkK=+FqvAToq7vWb;n_JV!arS^8ZL=5sJ#$FqyT|y7hI`Ef?JFu$
zt#Xt@zA%SXEb!gqwOqqhZR|KVf@878Y=(C`=$5R5)d6%%y7lV_OQpOl&=EEmD-U#p
z#bV`yo^)1Yy$(7SpTjb?o}N}<{Q){^zrZ>VI%?m?x&V5+72U*fT7cd}gbQH5)8?^?SFHiUU8o
zz^_Jc#~IspfiUFjz`rg~nenZM(R-@(t$973o?fYs>q0OA4@o3h(KjI|7OXI_r=66ns{
z2Wvg(&TOm=U@<>VY0qN{a01E~`3i>mWR7Gp@=^$`e09O*9a38ClgqYR9UZ4W1mvpu
zq8wH*Tv^}QEeb!uKMi4KO<0sWtUzB!Mkg{;5LV>#4Yj+5@*Nzf8iZaxWO#PbaCI&3
zWB(1RTxna|HSQ(TzPCG0)gs^M5+6HhZ$U}^5PeOza!f2#EGo|NT5iJM#Qy*s1^{(A
zH{&$`-Ty0LH3Z%N-D}nTKa284fbRc2uttI&%-t5#OXJg&_cQ3h{1DbJpa*le?e$ph5+=Dk?+AWE7~VXcN}X|BOq3-zS=
z5Z3chUz+o;nhm6xi}?aHl;%#XUC>CHZ(x-{V`;vQwHum9b1T+1Xev!p^B!m>%}ZDn
zSQp$P&2yNcn9Zf>E>BuWvm@nsprtfxVD*4j(k#K60v%3B1t
zO7m5$H=vy~mtd8_ZPJ{BwFfNnKaK10S^$u&{g=$5?UF5?BL{+CX~|U_u)$PWL9e|g
z;Vm&0$ZLKB>oDlG*Ji9Epx0jRnd-IIx0H7g^xErptg!kv8|hP+6*2YND*`JLES4(G
z$w_rIc`3VxoSjhbxSYmv0`%&pVifZM@Bk<$dz4yNM`JcHHg`ha-T{b%Kz9UV4gr08
z6R~o@Vl~!zG1Y@*vkgWaVsw`6^3t{-?f`vh&tSa-x{oi%Is&>87GfO*i-qR0C62Ql
zEE{15>TaXkG{TLKu{;6Y2tioYKsQ1lRy)v*aDmgj4bx%`oz%^7GQf{qP$v3d2&^#1
zm*dMFtGBeHu*X4IaiMppZ&YDXu1q-3L4OpiT01y~u>y2!SH-#kbZghfstdZcKj$=W
z#vzh&frIDcR}v~fwm9iQ;_>WaItx5RE=7rF~@>cJHLqdGU#?*gS8EGJMX}H
z19Uq-j#UO0ySRh|x+wV3&R+E45NMe~8;yGp*fsN1%$Z=OR5^lvkN7j_X5NQ&40JPB
z>&1=*bTik-Y65zd5P;PbEH=xtI_s#X1W*jb^NKV3Bod-JOX8
z{0O<8=&2B7J+lwN9sz#D+(h*Ip+df|ID2SzakiSGoV3s{}ekFLEN4F?ERkhG}daqCa8vqf8y5aaf6f*5pW?vky^nlKZ
z-+`41Iww8~Ydq+jcof#XpmX9MV0{ESC;lz4Ctd@q4d|S>x#wNM;*xevcAOJnmsmK7`I)h8HlFRLkPrbql7(U23VI}KgVh%F
zNM>s81Qs`|G>Vt1z^)DEV$L_VO&c6QJP5iC)?@7l-3D)C?E~Egrsfa8q8kpH#oK@2
z#}u89KGqy!yDFZHJkuP&6wQ9nn^QPcPMra>N!5YPo0gj>d#fp5u7i(aeGj^^w_{xZ
z-Pq4#Z3I1aR^fVX0X=oPSFfke<&?J?^wc>YYYphBvlwdz=&3XC0Uld`o;pWjm4Kc)
zJ7L`idg?sLInKw_Q>U>W0*lf1!D%!T*l+sQVsC&DlkT^8AA37)83fis_KqnmzVaqF
z`Q7Xxxp}$8@`dg{I5>PdZF%JlmCGAOwSujEAG<|hUX)SNp0c}wj;C5!cYuy3_ndV+
z6;a+C(D5`6YYFIhO2B#ybUc+|9RnRtE3iHW9Z$iudnM5E^cCe*#?xYbfZY=|2B7<*(nPBu8U@Ai*G9t{B%
z|K)vkH7)Jpfc>VHnmXuD;eBN)ki)|Ptka;ow_CsN-bI60*MaWdnOKuSckc`=W9#mn
zi1j+?uDA$mC+My?6>AshuISdTyW&~O`yO;xdUt1jq0LMhg>
zp!W#hV*LhskFXJ|g4bq`5Mye_)ahyuRx0RpbyKWPpwrbOvF3qJR}aK`5S*K3$eq0z
zEfV-=F@g7pWOM-?%Pp{SK*w@E);+*!sA1>#c?8IVRB!)0
zX@%Y19AVS8a}gf~-L|8#rh#tTrC6_m4&rTC`#`tYYgk)Bhr6lWlxgvslbC4U5e3UY
z%S7#ObejoiF5*L=8@3p0Jm`is<^pgU$e5}11Zx_wdkWbev!k&&30ZV5Vjk!#8;&)>
z6x&c1+OHWoRd53R`Ep7DN0dT!|G!@|m&2AqK(&AWJ%yUv+ug#iV1OUt$jkbW8oo5O
zNV5#JHptlt6{nT5E2Pp4R&|8YpSbqV%rFaf&Bj_!~yI3bcZz+Z}cbqYxw-gPrrh$I!
zP#$YK=q*LX7G&o@Zz;x=AJJGivgu|
z5#RX(Kk^G5(PP2-!D}XR76gyVF7?T`>?nYTyLqK;UA65bAZZ!0&
zsk>1_%tFxJ$h~?!{;#6E=RuGETd;P49{&$u9R@xAmtvg)J^mZ(Q?OV7blx6&u^#I+(7};~RR%gZjI{?W*8JBu
zU~LYhy1c`D1-_!(BHJ$$x8$%p%%SuJIi|)VrWjdoF7Bw!ANl~guif|X`XLX7Yks@=
zzMFUz68w3)c?}hAHfI^BFMdDXLC`VtD%J;}W5%st$INe(SB|UGG4lmxFs6=~&oPay
zW9DP5PL!#8Z5^x*pqKO^SRFwx>D}7(l70u}m4RN;FU8sedP(p0E1l^3gYqKk*d+RD
zVRZ(b==+c|yI|@>-$<-!pc8$)v8IDg^ew@93Us3HX{?Q)({~H77K2XTox=JGbo%ZM
ztka;=cMa>Z*$17ztAKR_==9wm-r?aU#zccUw^2TXIwo-`YA
zfhk>@Bd`{Nz8l7R7%aYLcW@Ffae&?9)bp4>8k@;eo^R%4ek2e2%8WT2bnoei)f;s0
znS!+fbnjV-wHow#pa^RXSbY6&-(4&+z^+}t#5`kcn|4jfW_JL(U5z;ebi3Y)DgoVYJ+a1u
zZZ~7y15R6cgL~XVo(i16Ad5U>Ddq&IdHK}~zyI{mQV!h&0kzy0!E-MEm0>S`p{KB9
zjQ-PJr#bjfuz6BcXPo0ig1!aDYz4Yu1F>p=9!A_V)x*ea%3B6{7#WZCH0Tt^vskM@
zr#O~ltpJ_k7=v{R^mc7G)(OztwbfWBL2uXG+Vytr`cl?Opr6&8qvk+Ny6=S+^t^^p@%8&IOrktHLP8rhfrgF2zm%Lrm0;Ip~gA^
zPJ7u*wHGjdfc@H|HTLaL-dB)4Bu_qK&#iv$6-z|h36C&+?_j2Jv;mx>Iq=T
zl2^JAZwctGGa2hK&|SwpUEOtdQC=D7uJat$I?!Eb1=iGsHeKfsW*DZPQ-iTW4YEBy
zrOY2pxzcp+l1{)jrsfu)6R_7~)dfAH8?yoE8Qqwsc0HpTt0m|eJrgSn^o(ABRSbGY
zABR#}#;oWfyrzjmg#9-@kIqDY(uYm7hKC
z@{uL{*-ZJ0&3C4@jSP3DuFFTT=g!aOPi_{-1wvJhi-u71=fAAZvlVs+xb7cEc#Cqf
z^DOF0;HUvm&gR#Vqc)L%1Kc)hm6M0JA8Hhj$u20$&bj>8lJEBUyquysb~-2Y7l`=x
zW39eteug9e4m?Ma9b*aJO3=M+4c1oBBf}1?gP=!-ZCKkuj|{7@o&!BHEXFzpdSq~0
zS&s}=xsTDHS7KGLnt@)4HOIOQ^h)e@tOU?2F$b#`=#`k;NAya}^!XW}S7NiV9ss=(
zn~60G^h(T)IK2{kkn)}ey%Jl2WujQG#Fk?{19~Oqo~M2o?T!ojVe}emUJLqRv|FZr
z#JrjE_JMxH?3NiR$B+!l%Y`Uu9>zKY(b7DJC)ke4uW|Xll-&HEZ-3J7MJo#~W6HM9C9E6nvdZf<6GPWM6`(aIg#A>9*Tnl=n
zUV!yH=#hFJRw=dX@wX4w2+-qiH>{DM$KQ@uO+Ee|<2+A*9)I7(IthCGb^C}Oe=BpI
z;h@Lg3)CEesmEV)&+h}Li|lsqyu_a!0zabbZ|I*wdD|BOenh?mVP-vQ_ji7)tmkDS
zsBz^Gzy1zwGmh&D{w2#Gh
zX*RRkV(=rNmY^?(5Zi#-guE5}2&e<-N8wrm>Kw=Y9d0(k_&N1)sh2U2U_A|bw0se37wFOQ0M;qc
zqvdy4zk(hu%kScKZP24-0p(qfsYgrq&gs$8?I?Qp)Qg%kK<}Q~V`YNgJ@v;b0ljw#t6pi
zVu+NBjufoBAWE9d7)c!a4@^rFj(VZ_q%R&tR>GhF0e5n2oGVbDoW*
z*^UV|7Me=aOviE1%*r$q_bt*KfHfYPOEUq>l-WX>@mR)gDNT2QajP_Mro7Y8PMX`X
zJ_h|Z+d8aIK)>ho0M=sAuQwQTE$Aou#x%9-hrGr*4*Kz`+e$h~_A}*GV|Al<|243}
zL2pN{!>SJ58=)gNVC=+
zdK~nW=6Pxk#Eh3_N30Y`kmhm9OvUUa&F8S*g5J`cg|!3{rMVyL3rLdY7_2WLS(-m$
z-AG?bk*4W!4Z)&=hA(3(1V47xQRq#>zmVzA5qE?CAydLpGr>Ng^eFaHQb$z@mTkP
z9#=+T%>X^F49D6HdbC)EwF~rUaX;4UphpY0cAd6qOuM%Mowfvh^DSWA$%++gbk}+>n-f7Uum@QamKqq4!$2tr8MW%1Deg&PjIfwNP=(No=tc=w*iIaL*
z9?*%CFsvS+6DMx%I&osoF%xv+GQ~-;237``vJ+OKjWSLE|4z06EoD^Zs
z1f4h;gEb#?;$$J#63~g0hp-laPMq||x&W#2+IM4p26swxE!O9dCQY~YbZNGDfw+VW
zY1YQ-0GZMphBXEHNOLIG-OyK>J+ZdJKxsaX^%`VJa~jqb7$i-%_QBFTKzXOYE6sPY
zjD43h-^SWcbYx5O2CNP+M4FYbIzo;#M_^5bq0$_Nl?y&;CSq+fwltr>+5#h_IUQ>&
zjFhHZd!97oU!=!DzBIkYf&wdZBIYP*W?>D6(bDXOwG~RFxfts;7%R=mSX7ccZ%LeJ_42>B>oijG?+Yzywt=L$4LjB(8O8k^IV=i3W033MAIU=1?G>Xlzk67M8}
zA0494W#QGI<$GC{alPrslaoE&s
z`mkO&_v*#O41P3p4tgF0mbd%KLJ97@VA;+yQ0IVotRXw!kBApRxAOt46QJ8UqBj`^
z&;i&4t0k0^=NXLE3M@7#AM_!;1b*C+bLc;U)i=n>_a&tdmbW7kwINt_`^ONU1bsW6
z!g?0;?O27i2K4R7#aas%d%K4H*;#=fjhu*{2|+;?Bj_;15n$QKQ&H~+>#yL?M_vR0
zwu9a0$mf8(w(P9o14zPxzKh0e1p3~5OWl8h4i)!IgXMYlr{*lsk133q2m0Yd0ah{S
zhYw@1CV_tV&<1NV=!Xw$u-1cq_^=6U3+Q)7XJc&zix)te-^p46{D_J;^dzwUi#mOf
z2Z3c|3`Z>h>&O_3JP86Ty04oL9Xdw6Yrc;I4uSjZ&vFG3kj66|;8B3=tmi2H0_dPR
ziuD8Nq0v2U9e%fSma(A2uR2ye(BbD^y$-))l=mg*r-a+Fz5*Sn+pvtS19cNtlXRO<
z`4h7drhcM#2D34yexm2ruAk_&r@StppXkM4bqD=KuPatJ&`jc}^O#Kom~($l?(p5&ex@pRs}%%r6L-k8jccyDh{|3D|)6X!`y
z^Tftvc;dW0GLvI75>k>w`0undZ$?UQPqH^TCBqvN8|z8UsNqC-Vp9^5y&RH~o{-^9
zNcRr#q@|SS{}YnaGkf$%h)wV$XL!5EB*rAidMY?Kdb-ENc{9>tlG9@@m+bA~@mwi4
z*tyBnk)F^q*^}mtNlf#^#Pz4-L{Cq1F4dhno}`$>9w})_oR~RZ3QpiOIX!dcVNP8R
zxN>nZ$yW^X|K6m8^rV=K*!UoX)U=eul%AO$Z)^-_l^WCE+cPHJJ^M;dwnozsA;Ea_J}xb$Z%iW1m>SbPAu%C?9(47FdHP*0#S<6q
TH1(MFPfN+Ta+Cf)In?4m(qVb>a>?NQ7J~OjB`%agy6rwP=0kZJ#Tb0
zoo!6H=%WOu0!)@N@5UN!(c@&C#~>ufel*J%2TYC{dl}X$P~Ik-cPzX;IA2?MCveU}
zmK?blt2=}`)+Fm4w`SgKM_p_s`T(zq68*jl^#mL!GUhaxP+r<`<4#KT{U`Dz$jy#L
zXDfMIXJc9+To+A8ra4X|8jq)(bXv7*q0QUS?SJhej+;r%Q>_<~
zC{_|WOLHUEb_h$e73+N{mgWmsJE26H{vzul%`fQh2y~U^QLM92D$P%^_Cq&mp2KPb
zizPR(gE1o@KqQYu9|QadW|b7rW4`4LAk7_Er@Vgk@^2#LH$Z@^-iW>xOip&cKDVi>
z-rdQVDI`Ab?KbX9xK{!{{^zwn9}
zL(jh7tDgLR^j8f!dmXG4=zQZI(z-9)Y)53J>CpDdoMHcU6?w1hhvQcoxQ`byw#(#cWAq*vv&yQJ)pDKpQSRH
zIG*XP-0sq>$C?j4q#40l06nF-1ZxHKlICJ8?>ft+xv1T|UYZLrpN0x)`m@wWn(s27
zuh8d>(tH`K1#Xh2-)DbmzCnMxV1Sjm2h$?Lii*iu@P0WuZ>ONn2c5U;v9^NF+XGk^
zL8s_f?WTqLTD~#6A;25-1N6^;ABSo6mO6&n-FutsNRQ_kGY0}(%UtwDkY#y-Ys6g+
z1qnBiiOh-4Y>+3bajlJOlc<|Aut|^mA{;`Wy6n*0U~x#Y^#7K02%blWRG1
z>yXz&x2wC9_Vc0bp>{hh_d?0l*0YlFhM7*pjn0zO{~fJP{o68~Nj1bWRxPtxr=?IB
zk7lBgbh058lcNp5zZ1MSyDaS|5f_1e*h{chgMQd+u(p7H*so*l1|0_m2;WUYh{Lx*ER)vVxvCrWP1e4?(~7glSU&HeY+rb76dNuvi@5V1_XD;;6)W2=wCc
zuT(FNr|7Q<^x{~KwHEZ^coAz8=*6)aYdh%0;bOIdK5_U@SD!e3roVHbPaKD^+CZN;
zKEc`t`o!@O))>yE`ovL%H4OBLqc_%Y&?k<3&jNko@XUKbpExFC%>eziXC~Hs&|iBd
zVAX>D+Oq&_Ay^bsVJ-&~2(Z)Yh29rzcUrgL4u+1iQ%)?AP9$BmQyhUk8bU#1X)}%9
z18!Wtvm5c2dxJ=G1=d>7vGfSmI?%DS6YCeyvE<*Aj-_F2_{M>br82AsLC2D3jR%Xg
zDP@0O2?0v!2J|YhEu}kfheEE^e!UuVELiQ=mmxj}x*VFYR)Q{vsaVaR%fYi&fyIaU
z(h`;*1eoT2=(j>ve#GwYts%%GATK)0=D(i@P#=cufd4gJrcF^79_N*_fJ%iH%uUc~
zZXz>1o{G+mSp4@^O9KbUY`M;#;c{LDT>|^D4uUR$L5w>VbO{t=jRTzs*QQP0(Ng+r
z2Av4gu~vaj1b;^LM&(QTI}CcGas=x~&>NL4SU-W@s9Y--IZFjy*~fz3sGMfxGEBWu
c>5nx5^hTuys}}S|r4nm0=#7eJO#x&60rZ$U>Hq)$

literal 1352
zcma*kKP&@b7{~GFPTOl$dqtXb5C)4_NF)Zt)>wo=Ooq$l`c@=zntR)!O`7=ANDNkN
zB&Kdc3`|l(87vlIFqs%lV(}w7u>5+-ck1VPukSsT!ueaHRGr_+jMw)QgJZRP_F}5v
zh^#(7FT8k}(W|6L6B+XNF|4es%QLRV4;6C8o-J~W#9;Co>K>W=(90f?JM{g8IFI&<
z3?YO5+c~HuWKvm!s-qB<)nD1h>)&zxcnX&?Ek`RqrvmoT($Ia#UUs#USITj7xj<>n
z=0-3xjm-4FK}Y$;pv=Y_7=8G8t@4##(T?kRYbC$P=8BlvLekB*whecN_|{sd@~yq%
zybshtxAp|}iTHk7-y%%U9LB9DP=v|>s7Yi|8H2J>l*%yFE{aiEfLceLR4S+q6sK|)
jY7up{B{v}xR31T{pd^*2P)%f0c>r~YQdHhR-6D}MqVUd2

diff --git a/build/StarcoinFramework/source_maps/EasyGasOracle.mvsm b/build/StarcoinFramework/source_maps/EasyGasOracle.mvsm
deleted file mode 100644
index 8de0452decee222fe62f388b2e146f7689bcfca8..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 4946
zcmb7`+iO%;6o>arG82=SCb6Za)+ClR#?)GxD&|EZRD!*E!$48c<6-6~L*kj~oSD)I
z2o(j5`l#j~sJ7N(E7nR7L`FnPDWz5MhCX;NeP~Njd@1zXm;-(L?K$wheS7WOI(x10
z!s$P%t>Xq3^v^O0hF30)6!P|l}>fr6fIRFW{m#^5zcaUft$&Uu%NTm>{
zO--R!?GPo#u^aS}R#V3O3N}7gESSnW3xNhcn3tFF#DUktQF5H?|<4&=Q
zs@=&veZ3d)Zh$`hIBHU6?%%{~XWezu9KafadTGXIk&@;i;vIpsH0>Q8g$8MUgLM{W
zNb@+>C1{l9*VAT`G{3|=2F=opvvQ_19~18xv`F(OtR&g{f;4Af&9-?i%?2#{_q0hf
zJ#Ds2vko%_v!ofH(rhQw{<$5}9K>1)uSjzt)_X8Vnyaxk!K>0-g=N<{SDGJ9o1M~p
zAM-=#lBPXRJA02bcVgx-`=mLF6~Y2(#xeV)Ss~tDc*Ds&h)MlYkL?hJZf$M#aUJ@`
z=k<|dttKdA9=EoBPI*U78`Mzs+R^7gG93kBHYlpq^x*bGQ!dPvyifhHvg}Hhpbvq4
z=H+g8;Y@(8NBgl3fxe=(ScgF$ptUB!p&*^0wfVs|a_;Tf8T9kude%SU{sN7KVvxy2
zxqPT@=O*?&NVIMX!XU~;o}bC&%V9|k9Ii8F1gLQGihA)Dg1(|fSW7`)(LXGD5K~{#
z$5^{Tw+!)~bjxs!c#lB045zRjgKinD^*b0n{Ukl@x3;fMHF$1+;S~0HXq~=Z&(CIy
zK@_QLzRZ}r(7ZjLEsq6W=x>+5?-P9XYnr1{v79M6jd>aWH9IEjmwYeEmx~!W&mjK0
zkgT;$zQ~{}P;1VA#+W@|UeY#4ZyeKQe1FVPOkW442uHQoqW%D%pIdCnTmvDcE
nlv8(d9rHFgbtfJ4VO^k~fq7WHpr3(1nS4H`eg>@72gdvddB&w|

diff --git a/build/StarcoinFramework/source_maps/EasyGasOracleScript.mvsm b/build/StarcoinFramework/source_maps/EasyGasOracleScript.mvsm
deleted file mode 100644
index f830934aa4f499af0f2fbf4e1949be132a110363..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 1082
zcmb7?Jxjw-6hLqK1r^gp(JqP~gKI%>5_E}<9ooT33Gs>1n1-Y&v>+}nogG{SMd_eU
z3I!(zXIB>oaq}-Ycse@WG;p@_-sPT`Ui9?ynx5AC)wRK;y}WvU;0)L2ty1vu+4%OV
zwcAONAz1SNv!)z3>2AA8J$AjoG`!f4+L9OPDHmSYBG+J*o2_FLHoKA0j@+Q%L#~vV
zaNoq5|BU+r6MpEo_d0Hnsw3Xe-$A6HuV7b1romE|oxxgwoN9hCd=WFRnj>ooGK~M_
z;R;+lM(ZMa1+uoD#hrt46dTV^{8p&F&I)!7M!TxZdWc7$rw*`E&{J<>bs&SfL1zcX
o2)Kn_hpYj2aCf1Y=|4ThJb_H{t`P4)k2k=206pFr)+31g0ny29lmGw#

diff --git a/build/StarcoinFramework/source_maps/EasyGasScript.mvsm b/build/StarcoinFramework/source_maps/EasyGasScript.mvsm
new file mode 100644
index 0000000000000000000000000000000000000000..02e6e0539013507f5340cffa180d0b5df4179f61
GIT binary patch
literal 1436
zcmb7@KP*F06o>Dtsyc-h?S+QMOZ|lHJI9`UU;Fe&3mn=jW9G}G6^wAtPCU;
zL4-jf27^?`E(SY8qw&4bbZ&3*ZQs2o=XcJH&rMwJI|s>~i^^$Z>*k^PIdE9}?n%^x
z(V6+_ijnJ8Y7-3g{}|Cp(<@JzUNY<2g`x^76&IeG?NcfZMmUvUwVYJBU`bap=r#mG
zp5-iAuH?J88xXM_yO>@#*GgiEZS*}*IxRdQzJMV%`-)YCfM}jzeL$ON`c@4z%3m|G
zJAZ8YS>K~SgKpMuxK#)jTq|pPcHWVuQ^)=SzgMx@K^h$aIqFfYF_5EfP<$LyL;XSf
zg%$#AqIdM`2iT1pgLbVw9l{(2t?(8QGa!ezh_wuIcnPc(&{))6v?FLCykqn;(A~as
r+$#u~xqQhfN~?E^`UqOTynz^q>7*CLih!KnJ8yPk%D>#Vx

literal 0
HcmV?d00001

diff --git a/build/StarcoinFramework/source_maps/GenesisSignerCapability.mvsm b/build/StarcoinFramework/source_maps/GenesisSignerCapability.mvsm
index 6b3a1d46dec5bae7ef9f83744b3921dee2b38c60..41be8a294a3ebcf1f8ac8f515980912a0068ee16 100644
GIT binary patch
literal 1176
zcma*lK`R7d7{Kv&X4jHkc9q&12NV}6DVN0oW12>pExVl5nq|_Iw#{%L7n~im-(U|S
zM@|k#d;lSL#a%ga@gJq!9&i0`zn*vI>2(Uu+k*aOH}h-b?~RMyf%B=$=p-|Dzx~i^
zwjG}tN~uxO=RvV22)1^Bjxh5S6U75HNj{>UNtcK2CzNVX
ze3CN%gc>+a{Mskv3+bY?m^V)eQ4XS9`p5M-{@oy@r^26AOFQcU_fulkt4nqmHxdt5
zS$So9zyp$3wuCw)d1Y6qYm!&iL`9SomwShLr4~`%pl&H8$|KYekDy(YX;d$zMft(Z
zK4eCezqfaYa*}y7)G5kkRE4sloJFlrPLyM)3F;E1hpLj&x-GX@uGp4qm7G##+BA!c
HZds{sZEvBt

literal 1176
zcma*lze>YU6oB!Qq;~L6Yq20Wh>NI$gQJTep`;y5hExziN-IGkQcB|@7AK)ls0w`u
z(M4T#Qe4`}$u|%xw4&kz_*D?xj+cDfk8{c4c5>;71$WwcZNJ<)t)toVcCTA+HR^K@
zUyGlQwTmecSt5h}9%Ir8%0U!Hez;Q(s&=tbEQNdF{sFL~%zVc52LlaFiYa0dpGL1N
zk$W1Pn9k=hSu)hY1}Z_ODkIb(S*r9=HTuW(EBt$w#EeHjtJW5g1AAm`7b}|G#BB|R
zOHyCiCGeW`l^vsQNMBhO)gygnPpCe{)a8DlQoMvARlXtLDXz*p)CMz$Rk@5>qY+ik
zpj;YNg%YZ4pqi9aWfgTo>oq%*FUFE|-D
zr5ZI7#6(}z61*jtXfbL^5vr7!_)z;`5F_|t8hvO~pg_SE{l;Vy-+tpJ-`h8H=FI%&
zKWBE(zxdJvZTF168}&<1oPK$F>cOe6PpqqK-afu@cuoEM6P&X&abwy|6xF7wCn(4=V+FVPC;|4fMk9!#V_dVb5Zn2feVTur7dJ*g34cGM9y&
z#>~gm3ws{x7l_ITEXV4A5@}w-x(=n%9KiYl%A|P)E3&|t1=6%u9yl!g3k2>RaE|H_
z^82;{36KN%9dQP9RIg%P10B_qShJv`YOU+wpw?9wvk6R|V=3N@ycH@_Ub?f_>-1xL
z{UDpnq*V=noJM=>lU!=}1mgFg=WiNo4)pw;#hM2_f1hIA1ijUVDhUPXt?prc0D7xO
zs@UchnX+^ASB$B*y0xO<@Jff#My%?3I3GtIgGhed>rpBA6Y;X`y+m)Ks%m2vgATz}
zdaT3LA;>*nhhQ81Jq9`iJF#|w4#AyRyFrKGDAq9O5FElf208@eSW}?u{S4L>aCoJD
zzR2DH8<%8fT7S#EiTpN1iZUG?e&8omWJZw3>=QWHlzS0x)^;w<8(0m5P)Fu8W+SGK
zOm3t)GLO>VF3^!_!)gZ|nblZv(2@BN>toQ78Nm7kbYxCq{R-uB=B@P`IJ{B=AHFT%
zT#MEs-)$SPT5=#=hym!ZY{$xi4vV!ya9D*Qz9T*ZlUL-$+<`vYMd_?7;_K`
zZ414@w-y@H3i;_wpX&M?-cL~2;|Ix%tQ{U|CzNDEF9>5{vfEcr*nu8{f`2Dj*_$vQ
zg0lZJqbk8xK*0-
zSkYo*Zj(wxM)0V}0BhcyqYq)v9deCS2k375qQ=jG5Y6OP^?Jn-q8|*FJbs9DzZ?O$rzPtA$J_C9h+OeJmJq^}+
H4vhH+n)Dw{

literal 6477
zcmb7|TTC2P9EZ<>ER<4i%N+`|P%UCijMgerl}4kDMr{@}@u8b349mo2cikO8ZHZ}s
zRITWPZ86fm;4SKdiK*4p7Zq)+CNm
z4tdfX$C`wEX-;813s*>U4(n4Wkfy;p4q<6lRvS|Xh0?6YS_?(e{GE}TF;_|Reylzy
zmgZ)x2Vu1|U93R}@H#t)UJnG0)mG%YZ39!PW3?A?8g#52tmi<->TRrdLC5M4)=|*0
zx`?#`I#xem*$t&*)r{2+I##7v8$icu1*>39kXYS``4s3_RncD~=vd9s-x(;80la|K
zMxSe>X{~k$@Z#Sja34e9sLmswunkCnoJe_@F*Ts0T8C8+I;!Uwya7{3)mn`ZKs
zvT9zygTO;hL3zSS#z&mE8yj^qSud4TC&&{tdd7}K8I$X`jQA($^(!r>HiBNii}crm
zsn_ot%vMaj)#tHJfZpm8Sf7L5>TMOqbb#LKm+0?mOuf~u)d>L}=@YaCs|LLqoJC%O
zP=3FYRw<~gG^QFTB{Brp^@NYd7c+oWwc>
zIs`|tPJ<4?dD|a%IDL(%!K$^lJ^e_t?B-)&1S@<$LVObrgY8FxTMW&wH0
zj=*85+z7F103DeotZvYe`H8W&VCu-^W~w9O)88)8>pPA$2|6IJ%okW+fsV`^
z*4LmTbIw}4p;GydtW|6;KKhZm$zasxFla66MSj>e;BCo?Oe5|G9hMB%0nlNw)iQDiKM+p4880Pk
z#{}xrP@MIhj34v8VONbXhQ0?1{##^a4`B{N$>pqQl(mV0>ChqFjCUL8kXB&b4mzac
zSW}=Y+Fq;~&=qYb){CGkTJGuf_WzasYFJ!d(cZ(X#ncromrY&K?xMf#pg($|SiPV>
zdTzk#1O3r6jr9)bkDgq{b>+=PyG)kG+?FhtW^MyiNOO^=IS-Z6{1EE`M5Gy_F4aSo
zG;@WcTAB&^8;2TcK8ZC6wbGoz+6Q&gwEbDTUYgTbFF=DdXRuy^Mrj_#dL5diIg51&
z)=G0f)&XdiW)IdI&?3#;nba!H>LTU{>!jI&)d}mRxy&4|!EBS}DXax(m*yhYGHj6M
zA6QM?Nw1V+CC%gX*^0SQn$}te0ZQ#Q{)yRP|BVTHdy65vwgG3DoX9NV9O#2_
zH`dFxTV3-%Lpy8Lpi^E%{?Rtzh?G;lj(>1&0zKs}tXn{z<$p7HH>N(zt+fRL9B2>l
jIqzQ1e*lBX3ELpZz56iYE1;KQ66;ma%V4e7z?gplvl0f5

diff --git a/build/StarcoinFramework/source_maps/TransactionManager.mvsm b/build/StarcoinFramework/source_maps/TransactionManager.mvsm
index 60380e6ceb8920785bc626c666f8f7fdc741e086..962b3f8bc4594724b0c6c82778c03191d24ff576 100644
GIT binary patch
literal 19276
zcmbuFd303e8HX=hLfArB6NrGUitPIq$YgR!1|~BhGl8()j>7;U$q=(3RH*S(tD;9O
zaKO562?xQYtt={{h*~{*6gk!^V%@bx1r=Oct@OFT1&-GK?gY+x{vprzeRrAp?)!W1
zd|E$vfj7{!+1B|L8AqR9->`9P`tc=uhu!#L*PTluFRti!gJBqVK@&LpUy}~usz|&#
z60Ip+7B7gzBa35IMv`HCD&}j_&oENKNJ)-FqswaJHEKi#b}wjM8L5iJYpf-a>LqH-
z2>dKasVS|9Ro6r+D%FS(_B=?6)YdFnR;BbZ)Jvd^ty^WWmDciDR1Lb40XNxe)W)Ob
zv1+9^pl-GGcx}bSF?mRjqway0(It`6xK+AP&A$)%4M;t8VHZcLt=j6C9QQF}zJ{hr
zRk2GWRnmX|0>k(RB-gBnTZ>{bbzI8_7{+QaSVOrB`x{0%G?C_HtO{r<%_CUmO}?=UWv5^I!g0qth=F;G#|p+
z2A!q37wZM+BF%wVuR&L79>+?)&@j@anSzxH8PZI{>SiO&Osw9}U7CHdMna}EKjn-@
zVV);VXV2>)&Fh(OJ@l032CUnlmo)Fdx)08mW&_q%=q=3$u^xjy(%gl$7y3$bDb_R4
zPnx#%EV$U{hh`YYSZITE^W5ZSAr4W4f}cG%C+(3nO+ynmwu_vf{+Z+IVS=tUUh0s5hYF
ziITt`VO7N{s47b1i`5hP6UO};+S{vEMpl+Di!8KiT-=0|ZfpS1-8ylFqE)4pHP*5!
z=7^S2UAn6K1~5JcPF!SXU}WLKs#vu==@Q13L2`9%H0r`{zGy$vypeveRVO<8gqFIe~
z6X=R&E!H1ES2WLZG-fxdW86CE
zX@5`c{6i`$jYjMscp?c^R>evy_{OT8;vVMM1BvZwe`Calkoc~4lu^ykYuv8Zk#YSY
z;azPsgG@M=T`k1;I5cKgyOMDm!R@ZLANNgY-mG7r;pz^CdKkv{fIGsi+panqDd#z2
zEuwdzgZ6l)&x4feny9TS6Ms}gj4oP}lEdRulb
zwBDBMn6Do6w!8`J70}zVv%20wKWDzfptsN?SYLn+h0f|amN}ml9m|~0h>m50dm6@Q
z(6P*mRRB7c&Bcm?j%BN`ZUr67He+oE9m}4<`YY&I_5s#6pkrC{UTou_V_A2s3qi-S
z7OXrHQ^zt7)(p_GtQe~TbSx{v3WJViSy&_3YjiBzj=39jEZc{50CX(-4C^@PSeC{y
zrh|@UtC?>ArjBLKxx3ixh9?`wcu1fSnt<*F*M(3q@;peO5Q?L(fW{O;*D>x6IM+hx
z0p@rK5-Wt>XT%Xmyb$`4QK>CYopWqOWogyP;>~WBtH*c`#tjG8UFK}$d`P%*n#rI=
z(5>-tu!i9`Kw}E0`xv(aTopp~t=RipyDNkoH^D+^JxkmJ?hBzc*z3TUrVF7#DRj0#
z7eX0Wqd^x!HOJZty1c2wx(jr9vl#1c(5cf|U8l|=T=z+!OQvkB
ze9$FR7SqgX3JcgLq;{Tg%`=B%#Eu=|!QWkO?1)X>>|2ospA;00bR6g
zz`6@`(efbH9?(V0D_Dm?7cDnMuj3)s1u#IGW3Z;!wloW{=E8;2Ea5m8VGfk$
zPOKN3&u$EDXe#4tTdm%dJ@J-vmWdDc2wZfEW|2-3DV5Mnhg`B
znT9n7CQ0)c$N4DcWNBWDRS#37S&7vE+0t}Y_eirtDmypiNOKU@81PCnA8Rh;O0xp%
zYA~hwI_JFsbE-6LYa`@Ia|_nvkT1dP<#()<|nIm|+7-h#CqW=Qi2tQ}A!O=tCxH0^7-A6yjQ!zb`1f&?PG2Ynj2
z{t4?xkmVH%<&o|7U2&u;#){O!Y56n)d!7vL))Km#W3E6H2bwPKNPc0y}8vd7b-l4u?o7?ocU4W
z$r&o_pBP#kw>r}IILhxK^B1P5v42dUCi#I0(kBrqemaS((d)AfV>7T@%dhRjth57k
zU|)l^6LetD;mCua1N(feIOxE>3hPGDZ!T`fY5*PWAHjMSbhOXJdJc57ckY~y_Ra@I
zNBi$sxoMW0X#WvrGfW-rld<}M{)t?3tR&D)fPJjK1XD-*e60DPqy2EK1)!t7v$~G<
zE12&((9!-||Ww;-J3)J=eu%opM*r<(w6
zu)2V50t~>K3c3l9j+FJ7RHu$B3SVd^G;Q{Ct$Ko0X2Lzb+9JXp4^+Xa)cT5y$gyWn!n+d;Pr
zoT^i|3tnWt1EAXl2eG~c-7a_t>nqUhf+;x!R?zK&Lae2r+Xd-ZWuV&ytFi6{-7awM
zk!}~f%Y0vhZWla{^$qBDf&Cq74=zg8R|nIfg9L)`d+3LtrQ09%{eawTNJ2rl3wkeT
zOb{N)xT$ciLAaPXY9O&7yoM1QA@LyGz^EPIKFmIc{ffO-!eRCuMtuQIyV}2|{%OQ>
zkum#?q6Z2Y|7*Ofh?vFbnP4o`5pl>+9!a1hVoR(spd;d1tlL0G#A~o_2OSaXunvF@
zemk+=03H19#Cj8S@N-tz!7qCl8xH8;HwbGw=y$poVcE70etod61|8?3SXY65r(1ya
zJJ7+;SzQOeLBshhfewD{u*QN8eyy-x9_c3d9l}f*;U@UKh1m*Izti1?*&0&^zf`OY
z(7~?_Ry*64CCa?rsqlRG&Pbnt77H3@X^
zn}@Xsbnwf@S`0e)WnoPL9sG`Q-g_~1oLh_a236tHi#)A%%O|d3`exvNHuES)A`Ig%A%KKh{6$c$A%dpBphshw;
z&~a|UgASA1u(pE^lfS|0I>t>z`~)0?}C0${1n#TLBA*7g!K;S_r%WXLHX@C
z%6v&<-Mmr$3e&b{$T<&V_2b)7B+a3$TmT_yUW&CI!qR*O>n$jj<{qrQFjJZhSY0@y
z5@~*e*$H#DG~dSTj5$Y|&gyfec@Oh#gL%^2k982{OY>2zw_$-aw`1)DOPaS}bsujS
z5ovyhnSpt+G~dDOh8dNnv-(154rab=h)Huk)?!#B&0MS{wk=H$me;nW*$=A$mP+%t
zSocAhG?!x4L%B4a)hncFALAx4x+NEQO042Bqq-QK%v`gu$n<)`X0A20IN%NYf`R7z
zcTtfQ4o)`%Rv;L*JYKI^817_rHoZY#z+y-+!^UO^wVmOBDoji~Z)w1NZxbv&`H!XaD)+
zN@xGMEq~^GL%zI#S!8+qMW!crHfQNK^X%)=(Kyd6@c5?&iwd|%p5kymC+XvoajC57
z=Imtte)>GmK0LFe&{t&Ub})J{VQ!Hb3R#}O$rww=#O2o}sWf$M5r=81D;sgMpAQ6y|uEpqxGk?pLswX>x;R=){SdC0H$uUO&6I
zr!Izb=QE7+&&(1sXB3;p%8=v3^7Dig#|jZRM};e5&T_`ybx>)lK7v-1FSkFRn5S<95h^6aUNT
z7OjgV>tpd$Wlgd;mW<6$)ER9JW4M?vZ;)Yxz-XTpi^ppkk|{M}I(7^?*2d}*$&|Gq
zR=+@vsmE`G_NmJ1M13k&U8_c{#l8*N#u`!!YU-4}1@%wR$=0n!iA$};iMSf{Bm-Wt
z*Jwz_s}l7}{|NPwU>~(K
zN3r%r&{~>#Sd*cRG$&$tAXAz{u$DrWG!s~tLpy2uv3>>ZrRl8RL7In{??2E{nvY|B
z4V|Rv-1*MZEFNMQC2*27OR?ra7io^fia}RtuEW{@+0xvCwFA0I^GU4dp}RES!rBi#
zr1>wbBXF`b+wlGD06nF-$es`L6lqSvDuQ0poQxHM-qH+X&43(f&ccdAA897AQjjan
zv#=VVuQZ)K?^J2NzwP{1&UtnT9b?
zn)hL5Vh)m~ZM6j#8-1d;VN^p#`)JLgL^675t$gAn(Jz4xZfla2$gAxE_9Lx6k*v^<
z=R482K=(f%0Y{sx`xvG!xSwyrWR&uSkdK80+1RCR1g)5wNoWlB~a
z-!kf?9FDcAB(O(Vb%|=Kipu1C^+fK=xKYs6UbQxMX;n?E!b-Wg2@@Fuy
z=!)iHtfxR%G|ynY1iGU6n%n*|ri+_Yo@*Etkj8G5Ku-j-!y?uGYCPPk%^%R~yQx^PwfX
znvZcaA?;ml5rZy=U$U#MWc(&*$*%S&<6Z!_yIQ+bDV3p3>p=rXt2?+7al&crK!XO1
zaqFH`ACFb>9I@unJJ3P9h9#Cl`}$Pe-D59-odl{MxiuBzm4M!s2V+eGy)Cc8x(oES
zd;^wk>uuS&(0W_m&V2hoZ_E3!x^naMw(P8~x6l#HHxl#~Itptv=uqgau49?=S<$h~
z`HbjTmgE>0gN|iaW32)m%hqE(2s)PS#M%owmi-g!DCk(0*^l`^$FhM~=Yo!9CRPA+
zESrh75Ogdn;A~QuI+k6DbtC9lwhrq7(6Q{dSib`u%Nnuj*=uwxJBs-|=vbD`e0@O2
zvf)^hK*zE$RypWcwu@t2fT?4dbM7uSyBS&JaY&;Osz9#>*M-m($SWX?Lg@GCcS1`F
zp>2$N27YNFw1+v4KzfBxr*?cZA^k#V2&2YB(>W)W)K=Ct7jJg6Ts_8%7&il4cbOL=
z*FoBq(=rCFhMbni!3_+51X@x!y~wzI;HnUMse@r$)zMuc>627$r?-_0iIt!+ftU=kFUG2ev!yu`D=XVD#!2&i%tLUFG>>5QJc;Nf%`Y$y!+Fwt2kSfL952lk
zSgYWCY1U)?1}>0hA=YY`Ak8zeK7)&-`54waFj1O!VeN%U(sWk$NVBL5Z!95Cnsc$L
zz$?v0tTm7?&5c+)!IWkvtldx`P1||_3Z=OZ>vJfQ=3%T(T@Ax0%|n=9!enW_i)DY~
zrbu%oE3W~+G#6vt2*uJIhqW03(#*yB213$&8S4|6D$N~O2O%s?XZ46Q?Q7W%Tom8Q
z^XbJx8WFw`{aSGSYpLF-P_V=|=d$j5r(8kMLeb
zMWH3{GUAL|4DOTUHQ1{l`&bj+`k{-j+65aJ^&n)rd7ZFrBE|S5!ifFanIDQ-F5lcf
ze4$}H0XeDTKS^vJUv2-u(Bi1oah^JXrzqt9%oHj6rvz$}@k~$xC;xa7SEF}x=KFxX
zT7GE{a!J1g9oL`6It)6lU%`=I4?3>jf^{G0xc+CX-JsuFyp44Lbg=&%s}*-!2m5l&
z)|fijJ9kb8d*_3qgZ(&Go(MYF_s5z9I@sr9%>n%bIS-Z>bPJ#})@IPb{u-=XKnMFI
z)~%p}y|cOw_D?e30nowT*$;HEKg4{Q7r6=cpJUp#e!p@MD}$X(zh9Ze%0bZ0g0Wa3
z(9MFYu{MBi7A(iQ3iSJx*;q$FzcqOl>m$$&h(BU|47vf~tgagney;j7&<%)Etc9Q(
z5R0&?KsO-l`D|M^AVy+UgKj{)iuEq&288|Wd=GR3!g=l*MldLZa^Hsw4dC%
z0kI#`wsix-IZoXIc!>F~V|CpE$j1tRZUI>LoE0e3Fn+4Bfz74uruovrd(9ME7unvK47EH|JGY`615W-prx>?W*YZ2&X
z!BVV^pqmBG_0-LR518*T=w`t)SVurN3+&H(S8!3Pb{oMfd`Ke(_eUQF?cDyP??U8!
zNFxT9qQ{^mF*wDzYvGs1;C0Ng4bpp){X8Syg!E(ZM~wOk+(+50k=$oUKg#xF)M#j(
zZaf`(E?<2(#r_TUkE5ZBY&!33+Ah%he~ot)EgKnq6BzS!w5;J27lV$LKCDYXN6S~S
z-US^kpT&9)bhLaNtIsGmf$`s%y)kuQ`~WitQwK(8bsZR&Gv9Tf17kJT^`HY|6_#!5
zz*vFx4ColR3F|4)Z-Q50Jq105L0VYT7&=^_SV9tIr)AH_NX
zItDtc>lnC|V|*NR415CXRnRf;HLTY`$G|;UAHZ-K2liuq0s4*gtyo`zeq-%CIrSTB
z=P9k@YWHzmOVDw31lBmvadjBhaL{q}JI;FrrVgPqu`UB0LcLg*gASq2>Np{>VbPLw~phM_ttg7?egwVGzKLH&=-^4l$I)r|O^*v0IpZOzLM?r_s$FR!I
zaT6_vVEI5t%WSO4prfU;x{j7>nQsH=Xt^Bg51^yv3t0aE9W9^3+6_8d-j8)URlQ%{
zqYSLmK)+r7m^u4l>bJ|z>Or}>$$W9p@1dQXGF8sGnE6&hSegx3wjGh?#aMIs#zm$1
zIOfYxBF(K>ufQ~EX0UQED3#`S%*RG&lu7ddW(0G(G{<61g&ES!!3x7nX*#RVlIHu&
zcL-)nv&(pDPq3tUg!ytX=ScGl%)=0q<{qpv=8Q{o9M&|bkY+AcDI}!ntUgbg3z=^z
z%$MdZSesyhG?!y-hDvERVl9J((wvKR0IH<o+lojSr+nz&HQf0sZ5w3HX{+s
z6KI~n9%mK%BE_Dlw}>}_$0zW5xPn|7tI!j1u5<^Z-?14&C3$|Iw`sgD;0*>MzDShg
z$v`=F5Ztd|3De{U%}CRUnq^q+jDA14xIbJB=g#*wPCq_N#GG1Uav!ZgNpT(*CK?P{
zc|LxFD4c*<+C@1*e|}e^|M9hafoUGUk8AV8k=s|(
+        TransactionManager::txn_prologue_v2(
             &account,
             txn_sender,
             txn_sequence_number,
             txn_public_key,
             txn_gas_price,
-            txn_max_gas_units
+            txn_max_gas_units,
+            1,1
         );
     }
 }
@@ -162,6 +164,7 @@ script {
 //# run --signers Genesis
 // successfully executed
 script {
+    use StarcoinFramework::TransactionManager;
     use StarcoinFramework::Account;
     use StarcoinFramework::STC::STC;
     use StarcoinFramework::Authenticator;
@@ -179,13 +182,13 @@ script {
         let txn_gas_price = 1;
         let txn_max_gas_units = 1000;
 
-        Account::txn_prologue(
+        TransactionManager::txn_prologue_v2(
             &account,
             txn_sender,
             txn_sequence_number,
             txn_public_key,
             txn_gas_price,
-            txn_max_gas_units
+            txn_max_gas_units,1,1
         );
 
         // execute the txn...
@@ -348,9 +351,23 @@ script {
 }
 // check: "Keep(ABORTED { code: 1031"
 
+//# run --signers Genesis
+script {
+    use StarcoinFramework::STC::STC;
+    use StarcoinFramework::Account::{deposit, withdraw};
+    use StarcoinFramework::EasyGas;
+    fun main(account: signer){
+        EasyGas::initialize(&account,@0x1,b"DummyToken",b"DummyToken",@alice);
+        let token = withdraw(&account,100000000000);
+        deposit(EasyGas::get_gas_fee_address(), token);
+    }
+}
+//check: EXECUTED
+
 //# run --signers Genesis
 // successfully executed
 script {
+    use StarcoinFramework::TransactionManager;
     use StarcoinFramework::Account;
     use StarcoinFramework::Authenticator;
     use StarcoinFramework::Vector;
@@ -361,7 +378,6 @@ script {
         let auth_key_vec = Authenticator::ed25519_authentication_key(copy txn_public_key);
         let txn_sender = Authenticator::derived_address(copy auth_key_vec);
         Vector::push_back(&mut txn_public_key, 0u8); //create preimage
-
         let seq = Account::sequence_number(txn_sender);
         assert!(seq == 1, 1005);
 
@@ -370,7 +386,7 @@ script {
         let txn_max_gas_units = 2500;
         Account::do_accept_token(&account);
 
-        Account::txn_prologue_v2(
+        TransactionManager::txn_prologue_v2(
             &account,
             txn_sender,
             txn_sequence_number,
@@ -382,7 +398,7 @@ script {
         );
         // execute the txn...
         let gas_units_remaining = 10;
-        Account::txn_epilogue_v3(
+        TransactionManager::txn_epilogue_v3(
             &account,
             txn_sender,
             txn_sequence_number,
diff --git a/integration-tests/oracle/EasyGas.exp b/integration-tests/oracle/EasyGas.exp
index 000940fb..21ea1304 100644
--- a/integration-tests/oracle/EasyGas.exp
+++ b/integration-tests/oracle/EasyGas.exp
@@ -1,13 +1,34 @@
-processed 6 tasks
+processed 7 tasks
 
-task 4 'run'. lines 12-19:
+task 5 'run'. lines 14-20:
 {
-  "gas_used": 45211,
-  "status": "Executed"
+  "gas_used": 32320,
+  "status": {
+    "MoveAbort": {
+      "location": {
+        "Module": {
+          "address": "0x00000000000000000000000000000001",
+          "name": "CoreAddresses"
+        }
+      },
+      "abort_code": "2818"
+    }
+  }
 }
 
-task 5 'run'. lines 21-33:
+task 6 'run'. lines 22-34:
 {
-  "gas_used": 207236,
-  "status": "Executed"
+  "gas_used": 175859,
+  "status": {
+    "ExecutionFailure": {
+      "location": {
+        "Module": {
+          "address": "0x00000000000000000000000000000001",
+          "name": "EasyGas"
+        }
+      },
+      "function": 2,
+      "code_offset": 3
+    }
+  }
 }
diff --git a/integration-tests/oracle/EasyGas.move b/integration-tests/oracle/EasyGas.move
index 747f1030..5183e683 100644
--- a/integration-tests/oracle/EasyGas.move
+++ b/integration-tests/oracle/EasyGas.move
@@ -11,35 +11,24 @@ module alice::STAR {
     struct STAR has store, copy, drop {}
 }
 
-//# run --signers alice
-script {
-    use StarcoinFramework::EasyGasOracle;
-    fun main(signer: signer) {
-        EasyGasOracle::register_gas_token_entry(&signer, @alice, b"STAR", b"STAR", @bob);
-
-    }
-}
-
 //# run --signers alice
 script {
     use StarcoinFramework::EasyGas;
-
     fun main(signer: signer) {
-        EasyGas::register_gas_fee_address(&signer, @lili);
-
+        EasyGas::initialize(&signer, @alice, b"STAR", b"STAR", @bob);
     }
 }
 
 //# run --signers bob
 script {
     use alice::STAR::STAR;
-    use StarcoinFramework::EasyGasOracle;
+    use StarcoinFramework::EasyGas;
 
     fun main(signer: signer) {
-        EasyGasOracle::register(&signer, 9);
-        EasyGasOracle::init_data_source(&signer, 0);
-        EasyGasOracle::update(&signer, 100);
-        let star_price= EasyGasOracle::gas_oracle_read();
+        EasyGas::register_oracle(&signer, 9);
+        EasyGas::init_oracle_source(&signer, 0);
+        EasyGas::update_oracle(&signer, 100);
+        let star_price= EasyGas::gas_oracle_read();
         assert!(star_price==100,1000);
     }
 }
\ No newline at end of file
diff --git a/integration-tests/transaction_scripts/create_account.move b/integration-tests/transaction_scripts/create_account.move
index 5dc8523b..27ecbe6c 100644
--- a/integration-tests/transaction_scripts/create_account.move
+++ b/integration-tests/transaction_scripts/create_account.move
@@ -13,4 +13,4 @@ script {
     fun main(account: signer, fresh_address: address, initial_amount: u128) {
         Account::create_account_with_initial_amount_v2(account, fresh_address, initial_amount);
     }
-}
+}
\ No newline at end of file
diff --git a/sources/Account.move b/sources/Account.move
index 63a8ee6f..34dc4036 100644
--- a/sources/Account.move
+++ b/sources/Account.move
@@ -454,12 +454,7 @@ module Account {
         aborts_if balance.token.value + token.value > MAX_U128;
     }
 
-    public (friend) fun deposit_to_balance_v2(sender:address, token: Token::Token) acquires Balance {
-        let balance = borrow_global_mut>(sender);
-        Token::deposit(&mut balance.token, token)
-    }
-
-    public (friend) fun withdraw_from_balance_v2(sender:address, amount: u128): Token acquires Balance {
+    public(friend) fun withdraw_from_balance_v2(sender:address, amount: u128): Token acquires Balance {
         let balance = borrow_global_mut>(sender);
         Token::withdraw(&mut balance.token, amount)
     }
diff --git a/sources/EasyGas.move b/sources/EasyGas.move
index 644ef9a4..9c2a3bdf 100644
--- a/sources/EasyGas.move
+++ b/sources/EasyGas.move
@@ -1,13 +1,15 @@
 address StarcoinFramework {
 
-module EasyGasOracle {
+module EasyGas {
     use StarcoinFramework::Account;
+    use StarcoinFramework::Account::{extract_withdraw_capability, withdraw_with_capability, restore_withdraw_capability,
+        deposit, SignerCapability
+    };
     use StarcoinFramework::Signer::address_of;
     use StarcoinFramework::TypeInfo::{type_of, module_name, account_address, struct_name};
     use StarcoinFramework::CoreAddresses;
     use StarcoinFramework::GenesisSignerCapability;
     use StarcoinFramework::PriceOracle;
-    friend StarcoinFramework::StdlibUpgradeScripts;
 
     struct STCToken has copy, store, drop {}
 
@@ -18,19 +20,34 @@ module EasyGasOracle {
         data_source: address,
     }
 
+    struct GasFeeAddress has key, store {
+        gas_fee_address: address,
+        cap: SignerCapability,
+    }
+
+    public fun initialize(
+        sender: &signer,
+        token_account_address: address,
+        token_module_name: vector,
+        token_struct_name: vector,
+        data_source: address,
+    ) acquires GasTokenEntry {
+        register_gas_token(sender, token_account_address, token_module_name, token_struct_name, data_source);
+        create_gas_fee_address(sender);
+    }
 
-    public fun register(sender: &signer, precision: u8) {
+    public fun register_oracle(sender: &signer, precision: u8) {
         PriceOracle::register_oracle>(sender, precision);
         let genesis_account = GenesisSignerCapability::get_genesis_signer();
         //todo:check gas token entry
         Account::do_accept_token(&genesis_account);
     }
 
-    public fun init_data_source(sender: &signer, init_value: u128) {
+    public fun init_oracle_source(sender: &signer, init_value: u128) {
         PriceOracle::init_data_source>(sender, init_value);
     }
 
-    public fun update(sender: &signer, value: u128) {
+    public fun update_oracle(sender: &signer, value: u128) {
         PriceOracle::update>(sender, value);
     }
 
@@ -43,13 +60,15 @@ module EasyGasOracle {
         PriceOracle::read>(data_source)
     }
 
-    public fun register_gas_token_entry(
-        _sender: &signer,
+
+    fun register_gas_token(
+        sender: &signer,
         account_address: address,
         module_name: vector,
         struct_name: vector,
         data_source: address,
     ) acquires GasTokenEntry {
+        CoreAddresses::assert_genesis_address(sender);
         let genesis_account = GenesisSignerCapability::get_genesis_signer();
         let gas_token_entry = GasTokenEntry { account_address, module_name, struct_name, data_source };
         if (exists(address_of(&genesis_account))) {
@@ -58,18 +77,6 @@ module EasyGasOracle {
         move_to(&genesis_account, gas_token_entry);
     }
 
-    #[test_only]
-    public fun register_gas_token_entry_test(
-        sender: &signer,
-        account_address: address,
-        module_name: vector,
-        struct_name: vector,
-        data_source: address,
-    ) acquires GasTokenEntry {
-        register_gas_token_entry(sender, account_address, module_name, struct_name, data_source);
-    }
-
-
     fun get_data_source_address(): address acquires GasTokenEntry {
         let token_type_info = type_of();
         let genesis = CoreAddresses::GENESIS_ADDRESS();
@@ -80,60 +87,56 @@ module EasyGasOracle {
         ) == *&gas_token_entry.account_address && struct_name(&token_type_info) == *&gas_token_entry.struct_name, 100);
         gas_token_entry.data_source
     }
-}
-
 
-module EasyGasOracleScript {
-    use StarcoinFramework::EasyGasOracle;
-
-    public entry fun register(sender: signer, precision: u8) {
-        EasyGasOracle::register(&sender, precision)
+    fun create_gas_fee_address(
+        sender: &signer,
+    ) {
+        CoreAddresses::assert_genesis_address(sender);
+        let genesis_account = GenesisSignerCapability::get_genesis_signer();
+        let (gas_fee_address, cap) = Account::create_delegate_account(&genesis_account);
+        let gas_fee_signer = Account::create_signer_with_cap(&cap);
+        Account::set_auto_accept_token(&gas_fee_signer, true);
+        let gas_fee_address_entry = GasFeeAddress { gas_fee_address, cap };
+        move_to(&genesis_account, gas_fee_address_entry);
     }
 
-    public entry fun init_data_source(sender: signer, init_value: u128) {
-        EasyGasOracle::init_data_source(&sender, init_value);
+    public fun get_gas_fee_address(): address acquires GasFeeAddress {
+        let genesis = CoreAddresses::GENESIS_ADDRESS();
+        let gas_fee_address_entry = borrow_global(genesis);
+
+        return gas_fee_address_entry.gas_fee_address
     }
 
-    public entry fun update(sender: signer, value: u128) {
-        EasyGasOracle::update(&sender, value)
+    public fun withdraw_gas_fee(_sender: &signer, amount: u128) acquires GasFeeAddress {
+        let genesis = CoreAddresses::GENESIS_ADDRESS();
+        let gas_fee_address_entry = borrow_global(genesis);
+        let gas_fee_signer = Account::create_signer_with_cap(&gas_fee_address_entry.cap);
+        let withdraw_cap = extract_withdraw_capability(&gas_fee_signer);
+        let token = withdraw_with_capability(&withdraw_cap, amount);
+        restore_withdraw_capability(withdraw_cap);
+        deposit(CoreAddresses::ASSOCIATION_ROOT_ADDRESS(), token);
     }
 }
 
-module EasyGas {
-    use StarcoinFramework::CoreAddresses;
-    use StarcoinFramework::Signer::address_of;
-    use StarcoinFramework::GenesisSignerCapability;
-    friend StarcoinFramework::StdlibUpgradeScripts;
-    struct GasFeeAddress has key, store, drop {
-        gas_fee_address: address,
-    }
 
-    public fun register_gas_fee_address(
-        _sender: &signer,
-        gas_fee_address: address,
-    ) acquires GasFeeAddress {
-        let genesis_account = GenesisSignerCapability::get_genesis_signer();
+module EasyGasScript {
+    use StarcoinFramework::EasyGas;
 
-        let gas_fee_address_entry = GasFeeAddress { gas_fee_address };
-        if (exists(address_of(&genesis_account))) {
-            move_from(address_of(&genesis_account));
-        };
+    public entry fun register(sender: signer, precision: u8) {
+        EasyGas::register_oracle(&sender, precision)
+    }
 
-        move_to(&genesis_account, gas_fee_address_entry);
+    public entry fun init_data_source(sender: signer, init_value: u128) {
+        EasyGas::init_oracle_source(&sender, init_value);
     }
 
-    #[test_only]
-    public fun register_gas_fee_address_test(
-        sender: &signer,
-        gas_fee_address: address,
-    ) acquires GasFeeAddress {
-        register_gas_fee_address(sender, gas_fee_address)
+    public entry fun update(sender: signer, value: u128) {
+        EasyGas::update_oracle(&sender, value)
     }
 
-    public fun get_gas_fee_address(): address acquires GasFeeAddress {
-        let genesis = CoreAddresses::GENESIS_ADDRESS();
-        let gas_fee_address_entry = borrow_global(genesis);
-        return gas_fee_address_entry.gas_fee_address
+    public entry fun withdraw_gas_fee_entry(sender: signer, amount: u128) {
+        EasyGas::withdraw_gas_fee(&sender, amount);
     }
+
 }
 }
diff --git a/sources/GenesisSignerCapability.move b/sources/GenesisSignerCapability.move
index d6094cb7..618eb536 100644
--- a/sources/GenesisSignerCapability.move
+++ b/sources/GenesisSignerCapability.move
@@ -3,14 +3,12 @@ module StarcoinFramework::GenesisSignerCapability {
     use StarcoinFramework::CoreAddresses;
     use StarcoinFramework::Errors;
 
-
-
     friend StarcoinFramework::NFT;
     friend StarcoinFramework::Oracle;
     friend StarcoinFramework::Genesis;
     friend StarcoinFramework::StdlibUpgradeScripts;
-    friend StarcoinFramework::EasyGasOracle;
     friend StarcoinFramework::EasyGas;
+
     const ENOT_GENESIS_ACCOUNT: u64 = 11;
 
     struct GenesisSignerCapability has key {
diff --git a/sources/StdlibUpgradeScripts.move b/sources/StdlibUpgradeScripts.move
index 19ecd775..8d296ea7 100644
--- a/sources/StdlibUpgradeScripts.move
+++ b/sources/StdlibUpgradeScripts.move
@@ -2,9 +2,8 @@ address StarcoinFramework {
 /// The module for StdlibUpgrade init scripts
 module StdlibUpgradeScripts {
 
-    use StarcoinFramework::EasyGas;
-    use StarcoinFramework::EasyGasOracle;
-    use StarcoinFramework::CoreAddresses;
+        use StarcoinFramework::EasyGas;
+        use StarcoinFramework::CoreAddresses;
         use StarcoinFramework::STC::{Self, STC};
         use StarcoinFramework::Token::{Self, LinearTimeMintKey};
         use StarcoinFramework::TreasuryWithdrawDaoProposal;
@@ -108,13 +107,10 @@ module StdlibUpgradeScripts {
         }
         public fun do_upgrade_from_v11_to_v12(sender: &signer) {
             {
-                EasyGasOracle::register_gas_token_entry(sender,
+                EasyGas::initialize(sender,
                     @0x8c109349c6bd91411d6bc962e080c4a3,
                     b"STAR",b"STAR",
                     @0x8c109349c6bd91411d6bc962e080c4a3);
-                //TODO:
-                EasyGas::register_gas_fee_address(sender,@0x3);
-		    
                 Block::checkpoints_init(sender);
             };
         }
diff --git a/sources/TransactionManager.move b/sources/TransactionManager.move
index 070c0e97..e08e4dc5 100644
--- a/sources/TransactionManager.move
+++ b/sources/TransactionManager.move
@@ -24,7 +24,6 @@ module TransactionManager {
     use StarcoinFramework::Hash;
     use StarcoinFramework::Vector;
     use StarcoinFramework::STC;
-    use StarcoinFramework::EasyGasOracle;
     use StarcoinFramework::EasyGas;
     spec module {
         pragma verify = false;
@@ -69,7 +68,7 @@ module TransactionManager {
         // specified by the transaction
         assert!(ChainId::get() == chain_id, Errors::invalid_argument(EPROLOGUE_BAD_CHAIN_ID));
         let (stc_price,scaling_factor)= if (!STC::is_stc()){
-            (EasyGasOracle::gas_oracle_read(), EasyGasOracle::get_scaling_factor())
+            (EasyGas::gas_oracle_read(), EasyGas::get_scaling_factor())
         }else{
             (1,1)
         };
@@ -173,7 +172,7 @@ module TransactionManager {
         CoreAddresses::assert_genesis_address(&account);
         let (stc_price,scaling_factor) =
         if (!STC::is_stc()){
-            (EasyGasOracle::gas_oracle_read(),EasyGasOracle::get_scaling_factor())
+            (EasyGas::gas_oracle_read(), EasyGas::get_scaling_factor())
         }else{
             (1,1)
         };
@@ -319,8 +318,8 @@ module TransactionManager {
             );
             let balance_amount_token = balance(txn_sender);
             assert!(balance_amount_token >= max_transaction_fee_token, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT));
-            let gas_fee_address = EasyGas::get_gas_fee_address();
             if (!is_stc()){
+                let gas_fee_address = EasyGas::get_gas_fee_address();
                 let balance_amount_stc= balance(gas_fee_address);
                 assert!(balance_amount_stc >= max_transaction_fee_stc, Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT));
             }
@@ -356,8 +355,9 @@ module TransactionManager {
             balance(txn_sender) >= transaction_fee_amount_token,
             Errors::limit_exceeded(EINSUFFICIENT_BALANCE)
         );
-        let gas_fee_address = EasyGas::get_gas_fee_address();
+
         if (!is_stc()){
+            let gas_fee_address = EasyGas::get_gas_fee_address();
             let genesis_balance_amount_stc=balance(gas_fee_address);
             assert!(genesis_balance_amount_stc >= transaction_fee_amount_stc,
                 Errors::invalid_argument(EPROLOGUE_CANT_PAY_GAS_DEPOSIT)
@@ -376,7 +376,8 @@ module TransactionManager {
                 transaction_fee_amount_token
             );
             if(!is_stc()) {
-                Account::deposit_to_balance_v2(gas_fee_address, transaction_fee_token);
+                let gas_fee_address = EasyGas::get_gas_fee_address();
+                Account::deposit(gas_fee_address, transaction_fee_token);
                 let stc_fee_token = Account::withdraw_from_balance_v2(gas_fee_address, transaction_fee_amount_stc);
                 TransactionFee::pay_fee(stc_fee_token);
             }else{
@@ -395,6 +396,5 @@ module TransactionManager {
         aborts_if !exists>(txn_sender);
         aborts_if txn_max_gas_units < gas_units_remaining;
     }
-
 }
-}
\ No newline at end of file
+}

From 216cc658f1956960e2a03b4aa1a8cd03615aa22c Mon Sep 17 00:00:00 2001
From: sanlee42 
Date: Wed, 16 Aug 2023 10:11:57 +0000
Subject: [PATCH 5/6] Fix prover

---
 build/StarcoinFramework/BuildInfo.yaml        |   2 +-
 .../docs/TransactionManager.md                |  26 +++++++++++-------
 .../source_maps/TransactionManager.mvsm       | Bin 19276 -> 19276 bytes
 sources/TransactionManager.move               |   4 +--
 4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/build/StarcoinFramework/BuildInfo.yaml b/build/StarcoinFramework/BuildInfo.yaml
index ac34abec..544cba98 100644
--- a/build/StarcoinFramework/BuildInfo.yaml
+++ b/build/StarcoinFramework/BuildInfo.yaml
@@ -5,7 +5,7 @@ compiled_package_info:
     StarcoinAssociation: "0x0000000000000000000000000a550c18"
     StarcoinFramework: "0x00000000000000000000000000000001"
     VMReserved: "0x00000000000000000000000000000000"
-  source_digest: 259949A9CFA76FB4455E923838B29E99222457B4EFBBDA972E1439BF7246EE5D
+  source_digest: DEAD5E4489A0087D5ECEDCE704BCF29BF0E73B77A305D5324A9F453D3803B69B
   build_flags:
     dev_mode: false
     test_mode: false
diff --git a/build/StarcoinFramework/docs/TransactionManager.md b/build/StarcoinFramework/docs/TransactionManager.md
index 969a8baf..8cf62406 100644
--- a/build/StarcoinFramework/docs/TransactionManager.md
+++ b/build/StarcoinFramework/docs/TransactionManager.md
@@ -750,16 +750,8 @@ It collects gas and bumps the sequence number
 
 
- - -## Module Specification - - - -
pragma verify = false;
-pragma aborts_if_is_strict = true;
-
- +
+Specification @@ -771,3 +763,17 @@ It collects gas and bumps the sequence number aborts_if !exists<Balance<TokenType>>(txn_sender); aborts_if txn_max_gas_units < gas_units_remaining;
+ + + + + + + +## Module Specification + + + +
pragma verify = false;
+pragma aborts_if_is_strict = true;
+
diff --git a/build/StarcoinFramework/source_maps/TransactionManager.mvsm b/build/StarcoinFramework/source_maps/TransactionManager.mvsm index 962b3f8bc4594724b0c6c82778c03191d24ff576..6f75505a7ae20d413e38ade9e08b6ab8aadd4325 100644 GIT binary patch literal 19276 zcmbuFd303e8HX=x2wT{fux|pg?+6G?CO65zWG0!Juo<}>CIdvsLNZ}#wWt*|o=R2l zv=%sE-9-rp!KGFf6;X;>Jy=DKbwR9KT}l;P&^|YCfups*JAreaf5`KF-(67ng_h4C(=B5?dH8F13n_)cl8$-+{C<7j{9k(yFSA%WL$e8cH(-D-{|^^K(`=F;k>D1j`Feq}dKD6H=w=tlm_be`da?pqVtQv7UzJ(sb^8 z3u(6J^VAJmO0x&n07#SO3660fW-DpV#hMSTrJ2B532mf#6V_U2E6qEw9)Nbzd<<(B zw3p^VtXH6eG)G~*2_2=`WFXfPI!UvQZ9!*grepPibZPd(8U$UWIRtAGbd~0RIPXg_ zyGhg8^SVp(Hs;$1J*2q_>u%^N&3myPf?m?B!P*JErTHk<)6hqn`>+l|Uujliy#W2B zXN@#m} z$damfX)JEJd$ixmxVxc+J=T6qmsb?W)>LRL&piXH0CYt&6KetJil!LrI?xr(YOLEq zS2XLf{sg+Bd66rBC#H*=G`Oo_jDsY0qw(k-Xy$e|3M0>fBzB|4=u4q4yHPdcHb4*i zdurz&Qdw~9W3mQ*n=IYU!Rd~-IkTH=whBD z)_i&gI%sFGL>{D8CSvX$d*iV^K=mWHrk;2MKyS<6a7_kc>TNlSwE}c}`~{Y6>uuS& z(0W_0X1=YUx8-eEuY=x}oz?Xg`W5q?0KJ8t#QGX^D0EiWvCR3b=vd}_MszG2%g1{% z=vd~*ngKeN6=5v{9m`f>-32<9ZO7UTI+neF^$*ao>=UdXK*zEcJvm0uv8*rFNYJsY zB`Z(D)Uj+D)*R5WY%bPP(6Q_?tjj^ivMj8L>@_-;?Z(^>I+h*AItn_LeTmhC)paaO z$La+-maS&a;g~v>Ip^+Tvzw4&7#Wa6A>>8(gX=|46_P82K4!#8NWKtCX~MT3YR@^oyu7&Lbn#|4%hhANKjS8V>n^hoIUka)oGb>F zL3-We;8hI&J=CRedWdm*z*Ql%wJCdlGk1lM<0e@MZDffp;Jy%Ai@gDiX}S;^lS*d` zbRpCmYcl9UCweJXO*z&Bpi`%_x=x+rxb7zClF5ga z54vQ^!pZ?%G7ZDJ4s>^XG1j%9yW?T3-+(T|oYi$1_AvAP6?7T49m}?L8RmSwbQyMp z`MB&Z%CP!a7lSUtoYi&7l*4>J&?VC}tm&XjCTDeBv^cwoE?S&jL>Dd99OEsZiqEUx@dVF>jdbcr4jwQHgJ)Shgc(^zci;{<-h=G&cG^yfzpg}Hf5L>OLH&Q zAs8ghHCV60U}>(v>es?BhD!50%+8p@q+z)Z-Gym`>^)IG-+M@K}ke)dAqr}rQ zl-NHpv^Z{cq#tpV4JXlV{Fx~d_KykFB#oG$7qtKJB(6qpoN5@`f!$huZ6D`w_ka%U zYq9o%4(!u8@>!q*`+Tfrpac6VtUrK$b8!z=4d`h9B-V?dqkTWDmq15*=g#S9?|e{n zw6Aw5`O-$-%}+VT=9oI#x563>`X_QNu+l&`0S>eJ5=!O$6P7n1ppH=oW-MpKa?F1PQ~K47vqz z7uHtLEeQKbR|C2Q;XD&{3t}Jh9RuBh*nwp~XLSqWVJzF$EePj0braxP<}2hWr<(xn zv3h`R0u09rf^Guz!pZ~P1o)EU%*WJCfJIoVKsNzyz^Vq_1XzuAJ?JLD0<2D6H%)-! zn5RHD0n(_Y27zt@?6l{@)J=emn09ren*h_9Z!TOapPSRLY+JVrvawonm2|t{2F!av zw+o!AQ@0BaG2cp{@% z0_Ps-cEN|t_dV!#!OK`bfNmGq-=WUnqEvlj2pu{|A_#wkejJ*({ZU_|p_GG=L=f(Q zJ`m~>geNgB2p1ZJ=Q77tkX#U6%ZSa8{JZQLM(qLjVfH2L*X^~E4znLH>T9Uq(f&2{ zk0YLoj5%~PUqa~ozs9?Yh*^xbz$nrYaojLAM$i$lHP#f+5pg}%-Jm1lEm-$}j)>J* zM?nX_y;$#n4u1Dxy$d?{Ijig7=NnEh3v}=sgB1ZC{6=Hhwhn%Sv2F$(=N4nF0sT&Q z2G;LD2R~X&o8WicUU{UO;P;-rGNyi~yAQJ+rVf6c zuzG_Ie(mk~KnK4ES^d|T`t5HnRvGBvHyW!PbntUl*TK&|#+9IhUq9|-Cg|YT0m}p( z{Nh+;po5#=%{brTUk$83$MBjRDqHkdjhI;-o5 zSjc?yK}SR%)&kHG@iwfjpd;d~SnEJX#44;0LBA({9_yc=-xF`c`T+EMVrTWB+!eoL zzO->}-Y9>IY1{d7&J$Qe`F4b)Ii8hgKv;jYj%e1^X9!C2zQ;m+1Sph50Gut2Jzaz8rOe^dS`SK#2j7~rK zOPYCK3!<8NTe6$_bb=)07kRXSOnWpIgfpnBnpJxHe~w z+`h{8IW{|A`nem_+8AKY^hI(qL!Ox)zvcDhc`|%{Uu5>#duh(%zIeHp?Tw2~`_hMk Nk<<6@|H+Mw{{kxi_w)b& literal 19276 zcmbuFd303e8HX=hLfArB6NrGUitPIq$YgR!1|~BhGl8()j>7;U$q=(3RH*S(tD;9O zaKO562?xQYtt={{h*~{*6gk!^V%@bx1r=Oct@OFT1&-GK?gY+x{vprzeRrAp?)!W1 zd|E$vfj7{!+1B|L8AqR9->`9P`tc=uhu!#L*PTluFRti!gJBqVK@&LpUy}~usz|&# z60Ip+7B7gzBa35IMv`HCD&}j_&oENKNJ)-FqswaJHEKi#b}wjM8L5iJYpf-a>LqH- z2>dKasVS|9Ro6r+D%FS(_B=?6)YdFnR;BbZ)Jvd^ty^WWmDciDR1Lb40XNxe)W)Ob zv1+9^pl-GGcx}bSF?mRjqway0(It`6xK+AP&A$)%4M;t8VHZcLt=j6C9QQF}zJ{hr zRk2GWRnmX|0>k(RB-gBnTZ>{bbzI8_7{+QaSVOrB`x{0%G?C_HtO{r<%_CUmO}?=UWv5^I!g0qth=F;G#|p+ z2A!q37wZM+BF%wVuR&L79>+?)&@j@anSzxH8PZI{>SiO&Osw9}U7CHdMna}EKjn-@ zVV);VXV2>)&Fh(OJ@l032CUnlmo)Fdx)08mW&_q%=q=3$u^xjy(%gl$7y3$bDb_R4 zPnx#%EV$U{hh`YYSZITE^W5ZSAr4W4f}cG%C+(3nO+ynmwu_vf{+Z+IVS=tUUh0s5hYF ziITt`VO7N{s47b1i`5hP6UO};+S{vEMpl+Di!8KiT-=0|ZfpS1-8ylFqE)4pHP*5! z=7^S2UAn6K1~5JcPF!SXU}WLKs#vu==@Q13L2`9%H0r`{zGy$vypeveRVO<8gqFIe~ z6X=R&E!H1ES2WLZG-fxdW86CE zX@5`c{6i`$jYjMscp?c^R>evy_{OT8;vVMM1BvZwe`Calkoc~4lu^ykYuv8Zk#YSY z;azPsgG@M=T`k1;I5cKgyOMDm!R@ZLANNgY-mG7r;pz^CdKkv{fIGsi+panqDd#z2 zEuwdzgZ6l)&x4feny9TS6Ms}gj4oP}lEdRulb zwBDBMn6Do6w!8`J70}zVv%20wKWDzfptsN?SYLn+h0f|amN}ml9m|~0h>m50dm6@Q z(6P*mRRB7c&Bcm?j%BN`ZUr67He+oE9m}4<`YY&I_5s#6pkrC{UTou_V_A2s3qi-S z7OXrHQ^zt7)(p_GtQe~TbSx{v3WJViSy&_3YjiBzj=39jEZc{50CX(-4C^@PSeC{y zrh|@UtC?>ArjBLKxx3ixh9?`wcu1fSnt<*F*M(3q@;peO5Q?L(fW{O;*D>x6IM+hx z0p@rK5-Wt>XT%Xmyb$`4QK>CYopWqOWogyP;>~WBtH*c`#tjG8UFK}$d`P%*n#rI= z(5>-tu!i9`Kw}E0`xv(aTopp~t=RipyDNkoH^D+^JxkmJ?hBzc*z3TUrVF7#DRj0# z7eX0Wqd^x!HOJZty1c2wx(jr9vl#1c(5cf|U8l|=T=z+!OQvkB ze9$FR7SqgX3JcgLq;{Tg%`=B%#Eu=|!QWkO?1)X>>|2ospA;00bR6g zz`6@`(efbH9?(V0D_Dm?7cDnMuj3)s1u#IGW3Z;!wloW{=E8;2Ea5m8VGfk$ zPOKN3&u$EDXe#4tTdm%dJ@J-vmWdDc2wZfEW|2-3DV5Mnhg`B znT9n7CQ0)c$N4DcWNBWDRS#37S&7vE+0t}Y_eirtDmypiNOKU@81PCnA8Rh;O0xp% zYA~hwI_JFsbE-6LYa`@Ia|_nvkT1dP<#()<|nIm|+7-h#CqW=Qi2tQ}A!O=tCxH0^7-A6yjQ!zb`1f&?PG2Ynj2 z{t4?xkmVH%<&o|7U2&u;#){O!Y56n)d!7vL))Km#W3E6H2bwPKNPc0y}8vd7b-l4u?o7?ocU4W z$r&o_pBP#kw>r}IILhxK^B1P5v42dUCi#I0(kBrqemaS((d)AfV>7T@%dhRjth57k zU|)l^6LetD;mCua1N(feIOxE>3hPGDZ!T`fY5*PWAHjMSbhOXJdJc57ckY~y_Ra@I zNBi$sxoMW0X#WvrGfW-rld<}M{)t?3tR&D)fPJjK1XD-*e60DPqy2EK1)!t7v$~G< zE12&((9!-||Ww;-J3)J=eu%opM*r<(w6 zu)2V50t~>K3c3l9j+FJ7RHu$B3SVd^G;Q{Ct$Ko0X2Lzb+9JXp4^+Xa)cT5y$gyWn!n+d;Pr zoT^i|3tnWt1EAXl2eG~c-7a_t>nqUhf+;x!R?zK&Lae2r+Xd-ZWuV&ytFi6{-7awM zk!}~f%Y0vhZWla{^$qBDf&Cq74=zg8R|nIfg9L)`d+3LtrQ09%{eawTNJ2rl3wkeT zOb{N)xT$ciLAaPXY9O&7yoM1QA@LyGz^EPIKFmIc{ffO-!eRCuMtuQIyV}2|{%OQ> zkum#?q6Z2Y|7*Ofh?vFbnP4o`5pl>+9!a1hVoR(spd;d1tlL0G#A~o_2OSaXunvF@ zemk+=03H19#Cj8S@N-tz!7qCl8xH8;HwbGw=y$poVcE70etod61|8?3SXY65r(1ya zJJ7+;SzQOeLBshhfewD{u*QN8eyy-x9_c3d9l}f*;U@UKh1m*Izti1?*&0&^zf`OY z(7~?_Ry*64CCa?rsqlRG&Pbnt77H3@X^ zn}@Xsbnwf@S`0e)WnoPL9sG`Q-g_~1oLh_a236tHi#)A%%O|d3`exvNHuES)A`Ig%A%KKh{6$c$A%dpBphshw; z&~a|UgASA1u(pE^lfS|0I>t>z`~)0?}C0${1n#TLBA*7g!K;S_r%WXLHX@C z%6v&<-Mmr$3e&b{$T<&V_2b)7B+a3$TmT_yUW&CI!qR*O>n$jj<{qrQFjJZhSY0@y z5@~*e*$H#DG~dSTj5$Y|&gyfec@Oh#gL%^2k982{OY>2zw_$-aw`1)DOPaS}bsujS z5ovyhnSpt+G~dDOh8dNnv-(154rab=h)Huk)?!#B&0MS{wk=H$me;nW*$=A$mP+%t zSocAhG?!x4L%B4a)hncFALAx4x+NEQO042Bqq-QK%v`gu$n<)`X0A20IN%NYf`R7z zcTtfQ4o)`%Rv;L*JYKI^817_rHoZY#z+y-+!^UO^wVmOBDoji~Z)w1NZxbv&`H!XaD)+ zN@xGMEq~^GL%zI#S!8+qMW!crHfQNK^X%)=(Kyd6@c5?&iwd|%p5kymC+XvoajC57 z=Imtte)>GmK0LFe&{t&Ub})J{VQ!Hb3R#}O$rww=#O2o}sWf$M5r=81D;sgMpAQ6y|uEpqxGk?pLswX>x;R=){SdC0H$uUO&6I zr!Izb=QE7+&&(1sXB3; Date: Fri, 18 Aug 2023 10:37:51 +0000 Subject: [PATCH 6/6] update mpm version --- scripts/dev_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev_setup.sh b/scripts/dev_setup.sh index 706bd653..21020108 100755 --- a/scripts/dev_setup.sh +++ b/scripts/dev_setup.sh @@ -19,7 +19,7 @@ Z3_VERSION=4.11.2 CVC5_VERSION=0.0.3 DOTNET_VERSION=6.0 BOOGIE_VERSION=2.15.8 -MPM_VERSION=v1.13.7-alpha +MPM_VERSION=v1.13.7 SCRIPT_PATH="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )"