Skip to content

fix(frontend): support union types in transaction parameters (DXP-546) - #1834

Open
jmlago wants to merge 4 commits into
v0.124-devfrom
legatus/dxp-546
Open

jmlago wants to merge 4 commits into
v0.124-devfrom
legatus/dxp-546

Conversation

@jmlago

@jmlago jmlago commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Fixes https://linear.app/genlayer-labs/issue/DXP-546/frontend-type-error-in-send-transaction

What and why

A constructor such as def __init__(self, a: str | None = None) previously fell back to an empty raw-calldata field and failed during deployment argument parsing. Union parameters now have an explicit type selector and reuse existing typed inputs. None encodes as null; string accepts ordinary text, including empty strings.

The shared form covers constructors and method calls, positional and keyword-only arguments. Resetting method parameters now remounts their inputs, keeping selectors synchronized even when schema refetching preserves a union object's identity. Complex alternatives use readable labels such as list[int], dict[string], and struct, while retaining raw-calldata entry. Only union fields receive schema props. Standalone None fields start with valid textual calldata.

Review follow-up

  • Addressed the remaining audit nit: outer parameter placeholders now use readable type labels, with positional and keyword regression tests.
  • Kept v0.124-dev as the base per the maintainer’s explicit request and subsequent approval.
  • Rebased onto v0.124-dev (6f2053f).
  • Added positional and keyword regression tests for a new methodBase reusing its union schema.
  • Replaced raw JSON option labels and placeholders with readable type names.
  • Renamed union tests to ContractParams.union.test.ts to avoid fix(frontend): show errors when encoding call data fails (DXP-583) #1833's added test file.
  • Moved component props into a field helper, preserving useInputMap's existing API and compatibility with fix(frontend): show errors when encoding call data fails (DXP-583) #1833's mocks.
  • Verified a temporary combined tree with fix(frontend): show errors when encoding call data fails (DXP-583) #1833 without merging either PR: 40 files / 266 tests passed, including all six encodingErrors integration cases.
  • Reproduced the pre-existing IntegerField precision/empty-value issue; reporting it separately rather than changing shared integer semantics in this ticket.

Testing done

  • cd frontend && npm ci --no-audit --no-fund after rebase.
  • npm run test -- --run: 35 files / 243 tests passed; TypeScript checking also passed after the final placeholder cleanup.
  • npm run build: passed on final retry, including TypeScript checking. Earlier local attempts failed in Monaco import analysis; an unmodified v0.124-dev build also exited 139. Reporting this intermittent build failure separately.
  • Commit hooks passed. Full local pre-commit passed except Ruff, whose binary cannot execute directly on this NixOS environment; CI pre-commit passed.
  • CI frontend tests, backend unit tests, and CodeQL passed on 11f172b.
  • git diff --check: passed.
  • Prior browser validation attempt could not start Chromium on this NixOS environment. No live deployment was performed; the parameter form is exercised through Vue component tests.

Assumptions

  • Support the general $or schema in the shared form, including write methods.
  • Default nullable unions to None; otherwise select the first alternative. Schemas do not expose Python defaults.
  • Select types explicitly instead of guessing whether 42 means an integer or a string.
  • Reset field state whenever method arguments reset, and reset values when selecting a different type.
  • Keep complex alternatives as raw calldata; show simple contained types for lists/dicts and generic list/dict/struct labels otherwise.
  • Keep the standalone None raw-calldata field, initialized with textual null.
  • Include keyword-only rendering so nullable keyword arguments can be edited.
  • Transaction error handling and existing integer-input validation/precision are separate concerns.

Checks

  • Reviewed changes and added regression tests.
  • Linked the ticket.
  • Conventional Commit title, retaining DXP-546.
  • Full browser E2E validation and screenshots (environment limitation above).

User facing release notes

Contract union parameters now let you choose the input type, including None. Selections reset correctly after contract schema changes, and complex types have readable labels.

@github-actions
github-actions Bot changed the base branch from main to v0.123-dev November 18, 2026 20:28
@github-actions

Copy link
Copy Markdown
Contributor

This PR targeted main, which is only the default/static branch.

I retargeted it to v0.123-dev, the active development branch. Pushes to v0.123-dev automatically fast-forward main.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ee975128-9cec-43da-a5af-9508c894f8ca

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@jmlago

jmlago commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Legatus audit: Changes requested (commit 97493fb)

I'd hold this PR: the code is fine, but the PR title fails a CI check, so it can't merge as it is.

