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

[MIP-02] Movescription Account #5

Open
jolestar opened this issue Jan 9, 2024 · 1 comment
Open

[MIP-02] Movescription Account #5

jolestar opened this issue Jan 9, 2024 · 1 comment

Comments

@jolestar
Copy link

jolestar commented Jan 9, 2024

Motivation

The Movescriptions protocol is designed for autonomous worlds, where users in on-chain games or autonomous worlds require different roles and accounts. MovescriptionAccount is created for such scenarios.

Through Sui's "Transfer to Object" functionality, an Object can be simulated as an account. It also binds internally to the NAME movescription(#17), mapping the name to the MovescriptionAccount ObjectID for displaying account names and enabling transfers via names.

Additionally, it supports binding a movescription with metadata as an image to serve as the character's avatar.

Moreover, this account can store the user's Coin assets, Movescription, and other Object items in the game.

Solution

/// Name resolver is a shared object, record name <-> address mapping
struct NameResolver has key{
  name_to_account: Table<String, ID>,
  account_to_name: Table<ID, String>,
}

struct MovescriptionAccount has key{
  id: UID,
  create_time: u64,
  // $MOVE Movescription
  name: Movescription,
}

public fun new_account(resolver: &mut NameResolver, name: &Movescription, ctx: &mut TxContext) : MovescriptionAccount{
  //store the name Movescription to the entity
  //resolve the name to the account object id.
}

public fun accept_payment<T>(account: &mut Account, sent: Receiving<Coin<T>>);

public fun withdraw<T>(account: &mut MovescriptionAccount, amount: u64, ctx: &mut TxContext): Coin<T>;

public fun accept_movescription(account: &mut Account, sent: Receiving<Movescription>);

public fun withdraw_movescription(account: &mut MovescriptionAccount, tick: String, amount: u64, ctx: &mut TxContext): Movescription;

public fun transfer(self: MovescriptionAccount, to: address){
  //other update and check
  transfer::transfer(self, to);
}

动机

Movescriptions 协议是一个自主世界的协议,用户在全链游戏或者自主世界中,需要有不同的角色和账户。MovescriptionAccount 为这种场景设计。

通过 Sui 的 Transfer to Object 功能,可以把 Object 模拟成一个账户。同时它内部绑定了 NAME 铭文,将 name 和 MovescriptionAccount ObjectID 做映射。用于展示角色名称以及转账时通过名称进行转账。

另外,也可以支持绑定一个 metadata 为 image 的铭文来做角色的头像。

同时,这个账户可以存储用户的 Coin 资产,Movescription,以及游戏中的其他 Object 道具。

@10xhunter
Copy link
Contributor

赞同,用例都很棒

@jolestar jolestar changed the title [MIP-02] Soulbound Movescription [MIP-02] Movescription Account Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants