-
Notifications
You must be signed in to change notification settings - Fork 1
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: add subscribe to payment #9
Changes from all commits
e6301e6
aea7e54
218791e
d66d857
42ff654
f7e5e24
a73cf8c
6f30fd1
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
ALCHEMY_ID= | ||
NEXT_PUBLIC_PUSHER_APP_CLUSTER= | ||
NEXT_PUBLIC_PUSHER_APP_KEY= | ||
WALLETCONNECT_PROJECT_ID= |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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') { | ||
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. There are a few steps in between, that you will see in the log statements. 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. For example you could make this function accept a callback function as a parameter that gets called on every update, that can then be used in react to update the state / progress. |
||
clearInterval(interval) | ||
resolve(taskStatus) | ||
} | ||
}, 500) | ||
}) | ||
} |
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.
This is probably going to be used both in the app as well as the shop so at some point we might want to move this into a shared sdk, but not necessary for the first version.