What the PR fixes. A constructor like def __init__(self, a: str | None = None) describes its parameter as {"$or": ["string", "null"]}. The frontend had no input for that type, so it showed an empty raw-calldata field. Parsing that empty text threw the "failed to parse" error from the ticket. The PR adds a type picker for these parameters. It starts on None, which sends null; picking a simple type shows the normal input for it; anything more complex falls back to the raw-calldata field. I confirmed the backend writes optional types this way: tests/integration/icontracts/schemas/log_indexer_get_contract_schema_for_code.py:18 has {"$or": ["dict", "null"]}. The same form is used for deploys and for write methods (ConstructorParameters.vue and ContractMethodItem.vue both render it), so the ticket's open question about write methods is covered too.

What I ran on head 97493fb:

  • Unit tests: npx vitest --run passed 33 files and 213 tests, including the 5 new union tests. They only load after npm run cp-examples has copied the example contracts, which a fresh checkout doesn't have.
  • Type check and lint: vue-tsc --noEmit is clean. ESLint on the changed files gives warnings only, no errors.
  • CI: Unit Tests / frontend, pre-commit, Backend lint, backend unit and db tests, and CodeQL pass. test, test-gasless and Load Tests were still running. E2E Tests was queued and is advisory.
  • Scope and secrets: I found no secrets. The changes stay within the ticket.

Findings, most serious first:

  1. Must fix: the PR title fails validate-pr-title (PR Conventional Commit Validation, run 44391326260). The title is DXP-546: support union types in transaction parameters, and the check rejects it with ##[error]Invalid or missing task type: ''. Must be one of: feat, fix, docs, .... PRs merged into v0.123-dev use titles like fix(scope): .... The PR description claims the title follows the required format; it doesn't. Rename it to something like fix(frontend): support union types in transaction parameters (DXP-546), which matches the commit message. No code change is needed.
  2. Minor: ContractParams.vue:101,116 now pass :schema to every field component, but only UnionField reads it. On the others it ends up as a stray HTML attribute, e.g. schema="[object Object]" on the raw-calldata field. It's harmless; you could declare an optional schema prop on the other fields or pass it only to unions.
  3. Minor: fieldValues.ts:33. A parameter typed only as None now starts as null, but it still gets the raw-calldata field, which expects text. Before the PR it started as empty text. This is rare and outside the ticket.
  4. Nit: there is no test for a union whose default type is itself a union. The code handles it by recursion.

The worktree has been removed.

@jmlago jmlago changed the title DXP-546: support union types in transaction parameters fix(frontend): support union types in transaction parameters (DXP-546) Nov 18, 2026
@jmlago
jmlago changed the base branch from v0.123-dev to main November 18, 2026 20:36
@github-actions
github-actions Bot changed the base branch from main to v0.123-dev November 18, 2026 20:37
@github-actions

Copy link
Copy Markdown
Contributor

This PR targeted main, which is only the default/static branch.

I retargeted it to v0.123-dev, the active development branch. Pushes to v0.123-dev automatically fast-forward main.

@jmlago
jmlago requested a review from danieljrc888 November 18, 2026 20:58
@danieljrc888
danieljrc888 marked this pull request as draft November 18, 2026 21:39
@jmlago
jmlago marked this pull request as ready for review November 18, 2026 21:59
@danieljrc888
danieljrc888 changed the base branch from v0.123-dev to v0.124-dev November 18, 2026 23:34

@danieljrc888 danieljrc888 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at 0d37807. The approach (a type selector for $or schemas) fixes the real cause. Two things to change before merging:

1. The selector can show one type while a different value is sent (frontend/src/components/global/fields/UnionField.vue)

selected is initialised once and only recomputed by the watch on props.schema. ContractParams.setInputParams resets every argument to its default whenever methodBase changes, but when the union schema object keeps its identity (TanStack Query structural sharing keeps the unchanged {$or:[...]} object after the schema query is refetched) that watch does not fire.

Scenario: param a: str | None. Pick "string", type hello, then edit the contract code (for example add a second constructor parameter). The selector still shows "string", the model was reset to the default, and the deploy sends None.

Fix: either remount the fields on every reset (a generation counter bumped in setInputParams and used in the v-for :key in ContractParams.vue), or make UnionField derive selected from the model when the parent replaces it. Add a regression test that passes a new methodBase reusing the same schema object.

2. Raw JSON as option labels (UnionField.vue, options and placeholder)

Complex alternatives are rendered with JSON.stringify, so list[int] | None shows an option labelled [{"$rep":"int"}]. Map $rep to list, $dict to dict and object schemas to struct (with the inner type where it is simple).

