Skip to content

Commit

Permalink
feat(frontend): implement grant and claim proposal pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman-zishan committed Dec 13, 2023
1 parent 5f25112 commit 4c1539f
Show file tree
Hide file tree
Showing 13 changed files with 723 additions and 33 deletions.
Binary file added 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 added 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.
95 changes: 95 additions & 0 deletions deployments/default.devnet-plan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
id: 0
name: Devnet deployment
network: devnet
stacks-node: "http://localhost:20443"
bitcoin-node: "http://devnet:devnet@localhost:18443"
plan:
batches:
- id: 0
transactions:
- contract-publish:
contract-name: extension-trait
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 1670
path: contracts/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
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: core
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 22660
path: contracts/core.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: membership-token
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 17200
path: contracts/membership-token.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: bootstrap
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 15470
path: contracts/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
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
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: grant-proposal
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 9270
path: contracts/grant-proposal.clar
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: hello-world
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 12460
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
anchor-block-only: true
clarity-version: 2
- contract-publish:
contract-name: proposal-voting
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
cost: 37540
path: contracts/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
anchor-block-only: true
clarity-version: 2
epoch: "2.1"
46 changes: 23 additions & 23 deletions history.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
#V2
(stx-get-balance tx-sender)
(stx-transfer? u1000000000000 tx-sender .core)
::get_asset_map
::get_asset_maps
::get_assets_maps
(contract-call? .core construct .bootstrap)
(as-contract stx-get-balance .core)
(as-contract (stx-get-balance .core))
(stx-get-balance .core)
(stx-transfer? u1000000000000 tx-sender .core)
(contract-call? .core construct .bootstrap)
::get_assets_maps
(contract-call? .proposal-submission propose .milestone-extension-proposal)
(contract-call? .proposal-submission propose .milestone-extension-proposal "extension for milestone based funding" "same as title")
(contract-call? .proposal-submission propose .milestone-extension-proposal "extension for milestone based funding" same as title)
(contract-call? .proposal-submission propose .milestone-extension-proposal u"extension for milestone based funding" u"same as title")
(contract-call? .proposal-submission propose .milestone-extension-proposal "extension for milestone based funding" u"same as title")
(contract-call? .proposal-voting vote u100 true .milestone-extension-proposal)
::get_assets_maps
(contract-call? .proposal-voting conclude .milestone-extension-proposal)
::advance_chain_tip 1440
(contract-call? .proposal-voting conclude .milestone-extension-proposal)
(stx-transfer? u1000000000000 tx-sender .core)
(contract-call? .core construct .bootstrap)
(contract-call? .proposal-submission propose .milestone-extension-proposal "extension for milestone based funding" u"same as title")
::advance_chain_tip 1440
Expand Down Expand Up @@ -99,3 +76,26 @@ block_height
(contract-call? .proposal-voting vote u100 true .grant-milestone-claim-proposal)
::advance_chain_tip 1440
(contract-call? .proposal-voting conclude .grant-milestone-claim-proposal)
(stx-transfer? u1000000000000 tx-sender .core)
(contract-call? .core construct .bootstrap)
(contract-call? .proposal-submission propose .milestone-extension-proposal)
(contract-call? .proposal-submission propose .milestone-extension-proposal "extension for milestone based funding" u"same as title")
(contract-call? .proposal-voting vote u100 true .milestone-extension-proposal)
::advance_chain_tip 1440
(contract-call? .proposal-voting conclude .milestone-extension-proposal)
::get_assets_maps
(contract-call? .proposal-submission propose .grant-proposal "friend.tech grant" u"a clone social media app")
(contract-call? .proposal-voting vote u100 true .grant-proposal)
(contract-call? .grant-proposal get-milestones ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.grant-proposal)\n
(contract-call? .milestone-extension get-milestones ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.grant-proposal)\n
(contract-call? .milestone-extension get-milestones 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.grant-proposal)\n
::advance_chain_tip 1440
(contract-call? .proposal-voting conclude .grant-proposal)
(contract-call? .milestone-extension get-milestones 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.grant-proposal)\n
(contract-call? .proposal-submission propose .grant-milestone-claim-proposal "test grant claim proposal" u"same as title")\n
::get_block_height
(contract-call? .milestone-extension get-milestones 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.grant-proposal)\n
::advance_chain_tip 14400
(contract-call? .proposal-voting vote u100 true .grant-milestone-claim-proposal)
(contract-call? .proposal-voting conclude .grant-milestone-claim-proposal)
::get_assets_maps
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"license": "ISC",
"dependencies": {
"@hirosystems/clarinet-sdk": "^1.1.0",
"@micro-stacks/react": "^1.0.9",
"@monaco-editor/react": "^4.6.0",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
Expand All @@ -26,14 +28,15 @@
"@stacks/encryption": "^6.9.0",
"@stacks/network": "^6.8.1",
"@stacks/transactions": "^6.9.0",
"chokidar-cli": "^3.0.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"lucide-react": "^0.294.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sonner": "^1.2.4",
"tailwind-merge": "^2.0.0",
"tailwindcss-animate": "^1.0.7",
"chokidar-cli": "^3.0.0"
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@commitlint/cli": "^17.4.3",
Expand Down
76 changes: 76 additions & 0 deletions src/components/codeEditor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React, { useEffect } from 'react';
import { Editor, loader } from '@monaco-editor/react';

const CodeEditor = ({ onCodeChange }: 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) {
onCodeChange(value); // Call the passed callback function with the current code value
}
}

