Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@terwey
Copy link
Collaborator

@terwey terwey commented Nov 9, 2025

No description provided.

claude and others added 9 commits November 9, 2025 17:36
Remove legacy venue parsing code from vault types as per multi-venue spec.
This includes:
- Legacy wireData fields (LegacyWallet, LegacyPrivateKey, etc.)
- legacyVenue and legacyVenueWithID structs
- decodeLegacyVenues() function
- Legacy parsing logic in decodeVenues()

The vault now only supports the modern multi-venue payload format.

Co-authored-by: Claude <[email protected]>
Add new endpoint to allow users to update the encrypted vault payload
after initial setup. This enables adding, editing, and removing venue
credentials without requiring a full vault re-initialization.

Changes:
- Add PUT /vault/payload to OpenAPI spec
- Implement UpdateVaultPayload handler with server-side validation
- Require both encrypted and decrypted payloads for validation
- Validate vault must be unsealed and session must be active
- Validate decrypted payload structure and venue configuration
- Use existing UpsertVaultPayload storage method (atomic transaction)
- Sync venue metadata to storage after successful update

The endpoint validates:
- Session authentication and vault unsealed state
- Encrypted payload structure (version, ciphertext, nonce)
- Decrypted payload contents using vault.Data.Validate()
- At least one primary venue exists
- No duplicate venue IDs
- Valid wallet addresses (40 hex chars)
- Valid private keys (64 hex chars)

After update, the vault remains unsealed but new configuration
is not active until seal/re-unseal cycle.

Co-authored-by: Claude <[email protected]>
The generated UpdateVaultPayload200JSONResponse has Message as *string,
but the handler was passing a string literal. Fixed to use a pointer.

Also add comprehensive test coverage for UpdateVaultPayload endpoint
covering all scenarios from the spec:
- Success case with valid payload
- Missing/invalid session (401)
- Vault sealed (403)
- No primary venue (400)
- Multiple primary venues (400)
- Duplicate venue IDs (400)
- Invalid wallet address (400)
- Invalid private key (400)
- Database errors (500)

Co-authored-by: Claude <[email protected]>
Fix test failures:
- Use VenueId field instead of ID in VenueRecord
- Pass vault.StateSealed to NewController (signature changed)

Co-authored-by: Claude <[email protected]>
Fix all UpdateVaultPayload tests to properly inject HTTP request
into context. The requireSession() function needs the HTTP request
in the context to work properly, even in debug mode.

Changes:
- Add net/http and net/http/httptest imports
- Create httptest.NewRequest for each test
- Add request to context using httpRequestContextKey
- Pass context with request to handler

Co-authored-by: Claude <[email protected]>
…hanging-functionality

test: fix vault payload update tests
@terwey terwey marked this pull request as ready for review November 9, 2025 18:52
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

d.THREECOMMASAPIKEY = payload.ThreeCommasAPIKey
d.THREECOMMASPRIVATEKEY = payload.ThreeCommasPrivate
d.Venues = venues
return nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve legacy vault payload decoding

The new Data.UnmarshalJSON now only parses venues and no longer calls the legacy conversion logic for HYPERLIQUID_* fields. Any existing ciphertext bundles saved before the multi‑venue schema (which store a single venue in those legacy keys) will now decode with an empty venue list. When the controller later unseals the vault, ensurePrimaryVenuePresent will fail because no primary venue exists, preventing users from logging in after upgrading. Unless all deployments have migrated their stored payloads, this silently drops backwards compatibility and will seal the vault permanently for affected users.

Useful? React with 👍 / 👎.

@terwey terwey merged commit f7a18ea into codex/investigate-multi-wallet-support-for-hyperliquid Nov 9, 2025
2 of 3 checks passed
@terwey terwey deleted the claude/vault-payload-update-endpoint-011CUxiES5RUW3tL4bb1Awsm branch November 9, 2025 18:57
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.

4 participants