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

task5 task6 #2155

Merged
merged 9 commits into from
Dec 13, 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
21 changes: 21 additions & 0 deletions mover/fengfengxiong123/code/task2/mint_dao_faucet_mainnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
sui client call \
--package 0x2 \
--module coin \
--function mint_and_transfer \
--type-args 0xae412de9df987063117db968d17e8f4dfa16b92f5f9527e36af47af427070b83::dao::DAO \
--args \
0xe880375ea3d82755a9c387bf3fb705a9bbc5982afc5d16349773e162754a9b86 \
10000000000 \
0x2af6c1938280cf418ce388f62deffe9a56746d0887c9e6c031a4127016987e35 \
--gas-budget 5000000

sui client call \
--package 0x2 \
--module coin \
--function mint_and_transfer \
--type-args 0xae412de9df987063117db968d17e8f4dfa16b92f5f9527e36af47af427070b83::faucetcoin::FAUCETCOIN \
--args \
0x56d0bb3c37de365e23a2c56180601da49d8b23794b45119f4fbb4c64deb1825a \
7000000000 \
0x2af6c1938280cf418ce388f62deffe9a56746d0887c9e6c031a4127016987e35 \
--gas-budget 5000000
25 changes: 25 additions & 0 deletions mover/fengfengxiong123/code/task2/mint_dao_faucet_testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
sui client call \
--package 0x2 \
--module coin \
--function mint_and_transfer \
--type-args 0xdacf8888168bfa8fbccf2cee479eaec3e3668326a165437bb347e9f0111cf0fc::dao::DAO \
--args \
0x7fa2d0cb719e6c40db0426485b62f2025b03491e022501f775b03733c70696c4 \
10000000000 \
0xc5608b3f246c832b6a0908abf0c61a22e0703f2a571e65f8b202db7b67fb366d \
--gas-budget 100000000

sui client call \
--package 0x2 \
--module coin \
--function mint_and_transfer \
--type-args 0xdacf8888168bfa8fbccf2cee479eaec3e3668326a165437bb347e9f0111cf0fc::faucetcoin::FAUCETCOIN \
--args \
0x34d9d14bef45e3da5c7dec9000c573b421a058b173372ea20b53ebbbdfcf3de0 \
70000000000 \
0xc5608b3f246c832b6a0908abf0c61a22e0703f2a571e65f8b202db7b67fb366d \
--gas-budget 700000000

# dao id 0x421e8725b78903b324cb5982f0ad030d658f5e8e92d1737010f482d570e3929e
# faucet id 0xd0d65c019e15821c72677a857277de3a18495f588a65e43312a4971bb37eba68
# 0x2::coin::TreasuryCap<0xf5832a67eabb78a0a021d807bba92de5d387334bda7ef6852a600fe9887446eb::faucetcoin::FAUCETCOIN>
34 changes: 34 additions & 0 deletions mover/fengfengxiong123/code/task2/my_coin/Move_testnet.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "38FA6D76635532E25C82A10BAEB3E861865131F2810F7F4FB5975D754CCBAA48"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ id = "Sui", name = "Sui" },
]

[[move.package]]
id = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates\\sui-framework\\packages\\move-stdlib" }

[[move.package]]
id = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[move.toolchain-version]
compiler-version = "1.38.2"
edition = "2024.beta"
flavor = "sui"

[env]

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0xdacf8888168bfa8fbccf2cee479eaec3e3668326a165437bb347e9f0111cf0fc"
latest-published-id = "0xdacf8888168bfa8fbccf2cee479eaec3e3668326a165437bb347e9f0111cf0fc"
published-version = "1"
10 changes: 0 additions & 10 deletions mover/fengfengxiong123/code/task2/start.sh

This file was deleted.

74 changes: 74 additions & 0 deletions mover/fengfengxiong123/code/task5/mainnet_call.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# 存入 dao
sui client call \
--package 0x79be9eb0279e5b773f1e43ca0248fea51000a6263b565911f6797fbba1234dc8 \
--module my_swap \
--function in_dao \
--args \
0x76272cd1775fc96952d6d3f0e9f3e55d73e3135ad06249d1124b9d41075609dc \
0x4b02a1e9a3579fcd68a17626f8813ddf677e2e5e0959fd997cb366f812a78c17 \
--gas-budget 10000000

# --args
# 共享对象id
# coin id

# 存入 faucet

