Skip to content

Commit

Permalink
Merge branch 'nl-open-payments-updates' into s2-fix-op-responses
Browse files Browse the repository at this point in the history
  • Loading branch information
sabineschaller committed Oct 25, 2023
2 parents b465df2 + 85e01e1 commit 85f7cfb
Show file tree
Hide file tree
Showing 56 changed files with 1,729 additions and 341 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ parserOptions:
plugins:
- '@typescript-eslint'
rules:
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }]
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }]
overrides:
- files: ["*.js"]
rules:
"@typescript-eslint/no-var-requires": "off"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@ build
.docusaurus
.cache-loader

# Env variables
.env

# AWS Lambda
*.zip
*.zip
12 changes: 6 additions & 6 deletions infrastructure/helm/rafiki/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ dependencies:
version: 18.1.6
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 12.12.10
version: 13.1.5
- name: rafiki-auth
repository: https://interledger.github.io/helm-charts
version: 0.2.0
version: 0.3.0
- name: rafiki-backend
repository: https://interledger.github.io/helm-charts
version: 0.2.0
version: 0.3.0
- name: rafiki-frontend
repository: https://interledger.github.io/helm-charts
version: 0.2.0
digest: sha256:8a420487e0f52d1156eae919d8597cd1e8b9b7c6aa438235c716d2bb0dddb5a5
generated: "2023-10-19T22:42:12.910402378Z"
version: 0.3.0
digest: sha256:cc447b08a0876e683f9fd05ec966f81bf3f0ca998be4d6c5a0e76500f3a06a6b
generated: "2023-10-24T08:00:30.323841445Z"
8 changes: 4 additions & 4 deletions infrastructure/helm/rafiki/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ dependencies:
version: "18.1.6"
repository: "https://charts.bitnami.com/bitnami"
- name: postgresql
version: '12.12.10'
version: '13.1.5'
repository: 'https://charts.bitnami.com/bitnami'
- name: rafiki-auth
version: '0.2.0'
version: '0.3.0'
repository: 'https://interledger.github.io/helm-charts'
- name: rafiki-backend
version: '0.2.0'
version: '0.3.0'
repository: 'https://interledger.github.io/helm-charts'
- name: rafiki-frontend
version: '0.2.0'
version: '0.3.0'
repository: 'https://interledger.github.io/helm-charts'
26 changes: 13 additions & 13 deletions infrastructure/terraform/rafiki-test/.terraform.lock.hcl

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

