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

[Feature] Member Grant Offer #174

Merged
merged 10 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: 1230BEA3543B7C4D5A397F38B505D8A688DA01A1E47B3BA14964E08D2921AFC6
source_digest: 469C525439FE77F1566910011706144A049CB00E9D6EDD631204C4CE3606E663
build_flags:
dev_mode: false
test_mode: false
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion build/StarcoinFramework/docs/MemberProposalPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
<b>let</b> proposal_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> <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_MemberJoinAction">MemberJoinAction</a>{member, init_sbt, image_data, image_url} = <a href="DAOSpace.md#0x1_DAOSpace_execute_proposal">DAOSpace::execute_proposal</a>&lt;DAOT, <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin">MemberProposalPlugin</a>, <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_MemberJoinAction">MemberJoinAction</a>&gt;(&proposal_cap, sender, proposal_id);
<b>let</b> member_cap = <a href="DAOSpace.md#0x1_DAOSpace_acquire_member_cap">DAOSpace::acquire_member_cap</a>&lt;DAOT, <a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin">MemberProposalPlugin</a>&gt;(&witness);
<a href="DAOSpace.md#0x1_DAOSpace_join_member">DAOSpace::join_member</a>(&member_cap, member, <a href="Option.md#0x1_Option_some">Option::some</a>(image_data), <a href="Option.md#0x1_Option_some">Option::some</a>(image_url) , init_sbt);
<a href="DAOSpace.md#0x1_DAOSpace_member_offer">DAOSpace::member_offer</a>(&member_cap, member, <a href="Option.md#0x1_Option_some">Option::some</a>(image_data), <a href="Option.md#0x1_Option_some">Option::some</a>(image_url) , init_sbt);
}
</code></pre>

Expand Down
Binary file modified build/StarcoinFramework/source_maps/MemberProposalPlugin.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/Offer.mvsm
Binary file not shown.
1 change: 1 addition & 0 deletions sources/Offer.move
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ module Offer {
pragma verify = false;
}


