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 6 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: 3977FFB3F8ED44A1FD4AFCBEE2027EFB707611899641612250DBBF23CC6D55EB
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.
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_create.exp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ task 7 'run'. lines 59-67:

task 10 'run'. lines 73-84:
{
"gas_used": 1054663,
"gas_used": 1054080,
"status": "Executed"
}
40 changes: 12 additions & 28 deletions integration-tests/daospace/dao_grant.exp
Original file line number Diff line number Diff line change
@@ -1,40 +1,24 @@
processed 17 tasks

task 5 'run'. lines 13-21:
{
"gas_used": 17743,
"status": {
"MoveAbort": {
"location": {
"Module": {
"address": "0x00000000000000000000000000000001",
"name": "Block"
}
},
"abort_code": "5382"
}
}
}

task 8 'run'. lines 123-134:
task 8 'run'. lines 108-119:
{
"gas_used": 1812265,
"status": "Executed"
}

task 9 'run'. lines 136-155:
task 9 'run'. lines 121-140:
{
"gas_used": 315396,
"gas_used": 427915,
"status": "Executed"
}

task 10 'run'. lines 157-191:
task 10 'run'. lines 142-174:
{
"gas_used": 561697,
"gas_used": 630999,
"status": "Executed"
}

task 12 'run'. lines 195-207:
task 12 'run'. lines 178-190:
{
"gas_used": 52853,
"status": {
Expand All @@ -50,20 +34,20 @@ task 12 'run'. lines 195-207:
}
}

task 13 'run'. lines 209-229:
task 13 'run'. lines 192-212:
{
"gas_used": 241369,
"gas_used": 253287,
"status": "Executed"
}

task 15 'run'. lines 233-253:
task 15 'run'. lines 216-236:
{
"gas_used": 229003,
"gas_used": 240921,
"status": "Executed"
}

task 16 'run'. lines 255-269:
task 16 'run'. lines 238-252:
{
"gas_used": 192361,
"gas_used": 345263,
"status": "Executed"
}
67 changes: 25 additions & 42 deletions integration-tests/daospace/dao_grant.move
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,21 @@

//# faucet --addr cindy --amount 10000000000

// TODO figure out how to call genesis init script in integration tests

//# run --signers creator
script{
use StarcoinFramework::StdlibUpgradeScripts;

fun main(){
StdlibUpgradeScripts::upgrade_from_v11_to_v12();
}
}
// check: EXECUTED
//# block --author 0x1 --timestamp 86200000

