Skip to content
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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

first pass at syndicate integration #549

wants to merge 18 commits into from

Conversation

jawndiego
Copy link
Contributor

needs testing

Copy link

vercel bot commented Mar 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
river-site ✅ Ready (Inspect) Visit Preview Apr 3, 2024 2:58am
river-site-metadata ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2024 2:58am

Copy link

railway-app bot commented Mar 26, 2024

This PR is being deployed to Railway 🚅

Copy link
Contributor

@0xTranqui 0xTranqui left a 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

@@ -1,6 +1,6 @@
import { createConfig } from '@ponder/core'
import { addresses, idRegistryABI, postGatewayABI } from 'scrypt'
import { http } from 'viem'
import { Hex, http } from 'viem'
Copy link
Contributor

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


const tx = await postGateway.post(post)
if (!projectId) {
Copy link
Contributor

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

})

console.log({ successfulTxHash })
Copy link
Contributor

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

`https://api.syndicate.io/wallet/project/${projectID}/request/${txID}`,
{
method: 'GET',
headers: { Authorization: `Bearer ${process.env.SYNDICATE_API_KEY}` },
Copy link
Contributor

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?

let transactionHash = null

while (!transactionHash) {
await new Promise((resolve) => setTimeout(resolve, every))
Copy link
Contributor

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

Copy link
Contributor

@0xTranqui 0xTranqui left a 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

)
}

export const postBatchObject = (postsArray: PostBatchFunction) => ({
Copy link
Contributor

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

import type { NextRequest } from 'next/server'
import { addresses, postGatewayABI } from 'scrypt'
import type { Hex } from 'viem'
import { syndicate, postObject, projectId } from '@/config/syndicateClient'
Copy link
Contributor

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


const tx = await postGateway.post(post)
const postTxRequest = postObject(post)
Copy link
Contributor

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?

postGatewayABI,
signer as unknown as ethers.Signer,
)
if (!authToken || typeof authToken !== 'string') {
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace OZ defender with Syndicate's tx cloud
2 participants