/// Take Offer and put to signer's Collection<Offered>.
public(script) fun take_offer<Offered: store>(_signer: signer, _offer_address: address){
abort Errors::invalid_state(ERR_DEPRECATED)
Expand Down
410 changes: 294 additions & 116 deletions sources/daospace/DAOSpace.move

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sources/daospaceplugin/AnyMemberPlugin.move
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module StarcoinFramework::AnyMemberPlugin{
let witness = AnyMemberPlugin{};
let member_cap = DAOSpace::acquire_member_cap<DAOT, AnyMemberPlugin>(&witness);
IdentifierNFT::accept<DAOSpace::DAOMember<DAOT>,DAOSpace::DAOMemberBody<DAOT>>(sender);
DAOSpace::join_member(&member_cap, Signer::address_of(sender), Option::some(image_data), Option::some(image_url), 1);
DAOSpace::member_offer(&member_cap, Signer::address_of(sender), Option::some(image_data), Option::some(image_url), 1);
}

public (script) fun join_entry<DAOT: store>(sender: signer, image_data:vector<u8>, image_url:vector<u8>){
Expand Down
25 changes: 12 additions & 13 deletions sources/daospaceplugin/GrantProposalPlugin.move
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//TODO find more good name
module StarcoinFramework::GrantProposalPlugin{
use StarcoinFramework::GenesisSignerCapability;
use StarcoinFramework::Errors;
use StarcoinFramework::Option;
use StarcoinFramework::DAOPluginMarketplace;
use StarcoinFramework::DAOSpace::{Self, CapType};
use StarcoinFramework::Signer;
use StarcoinFramework::Vector;
use StarcoinFramework::InstallPluginProposalPlugin;

Expand All @@ -27,7 +25,10 @@ module StarcoinFramework::GrantProposalPlugin{
}

struct GrantRevokeAction<phantom TokenT:store> has store, drop {
grantee:address
grantee: address,
total: u128,
start_time:u64,
period:u64
}

public fun initialize() {
Expand Down Expand Up @@ -84,32 +85,31 @@ module StarcoinFramework::GrantProposalPlugin{
let witness = GrantProposalPlugin{};
let proposal_cap = DAOSpace::acquire_proposal_cap<DAOT, GrantProposalPlugin>(&witness);
let GrantCreateAction{grantee, total, start_time, period} = DAOSpace::execute_proposal<DAOT, GrantProposalPlugin, GrantCreateAction<TokenT>>(&proposal_cap, sender, proposal_id);
assert!(grantee == Signer::address_of(sender),Errors::not_published(ERR_SENDER_NOT_SAME));
let grant_cap = DAOSpace::acquire_grant_cap<DAOT, GrantProposalPlugin>(&witness);
DAOSpace::create_grant<DAOT, GrantProposalPlugin, TokenT>(&grant_cap, sender, total, start_time, period);
DAOSpace::grant_offer<DAOT, TokenT>(&grant_cap, grantee, total, start_time, period);
}

public (script) fun execute_grant_proposal_entry<DAOT: store, TokenT:store>(sender: signer, proposal_id: u64){
execute_grant_proposal<DAOT, TokenT>(&sender, proposal_id);
}

public fun create_grant_revoke_proposal<DAOT: store, TokenT:store>(sender: &signer, description: vector<u8>, grantee:address, action_delay:u64){
public fun create_grant_revoke_proposal<DAOT: store, TokenT:store>(sender: &signer, description: vector<u8>, grantee:address, total: u128, start_time:u64, period: u64, action_delay:u64){
let witness = GrantProposalPlugin{};
let cap = DAOSpace::acquire_proposal_cap<DAOT, GrantProposalPlugin>(&witness);
let action = GrantRevokeAction<TokenT>{ grantee };
let action = GrantRevokeAction<TokenT>{ grantee, total, start_time, period };
DAOSpace::create_proposal(&cap, sender, action, description, action_delay);
}

public (script) fun create_grant_revoke_proposal_entry<DAOT: store, TokenT:store>(sender: signer, description: vector<u8>, grantee:address, action_delay:u64){
create_grant_revoke_proposal<DAOT, TokenT>(&sender, description, grantee, action_delay);
public (script) fun create_grant_revoke_proposal_entry<DAOT: store, TokenT:store>(sender: signer, description: vector<u8>, grantee:address, total: u128, start_time:u64, period: u64, action_delay:u64){
create_grant_revoke_proposal<DAOT, TokenT>(&sender, description, grantee, total, start_time, period, action_delay);
}

public fun execute_grant_revoke_proposal<DAOT: store, TokenT:store>(sender: &signer, proposal_id: u64){
let witness = GrantProposalPlugin{};
let proposal_cap = DAOSpace::acquire_proposal_cap<DAOT, GrantProposalPlugin>(&witness);
let GrantRevokeAction{ grantee } = DAOSpace::execute_proposal<DAOT, GrantProposalPlugin, GrantRevokeAction<TokenT>>(&proposal_cap, sender, proposal_id);
let GrantRevokeAction{ grantee, total, start_time, period } = DAOSpace::execute_proposal<DAOT, GrantProposalPlugin, GrantRevokeAction<TokenT>>(&proposal_cap, sender, proposal_id);
let grant_cap = DAOSpace::acquire_grant_cap<DAOT, GrantProposalPlugin>(&witness);
DAOSpace::grant_revoke<DAOT, GrantProposalPlugin, TokenT>(&grant_cap , grantee);
DAOSpace::grant_revoke<DAOT, TokenT>(&grant_cap , grantee, total, start_time, period);
}

public (script) fun execute_grant_revoke_proposal_entry<DAOT: store, TokenT:store>(sender: signer, proposal_id: u64){
Expand Down Expand Up @@ -143,9 +143,8 @@ module StarcoinFramework::GrantProposalPlugin{
start_time:start_time,
period:period
} = DAOSpace::execute_proposal<DAOT, GrantProposalPlugin, GrantConfigAction<TokenT>>(&proposal_cap, sender, proposal_id);
assert!(new_grantee == Signer::address_of(sender),Errors::not_published(ERR_SENDER_NOT_SAME));
let grant_cap = DAOSpace::acquire_grant_cap<DAOT, GrantProposalPlugin>(&witness);
DAOSpace::grant_config<DAOT, GrantProposalPlugin, TokenT>(&grant_cap , old_grantee , sender, total, start_time, period);
DAOSpace::grant_config<DAOT, TokenT>(&grant_cap , old_grantee ,new_grantee , total, start_time, period);
}

public (script) fun execute_grant_config_proposal_entry<DAOT: store, TokenT:store>(sender: signer, proposal_id: u64){
Expand Down
2 changes: 1 addition & 1 deletion sources/daospaceplugin/MemberProposalPlugin.move
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module StarcoinFramework::MemberProposalPlugin{
let proposal_cap = DAOSpace::acquire_proposal_cap<DAOT, MemberProposalPlugin>(&witness);
let MemberJoinAction{member, init_sbt, image_data, image_url} = DAOSpace::execute_proposal<DAOT, MemberProposalPlugin, MemberJoinAction>(&proposal_cap, sender, proposal_id);
let member_cap = DAOSpace::acquire_member_cap<DAOT, MemberProposalPlugin>(&witness);
DAOSpace::join_member(&member_cap, member, Option::some(image_data), Option::some(image_url) , init_sbt);
DAOSpace::member_offer(&member_cap, member, Option::some(image_data), Option::some(image_url) , init_sbt);
}

public (script) fun execute_proposal_entry<DAOT: store>(sender: signer, proposal_id: u64){
Expand Down
2 changes: 1 addition & 1 deletion sources/daospaceplugin/StakeToSBTPlugin.move
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ module StarcoinFramework::StakeToSBTPlugin {

if (!DAOSpace::is_member<DAOT>(sender_addr)) {
IdentifierNFT::accept<DAOSpace::DAOMember<DAOT>, DAOSpace::DAOMemberBody<DAOT>>(sender);
DAOSpace::join_member<DAOT, StakeToSBTPlugin>(
DAOSpace::member_offer<DAOT, StakeToSBTPlugin>(
&member_cap,
sender_addr,
Option::none<vector<u8>>(),
Expand Down