Skip to content

Commit

Permalink
Merge branch 'main' into mk/better-balances
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurapov committed Aug 20, 2024
2 parents 36efdd4 + 8e96bc3 commit c5eca52
Show file tree
Hide file tree
Showing 34 changed files with 435 additions and 250 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ body:graphql {
quote {
createdAt
expiresAt
highEstimatedExchangeRate
id
lowEstimatedExchangeRate
maxPacketAmount
minExchangeRate
walletAddressId
receiveAmount {
assetCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ body:graphql {
quote {
createdAt
expiresAt
highEstimatedExchangeRate
id
lowEstimatedExchangeRate
maxPacketAmount
minExchangeRate
walletAddressId
receiveAmount {
assetCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ body:graphql {
quote {
createdAt
expiresAt
highEstimatedExchangeRate
id
lowEstimatedExchangeRate
maxPacketAmount
minExchangeRate
estimatedExchangeRate
walletAddressId
receiveAmount {
assetCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ body:graphql {
quote {
createdAt
expiresAt
highEstimatedExchangeRate
id
lowEstimatedExchangeRate
maxPacketAmount
minExchangeRate
walletAddressId
estimatedExchangeRate
receiveAmount {
assetCode
assetScale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ body:graphql {
quote {
createdAt
expiresAt
highEstimatedExchangeRate
id
lowEstimatedExchangeRate
maxPacketAmount
minExchangeRate
estimatedExchangeRate
walletAddressId
receiveAmount {
assetCode
Expand Down
4 changes: 0 additions & 4 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ body:graphql {
quote {
createdAt
expiresAt
highEstimatedExchangeRate
id
lowEstimatedExchangeRate
maxPacketAmount
minExchangeRate
walletAddressId
receiveAmount {
assetCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ body:graphql {
quote {
createdAt
expiresAt
highEstimatedExchangeRate
id
lowEstimatedExchangeRate
maxPacketAmount
minExchangeRate
walletAddressId
estimatedExchangeRate
receiveAmount {
assetCode
assetScale
Expand Down
5 changes: 1 addition & 4 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Get Quote.bru
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ body:graphql {
query GetQuote($id: String!) {
quote(id: $id) {
createdAt
highEstimatedExchangeRate
expiresAt
id
lowEstimatedExchangeRate
maxPacketAmount
minExchangeRate
walletAddressId
estimatedExchangeRate
receiveAmount {
assetCode
assetScale
Expand Down
12 changes: 4 additions & 8 deletions localenv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ These packages include:
- `mock-account-servicing-entity` (mocks an [Account Servicing Entity](https://rafiki.dev/concepts/account-servicing-entity/)
- `frontend` (Remix app to expose a UI for Rafiki Admin management via interaction with the `backend` Admin APIs)
- `kratos` (An identity and user management solution for the `frontend`)
- `mailslurper` (A SMTP mail server to catch account recovery emails)
- `mailslurper` (A SMTP mail server to catch account recovery emails for the `frontend`)

These packages depend on the following databases:

Expand Down Expand Up @@ -255,15 +255,11 @@ Note that you have to go through an interaction flow by clicking on the `redirec

#### Admin UI

In order to manage, and view information about the Rafiki instance(s) using a UI, you can navigate to [`localhost:3010`](http://localhost:3010) (Cloud Nine Wallet) or [`localhost:4010`](http://localhost:4010) (Happy Life Bank). This is the `frontend` project which runs a Remix app for querying info and executing mutations against the Rafiki [Admin APIs](#admin-apis).
In order to manage, and view information about the Rafiki instance(s) you can use the [Rafiki Admin](../packages/frontend/README.md) UI. We have secured access to Rafiki Admin using [Ory Kratos](https://www.ory.sh/docs/kratos/ory-kratos-intro). Since access to the UI is on an invitation-only basis the registration flow is not publicly available. As such, in order to access Rafiki Admin you can click the registration link provided in the logs during `localenv` startup or you can manually add a new user with the invite-user script. Run `docker exec -it <admin-container-name> npm run invite-user -- [email protected]` and it will output a link to the terminal. Copy and paste this link in your browser and you will automatically be logged in and directed to the account settings page. The next step is changing your password. We're using a simple email and password authentication method.

We have secured access to the Admin UI using [Ory Kratos](https://www.ory.sh/docs/kratos/ory-kratos-intro), a secure and fully open-source identity and user management solution. Check it out on [GitHub](https://github.com/ory/kratos). Since access to the UI is on an invitation-only basis the registration flow is not publicly available. As such, in order to access the Admin UI you can click the registration link provided in the logs during `localenv` startup or you can manually add a new user with the invite-user script. Run `docker exec -it <admin-container-name> npm run invite-user -- [email protected]` and it will output recovery link to the terminal. The recovery link doubles as the invitation method. Copy and paste this link in your browser and you will automatically be logged in and directed to the account settings page. The next step is changing your password. We're using a simple email and password authentication method.
Note that a separate registration is required for Cloud Nine Wallet's Rafiki Admin and Happy Life Bank's Rafiki Admin, since they are each designed to run as separate mock account servicing entities. Once you've registered, you can always come back to your Rafiki Admin account by navigating to [`localhost:3010`](http://localhost:3010) (Cloud Nine Wallet) or [`localhost:4010`](http://localhost:4010) (Happy Life Bank) and logging in.

There is a password recovery flow. On the login page if you clkick the `forgot password` link and enter an email for a registered user then you can open [Mail Slurper](http://localhost:4436) to access the recovery link for your account.

We've also included a script to remove users: `docker exec -it <admin-container-name> npm run delete-user -- [email protected]`.

See the `frontend` [README](../packages/frontend/README.md) for more information.
You can test the account recovery flow by clicking "Forgot pasword?" on the login page and by navigating to [`localhost:4436`](http://localhost:4436) (Mailslurper interface).

#### Admin APIs

Expand Down
15 changes: 3 additions & 12 deletions localenv/mock-account-servicing-entity/generated/graphql.ts

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

68 changes: 8 additions & 60 deletions packages/backend/src/graphql/generated/graphql.schema.json

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

15 changes: 3 additions & 12 deletions packages/backend/src/graphql/generated/graphql.ts

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

14 changes: 4 additions & 10 deletions packages/backend/src/graphql/resolvers/outgoing_payment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ describe('OutgoingPayment Resolvers', (): void => {
metadata
quote {
id
maxPacketAmount
minExchangeRate
lowEstimatedExchangeRate
highEstimatedExchangeRate
estimatedExchangeRate
createdAt
expiresAt
}
Expand Down Expand Up @@ -245,14 +242,11 @@ describe('OutgoingPayment Resolvers', (): void => {
metadata,
quote: {
id: payment.quote.id,
maxPacketAmount: payment.quote.maxPacketAmount.toString(),
minExchangeRate: payment.quote.minExchangeRate.valueOf(),
lowEstimatedExchangeRate:
payment.quote.lowEstimatedExchangeRate.valueOf(),
highEstimatedExchangeRate:
payment.quote.highEstimatedExchangeRate.valueOf(),
createdAt: payment.quote.createdAt.toISOString(),
expiresAt: payment.quote.expiresAt.toISOString(),
estimatedExchangeRate: payment.quote.estimatedExchangeRate
? parseFloat(payment.quote.estimatedExchangeRate?.toString())
: undefined,
__typename: 'Quote'
},
createdAt: payment.createdAt.toISOString(),
Expand Down
8 changes: 0 additions & 8 deletions packages/backend/src/graphql/resolvers/quote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ describe('Quote Resolvers', (): void => {
assetCode
assetScale
}
maxPacketAmount
minExchangeRate
lowEstimatedExchangeRate
highEstimatedExchangeRate
createdAt
expiresAt
}
Expand Down Expand Up @@ -124,10 +120,6 @@ describe('Quote Resolvers', (): void => {
assetScale: quote.receiveAmount.assetScale,
__typename: 'Amount'
},
maxPacketAmount: quote.maxPacketAmount.toString(),
minExchangeRate: quote.minExchangeRate.valueOf(),
lowEstimatedExchangeRate: quote.lowEstimatedExchangeRate.valueOf(),
highEstimatedExchangeRate: quote.highEstimatedExchangeRate.valueOf(),
createdAt: quote.createdAt.toISOString(),
expiresAt: quote.expiresAt.toISOString(),
__typename: 'Quote'
Expand Down
7 changes: 2 additions & 5 deletions packages/backend/src/graphql/resolvers/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,8 @@ export function quoteToGraphql(quote: Quote): SchemaQuote {
receiver: quote.receiver,
debitAmount: quote.debitAmount,
receiveAmount: quote.receiveAmount,
maxPacketAmount: quote.maxPacketAmount,
minExchangeRate: quote.minExchangeRate.valueOf(),
lowEstimatedExchangeRate: quote.lowEstimatedExchangeRate.valueOf(),
highEstimatedExchangeRate: quote.highEstimatedExchangeRate.valueOf(),
createdAt: new Date(+quote.createdAt).toISOString(),
expiresAt: new Date(+quote.expiresAt).toISOString()
expiresAt: new Date(+quote.expiresAt).toISOString(),
estimatedExchangeRate: quote.estimatedExchangeRate?.valueOf()
}
}
10 changes: 2 additions & 8 deletions packages/backend/src/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -957,18 +957,12 @@ type Quote {
debitAmount: Amount!
"Amount to receive (fixed receive)"
receiveAmount: Amount!
"Maximum value per packet allowed on the possible routes"
maxPacketAmount: UInt64!
"Aggregate exchange rate the payment is guaranteed to meet"
minExchangeRate: Float!
"Lower bound of probed exchange rate"
lowEstimatedExchangeRate: Float!
"Upper bound of probed exchange rate"
highEstimatedExchangeRate: Float!
"Date-time of creation"
createdAt: String!
"Date-time of expiration"
expiresAt: String!
"Estimated exchange rate"
estimatedExchangeRate: Float
}

input AmountInput {
Expand Down
Loading

0 comments on commit c5eca52

Please sign in to comment.