@dcasegr/amm-client 0.42.2 → 0.42.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -75,7 +75,7 @@ The client (each an async function unless noted):
75
75
  `setTokenTerms` (0.40.0: the terms `{lpBps, validatorBps, commissionBps, minLegSats?}`), `discoveryState`, `setDiscovery`,
76
76
  `setEnablePrice`, `exchangeWallet`, `withdrawAll`, `settleWithdrawals` (0.42.x);
77
77
  - the paid enable (0.42.2, anyone signed; open-exchange 0.15.3): `enableTokenPaid(tokenId, {deployBeef?})` — the price
78
- from `/amm/defaults`, a BRC-29 payment to the exchange built with `noSend` (not sent: the exchange's take-in sends it),
78
+ from `/amm/defaults`, a BRC-29 payment to the exchange built as a protected noSend (0.42.3: BRC-177, `p nosend expiry seconds 600`; not sent: the exchange's take-in sends it),
79
79
  ONE BEEF with the deploy and the payment, `POST /amm/enable?tokenId=&paymentTxid=&paymentVout=&derivationPrefix=
80
80
  &derivationSuffix=` signed; the enabled row back; on any refusal or failure the unsent payment is aborted
81
81
  (`abortAction`). Refusals are `ClientError` kind `refused`, the exchange's code first in the message.
package/dist/client.d.ts CHANGED
@@ -391,6 +391,8 @@ export interface EnableCandidate {
391
391
  onDiscovery: boolean;
392
392
  inWallet: boolean;
393
393
  }
394
+ /** 0.42.3: the paid enable's payment is a protected noSend (BRC-177): the wallet reclaims it if nobody sends it within 600 s. */
395
+ export declare const ENABLE_PAYMENT_EXPIRY_LABEL = "p nosend expiry seconds 600";
394
396
  /**
395
397
  * The candidates to enable: discovery's token list (its order, newest first, with its metadata),
396
398
  * then the tokens only this wallet holds (in the order held); every token already on the swap
package/dist/client.js CHANGED
@@ -212,6 +212,8 @@ export async function walletDeployBeef(wallet, tokenId) {
212
212
  }
213
213
  return undefined;
214
214
  }
215
+ /** 0.42.3: the paid enable's payment is a protected noSend (BRC-177): the wallet reclaims it if nobody sends it within 600 s. */
216
+ export const ENABLE_PAYMENT_EXPIRY_LABEL = "p nosend expiry seconds 600";
215
217
  const canonicalId = (tokenId) => {
216
218
  const ref = parseTokenId(tokenId);
217
219
  return ref ? tokenIdText(ref) : null;
@@ -1311,7 +1313,10 @@ function makeClient(opts, s) {
1311
1313
  * (`GET <origin>/@discovery/1color/<token>/deploy`). The payment, ts-stack's standard (sdk BasicBRC29): a prefix and
1312
1314
  * a suffix from `createNonce`, the payee key `getPublicKey({protocolID: [2, "3241645161d8"], keyID: "<prefix>
1313
1315
  * <suffix>", counterparty: <the exchange>})`, ONE P2PKH output of exactly the price, `createAction` with
1314
- * `{randomizeOutputs: false, noSend: true}` — built and signed, NOT sent: the exchange's take-in sends it. Then ONE
1316
+ * `{noSend: true, randomizeOutputs: false}` and the BRC-177 label `ENABLE_PAYMENT_EXPIRY_LABEL` (0.42.3: a protected
1317
+ * noSend — the wallet prefunds an exact anchor and stores the payment, no change; a plain noSend lived only in the
1318
+ * toolbox's client-side batch, so the payer's storage never learned of it) — built and signed, NOT sent: the
1319
+ * exchange's take-in sends it; a wallet whose storage has no BRC-177 fails the createAction (surfaced). Then ONE
1315
1320
  * BEEF merging the deploy's and the payment's, `POST <swap>/enable?tokenId=&paymentTxid=&paymentVout=0
1316
1321
  * &derivationPrefix=&derivationSuffix=` signed (BRC-104). On any refusal or failure after the payment was built, the
1317
1322
  * unsent payment is aborted in the wallet (`abortAction`), so its coins are free again. → the enabled row.
@@ -1341,7 +1346,14 @@ function makeClient(opts, s) {
1341
1346
  const created = await wallet.createAction({
1342
1347
  description: "Open Exchange: enable a token",
1343
1348
  outputs: [{ satoshis: price, lockingScript: p2pkhHexOf(publicKey), outputDescription: "Open Exchange enable fee", customInstructions: JSON.stringify({ derivationPrefix, derivationSuffix, payee: exchange }) }],
1344
- options: { randomizeOutputs: false, noSend: true },
1349
+ // 0.42.3: a protected noSend (BRC-177, as @1sat/actions' payment to a handle): the wallet prefunds an exact anchor,
1350
+ // stores the payment in its storage with no change, and reclaims it if nobody sends it in time.
1351
+ labels: [ENABLE_PAYMENT_EXPIRY_LABEL],
1352
+ options: { noSend: true, randomizeOutputs: false },
1353
+ }).catch((e) => {
1354
+ // No fallback to a plain noSend: a wallet that cannot make a protected one (BRC-177) says why.
1355
+ const c = toClientError(e);
1356
+ throw c instanceof ClientError ? c : new ClientError("refused", `the wallet could not build the protected payment (BRC-177 noSend): ${errText(e)}`, { cause: e });
1345
1357
  });
1346
1358
  const txid = created.txid;
1347
1359
  if (!txid || !created.tx)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcasegr/amm-client",
3
- "version": "0.42.2",
3
+ "version": "0.42.3",
4
4
  "type": "module",
5
5
  "description": "The Open Exchange client (skein-amm): reads, swap, pool deploy / close / rebalance, move back and positions over a BRC-100 wallet, bound to one exchange by createClient. No React, no styles, no wallet provider.",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@1sat/actions": "0.1.3",
33
- "@dcasegr/amm-engine": "0.42.2",
33
+ "@dcasegr/amm-engine": "0.42.3",
34
34
  "cbor2": "^2.3.0"
35
35
  },
36
36
  "peerDependencies": {