//# publish
module creator::DAOHelper {
use StarcoinFramework::DAOPluginMarketplace;
use StarcoinFramework::DAOAccount;
use StarcoinFramework::DAOSpace::{Self, CapType};
use StarcoinFramework::AnyMemberPlugin::{Self, AnyMemberPlugin};
use StarcoinFramework::InstallPluginProposalPlugin::{Self, InstallPluginProposalPlugin};
use StarcoinFramework::Vector;
use StarcoinFramework::STC;
use StarcoinFramework::Option;
use StarcoinFramework::Signer;
use StarcoinFramework::InstallPluginProposalPlugin::InstallPluginProposalPlugin;
use StarcoinFramework::AnyMemberPlugin::AnyMemberPlugin;
use StarcoinFramework::AnyMemberPlugin;
use StarcoinFramework::InstallPluginProposalPlugin;

struct X has store, copy, drop{}

Expand All @@ -45,8 +38,6 @@ module creator::DAOHelper {
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,
Expand All @@ -55,8 +46,8 @@ module creator::DAOHelper {
min_proposal_deposit,
);
let dao_root_cap = DAOSpace::create_dao<X>(dao_account_cap, *&NAME, Option::none<vector<u8>>(), Option::none<vector<u8>>(), 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, InstallPluginProposalPlugin>(&dao_root_cap, InstallPluginProposalPlugin::required_caps());
DAOSpace::install_plugin_with_root_cap<X, AnyMemberPlugin>(&dao_root_cap, AnyMemberPlugin::required_caps());

DAOSpace::install_plugin_with_root_cap<X, XPlugin>(&dao_root_cap, required_caps());
Expand Down Expand Up @@ -101,21 +92,15 @@ 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::grant_offer<X,XPlugin,STC::STC>(&grant_cap, Signer::address_of(sender), total, start_time, period);
DAOSpace::grant_accept_offer<X, XPlugin, STC::STC>(sender)
}

public fun grant_revoke(grantee:address){
let witness = XPlugin{};
let grant_cap = DAOSpace::acquire_grant_cap<X, XPlugin>(&witness);
DAOSpace::grant_revoke<X,XPlugin,STC::STC>(&grant_cap, grantee);
}

public fun grant_config(sender:&signer, grantee:address, total:u128, start_time:u64,period:u64){
let witness = XPlugin{};
let grant_cap = DAOSpace::acquire_grant_cap<X, XPlugin>(&witness);
DAOSpace::grant_config<X,XPlugin,STC::STC>(&grant_cap, grantee ,sender, total, start_time, period);

}
}

//# block --author 0x1 --timestamp 86400000
Expand All @@ -136,7 +121,7 @@ script{
//# run --signers alice
script{
use creator::DAOHelper::{Self, X, XPlugin};
use StarcoinFramework::DAOSpace::{query_grant, query_grant_can_withdraw};
use StarcoinFramework::DAOSpace::{query_grant, query_grant_withdrawable_amount};
use StarcoinFramework::DAOSpace;
use StarcoinFramework::STC;

Expand All @@ -149,15 +134,15 @@ script{
assert!(DAOSpace::query_grant_info_start_time(&grant_info) == 86400,1003);
assert!(DAOSpace::query_grant_info_period(&grant_info) == 3600,1004);

assert!(query_grant_can_withdraw<X, XPlugin, STC::STC>(@alice) == 0,1005);
assert!(query_grant_withdrawable_amount<X, XPlugin, STC::STC>(@alice) == 0,1005);
}
}
// check: EXECUTED

//# run --signers bob
script{
use creator::DAOHelper::{Self, X, XPlugin};
use StarcoinFramework::DAOSpace::{Self,query_grant, query_grant_can_withdraw, grant_withdraw};
use StarcoinFramework::DAOSpace::{Self,query_grant, query_grant_withdrawable_amount, grant_withdraw};
use StarcoinFramework::STC;
use StarcoinFramework::Account;

Expand All @@ -170,22 +155,20 @@ script{
assert!(DAOSpace::query_grant_info_start_time(&grant_info) == 86400,1007);
assert!(DAOSpace::query_grant_info_period(&grant_info) == 0,1008);

assert!(query_grant_can_withdraw<X, XPlugin, STC::STC>(@bob) == 1000000000,1009);
assert!(query_grant_withdrawable_amount<X, XPlugin, STC::STC>(@bob) == 1000000000,1009);

grant_withdraw<X, XPlugin, STC::STC>(&sender, 500000000u128);
assert!(Account::balance<STC::STC>(@bob) == 10000000000 + 500000000, 1010);

DAOHelper::grant_config(&sender, @bob, 500000000u128, 86400u64, 0u64);

let grant_info = query_grant<X, XPlugin, STC::STC>(@bob);
assert!(DAOSpace::query_grant_info_total(&grant_info) == 500000000,1011);
assert!(DAOSpace::query_grant_info_total(&grant_info) == 1000000000,1011);
assert!(DAOSpace::query_grant_info_withdraw(&grant_info)== 500000000,1012);
assert!(DAOSpace::query_grant_info_start_time(&grant_info) == 86400,1013);
assert!(DAOSpace::query_grant_info_period(&grant_info) == 0,1014);
assert!(query_grant_can_withdraw<X, XPlugin, STC::STC>(@bob) == 0,1015);
assert!(query_grant_withdrawable_amount<X, XPlugin, STC::STC>(@bob) == 500000000,1015);

DAOHelper::grant_revoke(@bob);
assert!(DAOSpace::is_have_grant<X, XPlugin, STC::STC>(@bob) == false, 1016);
assert!(DAOSpace::is_exist_grant<X, XPlugin, STC::STC>(@bob) == false, 1016);
}
}
// check: EXECUTED
Expand All @@ -195,12 +178,12 @@ script{
//# run --signers alice
script{
use creator::DAOHelper::{X, XPlugin};
use StarcoinFramework::DAOSpace::{Self, query_grant_can_withdraw};
use StarcoinFramework::DAOSpace::{Self, query_grant_withdrawable_amount};
use StarcoinFramework::STC;

//alice withdraw more grant
fun withdraw_grant(sender: signer){
assert!(query_grant_can_withdraw<X, XPlugin, STC::STC>(@alice) == 277777, 1001);
assert!(query_grant_withdrawable_amount<X, XPlugin, STC::STC>(@alice) == 277777, 1001);
DAOSpace::grant_withdraw<X, XPlugin, STC::STC>(&sender, 377777u128);
}
}
Expand All @@ -209,13 +192,13 @@ script{
//# run --signers alice
script{
use creator::DAOHelper::{X, XPlugin};
use StarcoinFramework::DAOSpace::{Self, query_grant, query_grant_can_withdraw};
use StarcoinFramework::DAOSpace::{Self, query_grant, query_grant_withdrawable_amount};
use StarcoinFramework::STC;
use StarcoinFramework::Account;

//alice withdraw grant
fun withdraw_grant(sender: signer){
assert!(query_grant_can_withdraw<X, XPlugin, STC::STC>(@alice) == 277777, 1001);
assert!(query_grant_withdrawable_amount<X, XPlugin, STC::STC>(@alice) == 277777, 1001);
let old_balance = Account::balance<STC::STC>(@alice);
DAOSpace::grant_withdraw<X, XPlugin, STC::STC>(&sender, 277777u128);
assert!(Account::balance<STC::STC>(@alice) == old_balance + 277777, 1002);
Expand All @@ -233,13 +216,13 @@ script{
//# run --signers alice
script{
use creator::DAOHelper::{X, XPlugin};
use StarcoinFramework::DAOSpace::{Self, query_grant, query_grant_can_withdraw};
use StarcoinFramework::DAOSpace::{Self, query_grant, query_grant_withdrawable_amount};
use StarcoinFramework::STC;
use StarcoinFramework::Account;

//alice withdraw grant
fun withdraw_grant(sender: signer){
assert!(query_grant_can_withdraw<X, XPlugin, STC::STC>(@alice) == 1000000000 - 277777, 1001);
assert!(query_grant_withdrawable_amount<X, XPlugin, STC::STC>(@alice) == 1000000000 - 277777, 1001);
let old_balance = Account::balance<STC::STC>(@alice);
DAOSpace::grant_withdraw<X, XPlugin, STC::STC>(&sender, 1000000000 - 277777);
assert!(Account::balance<STC::STC>(@alice) == old_balance + 1000000000 - 277777, 1002);
Expand All @@ -261,9 +244,9 @@ script{
//alice create grant to cindy
fun create_grant(sender: signer){
DAOHelper::create_grant(&sender, 1000000000u128, 90000u64, 3600u64);
assert!(DAOSpace::is_have_grant<X, XPlugin, STC::STC>(@cindy) == true, 1001);
assert!(DAOSpace::is_exist_grant<X, XPlugin, STC::STC>(@cindy) == true, 1001);
DAOSpace::refund_grant<X, XPlugin, STC::STC>(&sender);
assert!(DAOSpace::is_have_grant<X, XPlugin, STC::STC>(@cindy) == false, 1002);
assert!(DAOSpace::is_exist_grant<X, XPlugin, STC::STC>(@cindy) == false, 1002);
}
}
// check: EXECUTED
4 changes: 2 additions & 2 deletions integration-tests/daospace/dao_proposal.exp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ task 9 'run'. lines 187-212:

task 11 'run'. lines 217-233:
{
"gas_used": 239832,
"gas_used": 239249,
"status": "Executed"
}

task 12 'run'. lines 235-251:
{
"gas_used": 239832,
"gas_used": 239249,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_proposal.move
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module creator::DAOHelper {
public fun member_join<DAOT:store>(to_address: address, init_sbt: u128){
let witness = XPlugin{};
let member_cap = DAOSpace::acquire_member_cap<DAOT, XPlugin>(&witness);
DAOSpace::join_member<DAOT, XPlugin>(&member_cap, to_address, Option::none<vector<u8>>(), Option::none<vector<u8>>(), init_sbt);
DAOSpace::join_member_with_member_cap<DAOT, XPlugin>(&member_cap, to_address, Option::none<vector<u8>>(), Option::none<vector<u8>>(), init_sbt);
}

struct Checkpoint<phantom DAOt:store> has key{
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_proposal_rejected.move
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module creator::DAOHelper {
public fun member_join<DAOT:store>(to_address: address, init_sbt: u128){
let witness = XPlugin{};
let member_cap = DAOSpace::acquire_member_cap<DAOT, XPlugin>(&witness);
DAOSpace::join_member<DAOT, XPlugin>(&member_cap, to_address, Option::none<vector<u8>>(), Option::none<vector<u8>>(), init_sbt);
DAOSpace::join_member_with_member_cap<DAOT, XPlugin>(&member_cap, to_address, Option::none<vector<u8>>(), Option::none<vector<u8>>(), init_sbt);
}

struct Checkpoint<phantom DAOt:store> has key{
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/daospace/stake_to_sbt_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ task 5 'run'. lines 71-79:

task 6 'run'. lines 81-117:
{
"gas_used": 660592,
"gas_used": 848983,
"status": "Executed"
}

Expand Down Expand Up @@ -48,7 +48,7 @@ task 12 'run'. lines 169-182:

task 13 'run'. lines 184-200:
{
"gas_used": 544264,
"gas_used": 556931,
"status": "Executed"
}

Expand All @@ -60,7 +60,7 @@ task 15 'run'. lines 204-219:

task 16 'run'. lines 221-232:
{
"gas_used": 311827,
"gas_used": 500218,
"status": {
"MoveAbort": {
"location": {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospaceplugin/gas_oracle_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ task 7 'run'. lines 89-98:

task 9 'run'. lines 102-116:
{
"gas_used": 269638,
"gas_used": 269055,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospaceplugin/mint_proposal_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ task 11 'run'. lines 110-123:

task 12 'run'. lines 125-139:
{
"gas_used": 269638,
"gas_used": 269055,
"status": "Executed"
}

Expand Down
Loading