You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
• Add Vitest E2E happy-path coverage for MultiToken state-mutating methods.
• Introduce MultiToken-specific deploy, commitment, and TransferSingle event helpers.
• Validate public/private balances, privacy expectations, and authwit flows via real SDK stack.
Diagram
graph TD
A["Vitest: multitoken.test.ts"] --> B["Test helpers: utils.ts"] --> C["Aztec SDK Wallet"] --> D["PXE/Node"] --> E["MultiToken contract"] --> F["Public logs"]
A -->|"assert balances"| E
B -->|"decode TransferSingle"| F
subgraph Legend
direction LR
_test["Test"] ~~~ _mod["Helper module"] ~~~ _svc["Service"]
end
Loading
High-Level Assessment
The following are alternative approaches to this PR:
1. Filter logs by event selector (or ABI metadata) instead of field-count
➕ More robust if other events with 4 fields are added later
➕ Reduces risk of false positives when decoding logs
➖ May require extra SDK plumbing if selector/tag access isn’t straightforward
➖ Slightly more code than the current “4 fields” heuristic
2. Avoid wallet internals for commitments by using public SDK return-value plumbing
➕ Less brittle than reaching into privateExecutionResult
➕ Aligns with supported API surface and reduces maintenance cost
➖ May not be currently possible without upstream SDK changes
➖ Could block tests until the SDK supports private return values cleanly
Recommendation: Current approach is reasonable for adding pragmatic E2E coverage now (and it already flags the wallet-internals escape hatch with a TODO). Consider tightening event filtering to use an event selector/tag once available to prevent future ambiguity as the contract emits more events.
• Introduces E2E tests covering deploy/view reads, mint variants (public/private/commitment), transfer variants across public/private/commitment, and burn flows. Validates privacy expectations (no public events in private-only flows), correct balance updates, and TransferSingle event decoding. Demonstrates public and private authwit flows, including additionalScopes for third-party submission.
utils.tsAdd MultiToken deploy/commitment helpers and TransferSingle log assertions+181/-0
Add MultiToken deploy/commitment helpers and TransferSingle log assertions
• Adds constants and utilities for MultiToken name/symbol encoding round-trip, contract deployment with a configurable minter/auth hook, and commitment initialization via wallet internals. Introduces MultiToken-specific public log querying and decoding for the 4-field TransferSingle event, plus an assertion helper for event sequences.
getMultiTokenTransferEvents decodes every public log with 4 emitted fields as TransferSingle, so any
other 4-field log from the same contract/tx will be mis-decoded and can make tests flaky or assert
the wrong events. The code even documents the TransferSingle selector but does not use it to
disambiguate logs before decoding.
The helper selects logs solely by emitted field count and decodes them as TransferSingle; a nearby
comment states an explicit selector but no selector-based filtering is implemented.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`getMultiTokenTransferEvents` currently filters public logs by `eventFields.length === 4` and decodes all matches as `TransferSingle`. This is not a unique discriminator: if `MultiToken` ever emits another 4-field event/log (or internal/public logs change shape), the helper will decode the wrong event type, breaking ordering/count assertions or producing false positives.
## Issue Context
There is already a comment documenting the expected selector (`0x2429b477`), but the implementation doesn’t use the selector/tag to filter.
## Fix Focus Areas
- src/ts/test/utils.ts[899-920]
- src/ts/test/utils.ts[771-777]
## Suggested fix
- Filter logs using a unique event discriminator (preferably the log tag / event selector associated with `MultiTokenContract.events.TransferSingle`) before decoding.
- Keep the field-count check as a secondary guard, not the primary selector.
- If the SDK exposes an event selector/tag on `eventMetadata`, compare it against the log’s tag; otherwise, consider catching decode failures and discarding non-matching logs.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
initializeMultiTokenTransferCommitment assumes nestedExecutionResults[0].returnValues[0] exists
and will throw a TypeError if the nested execution layout differs or the call fails in an unexpected
way, obscuring the real failure cause. This makes debugging commitment-related test failures
significantly harder.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`initializeMultiTokenTransferCommitment` directly indexes `nestedExecutionResults[0]` and `returnValues[0]` without validating array lengths or presence. If proving changes its nesting structure (or the call fails and returns no values), the helper will crash with a generic `Cannot read properties of undefined` instead of a clear error.
## Issue Context
This helper is used as a prerequisite for commitment-completion flows (mint/transfer to commitment). When it fails, the downstream tests will fail in confusing ways.
## Fix Focus Areas
- src/ts/test/utils.ts[854-877]
## Suggested fix
- Add explicit checks:
- `nestedExecutionResults?.length > 0`
- `nestedExecutionResults[0]?.returnValues?.length > 0`
- If missing, throw an Error that includes:
- function name (`initialize_transfer_commitment`)
- tx hash (if available)
- a short summary of the observed execution structure.
- Optionally assert the extracted commitment is non-zero before returning.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Author self-review: I have reviewed the code review findings, and addressed the relevant ones.
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 freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
2 participants
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.
🤖 Linear
Closes AZT-XXX
Description
add js tests