Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"description": "",
"dependencies": {
"@hono/zod-validator": "^0.7.6",
"@interledger/open-payments": "^7.1.3",
"@interledger/open-payments": "^7.4.0",
"@noble/ed25519": "^3.0.0",
"@paralleldrive/cuid2": "^3.3.0",
"@shared/config-storage-service": "workspace:^",
Expand Down
17 changes: 14 additions & 3 deletions api/src/utils/open-payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type OutgoingPayment,
type Quote,
type Grant,
isFinalizedGrant,
isFinalizedGrantWithAccessToken,
isPendingGrant,
createAuthenticatedClient,
} from '@interledger/open-payments'
Expand Down Expand Up @@ -168,6 +168,10 @@ export class OpenPaymentsService {
receiverWallet.authServer,
)

if (!isFinalizedGrantWithAccessToken(incomingPaymentGrant)) {
throw new Error('Expected incoming payment grant with access token')
}

// create incoming payment without incoming amount
const incomingPayment = await this.createIncomingPayment({
accessToken: incomingPaymentGrant.access_token.value,
Expand All @@ -183,6 +187,10 @@ export class OpenPaymentsService {
throw new Error('Expected non-interactive grant')
}

if (!isFinalizedGrantWithAccessToken(quoteGrant)) {
throw new Error('Expected quote grant with access token')
}

const quote = await this.createPaymentQuote({
walletAddress: walletAddress,
accessToken: quoteGrant.access_token.value,
Expand Down Expand Up @@ -235,8 +243,8 @@ export class OpenPaymentsService {
},
)

if (!isFinalizedGrant(continuation)) {
throw new Error('Expected finalized grant.')
if (!isFinalizedGrantWithAccessToken(continuation)) {
throw new Error('Expected finalized grant with access token')
}

const outgoingPayment = await this.client!.outgoingPayment.create(
Expand Down Expand Up @@ -430,6 +438,9 @@ export class OpenPaymentsService {
outgoingPaymentId: OutgoingPayment['id'],
continuationAccessToken: string,
): Promise<CheckPaymentResult> {
if (!isFinalizedGrantWithAccessToken(incomingPaymentGrant)) {
throw new Error('Expected incoming payment grant with access token')
}
let attempts = 0
await sleep(OUTGOING_PAYMENT_POLLING_INITIAL_DELAY)
while (++attempts <= OUTGOING_PAYMENT_POLLING_MAX_ATTEMPTS) {
Expand Down
2 changes: 1 addition & 1 deletion components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lit": "^3.3.2"
},
"devDependencies": {
"@interledger/open-payments": "^7.1.3",
"@interledger/open-payments": "^7.4.0",
"@shared/types": "workspace:^",
"@shared/utils": "workspace:^",
"publisher-tools-api": "workspace:^",
Expand Down
7 changes: 3 additions & 4 deletions frontend/app/utils/open-payments.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type PendingGrant,
type WalletAddress,
type AuthenticatedClient,
isFinalizedGrant,
isFinalizedGrantWithAccessToken,
isPendingGrant,
createAuthenticatedClient,
} from '@interledger/open-payments'
Expand Down Expand Up @@ -195,12 +195,11 @@ export async function isGrantValidAndAccepted(
},
)

if (!isFinalizedGrant(continuation)) {
if (!isFinalizedGrantWithAccessToken(continuation)) {
return false
}

// when continuation has access_token value it has been accepted by user
return continuation?.access_token?.value ? true : false
return !!continuation.access_token.value
}

async function createHeaders({
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"@floating-ui/react-dom": "^2.1.8",
"@interledger/open-payments": "^7.1.3",
"@interledger/open-payments": "^7.4.0",
"@noble/ed25519": "^3.0.0",
"@paralleldrive/cuid2": "^3.3.0",
"@react-router/cloudflare": "^7.11.0",
Expand Down
91 changes: 49 additions & 42 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion shared/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"private": true,
"devDependencies": {
"@interledger/open-payments": "^7.1.3",
"@interledger/open-payments": "^7.4.0",
"@shared/types": "workspace:^"
}
}
Loading