0xMiden / 0xMiden/web-sdk

Expose PSWAP API on web client and React SDK (mirror of miden-client#2162)

Abierto
#151 1 comentario 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
1
Forks
21
Merge medio
12 h 14 min
PR fusionados (30 d)
41

Descripción

## Summary

`miden-client#2162` ("Pswap Client") adds the Rust-side PSWAP API — `build_pswap_create`, `build_pswap_consume`, and `build_pswap_cancel` on `TransactionRequestBuilder`, plus a `miden-client pswap` CLI subcommand. The web client and React SDK in this repo don't have a PSWAP equivalent. For the v1 public-PSWAP DEX architecture (see `0xMiden/miden-client#1544`), browser-side users currently have no path to create PSWAPs.

## Description

The v1 DEX flow is "user creates a public PSWAP from a browser dApp, market-maker solvers discover it via tag subscription, race to fill it, and settle on-chain". The user-creation step has no web-side primitive today. Looking at the current state of this repo:

- `packages/react-sdk/src/hooks/useSwap.ts` — atomic SWAP only. Doc comment: *"Create an atomic swap offer"*.
- `crates/web-client/test/swap_transactions.test.ts` — exercises atomic SWAP only.
- A recursive search returns zero `pswap` hits anywhere in the repo.

So once `#2162` lands, we'll have a Rust-vs-web gap on the primary v1 user flow.

## What's needed

I'd expect this to be a fairly mechanical mirror of `#2162`'s surface:

- WASM bindings on `crates/web-client` exposing `build_pswap_create`, `build_pswap_consume`, and `build_pswap_cancel`, plus the `PswapTransactionData` shape (creator account ID, offered fungible asset, requested fungible asset, payback `NoteType`).
- A `usePswap` React hook in `packages/react-sdk` mirroring `useSwap`'s ergonomics. v1 callers will pass `NoteType.Public`; the hook should either default that way or expose it as a configurable option.
- TypeScript declarations for the new types and method signatures.
- An end-to-end web test mirroring `bin/integration-tests/src/tests/pswap_transaction.rs` (full-fill / partial-fill / cancel) on the browser side.

## Dependencies and prior art

- Depends on `0xMiden/miden-client#2162`. That PR currently has one failing integration test (`pswap_full_fill_onchain`) — resolution there will likely inform the web test too.
- PSWAP standard: `0xMiden/miden-base` commit `22d6d505` (merged `0xMiden/protocol#2636`, "PSwap Contract").
- v1 architecture context: the May 5 comment on `0xMiden/miden-client#1544`.

## Open Questions

1. **Scoping**: should this land as one PR mirroring all three methods, or split into `create` first (since it's the primary v1 user flow) and `consume` / `cancel` later?
2. **Hook surface**: extend `useSwap` with a `mode: 'atomic' | 'partial'` option, or keep them as distinct `useSwap` and `usePswap` hooks? Happy either way; the existing `useSwap` ergonomics seem worth preserving as-is so I'd lean toward a separate `usePswap`.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start by examining the existing `useSwap` hook in `packages/react-sdk/src/hooks/useSwap.ts` and the Rust-side PSWAP API in the linked `miden-client#2162`. The task involves creating WASM bindings in `crates/web-client`, a new `usePswap` hook mirroring `useSwap`, and corresponding TypeScript types. Run the existing swap tests in `crates/web-client/test/swap_transactions.test.ts` to understand the testing pattern. The work is done when the web client and React SDK can create, consume, and cancel PSWAP transactions, with passing integration tests.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
react, rust, typescript, wasm
Área
api, frontend, web-dev
Tipo de issue
Nueva funcionalidad
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Tranquilo
Claridad
Bien especificado
Aptitud para principiantes
55/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.