Also

  • The branch is based on main at c940729, 48 commits behind v0.124-dev. Rebase onto v0.124-dev.
  • It conflicts with #1833: both add frontend/test/unit/components/ContractParams.test.ts, and #1833's encodingErrors.integration.test.ts mocks useInputMap with only getComponent, so its 6 tests fail once this PR's getComponentProps call is in the tree. Whichever lands second must merge the test files and add getComponentProps to that mock.
  • Not introduced here but now reachable from more places: the int alternative reuses the number input, so 12345678901234567890 loses precision and a cleared field sends "".

@jmlago

jmlago commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Legatus audit: Approved (commit 11f172b)

I'd merge this PR as it is at 11f172b1. The code is correct and the tests pass. One thing for a person to confirm: the PR targets v0.124-dev, while the repo's support/ci/ACTIVE_DEV_BRANCH file says v0.123-dev.

What changed since 0d378076. The branch was rebased onto 6f2053f2, the current tip of v0.123-dev and of v0.124-dev; the PR's own diff is unchanged by that. Against v0.124-dev it is still the same 5 frontend files, and the two earlier commits are identical after the rebase. The new commit 11f172b1 does three things:

  • Union selectors reset between methods: ContractParams.vue:18,32,101,116 add a counter that forces the parameter fields to rebuild whenever the method changes. Before, if the next method had a parameter with the same name and schema, the old type choice and value carried over. A new test checks this for positional and keyword parameters.
  • Readable labels: getTypeLabel (fieldValues.ts:51-79) shows complex alternatives as list[int], list, dict[string], dict or struct, and None as None, instead of raw JSON. A test checks the labels in the type list and in the input placeholder.
  • Tidy-up: getComponentProps moved from useInputMap.ts into fieldValues.ts, and the test file was renamed to ContractParams.union.test.ts.

What I ran on 11f172b1:

  • Unit tests: npx vitest --run passed 35 files and 241 tests, 19 of them in ContractParams.union.test.ts. As before, npm run cp-examples has to run first.
  • Type check, lint and formatting: vue-tsc --noEmit is clean. ESLint on the changed files gives no errors (2 warnings). Prettier finds nothing to change.
  • CI:
    • Passed: Unit Tests / frontend, pre-commit, Backend lint, backend-unit-tests, CodeQL, Explorer Unit Tests and Validate branch policy.
    • Skipped by the workflow's triggers: test, test-gasless, db-integration-test and Load Tests.
    • Queued: E2E Tests, which is advisory. I didn't wait for it.
  • Secrets and scope: None found, and nothing outside the ticket.

Findings:

  1. For a person to confirm: the PR targets v0.124-dev, not the active branch named in the repo.

    • git show origin/main:support/ci/ACTIVE_DEV_BRANCH gives v0.123-dev.
    • The PR's events show a maintainer retargeted it manually: 2026-11-18T23:34:17Z base_ref_changed danieljrc888.
    • v0.124-dev currently points at the same commit as the tip of v0.123-dev.

    I'm treating this as a deliberate choice of release train, so it doesn't block my approval. If the fix should ship in a v0.123 release candidate, it has to target v0.123-dev instead.

  2. Note: the PR-title check doesn't run on this base. conventional-commit-pr.yml only runs for PRs into main, so after the retarget there is no title check at this commit. It passed on the previous push, and the title is unchanged and valid: fix(frontend): support union types in transaction parameters (DXP-546).

  3. Nit: ContractParams.vue:107,122 still pass a placeholder of `${paramType}`. For a union parameter that becomes the attribute placeholder="[object Object]" on the field's outer element. Nothing displays it.

The worktree has been removed.

@jmlago

jmlago commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

/run-e2e all

@danieljrc888

Copy link
Copy Markdown
Contributor

Re-reviewed at 11f172b. All four requested changes are resolved: fields are remounted on every reset through the generation key (ContractParams.vue), the regression test reuses the same schema object and fails without the key, complex alternatives have readable labels, the branch sits on the tip of v0.124-dev, and a trial merge with #1833 is clean with the full unit suite passing. No new defects found. Ready for a maintainer to merge.

@danieljrc888

Copy link
Copy Markdown
Contributor

Checked 21edfa8 (readable placeholders through getTypeLabel plus a test): fine, the previous conclusion stands.

@jmlago

jmlago commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Legatus audit: Approved (commit 21edfa8)

I'd merge this PR as it is at 21edfa83. The only new commit fixes the placeholder nit from my last review, and the tests pass. Someone should still confirm that v0.124-dev is the right base branch (point 1 below).

