forked from MystenLabs/walrus-docs
-
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.
fix: add missing code and fix deps for Move example (MystenLabs#152)
- Loading branch information
Showing
7 changed files
with
491 additions
and
4 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,26 @@ | ||
# @generated by Move, please check-in and do not edit manually. | ||
|
||
[move] | ||
version = 3 | ||
manifest_digest = "FD53D9835EB22E1D70E3DA6E97D739428929736A8C7CE77484CA020632F50558" | ||
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" | ||
dependencies = [ | ||
{ id = "Sui", name = "Sui" }, | ||
] | ||
|
||
[[move.package]] | ||
id = "MoveStdlib" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "testnet-v1.35.0", subdir = "crates/sui-framework/packages/move-stdlib" } | ||
|
||
[[move.package]] | ||
id = "Sui" | ||
source = { git = "https://github.com/MystenLabs/sui.git", rev = "testnet-v1.35.0", subdir = "crates/sui-framework/packages/sui-framework" } | ||
|
||
dependencies = [ | ||
{ id = "MoveStdlib", name = "MoveStdlib" }, | ||
] | ||
|
||
[move.toolchain-version] | ||
compiler-version = "1.35.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "WAL" | ||
license = "Apache-2.0" | ||
authors = ["Mysten Labs <[email protected]>"] | ||
edition = "2024.beta" | ||
|
||
[dependencies] | ||
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "testnet-v1.35.0" } | ||
|
||
[addresses] | ||
wal = "0x0" |
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,52 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: wal | ||
module wal::wal; | ||
|
||
use sui::coin; | ||
|
||
/// The OTW for the `WAL` coin. | ||
public struct WAL has drop {} | ||
|
||
#[allow(lint(share_owned))] | ||
fun init(otw: WAL, ctx: &mut TxContext) { | ||
let (treasury_cap, coin_metadata) = coin::create_currency( | ||
otw, | ||
9, // decimals, | ||
b"WAL", // symbol, | ||
b"WAL", // name, | ||
b"WAL Token", // description, | ||
option::none(), // url (currently, empty) | ||
ctx, | ||
); | ||
|
||
transfer::public_transfer(treasury_cap, ctx.sender()); | ||
transfer::public_share_object(coin_metadata); | ||
} | ||
|
||
#[test_only] | ||
use sui::test_scenario as test; | ||
|
||
#[test] | ||
fun test_init() { | ||
let user = @0xa11ce; | ||
let mut test = test::begin(user); | ||
init(WAL {}, test.ctx()); | ||
test.next_tx(user); | ||
|
||
let treasury_cap = test.take_from_address<coin::TreasuryCap<WAL>>(user); | ||
assert!(treasury_cap.total_supply() == 0); | ||
test.return_to_sender(treasury_cap); | ||
|
||
let coin_metadata = test.take_shared<coin::CoinMetadata<WAL>>(); | ||
|
||
assert!(coin_metadata.get_decimals() == 9); | ||
assert!(coin_metadata.get_symbol() == b"WAL".to_ascii_string()); | ||
assert!(coin_metadata.get_name() == b"WAL".to_string()); | ||
assert!(coin_metadata.get_description() == b"WAL Token".to_string()); | ||
assert!(coin_metadata.get_icon_url() == option::none()); | ||
|
||
test::return_shared(coin_metadata); | ||
test.end(); | ||
} |
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
Oops, something went wrong.