Skip to content

Commit

Permalink
feat: API endpoint dropdown, mainnet by default (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
openoms authored Oct 11, 2023
1 parent f99df1b commit d11b115
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 43 deletions.
26 changes: 13 additions & 13 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ description: For people new to Galoy, this page will point you in the right dire
* visit [get.blink.sv](https://get.blink.sv) for the App Store / Google Play / App Gallery links
* or download the Android apk from [github.com/GaloyMoney/galoy-mobile/releases](https://github.com/GaloyMoney/galoy-mobile/releases)

## Set up the email login
### Upgrade the account with a phone number
* select the menu on the top right and tap `Account`
* `Backup/upgrade account`
* complete the Account set up with a phone number

### Add an email address for login
* only available if a phone number was added previously
* select the menu on the top right and tap `Account`
* select `Email (for login)`
* enter an email address and complete the verification to enable login with email
* now can delete the phone number if desired

## For testing and development connect to our Staging environment
* more info on the [staging environment](https://dev.galoy.io/deployment/staging-environment)
* more info on [testing on signet](https://dev.galoy.io/deployment/signet)
Expand All @@ -26,16 +39,3 @@ description: For people new to Galoy, this page will point you in the right dire
* select `Staging` under `Update Environment`, `Save changes` and go back to `Settings`
* the wallet is now connected to the staging environment
* carry on with: `Create new account`, `Start with trial account` or `Log back in with Phone or Email`

## Set up the email login
### Upgrade the account with a phone number
* select the menu on the top right and tap `Account`
* `Backup/upgrade account`
* complete the Account set up with a phone number

### Add an email address for login
* only available if a phone number was added previously
* select the menu on the top right and tap `Account`
* select `Email (for login)`
* enter an email address and complete the verification to enable login with email
* now can delete the phone number if desired
3 changes: 0 additions & 3 deletions docs/api/a-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ slug: /api/auth
---

import { AuthProvider } from '/src/components/apiTutorial/AuthContext';
import PhoneLoginButton from '/src/components/apiTutorial/PhoneLoginButton';
import EmailLoginButton from '/src/components/apiTutorial/EmailLoginButton';
import AuthRequestBtcButton from '/src/components/apiTutorial/AuthRequestBtcButton';
import AuthRequestUsdButton from '/src/components/apiTutorial/AuthRequestUsdButton';

There are multiple ways to obtain an auth token to be used with the API.

Expand Down
4 changes: 0 additions & 4 deletions docs/api/b-stablesats.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ slug: /api/stablesats
import { AuthProvider } from '/src/components/apiTutorial/AuthContext';
import AuthRequestUsdButton from '/src/components/apiTutorial/AuthRequestUsdButton';

:::note
By default the calls are directed to the staging environment where the funds are worthless, using the default bitcoin [signet](https://dev.galoy.io/deployment/signet).
:::

<AuthProvider>

<AuthRequestUsdButton />
Expand Down
3 changes: 0 additions & 3 deletions docs/api/c-sats.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ slug: /api/sats
import { AuthProvider } from '/src/components/apiTutorial/AuthContext';
import AuthRequestBtcButton from '/src/components/apiTutorial/AuthRequestBtcButton';

:::note
By default the calls are directed to the staging environment where the funds are worthless, using the default bitcoin [signet](https://dev.galoy.io/deployment/signet).
:::
<AuthProvider>

<AuthRequestBtcButton />
Expand Down
4 changes: 2 additions & 2 deletions docs/api/d-postman.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ or go ahead and fork the collection with the staging environment preset to your

[![Run in Postman](https://run.pstmn.io/button.svg)](https://god.gw.postman.com/run-collection/29391384-67b79565-f9ed-4ff7-800c-10eabfd0fc38?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D29391384-67b79565-f9ed-4ff7-800c-10eabfd0fc38%26entityType%3Dcollection%26workspaceId%3Db8a32fb0-cb8e-4323-934f-c100c6ec02b7#?env%5Bgaloy-staging%5D=W3sia2V5IjoicHJvdG9jb2wiLCJ2YWx1ZSI6Imh0dHBzIiwiZW5hYmxlZCI6dHJ1ZSwic2Vzc2lvblZhbHVlIjoiaHR0cHMiLCJzZXNzaW9uSW5kZXgiOjB9LHsia2V5IjoiZG9tYWluIiwidmFsdWUiOiJhcGkuc3RhZ2luZy5nYWxveS5pbyIsImV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ZW1haWxDb2RlIiwidmFsdWUiOiIiLCJlbmFibGVkIjp0cnVlLCJ0eXBlIjoiZGVmYXVsdCIsInNlc3Npb25WYWx1ZSI6IiIsInNlc3Npb25JbmRleCI6MTZ9XQ==)

## `staging` and `mainnet` API access
## API access

Follow the links to register and get an authentication token:
* [Start with Blink](/api)
Expand All @@ -28,8 +28,8 @@ We've included the following files here that can be imported into Postman to get

### Environment variables

* [galoy-staging.postman_environment.json](https://dev.galoy.io/galoy-staging.postman_environment.json): environment variables to hit our deployed staging with signet bitcoin
* [galoy-mainnet.postman_environment.json](https://dev.galoy.io/galoy-mainnet.postman_environment.json): environment variables to hit our deployed Blink production environment with mainnet bitcoin
* [galoy-staging.postman_environment.json](https://dev.galoy.io/galoy-staging.postman_environment.json): environment variables to hit our deployed staging with signet bitcoin

### Usage

Expand Down
13 changes: 8 additions & 5 deletions src/components/apiTutorial/AuthRequestBtcButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useAuth } from './AuthContext';

function AuthRequestButton() {
const { authToken, setAuthToken } = useAuth();
const [apiEndpoint, setApiEndpoint] = useState('https://api.staging.galoy.io/graphql');
const [apiEndpoint, setApiEndpoint] = useState('https://api.blink.sv/graphql');
const [manualAuthToken, setManualAuthToken] = useState('');
const [amount, setAmount] = useState(1000);
const [accountWalletId, setAccountWalletId] = useState('');
Expand Down Expand Up @@ -266,13 +266,16 @@ mutation LnInvoicePaymentSend($input: LnInvoicePaymentInput!) {

return (
<div>
The GraphQL endpoint to connect to:
<input
<div>The GraphQL endpoint to connect to:</div>
<select
type="text"
value={apiEndpoint}
onChange={handleApiEndpointChange}
style={{ width: '100%', marginBottom: '10px' }}
/>
style={{ width: '50%', marginBottom: '10px' }}
>
<option value="https://api.blink.sv/graphql">Blink (mainnet) - https://api.blink.sv/graphql</option>
<option value="https://api.staging.galoy.io/graphql">Staging (signet) - https://api.staging.galoy.io/graphql</option>
</select>
<div>The following methods require a valid auth token set in the header as a bearer token:</div>
{authTokenSection}

Expand Down
9 changes: 6 additions & 3 deletions src/components/apiTutorial/AuthRequestUsdButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useAuth } from './AuthContext';

function AuthRequestButton() {
const { authToken, setAuthToken } = useAuth();
const [apiEndpoint, setApiEndpoint] = useState('https://api.staging.galoy.io/graphql');
const [apiEndpoint, setApiEndpoint] = useState('https://api.blink.sv/graphql');
const [manualAuthToken, setManualAuthToken] = useState('');
const [amount, setAmount] = useState(100);
const [accountWalletId, setAccountWalletId] = useState('');
Expand Down Expand Up @@ -267,12 +267,15 @@ mutation LnInvoicePaymentSend($input: LnInvoicePaymentInput!) {
return (
<div>
<div>The GraphQL endpoint to connect to:</div>
<input
<select
type="text"
value={apiEndpoint}
onChange={handleApiEndpointChange}
style={{ width: '50%', marginBottom: '10px' }}
/>
>
<option value="https://api.blink.sv/graphql">Blink (mainnet) - https://api.blink.sv/graphql</option>
<option value="https://api.staging.galoy.io/graphql">Staging (signet) - https://api.staging.galoy.io/graphql</option>
</select>
<div>The following methods require a valid auth token set in the header as a bearer token:</div>
{authTokenSection}

Expand Down
20 changes: 14 additions & 6 deletions src/components/apiTutorial/EmailLoginButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { generateCurlCommandRequestEmailCode, generateCurlCommandEmailLogin } fr

function EmailLoginButton() {
const { authToken, setAuthToken } = useAuth();
const [authEndpoint, setAuthEndpoint] = useState('https://api.staging.galoy.io/auth');
const [authEndpoint, setAuthEndpoint] = useState('https://api.blink.sv/auth');
const [emailAddress, setEmailAddress] = useState('');
const [emailCode, setEmailCode] = useState('');
const [successMessageEmailCode, setSuccessMessageEmailCode] = useState(null);
Expand Down Expand Up @@ -68,18 +68,26 @@ function EmailLoginButton() {
<h3>1) Request a 2FA code to your email</h3>
<div style={{ marginTop: '10px' }}></div>
<div>
<div>The REST authentication endpoint to connect to:</div>
<input type="text" value={authEndpoint} onChange={e => setAuthEndpoint(e.target.value)} style={{ width: '50%', marginBottom: '10px' }} />
<div>The REST authentication endpoint to connect to:</div>
<select
type="text"
value={authEndpoint}
onChange={e => setAuthEndpoint(e.target.value)}
style={{ width: '50%', marginBottom: '10px' }}
>
<option value="https://api.blink.sv/auth">Blink (mainnet) - https://api.blink.sv/graphql</option>
<option value="https://api.staging.galoy.io/auth">Staging (signet) - https://api.staging.galoy.io/graphql</option>
</select>
<div></div>
<input type="email" placeholder="Fill in the email address used with Blink" value={emailAddress} onChange={e => setEmailAddress(e.target.value)} style={{ width: '50%', marginBottom: '10px' }} />
<input type="email" placeholder="Fill in the email address used for the account" value={emailAddress} onChange={e => setEmailAddress(e.target.value)} style={{ width: '50%', marginBottom: '10px' }} />
</div>
<button onClick={handleRequestEmailCode}>Request code</button>
<div style={{ marginTop: '20px' }}>
<h4>cURL command to request an email code:</h4>
<pre style={{
backgroundColor: 'auto',
padding: '10px',
marginLeft: '10px' ,
marginLeft: '10px',
overflowX: 'auto',
whiteSpace: 'pre-wrap'
}}>
Expand Down Expand Up @@ -115,7 +123,7 @@ function EmailLoginButton() {
<pre style={{
backgroundColor: 'auto',
padding: '10px',
marginLeft: '10px' ,
marginLeft: '10px',
overflowX: 'auto',
whiteSpace: 'pre-wrap'
}}>
Expand Down
17 changes: 13 additions & 4 deletions src/components/apiTutorial/PhoneLoginButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { generateCurlCommandPhoneLogin } from './curlCommandGenerators';

function PhoneLoginButton() {
const { authToken, setAuthToken } = useAuth();
const [apiEndpoint, setApiEndpoint] = useState('https://api.staging.galoy.io/graphql');
const [apiEndpoint, setApiEndpoint] = useState('https://api.blink.sv/graphql');
const [phone, setPhone] = useState('');
const [code, setCode] = useState('');
const [showToken, setShowToken] = useState(false);
Expand Down Expand Up @@ -53,11 +53,20 @@ function PhoneLoginButton() {
<div>
<div>
<h2>Log in with phone and code</h2>
<input type="text" value={apiEndpoint} onChange={handleApiEndpointChange} style={{ width: '100%', marginBottom: '10px' }} />
<div>The GraphQL endpoint to connect to:</div>
<select
type="text"
value={apiEndpoint}
onChange={handleApiEndpointChange}
style={{ width: '50%', marginBottom: '10px' }}
>
<option value="https://api.blink.sv/graphql">Blink (mainnet) - https://api.blink.sv/graphql</option>
<option value="https://api.staging.galoy.io/graphql">Staging (signet) - https://api.staging.galoy.io/graphql</option>
</select>

<input type="text" placeholder="Phone" value={phone} onChange={handlePhoneChange} />
<input type="text" placeholder="Code" value={code} onChange={handleCodeChange} />


<button onClick={handleLogin}>Log in</button>
</div>

Expand All @@ -66,7 +75,7 @@ function PhoneLoginButton() {
<pre style={{
backgroundColor: 'auto',
padding: '10px',
marginLeft: '10px' ,
marginLeft: '10px',
overflowX: 'auto',
whiteSpace: 'pre-wrap'
}}>
Expand Down

0 comments on commit d11b115

Please sign in to comment.