Skip to content

Commit

Permalink
[move][sui-adapter][sui-framework] Remove object versioning from the …
Browse files Browse the repository at this point in the history
…Move layer (MystenLabs#3624)

* [move][sui-adapter][sui-framework] Remvoe object versioning from the Move layer

- Removed version from object::Info
- Renamed object::Info to object::UID
- The version of objects is now tracked on the Rust side in MoveObject
  • Loading branch information
tnowacki authored Aug 3, 2022
1 parent 30c634e commit 7af627e
Show file tree
Hide file tree
Showing 164 changed files with 1,842 additions and 1,886 deletions.
3 changes: 2 additions & 1 deletion crates/sui-adapter-transactional-tests/tests/call/simple.exp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ written: object(104)

task 3 'view-object'. lines 32-32:
Owner: Account Address ( A )
Contents: Test::M1::Object {info: sui::object::Info {id: sui::object::ID {bytes: fake(105)}, version: 1u64}, value: 0u64}
Version: 1
Contents: Test::M1::Object {id: sui::object::UID {id: sui::object::ID {bytes: fake(105)}}, value: 0u64}
6 changes: 3 additions & 3 deletions crates/sui-adapter-transactional-tests/tests/call/simple.move
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

//# publish
module Test::M1 {
use sui::object::{Self, Info};
use sui::object::{Self, UID};
use sui::tx_context::TxContext;
use sui::transfer;
use sui::coin::Coin;

struct Object has key, store {
info: Info,
id: UID,
value: u64,
}

Expand All @@ -21,7 +21,7 @@ module Test::M1 {

public entry fun create(value: u64, recipient: address, ctx: &mut TxContext) {
transfer::transfer(
Object { info: object::new(ctx), value },
Object { id: object::new(ctx), value },
recipient
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
//# publish

module t3::o3 {
use sui::object::{Self, Info};
use sui::object::{Self, UID};
use sui::transfer;
use sui::tx_context::{Self, TxContext};

struct Obj3 has key, store {
info: Info,
id: UID,
}

public entry fun create(ctx: &mut TxContext) {
let o = Obj3 { info: object::new(ctx) };
let o = Obj3 { id: object::new(ctx) };
transfer::transfer(o, tx_context::sender(ctx))
}
}

//# publish

module t2::o2 {
use sui::object::{Self, Info};
use sui::object::{Self, UID};
use sui::transfer;
use sui::tx_context::{Self, TxContext};
use t3::o3::Obj3;

struct Obj2 has key, store {
info: Info,
id: UID,
}

public entry fun create_shared(child: Obj3, ctx: &mut TxContext) {
Expand All @@ -45,24 +45,24 @@ module t2::o2 {
}

fun new(child: Obj3, ctx: &mut TxContext): Obj2 {
let info = object::new(ctx);
transfer::transfer_to_object_id(child, &info);
Obj2 { info }
let id = object::new(ctx);
transfer::transfer_to_object_id(child, &id);
Obj2 { id }
}
}


//# publish

module t1::o1 {
use sui::object::{Self, Info};
use sui::object::{Self, UID};
use sui::transfer;
use sui::tx_context::{Self, TxContext};
use t2::o2::Obj2;
use t3::o3::Obj3;

struct Obj1 has key {
info: Info,
id: UID,
}

public entry fun create_shared(child: Obj2, ctx: &mut TxContext) {
Expand All @@ -75,9 +75,9 @@ module t1::o1 {
}

fun new(child: Obj2, ctx: &mut TxContext): Obj1 {
let info = object::new(ctx);
transfer::transfer_to_object_id(child, &info);
Obj1 { info }
let id = object::new(ctx);
transfer::transfer_to_object_id(child, &id);
Obj1 { id }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
module Test::M {
use sui::tx_context::{Self, TxContext};
struct Obj has key {
info: sui::object::Info,
id: sui::object::UID,
value: u64
}

public entry fun mint(ctx: &mut TxContext) {
sui::transfer::transfer(
Obj { info: sui::object::new(ctx), value: 0 },
Obj { id: sui::object::new(ctx), value: 0 },
tx_context::sender(ctx),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ written: object(102)

task 2 'view-object'. lines 25-25:
Owner: Account Address ( _ )
Contents: Test::M1::Object {info: sui::object::Info {id: sui::object::ID {bytes: fake(104)}, version: 1u64}, value: 42u64}
Version: 1
Contents: Test::M1::Object {id: sui::object::UID {id: sui::object::ID {bytes: fake(104)}}, value: 42u64}

task 3 'view-object'. lines 27-27:
103::M1
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

//# publish
module Test::M1 {
use sui::object::{Self, Info};
use sui::object::{Self, UID};
use sui::tx_context::{Self, TxContext};
use sui::transfer;

struct Object has key, store {
info: Info,
id: UID,
value: u64,
}

// initializer that should be executed upon publishing this module
fun init(ctx: &mut TxContext) {
let value = 42;
let singleton = Object { info: object::new(ctx), value };
let singleton = Object { id: object::new(ctx), value };
transfer::transfer(singleton, tx_context::sender(ctx))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
// initializer not valid due extra non-ctx param

module Test::M1 {
use sui::object::{Self, Info};
use sui::object::{Self, UID};
use sui::tx_context::{Self, TxContext};
use sui::transfer;

struct Object has key, store {
info: Info,
id: UID,
value: u64,
}

// value param invalid
fun init(ctx: &mut TxContext, value: u64) {
let singleton = Object { info: object::new(ctx), value };
let singleton = Object { id: object::new(ctx), value };
transfer::transfer(singleton, tx_context::sender(ctx))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
// initializer not valid due to public visibility

module Test::M1 {
use sui::object::{Self, Info};
use sui::object::{Self, UID};
use sui::tx_context::{Self, TxContext};
use sui::transfer;

struct Object has key, store {
info: Info,
id: UID,
value: u64,
}

// public initializer - should not be executed
public fun init(ctx: &mut TxContext) {
let value = 42;
let singleton = Object { info: object::new(ctx), value };
let singleton = Object { id: object::new(ctx), value };
transfer::transfer(singleton, tx_context::sender(ctx))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
// initializer not valid due to return value

module Test::M1 {
use sui::object::{Self, Info};
use sui::object::{Self, UID};
use sui::tx_context::{Self, TxContext};
use sui::transfer;

struct Object has key, store {
info: Info,
id: UID,
value: u64,
}

// initializer that should be executed upon publishing this module
fun init(ctx: &mut TxContext): u64 {
let value = 42;
let singleton = Object { info: object::new(ctx), value };
let singleton = Object { id: object::new(ctx), value };
transfer::transfer(singleton, tx_context::sender(ctx));
value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ written: object(106)

task 4 'view-object'. lines 43-43:
Owner: Shared
Contents: t2::o2::Obj2 {info: sui::object::Info {id: sui::object::ID {bytes: fake(107)}, version: 1u64}}
Version: 1
Contents: t2::o2::Obj2 {id: sui::object::UID {id: sui::object::ID {bytes: fake(107)}}}

task 5 'run'. lines 45-45:
Error: Transaction Effects Status: Entry Argument Type Error. Error for argument at index 0: Immutable and shared objects cannot be passed by-value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
//# publish

module t2::o2 {
use sui::object::{Self, Info};
use sui::object::{Self, UID};
use sui::transfer;
use sui::tx_context::TxContext;

struct Obj2 has key, store {
info: Info,
id: UID,
}

public entry fun create(ctx: &mut TxContext) {
let o = Obj2 { info: object::new(ctx) };
let o = Obj2 { id: object::new(ctx) };
transfer::share_object(o)
}

public entry fun consume_o2(o2: Obj2) {
let Obj2 { info } = o2;
object::delete(info);
let Obj2 { id } = o2;
object::delete(id);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,27 @@ A: object(100), B: object(101), C: object(102)

task 1 'view-object'. lines 8-8:
Owner: Account Address ( A )
Contents: sui::coin::Coin<sui::sui::SUI> {info: sui::object::Info {id: sui::object::ID {bytes: fake(100)}, version: 0u64}, balance: sui::balance::Balance<sui::sui::SUI> {value: 100000u64}}
Version: 0
Contents: sui::coin::Coin<sui::sui::SUI> {id: sui::object::UID {id: sui::object::ID {bytes: fake(100)}}, balance: sui::balance::Balance<sui::sui::SUI> {value: 100000u64}}

task 2 'run'. lines 10-10:
created: object(106)
written: object(100), object(105)

task 3 'view-object'. lines 12-12:
Owner: Account Address ( A )
Contents: sui::coin::Coin<sui::sui::SUI> {info: sui::object::Info {id: sui::object::ID {bytes: fake(100)}, version: 1u64}, balance: sui::balance::Balance<sui::sui::SUI> {value: 99990u64}}
Version: 1
Contents: sui::coin::Coin<sui::sui::SUI> {id: sui::object::UID {id: sui::object::ID {bytes: fake(100)}}, balance: sui::balance::Balance<sui::sui::SUI> {value: 99990u64}}

task 4 'view-object'. lines 14-14:
Owner: Account Address ( B )
Contents: sui::coin::Coin<sui::sui::SUI> {info: sui::object::Info {id: sui::object::ID {bytes: fake(106)}, version: 1u64}, balance: sui::balance::Balance<sui::sui::SUI> {value: 10u64}}
Version: 1
Contents: sui::coin::Coin<sui::sui::SUI> {id: sui::object::UID {id: sui::object::ID {bytes: fake(106)}}, balance: sui::balance::Balance<sui::sui::SUI> {value: 10u64}}

task 5 'run'. lines 16-16:
written: object(100), object(107)

task 6 'view-object'. lines 18-18:
Owner: Account Address ( C )
Contents: sui::coin::Coin<sui::sui::SUI> {info: sui::object::Info {id: sui::object::ID {bytes: fake(100)}, version: 2u64}, balance: sui::balance::Balance<sui::sui::SUI> {value: 99990u64}}
Version: 2
Contents: sui::coin::Coin<sui::sui::SUI> {id: sui::object::UID {id: sui::object::ID {bytes: fake(100)}}, balance: sui::balance::Balance<sui::sui::SUI> {value: 99990u64}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ written: object(104)

task 2 'view-object'. lines 10-10:
Owner: Account Address ( A )
Contents: sui::object_basics::Object {info: sui::object::Info {id: sui::object::ID {bytes: fake(105)}, version: 1u64}, value: 10u64}
Version: 1
Contents: sui::object_basics::Object {id: sui::object::UID {id: sui::object::ID {bytes: fake(105)}}, value: 10u64}

task 3 'run'. lines 12-12:
written: object(105), object(106)

task 4 'view-object'. lines 14-14:
Owner: Account Address ( B )
Contents: sui::object_basics::Object {info: sui::object::Info {id: sui::object::ID {bytes: fake(105)}, version: 2u64}, value: 10u64}
Version: 2
Contents: sui::object_basics::Object {id: sui::object::UID {id: sui::object::ID {bytes: fake(105)}}, value: 10u64}

task 5 'run'. lines 16-16:
created: object(108)
Expand Down
6 changes: 4 additions & 2 deletions crates/sui-adapter-transactional-tests/tests/sui/unwrap.exp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ written: object(103)

task 2 'view-object'. lines 11-11:
Owner: Account Address ( A )
Contents: sui::object_basics::Object {info: sui::object::Info {id: sui::object::ID {bytes: fake(104)}, version: 1u64}, value: 10u64}
Version: 1
Contents: sui::object_basics::Object {id: sui::object::UID {id: sui::object::ID {bytes: fake(104)}}, value: 10u64}

task 3 'run'. lines 13-13:
created: object(106)
Expand All @@ -22,4 +23,5 @@ deleted: object(106)

task 5 'view-object'. lines 17-17:
Owner: Account Address ( A )
Contents: sui::object_basics::Object {info: sui::object::Info {id: sui::object::ID {bytes: fake(104)}, version: 3u64}, value: 10u64}
Version: 2
Contents: sui::object_basics::Object {id: sui::object::UID {id: sui::object::ID {bytes: fake(104)}}, value: 10u64}
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,32 @@ written: object(106)

task 3 'view-object'. lines 33-33:
Owner: Account Address ( A )
Contents: test::m::S {info: sui::object::Info {id: sui::object::ID {bytes: fake(107)}, version: 1u64}}
Version: 1
Contents: test::m::S {id: sui::object::UID {id: sui::object::ID {bytes: fake(107)}}}

task 4 'transfer-object'. lines 35-35:
Error: Transaction Effects Status: Invalid Transfer Object Transaction. Possibly not address-owned or possibly does not have public transfer.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidTransferObject, source: None } }

task 5 'view-object'. lines 37-40:
Owner: Account Address ( A )
Contents: test::m::S {info: sui::object::Info {id: sui::object::ID {bytes: fake(107)}, version: 2u64}}
Version: 2
Contents: test::m::S {id: sui::object::UID {id: sui::object::ID {bytes: fake(107)}}}

task 6 'run'. lines 42-42:
created: object(110)
written: object(109)

task 7 'view-object'. lines 44-44:
Owner: Account Address ( A )
Contents: test::m::Cup<test::m::S> {info: sui::object::Info {id: sui::object::ID {bytes: fake(110)}, version: 1u64}}
Version: 1
Contents: test::m::Cup<test::m::S> {id: sui::object::UID {id: sui::object::ID {bytes: fake(110)}}}

task 8 'transfer-object'. lines 46-46:
Error: Transaction Effects Status: Invalid Transfer Object Transaction. Possibly not address-owned or possibly does not have public transfer.
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: InvalidTransferObject, source: None } }

task 9 'view-object'. lines 48-48:
Owner: Account Address ( A )
Contents: test::m::Cup<test::m::S> {info: sui::object::Info {id: sui::object::ID {bytes: fake(110)}, version: 2u64}}
Version: 2
Contents: test::m::Cup<test::m::S> {id: sui::object::UID {id: sui::object::ID {bytes: fake(110)}}}
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
module test::m {
use sui::transfer;
use sui::tx_context::{Self, TxContext};
use sui::object::{Self, Info};
use sui::object::{Self, UID};

struct S has key { info: Info }
struct Cup<phantom T> has key { info: Info }
struct S has key { id: UID }
struct Cup<phantom T> has key { id: UID }

public entry fun mint_s(ctx: &mut TxContext) {
let info = object::new(ctx);
transfer::transfer(S { info }, tx_context::sender(ctx))
let id = object::new(ctx);
transfer::transfer(S { id }, tx_context::sender(ctx))
}

public entry fun mint_cup<T>(ctx: &mut TxContext) {
let info = object::new(ctx);
transfer::transfer(Cup<T> { info }, tx_context::sender(ctx))
let id = object::new(ctx);
transfer::transfer(Cup<T> { id }, tx_context::sender(ctx))
}
}

Expand Down
Loading

0 comments on commit 7af627e

Please sign in to comment.