This repository has been archived by the owner on Dec 17, 2021. It is now read-only.
generated from moonshotcollective/scaffold-eth
-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
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
Dhaiwat10
force-pushed
the
erc20-version
branch
from
December 1, 2021 02:16
da35708
to
0b8852f
Compare
Added a temp modal that asks for stake amount to recruiters when they click on the request information button. The One problem: For some reason, now I cannot unlock my own information. Well, I can unlock it but I can't see it. The backend returns an error. This was possible earlier. I did both the transactions successfully - request and approve request. Not sure if that's by design but just putting it out here. Other notes: Had to rebase this branch against staging since this branch didn't have the latest frontend code. |
QEDK
commented
Dec 1, 2021
Hey mate, thanks for reviewing. I don't have access to a laptop right now -
kinda an emergency, but I'll make these changes tomorrow. Dropping this msg
since I haven't been able to get back to this all day
…On Wed, 1 Dec 2021, 11:46 qedk, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In packages/react-app/components/cards/MediaCard.jsx
<#70 (comment)>
:
> @@ -70,27 +72,55 @@ function MediaCard({
const toast = useToast();
const handleRequestPrivateProfileUnlock = async () => {
+ const stakeAmount = prompt("Enter stake amount in MATIC");
Replace this with Chakra's modal: https://chakra-ui.com/docs/overlay/modal
------------------------------
In packages/react-app/components/cards/MediaCard.jsx
<#70 (comment)>
:
> @@ -70,27 +72,55 @@ function MediaCard({
const toast = useToast();
const handleRequestPrivateProfileUnlock = async () => {
+ const stakeAmount = prompt("Enter stake amount in MATIC");
+ if (!stakeAmount) {
+ return alert("Please enter a valid stake amount");
Perform validation using the NumberInput component:
https://chakra-ui.com/docs/form/number-input
------------------------------
In packages/react-app/components/cards/MediaCard.jsx
<#70 (comment)>
:
> try {
- const tx = await dRecruitContract.request(privateProfile.tokenId, {
- value: ethers.utils.parseEther("0.01"),
+ // Request allowance
+ const dERC20Address = await dRecruitContract.token();
+ const signer = await context.injectedProvider.getSigner();
+ const dERC20Contract = new ethers.Contract(dERC20Address, abis.ERC20, signer);
This process should not happen on the fly but stored in state on first
load, similar to other contracts. You can put it as the last step of
loadWeb3Modal()
------------------------------
In packages/react-app/components/cards/MediaCard.jsx
<#70 (comment)>
:
> try {
- const tx = await dRecruitContract.request(privateProfile.tokenId, {
- value: ethers.utils.parseEther("0.01"),
+ // Request allowance
+ const dERC20Address = await dRecruitContract.token();
+ const signer = await context.injectedProvider.getSigner();
+ const dERC20Contract = new ethers.Contract(dERC20Address, abis.ERC20, signer);
+ const allowance = await dERC20Contract.allowance(context.address, dRecruitContract.address);
+ // Only ask for allowance if it is not enough
+ if (allowance < weiStakeAmount) {
Also check if allowance is below the threshold amount, 1 * 10 ** 18, we
don't want dupe allowance txs
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#70 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJOIHE7KIWYE5LR4INSFDZ3UOW4UZANCNFSM5IHU5SIQ>
.
|
…early, optimize approval requests
QEDK
commented
Dec 2, 2021
QEDK
commented
Dec 2, 2021
QEDK
commented
Dec 2, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #21