- 
                Notifications
    
You must be signed in to change notification settings  - Fork 9
 
feat: psp22 Dao_example0 #422
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
          
     Open
      
      
            ndkazu
  wants to merge
  60
  commits into
  r0gue-io:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
ndkazu:psp_example0
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 58 commits
      Commits
    
    
            Show all changes
          
          
            60 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      d8f3c22
              
                Dao contract
              
              
                ndkazu 5cbb44a
              
                Added some events
              
              
                ndkazu bb060f1
              
                removed absent module
              
              
                ndkazu 30637ae
              
                Added some in-code documentation
              
              
                ndkazu e6c9edd
              
                Corrected index error
              
              
                ndkazu 058e53b
              
                Problem with first test
              
              
                ndkazu ff2b300
              
                Making sense of pop-drink for testing
              
              
                ndkazu 2505f89
              
                Added lib.rs to Cargo, but still...
              
              
                ndkazu 6f653a9
              
                Added the correct deploy() function in tests
              
              
                ndkazu aacbf87
              
                Put a limitation of description string length
              
              
                ndkazu f746400
              
                chore: add missing authors
              
              
                chungquantin 285c178
              
                new member test added
              
              
                ndkazu 34002d0
              
                create_proposal test
              
              
                ndkazu d17096c
              
                Calls prepared for testing
              
              
                ndkazu 3f2c114
              
                ReadMe
              
              
                ndkazu 22d46e3
              
                ReadME
              
              
                ndkazu b02f232
              
                create_proposal_test
              
              
                ndkazu c08b335
              
                Another test
              
              
                ndkazu 7a1563b
              
                Enactment test
              
              
                ndkazu 9eca1b2
              
                 one more test
              
              
                ndkazu b0d6194
              
                Reverted some changes
              
              
                ndkazu f8910ce
              
                Reverted some changes
              
              
                ndkazu 94d884e
              
                Documented the failing test: proposal_enactment_works
              
              
                ndkazu 00d76c0
              
                Another test...
              
              
                ndkazu 8de7a7d
              
                tests
              
              
                ndkazu 5e91679
              
                refactored the code & added another test
              
              
                ndkazu 77328df
              
                Treasury balance check & another test
              
              
                ndkazu a8206d4
              
                Another test
              
              
                ndkazu 56e622d
              
                cargo fmt
              
              
                ndkazu 4ad34f4
              
                Final test
              
              
                ndkazu 0cd9573
              
                Applied some fixes related to the code review
              
              
                ndkazu be3759f
              
                Added ProposalStatus enum
              
              
                ndkazu a34f0d1
              
                Added descriptions for errors
              
              
                ndkazu 5e8e8e4
              
                Review correction
              
              
                ndkazu ede1283
              
                cargo clippy
              
              
                ndkazu 425d757
              
                Merge branch 'r0gue-io:main' into psp22Example
              
              
                ndkazu 0e2db17
              
                update ink version
              
              
                ndkazu 21b13c5
              
                cargo clippy --fix
              
              
                ndkazu 34ba35c
              
                Some clean up
              
              
                ndkazu bd11e86
              
                All tests pass
              
              
                ndkazu 905705c
              
                cargo fmt
              
              
                ndkazu 0841c32
              
                Refactored code, implemented Default trait for Proposal
              
              
                ndkazu 562b17f
              
                cargo fmt
              
              
                ndkazu eaae705
              
                Preparations for use of RuntimeCall
              
              
                ndkazu adb72f9
              
                Use transfer_from instead of transfer for runtime_call
              
              
                ndkazu 290d0ec
              
                Corrected test mistake, using transfer_from instead of transfer
              
              
                ndkazu bad1126
              
                RuntimeCall working
              
              
                ndkazu 32ecca5
              
                Corrections
              
              
                ndkazu c357a07
              
                Code re-factoring
              
              
                ndkazu c0f9f9d
              
                RuntimeCall conversion problem
              
              
                ndkazu 2526c04
              
                customised RuntimeCalls works
              
              
                ndkazu a7e3084
              
                Option_1
              
              
                ndkazu 2f717a2
              
                Update tests.rs
              
              
                ndkazu 08a61a0
              
                Update Cargo.toml
              
              
                ndkazu 95ccd0f
              
                Update README.md
              
              
                ndkazu 2e194e6
              
                Update README.md
              
              
                ndkazu 25355d9
              
                Merge branch 'main' into psp_example0
              
              
                ndkazu d4ba764
              
                Applied corrections
              
              
                ndkazu c2a7d7c
              
                Starting correction
              
              
                ndkazu b7f1016
              
                Merge branch 'r0gue-io:main' into psp_example0
              
              
                ndkazu File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| [package] | ||
| authors = ["R0GUE <[email protected]>"] | ||
| edition = "2021" | ||
| name = "dao" | ||
| version = "0.1.0" | ||
| 
     | 
||
| [dependencies] | ||
| ink = { version = "5.1.0", default-features = false, features = ["ink-debug"] } | ||
| pop-api = { path = "../../../pop-api", default-features = false, features = [ | ||
| "fungibles", | ||
| ] } | ||
| 
     | 
