Repository navigation
feat(tempo): approve stored configurable account operations by hash alone - #5675
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: e8b64db The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9de6d64efd
ℹ️ 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".
| account: fromConfig(operation.account), | ||
| from: operation.userAddress ?? operation.account, |
There was a problem hiding this comment.
Preserve the parent sender for hash-only delegate approvals
For a stored TIP-1111 operation with userAddress, this account has the delegate's address rather than the parent sender's address. Core prepareTransactionRequest resets from to request.account.address after the preparation hook (src/actions/wallet/prepareTransactionRequest.ts:591–595), overwriting the parent address supplied below. Consequently, Account.fromBase.signTransaction sees identical accountSimulation.signer and from values and signs a normal configurable-account digest instead of the parent-bound keychain digest; Transaction.serialize likewise omits the keychain envelope. The resulting approval cannot approve the original stored operation. Use a sender account representing operation.userAddress for delegated operations while retaining operation.account as the simulation signer.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e8b64db: the sender account is now Account.fromConfig(operation.userAddress ?? operation.account), so core preparation keeps from as the parent and the owner signs the parent-bound keychain digest. Covered by 'behavior: an owner account approves a stored access key operation by hash', which failed before this change (from was the access key).
| }, | ||
| } as unknown as typeof r |
There was a problem hiding this comment.
Retain the approver in the prepared transaction request
When a caller prepares a hash-only approval with prepareTransactionRequest(client, { account: owner, hash }) and then passes the result to signTransaction, the returned request has replaced the owner account with an address-only configurable account without preserving owner. The signing action selects that returned account, and Account.fromConfig's signTransaction takes its owners.length === 0 branch and returns an unsigned transaction instead of an owner approval. Direct sendTransaction calls happen to work because they retain the original account separately, but the prepare-then-sign flow loses the signer. Preserve owner: approver in the returned request, as the existing explicit-owner branch does.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e8b64db: the hash-only branch now returns owner: approver, so prepareTransactionRequest then signTransaction returns the owner approval. Covered by 'behavior: a prepared hash approval signs as the owner account'.
|
Published pnpm add viem@pr-5675
pnpm add [email protected] |
…nt transactions (#1158) Added passkey owner inference to `accounts.viem.sendTransaction` and `sendTransactionSync` for coordinated configurable account transactions, and `Plugins.viem.OwnerRequiredError`. Raised `viem` to `^2.58.8`. ## Problem Viem's coordinated signing needs an `owner` on every call. In an app, that owner is the user's passkey, which the session's Tempo Account already holds. ## Behavior A call of the instance session's client that names no `owner`: | Call | The passkey becomes | | --- | --- | | `{ hash }` alone | `account`, so Viem 2.58.8 infers the configurable account from the stored operation (wevm/viem#5675) | | `{ account, calls }` with a configurable account that holds no local owner, such as `Account.fromConfig(address)` | `owner` | - The user's passkey that the account's configuration names signs. - If no passkey of the user is an owner, `Plugins.viem.OwnerRequiredError` throws before any ceremony or relay request. - A configurable account with a local owner stays Viem's own, also with `hash`. - Every other call is Viem's own, unchanged. A fixed session's client is unchanged. - The retry skips a call with `hash`, since the operation names another account than the session's. - Coordination needs the plugin's `relay`. ## API changes ```ts const pending = await accounts.viem.sendTransactionSync({ account: Account.fromConfig(multisig), calls, }) await accounts.viem.sendTransactionSync({ hash: pending.transactionHash }) ``` The user's passkey approves both calls. ```ts error.name === 'Plugins.viem.OwnerRequiredError' ``` Thrown when no passkey of the user owns the account. ```ts import { Accounts } from 'accounts' import { viem } from 'accounts/plugins' import { Account } from 'viem/tempo' const accounts = Accounts.create({ plugins: [viem({ relay: '/api/relay' })] }) const account = Account.fromConfig({ address: 'infer', owners: [passkeyOwner, cosigner], threshold: 2, }) const pending = await accounts.viem.sendTransactionSync({ account, calls }) ``` ## How to test 1. A local Tempo node, Viem's relay with `Relay.accounts({ store })`, a WebAuthn owner, and a secp256k1 cosigner share a 2-of-2 account. 2. The passkey sends first without `owner`, and the cosigner approves by hash: `success`, `from` the multisig. 3. The cosigner sends first, and `accounts.viem.sendTransactionSync({ hash })` approves: `success`, `from` the multisig. 4. A user without a passkey owner: `Plugins.viem.OwnerRequiredError`. All three fail without this change. `src/plugins/viem.test.ts` adds two regression tests: a non-owner's one passkey throws with no ceremony and no request, and a `hash` approval of an account with a local owner reaches Viem unchanged. `src/plugins/viem.test.ts` and `src/internal/viem/Retry.test.ts` pass (87/87), with `pnpm check` and `pnpm check:types`. No end-to-end spec covers it yet, since the suite has no relay with an operation store. ## Waterfall `pnpm waterfall test/client/plugins/viem.test.ts` at the head and at the base, with `pnpm waterfall:report --base`: every action's calls and rounds are unchanged. The suite has no coordinated send. A coordinated call adds a configuration read (`eth_getTransactionByHash` for `hash`, which Viem reads again, or `account_getConfig`), and outside the session's chain an account read. --------- Co-authored-by: jxom <[email protected]>
A later owner of a coordinated configurable account can now approve a stored operation with only its hash. The operation hash commits to the account, config, and transaction, so Viem reads the operation and takes the configurable account from it.
hash, noowner, and a rootaccountapproves as that owner. That input used to throw, so existing calls keep their behavior.operation.configis rejected before it signs.Account.fromConfig(operation.account). CoreprepareTransactionRequestsetsfromfromrequest.account, so the owner cannot be the request's account.getStoredOperation, which the existing{ account, hash, owner }path also uses.I kept the owner as
accountinstead of{ hash, owner }without an account, so coresendTransactionand its types stay unchanged.For operations with
userAddress(TIP-1111 delegates), the sender is the parent andaccountSimulation.signerisoperation.account, so the owner signs the parent-bound keychain digest.Tests
src/tempo/e2e.accounts.test.tsadds hash-only approvals on config version 0 and on version 1 after a rotation (with the owner as the client's account), a hash-only approval of a configurable access key operation, a prepared hash approval signed throughsignTransaction, and a rejection for a non-owner. They fail without this change. The full file passes locally (73/73).Docs
The send guide adds "Approve by Hash Alone".