Skip to content

WASM version bump + updated examples#1

Merged
h33p merged 78 commits into
mainfrom
feat/wasm-module-version-bump
Jun 4, 2026
Merged

WASM version bump + updated examples#1
h33p merged 78 commits into
mainfrom
feat/wasm-module-version-bump

Conversation

@Gohlub

@Gohlub Gohlub commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Updated WASM module to the most recent version + updated examples to match the new APIs.

Comment thread examples/app.ts Outdated
Comment thread src/compat.ts Outdated
Comment thread src/compat.ts Outdated
Comment thread src/provider.ts Outdated
@greptile-apps

greptile-apps Bot commented Apr 27, 2026

Copy link
Copy Markdown

Greptile Summary

  • Bumps @nockbox/iris-wasm from 0.1.1 → 0.2.0-alpha.10, migrating all APIs from WASM class instances to plain-JS objects (SpendCondition as array, Nicks as string, free-function style) and replacing signRawTx with typed signTx.
  • Adds three new SDK modules: bridge.ts (Nockchain → EVM bridge tx builder with Goldilocks belt encoding), migration.ts (v0 → v1 note migration), and compat.ts (bidirectional API-0 ↔ API-1 RPC bridge for legacy wallet compatibility).
  • In compat.ts, the SIGN_TX → nock_signRawTx conversion omits the required rawTxToProtobuf() call on rawTx, sending a WASM RawTx object to legacy wallets that expect PbCom2RawTransaction; notes and spendConditions are correctly serialized but rawTx is not.

Confidence Score: 4/5

Safe to merge after fixing the legacy-wallet rawTx serialization bug in compat.ts; all other issues are pre-flagged or in example code only.

One P1 defect: the SIGN_TX→nock_signRawTx compat path sends an un-serialized WASM RawTx to legacy wallets, breaking backward compatibility for API-0 wallets on the signing path. All other flagged issues are in example code or already acknowledged by the team.

src/compat.ts — specifically the SIGN_TX → nock_signRawTx request mapping path

Important Files Changed

Filename Overview
src/compat.ts New backward-compat RPC mapper; SIGN_TX→nock_signRawTx path sends a raw WASM RawTx object instead of converting it to PbCom2RawTransaction via rawTxToProtobuf, breaking legacy wallet compatibility.
src/bridge.ts New bridge transaction builder; adds remainingGift > 0 guard, encodes EVM address as 3 Goldilocks-field belts with round-trip validation; logic looks sound.
src/migration.ts New v0→v1 migration transaction builder; selects notes with min-threshold heuristic, delegates fee recalc to WASM, returns structured result or gracefully falls back to balance-only.
src/constants.ts Adds V0/V1/BYTHOS tx-engine settings constants, getLatestTxEngineSettings helper, and Zorp bridge config; values align with documented mainnet activation heights.
src/provider.ts Replaces signRawTx with typed signTx(tx, notes?), updates connect return shape to ConnectResponse, and removes the now-deleted TransactionBuilder dependency.
examples/app.ts Updated to 0.2 API; uses spendConditionFirstName instead of spendConditionHash for the gRPC query key — inconsistent with tx-builder.ts (see outside-diff comments).
examples/tx-builder.ts Updated to 0.2 API; refundLock typed as `LockRoot

Sequence Diagram

sequenceDiagram
    participant dApp
    participant Provider as NockchainProvider
    participant Compat as compat.ts (mapRequest)
    participant Wallet as Wallet Extension

    dApp->>Provider: signTx(NockchainTx, notes?)
    Provider->>Wallet: RPC { method: nock_signTx, params: { tx, notes }, api: "1.0.0" }

    alt Wallet is API-1
        Wallet-->>Provider: { tx: SignedNockchainTx }
        Provider-->>dApp: SignTxResponse
    else Wallet is API-0 (legacy)
        Provider->>Compat: mapRequest(SIGN_TX → nock_signRawTx)
        Note over Compat: nockchainTxToRawTx(tx) → RawTx<br/>noteToProtobuf(note) ✓<br/>spendConditionToProtobuf(sc) ✓<br/>rawTxToProtobuf(rawTx) ⚠️ MISSING
        Compat->>Wallet: RPC { method: nock_signRawTx, params: [{ rawTx(WASM), notes(pb), spendConditions(pb) }] }
        Wallet-->>Compat: PbCom2RawTransaction (legacy response)
        Compat->>Provider: mapResponse → rawTxFromProtobuf → rawTxV1ToNockchainTx → { tx }
        Provider-->>dApp: SignTxResponse
    end
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/compat.ts:169
**`rawTx` not converted to protobuf for legacy wallet**

`notes` and `spendConditions` are correctly serialized via `noteToProtobuf`/`spendConditionToProtobuf`, but `rawTx` (a WASM `RawTx` object returned by `nockchainTxToRawTx`) is placed in `legacyReq` as-is. The legacy `nock_signRawTx` endpoint expects a `PbCom2RawTransaction` — the same protobuf-shaped plain-JS object that `rawTxToProtobuf` produces and that `isPbCom2RawTransaction` validates. Sending the WASM type will fail the type guard in the legacy wallet and the signing request will be rejected.

```suggestion
        const legacyReq = { rawTx: rawTxToProtobuf(rawTx), notes, spendConditions };
```

Reviews (7): Last reviewed commit: "remove debug" | Re-trigger Greptile

Comment thread src/bridge.ts Outdated
Comment thread examples/tx-builder.ts
Comment thread src/bridge.ts Outdated
Comment thread src/compat.ts
const spendConditions = spendConditionsNative.map((spendCondition: SpendCondition) =>
spendConditionToProtobuf(spendCondition)
);
const legacyReq = { rawTx, notes, spendConditions };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 rawTx not converted to protobuf for legacy wallet

notes and spendConditions are correctly serialized via noteToProtobuf/spendConditionToProtobuf, but rawTx (a WASM RawTx object returned by nockchainTxToRawTx) is placed in legacyReq as-is. The legacy nock_signRawTx endpoint expects a PbCom2RawTransaction — the same protobuf-shaped plain-JS object that rawTxToProtobuf produces and that isPbCom2RawTransaction validates. Sending the WASM type will fail the type guard in the legacy wallet and the signing request will be rejected.

Suggested change
const legacyReq = { rawTx, notes, spendConditions };
const legacyReq = { rawTx: rawTxToProtobuf(rawTx), notes, spendConditions };
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/compat.ts
Line: 169

Comment:
**`rawTx` not converted to protobuf for legacy wallet**

`notes` and `spendConditions` are correctly serialized via `noteToProtobuf`/`spendConditionToProtobuf`, but `rawTx` (a WASM `RawTx` object returned by `nockchainTxToRawTx`) is placed in `legacyReq` as-is. The legacy `nock_signRawTx` endpoint expects a `PbCom2RawTransaction` — the same protobuf-shaped plain-JS object that `rawTxToProtobuf` produces and that `isPbCom2RawTransaction` validates. Sending the WASM type will fail the type guard in the legacy wallet and the signing request will be rejected.

```suggestion
        const legacyReq = { rawTx: rawTxToProtobuf(rawTx), notes, spendConditions };
```

How can I resolve this? If you propose a fix, please make it concise.

Comment thread src/bridge.ts Outdated
@h33p h33p merged commit 40b3464 into main Jun 4, 2026
1 check passed
h33p added a commit that referenced this pull request Jun 4, 2026
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