-
Notifications
You must be signed in to change notification settings - Fork 3
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
first pass at syndicate integration #549
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This PR is being deployed to Railway 🚅 |
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.
forgot how involved our txn relaying logic is. involved as in across many files and helpres + sections of the codebase. put in some comments/ideas for how to clean things up, but wonder if its worth a larger overhaul. id say ok for now but got me thinking
apps/delta/ponder.config.ts
Outdated
@@ -1,6 +1,6 @@ | |||
import { createConfig } from '@ponder/core' | |||
import { addresses, idRegistryABI, postGatewayABI } from 'scrypt' | |||
import { http } from 'viem' | |||
import { Hex, http } from 'viem' |
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.
can we get rid of this added Hex? not seeing any other changes to Delta so should be unncessary? just in terms of keeping the commit trail on delta clean
apps/site/app/api/post/route.ts
Outdated
|
||
const tx = await postGateway.post(post) | ||
if (!projectId) { |
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.
lets move as much of this as possible into the syndicate config. did a lil gist brainstorming here https://gist.github.com/0xTranqui/3a00d776f4065db0c77106685f941d24
apps/site/app/api/post/route.ts
Outdated
}) | ||
|
||
console.log({ successfulTxHash }) |
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.
we should prob remove most/all of these console logs before merging? what u think
apps/site/lib/api.ts
Outdated
`https://api.syndicate.io/wallet/project/${projectID}/request/${txID}`, | ||
{ | ||
method: 'GET', | ||
headers: { Authorization: `Bearer ${process.env.SYNDICATE_API_KEY}` }, |
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.
better dx to accept api key as a prop? instead of loading in from env here? like we do for w3supload down below?
apps/site/lib/api.ts
Outdated
let transactionHash = null | ||
|
||
while (!transactionHash) { | ||
await new Promise((resolve) => setTimeout(resolve, every)) |
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 feel like the delay is better suited for coming at the end of the loop, and only if its necssary (ie there will be another loop cuz was uncessful) like we do in this similar function that we use to wait for appearnace in ponder db? https://github.com/1ifeworld/river/blob/main/apps/site/lib/getTxnInclusion.ts
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.
think this is close, but overall would be better suited if we make a beefier syndicate config that exports all of the function definitions in one const. idea for it here https://gist.github.com/0xTranqui/7e9f19aee739395215984f138207c9ee
its like were making our own custom "viem config extension -- esque" syndicate client, tailored specifically for the actions we want to make in river. and then super easy to drop in wherever we need it to be
apps/site/config/syndicateClient.ts
Outdated
) | ||
} | ||
|
||
export const postBatchObject = (postsArray: PostBatchFunction) => ({ |
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 this function should be called "generatePostBatchTxnInput" or something like that. and read more like a function. same thing with the "postObject" export below
apps/site/app/api/post/route.ts
Outdated
import type { NextRequest } from 'next/server' | ||
import { addresses, postGatewayABI } from 'scrypt' | ||
import type { Hex } from 'viem' | ||
import { syndicate, postObject, projectId } from '@/config/syndicateClient' |
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.
will also leave this comment in the gneral review, but we should make this all be accessible just via one "syndicateClient" import.
peep here for gist idea of what this could look like: https://gist.github.com/0xTranqui/7e9f19aee739395215984f138207c9ee
apps/site/app/api/post/route.ts
Outdated
|
||
const tx = await postGateway.post(post) | ||
const postTxRequest = postObject(post) |
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.
if postTxnRquest is only used once, can we avoid this const and just put the postObject
in the sendTransaction inputs?
apps/site/app/api/postBatch/route.ts
Outdated
postGatewayABI, | ||
signer as unknown as ethers.Signer, | ||
) | ||
if (!authToken || typeof authToken !== 'string') { |
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.
whats the reason we have auth token in here? was it in our earlier routes? is there a reson its in postBatch but not post?
needs testing