change hardcoded signets to actual network

This commit is contained in:
Paul Miller
2023-05-15 09:32:21 -05:00
parent 71695795c2
commit 7e7804e3d9
6 changed files with 26 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
import { LoadingSpinner, NiceP, SmallAmount, SmallHeader } from './layout';
import { For, Match, ParentComponent, Show, Switch, createEffect, createMemo, createResource, createSignal } from 'solid-js';
import { For, Match, Show, Switch, createEffect, createMemo, createResource, createSignal } from 'solid-js';
import { useMegaStore } from '~/state/megaStore';
import { MutinyInvoice } from '@mutinywallet/mutiny-wasm';
import { JsonModal } from '~/components/JsonModal';
@@ -8,6 +8,7 @@ import utxoIcon from '~/assets/icons/coin.svg';
import { getRedshifted } from '~/utils/fakeLabels';
import { ActivityItem } from './ActivityItem';
import { MutinyTagItem } from '~/utils/tags';
import { Network } from '~/logic/mutinyWalletSetup';
export const THREE_COLUMNS = 'grid grid-cols-[auto,1fr,auto] gap-4 py-2 px-2 border-b border-neutral-800 last:border-b-0'
export const CENTER_COLUMN = 'min-w-0 overflow-hidden max-w-full'
@@ -40,11 +41,7 @@ export type UtxoItem = {
redshifted?: boolean,
}
const SubtleText: ParentComponent = (props) => {
return <h3 class='text-xs text-gray-500 uppercase'>{props.children}</h3>
}
function OnChainItem(props: { item: OnChainTx, labels: MutinyTagItem[] }) {
function OnChainItem(props: { item: OnChainTx, labels: MutinyTagItem[], network: Network }) {
const isReceive = () => props.item.received > props.item.sent
const [open, setOpen] = createSignal(false)
@@ -52,7 +49,7 @@ function OnChainItem(props: { item: OnChainTx, labels: MutinyTagItem[] }) {
return (
<>
<JsonModal open={open()} data={props.item} title="On-Chain Transaction" setOpen={setOpen}>
<a href={mempoolTxUrl(props.item.txid, "signet")} target="_blank" rel="noreferrer">
<a href={mempoolTxUrl(props.item.txid, props.network)} target="_blank" rel="noreferrer">
Mempool Link
</a>
</JsonModal>
@@ -158,6 +155,8 @@ export function CombinedActivity(props: { limit?: number }) {
const [activity, { refetch }] = createResource(getAllActivity);
const network = state.mutiny_wallet?.get_network() as Network;
createEffect(() => {
// After every sync we should refetch the activity
if (!state.is_syncing) {
@@ -178,11 +177,9 @@ export function CombinedActivity(props: { limit?: number }) {
{(activityItem) =>
<Switch>
<Match when={activityItem.type === "onchain"}>
{/* FIXME */}
<OnChainItem item={activityItem.item as OnChainTx} labels={activityItem.labels} />
<OnChainItem item={activityItem.item as OnChainTx} labels={activityItem.labels} network={network} />
</Match>
<Match when={activityItem.type === "lightning"}>
{/* FIXME */}
<InvoiceItem item={activityItem.item as MutinyInvoice} labels={activityItem.labels} />
</Match>
</Switch>

View File

@@ -9,6 +9,7 @@ import eify from "~/utils/eify";
import { ConfirmDialog } from "~/components/Dialog";
import { showToast } from "~/components/Toaster";
import { ImportExport } from "~/components/ImportExport";
import { Network } from "~/logic/mutinyWalletSetup";
// TODO: hopefully I don't have to maintain this type forever but I don't know how to pass it around otherwise
type RefetchPeersType = (info?: unknown) => MutinyPeer[] | Promise<MutinyPeer[] | undefined> | null | undefined
@@ -127,7 +128,7 @@ function ConnectPeer(props: { refetchPeers: RefetchPeersType }) {
type RefetchChannelsListType = (info?: unknown) => MutinyChannel[] | Promise<MutinyChannel[] | undefined> | null | undefined
function ChannelItem(props: { channel: MutinyChannel, network?: string }) {
function ChannelItem(props: { channel: MutinyChannel, network?: Network }) {
const [state, _] = useMegaStore()
const [confirmOpen, setConfirmOpen] = createSignal(false);
@@ -194,7 +195,7 @@ function ChannelsList() {
});
})
const network = state.mutiny_wallet?.get_network();
const network = state.mutiny_wallet?.get_network() as Network;
return (
<>
@@ -253,6 +254,8 @@ function OpenChannel(props: { refetchChannels: RefetchChannelsListType }) {
}
};
const network = state.mutiny_wallet?.get_network() as Network;
return (
<>
<InnerCard>
@@ -283,7 +286,7 @@ function OpenChannel(props: { refetchChannels: RefetchChannelsListType }) {
{JSON.stringify(newChannel()?.outpoint, null, 2)}
</pre>
<pre>{newChannel()?.outpoint}</pre>
<a class="text-sm font-light opacity-50 mt-2" href={mempoolTxUrl(newChannel()?.outpoint?.split(":")[0], "signet")} target="_blank" rel="noreferrer">
<a class="text-sm font-light opacity-50 mt-2" href={mempoolTxUrl(newChannel()?.outpoint?.split(":")[0], network)} target="_blank" rel="noreferrer">
Mempool Link
</a>
</Show>

View File

@@ -6,7 +6,7 @@ import initWaila from '@mutinywallet/waila-wasm'
// network?: string, proxy?: string, esplora?: string, rgs?: string, lsp?: string,
// }
type Network = "bitcoin" | "testnet" | "regtest" | "signet";
export type Network = "bitcoin" | "testnet" | "regtest" | "signet";
export type MutinyWalletSettingStrings = {
network?: Network, proxy?: string, esplora?: string, rgs?: string, lsp?: string,
}

View File

@@ -18,6 +18,7 @@ import { AmountCard } from "~/components/AmountCard";
import { ShareCard } from "~/components/ShareCard";
import { BackButton } from "~/components/layout/BackButton";
import { MutinyTagItem } from "~/utils/tags";
import { Network } from "~/logic/mutinyWalletSetup";
type OnChainTx = {
transaction: {
@@ -181,6 +182,8 @@ export default function Receive() {
const [paidState, { refetch }] = createResource(bip21Raw, checkIfPaid);
const network = state.mutiny_wallet?.get_network() as Network;
createEffect(() => {
const interval = setInterval(() => {
if (receiveState() === "show") refetch();
@@ -242,7 +245,7 @@ export default function Receive() {
<div class="flex flex-col items-center gap-8">
<img src={megacheck} alt="success" class="w-1/2 mx-auto max-w-[50vh] aspect-square" />
<Amount amountSats={paymentTx()?.received} showFiat />
<a href={mempoolTxUrl(paymentTx()?.txid, "signet")} target="_blank" rel="noreferrer">
<a href={mempoolTxUrl(paymentTx()?.txid, network)} target="_blank" rel="noreferrer">
Mempool Link
</a>
</div>

View File

@@ -13,6 +13,7 @@ import { MutinyChannel } from "@mutinywallet/mutiny-wasm";
import mempoolTxUrl from "~/utils/mempoolTxUrl";
import { Amount } from "~/components/Amount";
import { getRedshifted, setRedshifted } from "~/utils/fakeLabels";
import { Network } from "~/logic/mutinyWalletSetup";
type ShiftOption = "utxo" | "lightning"
@@ -106,6 +107,8 @@ function RedshiftReport(props: { redshift: RedshiftResult, utxo: UtxoItem }) {
setRedshifted(true, redshiftResource()?.output_utxo)
})
const network = state.mutiny_wallet?.get_network() as Network;
return (
<VStack biggap>
@@ -141,7 +144,7 @@ function RedshiftReport(props: { redshift: RedshiftResult, utxo: UtxoItem }) {
<KV key="Outbound channel">
<VStack>
<pre class="whitespace-pre-wrap break-all">{redshiftResource().introduction_channel}</pre>
<a class="" href={mempoolTxUrl(redshiftResource().introduction_channel?.split(":")[0], "signet")} target="_blank" rel="noreferrer">
<a class="" href={mempoolTxUrl(redshiftResource().introduction_channel?.split(":")[0], network)} target="_blank" rel="noreferrer">
View on mempool
</a>
</VStack>
@@ -150,7 +153,7 @@ function RedshiftReport(props: { redshift: RedshiftResult, utxo: UtxoItem }) {
<KV key="Return channel">
<VStack>
<pre class="whitespace-pre-wrap break-all">{redshiftResource().output_channel}</pre>
<a class="" href={mempoolTxUrl(redshiftResource().output_channel?.split(":")[0], "signet")} target="_blank" rel="noreferrer">
<a class="" href={mempoolTxUrl(redshiftResource().output_channel?.split(":")[0], network)} target="_blank" rel="noreferrer">
View on mempool
</a>

View File

@@ -1,4 +1,6 @@
export default function mempoolTxUrl(txid?: string, network?: string) {
import { Network } from "~/logic/mutinyWalletSetup"
export default function mempoolTxUrl(txid?: string, network?: Network) {
if (!txid || !network) {
console.error("Problem creating the mempool url")
return "#"