Skip to content

Commit

Permalink
refactor: move and rename mock-account-provider -> mock-account-servi…
Browse files Browse the repository at this point in the history
…cing-entity (#1253)

* refactor: move and rename mock-account-provider

* fix: additional renaming, updating docs

* fix(docs): remove mock account provider from docs

* fix(docs): map -> mase

* fix(docs): add Max's suggestions

* fix(docs): typo

Co-authored-by: Max Kurapov <[email protected]>

---------

Co-authored-by: Max Kurapov <[email protected]>
  • Loading branch information
sabineschaller and mkurapov authored Mar 23, 2023
1 parent ca535a6 commit 9975cdf
Show file tree
Hide file tree
Showing 71 changed files with 119 additions and 255 deletions.
4 changes: 2 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'pkg: backend': packages/backend/**/*
'pkg: frontend': packages/frontend/**/*
'pkg: auth': packages/auth/**/*
'pkg: map': packages/mock-account-provider/**/*
'pkg: mock-ase': localenv/mock-account-servicing-entity/**/*

# Add 'type: documentation' label to any change to *.md files
'type: ci':
Expand All @@ -24,4 +24,4 @@
# Add 'type: tests' label to any change to *.test.ts files
'type: tests': packages/**/*.test.ts

'type: localenv': infrastructure/local/*
'type: localenv': localenv/*
6 changes: 3 additions & 3 deletions .github/workflows/lint_test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ jobs:
run: |
npx @stoplight/spectral-cli lint ./packages/auth/openapi/*.yaml
mock-account-provider:
mock-account-servicing-entity:
runs-on: ubuntu-latest
needs: checkout
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/rafiki/env-setup
- run: pnpm --filter mock-account-provider build
- run: pnpm --filter mock-account-servicing-entity build

local-http-signatures:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
- backend
- frontend
- auth
- mock-account-provider
- mock-account-servicing-entity
- local-http-signatures
- token-introspection
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ pnpm check:format
pnpm check:lint
```

The [infrastructure/local](infrastructure/local) directory contains resources for setting up Rafiki in
The [localenv](localenv) directory contains resources for setting up Rafiki in
common configurations.
4 changes: 0 additions & 4 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ The frontend will host the internal admin interface. The current application is

## Additional packages

### Mock Account Provider

The `mock-account-provider` package is a [remix](https://remix.run/) application to mimic an [Account Servicing Entity](./glossary.md#account-servicing-entity). It is used to test the integration with the Rafiki webhooks and the quoting of outgoing payments.

### Token Introspection

The `token-introspection` package is a client library for making [GNAP](./glossary.md#grant-negotiation-authorization-protocol) token introspection requests to the auth server.
29 changes: 15 additions & 14 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## Local Environment

We have created a suite of packages that, together, mock an account provider that has deployed Rafiki, exposing an [SPSP](./glossary.md#simple-payments-setup-protocol-spsp) endpoint, the [Open Payments](./glossary.md#open-payments) APIs with its required [GNAP](./glossary.md#grant-negotiation-authorization-protocol) auth endpoints to request grants, as well as the STREAM endpoint for receiving Interledger packets. Additionally, we provide a simple request signing service that is used by Postman to generate request signatures required by the Open Payments APIs.
We have created a suite of packages that, together, mock an account servicing entity that has deployed Rafiki, exposing an [SPSP](./glossary.md#simple-payments-setup-protocol-spsp) endpoint, the [Open Payments](./glossary.md#open-payments) APIs with its required [GNAP](./glossary.md#grant-negotiation-authorization-protocol) auth endpoints to request grants, as well as the STREAM endpoint for receiving Interledger packets. Additionally, we provide a simple request signing service that is used by Postman to generate request signatures required by the Open Payments APIs.

These packages include

- `backend` (SPSP, Open Payments APIs, Admin APIs, STREAM endpoint)
- `auth` (GNAP auth server)
- `mock-account-provider` (mocks an [Account Servicing Entity](./glossary.md#account-servicing-entity))
- `mock-account-servicing-entity` (mocks an [Account Servicing Entity](./glossary.md#account-servicing-entity))
- `local-http-signatures` (request signature generation for Postman)

These packages depend on the following databases
Expand All @@ -17,7 +17,7 @@ These packages depend on the following databases
- Postgres (Open Payments resources, auth resources)
- Redis (STREAM details)

We provide containerized versions of our packages together with two pre-configured docker-compose files ([peer1](../infrastructure/local/docker-compose.yml) and [peer2](../infrastructure/local/peer-docker-compose.yml))to start two Mock Account Providers with their respective Rafiki backend and auth servers. They automatically peer and 2 to 3 user accounts are created on both of them.
We provide containerized versions of our packages together with two pre-configured docker-compose files ([peer1](../localenv/cloud-nine-wallet/docker-compose.yml) and [peer2](../localenv/happy-life-bank/docker-compose.yml))to start two Mock Account Servicing Entities with their respective Rafiki backend and auth servers. They automatically peer and 2 to 3 user accounts are created on both of them.

### Running the local environment

Expand All @@ -38,17 +38,17 @@ pnpm localenv:stop && pnpm localenv:dbvolumes:remove
pnpm localenv:start
```

### Exploring Accounts on Mock account provider
### Exploring Accounts on Mock Account Servicing Entity

Navigate to `localhost:3030` to view the accounts on one instance of the Mock Account Provider called Cloud Nine Wallet.
Navigate to `localhost:3030` to view the accounts on one instance of the Mock Account Servicing Entity called Cloud Nine Wallet.

![Mock Account Provider Accounts](./img/map-accounts.png)
![Mock Account Servicing Entity Accounts](./img/map-accounts.png)

The accounts of the second instance (Happy Life Bank) can be found on `localhost:3031`.

When clicking on the Account Name, a list of Transactions appears.

![Mock Account Provider Transactions](./img/map-transactions.png)
![Mock Account Servicing Entity Transactions](./img/map-transactions.png)

### Admin APIs

Expand All @@ -62,13 +62,14 @@ The Examples folder in the Postman collection includes an [eCommerce example](ht

1. requests a grant to create an incoming payment on Philip Fry's account
2. creates an incoming payment on Philip Fry's account
3. requests a grant to create (and read) a quote and an outgoing payment on Grace Franklin's account)
4. continues the grant request
5. creates a quote on Grace Franklin's account
6. creates an outgoing payment on Grace Franklin's account
7. fetches the outgoing payment on Grace Franklin's account

Note that one has to go throught the interaction flow after requesting a grant for a quote and outgoing payment.
3. requests a grant to create (and read) a quote on Grace Franklin's account
4. creates a quote on Grace Franklin's account
5. requests a grant to create (and read) an outgoing payment on Grace Franklin's account
6. continues the grant request
7. creates an outgoing payment on Grace Franklin's account
8. fetches the outgoing payment on Grace Franklin's account

Note that one has to go through the interaction flow after requesting a grant for a outgoing payment.

<video alt="Screen Recoding eCommerce Example" src="./mov/eCom-example.mov" width="560" height="315" controls></video>

Expand Down
6 changes: 3 additions & 3 deletions docs/img/rafiki-architecture.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ For the quoting to be successful, Rafiki needs to be provided with the current e
| `rates` | Object | Object containing `<asset_code : exchange_rate>` pairs, e.g. `{EUR: 1.1602}` |
| `rates.<asset_code>` | Number | exchange rate given `base` and `<asset_code>` |

The response status code for a successful request is a `200`. The `mock-account-provider` includes a [minimalistic example](../packages/mock-account-provider/app/routes/prices.ts).
The response status code for a successful request is a `200`. The `mock-account-servicing-entity` includes a [minimalistic example](../localenv/mock-account-servicing-entity/app/routes/prices.ts).

The `backend` package requires an environment variable called `PRICES_URL` which MUST specify the URL of this endpoint.

Expand Down Expand Up @@ -58,7 +58,7 @@ If the Account Servicing Entity decides to add sending fees, it is required to p
| `assetCode` | String | [ISO 4217 currency code](https://en.wikipedia.org/wiki/ISO_4217), e.g. `USD` |
| `assetScale` | Number | difference in orders of magnitude between the standard unit and a corresponding fractional unit, e.g. `2` |

If the payment is a `FixedSend` payment, this endpoint should deduct its fees from the receive amount value. If the payment is a `FixedDelivery` payment, this endpoint should add the fees to the send amount value. The response body MUST be equal to the [request body](#request-body) apart from the updated `sendAmount` or `receiveAmount` values. The response status code for a successful request is a `201`. The `mock-account-provider` includes a [minimalistic example](../packages/mock-account-provider/app/routes/quotes.ts).
If the payment is a `FixedSend` payment, this endpoint should deduct its fees from the receive amount value. If the payment is a `FixedDelivery` payment, this endpoint should add the fees to the send amount value. The response body MUST be equal to the [request body](#request-body) apart from the updated `sendAmount` or `receiveAmount` values. The response status code for a successful request is a `201`. The `mock-account-servicing-entity` includes a [minimalistic example](../localenv/mock-account-servicing-entity/app/routes/quotes.ts).

The `backend` package requires an environment variable called `QUOTE_URL` which MUST specify the URL of this endpoint.

Expand Down
2 changes: 1 addition & 1 deletion docs/tigerbeetle.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To use the desired version of TigerBeetle within the production environment, cha

### Local Environment

To use the desired version of TigerBeetle within the local environment, change the tag in the [tigerbeetle `docker-compose.yml` file](../infrastructure/local/tigerbeetle/docker-compose.yml).
To use the desired version of TigerBeetle within the local environment, change the tag in the [tigerbeetle `docker-compose.yml` file](../localenv/tigerbeetle/docker-compose.yml).

### Tests

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: '3'
services:
mock-account-provider:
mock-account-servicing-entity:
hostname: cloud-nine-wallet
build:
context: ../../..
dockerfile: ./packages/mock-account-provider/Dockerfile
context: ../..
dockerfile: ./localenv/mock-account-servicing-entity/Dockerfile
restart: always
networks:
- rafiki
Expand All @@ -25,7 +25,7 @@ services:
hostname: cloud-nine-wallet-backend
image: ghcr.io/interledger/rafiki-backend:latest
build:
context: ../../..
context: ../..
dockerfile: ./packages/backend/Dockerfile
restart: always
privileged: true
Expand Down Expand Up @@ -64,7 +64,7 @@ services:
hostname: cloud-nine-wallet-auth
image: ghcr.io/interledger/rafiki-auth:latest
build:
context: ../../..
context: ../..
dockerfile: ./packages/auth/Dockerfile
restart: always
networks:
Expand All @@ -80,8 +80,8 @@ services:
signatures:
hostname: cloud-nine-wallet-signatures
build:
context: ../../..
dockerfile: ./infrastructure/local/local-http-signatures/Dockerfile
context: ../..
dockerfile: ./localenv/local-http-signatures/Dockerfile
restart: always
ports:
- '3040:3000'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
self:
graphqlUrl: http://cloud-nine-wallet-backend:3001/graphql
hostname: 'cloud-nine-wallet-backend'
mapHostname: 'primary-map'
mapHostname: 'primary-mase'
openPaymentPublishedPort: 3000
asset:
code: USD
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: '3'
services:
mock-account-provider:
mock-account-servicing-entity:
hostname: happy-life-bank
build:
context: ../../..
dockerfile: ./packages/mock-account-provider/Dockerfile
context: ../..
dockerfile: ./localenv/mock-account-servicing-entity/Dockerfile
restart: always
networks:
- rafiki
Expand All @@ -25,7 +25,7 @@ services:
hostname: happy-life-bank-backend
image: ghcr.io/interledger/rafiki-backend:latest
build:
context: ../../..
context: ../..
dockerfile: ./packages/backend/Dockerfile
restart: always
privileged: true
Expand Down Expand Up @@ -61,7 +61,7 @@ services:
hostname: happy-life-bank-auth
image: ghcr.io/interledger/rafiki-auth:latest
build:
context: ../../..
context: ../..
dockerfile: ./packages/auth/Dockerfile
restart: always
networks:
Expand All @@ -76,8 +76,8 @@ services:
signatures:
hostname: happy-life-bank-signatures
build:
context: ../../..
dockerfile: ./infrastructure/local/local-http-signatures/Dockerfile
context: ../..
dockerfile: ./localenv/local-http-signatures/Dockerfile
restart: always
ports:
- '3041:3000'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
self:
graphqlUrl: http://happy-life-bank-backend:3001/graphql
hostname: 'happy-life-bank-backend'
mapHostname: 'primary-map'
mapHostname: 'primary-mase'
openPaymentPublishedPort: 4000
asset:
code: USD
Expand Down
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ RUN pnpm install -r --offline

RUN pnpm --filter local-http-signatures build

CMD ["node", "./infrastructure/local/local-http-signatures/dist/app.js"]
CMD ["node", "./localenv/local-http-signatures/dist/app.js"]
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ In order to build the docker container to run the signature app, run the followi

```shell
# from the root
docker build -f infrastructure/local/local-http-signatures/Dockerfile -t rafiki-signatures .
docker build -f localenv/local-http-signatures/Dockerfile -t rafiki-signatures .
```

The following environment variables can be set.
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.build.json",
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"lib": ["ES2020"],
"outDir": "./dist",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ RUN pnpm fetch
ADD . ./
RUN pnpm install -r --offline

RUN pnpm --filter mock-account-provider build
RUN pnpm --filter mock-account-servicing-entity build

CMD pnpm --filter mock-account-provider start
CMD pnpm --filter mock-account-servicing-entity start
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ rm -rf app
cp -R ../my-old-remix-app/app app
```

# Mock Account Provider
# Mock Account Servicing Entity

## Seed file

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

export const meta: MetaFunction = () => ({
charset: 'utf-8',
title: 'Mock Account Provider',
title: 'Mock Account Servicing Entity',
viewport: 'width=device-width,initial-scale=1'
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "mock-account-provider",
"name": "mock-account-servicing-entity",
"sideEffects": false,
"scripts": {
"build:deps": "pnpm --filter http-signature-utils build",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
self:
graphqlUrl: http://localhost:3001/graphql
hostname: 'backend'
mapHostname: 'primary-map'
mapHostname: 'primary-mase'
peers:
- asset: USD
scale: 2
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/local/peer-setup.md → localenv/peer-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ Example successful response:
### Create Payment Pointers to Send and Receive Payments

In this step we will provision payment pointers on the primary and secondary Rafiki instances.
Payment pointers are not accounts. Rafiki operators must supply their own "account provider"
Payment pointers are not accounts. Rafiki operators must supply their own "account servicing entity"
service for actually "holding" currency. Rafiki provides payment pointers--addresses within the
ILP network to which other nodes on the network can send payments, which will then be routed
to the account provider system and into the appropriate account.
to the account servicing entity's system and into the appropriate account.

At the end of this step, we will have two payment pointer IDs: one provisioned on the primary
instance and one provisioned on the secondary instance. We will use these payment pointer IDs in
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"build": "tsc --build",
"localenv:network:create": "docker network create --driver=bridge --subnet=10.5.0.0/24 --gateway=10.5.0.1 rafiki",
"localenv:network:remove": "docker network remove rafiki",
"localenv:cloud-nine-wallet": "docker compose -f ./infrastructure/local/cloud-nine-wallet/docker-compose.yml",
"localenv:happy-life-bank": "docker compose -f ./infrastructure/local/happy-life-bank/docker-compose.yml",
"localenv:tigerbeetle": "docker compose -f ./infrastructure/local/tigerbeetle/docker-compose.yml --env-file ./infrastructure/local/tigerbeetle/.env.tigerbeetle",
"localenv:cloud-nine-wallet": "docker compose -f ./localenv/cloud-nine-wallet/docker-compose.yml",
"localenv:happy-life-bank": "docker compose -f ./localenv/happy-life-bank/docker-compose.yml",
"localenv:tigerbeetle": "docker compose -f ./localenv/tigerbeetle/docker-compose.yml --env-file ./localenv/tigerbeetle/.env.tigerbeetle",
"localenv:build": "pnpm localenv:tigerbeetle build && pnpm localenv:cloud-nine-wallet build && pnpm localenv:happy-life-bank build",
"localenv:start": "pnpm localenv:network:create && pnpm localenv:tigerbeetle up -d && pnpm localenv:cloud-nine-wallet up -d && pnpm localenv:happy-life-bank up -d",
"localenv:stop": "pnpm localenv:happy-life-bank down && pnpm localenv:cloud-nine-wallet down && pnpm localenv:tigerbeetle down && pnpm localenv:network:remove",
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
development: {
client: 'postgresql',
connection: {
// The database, user and password here match those in the infrastructure/local/docker-compose.yml file
// The database, user and password here match those in the localenv/docker-compose.yml file
database: 'auth',
user: 'postgres',
password: 'password'
Expand All @@ -24,7 +24,7 @@ module.exports = {
peerdevelopment: {
client: 'postgresql',
connection: {
// The database, user and password here match those in the infrastructure/local/peer-docker-compose.yml file
// The database, user and password here match those in the localenv/peer-docker-compose.yml file
database: 'peerauth',
user: 'postgres',
password: 'password'
Expand Down
Loading

0 comments on commit 9975cdf

Please sign in to comment.