Skip to content

Commit

Permalink
feat(backend): wallet address response with tenant id (#2986)
Browse files Browse the repository at this point in the history
* feat(backend): create operator kratos identity on backend startup

* chore: formatting

* fix: handle new cases

* Add migration files

* Update migration files

* feat(tenant): basic tenant admin api schema and service

* Fix file name for migrations

* feat(auth): create basic tenant service and model plus graphql schema

* feat(graphql): generated data

* feat(auth): add basic tenant schema and appropriate resources like model and service

* feat(backend): add apollo client do dependencies

* feat(auth): delete tenant

* chore(auth): format

* feat(backend): create tenant service implementation

* feat(packages): make multi tenant work wip

* feat(backend): update resolvers with tenant id and finish the tenant creation

* feat(backend): small changes to schema + mapping of tenant to graphql + bruno

* feat(backend,frontend): create kratos identity when tenants are created, permissioned admin UI pages

* feat(wip): use tenantId in OP flow

* feat: quote grant requests with tenantId

* feat: outgoing payment with tenantId

* chore: formatting

* feat: bruno updates

* chore: remove some dangling merge stuff

---------

Co-authored-by: bsanduc <[email protected]>
Co-authored-by: golobitch <[email protected]>
  • Loading branch information
3 people authored Sep 30, 2024
1 parent d0867fa commit 3ab716c
Show file tree
Hide file tree
Showing 53 changed files with 148 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsHost}}/incoming-payments
url: {{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsHost}}/outgoing-payments
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/outgoing-payments
body: json
auth: none
}
Expand Down Expand Up @@ -35,7 +35,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("outgoingPaymentId", body.id.split("/").pop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{senderOpenPaymentsHost}}/outgoing-payments/{{outgoingPaymentId}}
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/outgoing-payments/{{outgoingPaymentId}}
body: none
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ script:post-response {
bru.setEnvVar("receiverAssetScale", body?.assetScale)

const authUrl = url.parse(body?.authServer)
const receiverTenantId = authUrl.pathname.split('/')[1]
bru.setEnvVar('receiverTenantId', receiverTenantId)
if (
authUrl.hostname.includes('cloud-nine-wallet') ||
authUrl.hostname.includes('happy-life-bank')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ script:post-response {
}

const body = res.getBody()

bru.setEnvVar("senderAssetCode", body?.assetCode)
bru.setEnvVar("senderAssetScale", body?.assetScale)

const authUrl = url.parse(body?.authServer)
const senderTenantId = authUrl.pathname.split('/')[1]
bru.setEnvVar('senderTenantId', senderTenantId)
if (
authUrl.hostname.includes('cloud-nine-wallet') ||
authUrl.hostname.includes('happy-life-bank')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/
url: {{receiverOpenPaymentsAuthHost}}/{{receiverTenantId}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ meta {
}

post {
url: {{receiverOpenPaymentsHost}}/incoming-payments
url: {{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments
body: json
auth: none
}

headers {
Authorization: GNAP {{accessToken}}
x-operator-secret: {{operatorApiSecret}}
}

body:json {
Expand Down Expand Up @@ -41,7 +42,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsHost}}/outgoing-payments
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/outgoing-payments
body: json
auth: none
}
Expand Down Expand Up @@ -34,7 +34,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("outgoingPaymentId", body.id.split("/").pop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsHost}}/quotes
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/quotes
body: json
auth: none
}
Expand All @@ -17,7 +17,7 @@ headers {
body:json {
{
"walletAddress": "{{senderWalletAddress}}",
"receiver": "{{receiverOpenPaymentsHost}}/incoming-payments/{{incomingPaymentId}}",
"receiver": "{{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments/{{incomingPaymentId}}",
"method": "ilp"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{senderOpenPaymentsHost}}/outgoing-payments/{{outgoingPaymentId}}
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/outgoing-payments/{{outgoingPaymentId}}
body: none
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,24 @@ script:pre-request {

script:post-response {
const url = require('url')

if (res.getStatus() !== 200) {
return
}

const body = res.getBody()
bru.setEnvVar("receiverAssetCode", body?.assetCode)
bru.setEnvVar("receiverAssetScale", body?.assetScale)

const authUrl = url.parse(body?.authServer)
const receiverTenantId = authUrl.pathname.split('/')[1]
bru.setEnvVar("receiverTenantId", receiverTenantId)
if (
authUrl.hostname.includes('cloud-nine-wallet') ||
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port);
} else {
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ script:post-response {
bru.setEnvVar("senderAssetScale", body?.assetScale)

const authUrl = url.parse(body?.authServer)
const senderTenantId = authUrl.pathname.split('/')[1]
bru.setEnvVar("senderTenantId", senderTenantId)
if (
authUrl.hostname.includes('cloud-nine-wallet') ||
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port);
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}

}

tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/
url: {{receiverOpenPaymentsAuthHost}}/{{receiverTenantId}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}
body: json
auth: none
}

headers {
x-operator-secret: {{operatorApiSecret}}
}

body:json {
{
"access_token": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsHost}}/incoming-payments
url: {{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments
body: json
auth: none
}
Expand Down Expand Up @@ -36,7 +36,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());
bru.setEnvVar("quoteDebitAmount", JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsHost}}/outgoing-payments
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/outgoing-payments
body: json
auth: none
}
Expand All @@ -17,7 +17,7 @@ headers {
body:json {
{
"walletAddress": "{{senderWalletAddress}}",
"incomingPayment": "{{receiverOpenPaymentsHost}}/incoming-payments/{{incomingPaymentId}}",
"incomingPayment": "{{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments/{{incomingPaymentId}}",
"debitAmount": {
"value": "300",
"assetCode": "USD",
Expand All @@ -40,7 +40,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("outgoingPaymentId", body.id.split("/").pop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsHost}}/outgoing-payments
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/outgoing-payments
body: json
auth: none
}
Expand All @@ -17,7 +17,7 @@ headers {
body:json {
{
"walletAddress": "{{senderWalletAddress}}",
"incomingPayment": "{{receiverOpenPaymentsHost}}/incoming-payments/{{incomingPaymentId}}",
"incomingPayment": "{{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments/{{incomingPaymentId}}",
"debitAmount": {
"value": "300",
"assetCode": "USD",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsHost}}/outgoing-payments
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/outgoing-payments
body: json
auth: none
}
Expand All @@ -17,7 +17,7 @@ headers {
body:json {
{
"walletAddress": "{{senderWalletAddress}}",
"incomingPayment": "{{receiverOpenPaymentsHost}}/incoming-payments/{{incomingPaymentId}}",
"incomingPayment": "{{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments/{{incomingPaymentId}}",
"debitAmount": {
"value": "300",
"assetCode": "USD",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{senderOpenPaymentsHost}}/outgoing-payments/{{outgoingPaymentId}}
url: {{senderOpenPaymentsHost}}/{{senderTenantId}}/outgoing-payments/{{outgoingPaymentId}}
body: none
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ script:post-response {
}

const body = res.getBody()

bru.setEnvVar("receiverAssetCode", body?.assetCode)
bru.setEnvVar("receiverAssetScale", body?.assetScale)

const authUrl = url.parse(body?.authServer)
const receiverTenantId = authUrl.pathname.split('/')[1]
bru.setEnvVar('receiverTenantId', receiverTenantId)
if (
authUrl.hostname.includes('cloud-nine-wallet') ||
authUrl.hostname.includes('happy-life-bank')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ script:post-response {
bru.setEnvVar("senderAssetScale", body?.assetScale)

const authUrl = url.parse(body?.authServer)
const senderTenantId = authUrl.pathname.split('/')[1]
bru.setEnvVar('senderTenantId', senderTenantId)
if (
authUrl.hostname.includes('cloud-nine-wallet') ||
authUrl.hostname.includes('happy-life-bank')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/
url: {{receiverOpenPaymentsAuthHost}}/{{receiverTenantId}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/
url: {{senderOpenPaymentsAuthHost}}/{{senderTenantId}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsHost}}/incoming-payments/{{incomingPaymentId}}/complete
url: {{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments/{{incomingPaymentId}}/complete
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsHost}}/incoming-payments
url: {{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments
body: json
auth: none
}
Expand Down Expand Up @@ -42,7 +42,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{receiverOpenPaymentsHost}}/incoming-payments/{{incomingPaymentId}}
url: {{receiverOpenPaymentsHost}}/{{receiverTenantId}}/incoming-payments/{{incomingPaymentId}}
body: none
auth: none
}
Expand Down
Loading

0 comments on commit 3ab716c

Please sign in to comment.