sui client call \
--package 0x79be9eb0279e5b773f1e43ca0248fea51000a6263b565911f6797fbba1234dc8 \
--module my_swap \
--function in_faucet \
--args \
0x76272cd1775fc96952d6d3f0e9f3e55d73e3135ad06249d1124b9d41075609dc \
0x66aded0c1b19689e2d950faa43f481a8ac79d57cea9773b6ef5aa0ad3a51e101 \
--gas-budget 10000000

# dao兑换 faucet

sui client call \
--package 0x79be9eb0279e5b773f1e43ca0248fea51000a6263b565911f6797fbba1234dc8 \
--module my_swap \
--function dao_to_faucet \
--args \
0x76272cd1775fc96952d6d3f0e9f3e55d73e3135ad06249d1124b9d41075609dc \
0x313757d4c979d01622b432ba5023c6e213dc10697c7e936bdb98f146dcb24a6e \
--gas-budget 10000000

# faucet 兑换 dao

sui client call \
--package 0x79be9eb0279e5b773f1e43ca0248fea51000a6263b565911f6797fbba1234dc8 \
--module my_swap \
--function faucet_to_dao \
--args \
0x76272cd1775fc96952d6d3f0e9f3e55d73e3135ad06249d1124b9d41075609dc \
0xdb6d3a4588cda222eeea5c4cfcf29dfcd82a4018ac265c28f0cd170e5e081066 \
--gas-budget 10000000

# 取回

sui client call \
--package 0x79be9eb0279e5b773f1e43ca0248fea51000a6263b565911f6797fbba1234dc8 \
--module my_swap \
--function remove_dao \
--args \
0x27854b46072a1e02d348128aac07acfe3503f9cf3bf10e1b353dadf2f1884e31 \
0x76272cd1775fc96952d6d3f0e9f3e55d73e3135ad06249d1124b9d41075609dc \
10000000000 \
--gas-budget 10000000

# 取回
sui client call \
--package 0x79be9eb0279e5b773f1e43ca0248fea51000a6263b565911f6797fbba1234dc8 \
--module my_swap \
--function remove_faucet \
--args \
0x27854b46072a1e02d348128aac07acfe3503f9cf3bf10e1b353dadf2f1884e31 \
0x76272cd1775fc96952d6d3f0e9f3e55d73e3135ad06249d1124b9d41075609dc \
10000000000 \
--gas-budget 20000000

# --args
# admin cap id
# 共享对象id
# value
43 changes: 43 additions & 0 deletions mover/fengfengxiong123/code/task5/my_swap/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "EB9F665BEE0BAC82780FB788046163155D6B97EF101BB023C33F4E2D92BBC83D"
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600"
dependencies = [
{ id = "Sui", name = "Sui" },
{ id = "my_coin", name = "my_coin" },
]

[[move.package]]
id = "MoveStdlib"
source = { git = "https://gitee.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates\\sui-framework\\packages\\move-stdlib" }

[[move.package]]
id = "Sui"
source = { git = "https://gitee.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[[move.package]]
id = "my_coin"
source = { local = "..\\..\\task2\\my_coin" }

dependencies = [
{ id = "Sui", name = "Sui" },
]

[move.toolchain-version]
compiler-version = "1.38.2"
edition = "2024.beta"
flavor = "sui"

[env]

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x79be9eb0279e5b773f1e43ca0248fea51000a6263b565911f6797fbba1234dc8"
latest-published-id = "0x79be9eb0279e5b773f1e43ca0248fea51000a6263b565911f6797fbba1234dc8"
published-version = "1"
38 changes: 38 additions & 0 deletions mover/fengfengxiong123/code/task5/my_swap/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "my_swap"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]

[dependencies]
Sui = { git = "https://gitee.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" }
#Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" }
my_coin = { local = "../../task2/my_coin" }
# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
# Revision can be a branch, a tag, and a commit hash.
# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }

# For local dependencies use `local = path`. Path is relative to the package root
# Local = { local = "../path/to" }

# To resolve a version conflict and force a specific version for dependency
# override use `override = true`
# Override = { local = "../conflicting/version", override = true }

[addresses]
my_swap = "0x0"

# Named addresses will be accessible in Move as `@name`. They're also exported:
# for example, `std = "0x1"` is exported by the Standard Library.
# alice = "0xA11CE"

[dev-dependencies]
# The dev-dependencies section allows overriding dependencies for `--test` and
# `--dev` modes. You can introduce test-only dependencies here.
# Local = { local = "../path/to/dev-build" }

[dev-addresses]
# The dev-addresses section allows overwriting named addresses for the `--test`
# and `--dev` modes.
# alice = "0xB0B"

