-
Notifications
You must be signed in to change notification settings - Fork 90
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): remove payment pointer from url, retrieve it from request query or body #2042
Changes from all commits
4a8b94c
650092b
646d1dc
3ebbdc0
4ad3cdb
5113efd
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 |
---|---|---|
|
@@ -40,27 +40,21 @@ exports.up = function (knex) { | |
table.dropIndex(['paymentPointerId', 'createdAt', 'id']) | ||
table.renameColumn('paymentPointerId', 'walletAddressId') | ||
table.foreign('walletAddressId').references('walletAddresses.id') | ||
table.index(['walletAddressId']) | ||
table.index(['createdAt']) | ||
table.index(['id']) | ||
table.index(['walletAddressId', 'createdAt', 'id']) | ||
}), | ||
knex.schema.alterTable('incomingPayments', function (table) { | ||
table.dropForeign(['paymentPointerId']) | ||
table.dropIndex(['paymentPointerId', 'createdAt', 'id']) | ||
table.renameColumn('paymentPointerId', 'walletAddressId') | ||
table.foreign('walletAddressId').references('walletAddresses.id') | ||
table.index(['walletAddressId']) | ||
table.index(['createdAt']) | ||
table.index(['id']) | ||
table.index(['walletAddressId', 'createdAt', 'id']) | ||
}), | ||
knex.schema.alterTable('outgoingPayments', function (table) { | ||
table.dropForeign(['paymentPointerId']) | ||
table.dropIndex(['paymentPointerId', 'createdAt', 'id']) | ||
table.renameColumn('paymentPointerId', 'walletAddressId') | ||
table.foreign('walletAddressId').references('walletAddresses.id') | ||
table.index(['walletAddressId']) | ||
table.index(['createdAt']) | ||
table.index(['id']) | ||
table.index(['walletAddressId', 'createdAt', 'id']) | ||
}), | ||
knex('webhookEvents') | ||
.update({ | ||
|
@@ -113,7 +107,7 @@ exports.down = function (knex) { | |
'ALTER INDEX "walletAddresses_pkey" RENAME TO "paymentPointers_pkey"' | ||
), | ||
knex.raw( | ||
'ALTER INDEX "walletAddresses_url_index" RENAME TO "paymentPointers_url_index"' | ||
'ALTER INDEX "walletaddresses_url_index" RENAME TO "paymentpointers_url_index"' | ||
), | ||
knex.raw( | ||
'ALTER INDEX "walletaddresses_processat_index" RENAME TO "paymentpointers_processat_index"' | ||
|
@@ -122,19 +116,18 @@ exports.down = function (knex) { | |
'ALTER TABLE "paymentPointers" DROP CONSTRAINT "walletaddresses_url_unique"' | ||
), | ||
knex.raw( | ||
'ALTER TABLE "paymentPointers" DROP CONSTRAINT "walletaddreses_assetid_foreign"' | ||
'ALTER TABLE "paymentPointers" DROP CONSTRAINT "walletaddresses_assetid_foreign"' | ||
), | ||
knex.schema.renameTable('walletAddressKeys', 'paymentPointerKeys'), | ||
knex.schema.alterTable('paymentPointerKeys', function (table) { | ||
table.dropForeign(['walletAddressId']) | ||
table.renameColumn('walletAddressId', 'paymentPointerId') | ||
table.foreign('paymentPointerId').references('paymentPointers.id') | ||
}), | ||
knex.raw( | ||
'ALTER INDEX "walletAddressKeys_pkey" RENAME TO "paymentPointerKeys_pkey"' | ||
), | ||
knex.raw( | ||
'ALTER TABLE "paymentpointerKeys" DROP CONSTRAINT "walletaddresskeys_paymentpointerid_foreign"' | ||
'ALTER TABLE "paymentPointerKeys" DROP CONSTRAINT "walletaddresskeys_walletaddressid_foreign"' | ||
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. What is 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. It's a foreign key on the table |
||
), | ||
knex.schema.alterTable('quotes', function (table) { | ||
table.dropForeign(['walletAddressId']) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,7 @@ async function getIncomingPaymentPublic( | |
const incomingPayment = await deps.incomingPaymentService.get({ | ||
id: ctx.params.id, | ||
client: ctx.accessAction === AccessAction.Read ? ctx.client : undefined, | ||
paymentPointerId: ctx.paymentPointer.id | ||
walletAddressId: ctx.walletAddress.id | ||
}) | ||
ctx.body = incomingPayment?.toPublicOpenPaymentsType() | ||
} catch (err) { | ||
|
@@ -105,16 +105,17 @@ async function getIncomingPaymentPrivate( | |
} catch (err) { | ||
ctx.throw(500, 'Error trying to get incoming payment') | ||
} | ||
if (!incomingPayment) return ctx.throw(404) | ||
if (!incomingPayment || !incomingPayment.walletAddress) return ctx.throw(404) | ||
const connection = deps.connectionService.get(incomingPayment) | ||
ctx.body = incomingPaymentToBody( | ||
ctx.walletAddress, | ||
incomingPayment.walletAddress, | ||
incomingPayment, | ||
connection | ||
) | ||
Comment on lines
+108
to
114
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'm assuming the connection part is going to be removed in a subsequent PR from @BlairCurrey ? 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. That's correct. 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. This part will actually still be here but with a paired down {
ilpAddress: IlpAddress
sharedSecret: Buffer
} So internally we still have some concept of connections but they are basically just the stream credentials. I could probably see a case for putting this somewhere in EDIT: we have since decided to change this to rename this to |
||
} | ||
|
||
export type CreateBody = { | ||
walletAddress: string | ||
expiresAt?: string | ||
incomingAmount?: AmountJSON | ||
metadata?: Record<string, unknown> | ||
|
@@ -146,10 +147,14 @@ async function createIncomingPayment( | |
) | ||
} | ||
|
||
if (!incomingPaymentOrError.walletAddress) { | ||
ctx.throw(404) | ||
} | ||
|
||
ctx.status = 201 | ||
const connection = deps.connectionService.get(incomingPaymentOrError) | ||
ctx.body = incomingPaymentToBody( | ||
ctx.walletAddress, | ||
incomingPaymentOrError.walletAddress, | ||
incomingPaymentOrError, | ||
connection | ||
) | ||
|
@@ -174,7 +179,12 @@ async function completeIncomingPayment( | |
errorToMessage[incomingPaymentOrError] | ||
) | ||
} | ||
ctx.body = incomingPaymentToBody(ctx.walletAddress, incomingPaymentOrError) | ||
|
||
if (!incomingPaymentOrError.walletAddress) { | ||
ctx.throw(404) | ||
} | ||
|
||
ctx.body = incomingPaymentToBody(incomingPaymentOrError.walletAddress, incomingPaymentOrError) | ||
} | ||
|
||
async function listIncomingPayments( | ||
|
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.
Fixing some typos in the migration