From 74ea62ad25745eb02548dda6704c65239b530c30 Mon Sep 17 00:00:00 2001 From: Todd Nowacki Date: Sat, 11 Jun 2022 10:20:42 -0700 Subject: [PATCH] Update move version (includes stdlib rename and entry functions) (#2514) * Update move version - Update move version - Update stdlib to lower_snake_case - Switch to entry functions --- Cargo.lock | 77 ++++----- .../tests/call/simple.move | 2 +- .../children/child_of_shared_object.move | 12 +- .../tests/entry_points/no_txn_context.move | 4 +- .../tests/entry_points/wrong_visibility.exp | 6 +- .../sui/move_call_args_type_mismatch.move | 2 +- crates/sui-adapter/Cargo.toml | 16 +- crates/sui-adapter/src/adapter.rs | 14 +- crates/sui-config/Cargo.toml | 4 +- crates/sui-core/Cargo.toml | 12 +- .../unit_tests/data/hero/sources/Hero.move | 24 +-- .../data/hero/sources/TrustedCoin.move | 4 +- .../object_owner/sources/ObjectOwner.move | 40 ++--- .../sources/ObjectWrapping.move | 24 +-- crates/sui-core/tests/staged/sui.yaml | 2 +- crates/sui-framework-build/Cargo.toml | 10 +- crates/sui-framework-build/src/lib.rs | 8 +- crates/sui-framework/Cargo.toml | 20 +-- .../sui-framework/deps/move-stdlib/Move.toml | 2 +- .../sources/{ASCII.move => ascii.move} | 44 ++--- .../sources/{BCS.move => bcs.move} | 2 +- .../{BitVector.move => bit_vector.move} | 44 ++--- .../{Capability.move => capability.move} | 50 +++--- .../sources/{Debug.move => debug.move} | 2 +- .../sources/{Errors.move => errors.move} | 8 +- .../{FixedPoint32.move => fixed_point32.move} | 28 ++-- .../sources/{GUID.move => guid.move} | 12 +- .../sources/{Hash.move => hash.move} | 2 +- .../sources/{Option.move => option.move} | 84 +++++----- .../sources/{Signer.move => signer.move} | 6 +- .../sources/{UnitTest.move => unit_test.move} | 2 +- .../sources/{Vector.move => vector.move} | 10 +- crates/sui-framework/sources/Bag.move | 38 ++--- crates/sui-framework/sources/Coin.move | 22 +-- crates/sui-framework/sources/Collection.move | 44 ++--- crates/sui-framework/sources/DevNetNFT.move | 16 +- .../sui-framework/sources/ERC721Metadata.move | 4 +- .../sources/Governance/Delegation.move | 22 +-- .../sources/Governance/Genesis.move | 26 +-- .../sources/Governance/SuiSystem.move | 16 +- .../sources/Governance/Validator.move | 32 ++-- .../sources/Governance/ValidatorSet.move | 122 +++++++------- crates/sui-framework/sources/ID.move | 8 +- .../sui-framework/sources/ObjectBasics.move | 16 +- crates/sui-framework/sources/SUI.move | 2 +- .../sui-framework/sources/TestScenario.move | 70 ++++---- crates/sui-framework/sources/Transfer.move | 8 +- crates/sui-framework/sources/TxContext.move | 22 +-- crates/sui-framework/sources/UTF8.move | 12 +- crates/sui-framework/sources/Url.move | 8 +- crates/sui-framework/tests/BagTests.move | 8 +- .../sui-framework/tests/CollectionTests.move | 10 +- crates/sui-framework/tests/UrlTests.move | 10 +- .../tests/ValidatorSetTests.move | 2 +- .../sui-framework/tests/ValidatorTests.move | 4 +- crates/sui-gateway/Cargo.toml | 2 +- crates/sui-json/Cargo.toml | 4 +- crates/sui-json/src/lib.rs | 6 +- crates/sui-storage/Cargo.toml | 2 +- .../sui-transactional-test-runner/Cargo.toml | 24 +-- .../src/test_adapter.rs | 2 +- crates/sui-types/Cargo.toml | 12 +- crates/sui-types/src/base_types.rs | 4 +- crates/sui-types/src/error.rs | 4 +- .../generic_and_generic_object_params.mvir | 2 +- .../generic_param_after_primitive.mvir | 2 +- .../entry_points/generic_with_key_invalid.exp | 4 +- .../generic_with_key_invalid.mvir | 8 +- .../entry_points/generic_with_key_valid.mvir | 4 +- .../tests/entry_points/id.mvir | 2 +- .../nested_generic_vector_param.mvir | 2 +- .../nested_key_generic_vector_param.mvir | 2 +- .../tests/entry_points/non_key_struct.mvir | 2 +- .../entry_points/non_key_struct_generic.mvir | 4 +- .../non_key_struct_generic_valid.mvir | 2 +- .../entry_points/non_key_struct_vector.mvir | 2 +- .../tests/entry_points/option.mvir | 14 +- .../entry_points/optional_txn_context.mvir | 4 +- .../tests/entry_points/return_values.mvir | 8 +- .../single_generic_vector_param.mvir | 2 +- .../tests/entry_points/single_type_param.mvir | 2 +- .../single_type_param_generic_object.mvir | 2 +- .../entry_points/single_type_param_key.mvir | 2 +- .../tests/init/cannot_call_init.mvir | 2 +- .../tests/init/not_private.mvir | 2 +- crates/sui-verifier/Cargo.toml | 10 +- .../sui-verifier/src/entry_points_verifier.rs | 9 +- crates/sui/Cargo.toml | 12 +- .../sources/CustomObjectTemplate.move | 2 +- .../sources/TicTacToe.move | 64 ++++---- .../sources/TrustedCoin.move | 4 +- .../sources/TrustedCoin.move | 4 +- crates/test-utils/Cargo.toml | 4 +- crates/workspace-hack/Cargo.toml | 152 +++++++++--------- .../examples/basics/sources/Counter.move | 10 +- .../examples/basics/sources/Lock.move | 18 +-- .../examples/basics/sources/Object.move | 2 +- .../examples/basics/sources/Sandwich.move | 10 +- .../examples/defi/sources/Escrow.move | 4 +- .../examples/defi/sources/FlashLender.move | 6 +- .../examples/defi/sources/SharedEscrow.move | 16 +- .../examples/defi/tests/EscrowTests.move | 10 +- .../examples/defi/tests/FlashLenderTests.move | 2 +- .../examples/defi/tests/SharedEscrowTest.move | 16 +- .../fungible_tokens/sources/MANAGED.move | 4 +- .../examples/games/sources/Hero.move | 34 ++-- .../games/sources/RockPaperScissors.move | 28 ++-- .../examples/games/sources/SeaHero.move | 2 +- .../games/sources/SharedTicTacToe.move | 14 +- .../examples/games/sources/TicTacToe.move | 64 ++++---- .../games/tests/RockPaperScissorsTests.move | 10 +- .../games/tests/SharedTicTacToeTests.move | 6 +- .../examples/games/tests/TicTacToeTests.move | 6 +- .../examples/move_tutorial/sources/M1.move | 6 +- .../examples/nfts/sources/Auction.move | 4 +- .../examples/nfts/sources/AuctionLib.move | 24 +-- .../examples/nfts/sources/Chat.move | 16 +- .../nfts/sources/CrossChainAirdrop.move | 24 +-- .../examples/nfts/sources/DiscountCoupon.move | 6 +- .../examples/nfts/sources/Geniteam.move | 52 +++--- .../examples/nfts/sources/Marketplace.move | 20 +-- .../examples/nfts/sources/SharedAuction.move | 6 +- .../examples/nfts/tests/AuctionTests.move | 14 +- .../examples/nfts/tests/ChatTests.move | 6 +- .../nfts/tests/CrossChainAirdropTests.move | 10 +- .../nfts/tests/DiscountCouponTests.move | 2 +- .../nfts/tests/SharedAuctionTests.move | 14 +- .../objects_tutorial/sources/ColorObject.move | 24 +-- .../sources/SimpleWarrior.move | 30 ++-- .../objects_tutorial/sources/TrustedSwap.move | 8 +- .../regulated_coin/sources/RegulatedCoin.move | 72 ++++----- 131 files changed, 1058 insertions(+), 1036 deletions(-) rename crates/sui-framework/deps/move-stdlib/sources/{ASCII.move => ascii.move} (80%) rename crates/sui-framework/deps/move-stdlib/sources/{BCS.move => bcs.move} (97%) rename crates/sui-framework/deps/move-stdlib/sources/{BitVector.move => bit_vector.move} (76%) rename crates/sui-framework/deps/move-stdlib/sources/{Capability.move => capability.move} (86%) rename crates/sui-framework/deps/move-stdlib/sources/{Debug.move => debug.move} (91%) rename crates/sui-framework/deps/move-stdlib/sources/{Errors.move => errors.move} (91%) rename crates/sui-framework/deps/move-stdlib/sources/{FixedPoint32.move => fixed_point32.move} (89%) rename crates/sui-framework/deps/move-stdlib/sources/{GUID.move => guid.move} (93%) rename crates/sui-framework/deps/move-stdlib/sources/{Hash.move => hash.move} (95%) rename crates/sui-framework/deps/move-stdlib/sources/{Option.move => option.move} (76%) rename crates/sui-framework/deps/move-stdlib/sources/{Signer.move => signer.move} (89%) rename crates/sui-framework/deps/move-stdlib/sources/{UnitTest.move => unit_test.move} (96%) rename crates/sui-framework/deps/move-stdlib/sources/{Vector.move => vector.move} (96%) diff --git a/Cargo.lock b/Cargo.lock index cea0fe108d2ca..907c7322c0133 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -645,7 +645,7 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytecode-interpreter-crypto" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "curve25519-dalek-fiat", @@ -3102,7 +3102,7 @@ dependencies = [ [[package]] name = "move-abigen" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3118,7 +3118,7 @@ dependencies = [ [[package]] name = "move-binary-format" version = "0.0.3" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "move-core-types", @@ -3131,12 +3131,12 @@ dependencies = [ [[package]] name = "move-borrow-graph" version = "0.0.1" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" [[package]] name = "move-bytecode-source-map" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3151,7 +3151,7 @@ dependencies = [ [[package]] name = "move-bytecode-utils" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "move-binary-format", @@ -3163,7 +3163,7 @@ dependencies = [ [[package]] name = "move-bytecode-verifier" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "move-binary-format", @@ -3175,7 +3175,7 @@ dependencies = [ [[package]] name = "move-bytecode-viewer" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "clap 3.1.18", @@ -3192,7 +3192,7 @@ dependencies = [ [[package]] name = "move-cli" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3233,7 +3233,7 @@ dependencies = [ [[package]] name = "move-command-line-common" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "difference", @@ -3248,7 +3248,7 @@ dependencies = [ [[package]] name = "move-compiler" version = "0.0.1" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3277,7 +3277,7 @@ dependencies = [ [[package]] name = "move-core-types" version = "0.0.4" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3292,7 +3292,7 @@ dependencies = [ [[package]] name = "move-coverage" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3312,7 +3312,7 @@ dependencies = [ [[package]] name = "move-disassembler" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "clap 3.1.18", @@ -3330,7 +3330,7 @@ dependencies = [ [[package]] name = "move-docgen" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "codespan", @@ -3348,7 +3348,7 @@ dependencies = [ [[package]] name = "move-errmapgen" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3362,7 +3362,7 @@ dependencies = [ [[package]] name = "move-ir-compiler" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3381,7 +3381,7 @@ dependencies = [ [[package]] name = "move-ir-to-bytecode" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "codespan-reporting", @@ -3400,7 +3400,7 @@ dependencies = [ [[package]] name = "move-ir-to-bytecode-syntax" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "hex", @@ -3413,7 +3413,7 @@ dependencies = [ [[package]] name = "move-ir-types" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "hex", @@ -3427,7 +3427,7 @@ dependencies = [ [[package]] name = "move-model" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "codespan", @@ -3453,7 +3453,7 @@ dependencies = [ [[package]] name = "move-package" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3486,7 +3486,7 @@ dependencies = [ [[package]] name = "move-prover" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "async-trait", @@ -3523,7 +3523,7 @@ dependencies = [ [[package]] name = "move-prover-boogie-backend" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "async-trait", @@ -3551,7 +3551,7 @@ dependencies = [ [[package]] name = "move-read-write-set-types" version = "0.0.3" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "move-binary-format", @@ -3562,7 +3562,7 @@ dependencies = [ [[package]] name = "move-resource-viewer" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3577,7 +3577,7 @@ dependencies = [ [[package]] name = "move-stackless-bytecode" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "codespan", "codespan-reporting", @@ -3604,7 +3604,7 @@ dependencies = [ [[package]] name = "move-stackless-bytecode-interpreter" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bytecode-interpreter-crypto", @@ -3622,8 +3622,9 @@ dependencies = [ [[package]] name = "move-stdlib" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ + "anyhow", "log", "move-binary-format", "move-command-line-common", @@ -3643,7 +3644,7 @@ dependencies = [ [[package]] name = "move-symbol-pool" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "once_cell", "serde 1.0.137", @@ -3652,7 +3653,7 @@ dependencies = [ [[package]] name = "move-table-extension" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "bcs", @@ -3669,7 +3670,7 @@ dependencies = [ [[package]] name = "move-transactional-test-runner" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "clap 3.1.18", @@ -3700,7 +3701,7 @@ dependencies = [ [[package]] name = "move-unit-test" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "clap 3.1.18", @@ -3730,7 +3731,7 @@ dependencies = [ [[package]] name = "move-vm-runtime" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "better_any", "fail", @@ -3747,7 +3748,7 @@ dependencies = [ [[package]] name = "move-vm-test-utils" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "move-core-types", @@ -3756,7 +3757,7 @@ dependencies = [ [[package]] name = "move-vm-types" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "bcs", "move-binary-format", @@ -4936,7 +4937,7 @@ dependencies = [ [[package]] name = "read-write-set" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "move-binary-format", @@ -4951,7 +4952,7 @@ dependencies = [ [[package]] name = "read-write-set-dynamic" version = "0.1.0" -source = "git+https://github.com/move-language/move?rev=1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b#1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" +source = "git+https://github.com/move-language/move?rev=4e15a34ecf155b7e2d9729d3b07f83c146149f02#4e15a34ecf155b7e2d9729d3b07f83c146149f02" dependencies = [ "anyhow", "move-binary-format", diff --git a/crates/sui-adapter-transactional-tests/tests/call/simple.move b/crates/sui-adapter-transactional-tests/tests/call/simple.move index 0996185aecafe..d94cf2e5421d6 100644 --- a/crates/sui-adapter-transactional-tests/tests/call/simple.move +++ b/crates/sui-adapter-transactional-tests/tests/call/simple.move @@ -19,7 +19,7 @@ module Test::M1 { value1 } - public(script) fun create(value: u64, recipient: address, ctx: &mut TxContext) { + public entry fun create(value: u64, recipient: address, ctx: &mut TxContext) { Transfer::transfer( Object { id: TxContext::new_id(ctx), value }, recipient diff --git a/crates/sui-adapter-transactional-tests/tests/children/child_of_shared_object.move b/crates/sui-adapter-transactional-tests/tests/children/child_of_shared_object.move index 6d1da13ef142b..12a4bb8004a3c 100644 --- a/crates/sui-adapter-transactional-tests/tests/children/child_of_shared_object.move +++ b/crates/sui-adapter-transactional-tests/tests/children/child_of_shared_object.move @@ -14,7 +14,7 @@ module T3::O3 { id: VersionedID, } - public(script) fun create(ctx: &mut TxContext) { + public entry fun create(ctx: &mut TxContext) { let o = O3 { id: TxContext::new_id(ctx) }; Transfer::transfer(o, TxContext::sender(ctx)) } @@ -33,15 +33,15 @@ module T2::O2 { child: ChildRef, } - public(script) fun create_shared(child: O3, ctx: &mut TxContext) { + public entry fun create_shared(child: O3, ctx: &mut TxContext) { Transfer::share_object(new(child, ctx)) } - public(script) fun create_owned(child: O3, ctx: &mut TxContext) { + public entry fun create_owned(child: O3, ctx: &mut TxContext) { Transfer::transfer(new(child, ctx), TxContext::sender(ctx)) } - public(script) fun use_o2_o3(_o2: &mut O2, _o3: &mut O3) {} + public entry fun use_o2_o3(_o2: &mut O2, _o3: &mut O3) {} fun new(child: O3, ctx: &mut TxContext): O2 { let id = TxContext::new_id(ctx); @@ -65,12 +65,12 @@ module T1::O1 { child: ChildRef, } - public(script) fun create_shared(child: O2, ctx: &mut TxContext) { + public entry fun create_shared(child: O2, ctx: &mut TxContext) { Transfer::share_object(new(child, ctx)) } // This function will be invalid if _o2 is a shared object and owns _o3. - public(script) fun use_o2_o3(_o2: &mut O2, _o3: &mut O3) {} + public entry fun use_o2_o3(_o2: &mut O2, _o3: &mut O3) {} fun new(child: O2, ctx: &mut TxContext): O1 { let id = TxContext::new_id(ctx); diff --git a/crates/sui-adapter-transactional-tests/tests/entry_points/no_txn_context.move b/crates/sui-adapter-transactional-tests/tests/entry_points/no_txn_context.move index e8f885530ab4e..6a1c2d4c63c0f 100644 --- a/crates/sui-adapter-transactional-tests/tests/entry_points/no_txn_context.move +++ b/crates/sui-adapter-transactional-tests/tests/entry_points/no_txn_context.move @@ -11,14 +11,14 @@ module Test::M { value: u64 } - public(script) fun mint(ctx: &mut TxContext) { + public entry fun mint(ctx: &mut TxContext) { Sui::Transfer::transfer( Obj { id: TxContext::new_id(ctx), value: 0 }, TxContext::sender(ctx), ) } - public(script) fun incr(obj: &mut Obj) { + public entry fun incr(obj: &mut Obj) { obj.value = obj.value + 1 } } diff --git a/crates/sui-adapter-transactional-tests/tests/entry_points/wrong_visibility.exp b/crates/sui-adapter-transactional-tests/tests/entry_points/wrong_visibility.exp index 3a0b84aa39fe5..58f7ef185c698 100644 --- a/crates/sui-adapter-transactional-tests/tests/entry_points/wrong_visibility.exp +++ b/crates/sui-adapter-transactional-tests/tests/entry_points/wrong_visibility.exp @@ -5,10 +5,10 @@ created: object(103) written: object(102) task 2 'run'. lines 26-26: -Error: Function visibility is invalid for an entry point to execution: "Can only call functions with 'public(script)' visibility". +Error: Non-`entry` function used for entry point to execution: "Can only call `entry` functions". task 3 'run'. lines 28-28: -Error: Function visibility is invalid for an entry point to execution: "Can only call functions with 'public(script)' visibility". +Error: Non-`entry` function used for entry point to execution: "Can only call `entry` functions". task 4 'run'. lines 30-30: -Error: Function visibility is invalid for an entry point to execution: "Can only call functions with 'public(script)' visibility". +Error: Non-`entry` function used for entry point to execution: "Can only call `entry` functions". diff --git a/crates/sui-adapter-transactional-tests/tests/sui/move_call_args_type_mismatch.move b/crates/sui-adapter-transactional-tests/tests/sui/move_call_args_type_mismatch.move index 6caa5f368f5d2..396f5bcb24a09 100644 --- a/crates/sui-adapter-transactional-tests/tests/sui/move_call_args_type_mismatch.move +++ b/crates/sui-adapter-transactional-tests/tests/sui/move_call_args_type_mismatch.move @@ -6,7 +6,7 @@ //# publish module Test::M { - public(script) fun create(_value: u64, _recipient: address) {} + public entry fun create(_value: u64, _recipient: address) {} } diff --git a/crates/sui-adapter/Cargo.toml b/crates/sui-adapter/Cargo.toml index 0494e4bc8f3af..b456c47f2cb62 100644 --- a/crates/sui-adapter/Cargo.toml +++ b/crates/sui-adapter/Cargo.toml @@ -13,13 +13,13 @@ bcs = "0.1.3" once_cell = "1.11.0" parking_lot = "0.12.1" -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } -move-cli = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-runtime = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } +move-cli = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-runtime = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } sui-framework = { path = "../sui-framework" } sui-verifier = { path = "../sui-verifier" } @@ -27,4 +27,4 @@ sui-types = { path = "../sui-types" } workspace-hack = { path = "../workspace-hack"} [dev-dependencies] -move-package = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-package = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } diff --git a/crates/sui-adapter/src/adapter.rs b/crates/sui-adapter/src/adapter.rs index a02ce6e4f3d67..9894a18690ebd 100644 --- a/crates/sui-adapter/src/adapter.rs +++ b/crates/sui-adapter/src/adapter.rs @@ -8,7 +8,7 @@ use move_binary_format::{ access::ModuleAccess, binary_views::BinaryIndexedView, errors::PartialVMResult, - file_format::{CompiledModule, LocalIndex, SignatureToken, StructHandleIndex, Visibility}, + file_format::{CompiledModule, LocalIndex, SignatureToken, StructHandleIndex}, }; use sui_framework::EventType; use sui_types::{ @@ -685,14 +685,14 @@ pub fn resolve_and_type_check( }) } }; - // Check for script visibility, but ignore for genesis. - // Genesis calls private functions, and bypasses this rule. This is helpful for ensuring the - // functions are not called again later. + // Check for entry modifier, but ignore for genesis. + // Genesis calls non-entry, private functions, and bypasses this rule. This is helpful for + // ensuring the functions are not called again later. // In other words, this is an implementation detail that we are using `execute` for genesis // functions, and as such need to bypass this check. - if fdef.visibility != Visibility::Script && !is_genesis { - return Err(SuiError::InvalidFunctionVisibility { - error: "Can only call functions with 'public(script)' visibility".to_string(), + if !fdef.is_entry && !is_genesis { + return Err(SuiError::InvalidNonEntryFunction { + error: "Can only call `entry` functions".to_string(), }); } let fhandle = module.function_handle_at(fdef.function); diff --git a/crates/sui-config/Cargo.toml b/crates/sui-config/Cargo.toml index e5abc845b92a3..36bbb27dc592d 100644 --- a/crates/sui-config/Cargo.toml +++ b/crates/sui-config/Cargo.toml @@ -21,8 +21,8 @@ tracing = "0.1.34" narwhal-config = { git = "https://github.com/MystenLabs/narwhal", rev = "2c5e8236c0702a3ff47dd769c2bbc94b029bf4a9", package = "config" } narwhal-crypto = { git = "https://github.com/MystenLabs/narwhal", rev = "2c5e8236c0702a3ff47dd769c2bbc94b029bf4a9", package = "crypto" } -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-package = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-package = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } sui-framework = { path = "../sui-framework" } diff --git a/crates/sui-core/Cargo.toml b/crates/sui-core/Cargo.toml index 88a24ea2471bc..013fe9fdbd8ad 100644 --- a/crates/sui-core/Cargo.toml +++ b/crates/sui-core/Cargo.toml @@ -50,12 +50,12 @@ sui-storage = { path = "../sui-storage" } sui-config = { path = "../sui-config" } sui-json = { path = "../sui-json" } -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } -move-package = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-runtime = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } +move-package = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-runtime = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "ff5c1d69057fe93be658377462ca2875a57a0223"} diff --git a/crates/sui-core/src/unit_tests/data/hero/sources/Hero.move b/crates/sui-core/src/unit_tests/data/hero/sources/Hero.move index 45dc25d207652..cd7a550f709a4 100644 --- a/crates/sui-core/src/unit_tests/data/hero/sources/Hero.move +++ b/crates/sui-core/src/unit_tests/data/hero/sources/Hero.move @@ -11,7 +11,7 @@ module Examples::Hero { use Sui::Math; use Sui::Transfer; use Sui::TxContext::{Self, TxContext}; - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; /// Our hero! struct Hero has key, store { @@ -114,7 +114,7 @@ module Examples::Hero { /// Slay the `boar` with the `hero`'s sword, get experience. /// Aborts if the hero has 0 HP or is not strong enough to slay the boar - public(script) fun slay(hero: &mut Hero, boar: Boar, ctx: &mut TxContext) { + public entry fun slay(hero: &mut Hero, boar: Boar, ctx: &mut TxContext) { let Boar { id: boar_id, strength: boar_strength, hp } = boar; let hero_strength = hero_strength(hero); let boar_hp = hp; @@ -134,8 +134,8 @@ module Examples::Hero { // hero gains experience proportional to the boar, sword grows in // strength by one (if hero is using a sword) hero.experience = hero.experience + hp; - if (Option::is_some(&hero.sword)) { - level_up_sword(Option::borrow_mut(&mut hero.sword), 1) + if (option::is_some(&hero.sword)) { + level_up_sword(option::borrow_mut(&mut hero.sword), 1) }; // let the world know about the hero's triumph by emitting an event! Event::emit(BoarSlainEvent { @@ -154,8 +154,8 @@ module Examples::Hero { return 0 }; - let sword_strength = if (Option::is_some(&hero.sword)) { - sword_strength(Option::borrow(&hero.sword)) + let sword_strength = if (option::is_some(&hero.sword)) { + sword_strength(option::borrow(&hero.sword)) } else { // hero can fight without a sword, but will not be very strong 0 @@ -187,14 +187,14 @@ module Examples::Hero { /// Add `new_sword` to the hero's inventory and return the old sword /// (if any) public fun equip_sword(hero: &mut Hero, new_sword: Sword): Option { - Option::swap_or_fill(&mut hero.sword, new_sword) + option::swap_or_fill(&mut hero.sword, new_sword) } /// Disarm the hero by returning their sword. /// Aborts if the hero does not have a sword. public fun remove_sword(hero: &mut Hero): Sword { - assert!(Option::is_some(&hero.sword), ENO_SWORD); - Option::extract(&mut hero.sword) + assert!(option::is_some(&hero.sword), ENO_SWORD); + option::extract(&mut hero.sword) } // --- Object creation --- @@ -222,7 +222,7 @@ module Examples::Hero { } } - public(script) fun acquire_hero(payment: Coin, ctx: &mut TxContext) { + public entry fun acquire_hero(payment: Coin, ctx: &mut TxContext) { let sword = create_sword(payment, ctx); let hero = create_hero(sword, ctx); Transfer::transfer(hero, TxContext::sender(ctx)) @@ -235,7 +235,7 @@ module Examples::Hero { id: TxContext::new_id(ctx), hp: 100, experience: 0, - sword: Option::some(sword), + sword: option::some(sword), } } @@ -283,7 +283,7 @@ module Examples::Hero { public fun delete_hero_for_testing(hero: Hero) { let Hero { id, hp: _, experience: _, sword } = hero; ID::delete(id); - let sword = Option::destroy_some(sword); + let sword = option::destroy_some(sword); let Sword { id, magic: _, strength: _ } = sword; ID::delete(id) } diff --git a/crates/sui-core/src/unit_tests/data/hero/sources/TrustedCoin.move b/crates/sui-core/src/unit_tests/data/hero/sources/TrustedCoin.move index d057a13aeb7e3..2a7b896558bb4 100644 --- a/crates/sui-core/src/unit_tests/data/hero/sources/TrustedCoin.move +++ b/crates/sui-core/src/unit_tests/data/hero/sources/TrustedCoin.move @@ -20,12 +20,12 @@ module Examples::TrustedCoin { Transfer::transfer(treasury_cap, TxContext::sender(ctx)) } - public(script) fun mint(treasury_cap: &mut TreasuryCap, amount: u64, ctx: &mut TxContext) { + public entry fun mint(treasury_cap: &mut TreasuryCap, amount: u64, ctx: &mut TxContext) { let coin = Coin::mint(amount, treasury_cap, ctx); Coin::transfer(coin, TxContext::sender(ctx)); } - public(script) fun transfer(treasury_cap: TreasuryCap, recipient: address) { + public entry fun transfer(treasury_cap: TreasuryCap, recipient: address) { Coin::transfer_cap(treasury_cap, recipient); } diff --git a/crates/sui-core/src/unit_tests/data/object_owner/sources/ObjectOwner.move b/crates/sui-core/src/unit_tests/data/object_owner/sources/ObjectOwner.move index 431c42e60633f..cf3145e41b20f 100644 --- a/crates/sui-core/src/unit_tests/data/object_owner/sources/ObjectOwner.move +++ b/crates/sui-core/src/unit_tests/data/object_owner/sources/ObjectOwner.move @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 module ObjectOwner::ObjectOwner { - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; use Sui::ID::{Self, VersionedID}; use Sui::Transfer::{Self, ChildRef}; use Sui::TxContext::{Self, TxContext}; @@ -21,72 +21,72 @@ module ObjectOwner::ObjectOwner { child: ChildRef, } - public(script) fun create_child(ctx: &mut TxContext) { + public entry fun create_child(ctx: &mut TxContext) { Transfer::transfer( Child { id: TxContext::new_id(ctx) }, TxContext::sender(ctx), ); } - public(script) fun create_parent(ctx: &mut TxContext) { + public entry fun create_parent(ctx: &mut TxContext) { let parent = Parent { id: TxContext::new_id(ctx), - child: Option::none(), + child: option::none(), }; Transfer::transfer(parent, TxContext::sender(ctx)); } - public(script) fun create_parent_and_child(ctx: &mut TxContext) { + public entry fun create_parent_and_child(ctx: &mut TxContext) { let parent_id = TxContext::new_id(ctx); let child = Child { id: TxContext::new_id(ctx) }; let (parent_id, child_ref) = Transfer::transfer_to_object_id(child, parent_id); let parent = Parent { id: parent_id, - child: Option::some(child_ref), + child: option::some(child_ref), }; Transfer::transfer(parent, TxContext::sender(ctx)); } - public(script) fun add_child(parent: &mut Parent, child: Child) { + public entry fun add_child(parent: &mut Parent, child: Child) { let child_ref = Transfer::transfer_to_object(child, parent); - Option::fill(&mut parent.child, child_ref); + option::fill(&mut parent.child, child_ref); } // Call to mutate_child will fail if its owned by a parent, // since all owners must be in the arguments for authentication. - public(script) fun mutate_child(_child: &mut Child) {} + public entry fun mutate_child(_child: &mut Child) {} // This should always succeeds, even when child is not owned by parent. - public(script) fun mutate_child_with_parent(_child: &mut Child, _parent: &mut Parent) {} + public entry fun mutate_child_with_parent(_child: &mut Child, _parent: &mut Parent) {} - public(script) fun transfer_child(parent: &mut Parent, child: Child, new_parent: &mut Parent) { - let child_ref = Option::extract(&mut parent.child); + public entry fun transfer_child(parent: &mut Parent, child: Child, new_parent: &mut Parent) { + let child_ref = option::extract(&mut parent.child); let new_child_ref = Transfer::transfer_child_to_object(child, child_ref, new_parent); - Option::fill(&mut new_parent.child, new_child_ref); + option::fill(&mut new_parent.child, new_child_ref); } - public(script) fun remove_child(parent: &mut Parent, child: Child, ctx: &mut TxContext) { - let child_ref = Option::extract(&mut parent.child); + public entry fun remove_child(parent: &mut Parent, child: Child, ctx: &mut TxContext) { + let child_ref = option::extract(&mut parent.child); Transfer::transfer_child_to_address(child, child_ref, TxContext::sender(ctx)); } // Call to delete_child can fail if it's still owned by a parent. - public(script) fun delete_child(child: Child, _parent: &mut Parent) { + public entry fun delete_child(child: Child, _parent: &mut Parent) { let Child { id } = child; ID::delete(id); } - public(script) fun delete_parent_and_child(parent: Parent, child: Child) { + public entry fun delete_parent_and_child(parent: Parent, child: Child) { let Parent { id: parent_id, child: child_ref_opt } = parent; - let child_ref = Option::extract(&mut child_ref_opt); - Option::destroy_none(child_ref_opt); + let child_ref = option::extract(&mut child_ref_opt); + option::destroy_none(child_ref_opt); ID::delete(parent_id); let Child { id: child_id } = child; Transfer::delete_child_object(child_id, child_ref); } - public(script) fun create_another_parent(child: Child, ctx: &mut TxContext) { + public entry fun create_another_parent(child: Child, ctx: &mut TxContext) { let id = TxContext::new_id(ctx); let (id, child_ref) = Transfer::transfer_to_object_id(child, id); let parent = AnotherParent { diff --git a/crates/sui-core/src/unit_tests/data/object_wrapping/sources/ObjectWrapping.move b/crates/sui-core/src/unit_tests/data/object_wrapping/sources/ObjectWrapping.move index 530b2d5a931ca..8e5b91d72c7bf 100644 --- a/crates/sui-core/src/unit_tests/data/object_wrapping/sources/ObjectWrapping.move +++ b/crates/sui-core/src/unit_tests/data/object_wrapping/sources/ObjectWrapping.move @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 module ObjectWrapping::ObjectWrapping { - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; use Sui::Transfer; use Sui::TxContext::{Self, TxContext}; use Sui::ID::{Self, VersionedID}; @@ -16,7 +16,7 @@ module ObjectWrapping::ObjectWrapping { child: Option, } - public(script) fun create_child(ctx: &mut TxContext) { + public entry fun create_child(ctx: &mut TxContext) { Transfer::transfer( Child { id: TxContext::new_id(ctx), @@ -25,36 +25,36 @@ module ObjectWrapping::ObjectWrapping { ) } - public(script) fun create_parent(child: Child, ctx: &mut TxContext) { + public entry fun create_parent(child: Child, ctx: &mut TxContext) { Transfer::transfer( Parent { id: TxContext::new_id(ctx), - child: Option::some(child), + child: option::some(child), }, TxContext::sender(ctx), ) } - public(script) fun set_child(parent: &mut Parent, child: Child) { - Option::fill(&mut parent.child, child) + public entry fun set_child(parent: &mut Parent, child: Child) { + option::fill(&mut parent.child, child) } - public(script) fun extract_child(parent: &mut Parent, ctx: &mut TxContext) { - let child = Option::extract(&mut parent.child); + public entry fun extract_child(parent: &mut Parent, ctx: &mut TxContext) { + let child = option::extract(&mut parent.child); Transfer::transfer( child, TxContext::sender(ctx), ) } - public(script) fun delete_parent(parent: Parent) { + public entry fun delete_parent(parent: Parent) { let Parent { id: parent_id, child: child_opt } = parent; ID::delete(parent_id); - if (Option::is_some(&child_opt)) { - let child = Option::extract(&mut child_opt); + if (option::is_some(&child_opt)) { + let child = option::extract(&mut child_opt); let Child { id: child_id } = child; ID::delete(child_id); }; - Option::destroy_none(child_opt) + option::destroy_none(child_opt) } } diff --git a/crates/sui-core/tests/staged/sui.yaml b/crates/sui-core/tests/staged/sui.yaml index ff575c725eea7..063813ba8d74d 100644 --- a/crates/sui-core/tests/staged/sui.yaml +++ b/crates/sui-core/tests/staged/sui.yaml @@ -483,7 +483,7 @@ SuiError: STRUCT: - error: STR 67: - InvalidFunctionVisibility: + InvalidNonEntryFunction: STRUCT: - error: STR 68: diff --git a/crates/sui-framework-build/Cargo.toml b/crates/sui-framework-build/Cargo.toml index f41914d67b5ce..2c8f2fcc5f161 100644 --- a/crates/sui-framework-build/Cargo.toml +++ b/crates/sui-framework-build/Cargo.toml @@ -12,9 +12,9 @@ publish = false sui-types = { path = "../sui-types" } sui-verifier = { path = "../../crates/sui-verifier" } -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-compiler = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } -move-package = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-compiler = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } +move-package = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } workspace-hack = { path = "../workspace-hack"} diff --git a/crates/sui-framework-build/src/lib.rs b/crates/sui-framework-build/src/lib.rs index ee98d8fecb47a..eb088837f0d5d 100644 --- a/crates/sui-framework-build/src/lib.rs +++ b/crates/sui-framework-build/src/lib.rs @@ -17,11 +17,11 @@ pub fn build_sui_framework_modules(lib_dir: &Path) -> SuiResult SuiResult> { let denylist = vec![ - ident_str!("Capability").to_owned(), - ident_str!("Event").to_owned(), - ident_str!("GUID").to_owned(), + ident_str!("capability").to_owned(), + ident_str!("event").to_owned(), + ident_str!("guid").to_owned(), #[cfg(not(test))] - ident_str!("Debug").to_owned(), + ident_str!("debug").to_owned(), ]; let modules: Vec = build_framework(lib_dir)? .into_iter() diff --git a/crates/sui-framework/Cargo.toml b/crates/sui-framework/Cargo.toml index 0a54b1b48f9d1..275b2da914487 100644 --- a/crates/sui-framework/Cargo.toml +++ b/crates/sui-framework/Cargo.toml @@ -18,22 +18,22 @@ once_cell = "1.11.0" sui-types = { path = "../sui-types" } sui-framework-build = { path = "../sui-framework-build" } -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-cli = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } -move-package = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-stdlib = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-unit-test = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-runtime = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-cli = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } +move-package = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-stdlib = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-unit-test = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-runtime = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } workspace-hack = { path = "../workspace-hack"} [build-dependencies] anyhow = { version = "1.0.57", features = ["backtrace"] } bcs = "0.1.3" sui-framework-build = { path = "../sui-framework-build" } -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } [package.metadata.cargo-udeps.ignore] normal = ["move-cli", "move-unit-test"] diff --git a/crates/sui-framework/deps/move-stdlib/Move.toml b/crates/sui-framework/deps/move-stdlib/Move.toml index 7b351711b769e..15b23a4e45bff 100644 --- a/crates/sui-framework/deps/move-stdlib/Move.toml +++ b/crates/sui-framework/deps/move-stdlib/Move.toml @@ -3,4 +3,4 @@ name = "MoveStdlib" version = "1.5.0" [addresses] -Std = "0x1" +std = "0x1" diff --git a/crates/sui-framework/deps/move-stdlib/sources/ASCII.move b/crates/sui-framework/deps/move-stdlib/sources/ascii.move similarity index 80% rename from crates/sui-framework/deps/move-stdlib/sources/ASCII.move rename to crates/sui-framework/deps/move-stdlib/sources/ascii.move index 51f14fefaf7c3..eb9f53f403442 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/ASCII.move +++ b/crates/sui-framework/deps/move-stdlib/sources/ascii.move @@ -3,10 +3,10 @@ /// The `ASCII` module defines basic string and char newtypes in Move that verify /// that characters are valid ASCII, and that strings consist of only valid ASCII characters. -module Std::ASCII { - use Std::Vector; - use Std::Errors; - use Std::Option::{Self, Option}; +module std::ascii { + use std::vector; + use std::errors; + use std::option::{Self, Option}; /// An invalid ASCII character was encountered when creating an ASCII string. const EINVALID_ASCII_CHARACTER: u64 = 0; @@ -33,11 +33,11 @@ module Std::ASCII { /// Convert a `byte` into a `Char` that is checked to make sure it is valid ASCII. public fun char(byte: u8): Char { - assert!(is_valid_char(byte), Errors::invalid_argument(EINVALID_ASCII_CHARACTER)); + assert!(is_valid_char(byte), errors::invalid_argument(EINVALID_ASCII_CHARACTER)); Char { byte } } spec char { - aborts_if !is_valid_char(byte) with Errors::INVALID_ARGUMENT; + aborts_if !is_valid_char(byte) with errors::INVALID_ARGUMENT; } /// Convert a vector of bytes `bytes` into an `String`. Aborts if @@ -45,20 +45,20 @@ module Std::ASCII { public fun string(bytes: vector): String { let x = try_string(bytes); assert!( - Option::is_some(&x), - Errors::invalid_argument(EINVALID_ASCII_CHARACTER) + option::is_some(&x), + errors::invalid_argument(EINVALID_ASCII_CHARACTER) ); - Option::destroy_some(x) + option::destroy_some(x) } spec string { - aborts_if exists i in 0..len(bytes): !is_valid_char(bytes[i]) with Errors::INVALID_ARGUMENT; + aborts_if exists i in 0..len(bytes): !is_valid_char(bytes[i]) with errors::INVALID_ARGUMENT; } /// Convert a vector of bytes `bytes` into an `String`. Returns /// `Some()` if the `bytes` contains all valid ASCII /// characters. Otherwise returns `None`. public fun try_string(bytes: vector): Option { - let len = Vector::length(&bytes); + let len = vector::length(&bytes); let i = 0; while ({ spec { @@ -67,21 +67,21 @@ module Std::ASCII { }; i < len }) { - let possible_byte = *Vector::borrow(&bytes, i); - if (!is_valid_char(possible_byte)) return Option::none(); + let possible_byte = *vector::borrow(&bytes, i); + if (!is_valid_char(possible_byte)) return option::none(); i = i + 1; }; spec { assert i == len; assert forall j in 0..len: is_valid_char(bytes[j]); }; - Option::some(String { bytes }) + option::some(String { bytes }) } /// Returns `true` if all characters in `string` are printable characters /// Returns `false` otherwise. Not all `String`s are printable strings. public fun all_characters_printable(string: &String): bool { - let len = Vector::length(&string.bytes); + let len = vector::length(&string.bytes); let i = 0; while ({ spec { @@ -90,7 +90,7 @@ module Std::ASCII { }; i < len }) { - let byte = *Vector::borrow(&string.bytes, i); + let byte = *vector::borrow(&string.bytes, i); if (!is_printable_char(byte)) return false; i = i + 1; }; @@ -105,21 +105,21 @@ module Std::ASCII { } public fun push_char(string: &mut String, char: Char) { - Vector::push_back(&mut string.bytes, char.byte); + vector::push_back(&mut string.bytes, char.byte); } spec push_char { ensures len(string.bytes) == len(old(string.bytes)) + 1; } public fun pop_char(string: &mut String): Char { - Char { byte: Vector::pop_back(&mut string.bytes) } + Char { byte: vector::pop_back(&mut string.bytes) } } spec pop_char { ensures len(string.bytes) == len(old(string.bytes)) - 1; } public fun length(string: &String): u64 { - Vector::length(as_bytes(string)) + vector::length(as_bytes(string)) } /// Get the inner bytes of the `string` as a reference @@ -139,9 +139,9 @@ module Std::ASCII { byte } - /// Returns `true` if `byte` is a valid ASCII character. Returns `false` otherwise. - public fun is_valid_char(byte: u8): bool { - byte <= 0x7F + /// Returns `true` if `b` is a valid ASCII character. Returns `false` otherwise. + public fun is_valid_char(b: u8): bool { + b <= 0x7F } /// Returns `true` if `byte` is an printable ASCII character. Returns `false` otherwise. diff --git a/crates/sui-framework/deps/move-stdlib/sources/BCS.move b/crates/sui-framework/deps/move-stdlib/sources/bcs.move similarity index 97% rename from crates/sui-framework/deps/move-stdlib/sources/BCS.move rename to crates/sui-framework/deps/move-stdlib/sources/bcs.move index fccf887032c09..e6c9a1f2db7e9 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/BCS.move +++ b/crates/sui-framework/deps/move-stdlib/sources/bcs.move @@ -5,7 +5,7 @@ /// Serialization). BCS is the binary encoding for Move resources and other non-module values /// published on-chain. See https://github.com/diem/bcs#binary-canonical-serialization-bcs for more /// details on BCS. -module Std::BCS { +module std::bcs { /// Return the binary representation of `v` in BCS (Binary Canonical Serialization) format native public fun to_bytes(v: &MoveValue): vector; diff --git a/crates/sui-framework/deps/move-stdlib/sources/BitVector.move b/crates/sui-framework/deps/move-stdlib/sources/bit_vector.move similarity index 76% rename from crates/sui-framework/deps/move-stdlib/sources/BitVector.move rename to crates/sui-framework/deps/move-stdlib/sources/bit_vector.move index afcce8c32cc63..69aa6b2ec96d8 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/BitVector.move +++ b/crates/sui-framework/deps/move-stdlib/sources/bit_vector.move @@ -1,9 +1,9 @@ // Copyright (c) 2022, Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 -module Std::BitVector { - use Std::Vector; - use Std::Errors; +module std::bit_vector { + use std::vector; + use std::errors; /// The provided index is out of bounds const EINDEX: u64 = 0; @@ -20,16 +20,16 @@ module Std::BitVector { } public fun new(length: u64): BitVector { - assert!(length > 0, Errors::invalid_argument(ELENGTH)); - assert!(length < MAX_SIZE, Errors::invalid_argument(ELENGTH)); + assert!(length > 0, errors::invalid_argument(ELENGTH)); + assert!(length < MAX_SIZE, errors::invalid_argument(ELENGTH)); let counter = 0; - let bit_field = Vector::empty(); + let bit_field = vector::empty(); while ({spec { invariant counter <= length; invariant len(bit_field) == counter; }; (counter < length)}) { - Vector::push_back(&mut bit_field, false); + vector::push_back(&mut bit_field, false); counter = counter + 1; }; spec { @@ -49,14 +49,14 @@ module Std::BitVector { } spec schema NewAbortsIf { length: u64; - aborts_if length <= 0 with Errors::INVALID_ARGUMENT; - aborts_if length >= MAX_SIZE with Errors::INVALID_ARGUMENT; + aborts_if length <= 0 with errors::INVALID_ARGUMENT; + aborts_if length >= MAX_SIZE with errors::INVALID_ARGUMENT; } /// Set the bit at `bit_index` in the `bitvector` regardless of its previous state. public fun set(bitvector: &mut BitVector, bit_index: u64) { - assert!(bit_index < Vector::length(&bitvector.bit_field), Errors::invalid_argument(EINDEX)); - let x = Vector::borrow_mut(&mut bitvector.bit_field, bit_index); + assert!(bit_index < vector::length(&bitvector.bit_field), errors::invalid_argument(EINDEX)); + let x = vector::borrow_mut(&mut bitvector.bit_field, bit_index); *x = true; } spec set { @@ -66,13 +66,13 @@ module Std::BitVector { spec schema SetAbortsIf { bitvector: BitVector; bit_index: u64; - aborts_if bit_index >= length(bitvector) with Errors::INVALID_ARGUMENT; + aborts_if bit_index >= length(bitvector) with errors::INVALID_ARGUMENT; } /// Unset the bit at `bit_index` in the `bitvector` regardless of its previous state. public fun unset(bitvector: &mut BitVector, bit_index: u64) { - assert!(bit_index < Vector::length(&bitvector.bit_field), Errors::invalid_argument(EINDEX)); - let x = Vector::borrow_mut(&mut bitvector.bit_field, bit_index); + assert!(bit_index < vector::length(&bitvector.bit_field), errors::invalid_argument(EINDEX)); + let x = vector::borrow_mut(&mut bitvector.bit_field, bit_index); *x = false; } spec set { @@ -82,17 +82,17 @@ module Std::BitVector { spec schema UnsetAbortsIf { bitvector: BitVector; bit_index: u64; - aborts_if bit_index >= length(bitvector) with Errors::INVALID_ARGUMENT; + aborts_if bit_index >= length(bitvector) with errors::INVALID_ARGUMENT; } /// Shift the `bitvector` left by `amount`. If `amount` is greater than the /// bitvector's length the bitvector will be zeroed out. public fun shift_left(bitvector: &mut BitVector, amount: u64) { if (amount >= bitvector.length) { - let len = Vector::length(&bitvector.bit_field); + let len = vector::length(&bitvector.bit_field); let i = 0; while (i < len) { - let elem = Vector::borrow_mut(&mut bitvector.bit_field, i); + let elem = vector::borrow_mut(&mut bitvector.bit_field, i); *elem = false; i = i + 1; }; @@ -117,8 +117,8 @@ module Std::BitVector { /// Return the value of the bit at `bit_index` in the `bitvector`. `true` /// represents "1" and `false` represents a 0 public fun is_index_set(bitvector: &BitVector, bit_index: u64): bool { - assert!(bit_index < Vector::length(&bitvector.bit_field), Errors::invalid_argument(EINDEX)); - *Vector::borrow(&bitvector.bit_field, bit_index) + assert!(bit_index < vector::length(&bitvector.bit_field), errors::invalid_argument(EINDEX)); + *vector::borrow(&bitvector.bit_field, bit_index) } spec is_index_set { include IsIndexSetAbortsIf; @@ -127,7 +127,7 @@ module Std::BitVector { spec schema IsIndexSetAbortsIf { bitvector: BitVector; bit_index: u64; - aborts_if bit_index >= length(bitvector) with Errors::INVALID_ARGUMENT; + aborts_if bit_index >= length(bitvector) with errors::INVALID_ARGUMENT; } spec fun spec_is_index_set(bitvector: BitVector, bit_index: u64): bool { if (bit_index >= length(bitvector)) { @@ -139,14 +139,14 @@ module Std::BitVector { /// Return the length (number of usable bits) of this bitvector public fun length(bitvector: &BitVector): u64 { - Vector::length(&bitvector.bit_field) + vector::length(&bitvector.bit_field) } /// Returns the length of the longest sequence of set bits starting at (and /// including) `start_index` in the `bitvector`. If there is no such /// sequence, then `0` is returned. public fun longest_set_sequence_starting_at(bitvector: &BitVector, start_index: u64): u64 { - assert!(start_index < bitvector.length, Errors::invalid_argument(EINDEX)); + assert!(start_index < bitvector.length, errors::invalid_argument(EINDEX)); let index = start_index; // Find the greatest index in the vector such that all indices less than it are set. diff --git a/crates/sui-framework/deps/move-stdlib/sources/Capability.move b/crates/sui-framework/deps/move-stdlib/sources/capability.move similarity index 86% rename from crates/sui-framework/deps/move-stdlib/sources/Capability.move rename to crates/sui-framework/deps/move-stdlib/sources/capability.move index 69a907d6fd615..8f9f076a60007 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/Capability.move +++ b/crates/sui-framework/deps/move-stdlib/sources/capability.move @@ -9,7 +9,7 @@ /// # Overview /// /// A capability is a unforgeable token which testifies that a signer has authorized a certain operation. -/// The token is valid during the transaction where it is obtained. Since the type `Capability::Cap` has +/// The token is valid during the transaction where it is obtained. Since the type `capability::Cap` has /// no ability to be stored in global memory, capabilities cannot leak out of a transaction. For every function /// called within a transaction which has a capability as a parameter, it is guaranteed that the capability /// has been obtained via a proper signer-based authorization step previously in the transaction's execution. @@ -21,7 +21,7 @@ /// /// ``` /// module Pkg::Feature { -/// use Std::Capability::Cap; +/// use std::capability::Cap; /// /// /// A type tag used in Cap. Only this module can create an instance, /// /// and there is no public function other than Self::acquire which returns a value of this type. @@ -34,13 +34,13 @@ /// // One needs to provide a witness for being the owner of Feature /// // in the 2nd parameter. /// <> -/// Capability::create(s, &Feature{}); +/// capability::create(s, &Feature{}); /// } /// /// /// Acquires the capability to work with this feature. /// public fun acquire(s: &signer): Cap { /// <> -/// Capability::acquire(s, &Feature{}); +/// capability::acquire(s, &Feature{}); /// } /// /// /// Does something related to the feature. The caller must pass a Cap. @@ -61,23 +61,23 @@ /// all together for a capability, one can use the following invariant: /// /// ``` -/// invariant forall a: address where Capability::spec_has_cap(a): -/// len(Capability::spec_delegates(a)) == 0; +/// invariant forall a: address where capability::spec_has_cap(a): +/// len(capability::spec_delegates(a)) == 0; /// ``` /// /// Similarly, the following invariant would enforce that delegates, if existent, must satisfy a certain /// predicate: /// /// ``` -/// invariant forall a: address where Capability::spec_has_cap(a): -/// forall d in Capability::spec_delegates(a): +/// invariant forall a: address where capability::spec_has_cap(a): +/// forall d in capability::spec_delegates(a): /// is_valid_delegate_for_feature(d); /// ``` /// -module Std::Capability { - use Std::Errors; - use Std::Signer; - use Std::Vector; +module std::capability { + use std::errors; + use std::signer; + use std::vector; const ECAP: u64 = 0; const EDELEGATE: u64 = 1; @@ -106,9 +106,9 @@ module Std::Capability { /// Creates a new capability class, owned by the passed signer. A caller must pass a witness that /// they own the `Feature` type parameter. public fun create(owner: &signer, _feature_witness: &Feature) { - let addr = Signer::address_of(owner); - assert!(!exists>(addr), Errors::already_published(ECAP)); - move_to>(owner, CapState{ delegates: Vector::empty() }); + let addr = signer::address_of(owner); + assert!(!exists>(addr), errors::already_published(ECAP)); + move_to>(owner, CapState{ delegates: vector::empty() }); } /// Acquires a capability token. Only the owner of the capability class, or an authorized delegate, @@ -129,16 +129,16 @@ module Std::Capability { /// Helper to validate an acquire. Returns the root address of the capability. fun validate_acquire(requester: &signer): address acquires CapState, CapDelegateState { - let addr = Signer::address_of(requester); + let addr = signer::address_of(requester); if (exists>(addr)) { let root_addr = borrow_global>(addr).root; // double check that requester is actually registered as a delegate - assert!(exists>(root_addr), Errors::invalid_state(EDELEGATE)); - assert!(Vector::contains(&borrow_global>(root_addr).delegates, &addr), - Errors::invalid_state(EDELEGATE)); + assert!(exists>(root_addr), errors::invalid_state(EDELEGATE)); + assert!(vector::contains(&borrow_global>(root_addr).delegates, &addr), + errors::invalid_state(EDELEGATE)); root_addr } else { - assert!(exists>(addr), Errors::not_published(ECAP)); + assert!(exists>(addr), errors::not_published(ECAP)); addr } } @@ -159,7 +159,7 @@ module Std::Capability { // TODO: explore whether this should be idempotent like now or abort public fun delegate(cap: Cap, _feature_witness: &Feature, to: &signer) acquires CapState { - let addr = Signer::address_of(to); + let addr = signer::address_of(to); if (exists>(addr)) return; move_to(to, CapDelegateState{root: cap.root}); add_element(&mut borrow_global_mut>(cap.root).delegates, addr); @@ -177,16 +177,16 @@ module Std::Capability { /// Helper to remove an element from a vector. fun remove_element(v: &mut vector, x: &E) { - let (found, index) = Vector::index_of(v, x); + let (found, index) = vector::index_of(v, x); if (found) { - Vector::remove(v, index); + vector::remove(v, index); } } /// Helper to add an element to a vector. fun add_element(v: &mut vector, x: E) { - if (!Vector::contains(v, &x)) { - Vector::push_back(v, x) + if (!vector::contains(v, &x)) { + vector::push_back(v, x) } } diff --git a/crates/sui-framework/deps/move-stdlib/sources/Debug.move b/crates/sui-framework/deps/move-stdlib/sources/debug.move similarity index 91% rename from crates/sui-framework/deps/move-stdlib/sources/Debug.move rename to crates/sui-framework/deps/move-stdlib/sources/debug.move index 6af0608bd875e..88fe954c26289 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/Debug.move +++ b/crates/sui-framework/deps/move-stdlib/sources/debug.move @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 /// Module providing debug functionality. -module Std::Debug { +module std::debug { native public fun print(x: &T); native public fun print_stack_trace(); diff --git a/crates/sui-framework/deps/move-stdlib/sources/Errors.move b/crates/sui-framework/deps/move-stdlib/sources/errors.move similarity index 91% rename from crates/sui-framework/deps/move-stdlib/sources/Errors.move rename to crates/sui-framework/deps/move-stdlib/sources/errors.move index e589b46d38ad6..b743b12bffbbb 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/Errors.move +++ b/crates/sui-framework/deps/move-stdlib/sources/errors.move @@ -15,14 +15,18 @@ /// framework evolves. /// /// >TODO: determine what kind of stability guarantees we give about reasons/associated module. -module Std::Errors { +module std::errors { /// A function to create an error from from a category and a reason. fun make(category: u8, reason: u64): u64 { (category as u64) + (reason << 8) } spec make { pragma opaque = true; - ensures [concrete] result == category + (reason << 8); + // The % below is to account for bits that could be shifted off the left end. + // For correctness, we would like that never to happen, but I'm cautious about + // using assert! in this module (no other uses), and require is just going to + // cause verification errors in public calling functions below. + ensures [concrete] result == category + (reason << 8) % (1 << 64); aborts_if [abstract] false; ensures [abstract] result == category; } diff --git a/crates/sui-framework/deps/move-stdlib/sources/FixedPoint32.move b/crates/sui-framework/deps/move-stdlib/sources/fixed_point32.move similarity index 89% rename from crates/sui-framework/deps/move-stdlib/sources/FixedPoint32.move rename to crates/sui-framework/deps/move-stdlib/sources/fixed_point32.move index 6e0e8bc60b54c..c1b2ae13fe736 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/FixedPoint32.move +++ b/crates/sui-framework/deps/move-stdlib/sources/fixed_point32.move @@ -4,9 +4,9 @@ /// Defines a fixed-point numeric type with a 32-bit integer part and /// a 32-bit fractional part. -module Std::FixedPoint32 { +module std::fixed_point32 { - use Std::Errors; + use std::errors; /// Define a fixed-point numeric type with 32 fractional bits. /// This is just a u64 integer but it is wrapped in a struct to @@ -45,7 +45,7 @@ module Std::FixedPoint32 { // 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)); + assert!(product <= MAX_U64, errors::limit_exceeded(EMULTIPLICATION)); (product as u64) } spec multiply_u64 { @@ -56,7 +56,7 @@ module Std::FixedPoint32 { spec schema MultiplyAbortsIf { val: num; multiplier: FixedPoint32; - aborts_if spec_multiply_u64(val, multiplier) > MAX_U64 with Errors::LIMIT_EXCEEDED; + aborts_if spec_multiply_u64(val, multiplier) > MAX_U64 with errors::LIMIT_EXCEEDED; } spec fun spec_multiply_u64(val: num, multiplier: FixedPoint32): num { (val * multiplier.value) >> 32 @@ -67,13 +67,13 @@ module Std::FixedPoint32 { /// is zero or if the quotient overflows. public fun divide_u64(val: u64, divisor: FixedPoint32): u64 { // Check for division by zero. - assert!(divisor.value != 0, Errors::invalid_argument(EDIVISION_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)); + 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) @@ -86,8 +86,8 @@ module Std::FixedPoint32 { spec 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; + aborts_if divisor.value == 0 with errors::INVALID_ARGUMENT; + aborts_if spec_divide_u64(val, divisor) > MAX_U64 with errors::LIMIT_EXCEEDED; } spec fun spec_divide_u64(val: num, divisor: FixedPoint32): num { (val << 32) / divisor.value @@ -110,12 +110,12 @@ module Std::FixedPoint32 { // fractional bits. let scaled_numerator = (numerator as u128) << 64; let scaled_denominator = (denominator as u128) << 32; - assert!(scaled_denominator != 0, Errors::invalid_argument(EDENOMINATOR)); + 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)); + 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)); + assert!(quotient <= MAX_U64, errors::limit_exceeded(ERATIO_OUT_OF_RANGE)); FixedPoint32 { value: (quotient as u64) } } spec create_from_rational { @@ -129,9 +129,9 @@ module Std::FixedPoint32 { 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; + 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; } spec fun spec_create_from_rational(numerator: num, denominator: num): FixedPoint32 { FixedPoint32{value: (numerator << 64) / (denominator << 32)} diff --git a/crates/sui-framework/deps/move-stdlib/sources/GUID.move b/crates/sui-framework/deps/move-stdlib/sources/guid.move similarity index 93% rename from crates/sui-framework/deps/move-stdlib/sources/GUID.move rename to crates/sui-framework/deps/move-stdlib/sources/guid.move index c5c7ec3597dba..35a7a08757eb7 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/GUID.move +++ b/crates/sui-framework/deps/move-stdlib/sources/guid.move @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 /// A module for generating globally unique identifiers -module Std::GUID { - use Std::Signer; +module std::guid { + use std::signer; /// A generator for new GUIDs. struct Generator has key { @@ -35,7 +35,7 @@ module Std::GUID { /// Generates a capability to create the privileged GUID on behalf of the signer // (also makes sure that the Generator is published under the signer account) public fun gen_create_capability(account: &signer): CreateCapability { - let addr = Signer::address_of(account); + let addr = signer::address_of(account); if (!exists(addr)) { move_to(account, Generator { counter: 0 }) }; @@ -55,7 +55,7 @@ module Std::GUID { /// Create and return a new GUID. Creates a `Generator` under `account` /// if it does not already have one public fun create(account: &signer): GUID acquires Generator { - let addr = Signer::address_of(account); + let addr = signer::address_of(account); if (!exists(addr)) { move_to(account, Generator { counter: 0 }) }; @@ -84,7 +84,7 @@ module Std::GUID { guid.id.addr } - /// Return the account address that created the GUID::ID + /// Return the account address that created the guid::ID public fun id_creator_address(id: &ID): address { id.addr } @@ -94,7 +94,7 @@ module Std::GUID { guid.id.creation_num } - /// Return the creation number associated with the GUID::ID + /// Return the creation number associated with the guid::ID public fun id_creation_num(id: &ID): u64 { id.creation_num } diff --git a/crates/sui-framework/deps/move-stdlib/sources/Hash.move b/crates/sui-framework/deps/move-stdlib/sources/hash.move similarity index 95% rename from crates/sui-framework/deps/move-stdlib/sources/Hash.move rename to crates/sui-framework/deps/move-stdlib/sources/hash.move index e6665386b352d..b1f2730dc6f49 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/Hash.move +++ b/crates/sui-framework/deps/move-stdlib/sources/hash.move @@ -5,7 +5,7 @@ /// /// The functions in this module are natively declared both in the Move runtime /// as in the Move prover's prelude. -module Std::Hash { +module std::hash { native public fun sha2_256(data: vector): vector; native public fun sha3_256(data: vector): vector; } diff --git a/crates/sui-framework/deps/move-stdlib/sources/Option.move b/crates/sui-framework/deps/move-stdlib/sources/option.move similarity index 76% rename from crates/sui-framework/deps/move-stdlib/sources/Option.move rename to crates/sui-framework/deps/move-stdlib/sources/option.move index 65e492c8e6611..a8e2eae6637d4 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/Option.move +++ b/crates/sui-framework/deps/move-stdlib/sources/option.move @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 /// This module defines the Option type and its methods to represent and handle an optional value. -module Std::Option { - use Std::Errors; - use Std::Vector; +module std::option { + use std::errors; + use std::vector; /// 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. @@ -26,7 +26,7 @@ module Std::Option { /// Return an empty `Option` public fun none(): Option { - Option { vec: Vector::empty() } + Option { vec: vector::empty() } } spec none { pragma opaque; @@ -39,7 +39,7 @@ module Std::Option { /// Return an `Option` containing `e` public fun some(e: Element): Option { - Option { vec: Vector::singleton(e) } + Option { vec: vector::singleton(e) } } spec some { pragma opaque; @@ -52,7 +52,7 @@ module Std::Option { /// Return true if `t` does not hold a value public fun is_none(t: &Option): bool { - Vector::is_empty(&t.vec) + vector::is_empty(&t.vec) } spec is_none { pragma opaque; @@ -62,7 +62,7 @@ module Std::Option { /// Return true if `t` holds a value public fun is_some(t: &Option): bool { - !Vector::is_empty(&t.vec) + !vector::is_empty(&t.vec) } spec is_some { pragma opaque; @@ -73,7 +73,7 @@ module Std::Option { /// 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(t: &Option, e_ref: &Element): bool { - Vector::contains(&t.vec, e_ref) + vector::contains(&t.vec, e_ref) } spec contains { pragma opaque; @@ -87,8 +87,8 @@ module Std::Option { /// Return an immutable reference to the value inside `t` /// Aborts if `t` does not hold a value public fun borrow(t: &Option): &Element { - assert!(is_some(t), Errors::invalid_argument(EOPTION_NOT_SET)); - Vector::borrow(&t.vec, 0) + assert!(is_some(t), errors::invalid_argument(EOPTION_NOT_SET)); + vector::borrow(&t.vec, 0) } spec borrow { pragma opaque; @@ -100,8 +100,8 @@ module Std::Option { /// Return `default_ref` if `t` does not hold a value public fun borrow_with_default(t: &Option, default_ref: &Element): &Element { let vec_ref = &t.vec; - if (Vector::is_empty(vec_ref)) default_ref - else Vector::borrow(vec_ref, 0) + if (vector::is_empty(vec_ref)) default_ref + else vector::borrow(vec_ref, 0) } spec borrow_with_default { pragma opaque; @@ -116,8 +116,8 @@ module Std::Option { default: Element, ): Element { let vec_ref = &t.vec; - if (Vector::is_empty(vec_ref)) default - else *Vector::borrow(vec_ref, 0) + if (vector::is_empty(vec_ref)) default + else *vector::borrow(vec_ref, 0) } spec get_with_default { pragma opaque; @@ -129,12 +129,12 @@ module Std::Option { /// Aborts if `t` already holds a value public fun fill(t: &mut Option, 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) + if (vector::is_empty(vec_ref)) vector::push_back(vec_ref, e) + else abort errors::invalid_argument(EOPTION_IS_SET) } spec fill { pragma opaque; - aborts_if is_some(t) with Errors::INVALID_ARGUMENT; + aborts_if is_some(t) with errors::INVALID_ARGUMENT; ensures is_some(t); ensures borrow(t) == e; } @@ -142,8 +142,8 @@ module Std::Option { /// 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(t: &mut Option): Element { - assert!(is_some(t), Errors::invalid_argument(EOPTION_NOT_SET)); - Vector::pop_back(&mut t.vec) + assert!(is_some(t), errors::invalid_argument(EOPTION_NOT_SET)); + vector::pop_back(&mut t.vec) } spec extract { pragma opaque; @@ -155,8 +155,8 @@ module Std::Option { /// Return a mutable reference to the value inside `t` /// Aborts if `t` does not hold a value public fun borrow_mut(t: &mut Option): &mut Element { - assert!(is_some(t), Errors::invalid_argument(EOPTION_NOT_SET)); - Vector::borrow_mut(&mut t.vec, 0) + assert!(is_some(t), errors::invalid_argument(EOPTION_NOT_SET)); + vector::borrow_mut(&mut t.vec, 0) } spec borrow_mut { pragma opaque; @@ -167,10 +167,10 @@ module Std::Option { /// Swap the old value inside `t` with `e` and return the old value /// Aborts if `t` does not hold a value public fun swap(t: &mut Option, e: Element): Element { - assert!(is_some(t), Errors::invalid_argument(EOPTION_NOT_SET)); + 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); + let old_value = vector::pop_back(vec_ref); + vector::push_back(vec_ref, e); old_value } spec swap { @@ -186,9 +186,9 @@ module Std::Option { /// Different from swap(), swap_or_fill() allows for `t` not holding a value. public fun swap_or_fill(t: &mut Option, e: Element): Option { let vec_ref = &mut t.vec; - let old_value = if (Vector::is_empty(vec_ref)) none() - else some(Vector::pop_back(vec_ref)); - Vector::push_back(vec_ref, e); + let old_value = if (vector::is_empty(vec_ref)) none() + else some(vector::pop_back(vec_ref)); + vector::push_back(vec_ref, e); old_value } spec swap_or_fill { @@ -200,8 +200,8 @@ module Std::Option { /// Destroys `t.` If `t` holds a value, return it. Returns `default` otherwise public fun destroy_with_default(t: Option, default: Element): Element { let Option { vec } = t; - if (Vector::is_empty(&mut vec)) default - else Vector::pop_back(&mut vec) + if (vector::is_empty(&mut vec)) default + else vector::pop_back(&mut vec) } spec destroy_with_default { pragma opaque; @@ -212,10 +212,10 @@ module Std::Option { /// Unpack `t` and return its contents /// Aborts if `t` does not hold a value public fun destroy_some(t: Option): Element { - assert!(is_some(&t), Errors::invalid_argument(EOPTION_NOT_SET)); + 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); + let elem = vector::pop_back(&mut vec); + vector::destroy_empty(vec); elem } spec destroy_some { @@ -227,13 +227,25 @@ module Std::Option { /// Unpack `t` /// Aborts if `t` holds a value public fun destroy_none(t: Option) { - assert!(is_none(&t), Errors::invalid_argument(EOPTION_IS_SET)); + assert!(is_none(&t), errors::invalid_argument(EOPTION_IS_SET)); let Option { vec } = t; - Vector::destroy_empty(vec) + vector::destroy_empty(vec) } spec destroy_none { pragma opaque; - aborts_if is_some(t) with Errors::INVALID_ARGUMENT; + aborts_if is_some(t) with errors::INVALID_ARGUMENT; + } + + /// Convert `t` into a vector of length 1 if it is `Some`, + /// and an empty vector otherwise + public fun to_vec(t: Option): vector { + let Option { vec } = t; + vec + } + spec to_vec { + pragma opaque; + aborts_if false; + ensures result == t.vec; } spec module {} // switch documentation context back to module level @@ -246,6 +258,6 @@ module Std::Option { spec schema AbortsIfNone { t: Option; - aborts_if is_none(t) with Errors::INVALID_ARGUMENT; + aborts_if is_none(t) with errors::INVALID_ARGUMENT; } } diff --git a/crates/sui-framework/deps/move-stdlib/sources/Signer.move b/crates/sui-framework/deps/move-stdlib/sources/signer.move similarity index 89% rename from crates/sui-framework/deps/move-stdlib/sources/Signer.move rename to crates/sui-framework/deps/move-stdlib/sources/signer.move index 7f5f96500d7ec..d7f2f59a29cf7 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/Signer.move +++ b/crates/sui-framework/deps/move-stdlib/sources/signer.move @@ -1,12 +1,12 @@ // Copyright (c) 2022, Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 -module Std::Signer { +module std::signer { // Borrows the address of the signer - // Conceptually, you can think of the `signer` as being a struct wrapper around an + // Conceptually, you can think of the `signer` as being a struct wrapper arround an // address // ``` - // struct Signer has drop { addr: address } + // struct signer has drop { addr: address } // ``` // `borrow_address` borrows this inner field native public fun borrow_address(s: &signer): &address; diff --git a/crates/sui-framework/deps/move-stdlib/sources/UnitTest.move b/crates/sui-framework/deps/move-stdlib/sources/unit_test.move similarity index 96% rename from crates/sui-framework/deps/move-stdlib/sources/UnitTest.move rename to crates/sui-framework/deps/move-stdlib/sources/unit_test.move index b16211e4fe95c..57c30658ae7c7 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/UnitTest.move +++ b/crates/sui-framework/deps/move-stdlib/sources/unit_test.move @@ -3,7 +3,7 @@ #[test_only] /// Module providing testing functionality. Only included for tests. -module Std::UnitTest { +module std::unit_test { /// Return a `num_signers` number of unique signer values. No ordering or /// starting value guarantees are made, only that the order and values of /// the signers in the returned vector is deterministic. diff --git a/crates/sui-framework/deps/move-stdlib/sources/Vector.move b/crates/sui-framework/deps/move-stdlib/sources/vector.move similarity index 96% rename from crates/sui-framework/deps/move-stdlib/sources/Vector.move rename to crates/sui-framework/deps/move-stdlib/sources/vector.move index 043f45b3b6dd5..4f34432eff891 100644 --- a/crates/sui-framework/deps/move-stdlib/sources/Vector.move +++ b/crates/sui-framework/deps/move-stdlib/sources/vector.move @@ -11,36 +11,44 @@ /// >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. -module Std::Vector { +module std::vector { /// The index into the vector is out of bounds const EINDEX_OUT_OF_BOUNDS: u64 = 0; + #[bytecode_instruction] /// Create an empty vector. native public fun empty(): vector; + #[bytecode_instruction] /// Return the length of the vector. native public fun length(v: &vector): u64; + #[bytecode_instruction] /// Acquire an immutable reference to the `i`th element of the vector `v`. /// Aborts if `i` is out of bounds. native public fun borrow(v: &vector, i: u64): ∈ + #[bytecode_instruction] /// Add element `e` to the end of the vector `v`. native public fun push_back(v: &mut vector, e: Element); + #[bytecode_instruction] /// Return a mutable reference to the `i`th element in the vector `v`. /// Aborts if `i` is out of bounds. native public fun borrow_mut(v: &mut vector, i: u64): &mut Element; + #[bytecode_instruction] /// Pop an element from the end of vector `v`. /// Aborts if `v` is empty. native public fun pop_back(v: &mut vector): Element; + #[bytecode_instruction] /// Destroy the vector `v`. /// Aborts if `v` is not empty. native public fun destroy_empty(v: vector); + #[bytecode_instruction] /// Swaps the elements at the `i`th and `j`th indices in the vector `v`. /// Aborts if `i`or `j` is out of bounds. native public fun swap(v: &mut vector, i: u64, j: u64); diff --git a/crates/sui-framework/sources/Bag.move b/crates/sui-framework/sources/Bag.move index 7ab0d26dd591b..1ccc84caad177 100644 --- a/crates/sui-framework/sources/Bag.move +++ b/crates/sui-framework/sources/Bag.move @@ -10,9 +10,9 @@ /// Bag is different from the Collection type in that Collection /// only supports owning objects of the same type. module Sui::Bag { - use Std::Errors; - use Std::Option::{Self, Option}; - use Std::Vector::Self; + use std::errors; + use std::option::{Self, Option}; + use std::vector::Self; use Sui::ID::{Self, ID, VersionedID}; use Sui::Transfer::{Self, ChildRef}; use Sui::TxContext::{Self, TxContext}; @@ -51,23 +51,23 @@ module Sui::Bag { public fun new_with_max_capacity(ctx: &mut TxContext, max_capacity: u64): Bag { assert!( max_capacity <= DEFAULT_MAX_CAPACITY && max_capacity > 0 , - Errors::limit_exceeded(EInvalidMaxCapacity) + errors::limit_exceeded(EInvalidMaxCapacity) ); Bag { id: TxContext::new_id(ctx), - objects: Vector::empty(), + objects: vector::empty(), max_capacity, } } /// Create a new Bag and transfer it to the signer. - public(script) fun create(ctx: &mut TxContext) { + public entry fun create(ctx: &mut TxContext) { Transfer::transfer(new(ctx), TxContext::sender(ctx)) } /// Returns the size of the Bag. public fun size(c: &Bag): u64 { - Vector::length(&c.objects) + vector::length(&c.objects) } /// Add an object to the Bag. @@ -77,54 +77,54 @@ module Sui::Bag { fun add_impl(c: &mut Bag, object: T, old_child_ref: Option>) { assert!( size(c) + 1 <= c.max_capacity, - Errors::limit_exceeded(EMaxCapacityExceeded) + errors::limit_exceeded(EMaxCapacityExceeded) ); let id = ID::id(&object); if (contains(c, id)) { abort EObjectDoubleAdd }; - Vector::push_back(&mut c.objects, *id); + vector::push_back(&mut c.objects, *id); Transfer::transfer_to_object_unsafe(object, old_child_ref, c); } /// Add a new object to the Bag. /// Abort if the object is already in the Bag. public fun add(c: &mut Bag, object: T) { - add_impl(c, object, Option::none()) + add_impl(c, object, option::none()) } /// Transfer a object that was owned by another object to the bag. /// Since the object is a child object of another object, an `old_child_ref` /// is around and needs to be consumed. public fun add_child_object(c: &mut Bag, object: T, old_child_ref: ChildRef) { - add_impl(c, object, Option::some(old_child_ref)) + add_impl(c, object, option::some(old_child_ref)) } /// Check whether the Bag contains a specific object, /// identified by the object id in bytes. public fun contains(c: &Bag, id: &ID): bool { - Option::is_some(&find(c, id)) + option::is_some(&find(c, id)) } /// Remove and return the object from the Bag. /// Abort if the object is not found. public fun remove(c: &mut Bag, object: T): T { let idx = find(c, ID::id(&object)); - if (Option::is_none(&idx)) { + if (option::is_none(&idx)) { abort EObjectNotFound }; - Vector::remove(&mut c.objects, *Option::borrow(&idx)); + vector::remove(&mut c.objects, *option::borrow(&idx)); object } /// Remove the object from the Bag, and then transfer it to the signer. - public(script) fun remove_and_take(c: &mut Bag, object: T, ctx: &mut TxContext) { + public entry fun remove_and_take(c: &mut Bag, object: T, ctx: &mut TxContext) { let object = remove(c, object); Transfer::transfer(object, TxContext::sender(ctx)); } /// Transfer the entire Bag to `recipient`. - public(script) fun transfer_(c: Bag, recipient: address) { + public entry fun transfer_(c: Bag, recipient: address) { Transfer::transfer(c, recipient) } @@ -146,11 +146,11 @@ module Sui::Bag { let i = 0; let len = size(c); while (i < len) { - if (Vector::borrow(&c.objects, i) == id) { - return Option::some(i) + if (vector::borrow(&c.objects, i) == id) { + return option::some(i) }; i = i + 1; }; - return Option::none() + return option::none() } } diff --git a/crates/sui-framework/sources/Coin.move b/crates/sui-framework/sources/Coin.move index 562ba55bae371..c0f1287bf73df 100644 --- a/crates/sui-framework/sources/Coin.move +++ b/crates/sui-framework/sources/Coin.move @@ -6,7 +6,7 @@ module Sui::Coin { use Sui::ID::{Self, VersionedID}; use Sui::Transfer; use Sui::TxContext::{Self, TxContext}; - use Std::Vector; + use std::vector; /// A coin of type `T` worth `value`. Transferable and storable struct Coin has key, store { @@ -85,14 +85,14 @@ module Sui::Coin { /// Join everything in `coins` with `self` public fun join_vec(self: &mut Coin, coins: vector>) { let i = 0; - let len = Vector::length(&coins); + let len = vector::length(&coins); while (i < len) { - let coin = Vector::remove(&mut coins, i); + let coin = vector::remove(&mut coins, i); join(self, coin); i = i + 1 }; // safe because we've drained the vector - Vector::destroy_empty(coins) + vector::destroy_empty(coins) } /// Public getter for the coin's value @@ -172,35 +172,35 @@ module Sui::Coin { /// Send `amount` units of `c` to `recipient /// Aborts with `EVALUE` if `amount` is greater than or equal to `amount` - public(script) fun transfer_(c: &mut Coin, amount: u64, recipient: address, ctx: &mut TxContext) { + public entry fun transfer_(c: &mut Coin, amount: u64, recipient: address, ctx: &mut TxContext) { Transfer::transfer(withdraw(&mut c.balance, amount, ctx), recipient) } /// Consume the coin `c` and add its value to `self`. /// Aborts if `c.value + self.value > U64_MAX` - public(script) fun join_(self: &mut Coin, c: Coin) { + public entry fun join_(self: &mut Coin, c: Coin) { join(self, c) } /// Join everything in `coins` with `self` - public(script) fun join_vec_(self: &mut Coin, coins: vector>) { + public entry fun join_vec_(self: &mut Coin, coins: vector>) { join_vec(self, coins) } /// Split coin `self` to two coins, one with balance `split_amount`, /// and the remaining balance is left is `self`. - public(script) fun split(self: &mut Coin, split_amount: u64, ctx: &mut TxContext) { + public entry fun split(self: &mut Coin, split_amount: u64, ctx: &mut TxContext) { let new_coin = withdraw(&mut self.balance, split_amount, ctx); Transfer::transfer(new_coin, TxContext::sender(ctx)); } /// Split coin `self` into multiple coins, each with balance specified /// in `split_amounts`. Remaining balance is left in `self`. - public(script) fun split_vec(self: &mut Coin, split_amounts: vector, ctx: &mut TxContext) { + public entry fun split_vec(self: &mut Coin, split_amounts: vector, ctx: &mut TxContext) { let i = 0; - let len = Vector::length(&split_amounts); + let len = vector::length(&split_amounts); while (i < len) { - split(self, *Vector::borrow(&split_amounts, i), ctx); + split(self, *vector::borrow(&split_amounts, i), ctx); i = i + 1; }; } diff --git a/crates/sui-framework/sources/Collection.move b/crates/sui-framework/sources/Collection.move index 27a76e2de3417..97001d0a13d32 100644 --- a/crates/sui-framework/sources/Collection.move +++ b/crates/sui-framework/sources/Collection.move @@ -12,9 +12,9 @@ /// access and operate on each individual object. /// In contrast to `Bag`, `Collection` requires all objects have the same type. module Sui::Collection { - use Std::Errors; - use Std::Option::{Self, Option}; - use Std::Vector::Self; + use std::errors; + use std::option::{Self, Option}; + use std::vector::Self; use Sui::ID::{Self, ID, VersionedID}; use Sui::Transfer::{Self, ChildRef}; use Sui::TxContext::{Self, TxContext}; @@ -59,23 +59,23 @@ module Sui::Collection { ): Collection { assert!( max_capacity <= DEFAULT_MAX_CAPACITY && max_capacity > 0 , - Errors::limit_exceeded(EInvalidMaxCapacity) + errors::limit_exceeded(EInvalidMaxCapacity) ); Collection { id: TxContext::new_id(ctx), - objects: Vector::empty(), + objects: vector::empty(), max_capacity, } } /// Create a new Collection and transfer it to the signer. - public(script) fun create(ctx: &mut TxContext) { + public entry fun create(ctx: &mut TxContext) { Transfer::transfer(new(ctx), TxContext::sender(ctx)) } /// Returns the size of the collection. public fun size(c: &Collection): u64 { - Vector::length(&c.objects) + vector::length(&c.objects) } /// Add an object to the collection. @@ -89,24 +89,24 @@ module Sui::Collection { ) { assert!( size(c) + 1 <= c.max_capacity, - Errors::limit_exceeded(EMaxCapacityExceeded) + errors::limit_exceeded(EMaxCapacityExceeded) ); let id = ID::id(&object); assert!(!contains(c, id), EObjectDoubleAdd); - let child_ref = if (Option::is_none(&old_child_ref)) { + let child_ref = if (option::is_none(&old_child_ref)) { Transfer::transfer_to_object(object, c) } else { - let old_child_ref = Option::extract(&mut old_child_ref); + let old_child_ref = option::extract(&mut old_child_ref); Transfer::transfer_child_to_object(object, old_child_ref, c) }; - Vector::push_back(&mut c.objects, child_ref); - Option::destroy_none(old_child_ref); + vector::push_back(&mut c.objects, child_ref); + option::destroy_none(old_child_ref); } /// Add an object to the collection. /// Abort if the object is already in the collection. public fun add(c: &mut Collection, object: T) { - add_impl(c, object, Option::none()) + add_impl(c, object, option::none()) } /// Transfer an object that was owned by another object to the collection. @@ -117,26 +117,26 @@ module Sui::Collection { object: T, old_child_ref: ChildRef, ) { - add_impl(c, object, Option::some(old_child_ref)) + add_impl(c, object, option::some(old_child_ref)) } /// Check whether the collection contains a specific object, /// identified by the object id in bytes. public fun contains(c: &Collection, id: &ID): bool { - Option::is_some(&find(c, id)) + option::is_some(&find(c, id)) } /// Remove and return the object from the collection. /// Abort if the object is not found. public fun remove(c: &mut Collection, object: T): (T, ChildRef) { let idx = find(c, ID::id(&object)); - assert!(Option::is_some(&idx), EObjectNotFound); - let child_ref = Vector::remove(&mut c.objects, *Option::borrow(&idx)); + assert!(option::is_some(&idx), EObjectNotFound); + let child_ref = vector::remove(&mut c.objects, *option::borrow(&idx)); (object, child_ref) } /// Remove the object from the collection, and then transfer it to the signer. - public(script) fun remove_and_take( + public entry fun remove_and_take( c: &mut Collection, object: T, ctx: &mut TxContext, @@ -146,7 +146,7 @@ module Sui::Collection { } /// Transfer the entire collection to `recipient`. - public(script) fun transfer_(c: Collection, recipient: address) { + public entry fun transfer_(c: Collection, recipient: address) { Transfer::transfer(c, recipient) } @@ -168,12 +168,12 @@ module Sui::Collection { let i = 0; let len = size(c); while (i < len) { - let child_ref = Vector::borrow(&c.objects, i); + let child_ref = vector::borrow(&c.objects, i); if (Transfer::is_child_unsafe(child_ref, id)) { - return Option::some(i) + return option::some(i) }; i = i + 1; }; - Option::none() + option::none() } } diff --git a/crates/sui-framework/sources/DevNetNFT.move b/crates/sui-framework/sources/DevNetNFT.move index 6da18c0bc336a..21b78f76aaf8f 100644 --- a/crates/sui-framework/sources/DevNetNFT.move +++ b/crates/sui-framework/sources/DevNetNFT.move @@ -35,7 +35,7 @@ module Sui::DevNetNFT { } /// Create a new DevNetNFT - public(script) fun mint( + public entry fun mint( name: vector, description: vector, url: vector, @@ -57,23 +57,23 @@ module Sui::DevNetNFT { } /// Transfer `nft` to `recipient` - public(script) fun transfer( + public entry fun transfer( nft: DevNetNFT, recipient: address, _: &mut TxContext ) { Transfer::transfer(nft, recipient) } /// Update the `description` of `nft` to `new_description` - public(script) fun update_description( - nft: &mut DevNetNFT, - new_description: vector, + public entry fun update_description( + nft: &mut DevNetNFT, + new_description: vector, _: &mut TxContext ) { nft.description = UTF8::string_unsafe(new_description) } /// Permanently delete `nft` - public(script) fun burn(nft: DevNetNFT, _: &mut TxContext) { + public entry fun burn(nft: DevNetNFT, _: &mut TxContext) { let DevNetNFT { id, name: _, description: _, url: _ } = nft; ID::delete(id) } @@ -101,13 +101,13 @@ module Sui::DevNetNFTTests { use Sui::UTF8; #[test] - public(script) fun mint_transfer_update() { + public entry fun mint_transfer_update() { let addr1 = @0xA; let addr2 = @0xB; // create the NFT let scenario = TestScenario::begin(&addr1); { - DevNetNFT::mint(b"test", b"a test", b"https://www.sui.io", TestScenario::ctx(&mut scenario)) + DevNetNFT::mint(b"test", b"a test", b"https://www.sui.io", TestScenario::ctx(&mut scenario)) }; // send it from A to B TestScenario::next_tx(&mut scenario, &addr1); diff --git a/crates/sui-framework/sources/ERC721Metadata.move b/crates/sui-framework/sources/ERC721Metadata.move index 8bd53ee8153d2..918efc19b9da5 100644 --- a/crates/sui-framework/sources/ERC721Metadata.move +++ b/crates/sui-framework/sources/ERC721Metadata.move @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 module Sui::ERC721Metadata { - use Std::ASCII; + use std::ascii; use Sui::Url::{Self, Url}; use Sui::UTF8; @@ -32,7 +32,7 @@ module Sui::ERC721Metadata { /// on `token_uri` or `name` public fun new(token_id: TokenID, name: vector, token_uri: vector): ERC721Metadata { // Note: this will abort if `token_uri` is not valid ASCII - let uri_str = ASCII::string(token_uri); + let uri_str = ascii::string(token_uri); ERC721Metadata { token_id, name: UTF8::string_unsafe(name), diff --git a/crates/sui-framework/sources/Governance/Delegation.move b/crates/sui-framework/sources/Governance/Delegation.move index aed34d282eea3..c332daa7f6e35 100644 --- a/crates/sui-framework/sources/Governance/Delegation.move +++ b/crates/sui-framework/sources/Governance/Delegation.move @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 module Sui::Delegation { - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; use Sui::Balance::Balance; use Sui::Coin::{Self, Coin}; use Sui::ID::{Self, VersionedID}; @@ -48,8 +48,8 @@ module Sui::Delegation { let delegate_amount = Coin::value(&stake); let delegation = Delegation { id: TxContext::new_id(ctx), - active_delegation: Option::some(Coin::into_balance(stake)), - ending_epoch: Option::none(), + active_delegation: option::some(Coin::into_balance(stake)), + ending_epoch: option::none(), delegate_amount, next_reward_unclaimed_epoch: starting_epoch, validator_address, @@ -66,11 +66,11 @@ module Sui::Delegation { assert!(is_active(self), 0); assert!(ending_epoch >= self.next_reward_unclaimed_epoch, 0); - let stake = Option::extract(&mut self.active_delegation); + let stake = option::extract(&mut self.active_delegation); let sender = TxContext::sender(ctx); Transfer::transfer(Coin::from_balance(stake, ctx), sender); - self.ending_epoch = Option::some(ending_epoch); + self.ending_epoch = option::some(ending_epoch); } /// Claim delegation reward. Increment next_reward_unclaimed_epoch. @@ -87,7 +87,7 @@ module Sui::Delegation { /// Destroy the delegation object. This can be done only when the delegation /// is inactive and all reward have been claimed. - public(script) fun burn(self: Delegation) { + public entry fun burn(self: Delegation) { assert!(!is_active(&self), 0); let Delegation { @@ -99,12 +99,12 @@ module Sui::Delegation { validator_address: _, } = self; ID::delete(id); - Option::destroy_none(active_delegation); - let ending_epoch = *Option::borrow(&ending_epoch); + option::destroy_none(active_delegation); + let ending_epoch = *option::borrow(&ending_epoch); assert!(next_reward_unclaimed_epoch == ending_epoch, 0); } - public(script) fun transfer(self: Delegation, recipient: address) { + public entry fun transfer(self: Delegation, recipient: address) { Transfer::transfer(self, recipient) } @@ -120,7 +120,7 @@ module Sui::Delegation { } else if (is_active(self)) { self.next_reward_unclaimed_epoch <= epoch_to_claim } else { - let ending_epoch = *Option::borrow(&self.ending_epoch); + let ending_epoch = *option::borrow(&self.ending_epoch); ending_epoch > epoch_to_claim } } @@ -134,6 +134,6 @@ module Sui::Delegation { } fun is_active(self: &Delegation): bool { - Option::is_some(&self.active_delegation) && Option::is_none(&self.ending_epoch) + option::is_some(&self.active_delegation) && option::is_none(&self.ending_epoch) } } diff --git a/crates/sui-framework/sources/Governance/Genesis.move b/crates/sui-framework/sources/Governance/Genesis.move index eb4b22015195e..92182e601909d 100644 --- a/crates/sui-framework/sources/Governance/Genesis.move +++ b/crates/sui-framework/sources/Governance/Genesis.move @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 module Sui::Genesis { - use Std::Vector; + use std::vector; use Sui::Coin; use Sui::SUI; @@ -33,23 +33,23 @@ module Sui::Genesis { ) { let treasury_cap = SUI::new(ctx); let storage_fund = Coin::mint_balance(INIT_STORAGE_FUND, &mut treasury_cap); - let validators = Vector::empty(); - let count = Vector::length(&validator_pubkeys); + let validators = vector::empty(); + let count = vector::length(&validator_pubkeys); assert!( - Vector::length(&validator_sui_addresses) == count - && Vector::length(&validator_stakes) == count - && Vector::length(&validator_names) == count - && Vector::length(&validator_net_addresses) == count, + vector::length(&validator_sui_addresses) == count + && vector::length(&validator_stakes) == count + && vector::length(&validator_names) == count + && vector::length(&validator_net_addresses) == count, 1 ); let i = 0; while (i < count) { - let sui_address = *Vector::borrow(&validator_sui_addresses, i); - let pubkey = *Vector::borrow(&validator_pubkeys, i); - let name = *Vector::borrow(&validator_names, i); - let net_address = *Vector::borrow(&validator_net_addresses, i); - let stake = *Vector::borrow(&validator_stakes, i); - Vector::push_back(&mut validators, Validator::new( + let sui_address = *vector::borrow(&validator_sui_addresses, i); + let pubkey = *vector::borrow(&validator_pubkeys, i); + let name = *vector::borrow(&validator_names, i); + let net_address = *vector::borrow(&validator_net_addresses, i); + let stake = *vector::borrow(&validator_stakes, i); + vector::push_back(&mut validators, Validator::new( sui_address, pubkey, name, diff --git a/crates/sui-framework/sources/Governance/SuiSystem.move b/crates/sui-framework/sources/Governance/SuiSystem.move index 1452c8886e53a..8405fe76f01a4 100644 --- a/crates/sui-framework/sources/Governance/SuiSystem.move +++ b/crates/sui-framework/sources/Governance/SuiSystem.move @@ -81,7 +81,7 @@ module Sui::SuiSystem { /// The amount of stake in the `validator` object must meet the requirements. // TODO: Does this need to go through a voting process? Any other criteria for // someone to become a validator? - public(script) fun request_add_validator( + public entry fun request_add_validator( self: &mut SuiSystemState, pubkey_bytes: vector, name: vector, @@ -114,7 +114,7 @@ module Sui::SuiSystem { /// (i.e. sender must match the sui_address in the validator). /// At the end of the epoch, the `validator` object will be returned to the sui_address /// of the validator. - public(script) fun request_remove_validator( + public entry fun request_remove_validator( self: &mut SuiSystemState, ctx: &mut TxContext, ) { @@ -125,7 +125,7 @@ module Sui::SuiSystem { } /// A validator can request adding more stake. This will be processed at the end of epoch. - public(script) fun request_add_stake( + public entry fun request_add_stake( self: &mut SuiSystemState, new_stake: Coin, ctx: &mut TxContext, @@ -142,7 +142,7 @@ module Sui::SuiSystem { /// in the current epoch and hence is not active yet), the stake will be withdrawn immediately /// and a coin with the withdraw amount will be sent to the validator's address. /// If the sender represents an active validator, the request will be processed at the end of epoch. - public(script) fun request_withdraw_stake( + public entry fun request_withdraw_stake( self: &mut SuiSystemState, withdraw_amount: u64, ctx: &mut TxContext, @@ -155,7 +155,7 @@ module Sui::SuiSystem { ) } - public(script) fun request_add_delegation( + public entry fun request_add_delegation( self: &mut SuiSystemState, delegate_stake: Coin, validator_address: address, @@ -169,7 +169,7 @@ module Sui::SuiSystem { Delegation::create(starting_epoch, validator_address, delegate_stake, ctx); } - public(script) fun request_remove_delegation( + public entry fun request_remove_delegation( self: &mut SuiSystemState, delegation: &mut Delegation, ctx: &mut TxContext, @@ -185,7 +185,7 @@ module Sui::SuiSystem { // TODO: Once we support passing vector of object references as arguments, // we should support passing a vector of &mut EpochRewardRecord, // which will allow delegators to claim all their reward in one transaction. - public(script) fun claim_delegation_reward( + public entry fun claim_delegation_reward( self: &mut SuiSystemState, delegation: &mut Delegation, epoch_reward_record: &mut EpochRewardRecord, @@ -208,7 +208,7 @@ module Sui::SuiSystem { /// 2. Distribute computation charge to validator stake and delegation stake. /// 3. Create reward information records for each validator in this epoch. /// 4. Update all validators. - public(script) fun advance_epoch( + public entry fun advance_epoch( self: &mut SuiSystemState, new_epoch: u64, storage_charge: u64, diff --git a/crates/sui-framework/sources/Governance/Validator.move b/crates/sui-framework/sources/Governance/Validator.move index 38286de2ae0c5..e29916d1698ff 100644 --- a/crates/sui-framework/sources/Governance/Validator.move +++ b/crates/sui-framework/sources/Governance/Validator.move @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 module Sui::Validator { - use Std::ASCII; - use Std::Option::{Self, Option}; - use Std::Vector; + use std::ascii; + use std::option::{Self, Option}; + use std::vector; use Sui::Balance::{Self, Balance}; use Sui::Coin; @@ -72,11 +72,11 @@ module Sui::Validator { ): Validator { assert!( // TODO: These constants are arbitrary, will adjust once we know more. - Vector::length(&net_address) <= 100 && Vector::length(&name) <= 50 && Vector::length(&pubkey_bytes) <= 128, + vector::length(&net_address) <= 100 && vector::length(&name) <= 50 && vector::length(&pubkey_bytes) <= 128, 0 ); // Check that the name is human-readable. - ASCII::string(copy name); + ascii::string(copy name); Validator { metadata: ValidatorMetadata { sui_address, @@ -87,7 +87,7 @@ module Sui::Validator { }, stake, delegation: 0, - pending_stake: Option::none(), + pending_stake: option::none(), pending_withdraw: 0, pending_delegation: 0, pending_delegation_withdraw: 0, @@ -112,12 +112,12 @@ module Sui::Validator { } = self; assert!(pending_withdraw == 0, 0); - if (Option::is_some(&pending_stake)) { + if (option::is_some(&pending_stake)) { // pending_stake can be non-empty as it can contain the gas reward from the last epoch. - let pending_stake_balance = Option::extract(&mut pending_stake); + let pending_stake_balance = option::extract(&mut pending_stake); Balance::join(&mut stake, pending_stake_balance); }; - Option::destroy_none(pending_stake); + option::destroy_none(pending_stake); Transfer::transfer(Coin::from_balance(stake, ctx), metadata.sui_address); } @@ -128,14 +128,14 @@ module Sui::Validator { new_stake: Balance, ) { let new_stake_value = Balance::value(&new_stake); - let pending_stake = if (Option::is_some(&self.pending_stake)) { - let pending_stake = Option::extract(&mut self.pending_stake); + let pending_stake = if (option::is_some(&self.pending_stake)) { + let pending_stake = option::extract(&mut self.pending_stake); Balance::join(&mut pending_stake, new_stake); pending_stake } else { new_stake }; - Option::fill(&mut self.pending_stake, pending_stake); + option::fill(&mut self.pending_stake, pending_stake); self.metadata.next_epoch_stake = self.metadata.next_epoch_stake + new_stake_value; } @@ -155,8 +155,8 @@ module Sui::Validator { /// Process pending stake and pending withdraws. public(friend) fun adjust_stake(self: &mut Validator, ctx: &mut TxContext) { - if (Option::is_some(&self.pending_stake)) { - let pending_stake = Option::extract(&mut self.pending_stake); + if (option::is_some(&self.pending_stake)) { + let pending_stake = option::extract(&mut self.pending_stake); Balance::join(&mut self.stake, pending_stake); }; if (self.pending_withdraw > 0) { @@ -207,8 +207,8 @@ module Sui::Validator { } public fun pending_stake_amount(self: &Validator): u64 { - if (Option::is_some(&self.pending_stake)) { - Balance::value(Option::borrow(&self.pending_stake)) + if (option::is_some(&self.pending_stake)) { + Balance::value(option::borrow(&self.pending_stake)) } else { 0 } diff --git a/crates/sui-framework/sources/Governance/ValidatorSet.move b/crates/sui-framework/sources/Governance/ValidatorSet.move index de1237f293569..ee63bf83d118c 100644 --- a/crates/sui-framework/sources/Governance/ValidatorSet.move +++ b/crates/sui-framework/sources/Governance/ValidatorSet.move @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 module Sui::ValidatorSet { - use Std::Option::{Self, Option}; - use Std::Vector; + use std::option::{Self, Option}; + use std::vector; use Sui::Balance::{Self, Balance}; use Sui::EpochRewardRecord; @@ -52,9 +52,9 @@ module Sui::ValidatorSet { delegation_stake, quorum_stake_threshold, active_validators: init_active_validators, - pending_validators: Vector::empty(), - pending_removals: Vector::empty(), - next_epoch_validators: Vector::empty(), + pending_validators: vector::empty(), + pending_removals: vector::empty(), + next_epoch_validators: vector::empty(), }; validators.next_epoch_validators = derive_next_epoch_validators(&validators); validators @@ -62,9 +62,9 @@ module Sui::ValidatorSet { /// Get the total number of candidates that might become validators in the next epoch. public(friend) fun total_validator_candidate_count(self: &ValidatorSet): u64 { - Vector::length(&self.active_validators) - + Vector::length(&self.pending_validators) - - Vector::length(&self.pending_removals) + vector::length(&self.active_validators) + + vector::length(&self.pending_validators) + - vector::length(&self.pending_removals) } /// Called by `SuiSystem`, add a new validator to `pending_validators`, which will be @@ -75,7 +75,7 @@ module Sui::ValidatorSet { && !contains_duplicate_validator(&self.pending_validators, &validator), 0 ); - Vector::push_back(&mut self.pending_validators, validator); + vector::push_back(&mut self.pending_validators, validator); } /// Called by `SuiSystem`, to remove a validator. @@ -88,13 +88,13 @@ module Sui::ValidatorSet { ) { let validator_address = TxContext::sender(ctx); let validator_index_opt = find_validator(&self.active_validators, validator_address); - assert!(Option::is_some(&validator_index_opt), 0); - let validator_index = Option::extract(&mut validator_index_opt); + assert!(option::is_some(&validator_index_opt), 0); + let validator_index = option::extract(&mut validator_index_opt); assert!( - !Vector::contains(&self.pending_removals, &validator_index), + !vector::contains(&self.pending_removals, &validator_index), 0 ); - Vector::push_back(&mut self.pending_removals, validator_index); + vector::push_back(&mut self.pending_removals, validator_index); } /// Called by `SuiSystem`, to add more stake to a validator. @@ -129,7 +129,7 @@ module Sui::ValidatorSet { self: &ValidatorSet, validator_address: address, ): bool { - Option::is_some(&find_validator(&self.active_validators, validator_address)) + option::is_some(&find_validator(&self.active_validators, validator_address)) } public(friend) fun request_add_delegation( @@ -149,9 +149,9 @@ module Sui::ValidatorSet { let validator_index_opt = find_validator(&self.active_validators, validator_address); // It's OK to not be able to find the validator. This can happen if the delegated // validator is no longer active. - if (Option::is_some(&validator_index_opt)) { - let validator_index = Option::extract(&mut validator_index_opt); - let validator = Vector::borrow_mut(&mut self.active_validators, validator_index); + if (option::is_some(&validator_index_opt)) { + let validator_index = option::extract(&mut validator_index_opt); + let validator = vector::borrow_mut(&mut self.active_validators, validator_index); Validator::request_remove_delegation(validator, delegate_amount); } } @@ -163,10 +163,10 @@ module Sui::ValidatorSet { total_stake: u64, ctx: &mut TxContext, ) { - let length = Vector::length(&self.active_validators); + let length = vector::length(&self.active_validators); let i = 0; while (i < length) { - let v = Vector::borrow(&self.active_validators, i); + let v = vector::borrow(&self.active_validators, i); EpochRewardRecord::create( epoch, computation_charge, @@ -227,10 +227,10 @@ module Sui::ValidatorSet { /// Checks whether a duplicate of `new_validator` is already in `validators`. /// Two validators duplicate if they share the same sui_address or same IP or same name. fun contains_duplicate_validator(validators: &vector, new_validator: &Validator): bool { - let len = Vector::length(validators); + let len = vector::length(validators); let i = 0; while (i < len) { - let v = Vector::borrow(validators, i); + let v = vector::borrow(validators, i); if (Validator::is_duplicate(v, new_validator)) { return true }; @@ -243,16 +243,16 @@ module Sui::ValidatorSet { /// Returns (true, index) if the validator is found, and the index is its index in the list. /// If not found, returns (false, 0). fun find_validator(validators: &vector, validator_address: address): Option { - let length = Vector::length(validators); + let length = vector::length(validators); let i = 0; while (i < length) { - let v = Vector::borrow(validators, i); + let v = vector::borrow(validators, i); if (Validator::sui_address(v) == validator_address) { - return Option::some(i) + return option::some(i) }; i = i + 1; }; - Option::none() + option::none() } fun get_validator_mut( @@ -260,9 +260,9 @@ module Sui::ValidatorSet { validator_address: address, ): &mut Validator { let validator_index_opt = find_validator(validators, validator_address); - assert!(Option::is_some(&validator_index_opt), 0); - let validator_index = Option::extract(&mut validator_index_opt); - Vector::borrow_mut(validators, validator_index) + assert!(option::is_some(&validator_index_opt), 0); + let validator_index = option::extract(&mut validator_index_opt); + vector::borrow_mut(validators, validator_index) } /// Process the pending withdraw requests. For each pending request, the validator @@ -271,9 +271,9 @@ module Sui::ValidatorSet { validators: &mut vector, withdraw_list: &mut vector, ctx: &mut TxContext ) { sort_removal_list(withdraw_list); - while (!Vector::is_empty(withdraw_list)) { - let index = Vector::pop_back(withdraw_list); - let validator = Vector::remove(validators, index); + while (!vector::is_empty(withdraw_list)) { + let index = vector::pop_back(withdraw_list); + let validator = vector::remove(validators, index); Validator::destroy(validator, ctx); } } @@ -282,23 +282,23 @@ module Sui::ValidatorSet { fun process_pending_validators( validators: &mut vector, pending_validators: &mut vector ) { - while (!Vector::is_empty(pending_validators)) { - let v = Vector::pop_back(pending_validators); - Vector::push_back(validators, v); + while (!vector::is_empty(pending_validators)) { + let v = vector::pop_back(pending_validators); + vector::push_back(validators, v); } } /// Sort all the pending removal indexes. fun sort_removal_list(withdraw_list: &mut vector) { - let length = Vector::length(withdraw_list); + let length = vector::length(withdraw_list); let i = 1; while (i < length) { - let cur = *Vector::borrow(withdraw_list, i); + let cur = *vector::borrow(withdraw_list, i); let j = i; while (j > 0) { j = j - 1; - if (*Vector::borrow(withdraw_list, j) > cur) { - Vector::swap(withdraw_list, j, j + 1); + if (*vector::borrow(withdraw_list, j) > cur) { + vector::swap(withdraw_list, j, j + 1); } else { break }; @@ -311,10 +311,10 @@ module Sui::ValidatorSet { fun calculate_total_stake_and_quorum_threshold(validators: &vector): (u64, u64, u64) { let validator_state = 0; let delegate_stake = 0; - let length = Vector::length(validators); + let length = vector::length(validators); let i = 0; while (i < length) { - let v = Vector::borrow(validators, i); + let v = vector::borrow(validators, i); validator_state = validator_state + Validator::stake_amount(v); delegate_stake = delegate_stake + Validator::delegate_amount(v); i = i + 1; @@ -327,17 +327,17 @@ module Sui::ValidatorSet { /// With 3f + 1 validators, we can tolerate up to f byzantine ones. /// Hence (2f + 1) / total is our threshold. fun calculate_quorum_threshold(validators: &vector): u8 { - let count = Vector::length(validators); + let count = vector::length(validators); let threshold = (2 * count / 3 + 1) * 100 / count; (threshold as u8) } /// Process the pending stake changes for each validator. fun adjust_stake(validators: &mut vector, ctx: &mut TxContext) { - let length = Vector::length(validators); + let length = vector::length(validators); let i = 0; while (i < length) { - let validator = Vector::borrow_mut(validators, i); + let validator = vector::borrow_mut(validators, i); Validator::adjust_stake(validator, ctx); i = i + 1; } @@ -352,17 +352,17 @@ module Sui::ValidatorSet { total_stake: u64, total_reward: u64, ): vector { - let results = Vector::empty(); - let length = Vector::length(validators); + let results = vector::empty(); + let length = vector::length(validators); let i = 0; while (i < length) { - let validator = Vector::borrow(validators, i); + let validator = vector::borrow(validators, i); // Integer divisions will truncate the results. Because of this, we expect that at the end // there will be some reward remaining in `total_reward`. // Use u128 to avoid multiplication overflow. let stake_amount: u128 = (Validator::stake_amount(validator) as u128); let reward_amount = stake_amount * (total_reward as u128) / (total_stake as u128); - Vector::push_back(&mut results, (reward_amount as u64)); + vector::push_back(&mut results, (reward_amount as u64)); i = i + 1; }; results @@ -370,11 +370,11 @@ module Sui::ValidatorSet { // TODO: Allow reward compunding for delegators. fun distribute_reward(validators: &mut vector, rewards: &vector, reward: &mut Balance) { - let length = Vector::length(validators); + let length = vector::length(validators); let i = 0; while (i < length) { - let validator = Vector::borrow_mut(validators, i); - let reward_amount = *Vector::borrow(rewards, i); + let validator = vector::borrow_mut(validators, i); + let reward_amount = *vector::borrow(rewards, i); let reward = Balance::split(reward, reward_amount); // Because reward goes to pending stake, it's the same as calling `request_add_stake`. Validator::request_add_stake(validator, reward); @@ -385,12 +385,12 @@ module Sui::ValidatorSet { /// Upon any change to the validator set, derive and update the metadata of the validators for the new epoch. /// TODO: If we want to enforce a % on stake threshold, this is the function to do it. fun derive_next_epoch_validators(self: &ValidatorSet): vector { - let active_count = Vector::length(&self.active_validators); - let removal_count = Vector::length(&self.pending_removals); - let result = Vector::empty(); + let active_count = vector::length(&self.active_validators); + let removal_count = vector::length(&self.pending_removals); + let result = vector::empty(); while (active_count > 0) { if (removal_count > 0) { - let removal_index = *Vector::borrow(&self.pending_removals, removal_count - 1); + let removal_index = *vector::borrow(&self.pending_removals, removal_count - 1); if (removal_index == active_count - 1) { // This validator will be removed, and hence we won't add it to the new validator set. removal_count = removal_count - 1; @@ -399,16 +399,16 @@ module Sui::ValidatorSet { }; }; let metadata = Validator::metadata( - Vector::borrow(&self.active_validators, active_count - 1), + vector::borrow(&self.active_validators, active_count - 1), ); - Vector::push_back(&mut result, *metadata); + vector::push_back(&mut result, *metadata); active_count = active_count - 1; }; result } #[test_only] - public(script) fun destroy_for_testing( + public entry fun destroy_for_testing( self: ValidatorSet, ctx: &mut TxContext ) { @@ -421,11 +421,11 @@ module Sui::ValidatorSet { pending_removals: _, next_epoch_validators: _, } = self; - while (!Vector::is_empty(&active_validators)) { - let v = Vector::pop_back(&mut active_validators); + while (!vector::is_empty(&active_validators)) { + let v = vector::pop_back(&mut active_validators); Validator::destroy(v, ctx); }; - Vector::destroy_empty(active_validators); - Vector::destroy_empty(pending_validators); + vector::destroy_empty(active_validators); + vector::destroy_empty(pending_validators); } } diff --git a/crates/sui-framework/sources/ID.move b/crates/sui-framework/sources/ID.move index eca6260c3e712..01b8545d63234 100644 --- a/crates/sui-framework/sources/ID.move +++ b/crates/sui-framework/sources/ID.move @@ -3,8 +3,8 @@ /// Sui object identifiers module Sui::ID { - use Std::BCS; - use Std::Vector; + use std::bcs; + use std::vector; friend Sui::SuiSystem; friend Sui::Transfer; @@ -69,7 +69,7 @@ module Sui::ID { /// Create an `ID` from raw bytes. /// Aborts with `EBadIDLength` if the length of `bytes` is not `ID_SIZE` public fun new_from_bytes(bytes: vector): ID { - if (Vector::length(&bytes) != ID_SIZE) { + if (vector::length(&bytes) != ID_SIZE) { abort(EBadIDLength) }; ID { bytes: bytes_to_address(bytes) } @@ -103,7 +103,7 @@ module Sui::ID { /// Get the raw bytes of `id` public fun bytes(id: &ID): vector { - BCS::to_bytes(&id.bytes) + bcs::to_bytes(&id.bytes) } /// Get the inner `ID` of `versioned_id` diff --git a/crates/sui-framework/sources/ObjectBasics.move b/crates/sui-framework/sources/ObjectBasics.move index a7d84f0e8843e..739655a699709 100644 --- a/crates/sui-framework/sources/ObjectBasics.move +++ b/crates/sui-framework/sources/ObjectBasics.move @@ -22,42 +22,42 @@ module Sui::ObjectBasics { new_value: u64 } - public(script) fun create(value: u64, recipient: address, ctx: &mut TxContext) { + public entry fun create(value: u64, recipient: address, ctx: &mut TxContext) { Transfer::transfer( Object { id: TxContext::new_id(ctx), value }, recipient ) } - public(script) fun transfer(o: Object, recipient: address) { + public entry fun transfer(o: Object, recipient: address) { Transfer::transfer(o, recipient) } - public(script) fun freeze_object(o: Object) { + public entry fun freeze_object(o: Object) { Transfer::freeze_object(o) } - public(script) fun set_value(o: &mut Object, value: u64) { + public entry fun set_value(o: &mut Object, value: u64) { o.value = value; } // test that reading o2 and updating o1 works - public(script) fun update(o1: &mut Object, o2: &Object) { + public entry fun update(o1: &mut Object, o2: &Object) { o1.value = o2.value; // emit an event so the world can see the new value Event::emit(NewValueEvent { new_value: o2.value }) } - public(script) fun delete(o: Object) { + public entry fun delete(o: Object) { let Object { id, value: _ } = o; ID::delete(id); } - public(script) fun wrap(o: Object, ctx: &mut TxContext) { + public entry fun wrap(o: Object, ctx: &mut TxContext) { Transfer::transfer(Wrapper { id: TxContext::new_id(ctx), o }, TxContext::sender(ctx)) } - public(script) fun unwrap(w: Wrapper, ctx: &mut TxContext) { + public entry fun unwrap(w: Wrapper, ctx: &mut TxContext) { let Wrapper { id, o } = w; ID::delete(id); Transfer::transfer(o, TxContext::sender(ctx)) diff --git a/crates/sui-framework/sources/SUI.move b/crates/sui-framework/sources/SUI.move index 85f3edbcb38c2..4be4e490ad3a5 100644 --- a/crates/sui-framework/sources/SUI.move +++ b/crates/sui-framework/sources/SUI.move @@ -19,7 +19,7 @@ module Sui::SUI { } /// Transfer to a recipient - public(script) fun transfer(c: Coin::Coin, recipient: address) { + public entry fun transfer(c: Coin::Coin, recipient: address) { Coin::transfer(c, recipient) } diff --git a/crates/sui-framework/sources/TestScenario.move b/crates/sui-framework/sources/TestScenario.move index b0b8a874263c3..be10d7f414d5d 100644 --- a/crates/sui-framework/sources/TestScenario.move +++ b/crates/sui-framework/sources/TestScenario.move @@ -5,8 +5,8 @@ module Sui::TestScenario { use Sui::ID::{Self, ID, VersionedID}; use Sui::TxContext::{Self, TxContext}; - use Std::Option::{Self, Option}; - use Std::Vector; + use std::option::{Self, Option}; + use std::vector; /// Requested a transfer or user-defined event on an invalid transaction index const EInvalidTxIndex: u64 = 1; @@ -82,7 +82,7 @@ module Sui::TestScenario { public fun begin(sender: &address): Scenario { Scenario { ctx: TxContext::new_from_address(*sender, 0), - removed: Vector::empty(), + removed: vector::empty(), event_start_indexes: vector[0], } } @@ -99,17 +99,17 @@ module Sui::TestScenario { // - it does not appear in an event during the current transaction. emit_wrapped_object_events(last_tx_start_index, &scenario.removed); // reset `removed` for the next tx - scenario.removed = Vector::empty(); + scenario.removed = vector::empty(); // start index for the next tx is the end index for the current one let new_total_events = num_events(); let tx_event_count = new_total_events - old_total_events; let event_end_index = last_tx_start_index + tx_event_count; - Vector::push_back(&mut scenario.event_start_indexes, event_end_index); + vector::push_back(&mut scenario.event_start_indexes, event_end_index); // create a seed for new transaction digest to ensure that this tx has a different // digest (and consequently, different object ID's) than the previous tx - let new_tx_digest_seed = (Vector::length(&scenario.event_start_indexes) as u8); + let new_tx_digest_seed = (vector::length(&scenario.event_start_indexes) as u8); scenario.ctx = TxContext::new_from_address(*sender, new_tx_digest_seed); } @@ -197,13 +197,13 @@ module Sui::TestScenario { ); let object_opt: Option = find_object_by_id_in_inventory(inventory, &id); - let objects = if (Option::is_some(&object_opt)) { - let object = Option::extract(&mut object_opt); - Vector::singleton(object) + let objects = if (option::is_some(&object_opt)) { + let object = option::extract(&mut object_opt); + vector::singleton(object) } else { vector[] }; - Option::destroy_none(object_opt); + option::destroy_none(object_opt); remove_unique_object_from_inventory(scenario, objects) } @@ -211,7 +211,7 @@ module Sui::TestScenario { /// It provides a way to check without triggering assertions. public fun can_take_owned_by_id(scenario: &Scenario, id: ID): bool { // Check that the object has not been removed from the inventory. - if (Vector::contains(&scenario.removed, &id)) { + if (vector::contains(&scenario.removed, &id)) { return false }; let sender = sender(scenario); @@ -221,7 +221,7 @@ module Sui::TestScenario { ); // And the object with the specified ID is indeed one of the owned. let object_opt: Option = find_object_by_id_in_inventory(objects, &id); - let res = Option::is_some(&object_opt); + let res = option::is_some(&object_opt); drop_object_for_testing(object_opt); res } @@ -238,13 +238,13 @@ module Sui::TestScenario { last_tx_start_index(scenario), ); let child_object_opt = find_object_by_id_in_inventory(objects, &child_id); - let child_objects = if (Option::is_some(&child_object_opt)) { - let child_object = Option::extract(&mut child_object_opt); - Vector::singleton(child_object) + let child_objects = if (option::is_some(&child_object_opt)) { + let child_object = option::extract(&mut child_object_opt); + vector::singleton(child_object) } else { vector[] }; - Option::destroy_none(child_object_opt); + option::destroy_none(child_object_opt); remove_unique_object_from_inventory(scenario, child_objects) } @@ -256,10 +256,10 @@ module Sui::TestScenario { let id = ID::id(&t); let removed = &mut scenario.removed; // TODO: add Vector::remove_element to Std that does this 3-liner - let (is_mem, idx) = Vector::index_of(removed, id); + let (is_mem, idx) = vector::index_of(removed, id); // can't return an object we haven't removed assert!(is_mem, ECantReturnObject); - Vector::remove(removed, idx); + vector::remove(removed, idx); // Update the object content in the inventory. // Because the events are the source of truth for all object values in the inventory, @@ -288,10 +288,10 @@ module Sui::TestScenario { ); // Check that there is one unique such object, and it has not // yet been removed from the inventory. - let res = Vector::length(&objects) == 1; + let res = vector::length(&objects) == 1; if (res) { - let id = ID::id(Vector::borrow(&objects, 0)); - res = !Vector::contains(&scenario.removed, id); + let id = ID::id(vector::borrow(&objects, 0)); + res = !vector::contains(&scenario.removed, id); }; drop_object_for_testing(objects); res @@ -315,15 +315,15 @@ module Sui::TestScenario { /// Return the number of concluded transactions in this scenario. /// This does not include the current transaction--e.g., this will return 0 if `next_tx` has never been called public fun num_concluded_txes(scenario: &Scenario): u64 { - Vector::length(&scenario.event_start_indexes) - 1 + vector::length(&scenario.event_start_indexes) - 1 } /// Return the index in the global transaction log where the events emitted by the `tx_idx`th transaction begin fun tx_start_index(scenario: &Scenario, tx_idx: u64): u64 { let idxs = &scenario.event_start_indexes; - let len = Vector::length(idxs); + let len = vector::length(idxs); assert!(tx_idx < len, EInvalidTxIndex); - *Vector::borrow(idxs, tx_idx) + *vector::borrow(idxs, tx_idx) } /// Return the tx start index of the current transaction. This is an index into the global event log @@ -331,19 +331,19 @@ module Sui::TestScenario { fun last_tx_start_index(scenario: &Scenario): u64 { let idxs = &scenario.event_start_indexes; // Safe because because `event_start_indexes` is always non-empty - *Vector::borrow(idxs, Vector::length(idxs) - 1) + *vector::borrow(idxs, vector::length(idxs) - 1) } fun remove_unique_object_from_inventory(scenario: &mut Scenario, inventory: vector): T { - let objects_len = Vector::length(&inventory); + let objects_len = vector::length(&inventory); if (objects_len == 1) { // found a unique object. ensure that it hasn't already been removed, then return it - let t = Vector::pop_back(&mut inventory); + let t = vector::pop_back(&mut inventory); let id = ID::id(&t); - Vector::destroy_empty(inventory); + vector::destroy_empty(inventory); - assert!(!Vector::contains(&scenario.removed, id), EAlreadyRemovedObject); - Vector::push_back(&mut scenario.removed, *id); + assert!(!vector::contains(&scenario.removed, id), EAlreadyRemovedObject); + vector::push_back(&mut scenario.removed, *id); t } else if (objects_len == 0) { abort(EEmptyInventory) @@ -353,19 +353,19 @@ module Sui::TestScenario { } fun find_object_by_id_in_inventory(inventory: vector, id: &ID): Option { - let object_opt = Option::none(); - while (!Vector::is_empty(&inventory)) { - let element = Vector::pop_back(&mut inventory); + let object_opt = option::none(); + while (!vector::is_empty(&inventory)) { + let element = vector::pop_back(&mut inventory); if (ID::id(&element) == id) { // Within the same test scenario, there is no way to // create two objects with the same ID. So this should // be unique. - Option::fill(&mut object_opt, element); + option::fill(&mut object_opt, element); } else { drop_object_for_testing(element); } }; - Vector::destroy_empty(inventory); + vector::destroy_empty(inventory); object_opt } diff --git a/crates/sui-framework/sources/Transfer.move b/crates/sui-framework/sources/Transfer.move index cb94f33e58a6b..dfe4132733251 100644 --- a/crates/sui-framework/sources/Transfer.move +++ b/crates/sui-framework/sources/Transfer.move @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 module Sui::Transfer { - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; use Sui::ID::{Self, ID, VersionedID}; // To allow access to transfer_to_object_unsafe. @@ -95,13 +95,13 @@ module Sui::Transfer { old_child_ref: Option>, owner: &mut R, ) { - let ChildRef { child_id: _ } = if (Option::is_none(&old_child_ref)) { + let ChildRef { child_id: _ } = if (option::is_none(&old_child_ref)) { transfer_to_object(obj, owner) } else { - let child_ref = Option::extract(&mut old_child_ref); + let child_ref = option::extract(&mut old_child_ref); transfer_child_to_object(obj, child_ref, owner) }; - Option::destroy_none(old_child_ref); + option::destroy_none(old_child_ref); } /// Transfer a child object to new owner. This is one of the two ways that can diff --git a/crates/sui-framework/sources/TxContext.move b/crates/sui-framework/sources/TxContext.move index 03967989e9f73..476da1eee056d 100644 --- a/crates/sui-framework/sources/TxContext.move +++ b/crates/sui-framework/sources/TxContext.move @@ -2,13 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 module Sui::TxContext { - use Std::Signer; + use std::signer; use Sui::ID::{Self, VersionedID}; #[test_only] - use Std::Errors; + use std::errors; #[test_only] - use Std::Vector; + use std::vector; #[test_only] use Sui::ID::ID; @@ -40,7 +40,7 @@ module Sui::TxContext { /// Return the address of the user that signed the current /// transaction public fun sender(self: &TxContext): address { - Signer::address_of(&self.signer) + signer::address_of(&self.signer) } /// Return a `signer` for the user that signed the current transaction @@ -75,8 +75,8 @@ module Sui::TxContext { /// Create a `TxContext` for testing public fun new(signer: signer, tx_hash: vector, ids_created: u64): TxContext { assert!( - Vector::length(&tx_hash) == TX_HASH_LENGTH, - Errors::invalid_argument(EBadTxHashLength) + vector::length(&tx_hash) == TX_HASH_LENGTH, + errors::invalid_argument(EBadTxHashLength) ); TxContext { signer, tx_hash, epoch: 0, ids_created } } @@ -85,8 +85,8 @@ module Sui::TxContext { /// Create a `TxContext` for testing, with a potentially non-zero epoch number. public fun new_with_epoch(signer: signer, tx_hash: vector, epoch: u64, ids_created: u64): TxContext { assert!( - Vector::length(&tx_hash) == TX_HASH_LENGTH, - Errors::invalid_argument(EBadTxHashLength) + vector::length(&tx_hash) == TX_HASH_LENGTH, + errors::invalid_argument(EBadTxHashLength) ); TxContext { signer, tx_hash, epoch, ids_created } } @@ -107,13 +107,13 @@ module Sui::TxContext { #[test_only] /// Utility for creating 256 unique input hashes fun dummy_tx_hash_with_hint(hint: u8): vector { - let tx_hash = Vector::empty(); + let tx_hash = vector::empty(); let i = 0; while (i < TX_HASH_LENGTH - 1) { - Vector::push_back(&mut tx_hash, 0u8); + vector::push_back(&mut tx_hash, 0u8); i = i + 1; }; - Vector::push_back(&mut tx_hash, hint); + vector::push_back(&mut tx_hash, hint); tx_hash } diff --git a/crates/sui-framework/sources/UTF8.move b/crates/sui-framework/sources/UTF8.move index acebb6c3c57a7..7d2df313aad0e 100644 --- a/crates/sui-framework/sources/UTF8.move +++ b/crates/sui-framework/sources/UTF8.move @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 module Sui::UTF8 { - use Std::ASCII; - use Std::Option::Option; + use std::ascii; + use std::option::Option; /// Wrapper type that should be interpreted as a UTF8 string by clients struct String has store, copy, drop { @@ -18,13 +18,13 @@ module Sui::UTF8 { } /// Construct a UTF8 string from the ASCII string `s` - public fun from_ascii(s: ASCII::String): String { - String { bytes: ASCII::into_bytes(s) } + public fun from_ascii(s: ascii::String): String { + String { bytes: ascii::into_bytes(s) } } /// Try to convert `self` to an ASCCI string - public fun try_into_ascii(self: String): Option { - ASCII::try_string(self.bytes) + public fun try_into_ascii(self: String): Option { + ascii::try_string(self.bytes) } /// Return the underlying bytes of `self` diff --git a/crates/sui-framework/sources/Url.move b/crates/sui-framework/sources/Url.move index 9da7b5a1b1742..5b02a3979787b 100644 --- a/crates/sui-framework/sources/Url.move +++ b/crates/sui-framework/sources/Url.move @@ -6,8 +6,8 @@ /// UrlCommitment: Sui type which wraps a Url but also includes an immutable commitment /// to the hash of the resource at the given URL module Sui::Url { - use Std::ASCII::{Self, String}; - use Std::Vector; + use std::ascii::{Self, String}; + use std::vector; /// Length of the vector representing a resource hash const HASH_VECTOR_LENGTH: u64 = 32; @@ -39,14 +39,14 @@ module Sui::Url { /// Create a `Url` with no validation from bytes /// Note: this will abort if `bytes` is not valid ASCII public fun new_unsafe_from_bytes(bytes: vector): Url { - let url = ASCII::string(bytes); + let url = ascii::string(bytes); Url { url } } /// Create a `UrlCommitment`, and set the immutable hash public fun new_unsafe_url_commitment(url: Url, resource_hash: vector): UrlCommitment { // Length must be exact - assert!(Vector::length(&resource_hash) == HASH_VECTOR_LENGTH, EHashLengthMismatch); + assert!(vector::length(&resource_hash) == HASH_VECTOR_LENGTH, EHashLengthMismatch); UrlCommitment { url, resource_hash } } diff --git a/crates/sui-framework/tests/BagTests.move b/crates/sui-framework/tests/BagTests.move index b048f452f6d46..418f41f3ce41e 100644 --- a/crates/sui-framework/tests/BagTests.move +++ b/crates/sui-framework/tests/BagTests.move @@ -20,7 +20,7 @@ module Sui::BagTests { } #[test] - public(script) fun test_bag() { + public entry fun test_bag() { let sender = @0x0; let scenario = &mut TestScenario::begin(&sender); @@ -55,7 +55,7 @@ module Sui::BagTests { #[test] #[expected_failure(abort_code = 520)] - public(script) fun test_init_with_invalid_max_capacity() { + public entry fun test_init_with_invalid_max_capacity() { let ctx = TxContext::dummy(); // Sui::Bag::DEFAULT_MAX_CAPACITY is not readable outside the module let max_capacity = 65536; @@ -65,7 +65,7 @@ module Sui::BagTests { #[test] #[expected_failure(abort_code = 520)] - public(script) fun test_init_with_zero() { + public entry fun test_init_with_zero() { let ctx = TxContext::dummy(); let bag = Bag::new_with_max_capacity(&mut ctx, 0); Bag::transfer_(bag, TxContext::sender(&ctx)); @@ -73,7 +73,7 @@ module Sui::BagTests { #[test] #[expected_failure(abort_code = 776)] - public(script) fun test_exceed_max_capacity() { + public entry fun test_exceed_max_capacity() { let ctx = TxContext::dummy(); let bag = Bag::new_with_max_capacity(&mut ctx, 1); diff --git a/crates/sui-framework/tests/CollectionTests.move b/crates/sui-framework/tests/CollectionTests.move index c1fd724436a14..c9d1a83d3be03 100644 --- a/crates/sui-framework/tests/CollectionTests.move +++ b/crates/sui-framework/tests/CollectionTests.move @@ -14,7 +14,7 @@ module Sui::CollectionTests { } #[test] - public(script) fun test_collection() { + public entry fun test_collection() { let sender = @0x0; let scenario = &mut TestScenario::begin(&sender); @@ -47,7 +47,7 @@ module Sui::CollectionTests { } #[test] - public(script) fun test_collection_bag_interaction() { + public entry fun test_collection_bag_interaction() { let sender = @0x0; let scenario = &mut TestScenario::begin(&sender); @@ -109,7 +109,7 @@ module Sui::CollectionTests { #[test] #[expected_failure(abort_code = 520)] - public(script) fun test_init_with_invalid_max_capacity() { + public entry fun test_init_with_invalid_max_capacity() { let ctx = TxContext::dummy(); // Sui::Collection::DEFAULT_MAX_CAPACITY is not readable outside the module let max_capacity = 65536; @@ -119,7 +119,7 @@ module Sui::CollectionTests { #[test] #[expected_failure(abort_code = 520)] - public(script) fun test_init_with_zero() { + public entry fun test_init_with_zero() { let ctx = TxContext::dummy(); let collection = Collection::new_with_max_capacity(&mut ctx, 0); Collection::transfer_(collection, TxContext::sender(&ctx)); @@ -127,7 +127,7 @@ module Sui::CollectionTests { #[test] #[expected_failure(abort_code = 776)] - public(script) fun test_exceed_max_capacity() { + public entry fun test_exceed_max_capacity() { let ctx = TxContext::dummy(); let collection = Collection::new_with_max_capacity(&mut ctx, 1); diff --git a/crates/sui-framework/tests/UrlTests.move b/crates/sui-framework/tests/UrlTests.move index 192aeb9cffee4..2a00831935cb2 100644 --- a/crates/sui-framework/tests/UrlTests.move +++ b/crates/sui-framework/tests/UrlTests.move @@ -4,7 +4,7 @@ #[test_only] module Sui::UrlTests { use Sui::Url; - use Std::ASCII::Self; + use std::ascii::Self; const EHASH_LENGTH_MISMATCH: u64 = 0; const URL_STRING_MISMATCH: u64 = 1; @@ -12,7 +12,7 @@ module Sui::UrlTests { #[test] fun test_basic_url() { // url strings are not currently validated - let url_str = ASCII::string(x"414243454647"); + let url_str = ascii::string(x"414243454647"); let url = Url::new_unsafe(url_str); assert!(Url::inner_url(&url) == url_str, URL_STRING_MISMATCH); @@ -22,7 +22,7 @@ module Sui::UrlTests { #[expected_failure(abort_code = 0)] fun test_malformed_hash() { // url strings are not currently validated - let url_str = ASCII::string(x"414243454647"); + let url_str = ascii::string(x"414243454647"); // length too short let hash = x"badf012345"; @@ -33,7 +33,7 @@ module Sui::UrlTests { #[test] fun test_good_hash() { // url strings are not currently validated - let url_str = ASCII::string(x"414243454647"); + let url_str = ascii::string(x"414243454647"); // 32 bytes let hash = x"1234567890123456789012345678901234567890abcdefabcdefabcdefabcdef"; @@ -43,7 +43,7 @@ module Sui::UrlTests { assert!(Url::url_commitment_resource_hash(&url_commit) == hash, EHASH_LENGTH_MISMATCH); assert!(Url::url_commitment_inner_url(&url_commit) == url_str, URL_STRING_MISMATCH); - let url_str = ASCII::string(x"37414243454647"); + let url_str = ascii::string(x"37414243454647"); Url::url_commitment_update(&mut url_commit, url_str); assert!(Url::url_commitment_inner_url(&url_commit) == url_str, URL_STRING_MISMATCH); diff --git a/crates/sui-framework/tests/ValidatorSetTests.move b/crates/sui-framework/tests/ValidatorSetTests.move index 483d08a11b1de..558f5106906d1 100644 --- a/crates/sui-framework/tests/ValidatorSetTests.move +++ b/crates/sui-framework/tests/ValidatorSetTests.move @@ -11,7 +11,7 @@ module Sui::ValidatorSetTests { use Sui::ValidatorSet; #[test] - public(script) fun test_validator_set_flow() { + public entry fun test_validator_set_flow() { // Create 4 validators, with stake 100, 200, 300, 400. let (ctx1, validator1) = create_validator(@0x1, 1); let (_ctx2, validator2) = create_validator(@0x2, 2); diff --git a/crates/sui-framework/tests/ValidatorTests.move b/crates/sui-framework/tests/ValidatorTests.move index 900e9fc9e6dcc..6054ab9e5945a 100644 --- a/crates/sui-framework/tests/ValidatorTests.move +++ b/crates/sui-framework/tests/ValidatorTests.move @@ -9,7 +9,7 @@ module Sui::ValidatorTests { use Sui::Validator; #[test] - public(script) fun test_validator_owner_flow() { + public entry fun test_validator_owner_flow() { let sender = @0x1; let scenario = &mut TestScenario::begin(&sender); { @@ -39,7 +39,7 @@ module Sui::ValidatorTests { } #[test] - public(script) fun test_pending_validator_flow() { + public entry fun test_pending_validator_flow() { let sender = @0x1; let scenario = &mut TestScenario::begin(&sender); let ctx = TestScenario::ctx(scenario); diff --git a/crates/sui-gateway/Cargo.toml b/crates/sui-gateway/Cargo.toml index fc9368dd31316..fcb69e708d762 100644 --- a/crates/sui-gateway/Cargo.toml +++ b/crates/sui-gateway/Cargo.toml @@ -30,6 +30,6 @@ sui-json = { path = "../sui-json" } sui-open-rpc = { path = "../sui-open-rpc" } sui-open-rpc-macros = { path = "../sui-open-rpc-macros" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "ff5c1d69057fe93be658377462ca2875a57a0223" } workspace-hack = { path = "../workspace-hack"} diff --git a/crates/sui-json/Cargo.toml b/crates/sui-json/Cargo.toml index 9380114d4cc3e..163cea8a6157f 100644 --- a/crates/sui-json/Cargo.toml +++ b/crates/sui-json/Cargo.toml @@ -17,8 +17,8 @@ schemars = "0.8.8" sui-types = { path = "../sui-types" } sui-verifier = { path = "../sui-verifier" } -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } workspace-hack = { path = "../workspace-hack"} [dev-dependencies] diff --git a/crates/sui-json/src/lib.rs b/crates/sui-json/src/lib.rs index 9349c3b47abe9..6479540088766 100644 --- a/crates/sui-json/src/lib.rs +++ b/crates/sui-json/src/lib.rs @@ -3,9 +3,7 @@ use anyhow::{anyhow, bail}; use move_binary_format::{ - access::ModuleAccess, - binary_views::BinaryIndexedView, - file_format::{SignatureToken, Visibility}, + access::ModuleAccess, binary_views::BinaryIndexedView, file_format::SignatureToken, }; use move_core_types::account_address::AccountAddress; use move_core_types::{ @@ -368,7 +366,7 @@ pub fn resolve_move_function_args( let function_signature = module.function_handle_at(fdef.function); let parameters = &module.signature_at(function_signature.parameters).0; - if fdef.visibility != Visibility::Script { + if !fdef.is_entry { bail!( "{}::{} does not have public(script) visibility", module.self_id(), diff --git a/crates/sui-storage/Cargo.toml b/crates/sui-storage/Cargo.toml index 54adc22368a6d..08ea8fb6a3a6e 100644 --- a/crates/sui-storage/Cargo.toml +++ b/crates/sui-storage/Cargo.toml @@ -23,7 +23,7 @@ sui-types = { path = "../sui-types" } typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "ff5c1d69057fe93be658377462ca2875a57a0223"} workspace-hack = { path = "../workspace-hack"} -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } [dev-dependencies] tempfile = "3.3.0" diff --git a/crates/sui-transactional-test-runner/Cargo.toml b/crates/sui-transactional-test-runner/Cargo.toml index 4fed23516e341..98553a40f760a 100644 --- a/crates/sui-transactional-test-runner/Cargo.toml +++ b/crates/sui-transactional-test-runner/Cargo.toml @@ -20,18 +20,18 @@ rand = "0.7.3" rayon = "1.5.3" tempfile = "3.2.0" -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-cli = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-command-line-common = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-compiler = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } -move-stdlib = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-symbol-pool = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-transactional-test-runner = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-runtime = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-cli = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-command-line-common = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-compiler = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } +move-stdlib = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-symbol-pool = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-transactional-test-runner = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-runtime = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } sui-framework = { path = "../sui-framework" } diff --git a/crates/sui-transactional-test-runner/src/test_adapter.rs b/crates/sui-transactional-test-runner/src/test_adapter.rs index 8842e2932f326..4d5272824ed83 100644 --- a/crates/sui-transactional-test-runner/src/test_adapter.rs +++ b/crates/sui-transactional-test-runner/src/test_adapter.rs @@ -685,7 +685,7 @@ impl<'a> GetModule for &'a SuiTestAdapter<'_> { static NAMED_ADDRESSES: Lazy> = Lazy::new(|| { let mut map = move_stdlib::move_stdlib_named_addresses(); - assert!(map.get("Std").unwrap().into_inner() == MOVE_STDLIB_ADDRESS); + assert!(map.get("std").unwrap().into_inner() == MOVE_STDLIB_ADDRESS); // TODO fix Sui framework constants map.insert( "Sui".to_string(), diff --git a/crates/sui-types/Cargo.toml b/crates/sui-types/Cargo.toml index d7ce5ed25fb05..f3779b0ecece0 100644 --- a/crates/sui-types/Cargo.toml +++ b/crates/sui-types/Cargo.toml @@ -39,12 +39,12 @@ strum_macros = "^0.24" name-variant = { git = "https://github.com/MystenLabs/mysten-infra", rev = "ff5c1d69057fe93be658377462ca2875a57a0223" } typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "ff5c1d69057fe93be658377462ca2875a57a0223" } -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } -move-disassembler = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-ir-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } +move-disassembler = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-ir-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } narwhal-executor = { git = "https://github.com/MystenLabs/narwhal", rev = "2c5e8236c0702a3ff47dd769c2bbc94b029bf4a9", package = "executor" } narwhal-crypto = { git = "https://github.com/MystenLabs/narwhal", rev = "2c5e8236c0702a3ff47dd769c2bbc94b029bf4a9", package = "crypto" } diff --git a/crates/sui-types/src/base_types.rs b/crates/sui-types/src/base_types.rs index 57be80b843ab5..23bbd6a92c139 100644 --- a/crates/sui-types/src/base_types.rs +++ b/crates/sui-types/src/base_types.rs @@ -294,8 +294,8 @@ impl IntoPoint for ExecutionDigests { } } -pub const STD_OPTION_MODULE_NAME: &IdentStr = ident_str!("Option"); -pub const STD_OPTION_STRUCT_NAME: &IdentStr = STD_OPTION_MODULE_NAME; +pub const STD_OPTION_MODULE_NAME: &IdentStr = ident_str!("option"); +pub const STD_OPTION_STRUCT_NAME: &IdentStr = ident_str!("Option"); pub const TX_CONTEXT_MODULE_NAME: &IdentStr = ident_str!("TxContext"); pub const TX_CONTEXT_STRUCT_NAME: &IdentStr = TX_CONTEXT_MODULE_NAME; diff --git a/crates/sui-types/src/error.rs b/crates/sui-types/src/error.rs index 94d2af30e7e37..6e0c0e2baaabb 100644 --- a/crates/sui-types/src/error.rs +++ b/crates/sui-types/src/error.rs @@ -218,8 +218,8 @@ pub enum SuiError { ModuleNotFound { module_name: String }, #[error("Function signature is invalid: {error:?}.")] InvalidFunctionSignature { error: String }, - #[error("Function visibility is invalid for an entry point to execution: {error:?}.")] - InvalidFunctionVisibility { error: String }, + #[error("Non-`entry` function used for entry point to execution: {error:?}.")] + InvalidNonEntryFunction { error: String }, #[error("Type error while binding function arguments: {error:?}.")] TypeError { error: String }, #[error("Execution aborted: {error:?}.")] diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/generic_and_generic_object_params.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/generic_and_generic_object_params.mvir index 18e3fa0ffca37..3180c3b7b2339 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/generic_and_generic_object_params.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/generic_and_generic_object_params.mvir @@ -8,7 +8,7 @@ module 0x0.M { struct Obj has key { id: ID.VersionedID, } - public(script) foo(l0: T0, l1: Self.Obj, c: &mut TxContext.TxContext) { + public entry foo(l0: T0, l1: Self.Obj, c: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/generic_param_after_primitive.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/generic_param_after_primitive.mvir index 16ac6206aa26e..1627873f21b90 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/generic_param_after_primitive.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/generic_param_after_primitive.mvir @@ -8,7 +8,7 @@ module 0x0.M { struct Obj has key { id: ID.VersionedID, } - public(script) foo(l0: Self.Obj, l1: u64, l2: T, ctx: &mut TxContext.TxContext) { + public entry foo(l0: Self.Obj, l1: u64, l2: T, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_invalid.exp b/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_invalid.exp index bb396b4280367..0911cc0b211c3 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_invalid.exp +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_invalid.exp @@ -1,7 +1,7 @@ processed 2 tasks task 0 'publish'. lines 6-16: -Error: Failed to verify the Move module, reason: "Invalid entry point parameter type. Expected primitive or object type. Got: Std::Option::Option". +Error: Failed to verify the Move module, reason: "Invalid entry point parameter type. Expected primitive or object type. Got: std::option::Option". task 1 'publish'. lines 18-28: -Error: Failed to verify the Move module, reason: "Invalid entry point parameter type. Expected primitive or object type. Got: vector>". +Error: Failed to verify the Move module, reason: "Invalid entry point parameter type. Expected primitive or object type. Got: vector>". diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_invalid.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_invalid.mvir index ce1d4d91545a1..c2ba8ffdb4575 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_invalid.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_invalid.mvir @@ -6,9 +6,9 @@ //# publish module 0x0.M { import 0x2.TxContext; - import 0x1.Option; + import 0x1.option; - public(script) no(l0: Option.Option, ctx: &mut TxContext.TxContext) { + public entry no(l0: option.Option, ctx: &mut TxContext.TxContext) { label l0: abort 0; } @@ -18,9 +18,9 @@ module 0x0.M { //# publish module 0x0.M { import 0x2.TxContext; - import 0x1.Option; + import 0x1.option; - public(script) no(l0: vector>, ctx: &mut TxContext.TxContext) { + public entry no(l0: vector>, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_valid.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_valid.mvir index afcd6ab02986d..783fdb31d5cb7 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_valid.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/generic_with_key_valid.mvir @@ -6,9 +6,9 @@ //# publish module 0x0.M { import 0x2.TxContext; - import 0x1.Option; + import 0x1.option; - public(script) yes(l0: T, l1: &T, l2: &mut T, ctx: &mut TxContext.TxContext) { + public entry yes(l0: T, l1: &T, l2: &mut T, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/id.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/id.mvir index 468d5621810af..1f55639b64633 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/id.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/id.mvir @@ -8,7 +8,7 @@ module 0x0.M { import 0x2.TxContext; import 0x2.ID; - public(script) yes( + public entry yes( l0: ID.ID, l1: vector, l2: vector>, diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/nested_generic_vector_param.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/nested_generic_vector_param.mvir index 419a9c7ada960..265e7ca4882bc 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/nested_generic_vector_param.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/nested_generic_vector_param.mvir @@ -5,7 +5,7 @@ module 0x0.M { import 0x2.TxContext; - public(script) foo(l: vector>, ctx: &mut TxContext.TxContext) { + public entry foo(l: vector>, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/nested_key_generic_vector_param.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/nested_key_generic_vector_param.mvir index d3420a348a1d6..55b43e3003f0b 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/nested_key_generic_vector_param.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/nested_key_generic_vector_param.mvir @@ -5,7 +5,7 @@ module 0x0.M { import 0x2.TxContext; - public(script) foo(l: vector>, ctx: &mut TxContext.TxContext) { + public entry foo(l: vector>, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct.mvir index 1f3477259df93..b0332e88fc88a 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct.mvir @@ -9,7 +9,7 @@ module 0x0.M { struct S has copy, drop, store { value: u64 } - public(script) no(s: Self.S, ctx: &mut TxContext.TxContext) { + public entry no(s: Self.S, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic.mvir index 1a79888205782..c34cca4aba1df 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic.mvir @@ -11,7 +11,7 @@ module 0x0.M { struct Obj has key { id: ID.VersionedID } struct NoStore has copy, drop { value: u64 } - public(script) no(s: Self.Obj, ctx: &mut TxContext.TxContext) { + public entry no(s: Self.Obj, ctx: &mut TxContext.TxContext) { label l0: abort 0; } @@ -27,7 +27,7 @@ module 0x0.M { struct Obj has key { id: ID.VersionedID } - public(script) no(s: Self.Obj, ctx: &mut TxContext.TxContext) { + public entry no(s: Self.Obj, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic_valid.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic_valid.mvir index 812524cc3e618..dab38c2df70f6 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic_valid.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_generic_valid.mvir @@ -10,7 +10,7 @@ module 0x0.M { struct Obj has key { id: ID.VersionedID } - public(script) no(s: Self.Obj, ctx: &mut TxContext.TxContext) { + public entry no(s: Self.Obj, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_vector.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_vector.mvir index cab1d04df6268..adb7509491000 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_vector.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/non_key_struct_vector.mvir @@ -9,7 +9,7 @@ module 0x0.M { struct S has copy, drop, store { value: u64 } - public(script) no(s: vector, ctx: &mut TxContext.TxContext) { + public entry no(s: vector, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/option.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/option.mvir index 63fc755e86a7d..470f19d76e9fd 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/option.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/option.mvir @@ -6,14 +6,14 @@ //# publish module 0x0.M { import 0x2.TxContext; - import 0x1.Option; + import 0x1.option; - public(script) yes( - l0: Option.Option, - l1: Option.Option>, - l2: Option.Option>, - l3: vector>, - l4: Option.Option>, + public entry yes( + l0: option.Option, + l1: option.Option>, + l2: option.Option>, + l3: vector>, + l4: option.Option>, ctx: &mut TxContext.TxContext ) { label l0: diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/optional_txn_context.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/optional_txn_context.mvir index 629d2999c73e0..deab025bf8342 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/optional_txn_context.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/optional_txn_context.mvir @@ -4,7 +4,7 @@ //# publish module 0x0.M { import 0x2.TxContext; - public(script) t() { + public entry t() { label l0: abort 0; } @@ -16,7 +16,7 @@ module 0x0.M { import 0x2.TxContext; import 0x2.ID; struct Obj has key { id: ID.VersionedID } - public(script) t(flag: bool, arg: &mut Self.Obj) { + public entry t(flag: bool, arg: &mut Self.Obj) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/return_values.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/return_values.mvir index 977d155f9d68f..812545e378986 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/return_values.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/return_values.mvir @@ -4,7 +4,7 @@ //# publish module 0x0.M { import 0x2.TxContext; - public(script) foo(ctx: &mut TxContext.TxContext): u64 { + public entry foo(ctx: &mut TxContext.TxContext): u64 { label l0: abort 0; } @@ -13,7 +13,7 @@ module 0x0.M { //# publish module 0x0.M { import 0x2.TxContext; - public(script) foo(ctx: &mut TxContext.TxContext): u64 * u8 { + public entry foo(ctx: &mut TxContext.TxContext): u64 * u8 { label l0: abort 0; } @@ -22,7 +22,7 @@ module 0x0.M { //# publish module 0x0.M { import 0x2.TxContext; - public(script) foo(ctx: &mut TxContext.TxContext): vector { + public entry foo(ctx: &mut TxContext.TxContext): vector { label l0: abort 0; } @@ -32,7 +32,7 @@ module 0x0.M { //# publish module 0x0.M { import 0x2.TxContext; - public(script) foo(ctx: &mut TxContext.TxContext): &u8 { + public entry foo(ctx: &mut TxContext.TxContext): &u8 { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/single_generic_vector_param.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/single_generic_vector_param.mvir index 194c876e1f86a..fab0e129a968c 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/single_generic_vector_param.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/single_generic_vector_param.mvir @@ -5,7 +5,7 @@ module 0x0.M { import 0x2.TxContext; - public(script) foo(l: vector, ctx: &mut TxContext.TxContext) { + public entry foo(l: vector, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param.mvir index a94195be94c2c..83a7464afb6f6 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param.mvir @@ -5,7 +5,7 @@ module 0x0.M { import 0x2.TxContext; - public(script) foo(l: T, ctx: &mut TxContext.TxContext) { + public entry foo(l: T, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param_generic_object.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param_generic_object.mvir index 4031142e35bcc..5d828993621a4 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param_generic_object.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param_generic_object.mvir @@ -8,7 +8,7 @@ module 0x0.M { struct Obj has key { id: ID.VersionedID, } - public(script) foo(l: Self.Obj, ctx: &mut TxContext.TxContext) { + public entry foo(l: Self.Obj, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param_key.mvir b/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param_key.mvir index 6ebea1f75cf9b..de03efe0472b4 100644 --- a/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param_key.mvir +++ b/crates/sui-verifier-transactional-tests/tests/entry_points/single_type_param_key.mvir @@ -5,7 +5,7 @@ module 0x0.M { import 0x2.TxContext; - public(script) foo(l: T, ctx: &mut TxContext.TxContext) { + public entry foo(l: T, ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier-transactional-tests/tests/init/cannot_call_init.mvir b/crates/sui-verifier-transactional-tests/tests/init/cannot_call_init.mvir index b557791e08862..77ccfeec77a4c 100644 --- a/crates/sui-verifier-transactional-tests/tests/init/cannot_call_init.mvir +++ b/crates/sui-verifier-transactional-tests/tests/init/cannot_call_init.mvir @@ -9,7 +9,7 @@ module 0x0.M { abort 0; } - public(script) init_again(ctx: &mut TxContext.TxContext) { + public entry init_again(ctx: &mut TxContext.TxContext) { label l0: Self.init(move(ctx)); return; diff --git a/crates/sui-verifier-transactional-tests/tests/init/not_private.mvir b/crates/sui-verifier-transactional-tests/tests/init/not_private.mvir index d8581b95a87fd..060ac125f4db1 100644 --- a/crates/sui-verifier-transactional-tests/tests/init/not_private.mvir +++ b/crates/sui-verifier-transactional-tests/tests/init/not_private.mvir @@ -13,7 +13,7 @@ module 0x0.M { //# publish module 0x0.M { import 0x2.TxContext; - public(script) init(ctx: &mut TxContext.TxContext) { + public entry init(ctx: &mut TxContext.TxContext) { label l0: abort 0; } diff --git a/crates/sui-verifier/Cargo.toml b/crates/sui-verifier/Cargo.toml index e3385a8916804..c072b6a232839 100644 --- a/crates/sui-verifier/Cargo.toml +++ b/crates/sui-verifier/Cargo.toml @@ -8,11 +8,11 @@ license = "Apache-2.0" publish = false [dependencies] -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } -move-disassembler = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-ir-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } +move-disassembler = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-ir-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } sui-types = { path = "../sui-types" } workspace-hack = { path = "../workspace-hack"} diff --git a/crates/sui-verifier/src/entry_points_verifier.rs b/crates/sui-verifier/src/entry_points_verifier.rs index 3413508300185..833a068a62e6c 100644 --- a/crates/sui-verifier/src/entry_points_verifier.rs +++ b/crates/sui-verifier/src/entry_points_verifier.rs @@ -32,7 +32,7 @@ pub const INIT_FN_NAME: &IdentStr = ident_str!("init"); /// - Alternatively, the function can have zero parameters /// /// For transaction entry points -/// - The function must have `Visibility::Script` +/// - The function must have `is_entry` true /// - The function must have at least one parameter: &mut TxContext (see `is_tx_context`) /// - The transaction context parameter must be the last parameter /// - The function cannot have any return values @@ -49,11 +49,10 @@ pub fn verify_module(module: &CompiledModule) -> SuiResult { continue; } - // find candidate entry functions and checke their parameters + // find candidate entry functions and check their parameters // (ignore other functions) - if func_def.visibility != Visibility::Script { - // it's not an entry function as a non-script function - // cannot be called from Sui + if !func_def.is_entry { + // it's not an entry function continue; } verify_entry_function_impl(module, func_def) diff --git a/crates/sui/Cargo.toml b/crates/sui/Cargo.toml index b7e8d56cf8d94..79c9ac3e3a58f 100644 --- a/crates/sui/Cargo.toml +++ b/crates/sui/Cargo.toml @@ -59,12 +59,12 @@ rustyline-derive = "0.6.0" colored = "2.0.0" unescape = "0.1.0" -move-package = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } -move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-unit-test = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-package = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } +move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-unit-test = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } narwhal-node = { git = "https://github.com/MystenLabs/narwhal", rev = "2c5e8236c0702a3ff47dd769c2bbc94b029bf4a9", package = "node" } diff --git a/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/CustomObjectTemplate.move b/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/CustomObjectTemplate.move index 0120f62846540..37fd1dd34984b 100644 --- a/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/CustomObjectTemplate.move +++ b/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/CustomObjectTemplate.move @@ -85,7 +85,7 @@ module Examples::CustomObjectTemplate { /// input objects + created objects + emitted events, increments the /// sequence number each object, creates a hash that commits to the /// outputs, etc. - public(script) fun main( + public entry fun main( to_read: &Object, to_write: &mut Object, to_consume: Object, diff --git a/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/TicTacToe.move b/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/TicTacToe.move index 8e2f2c84f57f9..d91509bf9030b 100644 --- a/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/TicTacToe.move +++ b/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/TicTacToe.move @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 module Examples::TicTacToe { - use Std::Option::{Self, Option}; - use Std::Vector; + use std::option::{Self, Option}; + use std::vector; use Sui::ID::{Self, ID, VersionedID}; use Sui::Event; @@ -59,15 +59,15 @@ module Examples::TicTacToe { } /// `x_address` and `o_address` are the account address of the two players. - public(script) fun create_game(x_address: address, o_address: address, ctx: &mut TxContext) { + public entry fun create_game(x_address: address, o_address: address, ctx: &mut TxContext) { // TODO: Validate sender address, only GameAdmin can create games. let id = TxContext::new_id(ctx); let game_id = *ID::inner(&id); let gameboard = vector[ - vector[Option::none(), Option::none(), Option::none()], - vector[Option::none(), Option::none(), Option::none()], - vector[Option::none(), Option::none(), Option::none()], + vector[option::none(), option::none(), option::none()], + vector[option::none(), option::none(), option::none()], + vector[option::none(), option::none(), option::none()], ]; let game = TicTacToe { id, @@ -94,7 +94,7 @@ module Examples::TicTacToe { /// Generate a new mark intended for location (row, col). /// This new mark is not yet placed, just transferred to the game. - public(script) fun send_mark_to_game(cap: &mut MarkMintCap, game_address: address, row: u64, col: u64, ctx: &mut TxContext) { + public entry fun send_mark_to_game(cap: &mut MarkMintCap, game_address: address, row: u64, col: u64, ctx: &mut TxContext) { if (row > 2 || col > 2) { abort INVALID_LOCATION }; @@ -108,7 +108,7 @@ module Examples::TicTacToe { Transfer::transfer(mark, game_address); } - public(script) fun place_mark(game: &mut TicTacToe, mark: Mark, ctx: &mut TxContext) { + public entry fun place_mark(game: &mut TicTacToe, mark: Mark, ctx: &mut TxContext) { // If we are placing the mark at the wrong turn, or if game has ended, // destroy the mark. let addr = get_cur_turn_address(game); @@ -117,13 +117,13 @@ module Examples::TicTacToe { return }; let cell = get_cell_mut_ref(game, mark.row, mark.col); - if (Option::is_some(cell)) { + if (option::is_some(cell)) { // There is already a mark in the desired location. // Destroy the mark. delete_mark(mark); return }; - Option::fill(cell, mark); + option::fill(cell, mark); update_winner(game); game.cur_turn = game.cur_turn + 1; @@ -138,30 +138,30 @@ module Examples::TicTacToe { } } - public(script) fun delete_game(game: TicTacToe) { + public entry fun delete_game(game: TicTacToe) { let TicTacToe { id, gameboard, cur_turn: _, game_status: _, x_address: _, o_address: _ } = game; - while (Vector::length(&gameboard) > 0) { - let row = Vector::pop_back(&mut gameboard); - while (Vector::length(&row) > 0) { - let element = Vector::pop_back(&mut row); - if (Option::is_some(&element)) { - let mark = Option::extract(&mut element); + while (vector::length(&gameboard) > 0) { + let row = vector::pop_back(&mut gameboard); + while (vector::length(&row) > 0) { + let element = vector::pop_back(&mut row); + if (option::is_some(&element)) { + let mark = option::extract(&mut element); delete_mark(mark); }; - Option::destroy_none(element); + option::destroy_none(element); }; - Vector::destroy_empty(row); + vector::destroy_empty(row); }; - Vector::destroy_empty(gameboard); + vector::destroy_empty(gameboard); ID::delete(id); } - public(script) fun delete_trophy(trophy: Trophy) { + public entry fun delete_trophy(trophy: Trophy) { let Trophy { id } = trophy; ID::delete(id); } - public(script) fun delete_cap(cap: MarkMintCap) { + public entry fun delete_cap(cap: MarkMintCap) { let MarkMintCap { id, game_id: _, remaining_supply: _ } = cap; ID::delete(id); } @@ -192,11 +192,11 @@ module Examples::TicTacToe { } fun get_cell_ref(game: &TicTacToe, row: u64, col: u64): &Option { - Vector::borrow(Vector::borrow(&game.gameboard, row), col) + vector::borrow(vector::borrow(&game.gameboard, row), col) } fun get_cell_mut_ref(game: &mut TicTacToe, row: u64, col: u64): &mut Option { - Vector::borrow_mut(Vector::borrow_mut(&mut game.gameboard, row), col) + vector::borrow_mut(vector::borrow_mut(&mut game.gameboard, row), col) } fun update_winner(game: &mut TicTacToe) { @@ -225,8 +225,8 @@ module Examples::TicTacToe { return }; let result = check_all_equal(game, row1, col1, row2, col2, row3, col3); - if (Option::is_some(&result)) { - let winner = Option::extract(&mut result); + if (option::is_some(&result)) { + let winner = option::extract(&mut result); game.game_status = if (&winner == &game.x_address) { X_WIN } else { @@ -239,15 +239,15 @@ module Examples::TicTacToe { let cell1 = get_cell_ref(game, row1, col1); let cell2 = get_cell_ref(game, row2, col2); let cell3 = get_cell_ref(game, row3, col3); - if (Option::is_some(cell1) && Option::is_some(cell2) && Option::is_some(cell3)) { - let cell1_player = *&Option::borrow(cell1).player; - let cell2_player = *&Option::borrow(cell2).player; - let cell3_player = *&Option::borrow(cell3).player; + if (option::is_some(cell1) && option::is_some(cell2) && option::is_some(cell3)) { + let cell1_player = *&option::borrow(cell1).player; + let cell2_player = *&option::borrow(cell2).player; + let cell3_player = *&option::borrow(cell3).player; if (&cell1_player == &cell2_player && &cell1_player == &cell3_player) { - return Option::some(cell1_player) + return option::some(cell1_player) }; }; - Option::none() + option::none() } fun delete_mark(mark: Mark) { diff --git a/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/TrustedCoin.move b/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/TrustedCoin.move index d057a13aeb7e3..2a7b896558bb4 100644 --- a/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/TrustedCoin.move +++ b/crates/sui/src/unit_tests/data/custom_genesis_package_1/sources/TrustedCoin.move @@ -20,12 +20,12 @@ module Examples::TrustedCoin { Transfer::transfer(treasury_cap, TxContext::sender(ctx)) } - public(script) fun mint(treasury_cap: &mut TreasuryCap, amount: u64, ctx: &mut TxContext) { + public entry fun mint(treasury_cap: &mut TreasuryCap, amount: u64, ctx: &mut TxContext) { let coin = Coin::mint(amount, treasury_cap, ctx); Coin::transfer(coin, TxContext::sender(ctx)); } - public(script) fun transfer(treasury_cap: TreasuryCap, recipient: address) { + public entry fun transfer(treasury_cap: TreasuryCap, recipient: address) { Coin::transfer_cap(treasury_cap, recipient); } diff --git a/crates/sui/src/unit_tests/data/dummy_modules_publish/sources/TrustedCoin.move b/crates/sui/src/unit_tests/data/dummy_modules_publish/sources/TrustedCoin.move index d057a13aeb7e3..2a7b896558bb4 100644 --- a/crates/sui/src/unit_tests/data/dummy_modules_publish/sources/TrustedCoin.move +++ b/crates/sui/src/unit_tests/data/dummy_modules_publish/sources/TrustedCoin.move @@ -20,12 +20,12 @@ module Examples::TrustedCoin { Transfer::transfer(treasury_cap, TxContext::sender(ctx)) } - public(script) fun mint(treasury_cap: &mut TreasuryCap, amount: u64, ctx: &mut TxContext) { + public entry fun mint(treasury_cap: &mut TreasuryCap, amount: u64, ctx: &mut TxContext) { let coin = Coin::mint(amount, treasury_cap, ctx); Coin::transfer(coin, TxContext::sender(ctx)); } - public(script) fun transfer(treasury_cap: TreasuryCap, recipient: address) { + public entry fun transfer(treasury_cap: TreasuryCap, recipient: address) { Coin::transfer_cap(treasury_cap, recipient); } diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index b227e0847d2ef..c42a55696e978 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -24,8 +24,8 @@ jsonrpsee-http-client = "0.13.1" sui-adapter = { path = "../sui-adapter" } sui-framework = { path = "../sui-framework" } sui-gateway = { path = "../sui-gateway" } -move-package = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } +move-package = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev ="ff5c1d69057fe93be658377462ca2875a57a0223"} narwhal-config = { git = "https://github.com/MystenLabs/narwhal", rev = "2c5e8236c0702a3ff47dd769c2bbc94b029bf4a9", package = "config" } diff --git a/crates/workspace-hack/Cargo.toml b/crates/workspace-hack/Cargo.toml index efe5f9e9c4876..132220e8dbaa9 100644 --- a/crates/workspace-hack/Cargo.toml +++ b/crates/workspace-hack/Cargo.toml @@ -62,7 +62,7 @@ bls-crypto = { git = "https://github.com/huitseeker/celo-bls-snark-rs", branch = blst = { version = "0.3" } bs58 = { version = "0.4", features = ["alloc", "std"] } bstr = { version = "0.2", features = ["lazy_static", "regex-automata", "serde", "serde1", "serde1-nostd", "std", "unicode"] } -bytecode-interpreter-crypto = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["fiat"] } +bytecode-interpreter-crypto = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["fiat"] } byteorder = { version = "1", features = ["i128", "std"] } bytes = { version = "1", features = ["std"] } bzip2-sys = { version = "0.1", default-features = false, features = ["static"] } @@ -243,41 +243,41 @@ mime = { version = "0.3", default-features = false } minimal-lexical = { version = "0.2", default-features = false, features = ["std"] } miniz_oxide = { version = "0.5", default-features = false } mio = { version = "0.8", features = ["net", "os-ext", "os-poll"] } -move-abigen = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-borrow-graph = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-bytecode-source-map = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-viewer = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-cli = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-command-line-common = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-compiler = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } -move-coverage = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-disassembler = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-docgen = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-errmapgen = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-ir-compiler = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-ir-to-bytecode = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-ir-to-bytecode-syntax = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-ir-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-model = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-package = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-prover = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-prover-boogie-backend = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-read-write-set-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-resource-viewer = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-stackless-bytecode = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-stackless-bytecode-interpreter = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-stdlib = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false, features = ["testing"] } -move-symbol-pool = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-table-extension = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-transactional-test-runner = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-unit-test = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-vm-runtime = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["debugging", "testing"] } -move-vm-test-utils = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-abigen = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-borrow-graph = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-bytecode-source-map = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-viewer = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-cli = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-command-line-common = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-compiler = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } +move-coverage = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-disassembler = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-docgen = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-errmapgen = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-ir-compiler = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-ir-to-bytecode = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-ir-to-bytecode-syntax = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-ir-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-model = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-package = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-prover = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-prover-boogie-backend = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-read-write-set-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-resource-viewer = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-stackless-bytecode = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-stackless-bytecode-interpreter = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-stdlib = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false, features = ["testing"] } +move-symbol-pool = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-table-extension = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-transactional-test-runner = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-unit-test = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-vm-runtime = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["debugging", "testing"] } +move-vm-test-utils = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } multiaddr = { version = "0.14", features = ["url"] } multihash = { version = "0.16", default-features = false, features = ["alloc", "derive", "identity", "multihash-derive", "multihash-impl", "std"] } mysten-network-9da6af2c8f03eecf = { package = "mysten-network", git = "https://github.com/MystenLabs/mysten-infra", rev = "7c247967e5a5abd59ecaa75bc62b05bcdf4503fe", default-features = false } @@ -349,8 +349,8 @@ rand_pcg = { version = "0.2", default-features = false } rand_xoshiro = { version = "0.6", default-features = false } rayon = { version = "1", default-features = false } rayon-core = { version = "1", default-features = false } -read-write-set = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -read-write-set-dynamic = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } +read-write-set = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +read-write-set-dynamic = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } ref-cast = { version = "1", default-features = false } regex = { version = "1", features = ["aho-corasick", "memchr", "perf", "perf-cache", "perf-dfa", "perf-inline", "perf-literal", "std", "unicode", "unicode-age", "unicode-bool", "unicode-case", "unicode-gencat", "unicode-perl", "unicode-script", "unicode-segment"] } regex-automata = { version = "0.1", features = ["regex-syntax", "std"] } @@ -556,7 +556,7 @@ blst = { version = "0.3" } bs58 = { version = "0.4", features = ["alloc", "std"] } bstr = { version = "0.2", features = ["lazy_static", "regex-automata", "serde", "serde1", "serde1-nostd", "std", "unicode"] } bumpalo = { version = "3" } -bytecode-interpreter-crypto = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["fiat"] } +bytecode-interpreter-crypto = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["fiat"] } byteorder = { version = "1", features = ["i128", "std"] } bytes = { version = "1", features = ["std"] } bzip2-sys = { version = "0.1", default-features = false, features = ["static"] } @@ -764,41 +764,41 @@ mime = { version = "0.3", default-features = false } minimal-lexical = { version = "0.2", default-features = false, features = ["std"] } miniz_oxide = { version = "0.5", default-features = false } mio = { version = "0.8", features = ["net", "os-ext", "os-poll"] } -move-abigen = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-borrow-graph = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-bytecode-source-map = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-bytecode-viewer = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-cli = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-command-line-common = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-compiler = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] } -move-coverage = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-disassembler = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-docgen = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-errmapgen = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-ir-compiler = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-ir-to-bytecode = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-ir-to-bytecode-syntax = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-ir-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-model = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-package = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-prover = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-prover-boogie-backend = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-read-write-set-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-resource-viewer = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-stackless-bytecode = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-stackless-bytecode-interpreter = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-stdlib = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false, features = ["testing"] } -move-symbol-pool = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-table-extension = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-transactional-test-runner = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-unit-test = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -move-vm-runtime = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["debugging", "testing"] } -move-vm-test-utils = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } -move-vm-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" } +move-abigen = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-binary-format = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-borrow-graph = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-bytecode-source-map = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-bytecode-verifier = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-bytecode-viewer = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-cli = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-command-line-common = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-compiler = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-core-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["address20"] } +move-coverage = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-disassembler = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-docgen = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-errmapgen = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-ir-compiler = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-ir-to-bytecode = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-ir-to-bytecode-syntax = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-ir-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-model = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-package = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-prover = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-prover-boogie-backend = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-read-write-set-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-resource-viewer = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-stackless-bytecode = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-stackless-bytecode-interpreter = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-stdlib = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false, features = ["testing"] } +move-symbol-pool = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-table-extension = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-transactional-test-runner = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-unit-test = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +move-vm-runtime = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", features = ["debugging", "testing"] } +move-vm-test-utils = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } +move-vm-types = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02" } multiaddr = { version = "0.14", features = ["url"] } multihash = { version = "0.16", default-features = false, features = ["alloc", "derive", "identity", "multihash-derive", "multihash-impl", "std"] } multihash-derive = { version = "0.8", default-features = false, features = ["std"] } @@ -891,8 +891,8 @@ rand_pcg = { version = "0.2", default-features = false } rand_xoshiro = { version = "0.6", default-features = false } rayon = { version = "1", default-features = false } rayon-core = { version = "1", default-features = false } -read-write-set = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } -read-write-set-dynamic = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", default-features = false } +read-write-set = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } +read-write-set-dynamic = { git = "https://github.com/move-language/move", rev = "4e15a34ecf155b7e2d9729d3b07f83c146149f02", default-features = false } readonly = { version = "0.2", default-features = false } ref-cast = { version = "1", default-features = false } ref-cast-impl = { version = "1", default-features = false } diff --git a/sui_programmability/examples/basics/sources/Counter.move b/sui_programmability/examples/basics/sources/Counter.move index add9a5ffe7f32..8470c9676cd7d 100644 --- a/sui_programmability/examples/basics/sources/Counter.move +++ b/sui_programmability/examples/basics/sources/Counter.move @@ -27,7 +27,7 @@ module Basics::Counter { } /// Create and share a Counter object. - public(script) fun create(ctx: &mut TxContext) { + public entry fun create(ctx: &mut TxContext) { Transfer::share_object(Counter { id: TxContext::new_id(ctx), owner: TxContext::sender(ctx), @@ -36,18 +36,18 @@ module Basics::Counter { } /// Increment a counter by 1. - public(script) fun increment(counter: &mut Counter) { + public entry fun increment(counter: &mut Counter) { counter.value = counter.value + 1; } /// Set value (only runnable by the Counter owner) - public(script) fun set_value(counter: &mut Counter, value: u64, ctx: &mut TxContext) { + public entry fun set_value(counter: &mut Counter, value: u64, ctx: &mut TxContext) { assert!(counter.owner == TxContext::sender(ctx), 0); counter.value = value; } /// Assert a value for the counter. - public(script) fun assert_value(counter: &Counter, value: u64) { + public entry fun assert_value(counter: &Counter, value: u64) { assert!(counter.value == value, 0) } } @@ -58,7 +58,7 @@ module Basics::CounterTest { use Basics::Counter; #[test] - public(script) fun test_counter() { + public entry fun test_counter() { let owner = @0xC0FFEE; let user1 = @0xA1; diff --git a/sui_programmability/examples/basics/sources/Lock.move b/sui_programmability/examples/basics/sources/Lock.move index 7620e8d8017b9..551b546498a32 100644 --- a/sui_programmability/examples/basics/sources/Lock.move +++ b/sui_programmability/examples/basics/sources/Lock.move @@ -10,7 +10,7 @@ module Basics::Lock { use Sui::ID::{Self, ID, VersionedID}; use Sui::Transfer; use Sui::TxContext::{Self, TxContext}; - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; /// Lock is empty, nothing to take. const ELockIsEmpty: u64 = 0; @@ -41,13 +41,13 @@ module Basics::Lock { /// Lock some content inside a shared object. A Key is created and is /// sent to the transaction sender. - public(script) fun create(obj: T, ctx: &mut TxContext) { + public entry fun create(obj: T, ctx: &mut TxContext) { let id = TxContext::new_id(ctx); let for = *ID::inner(&id); Transfer::share_object(Lock { id, - locked: Option::some(obj), + locked: option::some(obj), }); Transfer::transfer(Key { @@ -58,15 +58,15 @@ module Basics::Lock { /// Lock something inside a shared object using a Key. Aborts if /// lock is not empty or if key doesn't match the lock. - public(script) fun lock( + public entry fun lock( obj: T, lock: &mut Lock, key: &Key, ) { - assert!(Option::is_none(&lock.locked), ELockIsFull); + assert!(option::is_none(&lock.locked), ELockIsFull); assert!(&key.for == ID::id(lock), EKeyMismatch); - Option::fill(&mut lock.locked, obj); + option::fill(&mut lock.locked, obj); } /// Unlock the Lock with a Key and access its contents. @@ -77,10 +77,10 @@ module Basics::Lock { lock: &mut Lock, key: &Key, ): T { - assert!(Option::is_some(&lock.locked), ELockIsEmpty); + assert!(option::is_some(&lock.locked), ELockIsEmpty); assert!(&key.for == ID::id(lock), EKeyMismatch); - Option::extract(&mut lock.locked) + option::extract(&mut lock.locked) } /// Unlock the Lock and transfer its contents to the transaction sender. @@ -107,7 +107,7 @@ module Basics::LockTest { } #[test] - public(script) fun test_lock() { + public entry fun test_lock() { let user1 = @0x1; let user2 = @0x2; diff --git a/sui_programmability/examples/basics/sources/Object.move b/sui_programmability/examples/basics/sources/Object.move index 28c7f7f8123d4..68a26f744a0e7 100644 --- a/sui_programmability/examples/basics/sources/Object.move +++ b/sui_programmability/examples/basics/sources/Object.move @@ -85,7 +85,7 @@ module Basics::Object { /// input objects + created objects + emitted events, increments the /// sequence number each object, creates a hash that commits to the /// outputs, etc. - public(script) fun main( + public entry fun main( to_read: &Object, to_write: &mut Object, to_consume: Object, diff --git a/sui_programmability/examples/basics/sources/Sandwich.move b/sui_programmability/examples/basics/sources/Sandwich.move index 91f5f0c725301..e9d51a266708c 100644 --- a/sui_programmability/examples/basics/sources/Sandwich.move +++ b/sui_programmability/examples/basics/sources/Sandwich.move @@ -57,7 +57,7 @@ module Basics::Sandwich { } /// Exchange `c` for some ham - public(script) fun buy_ham( + public entry fun buy_ham( grocery: &mut Grocery, c: Coin, ctx: &mut TxContext @@ -69,7 +69,7 @@ module Basics::Sandwich { } /// Exchange `c` for some bread - public(script) fun buy_bread( + public entry fun buy_bread( grocery: &mut Grocery, c: Coin, ctx: &mut TxContext @@ -81,7 +81,7 @@ module Basics::Sandwich { } /// Combine the `ham` and `bread` into a delicious sandwich - public(script) fun make_sandwich( + public entry fun make_sandwich( ham: Ham, bread: Bread, ctx: &mut TxContext ) { let Ham { id: ham_id } = ham; @@ -97,7 +97,7 @@ module Basics::Sandwich { } /// Owner of the grocery can collect profits by passing his capability - public(script) fun collect_profits(_cap: &GroceryOwnerCapability, grocery: &mut Grocery, ctx: &mut TxContext) { + public entry fun collect_profits(_cap: &GroceryOwnerCapability, grocery: &mut Grocery, ctx: &mut TxContext) { let amount = Balance::value(&grocery.profits); assert!(amount > 0, ENoProfits); @@ -122,7 +122,7 @@ module Basics::TestSandwich { use Sui::SUI::SUI; #[test] - public(script) fun test_make_sandwich() { + public entry fun test_make_sandwich() { let owner = @0x1; let the_guy = @0x2; diff --git a/sui_programmability/examples/defi/sources/Escrow.move b/sui_programmability/examples/defi/sources/Escrow.move index 035edf46f11f9..8f2680f5ff035 100644 --- a/sui_programmability/examples/defi/sources/Escrow.move +++ b/sui_programmability/examples/defi/sources/Escrow.move @@ -51,7 +51,7 @@ module DeFi::Escrow { } /// Trusted third party can swap compatible objects - public(script) fun swap( + public entry fun swap( obj1: EscrowedObj, obj2: EscrowedObj, ) { @@ -83,7 +83,7 @@ module DeFi::Escrow { } /// Trusted third party can always return an escrowed object to its original owner - public(script) fun return_to_sender( + public entry fun return_to_sender( obj: EscrowedObj, ) { let EscrowedObj { diff --git a/sui_programmability/examples/defi/sources/FlashLender.move b/sui_programmability/examples/defi/sources/FlashLender.move index 32f17985a8a72..3185af7342652 100644 --- a/sui_programmability/examples/defi/sources/FlashLender.move +++ b/sui_programmability/examples/defi/sources/FlashLender.move @@ -78,7 +78,7 @@ module DeFi::FlashLender { } /// Same as `new`, but transfer `WithdrawCap` to the transaction sender - public(script) fun create(to_lend: Coin, fee: u64, ctx: &mut TxContext) { + public entry fun create(to_lend: Coin, fee: u64, ctx: &mut TxContext) { let balance = Coin::into_balance(to_lend); let withdraw_cap = new(balance, fee, ctx); Transfer::transfer(withdraw_cap, TxContext::sender(ctx)) @@ -129,7 +129,7 @@ module DeFi::FlashLender { } /// Allow admin to add more funds to `self` - public(script) fun deposit( + public entry fun deposit( self: &mut FlashLender, admin_cap: &AdminCap, coin: Coin ) { // only the holder of the `AdminCap` for `self` can deposit funds @@ -138,7 +138,7 @@ module DeFi::FlashLender { } /// Allow admin to update the fee for `self` - public(script) fun update_fee( + public entry fun update_fee( self: &mut FlashLender, admin_cap: &AdminCap, new_fee: u64 ) { // only the holder of the `AdminCap` for `self` can update the fee diff --git a/sui_programmability/examples/defi/sources/SharedEscrow.move b/sui_programmability/examples/defi/sources/SharedEscrow.move index b5719feb51382..ba72440323e4d 100644 --- a/sui_programmability/examples/defi/sources/SharedEscrow.move +++ b/sui_programmability/examples/defi/sources/SharedEscrow.move @@ -3,7 +3,7 @@ /// An escrow for atomic swap of objects without a trusted third party module DeFi::SharedEscrow { - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; use Sui::ID::{Self, ID, VersionedID}; use Sui::Transfer; @@ -41,7 +41,7 @@ module DeFi::SharedEscrow { ) { let creator = TxContext::sender(ctx); let id = TxContext::new_id(ctx); - let escrowed = Option::some(escrowed_item); + let escrowed = option::some(escrowed_item); Transfer::share_object( EscrowedObj { id, creator, recipient, exchange_for, escrowed @@ -50,13 +50,13 @@ module DeFi::SharedEscrow { } /// The `recipient` of the escrow can exchange `obj` with the escrowed item - public(script) fun exchange( + public entry fun exchange( obj: ExchangeForT, escrow: &mut EscrowedObj, ctx: &mut TxContext ) { - assert!(Option::is_some(&escrow.escrowed), EAlreadyExchangedOrCancelled); - let escrowed_item = Option::extract(&mut escrow.escrowed); + assert!(option::is_some(&escrow.escrowed), EAlreadyExchangedOrCancelled); + let escrowed_item = option::extract(&mut escrow.escrowed); assert!(&TxContext::sender(ctx) == &escrow.recipient, EWrongRecipient); assert!(ID::id(&obj) == &escrow.exchange_for, EWrongExchangeObject); // everything matches. do the swap! @@ -65,12 +65,12 @@ module DeFi::SharedEscrow { } /// The `creator` can cancel the escrow and get back the escrowed item - public(script) fun cancel( + public entry fun cancel( escrow: &mut EscrowedObj, ctx: &mut TxContext ) { assert!(&TxContext::sender(ctx) == &escrow.creator, EWrongOwner); - assert!(Option::is_some(&escrow.escrowed), EAlreadyExchangedOrCancelled); - Transfer::transfer(Option::extract(&mut escrow.escrowed), escrow.creator); + assert!(option::is_some(&escrow.escrowed), EAlreadyExchangedOrCancelled); + Transfer::transfer(option::extract(&mut escrow.escrowed), escrow.creator); } } diff --git a/sui_programmability/examples/defi/tests/EscrowTests.move b/sui_programmability/examples/defi/tests/EscrowTests.move index 28b3fdeaad3ce..d9e83e8ec27eb 100644 --- a/sui_programmability/examples/defi/tests/EscrowTests.move +++ b/sui_programmability/examples/defi/tests/EscrowTests.move @@ -29,7 +29,7 @@ module DeFi::EscrowTests { } #[test] - public(script) fun test_escrow_flow() { + public entry fun test_escrow_flow() { // Both Alice and Bob send items to the third party let scenario = &mut send_to_escrow(ALICE_ADDRESS, BOB_ADDRESS); swap(scenario, &THIRD_PARTY_ADDRESS); @@ -40,7 +40,7 @@ module DeFi::EscrowTests { } #[test] - public(script) fun test_return_to_sender() { + public entry fun test_return_to_sender() { // Both Alice and Bob send items to the third party let scenario = &mut send_to_escrow(ALICE_ADDRESS, BOB_ADDRESS); @@ -61,7 +61,7 @@ module DeFi::EscrowTests { #[test] #[expected_failure(abort_code = 1)] - public(script) fun test_swap_wrong_objects() { + public entry fun test_swap_wrong_objects() { // Both Alice and Bob send items to the third party except that Alice wants to exchange // for a different object than Bob's let scenario = &mut send_to_escrow_with_overrides(ALICE_ADDRESS, BOB_ADDRESS, true, false); @@ -70,14 +70,14 @@ module DeFi::EscrowTests { #[test] #[expected_failure(abort_code = 0)] - public(script) fun test_swap_wrong_recipient() { + public entry fun test_swap_wrong_recipient() { // Both Alice and Bob send items to the third party except that Alice put a different // recipient than Bob let scenario = &mut send_to_escrow_with_overrides(ALICE_ADDRESS, BOB_ADDRESS, false, true); swap(scenario, &THIRD_PARTY_ADDRESS); } - public(script) fun swap(scenario: &mut Scenario, third_party: &address) { + public entry fun swap(scenario: &mut Scenario, third_party: &address) { TestScenario::next_tx(scenario, third_party); { let item_a = TestScenario::take_owned>(scenario); diff --git a/sui_programmability/examples/defi/tests/FlashLenderTests.move b/sui_programmability/examples/defi/tests/FlashLenderTests.move index 8581857c7e84a..28ad75411b167 100644 --- a/sui_programmability/examples/defi/tests/FlashLenderTests.move +++ b/sui_programmability/examples/defi/tests/FlashLenderTests.move @@ -9,7 +9,7 @@ module DeFi::FlashLenderTests { use Sui::TestScenario; #[test] - public(script) fun flash_loan_example() { + public entry fun flash_loan_example() { let admin = @0x1; let borrower = @0x2; diff --git a/sui_programmability/examples/defi/tests/SharedEscrowTest.move b/sui_programmability/examples/defi/tests/SharedEscrowTest.move index 6de8962470f76..d7ecb91e921bb 100644 --- a/sui_programmability/examples/defi/tests/SharedEscrowTest.move +++ b/sui_programmability/examples/defi/tests/SharedEscrowTest.move @@ -29,7 +29,7 @@ module DeFi::SharedEscrowTests { } #[test] - public(script) fun test_escrow_flow() { + public entry fun test_escrow_flow() { // Alice creates the escrow let (scenario, item_b_versioned_id) = create_escrow(ALICE_ADDRESS, BOB_ADDRESS); @@ -42,7 +42,7 @@ module DeFi::SharedEscrowTests { } #[test] - public(script) fun test_cancel() { + public entry fun test_cancel() { // Alice creates the escrow let (scenario, id) = create_escrow(ALICE_ADDRESS, BOB_ADDRESS); ID::delete(id); @@ -59,7 +59,7 @@ module DeFi::SharedEscrowTests { #[test] #[expected_failure(abort_code = 0)] - public(script) fun test_cancel_with_wrong_owner() { + public entry fun test_cancel_with_wrong_owner() { // Alice creates the escrow let (scenario, id) = create_escrow(ALICE_ADDRESS, BOB_ADDRESS); ID::delete(id); @@ -71,7 +71,7 @@ module DeFi::SharedEscrowTests { #[test] #[expected_failure(abort_code = 2)] - public(script) fun test_swap_wrong_objects() { + public entry fun test_swap_wrong_objects() { // Alice creates the escrow in exchange for item b let (scenario, item_b_versioned_id) = create_escrow(ALICE_ADDRESS, BOB_ADDRESS); ID::delete(item_b_versioned_id); @@ -86,7 +86,7 @@ module DeFi::SharedEscrowTests { #[test] #[expected_failure(abort_code = 1)] - public(script) fun test_swap_wrong_recipient() { + public entry fun test_swap_wrong_recipient() { // Alice creates the escrow in exchange for item b let (scenario, item_b_versioned_id) = create_escrow(ALICE_ADDRESS, BOB_ADDRESS); let scenario = &mut scenario; @@ -97,7 +97,7 @@ module DeFi::SharedEscrowTests { #[test] #[expected_failure(abort_code = 3)] - public(script) fun test_cancel_twice() { + public entry fun test_cancel_twice() { // Alice creates the escrow let (scenario, id) = create_escrow(ALICE_ADDRESS, BOB_ADDRESS); ID::delete(id); @@ -115,7 +115,7 @@ module DeFi::SharedEscrowTests { cancel(scenario, &ALICE_ADDRESS); } - public(script) fun cancel(scenario: &mut Scenario, initiator: &address) { + public entry fun cancel(scenario: &mut Scenario, initiator: &address) { TestScenario::next_tx(scenario, initiator); { let escrow_wrapper = TestScenario::take_shared>(scenario); @@ -126,7 +126,7 @@ module DeFi::SharedEscrowTests { }; } - public(script) fun exchange(scenario: &mut Scenario, bob: &address, item_b_verioned_id: VersionedID) { + public entry fun exchange(scenario: &mut Scenario, bob: &address, item_b_verioned_id: VersionedID) { TestScenario::next_tx(scenario, bob); { let escrow_wrapper = TestScenario::take_shared>(scenario); diff --git a/sui_programmability/examples/fungible_tokens/sources/MANAGED.move b/sui_programmability/examples/fungible_tokens/sources/MANAGED.move index 7f3d9c59588fd..bdd395d49f212 100644 --- a/sui_programmability/examples/fungible_tokens/sources/MANAGED.move +++ b/sui_programmability/examples/fungible_tokens/sources/MANAGED.move @@ -28,12 +28,12 @@ module FungibleTokens::MANAGED { } /// Manager can burn coins - public(script) fun burn(treasury_cap: &mut TreasuryCap, coin: Coin) { + public entry fun burn(treasury_cap: &mut TreasuryCap, coin: Coin) { Coin::burn(coin, treasury_cap) } /// Manager can transfer the treasury capability to a new manager - public(script) fun transfer_cap(treasury_cap: TreasuryCap, recipient: address) { + public entry fun transfer_cap(treasury_cap: TreasuryCap, recipient: address) { Coin::transfer_cap(treasury_cap, recipient); } diff --git a/sui_programmability/examples/games/sources/Hero.move b/sui_programmability/examples/games/sources/Hero.move index dedc83f52a761..95d63be1dc691 100644 --- a/sui_programmability/examples/games/sources/Hero.move +++ b/sui_programmability/examples/games/sources/Hero.move @@ -11,7 +11,7 @@ module Games::Hero { use Sui::SUI::SUI; use Sui::Transfer; use Sui::TxContext::{Self, TxContext}; - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; /// Our hero! struct Hero has key, store { @@ -120,11 +120,11 @@ module Games::Hero { /// Anyone can create run their own game, all game objects will be /// linked to this game. - public(script) fun new_game(ctx: &mut TxContext) { + public entry fun new_game(ctx: &mut TxContext) { create(ctx); } - /// Create a new game. Separated to bypass public(script) vs init requirements. + /// Create a new game. Separated to bypass public entry vs init requirements. fun create(ctx: &mut TxContext) { let sender = TxContext::sender(ctx); let id = TxContext::new_id(ctx); @@ -150,7 +150,7 @@ module Games::Hero { /// Slay the `boar` with the `hero`'s sword, get experience. /// Aborts if the hero has 0 HP or is not strong enough to slay the boar - public(script) fun slay( + public entry fun slay( game: &GameInfo, hero: &mut Hero, boar: Boar, ctx: &mut TxContext ) { check_id(game, hero.game_id); @@ -174,8 +174,8 @@ module Games::Hero { // hero gains experience proportional to the boar, sword grows in // strength by one (if hero is using a sword) hero.experience = hero.experience + hp; - if (Option::is_some(&hero.sword)) { - level_up_sword(Option::borrow_mut(&mut hero.sword), 1) + if (option::is_some(&hero.sword)) { + level_up_sword(option::borrow_mut(&mut hero.sword), 1) }; // let the world know about the hero's triumph by emitting an event! Event::emit(BoarSlainEvent { @@ -194,8 +194,8 @@ module Games::Hero { return 0 }; - let sword_strength = if (Option::is_some(&hero.sword)) { - sword_strength(Option::borrow(&hero.sword)) + let sword_strength = if (option::is_some(&hero.sword)) { + sword_strength(option::borrow(&hero.sword)) } else { // hero can fight without a sword, but will not be very strong 0 @@ -228,14 +228,14 @@ module Games::Hero { /// Add `new_sword` to the hero's inventory and return the old sword /// (if any) public fun equip_sword(hero: &mut Hero, new_sword: Sword): Option { - Option::swap_or_fill(&mut hero.sword, new_sword) + option::swap_or_fill(&mut hero.sword, new_sword) } /// Disarm the hero by returning their sword. /// Aborts if the hero does not have a sword. public fun remove_sword(hero: &mut Hero): Sword { - assert!(Option::is_some(&hero.sword), ENO_SWORD); - Option::extract(&mut hero.sword) + assert!(option::is_some(&hero.sword), ENO_SWORD); + option::extract(&mut hero.sword) } // --- Object creation --- @@ -265,7 +265,7 @@ module Games::Hero { } } - public(script) fun acquire_hero( + public entry fun acquire_hero( game: &GameInfo, payment: Coin, ctx: &mut TxContext ) { let sword = create_sword(game, payment, ctx); @@ -283,13 +283,13 @@ module Games::Hero { id: TxContext::new_id(ctx), hp: 100, experience: 0, - sword: Option::some(sword), + sword: option::some(sword), game_id: id(game) } } /// Admin can create a potion with the given `potency` for `recipient` - public(script) fun send_potion( + public entry fun send_potion( game: &GameInfo, potency: u64, player: address, @@ -306,7 +306,7 @@ module Games::Hero { } /// Admin can create a boar with the given attributes for `recipient` - public(script) fun send_boar( + public entry fun send_boar( game: &GameInfo, admin: &mut GameAdmin, hp: u64, @@ -342,7 +342,7 @@ module Games::Hero { public fun delete_hero_for_testing(hero: Hero) { let Hero { id, hp: _, experience: _, sword, game_id: _ } = hero; ID::delete(id); - let sword = Option::destroy_some(sword); + let sword = option::destroy_some(sword); let Sword { id, magic: _, strength: _, game_id: _ } = sword; ID::delete(id) } @@ -354,7 +354,7 @@ module Games::Hero { } #[test] - public(script) fun slay_boar_test() { + public entry fun slay_boar_test() { use Sui::Coin; use Sui::TestScenario; diff --git a/sui_programmability/examples/games/sources/RockPaperScissors.move b/sui_programmability/examples/games/sources/RockPaperScissors.move index 47dd1aee9e5ae..cbb00d4cb91f0 100644 --- a/sui_programmability/examples/games/sources/RockPaperScissors.move +++ b/sui_programmability/examples/games/sources/RockPaperScissors.move @@ -29,8 +29,8 @@ module Games::RockPaperScissors { use Sui::ID::{Self, VersionedID}; use Sui::TxContext::{Self, TxContext}; use Sui::Transfer::{Self}; - use Std::Vector; - use Std::Hash; + use std::vector; + use std::hash; // -- Gestures and additional consts -- // @@ -95,8 +95,8 @@ module Games::RockPaperScissors { /// entry point and limits the ability to select a winner, if one of the secrets hasn't /// been revealed yet. public fun status(game: &Game): u8 { - let h1_len = Vector::length(&game.hash_one); - let h2_len = Vector::length(&game.hash_two); + let h1_len = vector::length(&game.hash_one); + let h2_len = vector::length(&game.hash_two); if (game.gesture_one != NONE && game.gesture_two != NONE) { STATUS_REVEALED @@ -117,7 +117,7 @@ module Games::RockPaperScissors { /// is initiated with default/empty values which will be filled later in the game. /// /// todo: extend with generics + T as prize - public(script) fun new_game(player_one: address, player_two: address, ctx: &mut TxContext) { + public entry fun new_game(player_one: address, player_two: address, ctx: &mut TxContext) { Transfer::transfer(Game { id: TxContext::new_id(ctx), prize: ThePrize { id: TxContext::new_id(ctx) }, @@ -134,7 +134,7 @@ module Games::RockPaperScissors { /// is encoded inside the [`hash`] argument. /// /// Currently there's no check on whether the game exists. - public(script) fun player_turn(at: address, hash: vector, ctx: &mut TxContext) { + public entry fun player_turn(at: address, hash: vector, ctx: &mut TxContext) { Transfer::transfer(PlayerTurn { hash, id: TxContext::new_id(ctx), @@ -144,16 +144,16 @@ module Games::RockPaperScissors { /// Add a hashed gesture to the game. Store it as a `hash_one` or `hash_two` depending /// on the player number (one or two) - public(script) fun add_hash(game: &mut Game, cap: PlayerTurn) { + public entry fun add_hash(game: &mut Game, cap: PlayerTurn) { let PlayerTurn { hash, id, player } = cap; let status = status(game); assert!(status == STATUS_HASH_SUBMISSION || status == STATUS_READY, 0); assert!(game.player_one == player || game.player_two == player, 0); - if (player == game.player_one && Vector::length(&game.hash_one) == 0) { + if (player == game.player_one && vector::length(&game.hash_one) == 0) { game.hash_one = hash; - } else if (player == game.player_two && Vector::length(&game.hash_two) == 0) { + } else if (player == game.player_two && vector::length(&game.hash_two) == 0) { game.hash_two = hash; } else { abort 0 // unreachable!() @@ -164,7 +164,7 @@ module Games::RockPaperScissors { /// Submit a [`Secret`] to the game owner who then matches the hash and saves the /// gesture in the [`Game`] object. - public(script) fun reveal(at: address, salt: vector, ctx: &mut TxContext) { + public entry fun reveal(at: address, salt: vector, ctx: &mut TxContext) { Transfer::transfer(Secret { id: TxContext::new_id(ctx), salt, @@ -175,7 +175,7 @@ module Games::RockPaperScissors { /// Use submitted [`Secret`]'s salt to find the gesture played by the player and set it /// in the [`Game`] object. /// TODO: think of ways to - public(script) fun match_secret(game: &mut Game, secret: Secret) { + public entry fun match_secret(game: &mut Game, secret: Secret) { let Secret { salt, player, id } = secret; assert!(player == game.player_one || player == game.player_two, 0); @@ -191,7 +191,7 @@ module Games::RockPaperScissors { /// The final accord to the game logic. After both secrets have been revealed, /// the game owner can choose a winner and release the prize. - public(script) fun select_winner(game: Game, ctx: &mut TxContext) { + public entry fun select_winner(game: Game, ctx: &mut TxContext) { assert!(status(&game) == STATUS_REVEALED, 0); let Game { @@ -251,7 +251,7 @@ module Games::RockPaperScissors { /// that nobody knows the gesture until the end, but at the same time each player commits /// to the result with his hash; fun hash(gesture: u8, salt: vector): vector { - Vector::push_back(&mut salt, gesture); - Hash::sha2_256(salt) + vector::push_back(&mut salt, gesture); + hash::sha2_256(salt) } } diff --git a/sui_programmability/examples/games/sources/SeaHero.move b/sui_programmability/examples/games/sources/SeaHero.move index 0693a5aa1955a..a609683e9fab1 100644 --- a/sui_programmability/examples/games/sources/SeaHero.move +++ b/sui_programmability/examples/games/sources/SeaHero.move @@ -92,7 +92,7 @@ module Games::SeaHero { /// Game admin can reate a monster wrapping a coin worth `reward` and send /// it to `recipient` - public(script) fun create_monster( + public entry fun create_monster( admin: &mut SeaHeroAdmin, reward_amount: u64, recipient: address, diff --git a/sui_programmability/examples/games/sources/SharedTicTacToe.move b/sui_programmability/examples/games/sources/SharedTicTacToe.move index 11fe8569bcc54..1e6289f330e12 100644 --- a/sui_programmability/examples/games/sources/SharedTicTacToe.move +++ b/sui_programmability/examples/games/sources/SharedTicTacToe.move @@ -15,7 +15,7 @@ // As we can see, by using shared object, the implementation is much // simpler than the other implementation. module Games::SharedTicTacToe { - use Std::Vector; + use std::vector; use Sui::ID::{Self, ID, VersionedID}; use Sui::Event; @@ -62,7 +62,7 @@ module Games::SharedTicTacToe { } /// `x_address` and `o_address` are the account address of the two players. - public(script) fun create_game(x_address: address, o_address: address, ctx: &mut TxContext) { + public entry fun create_game(x_address: address, o_address: address, ctx: &mut TxContext) { // TODO: Validate sender address, only GameAdmin can create games. let id = TxContext::new_id(ctx); @@ -83,13 +83,13 @@ module Games::SharedTicTacToe { Transfer::share_object(game); } - public(script) fun place_mark(game: &mut TicTacToe, row: u8, col: u8, ctx: &mut TxContext) { + public entry fun place_mark(game: &mut TicTacToe, row: u8, col: u8, ctx: &mut TxContext) { assert!(row < 3 && col < 3, EInvalidLocation); assert!(game.game_status == IN_PROGRESS, EGameEnded); let addr = get_cur_turn_address(game); assert!(addr == TxContext::sender(ctx), EInvalidTurn); - let cell = Vector::borrow_mut(Vector::borrow_mut(&mut game.gameboard, (row as u64)), (col as u64)); + let cell = vector::borrow_mut(vector::borrow_mut(&mut game.gameboard, (row as u64)), (col as u64)); assert!(*cell == MARK_EMPTY, ECellOccupied); *cell = game.cur_turn % 2; @@ -107,12 +107,12 @@ module Games::SharedTicTacToe { } } - public(script) fun delete_game(game: TicTacToe) { + public entry fun delete_game(game: TicTacToe) { let TicTacToe { id, gameboard: _, cur_turn: _, game_status: _, x_address: _, o_address: _ } = game; ID::delete(id); } - public(script) fun delete_trophy(trophy: Trophy) { + public entry fun delete_trophy(trophy: Trophy) { let Trophy { id } = trophy; ID::delete(id); } @@ -130,7 +130,7 @@ module Games::SharedTicTacToe { } fun get_cell(game: &TicTacToe, row: u64, col: u64): u8 { - *Vector::borrow(Vector::borrow(&game.gameboard, row), col) + *vector::borrow(vector::borrow(&game.gameboard, row), col) } fun update_winner(game: &mut TicTacToe) { diff --git a/sui_programmability/examples/games/sources/TicTacToe.move b/sui_programmability/examples/games/sources/TicTacToe.move index a40e358f10e08..fb721c22b1c2f 100644 --- a/sui_programmability/examples/games/sources/TicTacToe.move +++ b/sui_programmability/examples/games/sources/TicTacToe.move @@ -18,8 +18,8 @@ // providing different trade-offs: using shared object is more expensive, // however it eliminates the need of a centralized service. module Games::TicTacToe { - use Std::Option::{Self, Option}; - use Std::Vector; + use std::option::{Self, Option}; + use std::vector; use Sui::ID::{Self, ID, VersionedID}; use Sui::Event; @@ -76,15 +76,15 @@ module Games::TicTacToe { } /// `x_address` and `o_address` are the account address of the two players. - public(script) fun create_game(x_address: address, o_address: address, ctx: &mut TxContext) { + public entry fun create_game(x_address: address, o_address: address, ctx: &mut TxContext) { // TODO: Validate sender address, only GameAdmin can create games. let id = TxContext::new_id(ctx); let game_id = *ID::inner(&id); let gameboard = vector[ - vector[Option::none(), Option::none(), Option::none()], - vector[Option::none(), Option::none(), Option::none()], - vector[Option::none(), Option::none(), Option::none()], + vector[option::none(), option::none(), option::none()], + vector[option::none(), option::none(), option::none()], + vector[option::none(), option::none(), option::none()], ]; let game = TicTacToe { id, @@ -111,7 +111,7 @@ module Games::TicTacToe { /// Generate a new mark intended for location (row, col). /// This new mark is not yet placed, just transferred to the game. - public(script) fun send_mark_to_game( + public entry fun send_mark_to_game( cap: &mut MarkMintCap, game_address: address, row: u64, @@ -131,7 +131,7 @@ module Games::TicTacToe { Transfer::transfer(mark, game_address); } - public(script) fun place_mark(game: &mut TicTacToe, mark: Mark, ctx: &mut TxContext) { + public entry fun place_mark(game: &mut TicTacToe, mark: Mark, ctx: &mut TxContext) { // If we are placing the mark at the wrong turn, or if game has ended, // destroy the mark. let addr = get_cur_turn_address(game); @@ -140,13 +140,13 @@ module Games::TicTacToe { return }; let cell = get_cell_mut_ref(game, mark.row, mark.col); - if (Option::is_some(cell)) { + if (option::is_some(cell)) { // There is already a mark in the desired location. // Destroy the mark. delete_mark(mark); return }; - Option::fill(cell, mark); + option::fill(cell, mark); update_winner(game); game.cur_turn = game.cur_turn + 1; @@ -161,30 +161,30 @@ module Games::TicTacToe { } } - public(script) fun delete_game(game: TicTacToe) { + public entry fun delete_game(game: TicTacToe) { let TicTacToe { id, gameboard, cur_turn: _, game_status: _, x_address: _, o_address: _ } = game; - while (Vector::length(&gameboard) > 0) { - let row = Vector::pop_back(&mut gameboard); - while (Vector::length(&row) > 0) { - let element = Vector::pop_back(&mut row); - if (Option::is_some(&element)) { - let mark = Option::extract(&mut element); + while (vector::length(&gameboard) > 0) { + let row = vector::pop_back(&mut gameboard); + while (vector::length(&row) > 0) { + let element = vector::pop_back(&mut row); + if (option::is_some(&element)) { + let mark = option::extract(&mut element); delete_mark(mark); }; - Option::destroy_none(element); + option::destroy_none(element); }; - Vector::destroy_empty(row); + vector::destroy_empty(row); }; - Vector::destroy_empty(gameboard); + vector::destroy_empty(gameboard); ID::delete(id); } - public(script) fun delete_trophy(trophy: Trophy) { + public entry fun delete_trophy(trophy: Trophy) { let Trophy { id } = trophy; ID::delete(id); } - public(script) fun delete_cap(cap: MarkMintCap) { + public entry fun delete_cap(cap: MarkMintCap) { let MarkMintCap { id, game_id: _, remaining_supply: _ } = cap; ID::delete(id); } @@ -215,11 +215,11 @@ module Games::TicTacToe { } fun get_cell_ref(game: &TicTacToe, row: u64, col: u64): &Option { - Vector::borrow(Vector::borrow(&game.gameboard, row), col) + vector::borrow(vector::borrow(&game.gameboard, row), col) } fun get_cell_mut_ref(game: &mut TicTacToe, row: u64, col: u64): &mut Option { - Vector::borrow_mut(Vector::borrow_mut(&mut game.gameboard, row), col) + vector::borrow_mut(vector::borrow_mut(&mut game.gameboard, row), col) } fun update_winner(game: &mut TicTacToe) { @@ -248,8 +248,8 @@ module Games::TicTacToe { return }; let result = check_all_equal(game, row1, col1, row2, col2, row3, col3); - if (Option::is_some(&result)) { - let winner = Option::extract(&mut result); + if (option::is_some(&result)) { + let winner = option::extract(&mut result); game.game_status = if (&winner == &game.x_address) { X_WIN } else { @@ -262,15 +262,15 @@ module Games::TicTacToe { let cell1 = get_cell_ref(game, row1, col1); let cell2 = get_cell_ref(game, row2, col2); let cell3 = get_cell_ref(game, row3, col3); - if (Option::is_some(cell1) && Option::is_some(cell2) && Option::is_some(cell3)) { - let cell1_player = *&Option::borrow(cell1).player; - let cell2_player = *&Option::borrow(cell2).player; - let cell3_player = *&Option::borrow(cell3).player; + if (option::is_some(cell1) && option::is_some(cell2) && option::is_some(cell3)) { + let cell1_player = *&option::borrow(cell1).player; + let cell2_player = *&option::borrow(cell2).player; + let cell3_player = *&option::borrow(cell3).player; if (&cell1_player == &cell2_player && &cell1_player == &cell3_player) { - return Option::some(cell1_player) + return option::some(cell1_player) }; }; - Option::none() + option::none() } fun delete_mark(mark: Mark) { diff --git a/sui_programmability/examples/games/tests/RockPaperScissorsTests.move b/sui_programmability/examples/games/tests/RockPaperScissorsTests.move index 4d81eab97def6..04435fbfdfea9 100644 --- a/sui_programmability/examples/games/tests/RockPaperScissorsTests.move +++ b/sui_programmability/examples/games/tests/RockPaperScissorsTests.move @@ -5,11 +5,11 @@ module Games::RockPaperScissorsTests { use Games::RockPaperScissors::{Self as Game, Game, PlayerTurn, Secret, ThePrize}; use Sui::TestScenario::{Self}; - use Std::Vector; - use Std::Hash; + use std::vector; + use std::hash; #[test] - public(script) fun play_rock_paper_scissors() { + public entry fun play_rock_paper_scissors() { // So these are our heroes. let the_main_guy = @0xA1C05; let mr_lizard = @0xA55555; @@ -103,7 +103,7 @@ module Games::RockPaperScissorsTests { // Copy of the hashing function from the main module. fun hash(gesture: u8, salt: vector): vector { - Vector::push_back(&mut salt, gesture); - Hash::sha2_256(salt) + vector::push_back(&mut salt, gesture); + hash::sha2_256(salt) } } diff --git a/sui_programmability/examples/games/tests/SharedTicTacToeTests.move b/sui_programmability/examples/games/tests/SharedTicTacToeTests.move index e961052a49bf6..89066759c6dc3 100644 --- a/sui_programmability/examples/games/tests/SharedTicTacToeTests.move +++ b/sui_programmability/examples/games/tests/SharedTicTacToeTests.move @@ -14,7 +14,7 @@ module Games::SharedTicTacToeTests { const DRAW: u8 = 3; #[test] - public(script) fun play_tictactoe() { + public entry fun play_tictactoe() { let player_x = @0x0; let player_o = @0x1; @@ -81,7 +81,7 @@ module Games::SharedTicTacToeTests { #[test] - public(script) fun play_tictactoe_draw() { + public entry fun play_tictactoe_draw() { let player_x = @0x0; let player_o = @0x1; @@ -188,7 +188,7 @@ module Games::SharedTicTacToeTests { } - public(script) fun place_mark( + public entry fun place_mark( row: u8, col: u8, player: &address, diff --git a/sui_programmability/examples/games/tests/TicTacToeTests.move b/sui_programmability/examples/games/tests/TicTacToeTests.move index 5d75f896ad86d..1e21272ea861b 100644 --- a/sui_programmability/examples/games/tests/TicTacToeTests.move +++ b/sui_programmability/examples/games/tests/TicTacToeTests.move @@ -15,7 +15,7 @@ module Games::TicTacToeTests { #[test] - public(script) fun play_tictactoe() { + public entry fun play_tictactoe() { let admin = @0x0; let player_x = @0x1; let player_o = @0x2; @@ -84,7 +84,7 @@ module Games::TicTacToeTests { #[test] - public(script) fun play_tictactoe_draw() { + public entry fun play_tictactoe_draw() { let admin = @0x0; let player_x = @0x1; let player_o = @0x2; @@ -191,7 +191,7 @@ module Games::TicTacToeTests { assert!(!TestScenario::can_take_owned(scenario), 1); } - public(script) fun place_mark( + public entry fun place_mark( row: u64, col: u64, admin: &address, diff --git a/sui_programmability/examples/move_tutorial/sources/M1.move b/sui_programmability/examples/move_tutorial/sources/M1.move index 674133cc07977..0d27d70c81069 100644 --- a/sui_programmability/examples/move_tutorial/sources/M1.move +++ b/sui_programmability/examples/move_tutorial/sources/M1.move @@ -41,7 +41,7 @@ module MyFirstPackage::M1 { self.strength } - public(script) fun sword_create(forge: &mut Forge, magic: u64, strength: u64, recipient: address, ctx: &mut TxContext) { + public entry fun sword_create(forge: &mut Forge, magic: u64, strength: u64, recipient: address, ctx: &mut TxContext) { use Sui::Transfer; use Sui::TxContext; // create a sword @@ -55,7 +55,7 @@ module MyFirstPackage::M1 { forge.swords_created = forge.swords_created + 1; } - public(script) fun sword_transfer(sword: Sword, recipient: address) { + public entry fun sword_transfer(sword: Sword, recipient: address) { use Sui::Transfer; // transfer the sword Transfer::transfer(sword, recipient); @@ -87,7 +87,7 @@ module MyFirstPackage::M1 { } #[test] - public(script) fun test_sword_transactions() { + public entry fun test_sword_transactions() { use Sui::TestScenario; // create test addresses representing users diff --git a/sui_programmability/examples/nfts/sources/Auction.move b/sui_programmability/examples/nfts/sources/Auction.move index 7bb2e773ed887..1577d51d8fc7e 100644 --- a/sui_programmability/examples/nfts/sources/Auction.move +++ b/sui_programmability/examples/nfts/sources/Auction.move @@ -90,7 +90,7 @@ module NFTs::Auction { /// Updates the auction based on the information in the bid /// (update auction if higher bid received and send coin back for /// bids that are too low). This is executed by the auctioneer. - public(script) fun update_auction( + public entry fun update_auction( auction: &mut Auction, bid: Bid, ctx: &mut TxContext ) { let Bid { id, bidder, auction_id, bid: balance } = bid; @@ -103,7 +103,7 @@ module NFTs::Auction { /// Ends the auction - transfers item to the currently highest /// bidder or to the original owner if no bids have been /// placed. This is executed by the auctioneer. - public(script) fun end_auction( + public entry fun end_auction( auction: Auction, ctx: &mut TxContext ) { AuctionLib::end_and_destroy_auction(auction, ctx); diff --git a/sui_programmability/examples/nfts/sources/AuctionLib.move b/sui_programmability/examples/nfts/sources/AuctionLib.move index f4e52c7698817..b1545102e4bcb 100644 --- a/sui_programmability/examples/nfts/sources/AuctionLib.move +++ b/sui_programmability/examples/nfts/sources/AuctionLib.move @@ -6,7 +6,7 @@ /// one using single-owner objects only and the other using shared /// objects. module NFTs::AuctionLib { - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; use Sui::Coin; use Sui::Balance::{Self, Balance}; @@ -58,9 +58,9 @@ module NFTs::AuctionLib { // answer is that it's checked by the runtime. Auction { id, - to_sell: Option::some(to_sell), + to_sell: option::some(to_sell), owner: TxContext::sender(ctx), - bid_data: Option::none(), + bid_data: option::none(), } } @@ -73,15 +73,15 @@ module NFTs::AuctionLib { funds: Balance, ctx: &mut TxContext, ) { - if (Option::is_none(&auction.bid_data)) { + if (option::is_none(&auction.bid_data)) { // first bid let bid_data = BidData { funds, highest_bidder: bidder, }; - Option::fill(&mut auction.bid_data, bid_data); + option::fill(&mut auction.bid_data, bid_data); } else { - let prev_bid_data = Option::borrow(&auction.bid_data); + let prev_bid_data = option::borrow(&auction.bid_data); if (Balance::value(&funds) > Balance::value(&prev_bid_data.funds)) { // a bid higher than currently highest bid received let new_bid_data = BidData { @@ -93,7 +93,7 @@ module NFTs::AuctionLib { let BidData { funds, highest_bidder - } = Option::swap(&mut auction.bid_data, new_bid_data); + } = option::swap(&mut auction.bid_data, new_bid_data); // transfer previously highest bid to its bidder send_balance(funds, highest_bidder, ctx); @@ -112,14 +112,14 @@ module NFTs::AuctionLib { bid_data: &mut Option, ctx: &mut TxContext ) { - let item = Option::extract(to_sell); - if (Option::is_some(bid_data)) { + let item = option::extract(to_sell); + if (option::is_some(bid_data)) { // bids have been placed - send funds to the original item // owner and the item to the highest bidder let BidData { funds, highest_bidder - } = Option::extract(bid_data); + } = option::extract(bid_data); send_balance(funds, owner, ctx); Transfer::transfer(item, highest_bidder); @@ -141,8 +141,8 @@ module NFTs::AuctionLib { end_auction(&mut to_sell, owner, &mut bid_data, ctx); - Option::destroy_none(bid_data); - Option::destroy_none(to_sell); + option::destroy_none(bid_data); + option::destroy_none(to_sell); } /// Ends auction (should only be used if Auction is a shared diff --git a/sui_programmability/examples/nfts/sources/Chat.move b/sui_programmability/examples/nfts/sources/Chat.move index 38ff75bc59476..c65986df3a623 100644 --- a/sui_programmability/examples/nfts/sources/Chat.move +++ b/sui_programmability/examples/nfts/sources/Chat.move @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 module NFTs::Chat { - use Std::ASCII::{Self, String}; - use Std::Option::{Self, Option, some}; + use std::ascii::{Self, String}; + use std::option::{Self, Option, some}; use Sui::ID::{Self, ID, VersionedID}; use Sui::Transfer; use Sui::TxContext::{Self, TxContext}; - use Std::Vector::length; + use std::vector::length; /// Max text length. const MAX_TEXT_LENGTH: u64 = 512; @@ -46,7 +46,7 @@ module NFTs::Chat { let chat = Chat { id: TxContext::new_id(ctx), app_id, - text: ASCII::string(text), + text: ascii::string(text), ref_id, metadata, }; @@ -54,19 +54,19 @@ module NFTs::Chat { } /// Mint (post) a Chat object without referencing another object. - public(script) fun post( + public entry fun post( app_identifier: address, text: vector, metadata: vector, ctx: &mut TxContext, ) { - post_internal(ID::new(app_identifier), text, Option::none(), metadata, ctx); + post_internal(ID::new(app_identifier), text, option::none(), metadata, ctx); } /// Mint (post) a Chat object and reference another object (i.e., to simulate retweet, reply, like, attach). /// TODO: Using `address` as `app_identifier` & `ref_identifier` type, because we cannot pass `ID` to entry /// functions. Using `vector` for `text` instead of `String` for the same reason. - public(script) fun post_with_ref( + public entry fun post_with_ref( app_identifier: address, text: vector, ref_identifier: address, @@ -77,7 +77,7 @@ module NFTs::Chat { } /// Burn a Chat object. - public(script) fun burn(chat: Chat) { + public entry fun burn(chat: Chat) { let Chat { id, app_id: _, text: _, ref_id: _, metadata: _ } = chat; ID::delete(id); } diff --git a/sui_programmability/examples/nfts/sources/CrossChainAirdrop.move b/sui_programmability/examples/nfts/sources/CrossChainAirdrop.move index 36535fc83d1c2..03b2863a84428 100644 --- a/sui_programmability/examples/nfts/sources/CrossChainAirdrop.move +++ b/sui_programmability/examples/nfts/sources/CrossChainAirdrop.move @@ -6,7 +6,7 @@ /// support a single chain(Ethereum) right now, but this can be extended to other /// chains by adding a chain_id field. module NFTs::CrossChainAirdrop { - use Std::Vector; + use std::vector; use Sui::ERC721Metadata::{Self, ERC721Metadata, TokenID}; use Sui::ID::{VersionedID}; use Sui::Transfer; @@ -58,14 +58,14 @@ module NFTs::CrossChainAirdrop { Transfer::transfer( CrossChainAirdropOracle { id: TxContext::new_id(ctx), - managed_contracts: Vector::empty(), + managed_contracts: vector::empty(), }, TxContext::sender(ctx) ) } /// Called by the oracle to mint the airdrop NFT and transfer to the recipient - public(script) fun claim( + public entry fun claim( oracle: &mut CrossChainAirdropOracle, recipient: address, source_contract_address: vector, @@ -83,15 +83,15 @@ module NFTs::CrossChainAirdrop { source_contract_address: SourceContractAddress { address: source_contract_address }, metadata: ERC721Metadata::new(token_id, name, token_uri), }; - Vector::push_back(&mut contract.claimed_source_token_ids, token_id); + vector::push_back(&mut contract.claimed_source_token_ids, token_id); Transfer::transfer(nft, recipient) } fun get_or_create_contract(oracle: &mut CrossChainAirdropOracle, source_contract_address: &vector): &mut PerContractAirdropInfo { let index = 0; // TODO: replace this with SparseSet so that the on-chain uniqueness check can be O(1) - while (index < Vector::length(&oracle.managed_contracts)) { - let info = Vector::borrow_mut(&mut oracle.managed_contracts, index); + while (index < vector::length(&oracle.managed_contracts)) { + let info = vector::borrow_mut(&mut oracle.managed_contracts, index); if (&info.source_contract_address.address == source_contract_address) { return info }; @@ -104,18 +104,18 @@ module NFTs::CrossChainAirdrop { fun create_contract(oracle: &mut CrossChainAirdropOracle, source_contract_address: &vector): &mut PerContractAirdropInfo { let info = PerContractAirdropInfo { source_contract_address: SourceContractAddress { address: *source_contract_address }, - claimed_source_token_ids: Vector::empty() + claimed_source_token_ids: vector::empty() }; - Vector::push_back(&mut oracle.managed_contracts, info); - let idx = Vector::length(&oracle.managed_contracts) - 1; - Vector::borrow_mut(&mut oracle.managed_contracts, idx) + vector::push_back(&mut oracle.managed_contracts, info); + let idx = vector::length(&oracle.managed_contracts) - 1; + vector::borrow_mut(&mut oracle.managed_contracts, idx) } fun is_token_claimed(contract: &PerContractAirdropInfo, source_token_id: &TokenID): bool { // TODO: replace this with SparseSet so that the on-chain uniqueness check can be O(1) let index = 0; - while (index < Vector::length(&contract.claimed_source_token_ids)) { - let claimed_id = Vector::borrow(&contract.claimed_source_token_ids, index); + while (index < vector::length(&contract.claimed_source_token_ids)) { + let claimed_id = vector::borrow(&contract.claimed_source_token_ids, index); if (claimed_id == source_token_id) { return true }; diff --git a/sui_programmability/examples/nfts/sources/DiscountCoupon.move b/sui_programmability/examples/nfts/sources/DiscountCoupon.move index 06df9b143e167..36b55d3e21385 100644 --- a/sui_programmability/examples/nfts/sources/DiscountCoupon.move +++ b/sui_programmability/examples/nfts/sources/DiscountCoupon.move @@ -31,7 +31,7 @@ module NFTs::DiscountCoupon { } /// Mint then transfer a new `DiscountCoupon` NFT, and top up recipient with some SUI. - public(script) fun mint_and_topup( + public entry fun mint_and_topup( coin: Coin::Coin, discount: u8, expiration: u64, @@ -50,7 +50,7 @@ module NFTs::DiscountCoupon { } /// Burn DiscountCoupon. - public(script) fun burn(nft: DiscountCoupon) { + public entry fun burn(nft: DiscountCoupon) { let DiscountCoupon { id, issuer: _, discount: _, expiration: _ } = nft; ID::delete(id); } @@ -58,7 +58,7 @@ module NFTs::DiscountCoupon { /// Transfer DiscountCoupon to issuer only. // TODO: Consider adding more valid recipients. // If we stick with issuer-as-receiver only, then `recipient` input won't be required). - public(script) fun transfer(coupon: DiscountCoupon, recipient: address) { + public entry fun transfer(coupon: DiscountCoupon, recipient: address) { assert!(&coupon.issuer == &recipient, EWrongRecipient); Transfer::transfer(coupon, recipient); } diff --git a/sui_programmability/examples/nfts/sources/Geniteam.move b/sui_programmability/examples/nfts/sources/Geniteam.move index 7490ad3f7ef19..c1f12ed714669 100644 --- a/sui_programmability/examples/nfts/sources/Geniteam.move +++ b/sui_programmability/examples/nfts/sources/Geniteam.move @@ -6,10 +6,10 @@ module NFTs::Geniteam { use Sui::Collection::{Self, Collection}; use Sui::ID::VersionedID; use Sui::TxContext::{Self, TxContext}; - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; use Sui::Transfer::{Self, ChildRef}; - use Std::ASCII::{Self, String}; - use Std::Vector; + use std::ascii::{Self, String}; + use std::vector; /// Trying to add more than 1 farm to a Player const ETooManyFarms: u64 = 1; @@ -94,7 +94,7 @@ module NFTs::Geniteam { // ============================ Entry functions ============================ /// Create a player and transfer it to the transaction sender - public(script) fun create_player( + public entry fun create_player( player_name: vector, ctx: &mut TxContext ) { // Create player simply and transfer to caller @@ -103,12 +103,12 @@ module NFTs::Geniteam { } /// Create a Farm and add it to the Player - public(script) fun create_farm( + public entry fun create_farm( player: &mut Player, farm_img_index: u64, farm_name: vector, total_monster_slots: u64, ctx: &mut TxContext ) { // We only allow one farm for now - assert!(Option::is_none(&player.owned_farm), ETooManyFarms); + assert!(option::is_none(&player.owned_farm), ETooManyFarms); let farm = new_farm(farm_name, farm_img_index, total_monster_slots, ctx); @@ -116,12 +116,12 @@ module NFTs::Geniteam { let child_ref = Transfer::transfer_to_object(farm, player); // Store the farm - Option::fill(&mut player.owned_farm, child_ref) + option::fill(&mut player.owned_farm, child_ref) } /// Create a Monster and add it to the Farm's collection of Monsters, which /// is unbounded - public(script) fun create_monster(_player: &mut Player, + public entry fun create_monster(_player: &mut Player, farm: &mut Farm, pet_monsters: &mut Collection, monster_name: vector, @@ -168,7 +168,7 @@ module NFTs::Geniteam { let farm_cosmetic = FarmCosmetic { id: TxContext::new_id(ctx), cosmetic_type, - display: ASCII::string(display) + display: ascii::string(display) }; // Add it to the player's inventory @@ -190,7 +190,7 @@ module NFTs::Geniteam { let monster_cosmetic = MonsterCosmetic { id: TxContext::new_id(ctx), cosmetic_type, - display: ASCII::string(display) + display: ascii::string(display) }; // Add it to the player's inventory @@ -229,8 +229,8 @@ module NFTs::Geniteam { self.hunger_level = hunger_level; self.affection_level = affection_level; self.buddy_level = buddy_level; - if (Vector::length(&display) != 0) { - self.display = ASCII::string(display); + if (vector::length(&display) != 0) { + self.display = ascii::string(display); } } @@ -257,10 +257,10 @@ module NFTs::Geniteam { // Assign by slot if (cosmetic_slot_id == 0) { // Store the cosmetic - Option::fill(&mut farm.applied_farm_cosmetic_0, child_ref) + option::fill(&mut farm.applied_farm_cosmetic_0, child_ref) } else { // Store the cosmetic - Option::fill(&mut farm.applied_farm_cosmetic_1, child_ref) + option::fill(&mut farm.applied_farm_cosmetic_1, child_ref) }; } @@ -279,10 +279,10 @@ module NFTs::Geniteam { // Assign by slot if (cosmetic_slot_id == 0) { // Store the cosmetic - Option::fill(&mut monster.applied_monster_cosmetic_0, child_ref) + option::fill(&mut monster.applied_monster_cosmetic_0, child_ref) } else { // Store the cosmetic - Option::fill(&mut monster.applied_monster_cosmetic_1, child_ref) + option::fill(&mut monster.applied_monster_cosmetic_1, child_ref) }; } @@ -303,12 +303,12 @@ module NFTs::Geniteam { let player = Player { id, - player_name: ASCII::string(player_name), + player_name: ascii::string(player_name), water_runes_count: 0, fire_runes_count: 0, wind_runes_count: 0, earth_runes_count: 0, - owned_farm: Option::none(), + owned_farm: option::none(), inventory: child_ref }; @@ -332,15 +332,15 @@ module NFTs::Geniteam { let farm = Farm { id, - farm_name: ASCII::string(farm_name), + farm_name: ascii::string(farm_name), total_monster_slots, farm_img_index, level: 0, current_xp: 0, occupied_monster_slots: 0, pet_monsters: child_ref, - applied_farm_cosmetic_0: Option::none(), - applied_farm_cosmetic_1: Option::none(), + applied_farm_cosmetic_0: option::none(), + applied_farm_cosmetic_1: option::none(), }; farm @@ -359,19 +359,19 @@ module NFTs::Geniteam { Monster { id: TxContext::new_id(ctx), - monster_name: ASCII::string(monster_name), + monster_name: ascii::string(monster_name), monster_img_index, breed, monster_affinity, - monster_description: ASCII::string(monster_description), + monster_description: ascii::string(monster_description), monster_level: 0, monster_xp: 0, hunger_level: 0, affection_level: 0, buddy_level: 0, - display: ASCII::string(display), - applied_monster_cosmetic_0: Option::none(), - applied_monster_cosmetic_1: Option::none(), + display: ascii::string(display), + applied_monster_cosmetic_0: option::none(), + applied_monster_cosmetic_1: option::none(), } } } diff --git a/sui_programmability/examples/nfts/sources/Marketplace.move b/sui_programmability/examples/nfts/sources/Marketplace.move index 89c3b7d58c052..d7362c8e838dd 100644 --- a/sui_programmability/examples/nfts/sources/Marketplace.move +++ b/sui_programmability/examples/nfts/sources/Marketplace.move @@ -28,7 +28,7 @@ module NFTs::Marketplace { } /// Create a new shared Marketplace. - public(script) fun create(ctx: &mut TxContext) { + public entry fun create(ctx: &mut TxContext) { let id = TxContext::new_id(ctx); let objects = Bag::new(ctx); let (id, objects) = Bag::transfer_to_object_id(objects, id); @@ -40,7 +40,7 @@ module NFTs::Marketplace { } /// List an item at the Marketplace. - public(script) fun list( + public entry fun list( _marketplace: &Marketplace, objects: &mut Bag, item: T, @@ -73,7 +73,7 @@ module NFTs::Marketplace { } /// Call [`delist`] and transfer item to the sender. - public(script) fun delist_and_take( + public entry fun delist_and_take( _marketplace: &Marketplace, objects: &mut Bag, listing: Listing, @@ -101,7 +101,7 @@ module NFTs::Marketplace { } /// Call [`buy`] and transfer item to the sender. - public(script) fun buy_and_take( + public entry fun buy_and_take( _marketplace: &Marketplace, listing: Listing, objects: &mut Bag, @@ -144,7 +144,7 @@ module NFTs::MarketplaceTests { const BUYER: address = @0x00B; /// Create a shared [`Marketplace`]. - public(script) fun create_marketplace(scenario: &mut Scenario) { + public entry fun create_marketplace(scenario: &mut Scenario) { TestScenario::next_tx(scenario, &ADMIN); Marketplace::create(TestScenario::ctx(scenario)); } @@ -164,7 +164,7 @@ module NFTs::MarketplaceTests { } // SELLER lists Kitty at the Marketplace for 100 SUI. - public(script) fun list_kitty(scenario: &mut Scenario) { + public entry fun list_kitty(scenario: &mut Scenario) { TestScenario::next_tx(scenario, &SELLER); let mkp_wrapper = TestScenario::take_shared(scenario); let mkp = TestScenario::borrow_mut(&mut mkp_wrapper); @@ -177,7 +177,7 @@ module NFTs::MarketplaceTests { } #[test] - public(script) fun list_and_delist() { + public entry fun list_and_delist() { let scenario = &mut TestScenario::begin(&ADMIN); create_marketplace(scenario); @@ -204,7 +204,7 @@ module NFTs::MarketplaceTests { #[test] #[expected_failure(abort_code = 1)] - public(script) fun fail_to_delist() { + public entry fun fail_to_delist() { let scenario = &mut TestScenario::begin(&ADMIN); create_marketplace(scenario); @@ -230,7 +230,7 @@ module NFTs::MarketplaceTests { } #[test] - public(script) fun buy_kitty() { + public entry fun buy_kitty() { let scenario = &mut TestScenario::begin(&ADMIN); create_marketplace(scenario); @@ -262,7 +262,7 @@ module NFTs::MarketplaceTests { #[test] #[expected_failure(abort_code = 0)] - public(script) fun fail_to_buy() { + public entry fun fail_to_buy() { let scenario = &mut TestScenario::begin(&ADMIN); create_marketplace(scenario); diff --git a/sui_programmability/examples/nfts/sources/SharedAuction.move b/sui_programmability/examples/nfts/sources/SharedAuction.move index faa521b89ab49..6f3603b1aa53e 100644 --- a/sui_programmability/examples/nfts/sources/SharedAuction.move +++ b/sui_programmability/examples/nfts/sources/SharedAuction.move @@ -41,7 +41,7 @@ module NFTs::SharedAuction { /// Creates an auction. This is executed by the owner of the asset /// to be auctioned. - public(script) fun create_auction(to_sell: T, ctx: &mut TxContext) { + public entry fun create_auction(to_sell: T, ctx: &mut TxContext) { let auction = AuctionLib::create_auction(TxContext::new_id(ctx), to_sell, ctx); AuctionLib::share_object(auction); } @@ -50,7 +50,7 @@ module NFTs::SharedAuction { /// change of the auction state (if bid was high enough) or return /// of the funds (if the bid was too low). This is executed by a /// bidder. - public(script) fun bid( + public entry fun bid( coin: Coin, auction: &mut Auction, ctx: &mut TxContext ) { AuctionLib::update_auction( @@ -65,7 +65,7 @@ module NFTs::SharedAuction { /// bidder or back to the original owner if no bids have been /// placed. This is executed by the owner of the asset to be /// auctioned. - public(script) fun end_auction( + public entry fun end_auction( auction: &mut Auction, ctx: &mut TxContext ) { let owner = AuctionLib::auction_owner(auction); diff --git a/sui_programmability/examples/nfts/tests/AuctionTests.move b/sui_programmability/examples/nfts/tests/AuctionTests.move index 93864ba9234e8..2d8e9941acd5d 100644 --- a/sui_programmability/examples/nfts/tests/AuctionTests.move +++ b/sui_programmability/examples/nfts/tests/AuctionTests.move @@ -3,7 +3,7 @@ #[test_only] module NFTs::AuctionTests { - use Std::Vector; + use std::vector; use Sui::Coin::{Self, Coin}; use Sui::SUI::SUI; @@ -27,15 +27,15 @@ module NFTs::AuctionTests { // be available in Sui genesis state (e.g., mints and distributes // coins to users). fun init(ctx: &mut TxContext, bidders: vector
) { - while (!Vector::is_empty(&bidders)) { - let bidder = Vector::pop_back(&mut bidders); + while (!vector::is_empty(&bidders)) { + let bidder = vector::pop_back(&mut bidders); let coin = Coin::mint_for_testing(100, ctx); Coin::transfer(coin, bidder); }; } #[test] - public(script) fun simple_auction_test() { + public entry fun simple_auction_test() { let auctioneer = @0xABBA; let owner = @0xACE; let bidder1 = @0xFACE; @@ -44,9 +44,9 @@ module NFTs::AuctionTests { let scenario = &mut TestScenario::begin(&auctioneer); { - let bidders = Vector::empty(); - Vector::push_back(&mut bidders, bidder1); - Vector::push_back(&mut bidders, bidder2); + let bidders = vector::empty(); + vector::push_back(&mut bidders, bidder1); + vector::push_back(&mut bidders, bidder2); init(TestScenario::ctx(scenario), bidders); }; diff --git a/sui_programmability/examples/nfts/tests/ChatTests.move b/sui_programmability/examples/nfts/tests/ChatTests.move index 18df57ab9255f..f3abab33bd5c9 100644 --- a/sui_programmability/examples/nfts/tests/ChatTests.move +++ b/sui_programmability/examples/nfts/tests/ChatTests.move @@ -4,7 +4,7 @@ #[test_only] module NFTs::ChatTests { use NFTs::Chat::{Self, Chat}; - use Std::ASCII::Self; + use std::ascii::Self; use Sui::TestScenario::Self; const USER1_ADDRESS: address = @0xA001; @@ -12,7 +12,7 @@ module NFTs::ChatTests { const HELLO: vector = vector[72, 101, 108, 108, 111]; // "Hello" in ASCII. #[test] - public(script) fun test_chat() { + public entry fun test_chat() { let scenario = &mut TestScenario::begin(&USER1_ADDRESS); { Chat::post( @@ -27,7 +27,7 @@ module NFTs::ChatTests { { assert!(TestScenario::can_take_owned(scenario), 0); let chat = TestScenario::take_owned(scenario); // if can remove, object exists - assert!(Chat::text(&chat) == ASCII::string(HELLO), 0); + assert!(Chat::text(&chat) == ascii::string(HELLO), 0); TestScenario::return_owned(scenario, chat); } } diff --git a/sui_programmability/examples/nfts/tests/CrossChainAirdropTests.move b/sui_programmability/examples/nfts/tests/CrossChainAirdropTests.move index 6fbe5558bf3ce..374202ebecda4 100644 --- a/sui_programmability/examples/nfts/tests/CrossChainAirdropTests.move +++ b/sui_programmability/examples/nfts/tests/CrossChainAirdropTests.move @@ -25,7 +25,7 @@ module NFTs::CrossChainAirdropTests { } #[test] - public(script) fun test_claim_airdrop() { + public entry fun test_claim_airdrop() { let (scenario, oracle_address) = init(); // claim a token @@ -37,7 +37,7 @@ module NFTs::CrossChainAirdropTests { #[test] #[expected_failure(abort_code = 0)] - public(script) fun test_double_claim() { + public entry fun test_double_claim() { let (scenario, oracle_address) = init(); // claim a token @@ -47,7 +47,7 @@ module NFTs::CrossChainAirdropTests { claim_token(&mut scenario, &oracle_address, SOURCE_TOKEN_ID); } - public(script) fun init(): (Scenario, address) { + public entry fun init(): (Scenario, address) { let scenario = TestScenario::begin(&ORACLE_ADDRESS); { let ctx = TestScenario::ctx(&mut scenario); @@ -56,7 +56,7 @@ module NFTs::CrossChainAirdropTests { (scenario, ORACLE_ADDRESS) } - public(script) fun claim_token(scenario: &mut Scenario, oracle_address: &address, token_id: u64) { + public entry fun claim_token(scenario: &mut Scenario, oracle_address: &address, token_id: u64) { TestScenario::next_tx(scenario, oracle_address); { let oracle = TestScenario::take_owned(scenario); @@ -74,7 +74,7 @@ module NFTs::CrossChainAirdropTests { }; } - public(script) fun owns_object(scenario: &mut Scenario, owner: &address): bool{ + public entry fun owns_object(scenario: &mut Scenario, owner: &address): bool{ // Verify the token has been transfer to the recipient TestScenario::next_tx(scenario, owner); TestScenario::can_take_owned(scenario) diff --git a/sui_programmability/examples/nfts/tests/DiscountCouponTests.move b/sui_programmability/examples/nfts/tests/DiscountCouponTests.move index d3f87475f7c7a..43e297dc93cb3 100644 --- a/sui_programmability/examples/nfts/tests/DiscountCouponTests.move +++ b/sui_programmability/examples/nfts/tests/DiscountCouponTests.move @@ -25,7 +25,7 @@ module NFTs::DiscountCouponTests { } #[test] - public(script) fun test_mint_then_transfer() { + public entry fun test_mint_then_transfer() { let scenario = &mut TestScenario::begin(&ISSUER_ADDRESS); { init(TestScenario::ctx(scenario)); diff --git a/sui_programmability/examples/nfts/tests/SharedAuctionTests.move b/sui_programmability/examples/nfts/tests/SharedAuctionTests.move index e186c868d58fd..1c44a0d53c9e8 100644 --- a/sui_programmability/examples/nfts/tests/SharedAuctionTests.move +++ b/sui_programmability/examples/nfts/tests/SharedAuctionTests.move @@ -3,7 +3,7 @@ #[test_only] module NFTs::SharedAuctionTests { - use Std::Vector; + use std::vector; use Sui::Coin::{Self, Coin}; use Sui::SUI::SUI; @@ -31,15 +31,15 @@ module NFTs::SharedAuctionTests { // be available in Sui genesis state (e.g., mints and distributes // coins to users). fun init(ctx: &mut TxContext, bidders: vector
) { - while (!Vector::is_empty(&bidders)) { - let bidder = Vector::pop_back(&mut bidders); + while (!vector::is_empty(&bidders)) { + let bidder = vector::pop_back(&mut bidders); let coin = Coin::mint_for_testing(COIN_VALUE, ctx); Coin::transfer(coin, bidder); }; } #[test] - public(script) fun simple_auction_test() { + public entry fun simple_auction_test() { let admin = @0xABBA; // needed only to initialize "state of the world" let owner = @0xACE; let bidder1 = @0xFACE; @@ -48,9 +48,9 @@ module NFTs::SharedAuctionTests { let scenario = &mut TestScenario::begin(&admin); { - let bidders = Vector::empty(); - Vector::push_back(&mut bidders, bidder1); - Vector::push_back(&mut bidders, bidder2); + let bidders = vector::empty(); + vector::push_back(&mut bidders, bidder1); + vector::push_back(&mut bidders, bidder2); init(TestScenario::ctx(scenario), bidders); }; diff --git a/sui_programmability/examples/objects_tutorial/sources/ColorObject.move b/sui_programmability/examples/objects_tutorial/sources/ColorObject.move index 15b82350f6e91..c2557992bd3f1 100644 --- a/sui_programmability/examples/objects_tutorial/sources/ColorObject.move +++ b/sui_programmability/examples/objects_tutorial/sources/ColorObject.move @@ -24,7 +24,7 @@ module Tutorial::ColorObject { } } - public(script) fun create(red: u8, green: u8, blue: u8, ctx: &mut TxContext) { + public entry fun create(red: u8, green: u8, blue: u8, ctx: &mut TxContext) { let color_object = new(red, green, blue, ctx); Transfer::transfer(color_object, TxContext::sender(ctx)) } @@ -36,33 +36,33 @@ module Tutorial::ColorObject { // == Functions covered in Chapter 2 == /// Copies the values of `from_object` into `into_object`. - public(script) fun copy_into(from_object: &ColorObject, into_object: &mut ColorObject) { + public entry fun copy_into(from_object: &ColorObject, into_object: &mut ColorObject) { into_object.red = from_object.red; into_object.green = from_object.green; into_object.blue = from_object.blue; } - public(script) fun delete(object: ColorObject) { + public entry fun delete(object: ColorObject) { let ColorObject { id, red: _, green: _, blue: _ } = object; ID::delete(id); } - public(script) fun transfer(object: ColorObject, recipient: address) { + public entry fun transfer(object: ColorObject, recipient: address) { Transfer::transfer(object, recipient) } // == Functions covered in Chapter 3 == - public(script) fun freeze_object(object: ColorObject) { + public entry fun freeze_object(object: ColorObject) { Transfer::freeze_object(object) } - public(script) fun create_immutable(red: u8, green: u8, blue: u8, ctx: &mut TxContext) { + public entry fun create_immutable(red: u8, green: u8, blue: u8, ctx: &mut TxContext) { let color_object = new(red, green, blue, ctx); Transfer::freeze_object(color_object) } - public(script) fun update( + public entry fun update( object: &mut ColorObject, red: u8, green: u8, blue: u8, ) { @@ -81,7 +81,7 @@ module Tutorial::ColorObjectTests { // == Tests covered in Chapter 1 == #[test] - public(script) fun test_create() { + public entry fun test_create() { let owner = @0x1; // Create a ColorObject and transfer it to @owner. let scenario = &mut TestScenario::begin(&owner); @@ -109,7 +109,7 @@ module Tutorial::ColorObjectTests { // == Tests covered in Chapter 2 == #[test] - public(script) fun test_copy_into() { + public entry fun test_copy_into() { let owner = @0x1; let scenario = &mut TestScenario::begin(&owner); // Create two ColorObjects owned by `owner`, and obtain their IDs. @@ -142,7 +142,7 @@ module Tutorial::ColorObjectTests { } #[test] - public(script) fun test_delete() { + public entry fun test_delete() { let owner = @0x1; // Create a ColorObject and transfer it to @owner. let scenario = &mut TestScenario::begin(&owner); @@ -164,7 +164,7 @@ module Tutorial::ColorObjectTests { } #[test] - public(script) fun test_transfer() { + public entry fun test_transfer() { let owner = @0x1; // Create a ColorObject and transfer it to @owner. let scenario = &mut TestScenario::begin(&owner); @@ -194,7 +194,7 @@ module Tutorial::ColorObjectTests { // == Tests covered in Chapter 3 == #[test] - public(script) fun test_immutable() { + public entry fun test_immutable() { let sender1 = @0x1; let scenario = &mut TestScenario::begin(&sender1); { diff --git a/sui_programmability/examples/objects_tutorial/sources/SimpleWarrior.move b/sui_programmability/examples/objects_tutorial/sources/SimpleWarrior.move index dfd9125fb2d9e..114cffe432f28 100644 --- a/sui_programmability/examples/objects_tutorial/sources/SimpleWarrior.move +++ b/sui_programmability/examples/objects_tutorial/sources/SimpleWarrior.move @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 module Tutorial::SimpleWarrior { - use Std::Option::{Self, Option}; + use std::option::{Self, Option}; use Sui::ID::VersionedID; use Sui::Transfer; @@ -24,7 +24,7 @@ module Tutorial::SimpleWarrior { shield: Option, } - public(script) fun create_sword(strength: u8, ctx: &mut TxContext) { + public entry fun create_sword(strength: u8, ctx: &mut TxContext) { let sword = Sword { id: TxContext::new_id(ctx), strength, @@ -32,7 +32,7 @@ module Tutorial::SimpleWarrior { Transfer::transfer(sword, TxContext::sender(ctx)) } - public(script) fun create_shield(armor: u8, ctx: &mut TxContext) { + public entry fun create_shield(armor: u8, ctx: &mut TxContext) { let shield = Shield { id: TxContext::new_id(ctx), armor, @@ -40,28 +40,28 @@ module Tutorial::SimpleWarrior { Transfer::transfer(shield, TxContext::sender(ctx)) } - public(script) fun create_warrior(ctx: &mut TxContext) { + public entry fun create_warrior(ctx: &mut TxContext) { let warrior = SimpleWarrior { id: TxContext::new_id(ctx), - sword: Option::none(), - shield: Option::none(), + sword: option::none(), + shield: option::none(), }; Transfer::transfer(warrior, TxContext::sender(ctx)) } - public(script) fun equip_sword(warrior: &mut SimpleWarrior, sword: Sword, ctx: &mut TxContext) { - if (Option::is_some(&warrior.sword)) { - let old_sword = Option::extract(&mut warrior.sword); + public entry fun equip_sword(warrior: &mut SimpleWarrior, sword: Sword, ctx: &mut TxContext) { + if (option::is_some(&warrior.sword)) { + let old_sword = option::extract(&mut warrior.sword); Transfer::transfer(old_sword, TxContext::sender(ctx)); }; - Option::fill(&mut warrior.sword, sword); + option::fill(&mut warrior.sword, sword); } - public(script) fun equip_shield(warrior: &mut SimpleWarrior, shield: Shield, ctx: &mut TxContext) { - if (Option::is_some(&warrior.shield)) { - let old_shield = Option::extract(&mut warrior.shield); + public entry fun equip_shield(warrior: &mut SimpleWarrior, shield: Shield, ctx: &mut TxContext) { + if (option::is_some(&warrior.shield)) { + let old_shield = option::extract(&mut warrior.shield); Transfer::transfer(old_shield, TxContext::sender(ctx)); }; - Option::fill(&mut warrior.shield, shield); + option::fill(&mut warrior.shield, shield); } -} \ No newline at end of file +} diff --git a/sui_programmability/examples/objects_tutorial/sources/TrustedSwap.move b/sui_programmability/examples/objects_tutorial/sources/TrustedSwap.move index 9c9e174070932..e1c375ff93cf0 100644 --- a/sui_programmability/examples/objects_tutorial/sources/TrustedSwap.move +++ b/sui_programmability/examples/objects_tutorial/sources/TrustedSwap.move @@ -24,7 +24,7 @@ module Tutorial::TrustedSwap { fee: Balance, } - public(script) fun create_object(scarcity: u8, style: u8, ctx: &mut TxContext) { + public entry fun create_object(scarcity: u8, style: u8, ctx: &mut TxContext) { let object = Object { id: TxContext::new_id(ctx), scarcity, @@ -33,13 +33,13 @@ module Tutorial::TrustedSwap { Transfer::transfer(object, TxContext::sender(ctx)) } - public(script) fun transfer_object(object: Object, ctx: &mut TxContext) { + public entry fun transfer_object(object: Object, ctx: &mut TxContext) { Transfer::transfer(object, TxContext::sender(ctx)) } /// Anyone owns an `Object` can request swapping their object. This object /// will be wrapped into `ObjectWrapper` and sent to `service_address`. - public(script) fun request_swap(object: Object, fee: Coin, service_address: address, ctx: &mut TxContext) { + public entry fun request_swap(object: Object, fee: Coin, service_address: address, ctx: &mut TxContext) { assert!(Coin::value(&fee) >= MIN_FEE, 0); let wrapper = ObjectWrapper { id: TxContext::new_id(ctx), @@ -52,7 +52,7 @@ module Tutorial::TrustedSwap { /// When the admin has two swap requests with objects that are trade-able, /// the admin can execute the swap and send them back to the opposite owner. - public(script) fun execute_swap(wrapper1: ObjectWrapper, wrapper2: ObjectWrapper, ctx: &mut TxContext) { + public entry fun execute_swap(wrapper1: ObjectWrapper, wrapper2: ObjectWrapper, ctx: &mut TxContext) { // Only swap if their scarcity is the same and style is different. assert!(wrapper1.to_swap.scarcity == wrapper2.to_swap.scarcity, 0); assert!(wrapper1.to_swap.style != wrapper2.to_swap.style, 0); diff --git a/sui_programmability/examples/regulated_coin/sources/RegulatedCoin.move b/sui_programmability/examples/regulated_coin/sources/RegulatedCoin.move index 19813fd75279d..a7d22420e8b4b 100644 --- a/sui_programmability/examples/regulated_coin/sources/RegulatedCoin.move +++ b/sui_programmability/examples/regulated_coin/sources/RegulatedCoin.move @@ -96,7 +96,7 @@ module ABC::ABC { use Sui::Coin::{Self, Coin, TreasuryCap}; use Sui::ID::{Self, VersionedID}; use Sui::Transfer; - use Std::Vector; + use std::vector; /// The ticker of ABC regulated token struct ABC has drop {} @@ -134,7 +134,7 @@ module ABC::ABC { Transfer::share_object(Registry { id: TxContext::new_id(ctx), - banned: Vector::empty(), + banned: vector::empty(), swapped_amount: 0, }); } @@ -155,26 +155,26 @@ module ABC::ABC { /// Create an empty `RCoin` instance for account `for`. TreasuryCap is passed for /// authentification purposes - only admin can create new accounts. - public(script) fun create(_: &TreasuryCap, for: address, ctx: &mut TxContext) { + public entry fun create(_: &TreasuryCap, for: address, ctx: &mut TxContext) { Transfer::transfer(zero(for, ctx), for) } /// Mint more ABC. Requires TreasuryCap for authorization, so can only be done by admins. - public(script) fun mint(treasury: &mut TreasuryCap, owned: &mut RCoin, value: u64, _: &mut TxContext) { + public entry fun mint(treasury: &mut TreasuryCap, owned: &mut RCoin, value: u64, _: &mut TxContext) { Balance::join(borrow_mut(owned), Coin::mint_balance(value, treasury)) } /// Burn `value` amount of `RCoin`. Requires TreasuryCap for authorization, so can only be done by admins. /// /// TODO: Make TreasuryCap a part of Balance module instead of Coin. - public(script) fun burn(treasury: &mut TreasuryCap, owned: &mut RCoin, value: u64, ctx: &mut TxContext) { + public entry fun burn(treasury: &mut TreasuryCap, owned: &mut RCoin, value: u64, ctx: &mut TxContext) { Coin::burn(Coin::withdraw(borrow_mut(owned), value, ctx), treasury); } /// Ban some address and forbid making any transactions from or to this address. /// Only owner of the TreasuryCap can perform this action. - public(script) fun ban(_cap: &TreasuryCap, registry: &mut Registry, to_ban: address, _: &mut TxContext) { - Vector::push_back(&mut registry.banned, to_ban) + public entry fun ban(_cap: &TreasuryCap, registry: &mut Registry, to_ban: address, _: &mut TxContext) { + vector::push_back(&mut registry.banned, to_ban) } // === Public: Regulated transfers === @@ -183,12 +183,12 @@ module ABC::ABC { /// `to` account for being accepted later. /// Fails if sender is not an creator of the `RegulatedCoin` or if any of the parties is in /// the ban list in Registry. - public(script) fun transfer(r: &Registry, coin: &mut RCoin, value: u64, to: address, ctx: &mut TxContext) { + public entry fun transfer(r: &Registry, coin: &mut RCoin, value: u64, to: address, ctx: &mut TxContext) { let sender = TxContext::sender(ctx); assert!(RCoin::creator(coin) == sender, ENotOwner); - assert!(Vector::contains(&r.banned, &to) == false, EAddressBanned); - assert!(Vector::contains(&r.banned, &sender) == false, EAddressBanned); + assert!(vector::contains(&r.banned, &to) == false, EAddressBanned); + assert!(vector::contains(&r.banned, &sender) == false, EAddressBanned); Transfer::transfer(Transfer { to, @@ -202,11 +202,11 @@ module ABC::ABC { /// Fails if: /// 1. the `RegulatedCoin.creator` does not match `Transfer.to`; /// 2. the address of the creator/recipient is banned; - public(script) fun accept_transfer(r: &Registry, coin: &mut RCoin, transfer: Transfer, _: &mut TxContext) { + public entry fun accept_transfer(r: &Registry, coin: &mut RCoin, transfer: Transfer, _: &mut TxContext) { let Transfer { id, balance, to } = transfer; assert!(RCoin::creator(coin) == to, ENotOwner); - assert!(Vector::contains(&r.banned, &to) == false, EAddressBanned); + assert!(vector::contains(&r.banned, &to) == false, EAddressBanned); Balance::join(borrow_mut(coin), balance); ID::delete(id) @@ -220,11 +220,11 @@ module ABC::ABC { /// Fails if: /// 1. `RegulatedCoin.creator` was banned; /// 2. `RegulatedCoin` is not owned by the tx sender; - public(script) fun take(r: &mut Registry, coin: &mut RCoin, value: u64, ctx: &mut TxContext) { + public entry fun take(r: &mut Registry, coin: &mut RCoin, value: u64, ctx: &mut TxContext) { let sender = TxContext::sender(ctx); assert!(RCoin::creator(coin) == sender, ENotOwner); - assert!(Vector::contains(&r.banned, &sender) == false, EAddressBanned); + assert!(vector::contains(&r.banned, &sender) == false, EAddressBanned); // Update swapped amount for Registry to keep track of non-regulated amounts. r.swapped_amount = r.swapped_amount + value; @@ -237,12 +237,12 @@ module ABC::ABC { /// Fails if: /// 1. `RegulatedCoin.creator` was banned; /// 2. `RegulatedCoin` is not owned by the tx sender; - public(script) fun put_back(r: &mut Registry, rc_coin: &mut RCoin, coin: Coin, ctx: &mut TxContext) { + public entry fun put_back(r: &mut Registry, rc_coin: &mut RCoin, coin: Coin, ctx: &mut TxContext) { let balance = Coin::into_balance(coin); let sender = TxContext::sender(ctx); assert!(RCoin::creator(rc_coin) == sender, ENotOwner); - assert!(Vector::contains(&r.banned, &sender) == false, EAddressBanned); + assert!(vector::contains(&r.banned, &sender) == false, EAddressBanned); // Update swapped amount as in `swap_regulated`. r.swapped_amount = r.swapped_amount - Balance::value(&balance); @@ -291,29 +291,29 @@ module ABC::Tests { // === Test handlers; this trick helps reusing scenarios == - #[test] public(script) fun test_minting() { test_minting_(&mut scenario()) } - #[test] public(script) fun test_creation() { test_creation_(&mut scenario()) } - #[test] public(script) fun test_transfer() { test_transfer_(&mut scenario()) } - #[test] public(script) fun test_burn() { test_burn_(&mut scenario()) } - #[test] public(script) fun test_take() { test_take_(&mut scenario()) } - #[test] public(script) fun test_put_back() { test_put_back_(&mut scenario()) } - #[test] public(script) fun test_ban() { test_ban_(&mut scenario()) } + #[test] public entry fun test_minting() { test_minting_(&mut scenario()) } + #[test] public entry fun test_creation() { test_creation_(&mut scenario()) } + #[test] public entry fun test_transfer() { test_transfer_(&mut scenario()) } + #[test] public entry fun test_burn() { test_burn_(&mut scenario()) } + #[test] public entry fun test_take() { test_take_(&mut scenario()) } + #[test] public entry fun test_put_back() { test_put_back_(&mut scenario()) } + #[test] public entry fun test_ban() { test_ban_(&mut scenario()) } #[test] #[expected_failure(abort_code = 2)] - public(script) fun test_address_banned_fail() { + public entry fun test_address_banned_fail() { test_address_banned_fail_(&mut scenario()) } #[test] #[expected_failure(abort_code = 2)] - public(script) fun test_different_account_fail() { + public entry fun test_different_account_fail() { test_different_account_fail_(&mut scenario()) } #[test] #[expected_failure(abort_code = 1)] - public(script) fun test_not_owned_balance_fail() { + public entry fun test_not_owned_balance_fail() { test_not_owned_balance_fail_(&mut scenario()) } @@ -323,7 +323,7 @@ module ABC::Tests { fun people(): (address, address, address) { (@0xABC, @0xE05, @0xFACE) } // Admin creates a regulated coin ABC and mints 1,000,000 of it. - public(script) fun test_minting_(test: &mut Scenario) { + public entry fun test_minting_(test: &mut Scenario) { let (admin, _, _) = people(); next_tx(test, &admin); { @@ -344,7 +344,7 @@ module ABC::Tests { } // Admin creates an empty balance for the `user1`. - public(script) fun test_creation_(test: &mut Scenario) { + public entry fun test_creation_(test: &mut Scenario) { let (admin, user1, _) = people(); test_minting_(test); @@ -369,7 +369,7 @@ module ABC::Tests { // Admin transfers 500,000 coins to `user1`. // User1 accepts the transfer and checks his balance. - public(script) fun test_transfer_(test: &mut Scenario) { + public entry fun test_transfer_(test: &mut Scenario) { let (admin, user1, _) = people(); test_creation_(test); @@ -401,7 +401,7 @@ module ABC::Tests { } // Admin burns 100,000 of `RCoin` - public(script) fun test_burn_(test: &mut Scenario) { + public entry fun test_burn_(test: &mut Scenario) { let (admin, _, _) = people(); test_transfer_(test); @@ -421,7 +421,7 @@ module ABC::Tests { // User1 cashes 100,000 of his `RegulatedCoin` into a `Coin`; // User1 sends Coin it to `user2`. - public(script) fun test_take_(test: &mut Scenario) { + public entry fun test_take_(test: &mut Scenario) { let (_, user1, user2) = people(); test_transfer_(test); @@ -448,7 +448,7 @@ module ABC::Tests { // User2 sends his `Coin` to `admin`. // Admin puts this coin to his RegulatedCoin balance. - public(script) fun test_put_back_(test: &mut Scenario) { + public entry fun test_put_back_(test: &mut Scenario) { let (admin, _, user2) = people(); test_take_(test); @@ -472,7 +472,7 @@ module ABC::Tests { } // Admin bans user1 by adding his address to the registry. - public(script) fun test_ban_(test: &mut Scenario) { + public entry fun test_ban_(test: &mut Scenario) { let (admin, user1, _) = people(); test_transfer_(test); @@ -490,7 +490,7 @@ module ABC::Tests { } // Banned User1 fails to create a Transfer. - public(script) fun test_address_banned_fail_(test: &mut Scenario) { + public entry fun test_address_banned_fail_(test: &mut Scenario) { let (_, user1, user2) = people(); test_ban_(test); @@ -508,7 +508,7 @@ module ABC::Tests { } // User1 is banned. Admin tries to make a Transfer to User1 and fails - user banned. - public(script) fun test_different_account_fail_(test: &mut Scenario) { + public entry fun test_different_account_fail_(test: &mut Scenario) { let (admin, user1, _) = people(); test_ban_(test); @@ -527,7 +527,7 @@ module ABC::Tests { // User1 is banned and transfers the whole balance to User2. // User2 tries to use this balance and fails. - public(script) fun test_not_owned_balance_fail_(test: &mut Scenario) { + public entry fun test_not_owned_balance_fail_(test: &mut Scenario) { let (_, user1, user2) = people(); test_ban_(test);