Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing code and fix deps for Move example #152

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions contracts/wal/Move.lock
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"
11 changes: 11 additions & 0 deletions contracts/wal/Move.toml
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"
52 changes: 52 additions & 0 deletions contracts/wal/sources/wal.move
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();
}
1 change: 0 additions & 1 deletion contracts/walrus/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ edition = "2024.beta"
[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "testnet-v1.35.0" }
WAL = { local = "../wal" }
WAL_exchange = { local = "../wal_exchange" }

[addresses]
walrus = "0x0"
Loading