Repository navigation
Conversation
Exposes the privacy pool's ComputeAndInvoke client action, the only path where the pool derives identity_key inside the proof and passes it to a contract. Mirrors ComputeAndInvokeInput. Calldata arrays reuse STRK20_CALLDATA_ITEM so dapps can reference open note IDs they cannot know when writing the request.
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.
Summary
Adds
STRK20_COMPUTE_AND_INVOKE_ACTION, which exposes the privacy pool'sComputeAndInvokeclient action through the Wallet API.Follow-up to starknet-io/types-js#77. @PhilippeR26 confirmed there that
STRK20_ACTIONin types-js mirrors this spec, so the action has to land here first.Why
ComputeAndInvokeis the only path where the pool derivesidentity_keyinside the proof and passes it to a contract. It's live in the deployed pool (ClientAction::ComputeAndInvoke) and has been supported by the SDK since starkware-libs/starknet-privacy#853, butSTRK20_ACTIONhas no variant for it, so no wallet-based dapp can reach it.invokecan't stand in for it. A contract called throughinvokeonly sees calldata the dapp chose, so any identity it receives is whatever the dapp wrote.Shape
Mirrors
ComputeAndInvokeInputinpackages/privacy/src/actions.cairo:contract_addresscontract, as ininvokecompute_additional_datacompute_additional_datainvoke_additional_datainvoke_additional_dataField names are snake_case to match this file (
dapp_name,collect_policy) and the pool struct. The issue proposed camelCase, and types-js will follow whatever lands here. Both arrays are optional and default to empty, which matches the pool (empty spans are accepted) and the SDK'sComputeAndInvokeDetails.The schema description records the pool behaviour a dapp author needs. Each point is checked against
main:privacy_computereceives[identity_key, ...compute_additional_data]and must return a non-empty result (EMPTY_COMPUTE_RESULT)privacy_invoke_with_computationreceives[...compute_result, ...invoke_additional_data]_apply_invoke_and_depositspath asinvoke, so the existing open-note fill rule applies unchangedinvokeorcompute_and_invokeper transaction (assert_and_advance_phase)Placeholders
The open question on the issue was whether the two arrays should accept
${poolAddress}and${openNoteIds[N]}. This PR says yes, by reusingSTRK20_CALLDATA_ITEM.invoke_additional_dataneeds${openNoteIds[N]}in practice. A contract that returns capital to the user has to name the open note it deposits into, and the dapp can't know that ID when it writes the request. We hit this directly: Limen's anonymizer takes the challenge id as its onlycompute_additional_dataitem, snapshots its balance inprivacy_compute, and takes the return note's ID as its onlyinvoke_additional_dataitem, returning anOpenNoteDepositfor it. Three clearances on mainnet do exactly that:0x6e597fbe…0x6f155afb…0x2277d769…Through the SDK the note ID comes from the call builder. Through the Wallet API, a placeholder is the only way to express it.
The SDK already hands the compute-and-invoke builder exactly these two values. Its callback receives
InvokeCalldataBuilderArgs { openNotes, withdrawals, poolAddress }, the same argsinvokegets.Both values are known before proving. Open note IDs are fixed when the actions are assembled, and
privacy_computeruns later, during proof generation, so substitution works forcompute_additional_dataas well. One calldata item type across all three arrays keeps the wallet's substitution logic in one place.identity_keyandcompute_resultneed no placeholder. The pool prepends both, and the dapp can't supply either.Open questions
shadow_account_invokeas an invoke-phase action, it's also mutually exclusive withcompute_and_invoke. I left that out of the description because I don't know how the wallet builds it.wallet_strk20InvokeTransactionand prepare descriptions refer to "open notes filled by invoke actions". I left them alone, as feat(wallet-api): add STRK20 sub-account support #400 did, since the new action's description states the rule itself. Happy to broaden that wording if you'd rather.Checks
npm run format_checkandnpm run check_component_uniquenesspassnode validate.js wallet-api/wallet_rpc.jsonoutput is identical tomasterSTRK20_ACTIONwith ajv. Accepted: Limen's mainnet request shape (a literal challenge id plus${openNoteIds[0]}), a request with no data arrays,${poolAddress}in compute data, existinginvokepayloads. Rejected: a missingcontract, an unknown placeholder. With the newoneOfentry removed, the compute-and-invoke payload is rejected, so the test isn't passing vacuously.