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

support for pasting links. #1071

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -754,60 +754,50 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
content,
logging: Logging.instance,
);
if (paymentData != null &&
paymentData.coin?.uriScheme == coin.uriScheme) {
// auto fill address
_address = paymentData.address;
sendToController.text = _address!;

// autofill notes field.
if (paymentData.message != null) {
_note = paymentData.message;
} else if (paymentData.label != null) {
_note = paymentData.label;
}
if (paymentData != null && (paymentData.coin?.uriScheme == coin.uriScheme)) {
// Auto fill address
_address = paymentData.address.trim();
sendToController.text = _address!;

// autofill amoutn field
// Amount
if (paymentData.amount != null) {
final amount = Decimal.parse(paymentData.amount!).toAmount(
final Amount amount = Decimal.parse(paymentData.amount!).toAmount(
fractionDigits: coin.fractionDigits,
);
cryptoAmountController.text = ref
.read(pAmountFormatter(coin))
.format(amount, withUnitName: false);
cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format(
amount,
withUnitName: false,
);
ref.read(pSendAmount.notifier).state = amount;
}

// Trigger validation after pasting.
// Change focus to amount field if it's empty
if (cryptoAmountController.text.isEmpty) {
FocusScope.of(context).requestFocus(_cryptoFocus);
} else {
// Otherwise, focus on the send button
FocusScope.of(context).requestFocus(FocusNode());
}

// Trigger validation after pasting
_setValidAddressProviders(_address);
setState(() {
_addressToggleFlag = sendToController.text.isNotEmpty;
});
} else {
content = content.split("\n").first.trim();
if (coin is Epiccash) {
content = AddressUtils().formatAddress(content);
}

// Handle as a plain address if parsing fails
sendToController.text = content;
_address = content;

_setValidAddressProviders(_address);
setState(() {
_addressToggleFlag = sendToController.text.isNotEmpty;
});
}
} catch (e) {
// If parsing fails, treat it as a plain address.
if (coin is Epiccash) {
Copy link
Member

Choose a reason for hiding this comment

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

Why was this Epic Cash-specific case removed? Was this tested with Epic Cash?

// strip http:// and https:// if content contains @
content = AddressUtils().formatAddress(content);
}

sendToController.text = content;
_address = content;

// Trigger validation after pasting.
_setValidAddressProviders(_address);
setState(() {
_addressToggleFlag = sendToController.text.isNotEmpty;
Expand Down Expand Up @@ -1885,7 +1875,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
: (coin is Firo) &&
ref
.watch(
publicPrivateBalanceStateProvider.state,
publicPrivateBalanceStateProvider
.state,
)
.state ==
FiroType.lelantus
Expand Down