2 changes: 1 addition & 1 deletion infrastructure/terraform/rafiki-test/backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 4.84.0"
version = "~> 5.3.0"
}
}
backend "gcs" {
Expand Down
24 changes: 24 additions & 0 deletions localenv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,30 @@ The secondary Happy Life Bank docker compose file (`./happy-life-bank/docker-com
data stores created by the primary Rafiki instance so it can't be run by itself.
The `pnpm localenv:compose up` command starts both the primary instance and the secondary.

#### Autopeering

If you want to start the local env and peer it automatically to rafiki.money, you can run the following commands:

```
pnpm localenv:compose:autopeer
// OR to start with Postgres db
pnpm localenv:compose:psql:autopeer
```

Your local cloud nine rafiki instance will be peered automatically in this case with https://rafiki.money instance.
The required services will be exposed externally using [tunnelmole](https://www.npmjs.com/package/tunnelmole) package.
The exposed ports are 3000(open-payments), 3006(auth server), 3002(ilp connector).

To use the postman collection examples follow the steps:

1. run `docker logs rafiki-cloud-nine-mock-ase-1`
2. find the list of created payment pointers
3. copy the url of one of the payment pointers
4. set the url into `senderPaymentPointer` postman variable in `Remote Environment`

After stopping the script it is necessary to clear the environment using the command described in [Shutting down](#Shutting-down). This is necessary as on a new run of the scripts (with autopeeing or not) the payment pointer url will differ.

### Shutting down

```
Expand Down
24 changes: 16 additions & 8 deletions localenv/cloud-nine-wallet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ services:
ports:
- '3030:80'
environment:
NODE_ENV: development
NODE_ENV: ${NODE_ENV:-development}
LOG_LEVEL: debug
PORT: 80
SEED_FILE_LOCATION: /workspace/seed.yml
KEY_FILE: /workspace/private-key.pem
PUBLIC_HOST: ${CLOUD_NINE_PUBLIC_HOST:-https://cloud-nine-wallet-backend}
AUTH_SERVER_DOMAIN: ${CLOUD_NINE_AUTH_SERVER_DOMAIN:-http://localhost:3006}
TESTNET_AUTOPEER_URL: ${TESTNET_AUTOPEER_URL}
volumes:
- ../cloud-nine-wallet/seed.yml:/workspace/seed.yml
- ../cloud-nine-wallet/private-key.pem:/workspace/private-key.pem
Expand All @@ -33,10 +36,12 @@ services:
ports:
- '3000:80'
- '3001:3001'
- '3002:3002'
networks:
- rafiki
environment:
NODE_ENV: development
NODE_ENV: ${NODE_ENV:-development}
TRUST_PROXY: ${TRUST_PROXY}
LOG_LEVEL: debug
ADMIN_PORT: 3001
CONNECTOR_PORT: 3002
Expand All @@ -45,16 +50,17 @@ services:
USE_TIGERBEETLE: ${USE_TIGERBEETLE-false}
TIGERBEETLE_CLUSTER_ID: ${TIGERBEETLE_CLUSTER_ID-0}
TIGERBEETLE_REPLICA_ADDRESSES: ${TIGERBEETLE_REPLICA_ADDRESSES-''}
AUTH_SERVER_GRANT_URL: http://cloud-nine-wallet-auth:3006
AUTH_SERVER_GRANT_URL: ${CLOUD_NINE_AUTH_SERVER_DOMAIN:-http://cloud-nine-wallet-auth:3006}
AUTH_SERVER_INTROSPECTION_URL: http://cloud-nine-wallet-auth:3007
ILP_ADDRESS: test.cloud-nine-wallet
ILP_ADDRESS: ${ILP_ADDRESS:-test.cloud-nine-wallet}
STREAM_SECRET: BjPXtnd00G2mRQwP/8ZpwyZASOch5sUXT5o0iR5b5wU=
PUBLIC_HOST: http://cloud-nine-wallet-backend
OPEN_PAYMENTS_URL: http://cloud-nine-wallet-backend
PUBLIC_HOST: ${CLOUD_NINE_PUBLIC_HOST:-http://cloud-nine-wallet-backend}
OPEN_PAYMENTS_URL: ${CLOUD_NINE_OPEN_PAYMENTS_URL:-http://cloud-nine-wallet-backend}
WEBHOOK_URL: http://cloud-nine-wallet/webhooks
EXCHANGE_RATES_URL: http://cloud-nine-wallet/rates
REDIS_URL: redis://shared-redis:6379/0
WALLET_ADDRESS_URL: https://cloud-nine-wallet-backend/.well-known/pay
WALLET_ADDRESS_URL: ${CLOUD_NINE_WALLET_ADDRESS_URL:-https://cloud-nine-wallet-backend/.well-known/pay}
ILP_CONNECTOR_ADDRESS: ${CLOUD_NINE_CONNECTOR_URL}
depends_on:
- shared-database
- shared-redis
Expand All @@ -71,8 +77,10 @@ services:
- '3003:3003'
- '3006:3006'
environment:
NODE_ENV: development
NODE_ENV: ${NODE_ENV:-development}
TRUST_PROXY: ${TRUST_PROXY}
AUTH_DATABASE_URL: postgresql://cloud_nine_wallet_auth:cloud_nine_wallet_auth@shared-database/cloud_nine_wallet_auth
AUTH_SERVER_DOMAIN: ${CLOUD_NINE_AUTH_SERVER_DOMAIN:-http://localhost:3006}
depends_on:
- shared-database
shared-database:
Expand Down
3 changes: 1 addition & 2 deletions localenv/cloud-nine-wallet/seed.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
self:
graphqlUrl: http://cloud-nine-wallet-backend:3001/graphql
hostname: 'cloud-nine-wallet-backend'
mapHostname: 'primary-mase'
openPaymentPublishedPort: 3000
assets:
Expand Down Expand Up @@ -77,4 +76,4 @@ fees:
- fixed: 1
basisPoints: 200
asset: JPY
scale: 0
scale: 0
11 changes: 6 additions & 5 deletions localenv/happy-life-bank/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
PORT: 80
SEED_FILE_LOCATION: /workspace/seed.yml
KEY_FILE: /workspace/private-key.pem
PUBLIC_HOST: ${HAPPY_LIFE_BANK_PUBLIC_HOST:-https://happy-life-bank-backend}
volumes:
- ../happy-life-bank/seed.yml:/workspace/seed.yml
- ../happy-life-bank/private-key.pem:/workspace/private-key.pem
Expand Down Expand Up @@ -42,16 +43,16 @@ services:
USE_TIGERBEETLE: ${USE_TIGERBEETLE-false}
TIGERBEETLE_CLUSTER_ID: ${TIGERBEETLE_CLUSTER_ID-0}
TIGERBEETLE_REPLICA_ADDRESSES: ${TIGERBEETLE_REPLICA_ADDRESSES-''}
AUTH_SERVER_GRANT_URL: http://happy-life-bank-auth:3006
AUTH_SERVER_GRANT_URL: ${HAPPY_LIFE_BANK_AUTH_SERVER_DOMAIN:-http://happy-life-bank-auth:3006}
AUTH_SERVER_INTROSPECTION_URL: http://happy-life-bank-auth:3007
ILP_ADDRESS: test.happy-life-bank
STREAM_SECRET: BjPXtnd00G2mRQwP/8ZpwyZASOch5sUXT5o0iR5b5wU=
PUBLIC_HOST: http://happy-life-bank-backend
PUBLIC_HOST: ${HAPPY_LIFE_BANK_PUBLIC_HOST:-http://happy-life-bank-backend}
WEBHOOK_URL: http://happy-life-bank/webhooks
OPEN_PAYMENTS_URL: http://happy-life-bank-backend
OPEN_PAYMENTS_URL: ${HAPPY_LIFE_BANK_OPEN_PAYMENTS_URL:-http://happy-life-bank-backend}
EXCHANGE_RATES_URL: http://happy-life-bank/rates
REDIS_URL: redis://shared-redis:6379/1
WALLET_ADDRESS_URL: https://happy-life-bank-backend/.well-known/pay
WALLET_ADDRESS_URL: ${HAPPY_LIFE_BANK_WALLET_ADDRESS_URL:-https://happy-life-bank-backend/.well-known/pay}
depends_on:
- cloud-nine-backend
happy-life-auth:
Expand All @@ -67,7 +68,7 @@ services:
environment:
NODE_ENV: development
AUTH_DATABASE_URL: postgresql://happy_life_bank_auth:happy_life_bank_auth@shared-database/happy_life_bank_auth
AUTH_SERVER_DOMAIN: "http://localhost:4006"
AUTH_SERVER_DOMAIN: ${HAPPY_LIFE_BANK_AUTH_SERVER_DOMAIN:-http://localhost:4006}
depends_on:
- cloud-nine-auth
happy-life-admin:
Expand Down
3 changes: 1 addition & 2 deletions localenv/happy-life-bank/seed.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
self:
graphqlUrl: http://happy-life-bank-backend:3001/graphql
hostname: 'happy-life-bank-backend'
mapHostname: 'primary-mase'
openPaymentPublishedPort: 4000
assets:
Expand Down Expand Up @@ -88,4 +87,4 @@ fees:
- fixed: 1
basisPoints: 200
asset: JPY
scale: 0
scale: 0
5 changes: 3 additions & 2 deletions localenv/mock-account-servicing-entity/app/lib/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ export class ApiClient {

public static async endInteraction(
interactId: string,
nonce: string
nonce: string,
authServerDomain: string
): Promise<ApiResponse> {
window.location.href = `http://localhost:3006/interact/${interactId}/${nonce}/finish`
window.location.href = `${authServerDomain}/interact/${interactId}/${nonce}/finish`
return {
isFailure: false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export interface SeedInstance {
export interface Config {
seed: SeedInstance
key: crypto.KeyObject
publicHost: string
testnetAutoPeerUrl: string
authServerDomain: string
}

export const CONFIG: Config = {
Expand All @@ -62,5 +65,8 @@ export const CONFIG: Config = {
process.env.SEED_FILE_LOCATION || `./seed.example.yml`
).toString('utf8')
),
key: parseOrProvisionKey(process.env.KEY_FILE)
key: parseOrProvisionKey(process.env.KEY_FILE),
publicHost: process.env.PUBLIC_HOST ?? '',
testnetAutoPeerUrl: process.env.TESTNET_AUTOPEER_URL ?? '',
authServerDomain: process.env.AUTH_SERVER_DOMAIN || 'http://localhost:3006'
}
52 changes: 50 additions & 2 deletions localenv/mock-account-servicing-entity/app/lib/requesters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import type {
CreateWalletAddressInput,
JwkInput,
SetFeeResponse,
FeeType
} from '../../generated/graphql'
FeeType,
CreateOrUpdatePeerByUrlMutationResponse,
CreateOrUpdatePeerByUrlInput
} from 'generated/graphql'
import { apolloClient } from './apolloClient'
import { v4 as uuid } from 'uuid'

Expand Down Expand Up @@ -116,6 +118,52 @@ export async function createPeer(
})
}

export async function createAutoPeer(
peerUrl: string,
assetId: string
): Promise<CreateOrUpdatePeerByUrlMutationResponse | undefined> {
const createAutoPeerMutation = gql`
mutation CreateOrUpdatePeerByUrl($input: CreateOrUpdatePeerByUrlInput!) {
createOrUpdatePeerByUrl(input: $input) {
code
success
message
peer {
id
name
asset {
id
scale
code
withdrawalThreshold
}
}
}
}
`

const addedLiquidity = '10000' as unknown as bigint
const createPeerInput: { input: CreateOrUpdatePeerByUrlInput } = {
input: {
peerUrl,
assetId,
addedLiquidity
}
}
return apolloClient
.mutate({
mutation: createAutoPeerMutation,
variables: createPeerInput
})
.then(({ data }): CreateOrUpdatePeerByUrlMutationResponse => {
if (!data.createOrUpdatePeerByUrl.success) {
console.log(data.createOrUpdatePeerByUrl)
throw new Error(`Data was empty for assetId: ${assetId}`)
}
return data.createOrUpdatePeerByUrl
})
}

export async function addPeerLiquidity(
peerId: string,
amount: string,
Expand Down
Loading

0 comments on commit 85f7cfb

Please sign in to comment.