Skip to content

Commit

Permalink
Merge pull request #9 from janndriessen/feat/add-subscribe-to-payment
Browse files Browse the repository at this point in the history
feat: add subscribe to payment
  • Loading branch information
janndriessen authored Jan 18, 2024
2 parents 76a7ff0 + 6f30fd1 commit e60a45d
Show file tree
Hide file tree
Showing 7 changed files with 361 additions and 23 deletions.
2 changes: 1 addition & 1 deletion payment_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "eth-sdk && graphclient build && next dev",
"dev": "eth-sdk && graphclient build && next dev -p 4000",
"build": "eth-sdk && graphclient build && next build",
"start": "next start",
"lint": "next lint",
Expand Down
2 changes: 2 additions & 0 deletions shop/.env.default
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
ALCHEMY_ID=
NEXT_PUBLIC_PUSHER_APP_CLUSTER=
NEXT_PUBLIC_PUSHER_APP_KEY=
WALLETCONNECT_PROJECT_ID=
210 changes: 210 additions & 0 deletions shop/package-lock.json

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

2 changes: 2 additions & 0 deletions shop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@gelatonetwork/relay-sdk": "^5.5.5",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
Expand All @@ -27,6 +28,7 @@
"framer-motion": "^10.18.0",
"lucide-react": "^0.309.0",
"next": "14.0.4",
"pusher-js": "^8.4.0-rc2",
"qrcode": "^1.5.3",
"react": "^18",
"react-day-picker": "^8.10.0",
Expand Down
27 changes: 27 additions & 0 deletions shop/src/app/payment/components/payment-popup/gelato.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
GelatoRelay,
TransactionStatusResponse,
} from '@gelatonetwork/relay-sdk'

export async function awaitGelatoTask(
taskId: string,
): Promise<TransactionStatusResponse | null> {
const relay = new GelatoRelay()
return await new Promise((resolve, reject) => {
const maxRetry = 100
let retryNum = 0
const interval = setInterval(async () => {
retryNum++
if (retryNum > maxRetry) {
clearInterval(interval)
reject('Max retry reached')
}
const taskStatus = await relay.getTaskStatus(taskId)
console.log('Gelato task status:', taskStatus)
if (taskStatus?.taskState == 'ExecSuccess') {
clearInterval(interval)
resolve(taskStatus)
}
}, 500)
})
}
Loading

0 comments on commit e60a45d

Please sign in to comment.