-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invest #3
base: main
Are you sure you want to change the base?
Invest #3
Changes from all commits
bbb1056
e2b0f85
a89a128
4da82c5
48444f5
477ec08
31141d0
bc381c5
99df84c
41aa138
d8f3e6b
5f44f3c
68fa8f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,26 @@ import dygnifyStaking from "../../artifacts/contracts/DygnifyStaking.sol/Dygnify | |
import dygnifyToken from "../../artifacts/contracts/DygnifyToken.sol/DygnifyToken.json"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add try catch in all the functions in this file |
||
import { requestAccount } from "../navbar/NavBarHelper"; | ||
|
||
const dygnifyStakingAddress = "0xf79B8AF0D963124444A6443331D9Ba00bCfED855"; | ||
const token = "0x1546A8e7389B47d2Cf1bacE7C0ad3e0A91CAae94"; | ||
const dygnifyStakingAddress = "0x043c0B0385870AaFe42d98A2817DDA81E462Ccc9"; | ||
const token = "0x420d23b5D7B70fFEF09A6076B7Db1176472BaA37"; | ||
|
||
export async function approve(amount) { | ||
if (amount <= 0 || amount <= "0" ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. amount <= "0" this check is not correct |
||
console.log("Amount must be greater than 0"); | ||
} else if (typeof window.ethereum !== "undefined") { | ||
await requestAccount(); | ||
const provider = new ethers.providers.Web3Provider(window.ethereum); | ||
console.log({ provider }); | ||
const signer = provider.getSigner(); | ||
const contract2 = new ethers.Contract( | ||
token, | ||
dygnifyToken.abi, | ||
signer | ||
); | ||
const transaction = await contract2.approve(dygnifyStakingAddress,amount); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to use the return from approve function and proceed accordingly |
||
await transaction.wait() | ||
} | ||
} | ||
|
||
export async function stake(amount) { | ||
if (amount <= 0 || amount <= "0" ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comments as above regarding condition |
||
|
@@ -19,8 +37,9 @@ export async function stake(amount) { | |
dygnifyStaking.abi, | ||
signer | ||
); | ||
const transaction = await contract.stake(amount); | ||
await transaction.wait(); | ||
const transaction1 = await contract.stake(amount); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. improper naming of variable 'transaction1', variable naming needs to be corrected |
||
await transaction1.wait(); | ||
|
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ const Home = () => { | |
const form = () => { | ||
return ( | ||
<div className="box"> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary line addition, please remove |
||
<Sidebar></Sidebar> | ||
<aside className="right"> | ||
<NavBar /> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this line commented?