-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(backend): add local payment #2857
Changes from 74 commits
bb77152
fc06e24
257fd01
d9fa20e
2e76ee2
4fab5d8
b17db75
6e37420
9ef7f94
320ee21
07569a7
f3d5f5d
d795ce2
251c60a
8f0bcb8
eca01f1
770d7ea
3849db7
170bcc3
88618ce
823c512
2e9f043
3fb02e5
569f029
dae1de1
2016469
3182944
3665188
5b8bad3
b49e08e
eedacb5
27a64b2
26d0539
2723961
08126c5
205447d
0471d84
7b5142d
773e4f2
0a3adf4
347f9b0
37d399e
78d42b6
a96d654
7941f05
753a57b
ed30066
8476615
f8a979c
5cee618
d41777e
e0f988d
5d631bd
ececad2
63011ae
bd12e30
b0eaf8d
0d69a3d
31e6cc7
bb9d334
b0897d9
2d8048a
15d8929
c40db9e
0dbb2d3
61b1010
0dea97d
6c995d9
86f6db6
3fc6924
6634b8f
6706557
998ee25
a4cf57a
1835bc4
7db833b
4437438
3149428
fe63991
e6cad1e
f120aab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
meta { | ||
name: Create Outgoing Payment | ||
type: graphql | ||
seq: 3 | ||
} | ||
|
||
post { | ||
url: {{RafikiGraphqlHost}}/graphql | ||
body: graphql | ||
auth: none | ||
} | ||
|
||
body:graphql { | ||
mutation CreateOutgoingPayment($input: CreateOutgoingPaymentInput!) { | ||
createOutgoingPayment(input: $input) { | ||
payment { | ||
createdAt | ||
error | ||
metadata | ||
id | ||
walletAddressId | ||
receiveAmount { | ||
assetCode | ||
assetScale | ||
value | ||
} | ||
receiver | ||
debitAmount { | ||
assetCode | ||
assetScale | ||
value | ||
} | ||
sentAmount { | ||
assetCode | ||
assetScale | ||
value | ||
} | ||
state | ||
stateAttempts | ||
} | ||
} | ||
} | ||
} | ||
|
||
body:graphql:vars { | ||
{ | ||
"input": { | ||
"walletAddressId": "{{gfranklinWalletAddressId}}", | ||
"quoteId": "{{quoteId}}" | ||
} | ||
} | ||
} | ||
|
||
script:pre-request { | ||
const scripts = require('./scripts'); | ||
|
||
scripts.addApiSignatureHeader(); | ||
} | ||
|
||
script:post-response { | ||
const body = res.getBody(); | ||
|
||
if (body?.data) { | ||
bru.setEnvVar("outgoingPaymentId", body.data.createOutgoingPayment.payment.id); | ||
} | ||
} | ||
|
||
tests { | ||
test("Outgoing Payment id is string", function() { | ||
expect(bru.getEnvVar("outgoingPaymentId")).to.be.a("string"); | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
meta { | ||
name: Create Quote | ||
type: graphql | ||
seq: 2 | ||
} | ||
|
||
post { | ||
url: {{RafikiGraphqlHost}}/graphql | ||
body: graphql | ||
auth: none | ||
} | ||
|
||
body:graphql { | ||
mutation CreateQuote($input: CreateQuoteInput!) { | ||
createQuote(input: $input) { | ||
quote { | ||
createdAt | ||
expiresAt | ||
id | ||
walletAddressId | ||
receiveAmount { | ||
assetCode | ||
assetScale | ||
value | ||
} | ||
receiver | ||
debitAmount { | ||
assetCode | ||
assetScale | ||
value | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
body:graphql:vars { | ||
{ | ||
"input": { | ||
"walletAddressId": "{{gfranklinWalletAddressId}}", | ||
"receiver": "{{receiverId}}" | ||
} | ||
} | ||
} | ||
|
||
script:pre-request { | ||
const scripts = require('./scripts'); | ||
|
||
await scripts.loadWalletAddressIdsIntoVariables(); | ||
|
||
scripts.addApiSignatureHeader(); | ||
} | ||
|
||
script:post-response { | ||
const body = res.getBody(); | ||
|
||
if (body?.data) { | ||
bru.setEnvVar("quoteId", body.data.createQuote.quote.id); | ||
} | ||
} | ||
|
||
tests { | ||
test("Quote id is string", function() { | ||
expect(bru.getEnvVar("quoteId")).to.be.a("string"); | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
meta { | ||
name: Create Receiver -local Incoming Payment- | ||
type: graphql | ||
seq: 1 | ||
} | ||
|
||
post { | ||
url: {{RafikiGraphqlHost}}/graphql | ||
body: graphql | ||
auth: none | ||
} | ||
|
||
body:graphql { | ||
mutation CreateReceiver($input: CreateReceiverInput!) { | ||
createReceiver(input: $input) { | ||
receiver { | ||
completed | ||
createdAt | ||
expiresAt | ||
metadata | ||
id | ||
incomingAmount { | ||
assetCode | ||
assetScale | ||
value | ||
} | ||
walletAddressUrl | ||
receivedAmount { | ||
assetCode | ||
assetScale | ||
value | ||
} | ||
updatedAt | ||
} | ||
} | ||
} | ||
} | ||
|
||
body:graphql:vars { | ||
{ | ||
"input": { | ||
"metadata": { | ||
"description": "For lunch!" | ||
}, | ||
"incomingAmount": { | ||
"assetCode": "USD", | ||
"assetScale": 2, | ||
"value": 500 | ||
}, | ||
"walletAddressUrl": "https://cloud-nine-wallet-backend/accounts/bhamchest" | ||
} | ||
} | ||
} | ||
|
||
script:pre-request { | ||
const scripts = require('./scripts'); | ||
|
||
scripts.addApiSignatureHeader(); | ||
} | ||
|
||
script:post-response { | ||
const body = res.getBody(); | ||
|
||
if (body?.data) { | ||
bru.setEnvVar("receiverId", body.data.createReceiver.receiver.id); | ||
} | ||
} | ||
|
||
tests { | ||
test("Receiver id is string", function() { | ||
expect(bru.getEnvVar("receiverId")).to.be.a("string"); | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
meta { | ||
name: Get Outgoing Payment | ||
type: graphql | ||
seq: 4 | ||
} | ||
|
||
post { | ||
url: {{RafikiGraphqlHost}}/graphql | ||
body: graphql | ||
auth: none | ||
} | ||
|
||
body:graphql { | ||
query GetOutgoingPayment($id: String!) { | ||
outgoingPayment(id: $id) { | ||
createdAt | ||
error | ||
metadata | ||
id | ||
grantId | ||
walletAddressId | ||
quote { | ||
id | ||
} | ||
receiveAmount { | ||
assetCode | ||
assetScale | ||
value | ||
} | ||
receiver | ||
debitAmount { | ||
assetCode | ||
assetScale | ||
value | ||
} | ||
sentAmount { | ||
assetCode | ||
assetScale | ||
value | ||
} | ||
state | ||
stateAttempts | ||
} | ||
} | ||
} | ||
|
||
body:graphql:vars { | ||
{ | ||
"id": "{{outgoingPaymentId}}" | ||
} | ||
} | ||
|
||
script:pre-request { | ||
const scripts = require('./scripts'); | ||
|
||
scripts.addApiSignatureHeader(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
|
||
exports.up = function (knex) { | ||
return knex('quotes') | ||
.whereNull('estimatedExchangeRate') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In which cases the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont know of any specific cases where it would be null, but since it's nullable we should handle that possibility. |
||
.update({ | ||
estimatedExchangeRate: knex.raw('?? / ??', [ | ||
'lowEstimatedExchangeRateNumerator', | ||
'lowEstimatedExchangeRateDenominator' | ||
]) | ||
}) | ||
.then(() => { | ||
return knex.schema.table('quotes', (table) => { | ||
table.decimal('estimatedExchangeRate', 20, 10).notNullable().alter() | ||
}) | ||
}) | ||
} | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function (knex) { | ||
return knex.schema.table('quotes', (table) => { | ||
table.decimal('estimatedExchangeRate', 20, 10).nullable().alter() | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = function (knex) { | ||
return ( | ||
knex.schema | ||
// Create new table with columns from "quotes" to migrate | ||
.createTable('ilpQuoteDetails', function (table) { | ||
table.uuid('id').notNullable().primary() | ||
|
||
// quoteId is purposefully not a FK referencing quote.id | ||
// this allows us to create ilpQuoteDetail before quotes in service of | ||
// fully decoupling payment method/quote services. | ||
// https://github.com/interledger/rafiki/pull/2857#discussion_r1825891327 | ||
table.uuid('quoteId').notNullable().unique().index() | ||
|
||
table.bigInteger('maxPacketAmount').notNullable() | ||
table.decimal('minExchangeRateNumerator', 64, 0).notNullable() | ||
table.decimal('minExchangeRateDenominator', 64, 0).notNullable() | ||
table.decimal('lowEstimatedExchangeRateNumerator', 64, 0).notNullable() | ||
table | ||
.decimal('lowEstimatedExchangeRateDenominator', 64, 0) | ||
.notNullable() | ||
table.decimal('highEstimatedExchangeRateNumerator', 64, 0).notNullable() | ||
table | ||
.decimal('highEstimatedExchangeRateDenominator', 64, 0) | ||
.notNullable() | ||
|
||
table.timestamp('createdAt').defaultTo(knex.fn.now()) | ||
table.timestamp('updatedAt').defaultTo(knex.fn.now()) | ||
}) | ||
.then(() => { | ||
return knex.raw(` | ||
INSERT INTO "ilpQuoteDetails" ( | ||
id, | ||
"quoteId", | ||
"maxPacketAmount", | ||
"minExchangeRateNumerator", | ||
"minExchangeRateDenominator", | ||
"lowEstimatedExchangeRateNumerator", | ||
"lowEstimatedExchangeRateDenominator", | ||
"highEstimatedExchangeRateNumerator", | ||
"highEstimatedExchangeRateDenominator" | ||
) | ||
SELECT | ||
gen_random_uuid(), | ||
id AS "quoteId", | ||
"maxPacketAmount", | ||
"minExchangeRateNumerator", | ||
"minExchangeRateDenominator", | ||
"lowEstimatedExchangeRateNumerator", | ||
"lowEstimatedExchangeRateDenominator", | ||
"highEstimatedExchangeRateNumerator", | ||
"highEstimatedExchangeRateDenominator" | ||
FROM "quotes"; | ||
`) | ||
}) | ||
) | ||
} | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function (knex) { | ||
return knex.schema.dropTableIfExists('ilpQuoteDetails') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think still need to change the actual file name to reflect this name