UI: Invalid bech32 checksum on pair creation surfaces raw contract error to end users #382

Closed
opened 2026-06-15 13:41:13 +00:00 by totdking · 14 comments
totdking commented 2026-06-15 13:41:13 +00:00 (Migrated from gitlab.com)
No description provided.
totdking commented 2026-06-15 13:42:37 +00:00 (Migrated from gitlab.com)

Summary

On /create, the frontend validates obvious address format failures (wrong prefix, wrong length) with inline errors. However, it does not validate bech32 checksum correctness before submission. A structurally plausible address with an invalid checksum passes the inline guard and reaches the chain, which rejects it with a raw contract error surfaced verbatim to the user.

Observed error message (verbatim):

failed to execute message; message index: 0: Generic error: addr_validate errored: decoding bech32 failed: invalid checksum (expected 3hz2wp got 3hz289): execute wasm contract failed


Reproduction steps

  1. Navigate to /create
  2. Enter a valid Terra address in Token A
  3. Enter a structurally valid Terra address with a corrupted final characters in Token B (e.g. change last 3 chars to alter the bech32 checksum)
  4. Proceed past the whitelist warning and submit
  5. Observe: the raw contract error above is displayed in the UI

Expected behavior

The address input should validate bech32 checksum client-side and surface a clear inline error before submission. Example appropriate message:

"Invalid address: checksum does not match. Please check and re-enter the token address."

The raw contract error should never reach the user.


Actual behavior

The invalid checksum address bypasses the inline format guard and the transaction is submitted to the chain. The chain rejects it with a raw developer-facing error string rendered verbatim in the UI.


Environment

  • Chain: localterra
  • LCD: http://localhost:1317
  • Wallet: Keplr (Terra Classic)
  • Browser: Chrome
  • Page: /create
  • Network throttle applied: No

Severity: P2(polish) -- submission is blocked but the error copy is raw developer output. Requires a near-valid address to trigger; not a common user path but the output is unacceptable for production.

Related checklist item : CP-5

cc: @PlasticDigits

### Summary On `/create`, the frontend validates obvious address format failures (wrong prefix, wrong length) with inline errors. However, it does not validate bech32 checksum correctness before submission. A structurally plausible address with an invalid checksum passes the inline guard and reaches the chain, which rejects it with a raw contract error surfaced verbatim to the user. **Observed error message (verbatim):** > failed to execute message; message index: 0: Generic error: addr_validate errored: decoding bech32 failed: invalid checksum (expected 3hz2wp got 3hz289): execute wasm contract failed --- ### Reproduction steps 1. Navigate to `/create` 2. Enter a valid Terra address in Token A 3. Enter a structurally valid Terra address with a corrupted final characters in Token B (e.g. change last 3 chars to alter the bech32 checksum) 4. Proceed past the whitelist warning and submit 5. Observe: the raw contract error above is displayed in the UI --- ### Expected behavior The address input should validate bech32 checksum client-side and surface a clear inline error before submission. Example appropriate message: > "Invalid address: checksum does not match. Please check and re-enter the token address." The raw contract error should never reach the user. --- ### Actual behavior The invalid checksum address bypasses the inline format guard and the transaction is submitted to the chain. The chain rejects it with a raw developer-facing error string rendered verbatim in the UI. --- ### Environment - Chain: localterra - LCD: [http://localhost:1317](http://localhost:1317) - Wallet: Keplr (Terra Classic) - Browser: Chrome - Page: `/create` - Network throttle applied: No --- **Severity:** P2(polish) -- submission is blocked but the error copy is raw developer output. Requires a near-valid address to trigger; not a common user path but the output is unacceptable for production. **Related checklist item** : CP-5 cc: @PlasticDigits
PlasticDigits commented 2026-06-15 14:15:29 +00:00 (Migrated from gitlab.com)

mentioned in commit 3f9bc007e4

mentioned in commit 3f9bc007e493837178f6485d4f50388219fb6619
PlasticDigits commented 2026-06-15 14:16:00 +00:00 (Migrated from gitlab.com)

mentioned in merge request !911

mentioned in merge request !911
PlasticDigits commented 2026-06-15 14:19:53 +00:00 (Migrated from gitlab.com)

mentioned in commit bde8e3807e

mentioned in commit bde8e3807e12a2f2fb84001ad62a2377bd687b78
PlasticDigits commented 2026-06-15 14:24:58 +00:00 (Migrated from gitlab.com)

Verification — GitLab #382 (PASS)