// Function to define Clarity language
const defineClarityLanguage = (monaco) => {
monaco.languages.register({ id: 'clarity' });

monaco.languages.setMonarchTokensProvider('clarity', {
tokenizer: {
root: [
// Comments
[/(;;.*$)/, 'comment'],

// Strings
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' }],

// 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/,
'keyword'
],

// Numbers - Clarity supports both signed and unsigned integers
[/\bu?[0-9]+/, 'number'],

// Brackets and Parentheses
[/[{}()[\]]/, '@brackets'],

// Operators
[/[=<>!+\-*/%]/, 'operator']
],

string: [
[/[^"]+/, 'string'],
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
]
}
});
};

useEffect(() => {
loader.init().then((monaco) => {
defineClarityLanguage(monaco);
});
}, []);

return (
<Editor
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))
)
)"
onChange={handleEditorChange}
/>
);
};

export default CodeEditor;
59 changes: 59 additions & 0 deletions src/components/leftMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import { NavLink, useParams } from 'react-router-dom';
import { SVGComponent } from './stacksSvg';

import { WalletConnectButton } from './walletConnect';
import { useAccount } from '@micro-stacks/react';

// eslint-disable-next-line @typescript-eslint/no-explicit-any

const LeftMenu = () => {
const { stxAddress } = useAccount();

Check warning on line 11 in src/components/leftMenu.tsx

View workflow job for this annotation

GitHub Actions / Lint

'stxAddress' is assigned a value but never used
const { slug } = useParams();

Check warning on line 12 in src/components/leftMenu.tsx

View workflow job for this annotation

GitHub Actions / Lint

'slug' is assigned a value but never used
const getNavLinkClass = ({ isActive }: any) => {

Check warning on line 13 in src/components/leftMenu.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
return isActive
? 'flex items-center gap-5 bg-blue-500 rounded-xl font-bold text-md text-white py-3 px-4'
: 'flex items-center gap-5 bg-white hover:bg-blue-50 rounded-xl font-bold text-md text-gray-900 py-3 px-4';
};
return (
<aside className="fixed inset-y-0 left-0 bg-white shadow-md w-80 h-screen">
<div className="flex flex-col justify-between h-full">
<div className="flex-grow">
<div className="px-4 py-6 text-center border-b flex flex-row items-center justify-center gap-2">
<SVGComponent />
<h1 className="text-xl font-normal leading-none">
<span className="text-blue-500">s</span>DAO
</h1>
</div>
<div className="p-4">
<ul className="space-y-5">
{/* <li>
<NavLink to={'/home'} className={getNavLinkClass}>
<img src="../assets/home.png" alt="" width={50} />
Home
</NavLink>
</li> */}
<li>
<NavLink to={'/new-proposal'} className={getNavLinkClass}>
<img src="../assets/proposal.png" alt="" width={50} />
New grant proposal
</NavLink>
</li>
<li>
<NavLink to={'/claim'} className={getNavLinkClass}>
<img src="../assets/claim.png" alt="" width={50} />
Claim milestones
</NavLink>
</li>
</ul>
</div>
</div>
<div className="p-10 pb-25">
<WalletConnectButton />
</div>
</div>
</aside>
);
};

export default LeftMenu;
34 changes: 34 additions & 0 deletions src/components/stacksSvg.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';

export const SVGComponent = (props: any) => (

Check warning on line 3 in src/components/stacksSvg.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
<svg
id="Layer_1"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
viewBox="0 0 25 25"
style={{
enableBackground: 'new 0 0 159.8 159.8'
}}
xmlSpace="preserve"
width={25}
height={25}
{...props}
>
<style type="text/css">
{'.st0{fill:#5546FF;}\n\t.st1{fill:#FFFFFF;}'}
</style>
<path
className="st0"
cx={79.9}
cy={79.9}
r={79.9}
d="M25 12.5a12.5 12.5 0 0 1 -12.5 12.5A12.5 12.5 0 0 1 0 12.5a12.5 12.5 0 0 1 25 0z"
/>
<path
className="st1"
d="m17.6 19.087 -2.691 -4.224h3.864v-1.596H6.101v1.596h3.864l-2.691 4.224h2.002l3.16 -4.96 3.16 4.96H17.6zm1.173 -7.369v-1.596h-3.786l2.659 -4.177h-2.018l-3.192 5.037 -3.192 -5.037h-2.018l2.659 4.177h-3.786v1.611l12.672 -0.015z"
/>
</svg>
);
21 changes: 21 additions & 0 deletions src/components/walletConnect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useAuth } from '@micro-stacks/react';
import React from 'react';

export const WalletConnectButton = () => {
const { openAuthRequest, isRequestPending, signOut, isSignedIn } = useAuth();
const label = isRequestPending
? 'Loading...'
: isSignedIn
? 'Sign out'
: 'Connect Stacks wallet';
return (
<button
onClick={async () => {
if (isSignedIn) await signOut();
else await openAuthRequest();
}}
>
{label}
</button>
);
};
Loading

0 comments on commit 4c1539f

Please sign in to comment.