@1sat/permission-module-ui 0.0.14 → 0.0.16

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -4
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -515,21 +515,33 @@ function summarizeTokenTransfer(req, intent) {
515
515
  continue;
516
516
  const sym = tagValue(input.tags, "sym");
517
517
  const amt = BigInt(tagValue(input.tags, "amt") ?? "0");
518
- const cur = totals.get(tokenId) ?? { sym, amt: 0n };
519
- cur.amt += amt;
518
+ const cur = totals.get(tokenId) ?? { sym, inAmt: 0n, changeAmt: 0n };
519
+ cur.inAmt += amt;
520
520
  if (!cur.sym && sym)
521
521
  cur.sym = sym;
522
522
  totals.set(tokenId, cur);
523
523
  }
524
+ for (const output of intent.outputs) {
525
+ if (output.basket !== "bsv21")
526
+ continue;
527
+ const tokenId = tagValue(output.tags, "bsv21");
528
+ if (!tokenId)
529
+ continue;
530
+ const amt = BigInt(tagValue(output.tags, "amt") ?? "0");
531
+ const cur = totals.get(tokenId);
532
+ if (cur)
533
+ cur.changeAmt += amt;
534
+ }
524
535
  const rows = [];
525
536
  for (const [tokenId, info] of totals) {
526
537
  rows.push({
527
538
  key: "Token",
528
539
  value: info.sym ? `${info.sym} — ${shortenId(tokenId)}` : shortenId(tokenId)
529
540
  });
530
- rows.push({ key: "Amount", value: info.amt.toString() });
541
+ const sent = info.inAmt - info.changeAmt;
542
+ rows.push({ key: "Amount", value: sent.toString() });
531
543
  }
532
- const recipient = intent.outputs.find((o) => o.recipient)?.recipient;
544
+ const recipient = intent.outputs.find((o) => o.recipient && o.basket !== "bsv21")?.recipient;
533
545
  if (recipient)
534
546
  rows.push({ key: "Recipient", value: shortenValue(recipient) });
535
547
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/permission-module-ui",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "React component for the 1Sat permission module's prompt UX",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@1sat/permission-module": "0.0.18"
31
+ "@1sat/permission-module": "0.0.19"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": "^18.0.0 || ^19.0.0"