forked from HarmonicPool/cardano-wallet-interface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleReactPage_CCVault.js
79 lines (69 loc) · 1.72 KB
/
SimpleReactPage_CCVault.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React from 'react'
import { Wallet } from "@harmonicpool/cardano-wallet-interface";
export default class Home extends React.Component
{
constructor(props)
{
super(props);
this.state = {
currentDelegation: {},
ccvaultHasBeenInitialized: false
}
}
async componentDidMount()
{
await Wallet.enableCCVault();
// set your key once then you are free to go
Wallet.setBlockfrost("<your blockforst api key>");
this.setState({
currentDelegation: await Wallet.CCVault.getCurrentUserDelegation(),
ccvaultHasBeenInitialized: true
})
}
render()
{
return (
<div
style={{
position: "absolute",
height: "100vh",
width: "100vw",
top: 0,
left: 0,
display: "flex",
justifyContent: "center",
alignItems: "center"
}}
>
{
!this.state.ccvaultHasBeenInitialized ?
<p
style={{
fontFamily: "Arial, sans-serif",
fontSize: "5vh"
}}
>looking for CCVault... 👀</p>
:
(
this.state.currentDelegation.pool_id === "<your pool id>" ?
<p
style={{
fontFamily: "Arial, sans-serif",
fontSize: "5vh"
}}
>Thank you for your support ♥</p>
:
<button
onClick={() => Wallet.CCVault.delegateTo(
"<your pool id>"
// no need for api key since it has been setted in the componentDidMount() call
)}
>
Delegate
</button>
)
}
</div>
)
}
}