Skip to content

Commit

Permalink
toggle hodl
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul authored and TonyGiorgio committed Nov 16, 2023
1 parent 59abe9d commit 761222c
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 15 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.mutinywallet.mutinywallet"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 35
versionName "0.4.34"
versionCode 36
versionName "0.4.35"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
4 changes: 2 additions & 2 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.finance";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.4.34;
MARKETING_VERSION = 1.4.35;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = com.mutinywallet.mutiny;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -387,7 +387,7 @@
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.finance";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.4.34;
MARKETING_VERSION = 1.4.35;
PRODUCT_BUNDLE_IDENTIFIER = com.mutinywallet.mutiny;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mutiny-wallet",
"version": "0.4.34",
"version": "0.4.35",
"license": "MIT",
"packageManager": "[email protected]",
"scripts": {
Expand Down Expand Up @@ -57,7 +57,7 @@
"@kobalte/core": "^0.9.8",
"@kobalte/tailwindcss": "^0.5.0",
"@modular-forms/solid": "^0.18.1",
"@mutinywallet/mutiny-wasm": "0.4.34",
"@mutinywallet/mutiny-wasm": "0.4.35",
"@mutinywallet/waila-wasm": "^0.2.4",
"@solid-primitives/upload": "^0.0.111",
"@solid-primitives/websocket": "^1.2.0",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/components/KitchenSink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
Restart,
ResyncOnchain,
showToast,
ToggleHodl,
VStack
} from "~/components";
import { useI18n } from "~/i18n/context";
Expand Down Expand Up @@ -465,6 +466,8 @@ export function KitchenSink() {
<Hr />
<ChannelsList />
<Hr />
<ToggleHodl />
<Hr />
<ResyncOnchain />
<Hr />
<ResetRouter />
Expand Down
42 changes: 42 additions & 0 deletions src/components/ToggleHodl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Button, InnerCard, NiceP, VStack } from "~/components";
import { useI18n } from "~/i18n/context";
import { useMegaStore } from "~/state/megaStore";

export function ToggleHodl() {
const i18n = useI18n();
const [state, actions] = useMegaStore();

async function toggle() {
try {
await actions.toggleHodl();
window.location.href = "/";
} catch (e) {
console.error(e);
}
}

return (
<InnerCard
title={i18n.t("settings.admin.kitchen_sink.enable_zaps_to_hodl")}
>
<VStack>
<NiceP>
{i18n.t("settings.admin.kitchen_sink.zaps_to_hodl_desc")}
</NiceP>

<Button
intent={state.should_zap_hodl ? "green" : "red"}
onClick={toggle}
>
{state.should_zap_hodl
? i18n.t(
"settings.admin.kitchen_sink.zaps_to_hodl_disable"
)
: i18n.t(
"settings.admin.kitchen_sink.zaps_to_hodl_enable"
)}
</Button>
</VStack>
</InnerCard>
);
}
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ export * from "./NostrActivity";
export * from "./SyncContactsForm";
export * from "./GiftLink";
export * from "./MutinyPlusCta";
export * from "./ToggleHodl";
7 changes: 6 additions & 1 deletion src/i18n/en/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ export default {
amount: "Amount",
open_channel: "Open Channel",
nodes: "Nodes",
no_nodes: "No nodes"
no_nodes: "No nodes",
enable_zaps_to_hodl: "Enable zaps to hodl invoices?",
zaps_to_hodl_desc:
"Zaps to hodl invoices can result in channel force closes, which results in high on-chain fees. Use at your own risk!",
zaps_to_hodl_enable: "Enable hodl zaps",
zaps_to_hodl_disable: "Disable hodl zaps"
}
},
backup: {
Expand Down
8 changes: 6 additions & 2 deletions src/logic/mutinyWalletSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ export async function initializeWasm() {
export async function setupMutinyWallet(
settings: MutinyWalletSettingStrings,
password?: string,
safeMode?: boolean
safeMode?: boolean,
shouldZapHodl?: boolean
): Promise<MutinyWallet> {
console.log("Starting setup...");

Expand Down Expand Up @@ -245,6 +246,7 @@ export async function setupMutinyWallet(
console.log("Using storage address", storage);
console.log("Using scorer address", scorer);
console.log(safeMode ? "Safe mode enabled" : "Safe mode disabled");
console.log(shouldZapHodl ? "Hodl zaps enabled" : "Hodl zaps disabled");

const mutinyWallet = await new MutinyWallet(
// Password
Expand All @@ -265,7 +267,9 @@ export async function setupMutinyWallet(
// Do not skip device lock
undefined,
// Safe mode
safeMode || undefined
safeMode || undefined,
// Skip hodl invoices? (defaults to true, so if shouldZapHodl is true that's when we pass false)
shouldZapHodl ? false : undefined
);

sessionStorage.setItem("MUTINY_WALLET_INITIALIZED", Date.now().toString());
Expand Down
13 changes: 11 additions & 2 deletions src/state/megaStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type MegaStore = [
npub?: string;
preferredInvoiceType: "unified" | "lightning" | "onchain";
betaWarned: boolean;
should_zap_hodl: boolean;
},
{
setup(password?: string): Promise<void>;
Expand All @@ -87,6 +88,7 @@ export type MegaStore = [
onSuccess: (value: ParsedParams) => void
): void;
setBetaWarned(): void;
toggleHodl(): void;
}
];

Expand Down Expand Up @@ -121,7 +123,8 @@ export const Provider: ParentComponent = (props) => {
safe_mode: searchParams.safe_mode === "true",
npub: localStorage.getItem("npub") || undefined,
preferredInvoiceType: "unified" as "unified" | "lightning" | "onchain",
betaWarned: localStorage.getItem("betaWarned") === "true"
betaWarned: localStorage.getItem("betaWarned") === "true",
should_zap_hodl: localStorage.getItem("should_zap_hodl") === "true"
});

const actions = {
Expand Down Expand Up @@ -177,7 +180,8 @@ export const Provider: ParentComponent = (props) => {
const mutinyWallet = await setupMutinyWallet(
settings,
password,
state.safe_mode
state.safe_mode,
state.should_zap_hodl
);

// Give other components access to settings via the store
Expand Down Expand Up @@ -381,6 +385,11 @@ export const Provider: ParentComponent = (props) => {
setBetaWarned() {
localStorage.setItem("betaWarned", "true");
setState({ betaWarned: true });
},
toggleHodl() {
const should_zap_hodl = !state.should_zap_hodl;
localStorage.setItem("should_zap_hodl", should_zap_hodl.toString());
setState({ should_zap_hodl });
}
};

Expand Down

0 comments on commit 761222c

Please sign in to comment.