Coder Social home page Coder Social logo

movetool's Introduction

movefuns

The Move commons library for support multiple Move chains.

The goal of this library is to provide a common extension library for Move and to simplify the development of DApp SmartContracts on Move, like apache-commons library on Java or openzeppelin on Solidity.

Deploy status

Chain MoveFuns version Network Deployed Address
Starcoin 1.0.0 main/barnard 0x6ee3f577c8da207830c31e1f0abb4244
0l 1.0.0 main(TODO)
Aptos 1.0.0 test(TODO)
Sui 1.0.0 dev(TODO)

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

First off, thanks for taking the time to contribute! Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are greatly appreciated.

Contributions in the following are welcome:

  1. Report a bug.
  2. Submit a feature request, such as a codec function, an algorithm function.
  3. Implement feature or fix bug.

How to add new module to movefuns:

  1. Add New Move module to sources dir, such as MyModule.move.
  2. Write Move code and add unit test in the module file.
  3. [starcoin] Add an integration test to integration-tests dir, such as: test_my_module.move.
  4. [starcoin] Run the integration test mpm integration-test test_my_module.move .
  5. Run script ./scripts/build.sh for build and generate documents.
  6. Commit the changes and create a pull request.

You can view our Code of Conduct.

Support

Reach out to the maintainer at one of the following places:

License

movefuns is licensed as Apache 2.0.

movetool's People

Contributors

daog1 avatar jolestar avatar leeduckgo avatar nangongamo avatar tonyce avatar uvd avatar vueadmin avatar wgb5445 avatar wow-sven avatar yubing744 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

movetool's Issues

[Feature Request] 一个链上石头剪刀布小游戏

初步思路,有两个:

  • 用户和智能合约玩游戏
  1. 用户选择出石头剪刀或者布,支付 1 stc,合约里随机(合约中的随机数有局限,不过用在这个场景还可以)出石头剪刀或者布。
  2. 如果用户赢了,从资金库中支付 1 stc 给用户。
  3. 如果用户输了,1 stc 存到资金库。
  4. 需要有个很小的初始资金库。按概率来说,资金库不会被耗尽,如果耗尽就说明随机数规则被别人 hack 了。
  • 用户和用户之间玩游戏

这个稍微复杂一些,因为无法实现两个用户同时出拳,所以必须是异步的,所以先发起交易的一方需要先隐藏自己的出拳。

  1. Alice 开一局游戏,抵押 x stc,并带上自己选择的 hash。选择用一个很大的随机数字 n 表示,n%3 的余数 0,1,2 分别表示石头,剪刀,布。用户可以自己选择随机数代表自己的选择。hash = sha3(alice address + n)。DApp 生成一个代表该局游戏的链接。
  2. Alice 将自己的链接发给 Bob, Bob 同样做出选择,可以直接提交选择(0,1,2),抵押 x stc, 提交给合约。
  3. Alice 公开自己的选择,提交到合约,合约验证 hash 是否匹配,然后做出裁判。 这里有个超时机制,如果超过一定时间,Alice 依然不公开自己的选择,超时后 Bob 可以直接请求合约仲裁,合约直接判定 Alice 输。
  4. 赢的一方可以获取另外一方抵押的 stc,可以考虑扣取一部分手续费放到合约资金库。另外考虑到激励 Alice 及时公布选择,可以规定,一个分配比例,比如输的一方依然可以拿回 5% 的押金,剩下的都给赢的一方。

开发者收益

通过开发这个游戏可以有以下收益:

  1. 理解智能合约里的随机数
  2. 理解链上的状态的存储以及资金如何锁在合约里。
  3. 理解链上游戏的一些难点,随机数,隐藏信息等。
  4. 理解合约如何和 web 界面交互。

对这个游戏有其他想法或者建议,也欢迎在评论中提出。如果有其他游戏的构思,可以提交成 issue。

[Feature Request] 实现基于稳定币的自动兑换转账

经常有需求需要转账 100U 等值的 STC,一般的做法是先通过 oracle 来拿到 STC 对 USD 的价格,然后再计算数量,比较麻烦。可以通过合约自动完成这种换算。

首先需要定义一个合约,合约中通过 Oracle 自动换算输入的 usd 为 STC 数额。 Oracle 文档参看 https://github.com/starcoinorg/StarcoinPriceReporter

其次在页面上实现一个转账的界面。

扩展:

  • 是否有可能支持多种 Token?
    目前已经支持 stc star

[Feature Request] Support Issue a Token on webpage

Issue a Token on the webpage, and support some customization options, such as total issue amount, etc.

The most difficult part to achieve this requirement is: How to compile Move code on the webpage?

There are two possible approaches:

  1. Compile the move compiler to WASM, and call it in javascript.
  2. Support a compiler backend, the best way to do this is to provide a lambda function on AWS, for compiling Move source code to Move bytecode and Package.

feat: 开发一个合约部署Dapp

场景:用户通过starcoin-ide/mpm开发了一个合约,并生成了 release blob, 如果能有一个网页版Dapp,用户将blob文件拖拽到网页中,然后点击部署,弹出 starmask,完成签名,部署成功。

[开发工具] 错误码描述表生成工具或者查询工具

目前 StarcoinFramework 的错误码查询不太方便, 具体体现在:

  1. 错误码规范由 category 和 reason 构成, https://github.com/starcoinorg/starcoin-framework/blob/main/build/StarcoinFramework/docs/Errors.md#function-make 。因此程序返回的错误码不太直观,需要开发者熟悉这一计算方式,并且每次需要根据错误码计算出 category 和 reason。
  2. 计算出 category 和 reason 后,需要去对应模块查找原因。

目前有 starcoin 命令行工具可以查询,使用方法如下:

starcoin% dev move-explain -a 6
{
  "ok": {
    "category_code": 6,
    "category_name": null,
    "reason_code": 0,
    "reason_name": null
  }
}

该命令行工具每次都需要启动一个 starcoin node,体验不太好;并且错误描述似乎也不够详细。

如果有一个工具能够生成统一的错误码解释表,能很好的方便开发者查询错误。或者做一个更友好的错误码查询工具。
可以设计一些错误码的注释规范等,便于工具捕获信息。

在没有安装starmask的情况下,界面无任何显示

在没有安装starmask的情况下,界面无任何显示,f12输出入下,
image

27行如下代码:

    useEffect(() => {
        window.starcoin.on("accountsChanged", (accounts: any) => {
            setButtonText(accounts)
            dispatch(set(accounts))
        });
    }, [dispatch])

[Feature Request] 构想一个 WithdrawCapability 的使用场景并实现

Starcoin 的每个账户都有一个 withdrawal_capability 字段,
并且提供了 Account::extract_withdraw_capability 方法可以把用户的 WithdrawCapability 拿出来,
同时也提供了 Account::withdraw_with_capability, 可以通过 WithdrawCapability 从该 Capability 的原拥有者账户提取 Token。

设计一个应用场景,使用 WithdrawCapability, 比如资产托管。

[Feature Request][游戏]猜大小

用户和智能合约玩游戏

  1. 合约随机 0,1 中的一个数 随机到 1 合约赢 随机到 0 合约输
  2. 如果用户赢了,从资金库中支付 指定数量 stc 给用户。
  3. 如果用户输了,指定数量 stc 存到资金库。
  4. 用户单次最大压注金额为合约账户的 10分之一 防止 all in 掉合约账户

[Feature Request]【简单】链上记录这个单位转换哦 鉴于每个token 精度不一样 1.新增多token选择 2由于显示很多是格式化后的数量,支持去除格式化后的数字

精度如何获取 参考 https://github.com/starcoinorg/starcoin-explorer/blob/main/src/utils/sdk.ts#L149_L161

  • 2的说明
    比如 111,111,111.22 这样的数字

[Feature Request] 构想一个 KeyRotationCapability 的使用场景并实现

Starcoin 的每个账户都有一个 key_rotation_capability 字段,
并且提供了 Account::extract_key_rotation_capability 方法可以把用户的 KeyRotationCapability 拿出来,
同时也提供了 Account::rotate_authentication_key_with_capability, 可以通过 KeyRotationCapability 重置该 Capbility 原始拥有者的 authentication_key

设计一个应用场景,使用 KeyRotationCapability, 比如通过智能合约帮助用户重置 authentication_key。

[开发工具] 合约 Debug::print 格式转换工具

问题:
在合约调试中 使用 Debug::print打印出的结果多由数组组成
在调试中需要打印 hash字符串等,只能打印为数组,调试起来较为不便

需求:
在前端制作工具,方便进行数组转换为 ASCII 字符串,UTF8 字符串,还原 vector vector<vector>,还原带有 vector vector<vector>结构体

Transfer token to multi-address tools

  1. Support transfer token to multi-address, provider the address by webform or by CSV file.
  2. Support Any Token.
  3. Support setting the amount for individual addresses and can also be set an amount for all addresses.

yarn start 报错

开发环境运行 yarn start 报错

image

本地node版本:
node -v 130 ↵
v16.12.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.