-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
200 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.DS_Store | ||
.env | ||
.env.local | ||
*.db | ||
*.macaroon | ||
node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VITE_APP_TYPE=HTTP | ||
#VITE_APP_TYPE=WAILS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import React from "react"; | ||
import { useCSRF } from "src/hooks/useCSRF"; | ||
import { BackendType } from "src/types"; | ||
import { | ||
appFetch, | ||
handleFetchError, | ||
validateFetchResponse, | ||
} from "src/utils/fetch"; | ||
|
||
export function Setup() { | ||
const [backendType, setBackendType] = React.useState<BackendType>("BREEZ"); | ||
const [greenlightInviteCode, setGreenlightInviteCode] = | ||
React.useState<string>(""); | ||
const [mnemonic, setMnemonic] = React.useState<string>(""); | ||
const { data: csrf } = useCSRF(); | ||
|
||
async function handleSubmit(e: React.FormEvent) { | ||
e.preventDefault(); | ||
try { | ||
if (!greenlightInviteCode || !mnemonic) { | ||
throw new Error("please fill out all fields"); | ||
} | ||
if (!csrf) { | ||
throw new Error("info not loaded"); | ||
} | ||
const response = await appFetch("/api/setup", { | ||
method: "POST", | ||
headers: { | ||
"X-CSRF-Token": csrf, | ||
}, | ||
body: JSON.stringify({}), | ||
}); | ||
await validateFetchResponse(response); | ||
window.location.href = "/"; | ||
} catch (error) { | ||
handleFetchError("Failed to connect", error); | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<p className="mb-4"> | ||
Enter your node connection credentials to connect to your wallet. | ||
</p> | ||
<form onSubmit={handleSubmit}> | ||
<label | ||
htmlFor="backend-type" | ||
className="block font-medium text-gray-900 dark:text-white" | ||
> | ||
Backend Type | ||
</label> | ||
<select | ||
name="backend-type" | ||
value={backendType} | ||
onChange={(e) => setBackendType(e.target.value as BackendType)} | ||
id="backend-type" | ||
className="mb-4 bg-gray-50 border border-gray-300 text-gray-900 focus:ring-purple-700 dark:focus:ring-purple-600 dark:ring-offset-gray-800 focus:ring-2 text-sm rounded-lg block w-full p-2.5 dark:bg-surface-00dp dark:border-gray-700 dark:placeholder-gray-400 dark:text-white" | ||
> | ||
<option value={"BREEZ"}>Breez</option> | ||
<option value={"LND"}>LND</option> | ||
</select> | ||
|
||
{backendType === "BREEZ" && ( | ||
<> | ||
<label | ||
htmlFor="greenlight-invite-code" | ||
className="block font-medium text-gray-900 dark:text-white" | ||
> | ||
Greenlight Invite Code | ||
</label> | ||
<input | ||
name="greenlight-invite-code" | ||
onChange={(e) => setGreenlightInviteCode(e.target.value)} | ||
value={greenlightInviteCode} | ||
type="password" | ||
id="greenlight-invite-code" | ||
className="bg-gray-50 border border-gray-300 text-gray-900 focus:ring-purple-700 dark:focus:ring-purple-600 dark:ring-offset-gray-800 focus:ring-2 text-sm rounded-lg block w-full p-2.5 dark:bg-surface-00dp dark:border-gray-700 dark:placeholder-gray-400 dark:text-white" | ||
/> | ||
<label | ||
htmlFor="greenlight-invite-code" | ||
className="mt-4 block font-medium text-gray-900 dark:text-white" | ||
> | ||
BIP39 Mnemonic | ||
</label> | ||
<input | ||
name="mnemonic" | ||
onChange={(e) => setMnemonic(e.target.value)} | ||
value={mnemonic} | ||
type="password" | ||
id="mnemonic" | ||
className="bg-gray-50 border border-gray-300 text-gray-900 focus:ring-purple-700 dark:focus:ring-purple-600 dark:ring-offset-gray-800 focus:ring-2 text-sm rounded-lg block w-full p-2.5 dark:bg-surface-00dp dark:border-gray-700 dark:placeholder-gray-400 dark:text-white" | ||
/> | ||
</> | ||
)} | ||
{backendType === "LND" && ( | ||
<> | ||
<p>Coming soon</p> | ||
</> | ||
)} | ||
<button | ||
type="submit" | ||
className="mt-4 inline-flex w-full bg-purple-700 cursor-pointer dark:text-neutral-200 duration-150 focus-visible:ring-2 focus-visible:ring-offset-2 focus:outline-none font-medium hover:bg-purple-900 items-center justify-center px-5 py-3 rounded-md shadow text-white transition" | ||
> | ||
Connect | ||
</button> | ||
</form> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import "github.com/getAlby/nostr-wallet-connect/models/api" | ||
|
||
func (a *WailsApp) WailsRequestRouter(route string) interface{} { | ||
switch route { | ||
case "/api/apps": | ||
|
||
userApps := []App{} | ||
a.svc.db.Find(&userApps) | ||
apps := []api.App{} | ||
a.svc.ListApps(&userApps, &apps) | ||
a.svc.Logger.Infof("END WailsRequestRouter %v", len(apps)) | ||
return apps | ||
case "/api/info": | ||
infoResponse := api.InfoResponse{} | ||
a.svc.GetInfo(&infoResponse) | ||
return infoResponse | ||
case "/api/user/me": | ||
return nil | ||
case "/api/csrf": | ||
return "dummy" | ||
} | ||
a.svc.Logger.Fatalf("Unhandled route: %s", route) | ||
return nil | ||
} |