Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ RUN yarn install --frozen-lockfile

COPY ./src ./src

RUN chmod -R a+rX /app/src

RUN yarn build

RUN yarn install --frozen-lockfile --production
Expand Down
36 changes: 5 additions & 31 deletions quickstart/bin/quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,18 @@ COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-quickstart}"
DIR="$(dirname "$(readlink -f "$BASH_SOURCE")")"
source ${DIR}/helpers.sh

show_galoy() {
show_flash() {
cat << "EOF"
('-.
( OO ).-.
,----. / . --. / ,--. .-'),-----. ,--. ,--.
' .-./-') | \-. \ | |.-') ( OO' .-. ' \ `.' /
| |_( O- ).-'-' | | | | OO )/ | | | | .-') /
| | .--, \ \| |_.' | | |`-' |\_) | |\| |(OO \ /
(| | '. (_/ | .-. |(| '---.' \ | | | | | / /\_
| '--' | | | | | | | `' '-' ' `-./ /.__)
`------' `--' `--' `------' `-----' `--'
Flash quickstart
EOF
}

main() {
show_galoy
show_flash
echo "------------------------------------------------------------"
echo "------------------------------------------------------------"
echo
echo "Checking that all services are up and running"
echo
${DIR}/init-onchain.sh
${DIR}/init-lightning.sh
echo
echo "------------------------------------------------------------"
echo "------------------------------------------------------------"
echo
echo "Hitting graphql endpoints"
echo "Checking Flash public GraphQL endpoint"

echo "Running on network:"
for i in {1..90}; do
Expand All @@ -48,18 +32,8 @@ main() {
echo "$output" | jq .
exit 1
fi
echo
for i in {1..10}; do
echo "Logging in Alice"
login_user "alice" "+16505554328" "000000" && break
sleep 1
done

initialize_user_from_onchain "alice" "+16505554328" "000000"
echo "Alice account set up, token: $(read_value "alice")"

echo "TOKEN_ALICE=$(read_value "alice")"
export TOKEN_ALICE=$(read_value "alice")
echo "DONE"
}

main
31 changes: 31 additions & 0 deletions quickstart/bin/re-render.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,37 @@ pushd ${REPO_ROOT}/quickstart
ytt -f vendir > vendir.yml
vendir sync

rewrite_flash_quickstart_hosts() {
local files=(
dev/apollo-federation/supergraph-config.yaml
dev/apollo-federation/supergraph.graphql
dev/ory/kratos.yml
dev/ory/oathkeeper_rules.yaml
)

for file in "${files[@]}"; do
sed -i.bak 's#http://bats-tests:#http://flash:#g' "${file}"
rm -f "${file}.bak"
done

local app_check_files=(
dev/ory/oathkeeper.yml
dev/ory/oathkeeper_rules.yaml
)

for file in "${app_check_files[@]}"; do
sed -i.bak \
-e 's#- id: galoy-ws#- id: flash-ws#' \
-e 's#- id: galoy-backend#- id: flash-backend#' \
-e 's#firebaseappcheck.googleapis.com/72279297366#firebaseappcheck.googleapis.com/806646140435#' \
-e 's#projects/72279297366#projects/806646140435#' \
"${file}"
rm -f "${file}.bak"
done
}

rewrite_flash_quickstart_hosts

ytt -f ./docker-compose.tmpl.yml -f ${GALOY_ROOT_DIR}/docker-compose.yml -f ${GALOY_ROOT_DIR}/docker-compose.override.yml > docker-compose.yml

pushd ${GALOY_ROOT_DIR}
Expand Down
2 changes: 2 additions & 0 deletions quickstart/config/quickstart-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ibex:
mock: true
2 changes: 1 addition & 1 deletion quickstart/dev/apollo-federation/supergraph-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
federation_version: =2.3.2
subgraphs:
public:
routing_url: http://bats-tests:4012/graphql
routing_url: http://flash:4012/graphql
schema:
file: ../../src/graphql/public/schema.graphql
2 changes: 1 addition & 1 deletion quickstart/dev/apollo-federation/supergraph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ enum InvoicePaymentStatus
scalar join__FieldSet

enum join__Graph {
PUBLIC @join__graph(name: "public", url: "http://bats-tests:4012/graphql")
PUBLIC @join__graph(name: "public", url: "http://flash:4012/graphql")
}

scalar Language
Expand Down
6 changes: 3 additions & 3 deletions quickstart/dev/ory/kratos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ selfservice:
hooks:
- hook: web_hook
config:
# url: http://bats-tests:4002/auth/after_settings_hooks
# url: http://flash:4002/auth/after_settings_hooks
url: http://invalid-because-we-dont-want-profile-to-be-updated
method: POST
body: file:///home/ory/body.jsonnet
Expand Down Expand Up @@ -119,7 +119,7 @@ selfservice:
#
# - hook: web_hook
# config:
# url: http://bats-tests:4012/kratos/preregistration
# url: http://flash:4012/kratos/preregistration
# method: POST
# response:
# parse: true
Expand All @@ -132,7 +132,7 @@ selfservice:
# in: header
- hook: web_hook
config:
url: http://bats-tests:4012/kratos/registration
url: http://flash:4012/kratos/registration
method: POST
response:
parse: false
Expand Down
12 changes: 6 additions & 6 deletions quickstart/dev/ory/oathkeeper_rules.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- id: anonymous-rest-auth
upstream:
url: "http://bats-tests:4012"
url: "http://flash:4012"
match:
url: "<(http|https)>://<[a-zA-Z0-9-.:]+>/auth/<(clearCookies|login|logout|email/code|email/login|totp/validate|email/login/cookie)>"
methods: ["GET", "POST", "OPTIONS"]
Expand All @@ -13,7 +13,7 @@

- id: device-login
upstream:
url: "http://bats-tests:4012"
url: "http://flash:4012"
match:
url: "<(http|https)>://<[a-zA-Z0-9-.:]+>/auth/create/device-account"
methods: ["POST"]
Expand All @@ -34,9 +34,9 @@
mutators:
- handler: noop

- id: galoy-ws
- id: flash-ws
upstream:
url: "http://bats-tests:4000/graphql"
url: "http://flash:4000/graphql"
strip_path: /graphqlws # ONLY FOR DEV, in prod should resolve to /graphql, like ws.blink.sv/graphql
match:
url: "<(http|https)>://<[a-zA-Z0-9-.:]+>/graphqlws" # ONLY FOR DEV, in prod should resolve to /graphql
Expand All @@ -48,7 +48,7 @@
mutators:
- handler: noop

- id: galoy-backend
- id: flash-backend
upstream:
url: "http://apollo-router:4004"
match:
Expand Down Expand Up @@ -79,7 +79,7 @@

- id: admin-backend
upstream:
url: "http://bats-tests:4001"
url: "http://flash:4001"
strip_path: /admin
match:
url: "<(http|https)>://<.*><[0-9]+>/admin<.*>"
Expand Down
26 changes: 20 additions & 6 deletions quickstart/docker-compose.tmpl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- oathkeeper
- kratos
- kratos-pg
- galoy
- flash
- trigger
- redis
- mongodb
Expand All @@ -37,7 +37,7 @@ services:
kratos: #@ data.values.services["kratos"]
kratos-pg: #@ data.values.services["kratos-pg"]

galoy:
flash:
#@ if galoy_image_digest == "local":
build:
context: ../
Expand All @@ -50,7 +50,16 @@ services:
- "-r"
- "/app/lib/services/tracing.js"
- "lib/servers/graphql-main-server.js"
- "--configPath"
- "/app/dev/config/base-config.yaml"
- "--configPath"
- "/app/quickstart/config/quickstart-config.yaml"
env_file: ${HOST_PROJECT_PATH:-.}/${GALOY_QUICKSTART_PATH:-vendor/galoy-quickstart}/.env.galoy
environment:
- FLASH_ENABLE_IBEX_MOCK=true
volumes:
- ${FLASH_PROJECT_PATH:-..}/dev/config:/app/dev/config:ro
- ${FLASH_PROJECT_PATH:-..}/quickstart/config:/app/quickstart/config:ro
depends_on:
- trigger
- apollo-router
Expand All @@ -62,10 +71,6 @@ services:
- mongodb
- redis
- stablesats
networks:
default:
aliases:
- bats-tests
trigger:
#@ if galoy_image_digest == "local":
build:
Expand All @@ -79,7 +84,16 @@ services:
- "-r"
- "/app/lib/services/tracing.js"
- "lib/servers/trigger.js"
- "--configPath"
- "/app/dev/config/base-config.yaml"
- "--configPath"
- "/app/quickstart/config/quickstart-config.yaml"
env_file: ${HOST_PROJECT_PATH:-.}/${GALOY_QUICKSTART_PATH:-vendor/galoy-quickstart}/.env.galoy
environment:
- FLASH_ENABLE_IBEX_MOCK=true
volumes:
- ${FLASH_PROJECT_PATH:-..}/dev/config:/app/dev/config:ro
- ${FLASH_PROJECT_PATH:-..}/quickstart/config:/app/quickstart/config:ro
depends_on:
- lnd1
- bria
Expand Down
26 changes: 20 additions & 6 deletions quickstart/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
- oathkeeper
- kratos
- kratos-pg
- galoy
- flash
- trigger
- redis
- mongodb
Expand Down Expand Up @@ -68,13 +68,22 @@ services:
- POSTGRES_USER=dbuser
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=default
galoy:
flash:
image: us.gcr.io/galoy-org/galoy-app@sha256:61eec2c0747ce8e20e1a45f1d0492e955631e6d89f25cf2364c0727b27786cfe
command:
- -r
- /app/lib/services/tracing.js
- lib/servers/graphql-main-server.js
- --configPath
- /app/dev/config/base-config.yaml
- --configPath
- /app/quickstart/config/quickstart-config.yaml
env_file: ${HOST_PROJECT_PATH:-.}/${GALOY_QUICKSTART_PATH:-vendor/galoy-quickstart}/.env.galoy
environment:
- FLASH_ENABLE_IBEX_MOCK=true
volumes:
- ${FLASH_PROJECT_PATH:-..}/dev/config:/app/dev/config:ro
- ${FLASH_PROJECT_PATH:-..}/quickstart/config:/app/quickstart/config:ro
depends_on:
- trigger
- apollo-router
Expand All @@ -86,17 +95,22 @@ services:
- mongodb
- redis
- stablesats
networks:
default:
aliases:
- bats-tests
trigger:
image: us.gcr.io/galoy-org/galoy-app@sha256:61eec2c0747ce8e20e1a45f1d0492e955631e6d89f25cf2364c0727b27786cfe
command:
- -r
- /app/lib/services/tracing.js
- lib/servers/trigger.js
- --configPath
- /app/dev/config/base-config.yaml
- --configPath
- /app/quickstart/config/quickstart-config.yaml
env_file: ${HOST_PROJECT_PATH:-.}/${GALOY_QUICKSTART_PATH:-vendor/galoy-quickstart}/.env.galoy
environment:
- FLASH_ENABLE_IBEX_MOCK=true
volumes:
- ${FLASH_PROJECT_PATH:-..}/dev/config:/app/dev/config:ro
- ${FLASH_PROJECT_PATH:-..}/quickstart/config:/app/quickstart/config:ro
depends_on:
- lnd1
- bria
Expand Down
1 change: 1 addition & 0 deletions src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ export const configSchema = {
ibex: {
type: "object",
properties: {
mock: { type: "boolean", default: false },
clientId: { type: "string" },
clientSecret: { type: "string" },
environment: { type: "string", enum: ["production", "sandbox"] },
Expand Down
1 change: 1 addition & 0 deletions src/config/schema.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type WebhookServer = {
}

type IbexConfig = {
mock?: boolean
clientId: string
clientSecret: string
environment: 'production' | 'sandbox'
Expand Down
16 changes: 16 additions & 0 deletions src/services/ibex/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,23 @@ const Ibex = new IbexClient(
)

const IbexUrlConfig = IbexUrls[IbexConfig.environment]
const mockIbexEnabled =
IbexConfig.mock === true && process.env.FLASH_ENABLE_IBEX_MOCK === "true"
const mockLnurl =
"lnurl1dp68gurn8ghj7um9dej8xct5w3skccne9e3k7mf0d3h82unvwqhkxun0wa5kgct5v93kzmmfd3skjmn0wvhxcmmv9u"

const createAccount = async (
name: string,
currencyId: IbexCurrencyId,
): Promise<CreateAccountResponse201 | IbexError> => {
if (mockIbexEnabled) {
return {
id: `quickstart-${name}-${currencyId}`,
name,
currencyId,
} as CreateAccountResponse201
}

return Ibex.createAccount({ name, currencyId }).then(errorHandler)
}

Expand Down Expand Up @@ -286,6 +298,10 @@ const estimateOnchainFee = async (
const createLnurlPay = async (
body: CreateLnurlPayBodyParam,
): Promise<CreateLnurlPayResponse201 | IbexError> => {
if (mockIbexEnabled) {
return { lnurl: mockLnurl } as CreateLnurlPayResponse201
}

const bodyWithHooks = {
...body,
webhookUrl: WebhookServer.endpoints.onReceive.lnurl,
Expand Down
2 changes: 1 addition & 1 deletion test/flash/bridge-sandbox-e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The package scripts source `.env` from the project root, then source `.env.local
```bash
# Required
export IBEX_ENVIRONMENT=sandbox
export MONGODB_CON=mongodb://localhost:27017/flash
export MONGODB_CON=mongodb://localhost:27017/galoy

# Bridge sandbox — fill from Bridge dashboard
# These are the API key and webhook secret, not stored in .env directly in production:
Expand Down
Loading