-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
135 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { AddressInput, IntegerInput } from "../scaffold-eth"; | ||
import { PaymentRequestObject, decode } from "bolt11"; | ||
import QRCode from "qrcode.react"; | ||
|
||
export function Step1({ | ||
amount, | ||
invoice, | ||
recipientAddress, | ||
setRecipientAddress, | ||
setAmount, | ||
onClickContinue, | ||
onClickQRCode, | ||
}: { | ||
amount: bigint; | ||
invoice: string; | ||
recipientAddress: string; | ||
setRecipientAddress: (val: string) => void; | ||
setAmount: (val: bigint) => void; | ||
onClickContinue: () => void; | ||
onClickQRCode: () => void; | ||
}) { | ||
let paymentRequest: PaymentRequestObject = { | ||
satoshis: Number(0), | ||
tags: [{ tagName: "payment_hash", data: "abc123" }], | ||
}; | ||
if (invoice !== "") { | ||
paymentRequest = decode(invoice); | ||
} | ||
|
||
function isGenerateQRDisabled(): boolean { | ||
return amount === BigInt(0) || invoice !== ""; | ||
} | ||
return ( | ||
<div className="flex flex-col text-start w-full gap-2"> | ||
<div className="flex-col"> | ||
<span className="text-sm text-gray-500">Recipient Address</span> | ||
<AddressInput | ||
placeholder="0x123...321" | ||
value={recipientAddress} | ||
onChange={newAddress => { | ||
setRecipientAddress(newAddress); | ||
}} | ||
disabled={invoice !== ""} | ||
/> | ||
</div> | ||
<div className="flex-col"> | ||
<span className="text-sm text-gray-500">Amount (sats)</span> | ||
<IntegerInput | ||
value={amount} | ||
onChange={val => setAmount(BigInt(val))} | ||
disableMultiplyBy1e18 | ||
disabled={invoice !== ""} | ||
/> | ||
</div> | ||
<button | ||
className="btn btn-secondary rounded-none w-full" | ||
disabled={isGenerateQRDisabled()} | ||
onClick={() => onClickContinue()} | ||
> | ||
Generate Service Fee Invoice | ||
</button> | ||
{invoice && ( | ||
<div className="flex flex-col w-full gap-2 h-full"> | ||
<button | ||
className="btn btn-neutral rounded-none text-center w-full" | ||
onClick={() => { | ||
onClickQRCode(); | ||
}} | ||
> | ||
Copy Invoice | ||
</button> | ||
<div className="flex flex-col items-center"> | ||
<QRCode size={250} value={invoice} className="" /> | ||
</div> | ||
<div className="flex flex-col"> | ||
<span className="text-center text-gray-500">Service Fee: {paymentRequest.satoshis} sats</span> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { PaymentRequestObject, decode } from "bolt11"; | ||
import QRCode from "qrcode.react"; | ||
|
||
export function Step2({ invoice, onClickQRCode }: { invoice: string; onClickQRCode: () => void }) { | ||
let paymentRequest: PaymentRequestObject = { | ||
satoshis: Number(0), | ||
tags: [{ tagName: "payment_hash", data: "abc123" }], | ||
}; | ||
if (invoice !== "") { | ||
paymentRequest = decode(invoice); | ||
} | ||
return ( | ||
<div className="flex flex-col text-start cursor-pointer w-full" onClick={() => onClickQRCode()}> | ||
| ||
<div className="flex flex-col self-center gap-2"> | ||
<QRCode size={250} value={invoice} /> | ||
<button className="btn btn-neutral rounded-none w-full text-center" onClick={() => onClickQRCode()}> | ||
Copy Invoice | ||
</button> | ||
<div className="flex flex-col"> | ||
<span className="text-center text-gray-500">Invoice: {paymentRequest.satoshis} sats</span> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export function Step3({ txHash }: { txHash: string }) { | ||
return ( | ||
<div className="flex flex-col text-start w-full gap-2"> | ||
<a | ||
href={`https://3xpl.com/botanix/transaction/${txHash}`} | ||
target="_blank" | ||
rel="noreferrer" | ||
className="btn btn-secondary rounded-none w-full" | ||
> | ||
View Transaction | ||
</a> | ||
</div> | ||
); | ||
} |