Skip to content

Commit

Permalink
Add DAOSpace description (#85)
Browse files Browse the repository at this point in the history
* add description

* Add proposal description
  • Loading branch information
WGB5445 authored Aug 16, 2022
1 parent d401c37 commit a981f67
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 52 deletions.
2 changes: 1 addition & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: 0E40C59E95BD4C4EAC7E35CCB4EC85127F72EE5F48D70BEE8FBE34B526A11E42
source_digest: 7138A8A0DEBB195CC13E43D24FAACA4CCE188BA3536A5DED8646E8934CBC2431
build_flags:
dev_mode: false
test_mode: false
Expand Down
Binary file not shown.
Binary file modified build/StarcoinFramework/bytecode_modules/MemberProposalPlugin.mv
Binary file not shown.
6 changes: 3 additions & 3 deletions build/StarcoinFramework/docs/InstallPluginProposalPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@



<pre><code><b>public</b> <b>fun</b> <a href="InstallPluginProposalPlugin.md#0x1_InstallPluginProposalPlugin_create_proposal">create_proposal</a>&lt;DAOT: store, ToInstallPluginT: store&gt;(sender: &signer, required_caps: vector&lt;<a href="DAOSpace.md#0x1_DAOSpace_CapType">DAOSpace::CapType</a>&gt;, action_delay: u64)
<pre><code><b>public</b> <b>fun</b> <a href="InstallPluginProposalPlugin.md#0x1_InstallPluginProposalPlugin_create_proposal">create_proposal</a>&lt;DAOT: store, ToInstallPluginT: store&gt;(sender: &signer, required_caps: vector&lt;<a href="DAOSpace.md#0x1_DAOSpace_CapType">DAOSpace::CapType</a>&gt;, description: vector&lt;u8&gt;, action_delay: u64)
</code></pre>


Expand All @@ -113,14 +113,14 @@
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="InstallPluginProposalPlugin.md#0x1_InstallPluginProposalPlugin_create_proposal">create_proposal</a>&lt;DAOT: store, ToInstallPluginT: store&gt;(sender: &signer, required_caps: vector&lt;CapType&gt;, action_delay: u64){
<pre><code><b>public</b> <b>fun</b> <a href="InstallPluginProposalPlugin.md#0x1_InstallPluginProposalPlugin_create_proposal">create_proposal</a>&lt;DAOT: store, ToInstallPluginT: store&gt;(sender: &signer, required_caps: vector&lt;CapType&gt;, description: vector&lt;u8&gt;, action_delay: u64){
<b>let</b> witness = <a href="InstallPluginProposalPlugin.md#0x1_InstallPluginProposalPlugin">InstallPluginProposalPlugin</a>{};

<b>let</b> cap = <a href="DAOSpace.md#0x1_DAOSpace_acquire_proposal_cap">DAOSpace::acquire_proposal_cap</a>&lt;DAOT, <a href="InstallPluginProposalPlugin.md#0x1_InstallPluginProposalPlugin">InstallPluginProposalPlugin</a>&gt;(&witness);
<b>let</b> action = <a href="InstallPluginProposalPlugin.md#0x1_InstallPluginProposalPlugin_InstallPluginAction">InstallPluginAction</a>&lt;ToInstallPluginT&gt;{
required_caps,
};
<a href="DAOSpace.md#0x1_DAOSpace_create_proposal">DAOSpace::create_proposal</a>(&cap, sender, action, action_delay);
<a href="DAOSpace.md#0x1_DAOSpace_create_proposal">DAOSpace::create_proposal</a>(&cap, sender, action, description, action_delay);
}
</code></pre>

Expand Down
12 changes: 6 additions & 6 deletions build/StarcoinFramework/docs/MemberProposalPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@



<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_create_proposal">create_proposal</a>&lt;DAOT: store&gt;(sender: signer, member: <b>address</b>, init_sbt: u128, action_delay: u64)
<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_create_proposal">create_proposal</a>&lt;DAOT: store&gt;(sender: signer, description: vector&lt;u8&gt;, member: <b>address</b>, init_sbt: u128, action_delay: u64)
</code></pre>


Expand All @@ -121,14 +121,14 @@
<summary>Implementation</summary>


<pre><code><b>public</b> (<b>script</b>) <b>fun</b> <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_create_proposal">create_proposal</a>&lt;DAOT: store&gt;(sender: signer, member: <b>address</b>, init_sbt: u128, action_delay: u64){
<pre><code><b>public</b> (<b>script</b>) <b>fun</b> <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_create_proposal">create_proposal</a>&lt;DAOT: store&gt;(sender: signer, description: vector&lt;u8&gt;, member: <b>address</b>, init_sbt: u128, action_delay: u64){
<b>let</b> witness = <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin">MemberProposalPlugin</a>{};
<b>let</b> cap = <a href="DAOSpace.md#0x1_DAOSpace_acquire_proposal_cap">DAOSpace::acquire_proposal_cap</a>&lt;DAOT, <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin">MemberProposalPlugin</a>&gt;(&witness);
<b>let</b> action = <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_MemberJoinAction">MemberJoinAction</a>{
member,
init_sbt,
};
<a href="DAOSpace.md#0x1_DAOSpace_create_proposal">DAOSpace::create_proposal</a>(&cap, &sender, action, action_delay);
<a href="DAOSpace.md#0x1_DAOSpace_create_proposal">DAOSpace::create_proposal</a>(&cap, &sender, action, description, action_delay);
}
</code></pre>

