forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ts-sdk] Add tx.object.option for creatnig object options in transact… (
MystenLabs#20194) …ion builder ## Description Describe the changes or additions included in this PR. ## Test plan How did you test the new or updated feature? --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API:
- Loading branch information
1 parent
de2c7de
commit d5a23d7
Showing
21 changed files
with
632 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@mysten/sui': patch | ||
--- | ||
|
||
Add tx.object.option for creatnig object options in transaction builder |
12 changes: 6 additions & 6 deletions
12
crates/sui-core/src/unit_tests/data/entry_point_types/Move.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 0 | ||
version = 3 | ||
manifest_digest = "84B1ECECEB235E605B786F20F7F6441F45D0E087391F555801F49504C491BECE" | ||
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" | ||
|
||
dependencies = [ | ||
{ name = "Sui" }, | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
name = "MoveStdlib" | ||
id = "MoveStdlib" | ||
source = { local = "../../../../../sui-framework/packages/move-stdlib" } | ||
|
||
[[move.package]] | ||
name = "Sui" | ||
id = "Sui" | ||
source = { local = "../../../../../sui-framework/packages/sui-framework" } | ||
|
||
dependencies = [ | ||
{ name = "MoveStdlib" }, | ||
{ id = "MoveStdlib", name = "MoveStdlib" }, | ||
] | ||
|
||
[move.toolchain-version] | ||
compiler-version = "1.30.0" | ||
compiler-version = "1.38.0" | ||
edition = "2024.beta" | ||
flavor = "sui" |
12 changes: 6 additions & 6 deletions
12
crates/sui-core/src/unit_tests/data/entry_point_vector/Move.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 0 | ||
version = 3 | ||
manifest_digest = "78784529799C8284788E91AB0A8668CA7759418A3D6133C3ADE575F648524A1E" | ||
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" | ||
|
||
dependencies = [ | ||
{ name = "Sui" }, | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
name = "MoveStdlib" | ||
id = "MoveStdlib" | ||
source = { local = "../../../../../sui-framework/packages/move-stdlib" } | ||
|
||
[[move.package]] | ||
name = "Sui" | ||
id = "Sui" | ||
source = { local = "../../../../../sui-framework/packages/sui-framework" } | ||
|
||
dependencies = [ | ||
{ name = "MoveStdlib" }, | ||
{ id = "MoveStdlib", name = "MoveStdlib" }, | ||
] | ||
|
||
[move.toolchain-version] | ||
compiler-version = "1.30.0" | ||
compiler-version = "1.38.0" | ||
edition = "2024.beta" | ||
flavor = "sui" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 0 | ||
version = 3 | ||
manifest_digest = "AFCC8C08D078426D5FE98FB22E21578C4A7B9C1259C6EE53BEF2861BB801C976" | ||
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" | ||
|
||
dependencies = [ | ||
{ name = "Sui" }, | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
name = "MoveStdlib" | ||
id = "MoveStdlib" | ||
source = { local = "../../../../../../crates/sui-framework/packages/move-stdlib" } | ||
|
||
[[move.package]] | ||
name = "Sui" | ||
id = "Sui" | ||
source = { local = "../../../../../../crates/sui-framework/packages/sui-framework" } | ||
|
||
dependencies = [ | ||
{ name = "MoveStdlib" }, | ||
{ id = "MoveStdlib", name = "MoveStdlib" }, | ||
] | ||
|
||
[move.toolchain-version] | ||
compiler-version = "1.30.0" | ||
compiler-version = "1.38.0" | ||
edition = "2024.beta" | ||
flavor = "sui" |
50 changes: 29 additions & 21 deletions
50
sdk/typescript/test/e2e/data/coin_metadata/sources/coin_metadata.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module coin_metadata::test { | ||
use std::option; | ||
use sui::coin; | ||
use sui::transfer; | ||
use sui::url; | ||
module coin_metadata::test; | ||
|
||
public struct TEST has drop {} | ||
use sui::coin; | ||
use sui::url; | ||
|
||
fun init(witness: TEST, ctx: &mut TxContext) { | ||
let (mut treasury_cap, metadata) = coin::create_currency<TEST>( | ||
witness, | ||
2, | ||
b"TEST", | ||
b"Test Coin", | ||
b"Test coin metadata", | ||
option::some(url::new_unsafe_from_bytes(b"http://sui.io")), | ||
ctx | ||
); | ||
public struct TEST has drop {} | ||
|
||
coin::mint_and_transfer<TEST>(&mut treasury_cap, 5, tx_context::sender(ctx), ctx); | ||
coin::mint_and_transfer<TEST>(&mut treasury_cap, 6, tx_context::sender(ctx), ctx); | ||
fun init(witness: TEST, ctx: &mut TxContext) { | ||
let (mut treasury_cap, metadata) = coin::create_currency<TEST>( | ||
witness, | ||
2, | ||
b"TEST", | ||
b"Test Coin", | ||
b"Test coin metadata", | ||
option::some(url::new_unsafe_from_bytes(b"http://sui.io")), | ||
ctx, | ||
); | ||
|
||
transfer::public_share_object(metadata); | ||
transfer::public_share_object(treasury_cap) | ||
} | ||
coin::mint_and_transfer<TEST>( | ||
&mut treasury_cap, | ||
5, | ||
tx_context::sender(ctx), | ||
ctx, | ||
); | ||
coin::mint_and_transfer<TEST>( | ||
&mut treasury_cap, | ||
6, | ||
tx_context::sender(ctx), | ||
ctx, | ||
); | ||
|
||
transfer::public_share_object(metadata); | ||
transfer::public_share_object(treasury_cap) | ||
} |
97 changes: 48 additions & 49 deletions
97
sdk/typescript/test/e2e/data/demo-bear/sources/demo_bear.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,57 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module demo::demo_bear { | ||
use std::string::{String, utf8}; | ||
module demo::demo_bear; | ||
|
||
use sui::package; | ||
use sui::display; | ||
use std::string::{String, utf8}; | ||
use sui::display; | ||
use sui::package; | ||
|
||
/// our demo struct. | ||
public struct DemoBear has key, store { | ||
id: UID, | ||
name: String | ||
} | ||
/// our demo struct. | ||
public struct DemoBear has key, store { | ||
id: UID, | ||
name: String, | ||
} | ||
|
||
/// our OTW to create display. | ||
public struct DEMO_BEAR has drop {} | ||
|
||
// It's recommened to create Display using PTBs instead of | ||
// directly on the contracts. | ||
// We are only creating it here for demo purposes (one-step setup). | ||
fun init(otw: DEMO_BEAR, ctx: &mut TxContext){ | ||
let publisher = package::claim(otw, ctx); | ||
let keys = vector[ | ||
utf8(b"name"), | ||
utf8(b"image_url"), | ||
utf8(b"description"), | ||
]; | ||
|
||
|
||
let values = vector[ | ||
// Let's add a demo name for our `DemoBear` | ||
utf8(b"{name}"), | ||
// Adding a happy bear image. | ||
utf8(b"https://images.unsplash.com/photo-1589656966895-2f33e7653819?q=80&w=1000&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8cG9sYXIlMjBiZWFyfGVufDB8fDB8fHww"), | ||
// Description is static for all bears out there. | ||
utf8(b"The greatest figure for demos"), | ||
]; | ||
|
||
// Get a new `Display` object for the `Hero` type. | ||
let mut display = display::new_with_fields<DemoBear>( | ||
&publisher, keys, values, ctx | ||
); | ||
|
||
// Commit first version of `Display` to apply changes. | ||
display::update_version(&mut display); | ||
|
||
sui::transfer::public_transfer(display, ctx.sender()); | ||
sui::transfer::public_transfer(publisher, ctx.sender()) | ||
} | ||
/// our OTW to create display. | ||
public struct DEMO_BEAR has drop {} | ||
|
||
// It's recommened to create Display using PTBs instead of | ||
// directly on the contracts. | ||
// We are only creating it here for demo purposes (one-step setup). | ||
fun init(otw: DEMO_BEAR, ctx: &mut TxContext) { | ||
let publisher = package::claim(otw, ctx); | ||
let keys = vector[utf8(b"name"), utf8(b"image_url"), utf8(b"description")]; | ||
|
||
let values = vector[ | ||
// Let's add a demo name for our `DemoBear` | ||
utf8(b"{name}"), | ||
// Adding a happy bear image. | ||
utf8( | ||
b"https://images.unsplash.com/photo-1589656966895-2f33e7653819?q=80&w=1000&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8cG9sYXIlMjBiZWFyfGVufDB8fDB8fHww", | ||
), | ||
// Description is static for all bears out there. | ||
utf8(b"The greatest figure for demos"), | ||
]; | ||
|
||
// Get a new `Display` object for the `Hero` type. | ||
let mut display = display::new_with_fields<DemoBear>( | ||
&publisher, | ||
keys, | ||
values, | ||
ctx, | ||
); | ||
|
||
// Commit first version of `Display` to apply changes. | ||
display::update_version(&mut display); | ||
|
||
sui::transfer::public_transfer(display, ctx.sender()); | ||
sui::transfer::public_transfer(publisher, ctx.sender()) | ||
} | ||
|
||
public fun new(name: String, ctx: &mut TxContext): DemoBear { | ||
DemoBear { | ||
id: object::new(ctx), | ||
name: name | ||
} | ||
public fun new(name: String, ctx: &mut TxContext): DemoBear { | ||
DemoBear { | ||
id: object::new(ctx), | ||
name: name, | ||
} | ||
} |
Oops, something went wrong.