Skip to content

feat(tempo): add Account.serialize, Account.deserialize and keyAuthorization option - #5388

Merged
jxom merged 1 commit into
mainfrom
pyramid/71619f44-574d-41fb-be7e-6f6e8f53da2a
Nov 3, 2026
Merged

jxom merged 1 commit into
mainfrom
pyramid/71619f44-574d-41fb-be7e-6f6e8f53da2a

Conversation

@jxom

@jxom jxom commented Nov 3, 2026

Copy link
Copy Markdown
Member

Adds serialization for configurable accounts (TIP-1107) and a keyAuthorization option for access key accounts to viem/tempo, so apps that store accounts or access keys (such as Tempo ID's @tempoxyz/id) stop reimplementing them.

  • Account.serialize(account) returns { address, config? } (config in RPC format, JSON-safe).
  • Account.deserialize(value, { credentials?, getFn? }) rebuilds the account without a request. A passkey among credentials signs as an owner when its public key derives an owner address. A version-zero config must derive address (Account.AddressMismatchError otherwise), and a later version keeps address.
  • keyAuthorization on fromSecp256k1/fromP256/fromWebCryptoP256/fromHeadlessWebAuthn/from with access: the account holds the signed authorization and attaches it until the chain registers the access key. No KeyAuthorizationManager is needed. It throws if the authorization is for another access key.
localStorage.setItem('account', JSON.stringify(Account.serialize(account)))
const restored = Account.deserialize(JSON.parse(localStorage.getItem('account')!), { credentials: [passkey] })

const accessKey = Account.fromWebCryptoP256(keyPair, { access: root, keyAuthorization })

Validation: tsc and pnpm test --project tempo --run src/tempo/Account.test.ts (62 tests, 7 new) pass.

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
viem Ready Ready Preview Nov 3, 2026 12:16am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5591c21

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T00:18:29.873228Z 5591c21 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jxom
jxom merged commit 141f8c0 into main Nov 3, 2026
34 of 40 checks passed
@jxom
jxom deleted the pyramid/71619f44-574d-41fb-be7e-6f6e8f53da2a branch November 3, 2026 00:15
@github-actions github-actions Bot mentioned this pull request Nov 3, 2026

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

Copy link
Copy Markdown

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.

Reviewed commit: 5591c215c7

ℹ️ 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".

Comment thread src/tempo/Account.ts
const accessKeyAddress = Address.fromPublicKey(parameters.publicKey)
if (
keyAuthorization &&
!Address.isEqual(keyAuthorization.address, accessKeyAddress)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate authorization identity before caching it

When the same P256 public key was authorized with one key type but is reconstructed with another (for example, p256 versus webAuthn), or when the authorization names a different parent account, this address-only check accepts and caches it. The transaction path requires the authorization's key type and named account to match exactly (src/tempo/internal/relay/feePayer.ts:668-690), so the account will attach an unusable authorization and its first transaction will fail; validate keyAuthorization.type and any keyAuthorization.account against parameters.keyType and parentAddress here.

Useful? React with 👍 / 👎.

Comment thread src/tempo/Account.ts
* @param account Configurable account.
* @returns Serialized account.
*/
export function serialize(account: ConfigurableAccount): Serialized {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add site docs for the new persistence APIs

A repo-wide search of site/pages and site/vocs.config.ts finds the existing Account.fromConfig page and sidebar entry, but no page or navigation entry for either new Account.serialize or Account.deserialize API. This leaves the newly exported persistence workflow undiscoverable from the public Tempo documentation; add the required account subpages and sidebar wiring.

AGENTS.md reference: AGENTS.md:L106-L107

Useful? React with 👍 / 👎.

Comment thread src/tempo/Account.ts
Comment on lines +312 to +313
| 'keyAuthorization'
| 'keyAuthorizationManager'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add type tests for the new public signatures

This commit adds public serialization types and threads keyAuthorization through inference-heavy conditional account constructors, but it does not update the existing src/tempo/Account.test-d.ts. The runtime tests cannot verify that keyAuthorization is accepted only with access, that those calls still infer AccessKeyAccount, or that the new serialized/deserialized shapes remain usable through the public entrypoint; add focused expectTypeOf and rejection cases for these signatures.

AGENTS.md reference: AGENTS.md:L72-L76

Useful? React with 👍 / 👎.

This branch was successfully deployed

1 active deployment
Preview — 5591c215 Deployed Nov 3, 2026 by vercel[bot]
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.

1 participant