Expand Down Expand Up @@ -170,7 +170,7 @@



<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_install_plugin_proposal">install_plugin_proposal</a>&lt;DAOT: store&gt;(sender: signer, action_delay: u64)
<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_install_plugin_proposal">install_plugin_proposal</a>&lt;DAOT: store&gt;(sender: signer, description: vector&lt;u8&gt;, action_delay: u64)
</code></pre>


Expand All @@ -179,8 +179,8 @@
<summary>Implementation</summary>


<pre><code><b>public</b> (<b>script</b>) <b>fun</b> <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_install_plugin_proposal">install_plugin_proposal</a>&lt;DAOT:store&gt;(sender:signer, action_delay:u64){
<a href="InstallPluginProposalPlugin.md#0x1_InstallPluginProposalPlugin_create_proposal">InstallPluginProposalPlugin::create_proposal</a>&lt;DAOT, <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_MemberJoinAction">MemberJoinAction</a>&gt;(&sender, <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_required_caps">required_caps</a>(), action_delay);
<pre><code><b>public</b> (<b>script</b>) <b>fun</b> <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_install_plugin_proposal">install_plugin_proposal</a>&lt;DAOT:store&gt;(sender:signer, description: vector&lt;u8&gt;,action_delay:u64){
<a href="InstallPluginProposalPlugin.md#0x1_InstallPluginProposalPlugin_create_proposal">InstallPluginProposalPlugin::create_proposal</a>&lt;DAOT, <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_MemberJoinAction">MemberJoinAction</a>&gt;(&sender, <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_required_caps">required_caps</a>(), description, action_delay);
}
</code></pre>

Expand Down
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/MemberProposalPlugin.mvsm
Binary file not shown.
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_grant.exp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ task 5 'run'. lines 13-21:

