# Sup Adaptor Marketplace — API

All endpoints are JSON. Write helpers are **keyless**: they return drafts +
**unsigned** `register()` params. You sign with your own Sui wallet. Publishing
is permissionless — even without these helpers you can call `register()` directly.

## Discover (read)

`GET https://www.supwallet.app/api/adaptors?network=testnet`
→ `{ network, count, adaptors: CatalogEntry[] }` — each carries the verified
manifest, `usage` (on-chain actions / unique vaults), and `reviews`.

`GET https://www.supwallet.app/api/adaptors/schema`
→ the manifest + call-spec shape and the live registry ids per network.

## Publish helpers (keyless)

### 1. Introspect
`POST https://www.supwallet.app/api/adaptors/introspect`
```json
{ "packageId": "0x…", "network": "testnet" }
```
→ `{ witnesses, ops, modules }`. Each op has `params` (with a guessed `role` per
arg: wallet | amount | minOut | object | clock | pure | ctx) and `typeParamCount`.

### 2. Infer (mine past calls)
`POST https://www.supwallet.app/api/adaptors/infer`
```json
{ "packageId": "0x…", "entry": "swap_a_to_b", "network": "testnet" }
```
→ `{ args: [{ objectCandidates, singleton, pureCandidates }], sampleTypeArgs, samples }`.
The fixed object ids (pool/config) and scalars are taken from the function's real
past transactions — singletons auto-fill, varied ones come back as candidates.

### 3. Draft (full manifest + unsigned register)
`POST https://www.supwallet.app/api/adaptors/draft`
```json
{ "packageId": "0x…", "name": "MySwap", "summary": "…", "category": "Swap",
  "network": "testnet", "upload": true }
```
→ `{ manifest, manifestHash, manifestUri, serviceType, ops, executableOps, register }`.
With `upload:true` the manifest is pinned to Walrus and `manifestUri` is filled;
otherwise upload it yourself and put the `walrus://<blobId>` uri into the register
args. `register` is the **unsigned** call to sign.

## On-chain interface (the canonical, permissionless API)

Registry — testnet package `0x0`, object `0x0`:

```
registry::register(registry, package_id: address, service_type: String,
                   manifest_uri: String, manifest_hash: vector<u8>, clock)
registry::update(registry, service_type, package_id, manifest_uri, manifest_hash, clock)  // publisher only
registry::unlist(registry, service_type, clock)                                           // publisher only
registry::attest(registry, service_type, score: u8 (1..5), comment_uri: String, clock)    // reputation hook
```

Discovery is by indexing the `Registered` / `Updated` / `Unlisted` / `Attested`
events. `service_type` is namespaced by the publisher's package id, so it can't be
spoofed. Using a listed adaptor is always bounded by the per-service allowance the
owner grants (`SupWallet::wallet::grant_service_coin`).