What changed since 11f172b1. 21edfa83 sits directly on top of the last commit I reviewed, and the three earlier commits are unchanged. In frontend/src/components/Simulator/ContractParams.vue:109,124, the placeholder now uses getTypeLabel(paramType) instead of `${paramType}`. A union parameter now gets string | None instead of [object Object]. Complex types shown in the raw-calldata field get readable labels like list[int], and plain types keep the same text as before. A new test checks this for positional and keyword parameters. Against v0.124-dev the PR is still the same 5 frontend files.

What I ran on 21edfa83:

  • Unit tests: npx vitest --run passed 35 files and 243 tests, 21 of them in ContractParams.union.test.ts.
  • Type check, lint and formatting: vue-tsc --noEmit is clean. ESLint on the changed files gives no errors. Prettier finds nothing to change.
  • CI (gh pr checks 1834):
    • Passed: Unit Tests / frontend, pre-commit, Backend lint, backend-unit-tests, CodeQL, Explorer Unit Tests and Validate branch policy.
    • Skipped by the workflow's triggers: test, test-gasless, db-integration-test and Load Tests.
    • Pending: E2E Tests, which is advisory. I didn't wait for it.
  • Secrets and scope: None found, and nothing outside the ticket.

Findings:

  1. For a person to confirm: the PR targets v0.124-dev, not the branch the repo names as active. support/ci/ACTIVE_DEV_BRANCH on main still says v0.123-dev. A maintainer retargeted the PR to v0.124-dev by hand, so I'm treating that as a deliberate choice of release train. If the fix should ship in a v0.123 release candidate, the PR has to target v0.123-dev instead.
  2. Note: the PR-title check doesn't run on this base. That workflow only runs for PRs into main. The title is still valid: fix(frontend): support union types in transaction parameters (DXP-546).

I found nothing left to fix. The worktree has been removed.

@jmlago

jmlago commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

/run-e2e all

@jmlago

jmlago commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Legatus audit: Approved (commit 21edfa8)

I'd merge this PR as it is at 21edfa83. That is the commit I approved last round; the head hasn't moved and the PR is still open, unmerged and targeting v0.124-dev. Two things are new since then: the base branch moved, and the E2E check now reports a failure, though no tests actually ran.

The base moved. v0.124-dev is now at 48e23f14 ("fix(frontend): show errors when encoding call data fails (DXP-583) (#1833)"). That commit touches the same frontend area. I merged it locally onto the PR head:

  • Merge: clean.
  • Unit tests: npx vitest --run passed 40 files and 268 tests. That includes this PR's 21 union tests and the new base's ContractParams.test.ts (3), ConstructorParameters.test.ts (2) and encodingErrors.integration.test.ts (6).
  • Type check: vue-tsc --noEmit is clean.

Earlier results on the commit itself still hold. 243 unit tests passed, and type check, lint and formatting were clean.

CI (gh pr checks 1834):

  • Passed: Unit Tests / frontend, pre-commit, Backend lint, backend-unit-tests, CodeQL, Explorer Unit Tests and Validate branch policy.
  • Skipped by the workflow's triggers: test, test-gasless, db-integration-test and Load Tests.
  • E2E Tests: reports failure, but didn't test anything (finding 1).

Findings:

  1. E2E Tests reports failure without running any tests. The check started at 01:43:05Z and completed at 01:43:07Z. Its only output is "Request needs attention… ask the E2E operator", and its link is just the GitHub org page. E2E is advisory and nothing points at this change, so it doesn't affect my verdict. I've filed a ticket for it below.
  2. For a person to confirm (unchanged): the PR targets v0.124-dev. support/ci/ACTIVE_DEV_BRANCH on main still says v0.123-dev. A maintainer retargeted the PR by hand, so I'm treating it as a deliberate choice. If the fix should ship in a v0.123 release candidate, it has to target v0.123-dev instead.

I found no secrets and nothing outside the ticket. The worktree has been removed.

LEGATUS-TICKET
team: DEVOPS
title: genlayer-studio "E2E Tests" check fails in 2s with no logs or details link on PR #1834
blocks: no
On genlayer-studio PR #1834, head 21edfa8, the E2E Tests check run from app ci-core-e2e-runner (https://github.com/genlayerlabs/genlayer-studio/runs/135274867403) started at 2026-11-19T01:43:05Z and completed at 01:43:07Z with conclusion failure. Output title: "Request needs attention". Summary: "The request could not be completed. Nothing new is authorized to merge. Consult the current checks or ask the E2E operator to inspect the internal details before retrying." Its details_url is only https://github.com/genlayerlabs, so there are no logs and no reason given. It finished too fast to have run any tests. On base commit e1597c7 the same check reported "E2E Tests - success" (2026-11-17T01:45:06Z). The other checks on this commit pass, and unit tests pass with the PR merged onto the latest v0.124-dev. Expected: the E2E run executes, or reports an actionable reason and a link to its logs.
LEGATUS-END

