Skip to content

Commit

Permalink
feat: get rid of invoice type
Browse files Browse the repository at this point in the history
remove exposure of getInvoices via api
fix broken show more button for lndhub
signed-off-by: pavan joshi <pavanj914@gmail.com>
  • Loading branch information
pavanjoshi914 committed Nov 1, 2023
1 parent 6c784cc commit 7984fd5
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 61 deletions.
4 changes: 0 additions & 4 deletions src/common/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import type {
LnurlAuthResponse,
MessageAccountEdit,
MessageAccountValidate,
MessageInvoices,
MessageLnurlAuth,
MessageSettingsSet,
MessageTransactions,
Expand Down Expand Up @@ -171,8 +170,6 @@ export const unlock = (password: string) =>
msg.request<UnlockRes>("unlock", { password });
export const getBlocklist = (host: string) =>
msg.request<BlocklistRes>("getBlocklist", { host });
export const getInvoices = (options?: MessageInvoices["args"]) =>
msg.request<{ invoices: Invoice[] }>("getInvoices", options);
export const getTransactions = (options?: MessageTransactions["args"]) =>
msg.request<{ transactions: Invoice[] }>("getTransactions", options);
export const lnurlAuth = (
Expand Down Expand Up @@ -298,7 +295,6 @@ export default {
removeAccount,
unlock,
getBlocklist,
getInvoices,
getTransactions,
lnurlAuth,
getCurrencyRate,
Expand Down
10 changes: 3 additions & 7 deletions src/common/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import browser, { Runtime } from "webextension-polyfill";
import { ABORT_PROMPT_ERROR } from "~/common/constants";
import { getPosition as getWindowPosition } from "~/common/utils/window";
import type {
DeferredPromise,
Invoice,
OriginData,
OriginDataInternal,
} from "~/types";
import { ConnectorTransaction } from "~/extension/background-script/connectors/connector.interface";
import type { DeferredPromise, OriginData, OriginDataInternal } from "~/types";

const utils = {
base64ToHex: (str: string) => {
Expand Down Expand Up @@ -173,7 +169,7 @@ const utils = {
});
},
getBoostagramFromInvoiceCustomRecords: (
custom_records: Invoice["custom_records"] | undefined
custom_records: ConnectorTransaction["custom_records"] | undefined
) => {
try {
let boostagramDecoded: string | undefined;
Expand Down
3 changes: 1 addition & 2 deletions src/extension/background-script/actions/ln/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import checkPayment from "./checkPayment";
import connectPeer from "./connectPeer";
import getInfo from "./getInfo";
import invoices from "./invoices";

import keysend from "./keysend";
import makeInvoice from "./makeInvoice";
import request from "./request";
Expand All @@ -14,7 +14,6 @@ export {
checkPayment,
connectPeer,
getInfo,
invoices,
keysend,
makeInvoice,
request,
Expand Down
38 changes: 0 additions & 38 deletions src/extension/background-script/actions/ln/invoices.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/extension/background-script/actions/ln/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import utils from "~/common/lib/utils";
import { ConnectorTransaction } from "~/extension/background-script/connectors/connector.interface";
import state from "~/extension/background-script/state";
import type { Invoice, MessageTransactions } from "~/types";
import type { MessageTransactions } from "~/types";

const transactions = async (message: MessageTransactions) => {
const isSettled = message.args.isSettled;
Expand All @@ -10,7 +11,7 @@ const transactions = async (message: MessageTransactions) => {
try {
const result = await connector.getTransactions();

let transactions: Invoice[] = result.data.transactions
let transactions: ConnectorTransaction[] = result.data.transactions
.filter((transaction) =>
isSettled ? transaction.settled : !transaction.settled
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export default interface Connector {
unload(): Promise<void>;
getInfo(): Promise<GetInfoResponse>;
getBalance(): Promise<GetBalanceResponse>;
getInvoices(): Promise<GetInvoicesResponse>;
getTransactions(): Promise<GetTransactionsResponse>;
makeInvoice(args: MakeInvoiceArgs): Promise<MakeInvoiceResponse>;
sendPayment(args: SendPaymentArgs): Promise<SendPaymentResponse>;
Expand Down
9 changes: 7 additions & 2 deletions src/extension/background-script/connectors/lndhub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ export default class LndHub implements Connector {
fee: string;
keysend: boolean;
memo: string;
payment_hash: string;
payment_hash: {
type: string;
data: ArrayBuffer;
};
payment_preimage: string;
r_hash: {
type: "Buffer";
Expand All @@ -175,7 +178,9 @@ export default class LndHub implements Connector {
id: `${index}`,
memo: transaction.memo,
preimage: transaction.payment_preimage,
payment_hash: transaction.payment_hash,
payment_hash: Buffer.from(transaction.payment_hash.data).toString(
"hex"
),
settled: true,
settleDate: transaction.timestamp * 1000,
totalAmount: transaction.value,
Expand Down
1 change: 0 additions & 1 deletion src/extension/background-script/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const routes = {
lock: accounts.lock,
unlock: accounts.unlock,
getInfo: ln.getInfo,
getInvoices: ln.invoices,
getTransactions: ln.transactions,
sendPayment: ln.sendPayment,
sendPaymentAsync: ln.sendPaymentAsync,
Expand Down
4 changes: 0 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,6 @@ export interface MessageAllowanceList extends MessageDefault {
action: "listAllowances";
}

export interface MessageInvoices extends Omit<MessageDefault, "args"> {
args: { limit?: number; isSettled?: boolean };
action: "getInvoices";
}
export interface MessageTransactions extends Omit<MessageDefault, "args"> {
args: { limit?: number; isSettled?: boolean };
action: "getTransactions";
Expand Down

0 comments on commit 7984fd5

Please sign in to comment.