Skip to content

Commit

Permalink
feat(bootstrap-function): deployer can bootstrap dao from frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman-zishan committed Dec 13, 2023
1 parent 4c1539f commit 1b2a642
Show file tree
Hide file tree
Showing 32 changed files with 739 additions and 219 deletions.
20 changes: 10 additions & 10 deletions Clarinet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ telemetry = true
cache_dir = './.cache'
requirements = []
[contracts.bootstrap]
path = 'contracts/bootstrap.clar'
path = 'contracts/proposals/bootstrap.clar'
clarity_version = 2
epoch = 2.1

Expand All @@ -16,17 +16,17 @@ clarity_version = 2
epoch = 2.1

[contracts.extension-trait]
path = 'contracts/extension-trait.clar'
path = 'contracts/traits/extension-trait.clar'
clarity_version = 2
epoch = 2.1

[contracts.grant-milestone-claim-proposal]
path = 'contracts/grant-milestone-claim-proposal.clar'
path = 'contracts/proposals/grant-milestone-claim-proposal.clar'
clarity_version = 2
epoch = 2.1

[contracts.grant-proposal]
path = 'contracts/grant-proposal.clar'
path = 'contracts/proposals/grant-proposal.clar'
clarity_version = 2
epoch = 2.1

Expand All @@ -36,32 +36,32 @@ clarity_version = 2
epoch = 2.1

[contracts.membership-token]
path = 'contracts/membership-token.clar'
path = 'contracts/extensions/membership-token.clar'
clarity_version = 2
epoch = 2.1

[contracts.milestone-extension]
path = 'contracts/milestone-extension.clar'
path = 'contracts/extensions/milestone-extension.clar'
clarity_version = 2
epoch = 2.1

[contracts.milestone-extension-proposal]
path = 'contracts/milestone-extension-proposal.clar'
path = 'contracts/proposals/milestone-extension-proposal.clar'
clarity_version = 2
epoch = 2.1

[contracts.proposal-submission]
path = 'contracts/proposal-submission.clar'
path = 'contracts/extensions/proposal-submission.clar'
clarity_version = 2
epoch = 2.1

[contracts.proposal-trait]
path = 'contracts/proposal-trait.clar'
path = 'contracts/traits/proposal-trait.clar'
clarity_version = 2
epoch = 2.1

[contracts.proposal-voting]
path = 'contracts/proposal-voting.clar'
path = 'contracts/extensions/proposal-voting.clar'
clarity_version = 2
epoch = 2.1

Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,33 @@ To get the application running, follow these steps:
3. Install the dependencies: `yarn install`
4. Start the development server: `yarn dev`

fund the core contract with 1M STX
### fund the core contract with 1M STX

(stx-transfer? u1000000000000 tx-sender .core)

bootstrap core contract
### bootstrap core contract

(contract-call? .core construct .bootstrap)

### propose milestone extension
(contract-call? .proposal-submission propose .milestone-extension-proposal "extension for milestone based funding" u"same as title")

### vote for milestone proposal
(contract-call? .proposal-voting vote u100 true .milestone-extension-proposal)

### advance chain tip by proposal time
::advance_chain_tip 1440

### conclude proposal
(contract-call? .proposal-voting conclude .milestone-extension-proposal)

### propose grant
(contract-call? .proposal-submission propose .grant-proposal "test grant proposal" u"same as title")

### vote for grant proposal
(contract-call? .proposal-voting vote u100 true .grant-proposal)

::advance_chain_tip 1440

### conclude grant proposal
(contract-call? .proposal-voting conclude .grant-proposal)
Binary file added assets/SGT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/bootstrap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/claim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/proposal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/proposals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
;;
(define-map parameters (string-ascii 34) uint)

(map-set parameters "proposal-duration" u1440) ;; ~10 days based on a ~10 minute block time.
;; VERY_IMPORTANT: this is a test value and ideally the proposal-duration could be u1440 ~10 days (10 minutes per block)
(map-set parameters "proposal-duration" u1) ;; 1 block ~ 10 minutes (for testing)