@jmlago

jmlago commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

/run-e2e all

@jmlago

jmlago commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Legatus audit: Approved (commit 21edfa8)

I'd still merge this PR as it is at 21edfa83. The head hasn't moved, so there is no new code to review. The only new thing is that E2E Tests ran again and failed. That check is advisory, and I found no sign this change caused it.

State now:

  • PR: still open and unmerged, targeting v0.124-dev. GitHub reports it as "unstable", which is just the failed E2E check.
  • Base: still 48e23f14. Last round I merged it onto the PR head: 268 unit tests passed and the type check was clean.
  • Other CI: everything else passes or is skipped by its workflow's triggers, the same as before.

What I ran again on 21edfa83:

  • Unit tests: npx vitest --run passed 35 files and 243 tests.
  • Production build: npm run build passed. The E2E job builds the app this way before testing, so the change doesn't break that step.

Findings:

  1. E2E Tests failed, with no logs and no test names.

    I couldn't run E2E myself: the PR author reported Selenium can't start on this NixOS machine, and I didn't retry it.

  2. For a person to confirm (unchanged): the PR targets v0.124-dev. support/ci/ACTIVE_DEV_BRANCH on main still says v0.123-dev. A maintainer retargeted the PR by hand, so I'm treating it as a deliberate choice. If the fix should ship in a v0.123 release candidate, it has to target v0.123-dev instead.

I've filed a ticket for the E2E problem below; it extends the one from my last review. The worktree has been removed.

LEGATUS-TICKET
team: DEVOPS
title: genlayer-studio "E2E Tests" (ci-core-e2e-runner) fails across PRs with no logs, annotations or details link
blocks: no
The E2E Tests check from app ci-core-e2e-runner gives no way to diagnose failures. Its details_url is only https://github.com/genlayerlabs, it has no annotations (annotations_count 0), and its summaries are generic.

On #1834 the frontend build (npm run build) and all 243 unit tests pass locally, and the E2E specs' selectors are unaffected by the change. Expected: E2E runs to completion, or the check links to logs and names the failing test or setup step.
LEGATUS-END

@jmlago

jmlago commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

/run-e2e all

@jmlago

jmlago commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Legatus audit: Approved (commit 21edfa8)

I'd still merge this PR as it is at 21edfa83. The head and base haven't moved, so there is no new code to review; the tests pass again, and E2E failed again in a way that doesn't point at this change.

State now:

  • PR: still open and unmerged, targeting v0.124-dev. Against that base it is still the same 5 frontend files.
  • Base: v0.124-dev is still 48e23f14. Last round I merged it onto the PR head: 268 unit tests passed and the type check was clean.
  • Other CI: everything else passes or is skipped by its workflow's triggers, the same as before.

Tests re-run on 21edfa83 in a fresh worktree:

  • Unit tests: npx vitest --run passed 35 files and 243 tests, 21 of them in ContractParams.union.test.ts. I got this result three times, including once with the JSON reporter, which confirmed that every tracked unit-test file ran.
  • Type check: vue-tsc --noEmit exits 0.
  • Glitches along the way:
    • My first attempt produced no test output and the type check exited 2, because dependencies hadn't installed. A clean npm ci fixed it.
    • One run reported 34 files and 239 tests with no failures, then three later runs showed 35 and 243. I can't explain the dip, and nothing failed in it.

Findings:

  1. E2E Tests failed again, in 1 second. Check run 135285889360 started at 02:10:09Z and finished at 02:10:10Z with "Request needs attention". As before, there are no logs and the link is only the GitHub org page. It's the same pattern as the 2-second failures on DXP-570: Cancel transactions immediately when Studio has no validators #1838 and DXP-569: check LLM providers when validators are created, not when listing them #1839. E2E is advisory, nothing in it points at this change, and the two specs that deploy contracts through the changed form still match their selectors. This is already covered by the E2E ticket I filed last round, so I haven't filed a new one.
  2. For a person to confirm (unchanged): the PR targets v0.124-dev. support/ci/ACTIVE_DEV_BRANCH on main still says v0.123-dev. A maintainer retargeted the PR by hand, so I'm treating it as a deliberate choice. If the fix should ship in a v0.123 release candidate, it has to target v0.123-dev instead.

I found no secrets and nothing outside the ticket. The worktree has been removed.

@jmlago

jmlago commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

/run-e2e all

1 similar comment
@danieljrc888

Copy link
Copy Markdown
Contributor

/run-e2e all

@danieljrc888

Copy link
Copy Markdown
Contributor

/run-e2e all v0.6

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.

2 participants