Skip to content

Commit

Permalink
get rid of unified receive
Browse files Browse the repository at this point in the history
only do one at a time, address or invoice

move method chooser to receive amount screen

fix flicker on send / swap pages

amountless on-chain, fix receive warnings

fix unnecessary "Failed to conduct wallet operation" errors

close receive method chooser automatically
  • Loading branch information
futurepaul committed May 8, 2024
1 parent 11cc9eb commit a4981cb
Show file tree
Hide file tree
Showing 10 changed files with 324 additions and 274 deletions.
6 changes: 3 additions & 3 deletions e2e/fedimint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ test("fedmint join, receive, send", async ({ page }) => {

const value = await qrCode.getAttribute("value");

// The SVG's value property includes "bitcoin:t"
expect(value).toContain("bitcoin:t");
// The SVG's value property includes "bitcoin:l"
expect(value).toContain("lightning:l");

const lightningInvoice = value?.split("lightning=")[1];
const lightningInvoice = value?.split("lightning:")[1];

// Post the lightning invoice to the server
const _response = await fetch(
Expand Down
6 changes: 3 additions & 3 deletions e2e/roundtrip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ test("rountrip receive and send", async ({ page }) => {

const value = await qrCode.getAttribute("value");

// The SVG's value property includes "bitcoin:t"
expect(value).toContain("bitcoin:t");
// The SVG's value property includes "lightning:l"
expect(value).toContain("lightning:l");

const lightningInvoice = value?.split("lightning=")[1];
const lightningInvoice = value?.split("lightning:")[1];

// Post the lightning invoice to the server
const _response = await fetch(
Expand Down
14 changes: 6 additions & 8 deletions public/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,10 @@
"receive_add_the_sender": "Add the sender for your records",
"keep_mutiny_open": "Keep Mutiny open to complete the payment.",
"choose_payment_format": "Choose payment format",
"unified_label": "Unified",
"unified_caption": "Combines a bitcoin address and a lightning invoice. Sender chooses payment method.",
"lightning_label": "Lightning invoice",
"lightning_caption": "Ideal for small transactions. Usually lower fees than on-chain.",
"onchain_label": "Bitcoin address",
"onchain_caption": "On-chain, just like Satoshi did it. Ideal for very large transactions.",
"unified_setup_fee": "A lightning setup fee of {{amount}} SATS will be charged if paid over lightning.",
"lightning_setup_fee": "A lightning setup fee of {{amount}} SATS will be charged for this receive.",
"amount": "Amount",
"fee": "+ Fee",
Expand All @@ -123,11 +120,11 @@
"channel_size": "Channel size",
"channel_reserve": "- Channel reserve",
"error_under_min_lightning": "Defaulting to On-chain. Amount is too small for your initial Lightning receive.",
"error_creating_unified": "Defaulting to On-chain. Something went wrong when creating the unified address",
"error_creating_address": "Something went wrong when creating the on-chain address",
"error_creating_unified": "Defaulting to On-chain. Something went wrong when creating the Lightning invoice.",
"error_creating_address": "Something went wrong when creating the on-chain address.",
"amount_editable": {
"receive_too_small": "Your first receive needs to be {{amount}} SATS or greater.",
"setup_fee_lightning": "A lightning setup fee will be charged if paid over lightning.",
"setup_fee_lightning": "A lightning setup fee will be charged.",
"more_than_21m": "There are only 21 million bitcoin.",
"set_amount": "Set amount",
"max": "MAX",
Expand All @@ -142,15 +139,16 @@
"integrated_qr": {
"onchain": "On-chain",
"lightning": "Lightning",
"unified": "Unified",
"gift": "Lightning Gift"
},
"remember_choice": "Remember my choice next time",
"what_for": "What's this for?",
"method_help": {
"title": "Receive Method",
"body": "Lightning receives will automatically go into your chosen federation. You can swap to self-custodial later if you want."
}
},
"receive_strings_error": "Something went wrong generating an invoice or on-chain address.",
"error_under_min_onchain": "That's under the dust limit! On-chain transactions should be much bigger."
},
"send": {
"search": {
Expand Down
1 change: 0 additions & 1 deletion src/components/AmountEditable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export const AmountEditable: ParentComponent<{
state.fiat,
sw
).then((sats) => {
console.log("sats", sats);
setLocalFiat(sats);
});
}
Expand Down
10 changes: 0 additions & 10 deletions src/components/IntegratedQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ function KindIndicator(props: { kind: ReceiveFlavor | "gift" | "lnAddress" }) {
</h3>
<Zap class="h-4 w-4" />
</Match>

<Match when={props.kind === "unified"}>
<h3 class="font-semibold">
{i18n.t("receive.integrated_qr.unified")}
</h3>
<div class="flex gap-1">
<Zap class="h-4 w-4" />
<Link class="h-4 w-4" />
</div>
</Match>
</Switch>
</div>
);
Expand Down
37 changes: 27 additions & 10 deletions src/components/ReceiveWarnings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { createResource, Match, Switch } from "solid-js";
import { InfoBox } from "~/components/InfoBox";
import { FeesModal } from "~/components/MoreInfoModal";
import { useI18n } from "~/i18n/context";
import { ReceiveFlavor } from "~/routes";
import { useMegaStore } from "~/state/megaStore";

export function ReceiveWarnings(props: {
amountSats: bigint;
from_fedi_to_ln?: boolean;
flavor?: ReceiveFlavor;
}) {
const i18n = useI18n();
const [state, _actions, sw] = useMegaStore();
Expand Down Expand Up @@ -37,17 +39,19 @@ export function ReceiveWarnings(props: {
if (state.federations?.length !== 0 && props.from_fedi_to_ln !== true) {
return undefined;
}
if (
(state.balance?.lightning || 0n) === 0n &&
!state.settings?.lsps_connection_string
) {
return i18n.t("receive.amount_editable.receive_too_small", {
amount: "100,000"
});
}
if (props.flavor === "lightning") {
if (
(state.balance?.lightning || 0n) === 0n &&
!state.settings?.lsps_connection_string
) {
return i18n.t("receive.amount_editable.receive_too_small", {
amount: "100,000"
});
}

if (props.amountSats > (inboundCapacity() || 0n)) {
return i18n.t("receive.amount_editable.setup_fee_lightning");
if (props.amountSats > (inboundCapacity() || 0n)) {
return i18n.t("receive.amount_editable.setup_fee_lightning");
}
}

return undefined;
Expand All @@ -65,8 +69,21 @@ export function ReceiveWarnings(props: {
}
};

const tooSmallWarning = () => {
if (
props.flavor === "onchain" &&
props.amountSats > 0n &&
props.amountSats < 546n
) {
return i18n.t("receive.error_under_min_onchain");
}
};

return (
<Switch>
<Match when={tooSmallWarning()}>
<InfoBox accent="red">{tooSmallWarning()}</InfoBox>
</Match>
<Match when={sillyAmountWarning()}>
<InfoBox accent="red">{sillyAmountWarning()}</InfoBox>
</Match>
Expand Down
Loading

0 comments on commit a4981cb

Please sign in to comment.