Skip to content

Commit

Permalink
Update vortex extension (raycast#16626)
Browse files Browse the repository at this point in the history
* Update vortex extension

- Merge pull request raycast#3 from d4rp4t/fiat-transactions
- Merge branch \'getAlby:main\' into fiat-transactions
- prepare for publish prettier + lint
- Changelog Update
- Merge pull request raycast#13 from d4rp4t/fiat-transactions
- Enable redemption of tokens regardless of their unit distribution
- Add \'fiat\' transactions
- Merge pull request #2 from d4rp4t/add_cashu_support
- Merge pull request raycast#12 from d4rp4t/add_cashu_support
- fix checksum error with npm ci
- fix checksum error with npm ci
- Readme edit
- publish
- Prettier + ESlint fixes
- Prettier + ESlint fixes
- Change withdraw icon to png
- Add redeem function for Cashu tokens and LNURL vouchers, update dependencies. Code cleanup
- code cleanup
- Merge pull request #1 from d4rp4t/dev
- Show fiat value for each transaction.
- Transaction details added.
- Remove duplicated function. Balance can be checked in Recent Transactions. Updated Dependencies
- Chagelog
- update dependencies
- fix linting errors
- raycast clint, eslint install
- Screenshots
- Merge pull request raycast#10 from getAlby/error
- Show error message when the wallet connection fails
- Merge pull request raycast#6 from getAlby/naming
- Merge pull request raycast#7 from getAlby/lint
- fiat balance
- linting
- Better invoice status naming
- Remove yarn.lock we use npm
- nicer loading
- Merge pull request raycast#3 from getAlby/fiat-balance-and-cleanup
- Fiat balance
- cleanup
- Placeholder
- Copy and names
- Copy and icons update
- Update README.md
- Initial commit

* cleanup

* cleanup

* restore compressed images
  • Loading branch information
d4rp4t authored Feb 4, 2025
1 parent 34b4bf7 commit 5bda66f
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 358 deletions.
12 changes: 9 additions & 3 deletions extensions/vortex/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# Alby Changelog

## [Features] - 2025-01-26

- Added Support for creating invoices in fiat.
- Added Support for sending zaps via lightning address in fiat
- Added support for cashu tokens with all units

## [Features] - 2025-01-12

- Removed View Balance function - it could be checked in last transactions.
- Removed View Balance function - it could be checked in last transactions.
- Modified Last Transactions function - now user can see details.
- Added Cashu Tokens and LNURL redeeming support in Redeem function.
- Code cleanup.
- Code cleanup.
- Dependency updates.
- Added Inline Command Parameters for Send and Redeem commands.

## [Dependency Updates] - 2024-05-17

- Fixed bug handling lightning addresses with no custom key/value records

## [Initial Version] - 2023-12-22
## [Initial Version] - 2023-12-22
51 changes: 0 additions & 51 deletions extensions/vortex/src/Balance.tsx

This file was deleted.

23 changes: 0 additions & 23 deletions extensions/vortex/src/ConnectionError.tsx

This file was deleted.

45 changes: 39 additions & 6 deletions extensions/vortex/src/CreateInvoice.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
import { setInterval } from "timers";
import { useEffect, useRef, useState } from "react";
import { Action, ActionPanel, Detail, environment, Form, Icon, LaunchProps, showToast, Toast } from "@raycast/api";
import {
Action,
ActionPanel,
Detail,
environment,
Form,
getPreferenceValues,
Icon,
LaunchProps,
showToast,
Toast,
} from "@raycast/api";
import { toDataURL } from "qrcode";
import { webln } from "@getalby/sdk";

import ConnectionError from "./components/ConnectionError";
import { connectWallet } from "./utils/wallet";
import { fiat } from "@getalby/lightning-tools";
import "cross-fetch/polyfill";

export default function CreateInvoice(props: LaunchProps<{ arguments: Arguments.Createinvoice }>) {
const [amount, setAmount] = useState(props.arguments.input);
const [amount, setAmount] = useState<string>(props.arguments.input);
const [description, setDescription] = useState("");
const [invoice, setInvoice] = useState<string | undefined>();
const [invoiceMarkdown, setInvoiceMarkdown] = useState<string | undefined>();
const [invoiceState, setInvoiceState] = useState("pending");
const [loading, setLoading] = useState<boolean>(false);
const [connectionError, setConnectionError] = useState<unknown>(null);
const [isSatDenomination, setSatDenomination] = useState(true);

const invoiceCheckerIntervalRef = useRef<NodeJS.Timeout>();
const invoiceCheckCounterRef = useRef(0);
const nwc = useRef<webln.NostrWebLNProvider>();

const fiatCurrency = getPreferenceValues<{ currency: string }>().currency;

const checkInvoicePayment = (invoice: string) => {
if (invoiceCheckerIntervalRef && invoiceCheckerIntervalRef.current) {
clearInterval(invoiceCheckerIntervalRef.current);
Expand Down Expand Up @@ -56,10 +73,15 @@ export default function CreateInvoice(props: LaunchProps<{ arguments: Arguments.

try {
setLoading(true);
let satoshis: string | number = amount;
nwc.current = await connectWallet();
await showToast(Toast.Style.Animated, "Requesting invoice...");
if (!isSatDenomination) {
satoshis = await fiat.getSatoshiValue({ amount: amount, currency: fiatCurrency });
console.log(satoshis);
}
const invoiceResponse = await nwc.current.makeInvoice({
amount, // This should be the amount in satoshis
amount: satoshis, // This should be the amount in satoshis
defaultMemo: description,
});

Expand All @@ -74,6 +96,7 @@ export default function CreateInvoice(props: LaunchProps<{ arguments: Arguments.
} catch (error) {
setConnectionError(error);
await showToast(Toast.Style.Failure, "Error creating invoice");
console.trace(error);
} finally {
setLoading(false);
}
Expand Down Expand Up @@ -117,13 +140,19 @@ export default function CreateInvoice(props: LaunchProps<{ arguments: Arguments.
actions={
<ActionPanel>
<Action title="Create Invoice" onAction={handleCreateInvoice} />

<Action
title={`Swap Currency to ${isSatDenomination ? fiatCurrency : "Satoshi"}`}
onAction={() => setSatDenomination(!isSatDenomination)}
shortcut={{ modifiers: ["cmd"], key: "s" }}
/>
</ActionPanel>
}
>
<Form.TextField
id="amount"
title="Amount (Satoshis)"
placeholder="Enter the amount in satoshis"
title={`Amount (${isSatDenomination ? "Satoshis" : fiatCurrency})`}
placeholder={`Enter the amount in ${isSatDenomination ? "satoshis" : fiatCurrency}`}
value={amount}
onChange={setAmount}
/>
Expand All @@ -147,7 +176,11 @@ export default function CreateInvoice(props: LaunchProps<{ arguments: Arguments.
}
metadata={
<Detail.Metadata>
<Detail.Metadata.Label title="Amount" text={`${amount} sats`} icon={Icon.Bolt} />
<Detail.Metadata.Label
title="Amount"
text={`${amount} ${isSatDenomination ? "sats" : fiatCurrency}`}
icon={Icon.Bolt}
/>
<Detail.Metadata.Label title="Description" text={description} />
<Detail.Metadata.TagList title="Status">
<Detail.Metadata.TagList.Item
Expand Down
82 changes: 0 additions & 82 deletions extensions/vortex/src/PayInvoice.tsx

This file was deleted.

Loading

0 comments on commit 5bda66f

Please sign in to comment.