-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from YoubetDao/feat/support-donate-and-reward
feat: support donation and reward distribution
- Loading branch information
Showing
14 changed files
with
547 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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
27 changes: 27 additions & 0 deletions
27
examples/simple-react/src/components/sections/AllProjects.tsx
This file contains 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,27 @@ | ||
import { useState } from "react"; | ||
import { sdk } from "../../lib/youbet-sdk"; | ||
|
||
import { Section } from "../Section"; | ||
import { Button } from "../Button"; | ||
|
||
export function AllProjects() { | ||
const [value, setValue] = useState<any[]>([]); | ||
|
||
const tryMe = async () => { | ||
const result = await sdk.client.getAllProjectIds(); | ||
setValue(result); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Section title="All Project Ids"> | ||
<div> | ||
<Button onClick={tryMe}>Try Me!</Button> | ||
</div> | ||
{value.map((data) => { | ||
return <div key={data}>{data}</div>; | ||
})} | ||
</Section> | ||
</> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
examples/simple-react/src/components/sections/ClaimReward.tsx
This file contains 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,17 @@ | ||
import { sdk } from '../../lib/youbet-sdk' | ||
import { Section } from '../Section' | ||
import { Button } from '../Button' | ||
|
||
export function ClaimReward() { | ||
const tryMe = async () => { | ||
await sdk.contract.claimReward() | ||
} | ||
|
||
return (<> | ||
<Section title="Claim Reward"> | ||
<div> | ||
<Button onClick={tryMe}>Try Me!</Button> | ||
</div> | ||
</Section> | ||
</>) | ||
} |
This file contains 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
32 changes: 32 additions & 0 deletions
32
examples/simple-react/src/components/sections/CreateProject.tsx
This file contains 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,32 @@ | ||
import { useState } from "react"; | ||
import { sdk } from "../../lib/youbet-sdk"; | ||
import { Section } from "../Section"; | ||
import { Button } from "../Button"; | ||
|
||
export function CreateProject() { | ||
const [id, setId] = useState("829893564"); | ||
const [name, setName] = useState("YoubetDao/youbet-test-repo/issues/12"); | ||
|
||
const tryMe = async () => { | ||
const taskInfo = await sdk.contract.createProject(id, name); | ||
console.log(taskInfo); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Section title="Create Project"> | ||
<div> | ||
<label>Id: github id</label> | ||
<input value={id} onChange={(e) => setId(e.target.value)} /> | ||
</div> | ||
<div> | ||
<label>Name: related to github issue</label> | ||
<input value={name} onChange={(e) => setName(e.target.value)} /> | ||
</div> | ||
<div> | ||
<Button onClick={tryMe}>Try Me!</Button> | ||
</div> | ||
</Section> | ||
</> | ||
); | ||
} |
55 changes: 35 additions & 20 deletions
55
examples/simple-react/src/components/sections/CreateTask.tsx
This file contains 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 |
---|---|---|
@@ -1,25 +1,40 @@ | ||
import { useState } from 'react' | ||
import { sdk } from '../../lib/youbet-sdk' | ||
import { Section } from '../Section' | ||
import { Button } from '../Button' | ||
import { useState } from "react"; | ||
import { sdk } from "../../lib/youbet-sdk"; | ||
import { Section } from "../Section"; | ||
import { Button } from "../Button"; | ||
|
||
export function CreateTask() { | ||
const [sub, setSub] = useState('YoubetDao/youbet-web3-allin/issues/1') | ||
const [id, setId] = useState("2460577971"); | ||
const [name, setName] = useState("YoubetDao/youbet-test-repo/issues/12"); | ||
const [projectId, setProjectId] = useState("829893564"); | ||
|
||
const tryMe = async () => { | ||
const taskInfo = await sdk.contract.createTask(sub) | ||
console.log(taskInfo) | ||
} | ||
const taskInfo = await sdk.contract.createTask(id, name, projectId); | ||
console.log(taskInfo); | ||
}; | ||
|
||
return (<> | ||
<Section title="Create Task"> | ||
<div> | ||
<label>Sub: related to github issue</label> | ||
<input value={sub} onChange={(e) => setSub(e.target.value)} /> | ||
</div> | ||
<div> | ||
<Button onClick={tryMe}>Try Me!</Button> | ||
</div> | ||
</Section> | ||
</>) | ||
} | ||
return ( | ||
<> | ||
<Section title="Create Task"> | ||
<div> | ||
<label>Id: github id</label> | ||
<input value={id} onChange={(e) => setId(e.target.value)} /> | ||
</div> | ||
<div> | ||
<label>Name: related to github issue</label> | ||
<input value={name} onChange={(e) => setName(e.target.value)} /> | ||
</div> | ||
<div> | ||
<label>ProjectId: github id</label> | ||
<input | ||
value={projectId} | ||
onChange={(e) => setProjectId(e.target.value)} | ||
/> | ||
</div> | ||
<div> | ||
<Button onClick={tryMe}>Try Me!</Button> | ||
</div> | ||
</Section> | ||
</> | ||
); | ||
} |
30 changes: 30 additions & 0 deletions
30
examples/simple-react/src/components/sections/DonateToProject.tsx
This file contains 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,30 @@ | ||
import { useState } from "react"; | ||
import { sdk } from "../../lib/youbet-sdk"; | ||
import { Section } from "../Section"; | ||
import { Button } from "../Button"; | ||
|
||
export function DonateToProject() { | ||
const [projectId, setProjectId] = useState("829893564"); | ||
|
||
const tryMe = async () => { | ||
const taskInfo = await sdk.contract.donateToProject(projectId, "0.0003"); | ||
console.log(taskInfo); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Section title="Donate To Project"> | ||
<div> | ||
<label>ProjectId</label> | ||
<input | ||
value={projectId} | ||
onChange={(e) => setProjectId(e.target.value)} | ||
/> | ||
</div> | ||
<div> | ||
<Button onClick={tryMe}>Try Me!</Button> | ||
</div> | ||
</Section> | ||
</> | ||
); | ||
} |
36 changes: 36 additions & 0 deletions
36
examples/simple-react/src/components/sections/GetClaimedRewards.tsx
This file contains 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,36 @@ | ||
import { useState } from "react"; | ||
import { sdk } from "../../lib/youbet-sdk"; | ||
import { Section } from "../Section"; | ||
import { Button } from "../Button"; | ||
|
||
export function GetClaimedRewards() { | ||
const [user, setUser] = useState( | ||
"0x4808df9a90196d41459a3fe37d76dca32f795338" | ||
); | ||
const [value, setValue] = useState(0); | ||
|
||
const tryMe = async () => { | ||
const result = await sdk.client.getClaimedRewards(user); | ||
setValue(result); | ||
console.log(result); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Section title="Get Claimed Rewards"> | ||
<div> | ||
<label>User wallet address</label> | ||
<input value={user} onChange={(e) => setUser(e.target.value)} /> | ||
</div> | ||
<div> | ||
<Button onClick={tryMe}>Try Me!</Button> | ||
</div> | ||
{ | ||
<div> | ||
<textarea disabled value={value}></textarea> | ||
</div> | ||
} | ||
</Section> | ||
</> | ||
); | ||
} |
34 changes: 34 additions & 0 deletions
34
examples/simple-react/src/components/sections/GetProjectParticipants.tsx
This file contains 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,34 @@ | ||
import { useState } from "react"; | ||
import { sdk } from "../../lib/youbet-sdk"; | ||
import { Section } from "../Section"; | ||
import { Button } from "../Button"; | ||
|
||
export function GetProjectParticipants() { | ||
const [projectId, setProjectId] = useState("829893564"); | ||
const [value, setValue] = useState<string[]>([]); | ||
|
||
const tryMe = async () => { | ||
const result = await sdk.client.getProjectParticipants(projectId); | ||
setValue(result); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Section title="Get Project Participants"> | ||
<div> | ||
<label>ProjectId</label> | ||
<input | ||
value={projectId} | ||
onChange={(e) => setProjectId(e.target.value)} | ||
/> | ||
</div> | ||
<div> | ||
<Button onClick={tryMe}>Try Me!</Button> | ||
</div> | ||
{value.map((data) => { | ||
return <div key={data}>address: {data}</div>; | ||
})} | ||
</Section> | ||
</> | ||
); | ||
} |
35 changes: 35 additions & 0 deletions
35
examples/simple-react/src/components/sections/GetTotalRewards.tsx
This file contains 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,35 @@ | ||
import { useState } from "react"; | ||
import { sdk } from "../../lib/youbet-sdk"; | ||
import { Section } from "../Section"; | ||
import { Button } from "../Button"; | ||
|
||
export function GetTotalRewards() { | ||
const [user, setUser] = useState( | ||
"0x4808df9a90196d41459a3fe37d76dca32f795338" | ||
); | ||
const [value, setValue] = useState(0); | ||
|
||
const tryMe = async () => { | ||
const result = await sdk.client.getTotalRewards(user); | ||
setValue(result); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Section title="Get Total Rewards"> | ||
<div> | ||
<label>User wallet address</label> | ||
<input value={user} onChange={(e) => setUser(e.target.value)} /> | ||
</div> | ||
<div> | ||
<Button onClick={tryMe}>Try Me!</Button> | ||
</div> | ||
{ | ||
<div> | ||
<textarea disabled value={value}></textarea> | ||
</div> | ||
} | ||
</Section> | ||
</> | ||
); | ||
} |
Oops, something went wrong.