task 8 'run'. lines 99-108:
{
"gas_used": 1157874,
"gas_used": 1159993,
"status": {
"Keep": "Executed"
}
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/daospace/dao_grant.move
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module creator::DAOHelper {
min_action_delay,
min_proposal_deposit,
);
let dao_root_cap = DAOSpace::create_dao<X>(dao_account_cap, *&NAME, X{}, config);
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, AnyMemberPlugin>(&dao_root_cap, AnyMemberPlugin::required_caps());
Expand All @@ -77,7 +77,7 @@ module creator::DAOHelper {
public fun create_grant(sender:&signer, total:u128, start_time:u64,period:u64){
let witness = XPlugin{};
let grant_cap = DAOSpace::acquire_grant_cap<X, XPlugin>(&witness);
DAOSpace::create_grant<X,XPlugin,STC::STC>(&grant_cap, sender, total, start_time, period);
DAOSpace::create_grant<X,XPlugin,STC::STC>(&grant_cap,sender, total, start_time, period);
}

public fun grant_revoke(grantee:address){
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/daospace/dao_proposal.exp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ task 5 'run'. lines 13-21:

task 8 'run'. lines 132-141:
{
"gas_used": 1155077,
"gas_used": 1157196,
"status": {
"Keep": "Executed"
}
Expand Down Expand Up @@ -50,7 +50,7 @@ task 12 'run'. lines 206-222:

task 13 'run'. lines 225-246:
{
"gas_used": 239838,
"gas_used": 240459,
"status": {
"Keep": {
"MoveAbort": [
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/daospace/dao_proposal.move
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module creator::DAOHelper {
min_action_delay,
min_proposal_deposit,
);
let dao_root_cap = DAOSpace::create_dao<X>(dao_account_cap, *&NAME, X{}, config);
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());
Expand Down Expand Up @@ -90,7 +90,7 @@ module creator::DAOHelper {
total,
receiver,
};
let proposal_id = DAOSpace::create_proposal(&cap, sender, action, action_delay);
let proposal_id = DAOSpace::create_proposal(&cap, sender, action, b"ipfs://description", action_delay);
checkpoint<DAOT>(proposal_id);

proposal_id
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/stake_to_sbt_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ task 4 'run'. lines 9-17:

task 6 'run'. lines 60-68:
{
"gas_used": 1250974,
"gas_used": 1253093,
"status": {
"Keep": "Executed"
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/stake_to_sbt_plugin.move
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module creator::XDAO {
min_action_delay,
min_proposal_deposit,
);
let dao_root_cap = DAOSpace::create_dao<X>(dao_account_cap, *&NAME, X {}, config);
let dao_root_cap = DAOSpace::create_dao<X>(dao_account_cap, *&NAME, b"ipfs://description", X {}, config);

DAOSpace::install_plugin_with_root_cap<X, StakeToSBTPlugin>(&dao_root_cap, StakeToSBTPlugin::required_caps());
StakeToSBTPlugin::accept_token_with_root_cap<X, STC::STC>(&dao_root_cap);
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/xdao.exp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ task 2 'run'. lines 7-14:

task 4 'run'. lines 53-60:
{
"gas_used": 1036446,
"gas_used": 1038565,
"status": {
"Keep": "Executed"
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/xdao.move
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module creator::XDAO {
min_action_delay,
min_proposal_deposit,
);
let dao_root_cap = DAOSpace::create_dao<X>(dao_account_cap, *&NAME, X{}, config);
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());
Expand Down
34 changes: 29 additions & 5 deletions sources/daospace/DAOSpace.move
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ module StarcoinFramework::DAOSpace {
id: u64,
// TODO migrate ASIIC String and use ASSIC String
name: vector<u8>,
// description ipfs://xxxxx
description:vector<u8>,
dao_address: address,
next_member_id: u64,
next_proposal_id: u64,
Expand Down Expand Up @@ -224,14 +226,15 @@ module StarcoinFramework::DAOSpace {
}

/// Create a dao with a exists DAO account
public fun create_dao<DAOT: store>(cap: DAOAccountCap, name: vector<u8>, ext: DAOT, config: DAOConfig): DAORootCap<DAOT> acquires DAOEvent {
public fun create_dao<DAOT: store>(cap: DAOAccountCap, name: vector<u8>, description: vector<u8>, ext: DAOT, config: DAOConfig): DAORootCap<DAOT> acquires DAOEvent {
let dao_signer = DAOAccount::dao_signer(&cap);

let dao_address = Signer::address_of(&dao_signer);
let id = DAORegistry::register<DAOT>(dao_address);
let dao = DAO{
id,
name: *&name,
name: copy name,
description: copy description,
dao_address,
next_member_id: 1,
next_proposal_id: 1,
Expand Down Expand Up @@ -305,6 +308,7 @@ module StarcoinFramework::DAOSpace {
DAOCreatedEvent {
id,
name: copy name,
description:copy description,
dao_address,
},
);
Expand All @@ -313,9 +317,9 @@ module StarcoinFramework::DAOSpace {
}

// Upgrade account to DAO account and create DAO
public fun upgrade_to_dao<DAOT: store>(sender: signer, name: vector<u8>, ext: DAOT, config: DAOConfig): DAORootCap<DAOT> acquires DAOEvent{
public fun upgrade_to_dao<DAOT: store>(sender: signer, name: vector<u8>, description:vector<u8>, ext: DAOT, config: DAOConfig): DAORootCap<DAOT> acquires DAOEvent{
let cap = DAOAccount::upgrade_to_dao(sender);
create_dao<DAOT>(cap, name, ext, config)
create_dao<DAOT>(cap, name, description, ext, config)
}

/// Burn the root cap after init the DAO
Expand All @@ -331,6 +335,7 @@ module StarcoinFramework::DAOSpace {
struct DAOCreatedEvent has drop, store{
id: u64,
name: vector<u8>,
description:vector<u8>,
dao_address: address,
}

Expand Down Expand Up @@ -1035,6 +1040,8 @@ module StarcoinFramework::DAOSpace {
id: u64,
/// creator of the proposal
proposer: address,
/// description of proposal , ipfs://
description:vector<u8>,
/// when voting begins.
start_time: u64,
/// when voting ends.
Expand Down Expand Up @@ -1151,6 +1158,8 @@ module StarcoinFramework::DAOSpace {
dao_id: u64,
/// the proposal id.
proposal_id: u64,
/// description of proposal , ipfs://
description: vector<u8>,
/// proposer is the user who create the proposal.
proposer: address,
}
Expand Down Expand Up @@ -1187,6 +1196,7 @@ module StarcoinFramework::DAOSpace {
_cap: &DAOProposalCap<DAOT, PluginT>,
sender: &signer,
action: ActionT,
description: vector<u8>,
action_delay: u64,
): u64 acquires DAO, GlobalProposals, DAOAccountCapHolder, ProposalActions, ProposalEvent, GlobalProposalActions {
// check DAO member
Expand All @@ -1213,6 +1223,7 @@ module StarcoinFramework::DAOSpace {
let proposal = Proposal {
id: proposal_id,
proposer,
description: copy description,
start_time,
end_time: start_time + voting_period,
yes_votes: 0,
Expand Down Expand Up @@ -1277,7 +1288,7 @@ module StarcoinFramework::DAOSpace {
let dao_id = dao_id(dao_address);
let proposal_event = borrow_global_mut<ProposalEvent<DAOT>>(dao_address);
Event::emit_event(&mut proposal_event.proposal_create_event,
ProposalCreatedEvent { dao_id, proposal_id, proposer },
ProposalCreatedEvent { dao_id, proposal_id, description: copy description, proposer },
);

proposal_id
Expand Down Expand Up @@ -1766,6 +1777,19 @@ module StarcoinFramework::DAOSpace {
}
}

/// Update DAO description
public fun set_dao_description<DAOT: store,
PluginT: drop,
ConfigT: copy + store + drop>(
_cap: &mut DAOModifyConfigCap<DAOT, PluginT>,
description: vector<u8>)
acquires DAO{
let dao_address = dao_address<DAOT>();
let dao = borrow_global_mut<DAO>(dao_address);
dao.description = description;
}


/// get default voting delay of the DAO.
public fun voting_delay<DAOT: store>(): u64 {
get_config<DAOT>().voting_delay
Expand Down
4 changes: 2 additions & 2 deletions sources/daospaceplugin/AnyMemberPlugin.move
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module StarcoinFramework::AnyMemberPlugin{
DAOSpace::join_member(&member_cap, Signer::address_of(&sender), 1);
}

public (script) fun install_plugin_proposal<DAOT:store>(sender:signer, action_delay:u64){
InstallPluginProposalPlugin::create_proposal<DAOT, AnyMemberPlugin>(&sender, required_caps(), action_delay);
public (script) fun install_plugin_proposal<DAOT:store>(sender:signer, description: vector<u8>, action_delay:u64){
InstallPluginProposalPlugin::create_proposal<DAOT, AnyMemberPlugin>(&sender, required_caps(), description, action_delay);
}
}
8 changes: 4 additions & 4 deletions sources/daospaceplugin/ConfigProposalPlugin.move
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module StarcoinFramework::ConfigProposalPlugin {
caps
}

public fun create_proposal<DAOT: store, ConfigT: store>(sender: signer, action_delay: u64, config: ConfigT) {
public fun create_proposal<DAOT: store, ConfigT: store>(sender: signer, description: vector<u8>,action_delay: u64, config: ConfigT) {
let witness = ConfigProposalPlugin{};
let cap = DAOSpace::acquire_proposal_cap<DAOT, ConfigProposalPlugin>(&witness);
let action = ConfigProposalAction<ConfigT>{
Expand All @@ -25,7 +25,7 @@ module StarcoinFramework::ConfigProposalPlugin {
DAOSpace::create_proposal<
DAOT,
ConfigProposalPlugin,
ConfigProposalAction<ConfigT>>(&cap, &sender, action, action_delay);
ConfigProposalAction<ConfigT>>(&cap, &sender, action, description, action_delay);
}

public (script) fun execute_proposal<DAOT: store, ConfigT: copy + drop + store>(sender: signer, proposal_id: u64) {
Expand All @@ -42,7 +42,7 @@ module StarcoinFramework::ConfigProposalPlugin {
DAOSpace::set_custom_config<DAOT, ConfigProposalPlugin, ConfigT>(&mut modify_config_cap, config);
}

public (script) fun install_plugin_proposal<DAOT:store>(sender:signer, action_delay:u64){
InstallPluginProposalPlugin::create_proposal<DAOT, ConfigProposalPlugin>(&sender, required_caps(), action_delay);
public (script) fun install_plugin_proposal<DAOT:store>(sender:signer, description: vector<u8>, action_delay:u64){
InstallPluginProposalPlugin::create_proposal<DAOT, ConfigProposalPlugin>(&sender, required_caps(), description, action_delay);
}
}
Loading

0 comments on commit a981f67

Please sign in to comment.