feat: session key support and Safe multisig tooling#416
Merged
Conversation
Add session key authentication for delegated signing from a Safe multisig wallet. When SESSION_KEY_PRIVATE_KEY is set, DealBot uses scoped session key permissions instead of direct wallet signing. - Add SESSION_KEY_PRIVATE_KEY env var (mutually exclusive with WALLET_PRIVATE_KEY) - Session key mode in both deal service and wallet SDK Synapse creation - Read-only account readiness check via synapse-core getUploadCosts in session key mode - Scripts: create-session-key-safe.mjs (session key registration calldata), fund-safe.mjs (USDFC deposit + FWSS operator approval calldata) - Runbook: docs/runbooks/wallet-and-session-keys.md - @filoz/synapse-core added as dev dependency for scripts and readiness check
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for operating DealBot using a Safe multisig as the root wallet while delegating day-to-day signing to a scoped, expiring session key. This includes backend wiring for session key auth, operational runbooks, and helper scripts for Safe transaction calldata.
Changes:
- Add
SESSION_KEY_PRIVATE_KEYconfiguration and session-key-mode Synapse initialization in backend services. - Add readiness/allowance handling for session-key mode plus related test updates.
- Add operational runbook + Safe calldata generation scripts for session key registration and funding/approvals.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
apps/backend/src/config/app.config.ts |
Adds SESSION_KEY_PRIVATE_KEY to config + updates validation/loading logic. |
apps/backend/src/deal/deal.service.ts |
Creates Synapse instance using session key when configured (async init). |
apps/backend/src/wallet-sdk/wallet-sdk.service.ts |
Initializes Synapse in session-key mode and changes allowance behavior accordingly. |
apps/backend/src/wallet-sdk/wallet-sdk.service.spec.ts |
Adds config-validation tests and basic session/direct allowance-path tests. |
apps/backend/scripts/create-session-key-safe.mjs |
Generates Safe calldata for registering a session key on-chain. |
apps/backend/scripts/fund-safe.mjs |
Generates Safe batch calldata for USDFC deposit and FWSS operator approvals. |
docs/runbooks/wallet-and-session-keys.md |
New runbook documenting Safe + session key lifecycle and funding flows. |
docs/environment-variables.md |
Documents SESSION_KEY_PRIVATE_KEY and updates wallet key guidance. |
docs/production-operations.md |
Links to the new wallet/session key runbook. |
apps/backend/package.json |
Adds @filoz/synapse-core (currently as a dev dependency). |
pnpm-lock.yaml |
Lockfile update for @filoz/synapse-core. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
apps/backend/src/config/app.config.ts:114
IBlockchainConfig.walletPrivateKeyis typed as required, but config validation now makesWALLET_PRIVATE_KEYoptional (session key mode). This can leakundefined/"" into runtime code paths that still assume a real private key. Suggest makingwalletPrivateKeyoptional in the interface and only constructing an account when it’s actually present/selected by validation.
export interface IBlockchainConfig {
network: Network;
rpcUrl?: string;
sessionKeyPrivateKey?: `0x${string}`;
walletAddress: string;
walletPrivateKey: `0x${string}`;
checkDatasetCreationFees: boolean;
useOnlyApprovedProviders: boolean;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rjan90
approved these changes
Apr 1, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add session key authentication for delegated signing from a Safe multisig wallet. When SESSION_KEY_PRIVATE_KEY is set, DealBot uses scoped session key permissions instead of direct wallet signing.