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

ZEUS-1419: LNURL-w fixed value patch #1427

Merged
merged 7 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
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
13 changes: 9 additions & 4 deletions components/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ export default class AmountInput extends React.Component<
constructor(props: any) {
super(props);

const { amount } = props;
const { amount, onAmountChange } = props;
let satAmount = '0';
if (amount) satAmount = getSatAmount(amount).toString();
onAmountChange(amount, satAmount);
this.state = {
satAmount
};
Expand Down Expand Up @@ -124,7 +125,9 @@ export default class AmountInput extends React.Component<
return (
<React.Fragment>
{title && (
<TouchableOpacity onPress={() => this.onChangeUnits()}>
<TouchableOpacity
onPress={() => !locked && this.onChangeUnits()}
>
<Text
style={{
fontFamily: 'Lato-Regular',
Expand Down Expand Up @@ -160,10 +163,12 @@ export default class AmountInput extends React.Component<
units === 'fiat' &&
getSymbol().symbol
}
toggleUnits={this.onChangeUnits}
toggleUnits={() => !locked && this.onChangeUnits()}
/>
{!hideConversion && (
<TouchableOpacity onPress={() => this.onChangeUnits()}>
<TouchableOpacity
onPress={() => !locked && this.onChangeUnits()}
>
<View style={{ marginBottom: 10 }}>
{fiat !== 'Disabled' && units !== 'fiat' && (
<Amount sats={satAmount} fixedUnits="fiat" />
Expand Down
28 changes: 20 additions & 8 deletions views/Receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ export default class Receive extends React.Component<
const settings = await getSettings();

this.setState({
addressType: settings.invoices.addressType || '1',
memo: settings.invoices.memo || '',
expiry: settings.invoices.expiry || '3600',
routeHints: settings.invoices.routeHints || false,
ampInvoice: settings.invoices.ampInvoice || false
addressType: settings?.invoices?.addressType || '1',
memo: settings?.invoices?.memo || '',
expiry: settings?.invoices?.expiry || '3600',
routeHints: settings?.invoices?.routeHints || false,
ampInvoice: settings?.invoices?.ampInvoice || false
});

const lnOnly =
Expand Down Expand Up @@ -165,15 +165,18 @@ export default class Receive extends React.Component<
}

if (lnurl) {
this.props.UnitsStore.resetUnits();
this.setState({
memo: lnurl.defaultDescription,
value: (lnurl.maxWithdrawable / 1000).toString()
value: (lnurl.maxWithdrawable / 1000).toString(),
satAmount: getSatAmount(lnurl.maxWithdrawable / 1000)
});
}

if (amount) {
this.setState({
value: amount
value: amount,
satAmount: getSatAmount(amount)
});
}

Expand Down Expand Up @@ -203,13 +206,22 @@ export default class Receive extends React.Component<
const { reset } = InvoicesStore;

reset();
const amount: string = navigation.getParam('amount');
const lnurl: LNURLWithdrawParams | undefined =
navigation.getParam('lnurlParams');

if (amount) {
this.setState({
value: amount,
satAmount: getSatAmount(amount)
});
}

if (lnurl) {
this.setState({
memo: lnurl.defaultDescription,
value: (lnurl.maxWithdrawable / 1000).toString()
value: (lnurl.maxWithdrawable / 1000).toString(),
satAmount: getSatAmount(lnurl.maxWithdrawable / 1000)
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions views/handleAnythingQRScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export default class handleAnythingQRScanner extends React.Component<
this.setState({
loading: false
});
const [route, props] = response;
if (route) {
if (response) {
const [route, props] = response;
navigation.navigate(route, props);
} else {
navigation.goBack();
Expand Down