feat(wallets): Turnkey wallet provider (TS 0.5.1 / Py 0.4.3) - #72
feat(wallets): Turnkey wallet provider (TS 0.5.1 / Py 0.4.3)#72jardenx wants to merge 8 commits into
Conversation
Pure signer over Turnkey's hosted API (keys in AWS Nitro enclaves): three sign.* overrides + CALLS_ARBITRARY/PAYMASTER_SPONSOR, lazy optional-peer loading (@turnkey/sdk-server + @turnkey/viem), strictDefault SigningPolicy enforced before every billable call, explicit EIP712Domain injection (0.14.x stripping trap), expectedChainId fail-closed pin.
Config kind dispatch gains a turnkey branch: TurnkeyWalletProvider.fromEnv pinned to the network's chain id, optional WALLET_ADDRESS anchor checked fail-closed (WalletIdentityMismatch). WALLET_PASSWORD stays EVM-only.
publicApi asserts the Tier-1/Tier-2 turnkey surface; turnkeyTypeCompat pins the structural mirrors against @turnkey/sdk-server@8.1.0 and @turnkey/viem@0.14.34 at typecheck time.
…ity client Turnkey ships no Python SDK, so this adds the thin slice the provider needs: P-256 X-Stamp request stamping (cryptography, new optional extra bnbagent[turnkey]), a minimal SIGN_RAW_PAYLOAD_V2/SIGN_TRANSACTION_V2 activity client over requests, and a pure-signer provider (191 blind digest, 712 full-document payload with EIP712Domain always included, legacy+1559 unsigned RLP). Registered as factory kind 'turnkey'; conformance matrix extended; fake in-process enclave (eth_account) keeps CI offline.
… 0.5.0 Env-gated live E2Es (TS 5 / Py 4 billed signatures, serial >=1.1s, chain-id assert before anything billable), wallet-matrix rows in the three READMEs with the root-key and per-signature-billing warnings.
Pull Request ReviewThis PR adds Turnkey remote-enclave wallet providers to the Python and TypeScript SDKs, including EIP-191, EIP-712, legacy, and EIP-1559 signing, environment-based configuration, ERC-8183 integration, and optional dependencies. It also adds lazy SDK loading, P-256 request stamping for Python, EIP-712 domain handling, extensive mocked tests, live E2E examples, documentation, and package version bumps. Sensitive ContentPrivate Key / Seed Phrase / Mnemonic / Secret Material:
Security IssuesNo serious security issues detected. Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits. |
Pull Request ReviewThis PR adds Turnkey remote-enclave wallet providers to the Python and TypeScript SDKs, including message, transaction, and EIP-712 signing, wallet factory/config integration, lazy optional dependencies, chain-ID pinning, and signing-policy enforcement. It also adds EIP-712 domain-injection safeguards, extensive mocked and live E2E coverage, documentation, dependency updates, and version bumps to Python 0.4.3 and TypeScript 0.5.1. Sensitive ContentNo sensitive content detected. Security IssuesNo serious security issues detected. Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits. |
B402 now verifies ERC-1271 session signatures on its permit2 rails (field-verified against CMC on BSC mainnet, 2026-08-18: verify + settle end-to-end). Align AltanaX402Payer with the b402 merchant wire: - pass the challenge's top-level x402Version and resource into signX402Payment (merchants reject envelopes missing either; Altana SDK only carries them into the envelope when the requirement includes them) - send the payment envelope under both X-PAYMENT and PAYMENT-SIGNATURE (part of the b402 merchant population reads only the latter) - normalizeX402PaymentHeader: JSON-level back-fill for pre-0.7.0 Altana envelopes (resource/x402Version injection, permit2Authorization spelling alongside the legacy permit+from dialect); strict no-op on compliant envelopes, signature bytes never touched - expectedPayTo recipient pin (parity with TwakX402Payer; studio already passes it and it was silently ignored) - raise the @altananetwork/sdk peer ceiling to <0.8.0 (0.7.x fixed the envelope gaps upstream); devDep to 0.7.1 eip3009 stays EOA-only at the facilitator (probed 2026-08-18: invalid_exact_evm_payload_signature), so route ranking keeps permit2 first — unchanged.
Pull Request ReviewThis PR adds Turnkey remote-enclave wallet providers for both Python and TypeScript, including environment-based configuration, EIP-191/EIP-712 and transaction signing, chain-ID pinning, optional dependencies, documentation, E2E scripts, and extensive mocked tests. It also bumps the Python and TypeScript package versions and improves Altana x402/B402 compatibility with recipient pinning, payment-header normalization, and dual payment headers. Sensitive ContentPrivate Key / Seed Phrase / Mnemonic / Secret Material:
Security IssuesNo serious security issues detected. Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits. |
Summary
Adds Turnkey as a wallet provider (TS + Python): remote enclave signer over Turnkey's API —
signMessage/signTransaction/signTypedData, capabilities auto-derived, defaultLocalExecutor, x402 support viaX402Signerfor free. Configured via env (TURNKEY_API_PUBLIC_KEY/TURNKEY_API_PRIVATE_KEY/TURNKEY_ORG_ID/TURNKEY_SIGN_WITH, optionalTURNKEY_API_BASE_URL) and wired into ERC-8183 config viaWALLET_KIND=turnkey.Based on the 2026-07 POC (
poc-space/turnkey/): 11 probes PASS, ERC-8004 on-chain registration, 8183 quote, x402 buyer/seller loops, non-root policy enforcement all verified live.TypeScript (
@bnbagent/sdk0.5.0 → 0.5.1)src/wallets/turnkey/—TurnkeyWalletProviderwith lazy-loaded optional peers@turnkey/sdk-server+@turnkey/viem(altana-stylesdkLoaderseam, published.d.tsstays free of@turnkey/*references).@turnkey/viem≤0.14.34 silently serializes the domain as{}whenEIP712Domainisn't explicit intypes(signature succeeds, gets billed, binds an empty domain). We strip on input, injectgetTypesForEIP712Domain({domain})before handing to the vendor account, and computemessageHashfrom the un-injected form. Injection is idempotent if upstream fixes it.expectedChainIdfail-closed (rejected before any billable call); legacy + EIP-1559 both supported via viem type inference; strictSigningPolicyenforced before signing.erc8183/config.ts:WALLET_KIND=turnkeybranch with optionalwalletAddresschecksum reconciliation.Python (
bnbagent0.4.2 → 0.4.3)bnbagent/wallets/turnkey/— self-built P-256 stamper + minimal activity client (onlysign_raw_payload/sign_transaction; Turnkey ships no full Python SDK).cryptographyas optional extrabnbagent[turnkey].AgentConfigwallet_kind="turnkey"support, aligned with TSerc8183/config.ts.Tests / E2E
@turnkey/*devDeps (upstream drift = typecheck failure).TURNKEY_E2E=1 pnpm -C typescript e2e:turnkey(5 sigs) +python examples/turnkey_e2e.py(4 sigs). Both ran PASS on BSC testnet (9 billable sigs total).Verification
pnpm -C typescript checkgreen (1151 tests + 1 skip;dist/**/*.d.tshas no@turnkeyreferences)cd python && uv run pytestgreen (820 tests)Release notes
@bnbagent/sdk@0.5.1+ PyPIbnbagent==0.4.3→ studiofeat/turnkey-walletPR (studio pins the published version; its lockfile can only regenerate after 0.5.1 is on npm).ethSendTransactionmanaged broadcast never used (paywall); root API keys bypass all server-side Turnkey policies — production posture (non-root user + explicit ALLOW policies) called out in docs.