-
Notifications
You must be signed in to change notification settings - Fork 68
feat: add codex wallet #1206
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
Open
w84april
wants to merge
52
commits into
main
Choose a base branch
from
feat/impersonate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: add codex wallet #1206
Changes from 51 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
37782f7
Fix simple return accounting and finalize portfolio return charts (#1…
rossgalloway 80ef04c
fix: show pending transaction function names in overlay (#1179)
rossgalloway f753645
fix: refresh portfolio balances without hard reload (#1187)
rossgalloway 70b5bf1
Devex: improve tenderly and dev tools (#1182)
rossgalloway 10a23b8
feat: add codex wallet
w84april 06ddec7
Add merkle rewards filters and make them refresh (#1180)
rossgalloway 9eb7d87
bump deps
rossgalloway f0a6df9
update lockfile
rossgalloway 101ebc0
feat: add codex wallet
w84april 3296f8c
feat: add selective portfolio impersonation benchmark flow
rossgalloway 0514966
Prep for yvBTC (#1185)
rossgalloway 9414a34
update gitignore
rossgalloway 566788f
Fix/pnl misc 2 (#1203)
w84april b5515a0
add vaults link to header
rossgalloway 24011b1
fix: suggested vault yvUSD suggestions
rossgalloway 6c9aff3
fix: handle Safe app Katana approval and improve safe transaction ove…
rossgalloway e41e852
docs: investigate tenderly rpc mismatch
rossgalloway 060c1e2
feat: use enso base for tenderly balances
rossgalloway a39a1fb
Lint
rossgalloway b6ea152
Lint
rossgalloway 3e8a100
Lint
rossgalloway 43d9f13
Lint
rossgalloway c7147a0
feat: add codex wallet
w84april 2308abe
feat: enable codex wallet signing
rossgalloway 9dbcbf2
Lint
rossgalloway 64953da
Lint
rossgalloway e26551b
Lint
rossgalloway 43e51e2
Lint
rossgalloway e497005
Merge branch 'feat/portfolio-impersonation-perf-selective' into codex…
rossgalloway 53c67aa
Merge branch 'codex/investigate-tenderly-rpc-mismatch' into codex/rec…
rossgalloway 9223d97
Fix codex wallet transaction readiness
rossgalloway e20cd56
Sync Tenderly status test fixture
rossgalloway ef5d61c
Isolate Tenderly vault balance overrides
rossgalloway 2bbd505
fix: tests
w84april bfd857a
chore: remove pg
w84april a705931
Merge branch 'main' into release/26-04-17
w84april 564c960
chore: upd docs & remove logging
w84april c19510c
Merge branch 'release/26-04-17' into codex/reconcile-vnet-portfolio-i…
rossgalloway 36c0653
delete plan docs
rossgalloway a2cbb1e
update test
rossgalloway eebfb59
Fix Tenderly preview controls
rossgalloway 500eb65
fix: address Tenderly admin mutations are reachable from browser origins
rossgalloway 9c33ca1
review: harden fix for Tenderly admin mutations are reachable from br…
rossgalloway 029d090
fix: address Tenderly execution chain IDs can shadow canonical chain IDs
rossgalloway 9bae073
fix: address Iframe and embedded wallet modes have weak session/origi…
rossgalloway 1266f76
review: harden fix for Iframe and embedded wallet modes have weak ses…
rossgalloway 553339f
Merge branch 'codex/fix-yearn-fi-group-tenderly-local-admin-boundary'…
rossgalloway 9fc5249
Merge branch 'codex/reconcile-vnet-portfolio-impersonation' into feat…
rossgalloway 29c1dc3
fix test
rossgalloway ca712ec
Merge remote-tracking branch 'origin/main' into feat/impersonate
rossgalloway 1e3cccc
cleanup
rossgalloway f24d7fa
Fix admin access review issues
rossgalloway File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import type { VercelRequest, VercelResponse } from '@vercel/node' | ||
| import { invalidateVaults, type VaultIdentifier } from '../lib/holdings/services/cache' | ||
| import { isHoldingsStorageEnabled } from '../lib/holdings/storage/redis' | ||
|
|
||
| function isValidAddress(address: string): boolean { | ||
| return /^0x[a-fA-F0-9]{40}$/.test(address) | ||
| } | ||
|
|
||
| interface InvalidateRequestBody { | ||
| vaults: Array<{ address: string; chainId: number }> | ||
| } | ||
|
|
||
| function validateBody(body: unknown): body is InvalidateRequestBody { | ||
| if (!body || typeof body !== 'object') return false | ||
| const b = body as Record<string, unknown> | ||
| if (!Array.isArray(b.vaults)) return false | ||
| if (b.vaults.length === 0) return false | ||
|
|
||
| for (const vault of b.vaults) { | ||
| if (!vault || typeof vault !== 'object') return false | ||
| const v = vault as Record<string, unknown> | ||
| if (typeof v.address !== 'string' || !isValidAddress(v.address)) return false | ||
| if (typeof v.chainId !== 'number' || !Number.isInteger(v.chainId)) return false | ||
| } | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| export default async function handler(req: VercelRequest, res: VercelResponse) { | ||
| res.setHeader('Access-Control-Allow-Origin', '*') | ||
| res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS') | ||
| res.setHeader('Access-Control-Allow-Headers', 'Content-Type, x-admin-secret') | ||
|
|
||
| if (req.method === 'OPTIONS') { | ||
| return res.status(204).end() | ||
| } | ||
|
|
||
| if (req.method !== 'POST') { | ||
| return res.status(405).json({ error: 'Method not allowed' }) | ||
| } | ||
|
|
||
| // Check admin secret | ||
| const adminSecret = process.env.ADMIN_SECRET | ||
| if (!adminSecret) { | ||
| return res.status(503).json({ error: 'Admin endpoint not configured' }) | ||
| } | ||
|
|
||
| const providedSecret = req.headers['x-admin-secret'] | ||
| if (providedSecret !== adminSecret) { | ||
| return res.status(401).json({ error: 'Unauthorized' }) | ||
| } | ||
|
|
||
| // Check Redis storage is enabled | ||
| if (!isHoldingsStorageEnabled()) { | ||
| return res.status(503).json({ error: 'Caching not enabled (Redis storage not configured)' }) | ||
| } | ||
|
|
||
| // Validate request body | ||
| const body = req.body | ||
| if (!validateBody(body)) { | ||
| return res.status(400).json({ | ||
| error: 'Invalid request body', | ||
| expected: { | ||
| vaults: [{ address: '0x...', chainId: 1 }] | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| try { | ||
| const vaults: VaultIdentifier[] = body.vaults.map((v) => ({ | ||
| address: v.address, | ||
| chainId: v.chainId | ||
| })) | ||
|
|
||
| const invalidatedCount = await invalidateVaults(vaults) | ||
| const timestamp = new Date().toISOString() | ||
|
|
||
| return res.status(200).json({ | ||
| success: true, | ||
| invalidated: invalidatedCount, | ||
| vaults: vaults.map((v) => `${v.chainId}:${v.address.toLowerCase()}`), | ||
| timestamp | ||
| }) | ||
| } catch (error) { | ||
| console.error('[Admin] Invalidate cache error:', error) | ||
| return res.status(500).json({ error: 'Failed to invalidate cache' }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.