43 changes: 43 additions & 0 deletions mover/fengfengxiong123/code/task5/my_swap/Move_testnet.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "6DF6AD21254139229F69396B1C66F38B90657C1A1862749A5BDE30BF025F7751"
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600"
dependencies = [
{ id = "Sui", name = "Sui" },
{ id = "my_coin", name = "my_coin" },
]

[[move.package]]
id = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates\\sui-framework\\packages\\move-stdlib" }

[[move.package]]
id = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[[move.package]]
id = "my_coin"
source = { local = "..\\..\\task2\\my_coin" }

dependencies = [
{ id = "Sui", name = "Sui" },
]

[move.toolchain-version]
compiler-version = "1.38.2"
edition = "2024.beta"
flavor = "sui"

[env]

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0x2652eb0f0ec2655013e116118a23793672ffd6d0473876c2d7afa45598af4f31"
latest-published-id = "0x2652eb0f0ec2655013e116118a23793672ffd6d0473876c2d7afa45598af4f31"
published-version = "1"
72 changes: 72 additions & 0 deletions mover/fengfengxiong123/code/task5/my_swap/sources/my_swap.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
module my_swap::my_swap;
use my_coin::dao::DAO;
use my_coin::faucetcoin::FAUCETCOIN;
use sui::balance;
use sui::balance::Balance;
use sui::coin;
use sui::coin::{into_balance, from_balance};
use sui::coin::Coin;

public struct MyBank has key, store {
id: UID,
doc_coin: Balance<DAO>,
faucet_coin: Balance<FAUCETCOIN>
}

public struct AdminCap has key, store { id: UID }

fun init(ctx: &mut TxContext) {
let bank = MyBank {
id: object::new(ctx),
doc_coin: balance::zero<DAO>(),
faucet_coin: balance::zero<FAUCETCOIN>()
};
let admin = AdminCap { id: object::new(ctx) };
transfer::public_share_object(bank);
transfer::transfer(admin, ctx.sender())
}

public entry fun in_dao(bank: &mut MyBank, in: Coin<DAO>, _: &mut TxContext) {
let dao_coin = into_balance(in);
bank.doc_coin.join(dao_coin);
}

public entry fun in_faucet(bank: &mut MyBank, in: Coin<FAUCETCOIN>, _: &mut TxContext) {
let faucet_coin = into_balance(in);
bank.faucet_coin.join(faucet_coin);
}

public entry fun dao_to_faucet(bank: &mut MyBank, in: Coin<DAO>, ctx: &mut TxContext) {
let dao_in = into_balance(in);
let faucet = bank.faucet_coin.split(dao_in.value() * 7);
bank.doc_coin.join(dao_in);
let out_faucet = from_balance(faucet, ctx);
transfer::public_transfer(out_faucet, ctx.sender())
}

public entry fun faucet_to_dao(bank: &mut MyBank, in: Coin<FAUCETCOIN>, ctx: &mut TxContext) {
let faucet_in = into_balance(in);
let dao = bank.doc_coin.split(faucet_in.value() / 7);
bank.faucet_coin.join(faucet_in);
let out_dao = from_balance(dao, ctx);
transfer::public_transfer(out_dao, ctx.sender())
}

public entry fun remove_dao(_: &AdminCap, bank: &mut MyBank, dao_amt: u64, ctx: &mut TxContext) {
if (bank.doc_coin.value() < dao_amt) {
abort 101
};
let dao_coin = bank.doc_coin.split(dao_amt);
let dao_ = coin::from_balance(dao_coin, ctx);
transfer::public_transfer(dao_, ctx.sender());
}

public entry fun remove_faucet(_: &AdminCap, bank: &mut MyBank, faucet_amt: u64, ctx: &mut TxContext) {
if (bank.faucet_coin.value() < faucet_amt) {
abort 102
};

let faucet_coin = bank.faucet_coin.split(faucet_amt);
let faucet_ = coin::from_balance(faucet_coin, ctx);
transfer::public_transfer(faucet_, ctx.sender());
}
18 changes: 18 additions & 0 deletions mover/fengfengxiong123/code/task5/my_swap/tests/my_swap_tests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
#[test_only]
module my_swap::my_swap_tests;
// uncomment this line to import the module
// use my_swap::my_swap;

const ENotImplemented: u64 = 0;

#[test]
fun test_my_swap() {
// pass
}

#[test, expected_failure(abort_code = ::my_swap::my_swap_tests::ENotImplemented)]
fun test_my_swap_fail() {
abort ENotImplemented
}
*/
Loading
Loading