Skip to content

Commit 92fe654

Browse files
awelclongbowlu
authored andcommitted
[Move] Fixed test function calling entry functino and updated docs (MystenLabs#1653)
1 parent bfeb09b commit 92fe654

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

doc/src/build/move.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ In Sui, Move is used to define, create and manage programmable Sui
3737
imposes additional restrictions on the code that can be written in
3838
Move, effectively using a subset of Move (a.k.a. *Sui Move*), which
3939
makes certain parts of the original Move documentation not applicable
40-
to smart contract development in Sui (e.g., there is no concept of a
41-
[script](https://github.com/diem/move/blob/main/language/documentation/book/src/modules-and-scripts.md#scripts)
42-
in Sui Move). Consequently, it's best to simply follow this tutorial
40+
to smart contract development in Sui. Consequently, it's best to simply follow this tutorial
4341
and relevant Move documentation links provided in the tutorial.
4442

4543
Before we look at the Move code included with Sui, let's talk briefly
@@ -254,13 +252,10 @@ that it will do what it is intended to do.)
254252

255253
In general, an entry function, must satisfy the following properties:
256254

257-
- be public
255+
- have `public(script)` visibility modifier
258256
- have no return value
259-
- have parameters ordered as follows:
260-
- one or more Sui objects (or vectors of objects)
261-
- one or more primitive types (or vectors of such types)
262-
- a mutable reference to an instance of the `TxContext` struct
263-
defined in the [TxContext module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/TxContext.move)
257+
- have a mutable reference to an instance of the `TxContext` struct
258+
defined in the [TxContext module](https://github.com/MystenLabs/sui/tree/main/sui_programmability/framework/sources/TxContext.move) as the last parameter
264259

265260
More, concretely, the `transfer` function is public, has no return
266261
value, and has three parameters:
@@ -659,11 +654,13 @@ struct available for function definitions:
659654
660655
We can now build the module extended with the new functions but still
661656
have only one test defined. Let us change that by adding another test
662-
function:
657+
function. Note that this function needs to have `public(script)`
658+
visibility modifier to be able to call other functions with the same
659+
modifier, such as our entry function `sword_create`.
663660
664661
``` rust
665662
#[test]
666-
public fun test_sword_transactions() {
663+
public(script) fun test_sword_transactions() {
667664
use Sui::TestScenario;
668665
669666
let admin = @0xABBA;

sui_programmability/tutorial/sources/M1.move

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ module MyFirstPackage::M1 {
8787
}
8888

8989
#[test]
90-
public fun test_sword_transactions() {
90+
public(script) fun test_sword_transactions() {
9191
use Sui::TestScenario;
9292

9393
// create test addresses representing users

0 commit comments

Comments
 (0)