@1sat/permission-module-ui 0.0.15 → 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.
- package/dist/index.js +16 -4
- package/package.json +1 -1
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,
|
|
519
|
-
cur.
|
|
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
|
-
|
|
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 {
|