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

Read the min amount of BTC deposit from the SDK #303

Merged
merged 21 commits into from
Apr 16, 2024
Merged

Conversation

kkosiorowska
Copy link
Contributor

@kkosiorowska kkosiorowska commented Mar 7, 2024

Closes #234
Closes #336

This PR reads the minimum amount of BTC deposit from the SDK and saves it in the redux store.

What has been done:

  • Fetch the minimum amount of BTC deposit from the SDK
  • Create a special hook useFetchSdkData to load all needed data from the SDK
  • Set desired decimals for Bitcoin currency manually. Previously, we determined the number of desired places based on the minimum stake amount. However, now we are not able to do it this way because the data from the SDK is loaded after connecting the accounts.
  • Standardization of types in the form. Use a bigint for tokenBalnce.
  • Extend CurrencyBalance to pass the amount in bigint

One note: the contracts have not been deployed yet. Therefore, an error will appear in the console TypeError: this.instance.minDepositAmount is not a function However, When the contracts are re-deployed I will update the code and the error will disappear.


⚠️ Should be merged after #349 ⚠️

  • After updating the branch with the changes from 349, check whether the min deposit amount was fetched correctly.

@kkosiorowska kkosiorowska added the 🎨 dApp dApp label Mar 7, 2024
@kkosiorowska kkosiorowska self-assigned this Mar 7, 2024
Copy link

netlify bot commented Mar 7, 2024

Deploy Preview for acre-dapp-testnet ready!

Name Link
🔨 Latest commit 4734e21
🔍 Latest deploy log https://app.netlify.com/sites/acre-dapp-testnet/deploys/6618db285e2ef50008cec025
😎 Deploy Preview https://deploy-preview-303--acre-dapp-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Add `fromSatoshi` fn that converts an amount from `1e8` to `1e18` token precision. Also here we remove optional `fromPrecision` param in `toSatoshi` fn - we assume we always convert from `1e18` to `1e8` and in `fromSatoshi` we always convert from `1e8` to `1e18`.
The minimum amount of BTC deposit should be taken from  `BitcoinDepositor` contract. The amount is in tBTC token precision before export this value in SDK has to be converted to satoshi precision.
Since the minimum staking amount is in bigint, we should standardize it not mix types in the form. This approach also gets rid of the double conversion of tokenBalance to bigint in the `TokenBalanceInput` component and validation method.
The BigInt constructor also accepts the value bigint. There is no need to check whether the number is of type bigint to avoid the constructor.
@kkosiorowska kkosiorowska marked this pull request as ready for review April 10, 2024 10:41
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic comes from #281. To avoid waiting for this PR, I copied this solution.

@kkosiorowska kkosiorowska requested a review from ioay April 12, 2024 09:29
ioay
ioay previously approved these changes Apr 12, 2024
Copy link
Contributor

@ioay ioay left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 Resolve file conflicts, please.
@r-czajkowski could you take a look at the SDK part?

r-czajkowski
r-czajkowski previously approved these changes Apr 12, 2024
@r-czajkowski r-czajkowski enabled auto-merge April 15, 2024 13:00
@kkosiorowska kkosiorowska dismissed stale reviews from r-czajkowski and ioay via b836867 April 15, 2024 14:08
@r-czajkowski r-czajkowski merged commit 1a2dbab into main Apr 16, 2024
20 checks passed
@r-czajkowski r-czajkowski deleted the min-amount-btc branch April 16, 2024 08:00
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.

Extends methods to handle bigint type value Read the minimum amount of BTC deposit from the SDK
3 participants