✨ server: support multi-chain account creation in activity webhook#965
✨ server: support multi-chain account creation in activity webhook#965cruzdanilo merged 1 commit intomainfrom
Conversation
🦋 Changeset detectedLatest commit: e76f034 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 48 minutes and 32 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
WalkthroughAdds multi-chain account-creation to the activity webhook: runtime network resolution via a NETWORKS registry, chain-specific Alchemy RPC and wallet clients with tracing, keeper extender generification and DI, trace client extraction, and corresponding test updates for event-network flows. Changes
Sequence Diagram(s)sequenceDiagram
participant Webhook as Activity Webhook
participant Validator as Network Validator
participant NETWORKS as NETWORKS Map
participant Alchemy as Alchemy RPC Client
participant Wallet as Wallet Client
participant Keeper as Keeper/Extender
participant Sentry as Sentry/Tracing
Webhook->>Validator: receive payload, validate `event.network`
Validator->>NETWORKS: lookup chain by network string
NETWORKS-->>Validator: return Chain or error
Validator-->>Webhook: resolved chain
alt chain == configured chain
Webhook->>Alchemy: create public & trace clients (.extend(trace))
Alchemy->>Alchemy: getCode / trace calls
Webhook->>Keeper: extender(..., { publicClient, traceClient })
Webhook->>Wallet: createWalletClient(...).extend(...).exaSend(createAccount, fees: undefined)
Wallet-->>Webhook: exaSend result
Webhook->>Sentry: set context and capture requests
Webhook->>Webhook: market lookup / poke / auto-credit
else chain != configured chain
Webhook->>Wallet: createWalletClient(...).extend(...).exaSend(createAccount, fees: "auto")
Wallet-->>Webhook: exaSend result
Webhook->>Sentry: mark span OK and return (skip poke/auto-credit)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❌ 1 Tests Failed:
View the full list of 1 ❄️ flaky test(s)
To view more test analytics, go to the Prevent Tests Dashboard |
079754c to
4e162a5
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
server/hooks/activity.ts (1)
162-174: 🧹 Nitpick | 🔵 TrivialHoist
transport/clientout of the per-account loop.Both only depend on
chainwhich is fixed per payload, yet they're rebuilt for every account inpokes(including a freshonFetchRequestclosure and a new traced public client). For payloads with multiple recipients (see thepokes multiple accountstest) this is wasted work.♻️ Proposed fix
const { "sentry-trace": sentryTrace, baggage } = getTraceData(); + const transport = http(`${chain.rpcUrls.alchemy.http[0]}/${alchemyAPIKey}`, { + async onFetchRequest(request) { + captureRequests([v.parse(Request, await request.json())]); + }, + }); + const client = createPublicClient({ chain, transport, rpcSchema: rpcSchema<Tracer>() }).extend(trace); Promise.allSettled( [...pokes].map(([account, { publicKey, factory, source, assets }]) => continueTrace({ sentryTrace, baggage }, () => withScope((scope) => startSpan( { name: "account activity", op: "exa.activity", attributes: { account }, forceTransaction: true }, async (span) => { scope.setUser({ id: account }); - const transport = http(`${chain.rpcUrls.alchemy.http[0]}/${alchemyAPIKey}`, { - async onFetchRequest(request) { - captureRequests([v.parse(Request, await request.json())]); - }, - }); - const client = createPublicClient({ chain, transport, rpcSchema: rpcSchema<Tracer>() }).extend(trace); const isDeployed = !!(await client.getCode({ address: account }));Note: the
deploys on the event network…test mocksviem.createPublicClientwithmockReturnValueOnce, which would still match (single account → single call).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6cf4e34e-3b60-4872-b1a9-aa72d5decf0e
📒 Files selected for processing (6)
.changeset/new-koi-curl.mdserver/hooks/activity.tsserver/test/hooks/activity.test.tsserver/utils/alchemy.tsserver/utils/keeper.tsserver/utils/traceClient.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e76f03477e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
closes #960
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Refactor