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

able to update DAOExt #108

Merged
merged 5 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -306,7 +306,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: 695F4208154FB109E223367B79D9AD3C30261C91BF6F595A3B9D2226BC5103B0
source_digest: 044435CA877E6DB9C971033C081A138460D02E8687360DB4EAB1BF235AF9DD58
build_flags:
dev_mode: false
test_mode: false
Expand Down
17 changes: 16 additions & 1 deletion sources/daospace/DAOSpace.move
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module StarcoinFramework::DAOSpace {
const ERR_NFT_ERROR: u64 = 104;
const ERR_ALREADY_INIT: u64 = 105;
const ERR_TOKEN_ERROR: u64 = 106;
const ERR_DAO_EXT: u64 = 107;

/// member
const ERR_EXPECT_MEMBER: u64 = 200;
Expand Down Expand Up @@ -340,7 +341,21 @@ module StarcoinFramework::DAOSpace {
DAORootCap<DAOT>{}
}

// Upgrade account to DAO account and create DAO
/// Update DAOExt with new ext and return the old one.
public fun update_dao_ext_with_root_cap<DAOT: store>(_cap: &DAORootCap<DAOT>, ext: DAOT): DAOT
pause125 marked this conversation as resolved.
Show resolved Hide resolved
acquires DAOAccountCapHolder, DAOExt {
let dao_addr = dao_address<DAOT>();
assert!(exists<DAOExt<DAOT>>(dao_addr), Errors::not_published(ERR_DAO_EXT));
let DAOExt { ext: old_ext } = move_from<DAOExt<DAOT>>(dao_addr);

let dao_signer = dao_signer<DAOT>();
move_to(&dao_signer, DAOExt{
ext
});
old_ext
}

/// Upgrade account to DAO account and create DAO
public fun upgrade_to_dao<DAOT: store>(sender: signer, name: vector<u8>, image_data:Option::Option<vector<u8>>, image_url:Option::Option<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, image_data, image_url, description, ext, config)
Expand Down