-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Administrator
authored and
Administrator
committed
Dec 25, 2024
1 parent
ced734c
commit f76b234
Showing
45 changed files
with
2,513 additions
and
16 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 @@ | ||
build/* |
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,37 @@ | ||
[package] | ||
name = "xdd_object" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
# license = "" # e.g., "MIT", "GPL", "Apache 2.0" | ||
# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] | ||
|
||
[dependencies] | ||
Sui = { git = "https://gitee.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" } | ||
|
||
# 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] | ||
xdd_object = "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" | ||
|
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,28 @@ | ||
sui client call --package 包名 --module 模块名 --function 方法名 --args 权限id(TreasuryCap对应的id) 金额 | ||
|
||
|
||
sui client call --package 0xba67f9e412da95fa110516926ce34257b1f988240ec2f6fd08fbe512c8ce45a8 --module xdd_object --function mint_xdd_object --args 0xc93bc1e5ef92f68148a602b53dc65d39a3cf6e6a18d9cf6337e6de5c340a7ce5 1000000000000 | ||
|
||
|
||
|
||
|
||
#铸币,只有自己有权限 | ||
sui client call --package 0x2 --module coin --function mint_and_transfer \ | ||
--type-args 0x7e81cbf616ef12f9049ede655c0d9ee31283fbe8f15067f749b010c40c280d76::usd::USD \ | ||
--args 0x8ea7753c31670fe2ab6042901c13ed2b174b420ee09b7f16482531080cef831b 10000000000 0x0c651eb9cd6ffa4928b5a9481f09591834a68f452cfbb8932cd6ac3643a61eb2 | ||
|
||
#usd | ||
sui client call --package 0x2 --module coin --function mint_and_transfer --type-args 0x7e81cbf616ef12f9049ede655c0d9ee31283fbe8f15067f749b010c40c280d76::usd::USD --args 0x8ea7753c31670fe2ab6042901c13ed2b174b420ee09b7f16482531080cef831b 10000000000 0x0c651eb9cd6ffa4928b5a9481f09591834a68f452cfbb8932cd6ac3643a61eb2 | ||
|
||
#铸币,所有人都有权限 | ||
#sui client call --package 包名 --module 模块名 --function 方法名 --type-args 币种 --args 权限id(TreasuryCap对应的id) 金额 地址 | ||
|
||
sui client call --package 0x2 --module coin --function mint_and_transfer --type-args 0x5eb4ac5d056728b852c659eb39c3cccc787568727f66ae246095530dcb17da80::rmb::RMB --args 0x302296d929561950c86c95f7b5df3c7c89288dd72f2adbda8c5e8a3a8570ae4d 10000000000 0x0c651eb9cd6ffa4928b5a9481f09591834a68f452cfbb8932cd6ac3643a61eb2 | ||
|
||
|
||
|
||
|
||
# 正式环境 | ||
sui client call --package 0x2cdd34202d285b2f4579955b57cb29cfd1c7ac9178cdc0d8424e47eb0c7a4016 --module xdd_object --function mint_xdd_object --args 0xd0df52564401b64c96a88f29751297cf8213658800a427e7c2a78b57d6ecf5ac 100000000000 | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
mover/xdd-object/code/task2/xdd_object/sources/xdd_object.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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module xdd_object::xdd_object { | ||
use std::option::none; | ||
use sui::coin; | ||
use sui::coin::{create_currency, TreasuryCap}; | ||
use sui::transfer::{public_transfer, public_freeze_object}; | ||
use sui::tx_context::TxContext; | ||
use sui::url::Url; | ||
|
||
public struct XDD_OBJECT has drop { | ||
|
||
} | ||
|
||
|
||
fun init(xddObject: XDD_OBJECT, ctx: &mut TxContext) { | ||
//创建代币 | ||
let (treasuryCap, coinMetadata) = create_currency( | ||
xddObject, | ||
9, | ||
b"XDD_OBJECT", | ||
b"XDD_OBJECT", | ||
b"", | ||
none<Url>(), | ||
ctx); | ||
|
||
//冻结货币元数据 | ||
public_freeze_object(coinMetadata); | ||
|
||
//将铸币权限给创建人 | ||
public_transfer(treasuryCap, ctx.sender()); | ||
} | ||
|
||
//铸币方法 | ||
public entry fun mint_xdd_object(cap: &mut TreasuryCap<XDD_OBJECT>, value: u64, ctx: &mut TxContext) { | ||
//铸币 | ||
let xddCoin = coin::mint(cap, value, ctx); | ||
//将代币转给某人, 也可以给指定地址 | ||
public_transfer(xddCoin, ctx.sender()); | ||
} | ||
|
||
|
||
|
||
} |
18 changes: 18 additions & 0 deletions
18
mover/xdd-object/code/task2/xdd_object/tests/xdd_object_tests.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
#[test_only] | ||
module xdd_object::xdd_object_tests; | ||
// uncomment this line to import the module | ||
// use xdd_object::xdd_object; | ||
const ENotImplemented: u64 = 0; | ||
#[test] | ||
fun test_xdd_object() { | ||
// pass | ||
} | ||
#[test, expected_failure(abort_code = ::xdd_object::xdd_object_tests::ENotImplemented)] | ||
fun test_xdd_object_fail() { | ||
abort ENotImplemented | ||
} | ||
*/ |
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 @@ | ||
build/* |
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,37 @@ | ||
[package] | ||
name = "xdd_object_faucet" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
# license = "" # e.g., "MIT", "GPL", "Apache 2.0" | ||
# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] | ||
|
||
[dependencies] | ||
Sui = { git = "https://gitee.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" } | ||
|
||
# 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] | ||
xdd_object_faucet = "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" | ||
|
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,10 @@ | ||
sui client call --package 包名 --module 模块名 --function 方法名 --args 权限id(TreasuryCap对应的id) 金额 接收地址 | ||
|
||
sui client call --package 0x1806931dfd9024b573fbd8abe56e3bc52c7f7030400921b7b9e859ca17b73c31 --module xdd_object_faucet --function mint_xdd_object_faucet --args 0x0dfb9a7f966d73da20e89a55b8f9bf6fb96a3f219b2d1eab50b4b1faf34afd81 1000000000000 0x0c651eb9cd6ffa4928b5a9481f09591834a68f452cfbb8932cd6ac3643a61eb2 | ||
|
||
|
||
|
||
|
||
#生产环境 | ||
sui client call --package 0x2ba9a31fbd3e1ef640c0c52fd4f0a719ba881514133fcd5884b48b62c0eb58d2 --module xdd_object_faucet --function mint_xdd_object_faucet --args 0x9dc0a87820bac5b153b5f8771f4ce16827a53ed672447b2c6a1320924326e6b6 10000000000 0x0c651eb9cd6ffa4928b5a9481f09591834a68f452cfbb8932cd6ac3643a61eb2 | ||
sui client call --package 0x2ba9a31fbd3e1ef640c0c52fd4f0a719ba881514133fcd5884b48b62c0eb58d2 --module xdd_object_faucet --function mint_xdd_object_faucet --args 0x9dc0a87820bac5b153b5f8771f4ce16827a53ed672447b2c6a1320924326e6b6 10000000000 0x517f05f8975255e1ab82bc74419d29601ac85d761acff71f00749478edd723b8 |
Oops, something went wrong.