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(suite-native): Send Custom Fee #15364

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Conversation

PeKne
Copy link
Contributor

@PeKne PeKne commented Nov 13, 2024

Description

  • custom fee implemented for all the enabled network (both Bitcoin-like and Ethereum-like + tokens)
  • working with a send max enabled as well (the total amount is always adjusted so all the balance is send from the account)

Related Issue

Resolve #15180

Screenshots:

BTC

Screen.Recording.2024-11-13.at.9.57.12.mov

BTC - Send Max

Screen.Recording.2024-11-13.at.10.40.24.mov

ETH

Screen.Recording.2024-11-13.at.10.39.37.mov

@PeKne PeKne added the mobile Suite Lite issues and PRs label Nov 13, 2024
Copy link

github-actions bot commented Nov 13, 2024

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 10
  • More info

Learn more about 𝝠 Expo Github Action

onClose();
});

const animatedButtonContainerStyle = useAnimatedStyle(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you might want to use this https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/layout-transitions#linear-transition

It should work better and it should also add some nice animation when that error box is diplayed

Copy link
Contributor Author

@PeKne PeKne Nov 15, 2024

Choose a reason for hiding this comment

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

The layout linear transition works good for calculating animation of the component wrappen in the Animated.View. But I decided to use this kind of height transformation, because it also nicely resizes the whole bottomSheet (wrapper of the content) without doing any nasty layout jumps. If you have some better solution to address this issue, I will be happy to fix that.

Copy link
Contributor

@Nodonisko Nodonisko left a comment

Choose a reason for hiding this comment

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

Checked, not tested on real device also I don't know much about how fees works

</HStack>
</VStack>
<HStack flex={1} justifyContent="space-between">
<Box flex={1 / 3}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if you use just 1 and later 2 it will work same from what I know about flexbox

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const mockedFee = transactionBytes * Number(feePerUnit);
const mockedTotalAmount = mockedFee + (Number(normalFee.totalSpent) - Number(normalFee.fee));
const isSubmittable = selectedFeeLevelTransaction.type === 'final';
const mockedFee = BigNumber(transactionBytes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we memo these BigNumber operations? They are usually quite slow

Copy link
Contributor Author

Choose a reason for hiding this comment

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


// TODO: estimate do not work for error state EtH
// If the trezor-connect is unable to compose the transaction, we display rough estimate of the fee instead.
const feeEstimate = watchedFeePerUnit
Copy link
Contributor

Choose a reason for hiding this comment

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

can we memo this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


if (!networkFeeInfo) return false;

const feeBig = new BigNumber(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is necessary to have BN here? How does numbers looks like?

I guess this validation runs with every change of form so it should be super quick.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right, no need for BN here 61136b9

state: NativeSendRootState,
): GeneralPrecomposedTransaction | undefined => state.wallet.send.feeLevels.custom;

export const selectFeeLevelTransactionBytes = (
Copy link
Contributor

Choose a reason for hiding this comment

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

use memoize, especially if you use BN

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Suite Lite issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Send Coins - Custom fee
2 participants