add check-types command and fix type errors

This commit is contained in:
Paul Miller
2023-07-28 11:00:00 -05:00
parent 3f8eafa93c
commit 3868b3f0a0
14 changed files with 1092 additions and 972 deletions

View File

@@ -21,8 +21,8 @@ import { DIALOG_CONTENT, DIALOG_POSITIONER } from "~/styles/dialogs";
import { InfoBox } from "./InfoBox";
import { Network } from "~/logic/mutinyWalletSetup";
import { FeesModal } from "./MoreInfoModal";
import { useNavigate } from "@solidjs/router";
import { useI18n } from "~/i18n/context";
import { useNavigate } from "solid-start";
const FIXED_AMOUNTS_SATS = [
{ label: "10k", amount: "10000" },
@@ -70,7 +70,7 @@ function SingleDigitButton(props: {
fiat: boolean;
}) {
const i18n = useI18n();
let holdTimer: number;
let holdTimer: ReturnType<typeof setTimeout> | undefined;
const holdThreshold = 500;
function onHold() {

View File

@@ -2,12 +2,11 @@ import { onCleanup, onMount } from "solid-js";
import {
BarcodeScanner,
BarcodeFormat,
CameraPermissionState,
CameraPermissionType,
CameraPluginPermissions,
PermissionStates
PermissionStates,
ScanResult
} from "@mutinywallet/barcode-scanner";
import QrScanner from "qr-scanner";
import { Capacitor } from "@capacitor/core";
export default function Scanner(props: { onResult: (result: string) => void }) {
let container: HTMLVideoElement | undefined;
@@ -22,7 +21,7 @@ export default function Scanner(props: { onResult: (result: string) => void }) {
const permissions: PermissionStates =
await BarcodeScanner.checkPermissions();
if (permissions.camera === "granted") {
const callback = (result: ScanResult, err?: any) => {
const callback = (result: ScanResult, err?: unknown) => {
if (err) {
console.error(err);
return;
@@ -33,7 +32,7 @@ export default function Scanner(props: { onResult: (result: string) => void }) {
}
};
await BarcodeScanner.start(
{ targetedFormats: [BarcodeFormat.QR_CODE] },
{ formats: [BarcodeFormat.QR_CODE] },
callback
);
} else if (permissions.camera === "prompt") {

View File

@@ -29,8 +29,7 @@ export default {
"A lightning setup fee will be charged if paid over lightning.",
too_big_for_beta:
"That's a lot of sats. You do know Mutiny Wallet is still in beta, yeah?",
more_than_21m:
"There are only 21 million bitcoin.",
more_than_21m: "There are only 21 million bitcoin.",
set_amount: "Set amount",
max: "MAX"
}

View File

@@ -42,14 +42,33 @@ export function getExistingSettings(): MutinyWalletSettingStrings {
localStorage.getItem("MUTINY_SETTINGS_scorer") ||
import.meta.env.VITE_SCORER;
return { network, proxy, esplora, rgs, lsp, auth, subscriptions, storage, scorer };
return {
network,
proxy,
esplora,
rgs,
lsp,
auth,
subscriptions,
storage,
scorer
};
}
export async function setAndGetMutinySettings(
settings?: MutinyWalletSettingStrings
): Promise<MutinyWalletSettingStrings> {
let { network, proxy, esplora, rgs, lsp, auth, subscriptions, storage, scorer } =
settings || {};
let {
network,
proxy,
esplora,
rgs,
lsp,
auth,
subscriptions,
storage,
scorer
} = settings || {};
const existingSettings = getExistingSettings();
@@ -98,7 +117,7 @@ export async function setAndGetMutinySettings(
auth,
subscriptions,
storage,
scorer
scorer
};
} catch (error) {
console.error(error);
@@ -152,8 +171,17 @@ export async function setupMutinyWallet(
password?: string
): Promise<MutinyWallet> {
console.log("Starting setup...");
const { network, proxy, esplora, rgs, lsp, auth, subscriptions, storage, scorer } =
await setAndGetMutinySettings(settings);
const {
network,
proxy,
esplora,
rgs,
lsp,
auth,
subscriptions,
storage,
scorer
} = await setAndGetMutinySettings(settings);
console.log("Initializing Mutiny Manager");
console.log("Using network", network);
console.log("Using proxy", proxy);

View File

@@ -382,9 +382,10 @@ export default function Redshift() {
return (await state.mutiny_wallet?.list_utxos()) as UtxoItem[];
};
// TODO: FIXME: this is old code needs to be revisited!
const getChannels = async () => {
console.log("Getting channels");
await state.mutiny_wallet?.sync();
// await state.mutiny_wallet?.sync();
const channels =
(await state.mutiny_wallet?.list_channels()) as Promise<
MutinyChannel[]

View File

@@ -29,9 +29,7 @@ export default function Scanner() {
let text;
if (Capacitor.isNativePlatform()) {
const { value } = await Clipboard.read({
type: "string"
});
const { value } = await Clipboard.read();
text = value;
} else {
text = await navigator.clipboard.readText();

View File

@@ -391,9 +391,7 @@ export default function Send() {
let text;
if (Capacitor.isNativePlatform()) {
const { value } = await Clipboard.read({
type: "string"
});
const { value } = await Clipboard.read();
text = value;
} else {
if (!navigator.clipboard.readText) {

View File

@@ -12,11 +12,11 @@ export default function NotFound() {
const i18n = useI18n();
return (
<SafeArea>
<Title>{i18n.t("not_found.title")}</Title>
<Title>{i18n.t("error.not_found.title")}</Title>
<HttpStatusCode code={404} />
<DefaultMain>
<LargeHeader>{i18n.t("not_found.title")}</LargeHeader>
<p>{i18n.t("not_found.wtf_paul")}</p>
<LargeHeader>{i18n.t("error.not_found.title")}</LargeHeader>
<p>{i18n.t("error.not_found.wtf_paul")}</p>
<div class="h-full" />
<ButtonLink href="/" intent="red">
{i18n.t("common.dangit")}

View File

@@ -97,9 +97,7 @@ function TwelveWordsEntry() {
let text;
if (Capacitor.isNativePlatform()) {
const { value } = await Clipboard.read({
type: "string"
});
const { value } = await Clipboard.read();
text = value;
} else {
if (!navigator.clipboard.readText) {

View File

@@ -12,7 +12,7 @@ export const useCopy = ({ copiedTimeout = 2000 }: UseCopyProps = {}): [
copied: Accessor<boolean>
] => {
const [copied, setCopied] = createSignal(false);
let timeout: number;
let timeout: ReturnType<typeof setTimeout> | undefined;
const copy: CopyFn = async (text) => {
if (Capacitor.isNativePlatform()) {
await Clipboard.write({