Skip to content

Commit

Permalink
chore: some linting #1727
Browse files Browse the repository at this point in the history
  • Loading branch information
escapedcat committed Nov 23, 2022
1 parent 335738e commit 2d39f40
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 50 deletions.
1 change: 0 additions & 1 deletion src/app/screens/Nostr/ConfirmSignMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function ConfirmSignMessage() {
const [rememberPermission, setRememberPermission] = useState(false);

// TODO: refactor: the success message and loading will not be displayed because after the reply the prompt is closed.
// escapedcat: is this ok because we only show these in the popup usually?
async function confirm() {
try {
setLoading(true);
Expand Down
4 changes: 0 additions & 4 deletions src/app/screens/Unlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,10 @@ function Unlock() {
function unlock() {
auth
.unlock(password, () => {
console.log("FROM", from);

if (from !== "/") {
console.log("FROM JA");
navigate(from, { replace: true });
} else {
// unlock was triggered on it's own there's no from (i.e. nostr action)
console.log("FROM NEIn");
window.close();
}
})
Expand Down
10 changes: 0 additions & 10 deletions src/extension/background-script/actions/allowances/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,19 @@ const enable = async (
message: MessageAllowanceEnable,
sender?: Runtime.MessageSender
) => {
console.log("INSIDE enbale <---- message: ", message);
const isUnlocked = state.getState().isUnlocked();
const host = message.origin.host || message.args.host;
const allowance = await db.allowances
.where("host")
.equalsIgnoreCase(host)
.first();
console.log("enable -> isUnlocked: ", isUnlocked);
console.log("enable -> allowance: ", allowance);

if (isUnlocked && allowance && allowance.enabled) {
console.log("enable -> no prompt needed");

return {
data: { enabled: true },
};
} else {
console.log("enable -> prompt needed");

try {
console.log("enable -> prompt needed - try");
const response = await utils.openPrompt<{
enabled: boolean;
remember: boolean;
Expand All @@ -40,8 +32,6 @@ const enable = async (
await setIcon(ExtensionIcon.Active, sender.tab.id as number); // highlight the icon when enabled
}

console.log("enable -> prompt needed - response: ", response);

// if the response should be saved/remembered we update the allowance for the domain
// as this returns a promise we must wait until it resolves
if (response.data.enabled && response.data.remember) {
Expand Down
33 changes: 2 additions & 31 deletions src/extension/background-script/actions/nostr/signEventOrPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@ const signEventOrPrompt = async (message: MessageSignEvent) => {
};
}

console.log("message.args.event", message.args.event);

const enableMessage: MessageAllowanceEnable = {
origin: message.origin, // TODO: make sure we pass the image as well
origin: message.origin,
args: {
host: message.origin.host,
},
action: "public/webln/enable",
};

const foo = await enable(enableMessage);
console.log("after enbale <----", foo);
await enable(enableMessage);

const dbPermissions = await db.permissions
.where("host")
Expand All @@ -60,26 +57,6 @@ const signEventOrPrompt = async (message: MessageSignEvent) => {
throw new Error("User rejected");
}

// if (!allowanceId) {
// console.log("mno matching allowance");

// const dbAllowance: DbAllowance = {
// createdAt: Date.now().toString(),
// enabled: true,
// host: message.origin.host,
// imageURL: "", // need to get the image
// lastPaymentAt: 0,
// lnurlAuth: false,
// name: "",
// remainingBudget: 0,
// tag: "",
// totalBudget: 0,
// };
// allowanceId = await db.allowances.add(dbAllowance);
// }

console.log("matching allowance!");

if (response.data.rememberPermission) {
const matchingAllowance = await db.allowances
.where("host")
Expand All @@ -89,8 +66,6 @@ const signEventOrPrompt = async (message: MessageSignEvent) => {

if (!allowanceId) return; // type-guard only

console.log("rememberme?");

const permission: DbPermission = {
createdAt: Date.now().toString(),
allowanceId,
Expand All @@ -99,20 +74,16 @@ const signEventOrPrompt = async (message: MessageSignEvent) => {
enabled: true,
blocked: false,
};
console.log("rememberme!", permission);

await db.permissions.add(permission);
}
}

console.log("SO HAZ permissions - message: ", message);
const signedEvent = await state
.getState()
.getNostr()
.signEvent(message.args.event);

console.log("SO HAZ permissions - signedEvent: ", signedEvent);

return { data: signedEvent };
} catch (e) {
console.error("signEvent cancelled", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import db from "../../db";
import sendPayment from "../ln/sendPayment";

const sendPaymentOrPrompt = async (message: Message) => {
console.log("sendPaymentOrPrompt");

if (!("host" in message.origin)) return;

const paymentRequest = message.args.paymentRequest;
Expand Down Expand Up @@ -40,8 +38,6 @@ async function checkAllowance(host: string, amount: number) {
}

async function sendPaymentWithAllowance(message: Message) {
console.log("sendPaymentWithAllowance");

try {
const response = await sendPayment(message);
return response;
Expand Down

0 comments on commit 2d39f40

Please sign in to comment.