||
| [dev-dependencies] | ||
| drink = { package = "pop-drink", git = "https://github.com/r0gue-io/pop-drink" } | ||
| env_logger = { version = "0.11.3" } | ||
| serde_json = "1.0.114" | ||
| 
     | 
||
| [lib] | ||
| path = "src/lib.rs" | ||
| 
     | 
||
| [features] | ||
| default = ["std"] | ||
| e2e-tests = [] | ||
| ink-as-dependency = [] | ||
| std = [ | ||
| "ink/std", | ||
| "pop-api/std", | ||
| ] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Simple PSP22 DAO contract example | ||
| This contract implements a Decentralized Autonomous Organization with token-based voting system built with Pop API. Members can submit a funding proposal, vote for or against it, and enact funds transfer. | ||
                
      
                  ndkazu marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| ## Description | ||
| This contract implements a Decentralized Autonomous Organization using Psp22. | ||
| The objectivbe of this DAO is to allow its members to vote for funding of projects they would like to see developped. | ||
| To become a member, a user needs to pay some amount of the Dao_token to the Dao Treasury(Dao_tokens obtained through airdrops or token purchase...) ⇒ The subscription payment becomes the Member voting_power. | ||
| Approved projects are funded by the Dao Treasury. | ||
| The key functionalities include: | ||
| - **Membership Management**: It maintains a registry of DAO members. | ||
| - **Proposal Lifecycle**: The contract manages the creation, voting, and execution of proposals. Each proposal includes details like description, voting period, vote tallies, execution status, beneficiary, and amount to be awarded. | ||
| - **Voting Mechanism**: It implements a voting system where members can vote with their balance on proposals. The contract tracks voting periods and maintains vote counts for each proposal. | ||
| - **Token Integration**: The Pop API is used to create and manage the DAO token. | ||
| - **Governance Parameters**: governance parameters such as voting periods are customizable. | ||
| - **Vote Tracking**: The contract keeps track of when members last voted. | ||
| - **Proposal Execution**: Once a proposal's voting period ends and passes, the contract handles its execution: transferring funds to the chosen beneficiary. | ||
| 
     | 
||
| 
     | 
||
| ## Dao Workflow | ||
| - **Subscription**: The first step is membership: users use their funds* to join the Dao, become members, and determine their voting power, as membership gives them the right to vote on the use of the Dao Treasury. | ||
| - **Proposal**: Dao members can create spending proposals for the treasury. At the moment, the voting period for the proposal is given by the proposal creator, but this could be a Dao parameter, determined by the creator of the Dao contract. | ||
| - **Vote**: Members of the Dao can vote for or against a given proposal, through the selection of the corresponding proposal ID. The vote has to be cast within the voting period of the selected proposal. | ||
| - **Proposal enactment**: After the end of the voting period, If the proposal has been accepted by the Dao Members, the proposal can be enacted, i.e. funds can be claimed/transferred to the account specified as the beneficiary in the proposal. Any member can claim the reward for the winning proposal. | ||
| 
     | 
||
| *It is assumed that after Dao & associated token creation, potential members own the Dao Token through airdrop, token purchase, etc... (These mechanisms are not part of the contract). | ||
| 
     | 
||
| ### Flowchart | ||
                
      
                  ndkazu marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| ```mermaid | ||
| flowchart LR | ||
| A[Subscriber A] -->|Joins DAO| M[Membership Process] | ||
| B[Subscriber B] -->|Joins DAO| M | ||
| C[Subscriber C] -->|Joins DAO| M | ||
| D[Subscriber D] -->|Joins DAO| M | ||
| M --> E[Subscriber B creates Proposal] | ||
| E --> F[Voting Process] | ||
| F -->|Votes by| G[Subscribers A, C, D] | ||
| G --> H{Proposal Accepted?} | ||
| H -- Yes --> I[Proposal Enactment] | ||
| H -- No --> J[End of Process] | ||
| I --> K[Subscriber A claims reward for proposal's beneficiary] | ||
| K --> L[Funds transferred to beneficiary] | ||
| 
     | 
||
| style A fill:#f9f,stroke:#333,stroke-width:2px | ||
| style B fill:#f9f,stroke:#333,stroke-width:2px | ||
| style C fill:#f9f,stroke:#333,stroke-width:2px | ||
| style D fill:#f9f,stroke:#333,stroke-width:2px | ||
| style M fill:#bbf,stroke:#333,stroke-width:2px | ||
| style E fill:#bbf,stroke:#333,stroke-width:2px | ||
| style F fill:#bbf,stroke:#333,stroke-width:2px | ||
| style G fill:#bbf,stroke:#333,stroke-width:2px | ||
| style H fill:#ff0,stroke:#333,stroke-width:2px | ||
| style I fill:#bfb,stroke:#333,stroke-width:2px | ||
| style J fill:#f99,stroke:#333,stroke-width:2px | ||
| style K fill:#bfb,stroke:#333,stroke-width:2px | ||
| style L fill:#bfb,stroke:#333,stroke-width:2px | ||
| ``` | ||
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.