Skip to content

Commit 7c9b2e3

Browse files
committed
feat: support get github and wallet binding on chain and release 0.0.11
1 parent 64f5c02 commit 7c9b2e3

File tree

5 files changed

+79
-1
lines changed

5 files changed

+79
-1
lines changed

examples/simple-react/src/App.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { GetClaimedRewards } from "./components/sections/GetClaimedRewards";
2323
import { GetTotalRewards } from "./components/sections/GetTotalRewards";
2424
import { AllProjects } from "./components/sections/AllProjects";
2525
import { GetProjectParticipants } from "./components/sections/GetProjectParticipants";
26+
import { GetWalletByGithub } from "./components/sections/GetWalletByGithub";
27+
import { GetGithubByWallet } from "./components/sections/GetGithubByWallet";
2628
// import { GoalCreated } from './components/sections/GoalCreated'
2729

2830
function App() {
@@ -64,6 +66,8 @@ function App() {
6466
<GetClaimedRewards />
6567
<AllProjects />
6668
<GetProjectParticipants />
69+
<GetWalletByGithub />
70+
<GetGithubByWallet />
6771
{/* <GoalCreated /> */}
6872
</main>
6973
<footer className="footer">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { useState } from "react";
2+
import { sdk } from "../../lib/youbet-sdk";
3+
import { Section } from "../Section";
4+
import { Button } from "../Button";
5+
6+
export function GetGithubByWallet() {
7+
const [wallet, setWallet] = useState(
8+
"0x4808df9a90196d41459a3Fe37D76DCa32F795338"
9+
);
10+
const [value, setValue] = useState("");
11+
12+
const tryMe = async () => {
13+
const result = await sdk.client.getGithubByWallet(wallet);
14+
setValue(result);
15+
};
16+
17+
return (
18+
<>
19+
<Section title="Get Project Participants">
20+
<div>
21+
<label>Wallet</label>
22+
<input value={wallet} onChange={(e) => setWallet(e.target.value)} />
23+
</div>
24+
<div>
25+
<Button onClick={tryMe}>Try Me!</Button>
26+
</div>
27+
{value}
28+
</Section>
29+
</>
30+
);
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { useState } from "react";
2+
import { sdk } from "../../lib/youbet-sdk";
3+
import { Section } from "../Section";
4+
import { Button } from "../Button";
5+
6+
export function GetWalletByGithub() {
7+
const [github, setGithub] = useState("wfnuser");
8+
const [value, setValue] = useState("");
9+
10+
const tryMe = async () => {
11+
const result = await sdk.client.getWalletByGithub(github);
12+
setValue(result);
13+
};
14+
15+
return (
16+
<>
17+
<Section title="Get Project Participants">
18+
<div>
19+
<label>Github</label>
20+
<input value={github} onChange={(e) => setGithub(e.target.value)} />
21+
</div>
22+
<div>
23+
<Button onClick={tryMe}>Try Me!</Button>
24+
</div>
25+
{value}
26+
</Section>
27+
</>
28+
);
29+
}

packages/youbet-sdk/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "youbet-sdk",
3-
"version": "0.0.10",
3+
"version": "0.0.12",
44
"description": "Awesome SDK it is.",
55
"main": "./dist/cjs/main.js",
66
"module": "./dist/esm/index.js",

packages/youbet-sdk/src/modules/clientModule.ts

+14
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export interface ViewContract extends BaseContract {
1717
getAllProjectIds: BaseContractMethod<[], any, Result>;
1818
getProjectParticipants: BaseContractMethod<[string], any, Result>;
1919
getProjectUserPoints: BaseContractMethod<[string, string], any, number>;
20+
getGithubByWallet: BaseContractMethod<[string], any, string>;
21+
getWalletByGithub: BaseContractMethod<[string], any, string>;
2022
}
2123

2224
export class ClientModule {
@@ -124,4 +126,16 @@ export class ClientModule {
124126
const result = await contract.getProjectUserPoints(projectId, user);
125127
return result;
126128
}
129+
130+
async getGithubByWallet(user: string): Promise<string> {
131+
const contract = await this._getContract();
132+
const result = await contract.getGithubByWallet(user);
133+
return result;
134+
}
135+
136+
async getWalletByGithub(github: string): Promise<string> {
137+
const contract = await this._getContract();
138+
const result = await contract.getWalletByGithub(github);
139+
return result;
140+
}
127141
}

0 commit comments

Comments
 (0)