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

[dao] Implement DAOSpace #32

Merged
merged 35 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
03106a4
[genesis_dao] Implement GenesisDao
jolestar Jun 7, 2022
5d13575
Implement Proposal
jolestar Jun 21, 2022
e34ccee
Init MemberJoinPlugin
jolestar Jun 23, 2022
e94b12e
implement InstallPluginProposalPlugin
jolestar Jun 24, 2022
d52b8c7
update build
jolestar Jun 21, 2022
7d013e1
update build
jolestar Jun 24, 2022
4c3cd3b
Merge branch 'main' into genesis_dao
jolestar Jun 28, 2022
d0b5690
Implement DaoAccount and GenesisDao module (#46)
jolestar Jun 29, 2022
131c121
Update BuildInfo.yaml
jolestar Jun 29, 2022
b4870d9
merge Dao proposal and dao config into genesis dao base code (#47)
baichuan3 Jun 29, 2022
36242c8
Merge branch 'main' into genesis_dao
jolestar Jun 29, 2022
72173ab
Update BuildInfo.yaml
jolestar Jun 29, 2022
e3306a6
Genesis dao plugin (#49)
welbon Jul 1, 2022
fdddff4
Dao account test (#53)
jolestar Jul 5, 2022
6856141
Add member event (#55)
WGB5445 Jul 5, 2022
5bd7b61
Merge branch 'main' into genesis_dao
jolestar Jul 5, 2022
f081d2e
Dao proposal implement (#57)
baichuan3 Jul 6, 2022
8b60212
Genesis dao test (#59)
jolestar Jul 7, 2022
2737469
checkpoints temp Test (#62)
WGB5445 Jul 8, 2022
5f3df4a
Grant plugin (#61)
WGB5445 Jul 11, 2022
e1317dc
Add the plugin code that to convert token to SBT amount (#64)
welbon Jul 14, 2022
5cd8c0a
Dao proposal test (#66)
baichuan3 Jul 16, 2022
af63eff
Dao event and get vote info api (#69)
baichuan3 Jul 19, 2022
38c8d65
event associate with dao id (#71)
baichuan3 Jul 19, 2022
7ba5d10
Change some functions into Script methods and fix part of the logic (…
WGB5445 Jul 19, 2022
cd1002d
[ Other ] Rename DaoSpace (#72)
WGB5445 Jul 22, 2022
ea66229
Add Grant view and Grant refund (#73)
WGB5445 Jul 26, 2022
322f919
[lib] Refactor include source dir
jolestar Jul 26, 2022
e17525c
Fix stake SBT plugin from one stake to multiple stake
welbon Jul 26, 2022
4bc5d65
DAOSpace error code (#74)
jolestar Jul 26, 2022
2e9928a
[Feature and test]Add dao_grant test and query_grant_info_total (#76)
WGB5445 Jul 26, 2022
0d7b1f4
Fixed the problems in PR that relationship between SBT and the staked…
welbon Jul 27, 2022
5ca37d6
Add some integration test for StakeToSBTPlugin
welbon Jul 29, 2022
7e798f5
Add some integration test for StakeToSBTPlugin
welbon Jul 29, 2022
4116929
Rename Dao to DAO (#79)
jolestar Jul 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: Dao
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: DaoAccount
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: DaoRegistry
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: DaoVoteScripts
: StarcoinFramework
Expand Down Expand Up @@ -90,6 +96,9 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: Genesis
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: GenesisDao
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: GenesisNFT
: StarcoinFramework
Expand All @@ -108,12 +117,18 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: IdentifierNFTScripts
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: InstallPluginProposalPlugin
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: LanguageVersion
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: Math
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: MemberProposalPlugin
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: MerkleNFTDistributor
: StarcoinFramework
Expand Down Expand Up @@ -252,6 +267,12 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: Version
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: VoteUtil
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: XDao
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: YieldFarming
: StarcoinFramework
Expand Down
Binary file not shown.
Binary file not shown.
Binary file added build/StarcoinFramework/abis/XDao/create_dao.abi
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added build/StarcoinFramework/bytecode_modules/VoteUtil.mv
Binary file not shown.
Binary file added build/StarcoinFramework/bytecode_modules/XDao.mv
Binary file not shown.
290 changes: 290 additions & 0 deletions build/StarcoinFramework/docs/DaoAccount.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@

<a name="0x1_DaoAccount"></a>

# Module `0x1::DaoAccount`



- [Resource `DaoAccount`](#0x1_DaoAccount_DaoAccount)
- [Resource `DaoAccountCapability`](#0x1_DaoAccount_DaoAccountCapability)
- [Function `create_account`](#0x1_DaoAccount_create_account)
- [Function `create_account_entry`](#0x1_DaoAccount_create_account_entry)
- [Function `extract_dao_account_cap`](#0x1_DaoAccount_extract_dao_account_cap)
- [Function `upgrade_to_dao`](#0x1_DaoAccount_upgrade_to_dao)
- [Function `dao_signer`](#0x1_DaoAccount_dao_signer)
- [Function `submit_upgrade_plan`](#0x1_DaoAccount_submit_upgrade_plan)
- [Function `submit_upgrade_plan_entry`](#0x1_DaoAccount_submit_upgrade_plan_entry)


<pre><code><b>use</b> <a href="Account.md#0x1_Account">0x1::Account</a>;
<b>use</b> <a href="Option.md#0x1_Option">0x1::Option</a>;
<b>use</b> <a href="PackageTxnManager.md#0x1_PackageTxnManager">0x1::PackageTxnManager</a>;
<b>use</b> <a href="Signer.md#0x1_Signer">0x1::Signer</a>;
</code></pre>



<a name="0x1_DaoAccount_DaoAccount"></a>

## Resource `DaoAccount`

DaoAccount


<pre><code><b>struct</b> <a href="DaoAccount.md#0x1_DaoAccount">DaoAccount</a> <b>has</b> key
</code></pre>



<details>
<summary>Fields</summary>


<dl>
<dt>
<code>dao_address: <b>address</b></code>
</dt>
<dd>

</dd>
<dt>
<code>signer_cap: <a href="Account.md#0x1_Account_SignerCapability">Account::SignerCapability</a></code>
</dt>
<dd>

</dd>
</dl>


</details>

<a name="0x1_DaoAccount_DaoAccountCapability"></a>

## Resource `DaoAccountCapability`

This capability can control the Dao account


<pre><code><b>struct</b> <a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a> <b>has</b> store, key
</code></pre>



<details>
<summary>Fields</summary>


<dl>
<dt>
<code>dao_address: <b>address</b></code>
</dt>
<dd>

</dd>
</dl>


</details>

<a name="0x1_DaoAccount_create_account"></a>

## Function `create_account`

Create a new Dao Account and return DaoAccountCapability
Dao Account is a delegate account, the <code>creator</code> has the <code><a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a></code>


<pre><code><b>public</b> <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_create_account">create_account</a>(creator: &signer): <a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccount::DaoAccountCapability</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_create_account">create_account</a>(creator: &signer): <a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a> {
<b>let</b> (dao_address, signer_cap) = <a href="Account.md#0x1_Account_create_delegate_account">Account::create_delegate_account</a>(creator);
<b>let</b> dao_signer = <a href="Account.md#0x1_Account_create_signer_with_cap">Account::create_signer_with_cap</a>(&signer_cap);

<a href="PackageTxnManager.md#0x1_PackageTxnManager_update_module_upgrade_strategy">PackageTxnManager::update_module_upgrade_strategy</a>(&dao_signer, <a href="PackageTxnManager.md#0x1_PackageTxnManager_get_strategy_two_phase">PackageTxnManager::get_strategy_two_phase</a>(), <a href="Option.md#0x1_Option_some">Option::some</a>(0));
<b>move_to</b>(&dao_signer, <a href="DaoAccount.md#0x1_DaoAccount">DaoAccount</a>{
dao_address,
signer_cap: signer_cap,
});
<a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a>{
dao_address
}
}
</code></pre>



</details>

<a name="0x1_DaoAccount_create_account_entry"></a>

## Function `create_account_entry`

Entry function for create dao account, the <code><a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a></code> save to the <code>creator</code> account


<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_create_account_entry">create_account_entry</a>(sender: signer)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_create_account_entry">create_account_entry</a>(sender: signer){
<b>let</b> cap = <a href="DaoAccount.md#0x1_DaoAccount_create_account">create_account</a>(&sender);
<b>move_to</b>(&sender, cap);
}
</code></pre>



</details>

<a name="0x1_DaoAccount_extract_dao_account_cap"></a>

## Function `extract_dao_account_cap`



<pre><code><b>public</b> <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_extract_dao_account_cap">extract_dao_account_cap</a>(sender: &signer): <a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccount::DaoAccountCapability</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_extract_dao_account_cap">extract_dao_account_cap</a>(sender: &signer): <a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a> <b>acquires</b> <a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a>{
//TODO check
<b>move_from</b>&lt;<a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a>&gt;(<a href="Signer.md#0x1_Signer_address_of">Signer::address_of</a>(sender))
}
</code></pre>



</details>

<a name="0x1_DaoAccount_upgrade_to_dao"></a>

## Function `upgrade_to_dao`

Upgrade <code>sender</code> account to Dao account


<pre><code><b>public</b> <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_upgrade_to_dao">upgrade_to_dao</a>(sender: signer): <a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccount::DaoAccountCapability</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_upgrade_to_dao">upgrade_to_dao</a>(sender: signer): <a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a> {
//TODO <b>assert</b> sender not <a href="Dao.md#0x1_Dao">Dao</a>
<b>let</b> signer_cap = <a href="Account.md#0x1_Account_remove_signer_capability">Account::remove_signer_capability</a>(&sender);
//TODO check the account upgrade_strategy
<a href="PackageTxnManager.md#0x1_PackageTxnManager_update_module_upgrade_strategy">PackageTxnManager::update_module_upgrade_strategy</a>(&sender, <a href="PackageTxnManager.md#0x1_PackageTxnManager_get_strategy_two_phase">PackageTxnManager::get_strategy_two_phase</a>(), <a href="Option.md#0x1_Option_some">Option::some</a>(0));
<b>let</b> dao_address = <a href="Signer.md#0x1_Signer_address_of">Signer::address_of</a>(&sender);
<b>move_to</b>(&sender, <a href="DaoAccount.md#0x1_DaoAccount">DaoAccount</a>{
dao_address,
signer_cap: signer_cap,
});
<a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a>{
dao_address
}
}
</code></pre>



</details>

<a name="0x1_DaoAccount_dao_signer"></a>

## Function `dao_signer`

Provide a function to create signer with <code><a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a></code>


<pre><code><b>public</b> <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_dao_signer">dao_signer</a>(cap: &<a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccount::DaoAccountCapability</a>): signer
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_dao_signer">dao_signer</a>(cap: &<a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a>): signer <b>acquires</b> <a href="DaoAccount.md#0x1_DaoAccount">DaoAccount</a> {
<b>let</b> signer_cap = &<b>borrow_global</b>&lt;<a href="DaoAccount.md#0x1_DaoAccount">DaoAccount</a>&gt;(cap.dao_address).signer_cap;
<a href="Account.md#0x1_Account_create_signer_with_cap">Account::create_signer_with_cap</a>(signer_cap)
}
</code></pre>



</details>

<a name="0x1_DaoAccount_submit_upgrade_plan"></a>

## Function `submit_upgrade_plan`

Sumbit upgrade plan for the Dao account
This function is a shortcut for create signer with DaoAccountCapability and invoke <code><a href="PackageTxnManager.md#0x1_PackageTxnManager_submit_upgrade_plan_v2">PackageTxnManager::submit_upgrade_plan_v2</a></code>


<pre><code><b>public</b> <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_submit_upgrade_plan">submit_upgrade_plan</a>(cap: &<a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccount::DaoAccountCapability</a>, package_hash: vector&lt;u8&gt;, version: u64, enforced: bool)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_submit_upgrade_plan">submit_upgrade_plan</a>(cap: &<a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a>, package_hash: vector&lt;u8&gt;, version:u64, enforced: bool) <b>acquires</b> <a href="DaoAccount.md#0x1_DaoAccount">DaoAccount</a>{
<b>let</b> dao_signer = <a href="DaoAccount.md#0x1_DaoAccount_dao_signer">dao_signer</a>(cap);
<a href="PackageTxnManager.md#0x1_PackageTxnManager_submit_upgrade_plan_v2">PackageTxnManager::submit_upgrade_plan_v2</a>(&dao_signer, package_hash, version, enforced);
}
</code></pre>



</details>

<a name="0x1_DaoAccount_submit_upgrade_plan_entry"></a>

## Function `submit_upgrade_plan_entry`

Sumbit upgrade plan for the Dao account, sender must hold the <code><a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a></code>


<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_submit_upgrade_plan_entry">submit_upgrade_plan_entry</a>(sender: signer, package_hash: vector&lt;u8&gt;, version: u64, enforced: bool)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="DaoAccount.md#0x1_DaoAccount_submit_upgrade_plan_entry">submit_upgrade_plan_entry</a>(sender: signer, package_hash: vector&lt;u8&gt;, version:u64, enforced: bool) <b>acquires</b> <a href="DaoAccount.md#0x1_DaoAccount">DaoAccount</a>, <a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a>{
<b>let</b> addr = <a href="Signer.md#0x1_Signer_address_of">Signer::address_of</a>(&sender);
<b>let</b> cap = <b>borrow_global</b>&lt;<a href="DaoAccount.md#0x1_DaoAccount_DaoAccountCapability">DaoAccountCapability</a>&gt;(addr);
<a href="DaoAccount.md#0x1_DaoAccount_submit_upgrade_plan">submit_upgrade_plan</a>(cap, package_hash, version, enforced)
}
</code></pre>



</details>