Skip to content

Commit

Permalink
Merge pull request #2001 from nextuser/task4
Browse files Browse the repository at this point in the history
task4
  • Loading branch information
Sifotd authored Nov 25, 2024
2 parents c7ab044 + 9a5979c commit 1ee13c7
Show file tree
Hide file tree
Showing 30 changed files with 2,587 additions and 11 deletions.
Empty file.
46 changes: 46 additions & 0 deletions mover/nextuser/code/task2/coin_faucet/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# @generated by Move, please check-in and do not edit manually.

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

[[move.package]]
id = "MoveStdlib"
source = { local = "/home/ljl/sui-devnet/sui/crates/sui-framework/packages/move-stdlib" }

[[move.package]]
id = "Sui"
source = { local = "/home/ljl/sui-devnet/sui/crates/sui-framework/packages/sui-framework" }

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

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

[env]

[env.devnet]
chain-id = "ec8bffc7"
original-published-id = "0xc07ee2857e593ad33aa04bd77127604832529cee0947dcf5eb4fb4f72b5cb66a"
latest-published-id = "0xc07ee2857e593ad33aa04bd77127604832529cee0947dcf5eb4fb4f72b5cb66a"
published-version = "1"

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0x5004eab7e42fd66ad3b7475632ae3070e9a4015f8f8976009e7e8637592e9d76"
latest-published-id = "0x5004eab7e42fd66ad3b7475632ae3070e9a4015f8f8976009e7e8637592e9d76"
published-version = "1"

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0x9d5271ec037a50cafae643b4cc495c9e58ec993267b192d2693587f08c23367d"
latest-published-id = "0x9d5271ec037a50cafae643b4cc495c9e58ec993267b192d2693587f08c23367d"
published-version = "1"
43 changes: 43 additions & 0 deletions mover/nextuser/code/task2/coin_faucet/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[package]
name = "coin_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 = "git@github.com:MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/devnet" }
Sui = {local= "/home/ljl/sui-devnet/sui/crates/sui-framework/packages/sui-framework"}
# 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]
#devnet
# coin_faucet = "0xc07ee2857e593ad33aa04bd77127604832529cee0947dcf5eb4fb4f72b5cb66a"

#testnet
#coin_faucet = "0x9d5271ec037a50cafae643b4cc495c9e58ec993267b192d2693587f08c23367d"
#mainnet
coin_faucet = "0x5004eab7e42fd66ad3b7475632ae3070e9a4015f8f8976009e7e8637592e9d76"

# 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"

162 changes: 162 additions & 0 deletions mover/nextuser/code/task2/coin_faucet/devnet.log

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions mover/nextuser/code/task2/coin_faucet/sources/client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
sui client publish --skip-fetch-latest-git-deps --skip-dependency-verification

查看输出结果中的 0x2::coin::TreasuryCap 对象


│ ObjectID: 0x8e1bebaac6dd33bf486fb294981f13fb6946051f465db0c25401b61b01f7421e │
│ │ Sender: 0x540105a7d2f5f54a812c630f2996f1790ed0e60d1f9a870ce397f03e4cec9b38 │
│ │ Owner: Account Address ( 0x540105a7d2f5f54a812c630f2996f1790ed0e60d1f9a870ce397f03e4cec9b38 ) │
│ │ ObjectType: 0x2::coin::TreasuryCap<0x65a0995fd59c97b94fd975a3fb42c745cdff54711c1caae2934858e6eb99adb4::jp::JP>
│ │ Version: 236167313 │
│ │ Digest: BnpekhzZQWQnR77hpGMZyhafRrMe57AyJainuFX8xEjg


# testnet
export PKG=0x65a0995fd59c97b94fd975a3fb42c745cdff54711c1caae2934858e6eb99adb4
export JP_CAP=0x8e1bebaac6dd33bf486fb294981f13fb6946051f465db0c25401b61b01f7421e

# 获取当前激活的地址
export C_ADDR=`sui client active-address`

# 执行铸币,transfer给本地址
sui client call --package 0x2 --module coin --function mint_and_transfer --type-args $PKG::jp::JP --args $JP_CAP 8800000 $C_ADDR

# 获得输出创建coin
Created Objects: │
│ ┌── │
│ │ ObjectID: 0x95245c704b124aa96f49ab1cdd459c7219d1dc1165faaeae80a514524e8308e2 │
│ │ Sender: 0x540105a7d2f5f54a812c630f2996f1790ed0e60d1f9a870ce397f03e4cec9b38 │
│ │ Owner: Account Address ( 0x540105a7d2f5f54a812c630f2996f1790ed0e60d1f9a870ce397f03e4cec9b38 ) │
│ │ ObjectType: 0x2::coin::Coin<0x65a0995fd59c97b94fd975a3fb42c745cdff54711c1caae2934858e6eb99adb4::jp::JP>
│ │ Version: 236167314 │
│ │ Digest: Gh2shitikPnbxxffpPj5mnWwrUCNJChEPyCNaBB2YHMV

# 查看获得货币
sui client balance $C_ADDR




23 changes: 23 additions & 0 deletions mover/nextuser/code/task2/coin_faucet/sources/jp.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//use as faucet
module coin_faucet::jp{
use sui::coin;
use sui::url;
const JyqUrl:vector<u8> = b"https://tse4-mm.cn.bing.net/th/id/OIP-C.XVkbV--98d7_YfeLR2a_fAHaHa?rs=1&pid=ImgDetMain";

public struct JP has drop{ }

fun init( otw :JP , ctx : &mut TxContext)
{
let (cap,meta) = coin::create_currency(
otw,
0,
b"YEN",
b"YEN of Japan",
b"Japanese money",
option::some(url::new_unsafe_from_bytes(JyqUrl)),
ctx);

transfer::public_share_object(cap);
transfer::public_freeze_object(meta);
}
}
Loading

0 comments on commit 1ee13c7

Please sign in to comment.