;; public functions
;;
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions contracts/hello-world.clar
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
;; onchain testing ground
(define-map grants
principal
{ milestones: (list 10 { id: uint, start-height: uint, end-height: uint, amount: uint }) }
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

;; traits
;;
(impl-trait .proposal-trait.proposal-trait)


;; token definitions
;;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

;; traits
;;

(define-trait proposal-trait
(
(execute (principal) (response bool uint))
Expand Down
28 changes: 14 additions & 14 deletions deployments/default.devnet-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ plan:
contract-name: extension-trait
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 1670
path: contracts/extension-trait.clar
path: contracts/traits/extension-trait.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: proposal-trait
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 1680
path: contracts/proposal-trait.clar
cost: 1670
path: contracts/traits/proposal-trait.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
Expand All @@ -33,63 +33,63 @@ plan:
contract-name: membership-token
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 17200
path: contracts/membership-token.clar
path: contracts/extensions/membership-token.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: bootstrap
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 15470
path: contracts/bootstrap.clar
path: contracts/proposals/bootstrap.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: milestone-extension
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 26090
path: contracts/milestone-extension.clar
path: contracts/extensions/milestone-extension.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: grant-milestone-claim-proposal
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 4540
path: contracts/grant-milestone-claim-proposal.clar
cost: 4990
path: contracts/proposals/grant-milestone-claim-proposal.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: grant-proposal
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 9270
path: contracts/grant-proposal.clar
path: contracts/proposals/grant-proposal.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: hello-world
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 12460
cost: 12720
path: contracts/hello-world.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: milestone-extension-proposal
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 7600
path: contracts/milestone-extension-proposal.clar
path: contracts/proposals/milestone-extension-proposal.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: proposal-voting
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 37540
path: contracts/proposal-voting.clar
path: contracts/extensions/proposal-voting.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: proposal-submission
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 16350
path: contracts/proposal-submission.clar
cost: 17470
path: contracts/extensions/proposal-submission.clar
anchor-block-only: true
clarity-version: 2
epoch: "2.1"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"chokidar-cli": "^3.0.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jotai": "^2.6.0",
"lucide-react": "^0.294.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
16 changes: 3 additions & 13 deletions src/components/codeEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import { Editor, loader } from '@monaco-editor/react';

const CodeEditor = ({ onCodeChange }: any) => {
const CodeEditor = ({ onCodeChange, initialCode }: any) => {

Check warning on line 4 in src/components/codeEditor.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
function handleEditorChange(value, event) {

Check warning on line 5 in src/components/codeEditor.tsx

View workflow job for this annotation

GitHub Actions / Lint

'event' is defined but never used
console.log('here is the current model value:', value);
if (onCodeChange) {
Expand All @@ -24,7 +24,7 @@ const CodeEditor = ({ onCodeChange }: any) => {

// Keywords
[
/\b(define-data-var|define-public|define-private|define-read-only|define-constant|begin|let|if|map-set|map-get\?|and|or|not|is-eq|unwrap-panic|unwrap-err-panic|unwrap-err!|unwrap!|asserts!|try!|ok|err)\b/,
/\b(contract-call?|impl-trait|define-data-var|define-public|define-private|define-read-only|define-constant|begin|let|if|map-set|map-get\?|and|or|not|is-eq|unwrap-panic|unwrap-err-panic|unwrap-err!|unwrap!|asserts!|try!|ok|err)\b/,
'keyword'
],

Expand Down Expand Up @@ -57,17 +57,7 @@ const CodeEditor = ({ onCodeChange }: any) => {
height="50vh"
theme="vs-dark"
defaultLanguage="clarity" // Set to use the custom Clarity language
defaultValue="(define-data-var count int 0)
(define-public (add-number (number int))
(let
(
(current-count count)
)
(var-set count (+ 1 number))
(ok (var-get count))
)
)"
defaultValue={initialCode}
onChange={handleEditorChange}
/>
);
Expand Down
14 changes: 14 additions & 0 deletions src/components/leftMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const LeftMenu = () => {
Home
</NavLink>
</li> */}
<li>
<NavLink to={'/my-proposals'} className={getNavLinkClass}>
<img src="../assets/proposals.png" alt="" width={50} />
My proposals
</NavLink>
</li>
<li>
<NavLink to={'/new-proposal'} className={getNavLinkClass}>
<img src="../assets/proposal.png" alt="" width={50} />
Expand All @@ -45,6 +51,14 @@ const LeftMenu = () => {
Claim milestones
</NavLink>
</li>
{stxAddress === 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM' && (
<li>
<NavLink to={'/bootstrap'} className={getNavLinkClass}>
<img src="../assets/bootstrap.png" alt="" width={50} />
Bootstrap DAO
</NavLink>
</li>
)}
</ul>
</div>
</div>
Expand Down
Loading

0 comments on commit 1b2a642

Please sign in to comment.