Skip to content
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

feat: add stx price button to post conditions #1148

Merged
merged 6 commits into from
Jun 23, 2023

Conversation

shamim-io
Copy link
Contributor

closes #1101

Closes Display dollar amount on Stacks tokens #1101

Fixes issue: Display dollar amount on Stacks tokens in post conditions

Feature details
Added StxPriceButton to post conditions

Feature image
Screenshot 2023-05-10 at 3 57 55 AM

Files changed
post-conditions.tsx
ContractCall/index.tsx

@vercel
Copy link

vercel bot commented May 25, 2023

@shamim-io is attempting to deploy a commit to the Hiro Systems Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented May 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hiro-explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 23, 2023 2:15pm

@He1DAr
Copy link
Collaborator

He1DAr commented May 31, 2023

@shamim-io could you please look into this error:
image
Thank you so much!

@shamim-io
Copy link
Contributor Author

@He1DAr I have modified the PR. We should not get this error again. Thanks!

@He1DAr
Copy link
Collaborator

He1DAr commented Jun 2, 2023

Thank you for updating the PR!
I ran a few tests, and it seems like there's a small issue with the value passed to the price button. For example, if you check out this link: https://hiro-explorer-git-fork-shamim-io-feat-stxbutton-blockstack.vercel.app/txid/0xa38b0e9c953c4e5b2f7362fec881456c19160a33659aa6cf80e356d52ad281db?chain=mainnet)], you'll notice that the value isn't displaying the correct amount for the price button. It should reflect the $ amount of 2 STX.
Thanks again for your help! Let me know if you need any further information. 😊

@shamim-io
Copy link
Contributor Author

@He1DAr I have passed the post condition amount to the button. Can you suggest which value shall I pass?
If its post condition amount only, then I think we need to modify the value in the API response from backend. Correct me if i am wrong.

@He1DAr
Copy link
Collaborator

He1DAr commented Jun 9, 2023

Hi @shamim-io!
The issue is caused by passing the value to StxPriceButton in stx instead of microStx. To fix this, you can pass condition.amount directly. That should do the trick!

{condition.type === 'stx' && <StxPriceButton tx={tx} value={Number(condition.amount)} />}

If you have any more questions, feel free to ask. Thank you for your patience in resolving the issue.

@shamim-io
Copy link
Contributor Author

@He1DAr I have modified the condition. Sorry I solved it a bit late.

@He1DAr
Copy link
Collaborator

He1DAr commented Jun 14, 2023

@He1DAr I have modified the condition. Sorry I solved it a bit late.

Thank you @shamim-io! Adjusting getAmount will cause a bug in the displayed value of the post-condition. Please check the previous comment for the proposed solution.
image

@shamim-io
Copy link
Contributor Author

@He1DAr Even the above logic that you provided doesn't give the correct value.
Screenshot 2023-06-15 at 11 48 29 PM

So apparently 8000STX ~ 4000 USD.

Do we need to multiply the value by 100 as under:
{condition.type === 'stx' && ( <StxPriceButton tx={tx} value={Number(condition.amount) * 100} /> )}

@shamim-io
Copy link
Contributor Author

shamim-io commented Jun 18, 2023

@He1DAr Any thoughts on the above comment ? 🙂
I have updated the PR though.

@He1DAr
Copy link
Collaborator

He1DAr commented Jun 21, 2023

Hi @shamim-io,
No need to multiple, the proposed solution should work.
image
image

@shamim-io
Copy link
Contributor Author

@He1DAr I have made the changes. Sorry for the confusion. Fingers crossed :)

Copy link
Collaborator

@He1DAr He1DAr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you @shamim-io

@He1DAr He1DAr merged commit fe2b26d into hirosystems:main Jun 23, 2023
9 checks passed
@github-actions
Copy link

🎉 This PR is included in version 1.108.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display dollar amount on Stacks tokens
2 participants