DAO和插件的关系
DAO是主体,可以安装插件和使用插件
插件来完成具体的功能的扩展
分几部分来描述插件
第一部分,插件功能,如何使用,以及插件API文档
1. 插件的功能
1.1 Grant插件
Grant 插件提供 :
创建/执行颁发 Grant 的提案
创建/执行修改 Grant 的提案
创建/执行收回 Grant 的提案
创建安装 Grant 插件的提案
1.2 Member插件
1.3 Stake插件
2. 场景:描述StarcoinDAO下插件的使用和对接
2.1 Grant插件
在Starcoin DAO 中其他项目可以创建 颁发 Grant 的提案,来为申请人获得 Grant 奖励
一旦创建 Grant 的提案通过,申请人可以 通过 前端/cli 领取 Grant
当 申请人拥有 Grant 时,任意成员可以提案要求撤销/修改 申请人的 Grant 奖励,当提案通过后,申请人的 Grant 将被撤销/修改
2.2 Member插件
2.3 Stake插件
…
第二部分:在DAO里如何install插件,以及如何使用插件
1. 如何安装插件
插件的安装方式有两种:
当 DAO 被创建安装 (静态安装)
当 DAO 已经创建好后通过 “安装插件的插件”提案 安装(动态安装)
插件被安装后暂时没有卸载方法
1.1 静态安装
DAO 初始化创建(合约 Write 接口)
在一个DAO被实例化创建时,需要先上传该 DAO 的 合约模块后执行 DAO 的 初始化函数(对应下方create_dao
)
参数:
voting_delay
投票多久后开始
voting_period
投票的时间区间
voting_quorum_rate
投票成功的比例
min_action_delay
多久后可以执行提案
min_proposal_deposit
最小的提案质押 Token 数
public(script) fun create_dao( sender: signer, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64, min_proposal_deposit: u128,)
安装插件
DAOSpace::install_plugin_with_root_cap
调用此函数可以在 DAO 创建的同时 安装插件,无需投票安装
DAOSpace::install_plugin_with_root_cap<X, InstallPluginProposalPlugin>(&dao_root_cap, InstallPluginProposalPlugin::required_caps());
例子:XDAO
module creator::XDAO { use StarcoinFramework::DAOAccount; use StarcoinFramework::DAOSpace; use StarcoinFramework::MemberProposalPlugin::{Self, MemberProposalPlugin}; use StarcoinFramework::InstallPluginProposalPlugin::{Self, InstallPluginProposalPlugin}; struct X has store{} const NAME: vector<u8> = b"X"; /// directly upgrade the sender account to DAOAccount and create DAO public(script) fun create_dao( sender: signer, voting_delay: u64, voting_period: u64, voting_quorum_rate: u8, min_action_delay: u64, min_proposal_deposit: u128,){ let dao_account_cap = DAOAccount::upgrade_to_dao(sender); //let dao_signer = DAOAccount::dao_signer(&dao_account_cap); let config = DAOSpace::new_dao_config( voting_delay, voting_period, voting_quorum_rate, min_action_delay, min_proposal_deposit, ); let dao_root_cap = DAOSpace::create_dao<X>(dao_account_cap, *&NAME, b"ipfs://description", X{}, config); DAOSpace::install_plugin_with_root_cap<X, InstallPluginProposalPlugin>(&dao_root_cap, InstallPluginProposalPlugin::required_caps()); DAOSpace::install_plugin_with_root_cap<X, MemberProposalPlugin>(&dao_root_cap, MemberProposalPlugin::required_caps()); DAOSpace::burn_root_cap(dao_root_cap); } }
1.2 动态安装(合约 Write 接口)
动态安装适用于 DAO 已经创建好后 ,想要安装其他插件
需要被安装插件提供
install_plugin_proposal
接口,或者其他类似功能的接口
public(script) fun install_plugin_proposal<DAOT: store>(sender: signer, description:vector<u8>, action_delay: u64)
参数:
description:vector<u8>
要安装插件提案的描述
action_delay:u64
多久后可以执行提案
2. 使用插件
2.1 Grant 插件
Grant 授予:
合约接口:
public (script) fun create_grant_proposal<DAOT: store, TokenT:store>(sender: signer, description: vector<u8>,grantee: address, total: u128, start_time:u64, period: u64, action_delay:u64)
Grant 销毁:
合约接口:
public (script) fun create_grant_revoke_proposal<DAOT: store, TokenT:store>(sender: signer, description: vector<u8>, grantee:address, action_delay:u64)
Grant 修改:
合约接口:
public (script) fun create_grant_config_proposal<DAOT: store, TokenT:store>(sender: signer, description: vector<u8>, old_grantee: address, new_grantee: address, total: u128, period: u64,start_time:u64, action_delay:u64)