WASM version bump + updated examples#1
Conversation
Made-with: Cursor
Greptile Summary
Confidence Score: 4/5Safe to merge after fixing the legacy-wallet One P1 defect: the src/compat.ts — specifically the SIGN_TX → nock_signRawTx request mapping path
|
| 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
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
| const spendConditions = spendConditionsNative.map((spendCondition: SpendCondition) => | ||
| spendConditionToProtobuf(spendCondition) | ||
| ); | ||
| const legacyReq = { rawTx, notes, spendConditions }; |
There was a problem hiding this 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.
| 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.The lockfile still pointed @nockbox/iris-wasm at the monorepo file path, so git installs failed during prepare when that path did not exist.
WASM version bump + updated examples
Updated WASM module to the most recent version + updated examples to match the new APIs.