Verified on main at merge bde8e380 (Validate bech32 checksum on /create token address inputs (#382)).

Acceptance criteria

Criterion Result How verified
Client-side bech32 checksum validation on /create token fields before submit PASS getTerraAddressInputError uses fromBech32; corrupted terra1… addresses fail checksum gate while passing format regex
Inline error: "Invalid address: checksum does not match. Please check and re-enter the token address." PASS terraAddressValidation.test.ts, CreatePairPage.test.tsx
Create Pair submit disabled when checksum invalid PASS CreatePairPage.test.tsx asserts button disabled
Raw contract error (addr_validate / decoding bech32 failed / execute wasm contract failed) must not reach users PASS Inline guard blocks submit; humanizeUserFacingError.test.ts maps the reported verbatim chain string to retail checksum copy via tryHumanizeTerraTxMessage
Browser /create reproduction (valid Token A + corrupted Token B) PASS Playwright smoke (PLAYWRIGHT_SKIP_CHAIN=1): Simulated Wallet connected → /create → inline checksum message visible, Create Pair disabled, no raw contract text in DOM
Docs / agent invariants (CP-5) PASS docs/frontend.md § Create pair — token address validation; skills/AGENTS_FRONTEND_USER_ERRORS.md cross-link

Commands run

# Targeted unit/component tests (#382)
cd frontend-dapp && vitest run \
  src/utils/__tests__/terraAddressValidation.test.ts \
  src/utils/__tests__/humanizeUserFacingError.test.ts \
  src/pages/CreatePairPage.test.tsx
# → 3 files, 24 tests passed

# Browser manual (issue reproduction path)
PLAYWRIGHT_SKIP_CHAIN=1 REQUIRE_LOCALTERRA=0 \
  playwright test e2e/issue-382-verify.spec.ts --project=e2e-smoke --workers=1
# → 1 passed (ephemeral verify spec; not committed)

Notes

  • Full make test-frontend reports one unrelated failure (cosmesPatch127.test.ts — missing patch file for @goblinhunt/cosmes@0.0.71-ghunt.22); not in scope for #382.
  • LocalTerra was not required for this UI-only checksum gate; chain submit path is blocked client-side.

Closing as verified on main.

## Verification — GitLab #382 (PASS) Verified on `main` at merge `bde8e380` (*Validate bech32 checksum on /create token address inputs (#382)*). ### Acceptance criteria | Criterion | Result | How verified | |-----------|--------|--------------| | Client-side bech32 checksum validation on `/create` token fields before submit | **PASS** | `getTerraAddressInputError` uses `fromBech32`; corrupted `terra1…` addresses fail checksum gate while passing format regex | | Inline error: *"Invalid address: checksum does not match. Please check and re-enter the token address."* | **PASS** | `terraAddressValidation.test.ts`, `CreatePairPage.test.tsx` | | **Create Pair** submit disabled when checksum invalid | **PASS** | `CreatePairPage.test.tsx` asserts button disabled | | Raw contract error (`addr_validate` / `decoding bech32 failed` / `execute wasm contract failed`) must not reach users | **PASS** | Inline guard blocks submit; `humanizeUserFacingError.test.ts` maps the reported verbatim chain string to retail checksum copy via `tryHumanizeTerraTxMessage` | | Browser `/create` reproduction (valid Token A + corrupted Token B) | **PASS** | Playwright smoke (`PLAYWRIGHT_SKIP_CHAIN=1`): Simulated Wallet connected → `/create` → inline checksum message visible, **Create Pair** disabled, no raw contract text in DOM | | Docs / agent invariants (CP-5) | **PASS** | `docs/frontend.md` § Create pair — token address validation; `skills/AGENTS_FRONTEND_USER_ERRORS.md` cross-link | ### Commands run ```bash # Targeted unit/component tests (#382) cd frontend-dapp && vitest run \ src/utils/__tests__/terraAddressValidation.test.ts \ src/utils/__tests__/humanizeUserFacingError.test.ts \ src/pages/CreatePairPage.test.tsx # → 3 files, 24 tests passed # Browser manual (issue reproduction path) PLAYWRIGHT_SKIP_CHAIN=1 REQUIRE_LOCALTERRA=0 \ playwright test e2e/issue-382-verify.spec.ts --project=e2e-smoke --workers=1 # → 1 passed (ephemeral verify spec; not committed) ``` ### Notes - Full `make test-frontend` reports one **unrelated** failure (`cosmesPatch127.test.ts` — missing patch file for `@goblinhunt/cosmes@0.0.71-ghunt.22`); not in scope for #382. - LocalTerra was not required for this UI-only checksum gate; chain submit path is blocked client-side. Closing as verified on `main`.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-06-15 14:24:59 +00:00
totdking commented 2026-06-15 15:01:09 +00:00 (Migrated from gitlab.com)

mentioned in issue #291

mentioned in issue #291
totdking commented 2026-06-16 12:55:46 +00:00 (Migrated from gitlab.com)

Verification

At front end, before any tx is carried out, it panics and returns a ui friendly error

Good to go.

### Verification At front end, before any tx is carried out, it panics and returns a ui friendly error Good to go.
PlasticDigits commented 2026-08-17 03:45:49 +00:00 (Migrated from gitlab.com)

mentioned in issue #542

mentioned in issue #542
PlasticDigits commented 2026-08-17 03:45:49 +00:00 (Migrated from gitlab.com)

marked as related to #542

marked as related to #542
PlasticDigits commented 2026-08-17 04:29:00 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1071

mentioned in merge request !1071
PlasticDigits commented 2026-08-18 12:08:59 +00:00 (Migrated from gitlab.com)

mentioned in issue #562

mentioned in issue #562
PlasticDigits commented 2026-08-22 10:59:13 +00:00 (Migrated from gitlab.com)

mentioned in issue #593

mentioned in issue #593
PlasticDigits commented 2026-08-31 04:56:53 +00:00 (Migrated from gitlab.com)

mentioned in issue #711

mentioned in issue #711
PlasticDigits commented 2026-08-31 05:36:05 +00:00 (Migrated from gitlab.com)

mentioned in issue #713

mentioned in issue #713
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic#382
No description provided.