diff --git a/.env b/.env new file mode 100644 index 00000000..18f0dedf --- /dev/null +++ b/.env @@ -0,0 +1,12 @@ +APP_NAME=Bitcoin Beach +APP_URI=https://bitcoinbeach.com +GRAPHQL_HOSTNAME=api.mainnet.galoy.io +GRAPHQL_HOSTNAME_INTERNAL=api.galoy-name-galoy.svc.cluster.local + +PLAY_STORE_LINK=https://play.google.com/store/apps/details?id=com.galoyapp +APP_STORE_LINK=https://apps.apple.com/app/bitcoin-beach-wallet/id1531383905 +APK_LINK=https://storage.googleapis.com/bitcoin-beach-wallet/latest.apk + +GRAPHQL_URI=https://$GRAPHQL_HOSTNAME/graphql +GRAPHQL_SUBSCRIPTION_URI=wss://$GRAPHQL_HOSTNAME/graphql +GRAPHQL_URI_INTERNAL=http://$GRAPHQL_HOSTNAME_INTERNAL/graphql diff --git a/.gitignore b/.gitignore index 82a2d302..6141bf0a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,14 +14,10 @@ tsconfig.tsbuildinfo # misc .DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local +.env*.local npm-debug.log* yarn-debug.log* yarn-error.log* public/env.js -.env .vscode/ diff --git a/README.md b/README.md index 075a0bd2..364e45cf 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Galoy-Pay uses query, mutation, and subscription operations from the Galoy's gra In the project directory, create a file name `.env.local` and fill it with ``` -NEXT_PUBLIC_GRAPHQL_HOSTNAME='api.staging.galoy.io' +GRAPHQL_HOSTNAME='api.staging.galoy.io' ``` (or use your custom API URL), then run diff --git a/components/header.tsx b/components/header.tsx index 0056c00c..96718615 100644 --- a/components/header.tsx +++ b/components/header.tsx @@ -2,16 +2,14 @@ import Navbar from "react-bootstrap/Navbar" import Container from "react-bootstrap/Container" import Image from "react-bootstrap/Image" -function Header() { +export default function Header({ link }: { link: string }) { return ( - + ) } - -export default Header diff --git a/lib/config.ts b/lib/config.ts deleted file mode 100644 index e9a6fe9f..00000000 --- a/lib/config.ts +++ /dev/null @@ -1,27 +0,0 @@ -let GRAPHQL_HOSTNAME = process.env.NEXT_PUBLIC_GRAPHQL_HOSTNAME as string - -// we need an internal dns to properly propagate the ip related headers to api -// if we use the api endpoints, nginx will rewrite the header to prevent spoofing -// for example: "api.galoy-name-galoy.svc.cluster.local" -const GRAPHQL_HOSTNAME_INTERNAL = process.env.GRAPHQL_HOSTNAME_INTERNAL as string - -// FIXME: remove once dns has been migrated out of ln.bitcoinbeach.com -if (!GRAPHQL_HOSTNAME) { - if (typeof window !== "undefined") { - let hostParts = window.location.host.split(".") - if (hostParts.length <= 3) { - // throw new Error("Missing env variables") - hostParts = "pay.mainnet.galoy.io".split(".") - } - hostParts[0] = "api" - GRAPHQL_HOSTNAME = hostParts.join(".") - } else { - GRAPHQL_HOSTNAME = "api.mainnet.galoy.io" - } -} - -const GRAPHQL_URI_INTERNAL = `http://${GRAPHQL_HOSTNAME_INTERNAL}/graphql` -const GRAPHQL_URI = `https://${GRAPHQL_HOSTNAME}/graphql` -const GRAPHQL_SUBSCRIPTION_URI = `wss://${GRAPHQL_HOSTNAME}/graphql` - -export { GRAPHQL_URI, GRAPHQL_SUBSCRIPTION_URI, GRAPHQL_URI_INTERNAL } diff --git a/lib/download.ts b/lib/download.ts index 1177ae50..6d5bbb70 100644 --- a/lib/download.ts +++ b/lib/download.ts @@ -24,7 +24,3 @@ export const getOS = () => { return undefined } - -export const playStoreLink = "https://play.google.com/store/apps/details?id=com.galoyapp" -export const appStoreLink = "https://apps.apple.com/app/bitcoin-beach-wallet/id1531383905" -export const apkLink = "https://storage.googleapis.com/bitcoin-beach-wallet/latest.apk" diff --git a/lib/graphql.tsx b/lib/graphql.tsx index b7d588a4..e498ede9 100644 --- a/lib/graphql.tsx +++ b/lib/graphql.tsx @@ -8,15 +8,16 @@ import { } from "@apollo/client" import { WebSocketLink } from "@apollo/client/link/ws" import { getMainDefinition } from "@apollo/client/utilities" +import getConfig from "next/config" -import { GRAPHQL_URI, GRAPHQL_SUBSCRIPTION_URI } from "./config" +const { publicRuntimeConfig } = getConfig() const httpLink = new HttpLink({ - uri: GRAPHQL_URI, + uri: publicRuntimeConfig.graphqlUri, }) const wsLink = new WebSocketLink({ - uri: GRAPHQL_SUBSCRIPTION_URI, + uri: publicRuntimeConfig.graphqlSubscriptionUri, options: { reconnect: true, }, diff --git a/next.config.js b/next.config.js index caca1f91..d9fd5fc3 100644 --- a/next.config.js +++ b/next.config.js @@ -4,4 +4,22 @@ module.exports = { { source: "/.well-known/lnurlp/:username", destination: "/api/lnurlp/:username" }, ] }, + serverRuntimeConfig: { + // we need an internal dns to properly propagate the ip related headers to api + // if we use the api endpoints, nginx will rewrite the header to prevent spoofing + // for example: "api.galoy-name-galoy.svc.cluster.local" + graphqlUriInternal: process.env.GRAPHQL_URI_INTERNAL, + }, + publicRuntimeConfig: { + appName: process.env.APP_NAME, + appUri: process.env.APP_URI, + graphqlUri: process.env.GRAPHQL_URI, + graphqlSubscriptionUri: process.env.GRAPHQL_SUBSCRIPTION_URI, + storeLinks: { + android: process.env.PLAY_STORE_LINK, + ios: process.env.APP_STORE_LINK, + huawei: process.env.APK_LINK, + apk: process.env.APK_LINK, + }, + }, } diff --git a/pages/[username].tsx b/pages/[username].tsx index e4878250..d6437c0b 100644 --- a/pages/[username].tsx +++ b/pages/[username].tsx @@ -3,13 +3,18 @@ import Row from "react-bootstrap/Row" import Col from "react-bootstrap/Col" import Card from "react-bootstrap/Card" import Container from "react-bootstrap/Container" +import Button from "react-bootstrap/Button" import Image from "react-bootstrap/Image" import { gql, useQuery } from "@apollo/client" import ReceiveAmount from "../components/receive-amount" import ReceiveNoAmount from "../components/receive-no-amount" +import getConfig from "next/config" -import { getOS, playStoreLink, appStoreLink } from "../lib/download" +import { getOS } from "../lib/download" + +const { publicRuntimeConfig } = getConfig() +const stores = publicRuntimeConfig.storeLinks const RECIPIENT_WALLET_ID = gql` query accountDefaultWallet($username: Username!) { @@ -30,12 +35,12 @@ export default function Receive() { }, }) - const os = getOS() - if (error) return
{error.message}
if (loading) return
Loading...
if (!data) return null + const os = getOS() + const { id: recipientWalletId, walletCurrency: recipientWalletCurrency } = data.accountDefaultWallet @@ -67,22 +72,33 @@ export default function Receive() { {os === "android" && ( - + )} {os === "ios" && ( - + )} + {os === "huawei" && ( + + )} {os === undefined && (
- +   - +
diff --git a/pages/_app.tsx b/pages/_app.tsx index 2f8ee69f..a8a83cab 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -4,11 +4,14 @@ import "./index.css" import Head from "next/head" import dynamic from "next/dynamic" import { NextPage } from "next" +import getConfig from "next/config" import Header from "../components/header" const GraphQLProvider = dynamic(() => import("../lib/graphql"), { ssr: false }) +const { publicRuntimeConfig } = getConfig() + export default function Layout({ Component, pageProps, @@ -24,7 +27,7 @@ export default function Layout({