diff --git a/book/src/move-basics/ownership-and-scope.md b/book/src/move-basics/ownership-and-scope.md index e9b4a2d..f11c4b1 100644 --- a/book/src/move-basics/ownership-and-scope.md +++ b/book/src/move-basics/ownership-and-scope.md @@ -25,10 +25,15 @@ module book::ownership { let a = 1; // a is owned by the `owner` function } // a is dropped here + public fun other() { + let b = 2; // b is owned by the `other` function + } // b is dropped here + #[test] fun test_owner() { owner(); - // a is not valid here + other(); + // a & b is not valid here } } ``` diff --git a/book/src/programmability/module-initializer.md b/book/src/programmability/module-initializer.md index 75ee0d1..1ce6c2c 100644 --- a/book/src/programmability/module-initializer.md +++ b/book/src/programmability/module-initializer.md @@ -25,7 +25,7 @@ The function is called on publish, if it is present in the module and follows th - The function has to be named `init`, be private and have no return values. - Takes one or two arguments: [One Time Witness](./one-time-witness.md) (optional) and - [TxContext](./transaction-context.md). With `TxContext always being the last argument. + [TxContext](./transaction-context.md). With `TxContext` always being the last argument. ```move fun init(ctx: &mut TxContext) { /* ... */} diff --git a/book/src/programmability/publisher.md b/book/src/programmability/publisher.md index 750ea43..5bb8ad6 100644 --- a/book/src/programmability/publisher.md +++ b/book/src/programmability/publisher.md @@ -51,7 +51,7 @@ system configurations, it can also be used to manage the application's state. ``` However, Publisher misses some native properties of [Capabilities](./capability.md), such as type -safety and expressiveness. The signature for the `admin_function` is not very explicit, can be +safety and expressiveness. The signature for the `admin_action` is not very explicit, can be called by anyone else. And due to `Publisher` object being standard, there now is a risk of unauthorized access if the `from_module` check is not performed. So it's important to be cautious when using the `Publisher` object as an admin role. diff --git a/book/src/programmability/witness-pattern.md b/book/src/programmability/witness-pattern.md index dda13f9..30475eb 100644 --- a/book/src/programmability/witness-pattern.md +++ b/book/src/programmability/witness-pattern.md @@ -48,7 +48,7 @@ module book::witness_source { } ``` -The instance of the struct `W` is passed into the `new` function to create an `Instance`, thereby +The instance of the struct `W` is passed into the `new_instance` function to create an `Instance`, thereby proving that the module `book::witness_source` owns the type `W`. ## Instantiating a Generic Type diff --git a/packages/samples/sources/programmability/bcs.move b/packages/samples/sources/programmability/bcs.move index 4fe51dd..81565d8 100644 --- a/packages/samples/sources/programmability/bcs.move +++ b/packages/samples/sources/programmability/bcs.move @@ -25,7 +25,7 @@ use sui::bcs; let bool_bytes = bcs::to_bytes(&true); // 0x2a - just a single byte let u8_bytes = bcs::to_bytes(&42u8); -// 0x000000000000002a - 8 bytes +// 0x2a00000000000000 - 8 bytes let u64_bytes = bcs::to_bytes(&42u64); // address is a fixed sequence of 32 bytes // 0x0000000000000000000000000000000000000000000000000000000000000002 diff --git a/reference/src/variables.md b/reference/src/variables.md index 04ad0b4..12c8d51 100644 --- a/reference/src/variables.md +++ b/reference/src/variables.md @@ -203,7 +203,7 @@ x = 1; ### Multiple declarations with structs -`let` can also introduce more than one local at a time when destructuring (or matching against) a +`let` can also introduce more than one local variables at a time when destructuring (or matching against) a struct. In this form, the `let` creates a set of local variables that are initialized to the values of the fields from a struct. The syntax looks like this: @@ -226,7 +226,7 @@ public struct P(u64, u64) and ```move -let P(local1, local2) = T { f1: 1, f2: 2 }; +let P (local1, local2) = P ( 1, 2 ); // local1: u64 // local2: u64 ```