@1sat/permission-module-ui 0.0.15 → 0.0.17
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 +31 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -468,8 +468,23 @@ function summarizeRequest(req) {
|
|
|
468
468
|
if (req.kind === "protocol") {
|
|
469
469
|
return summarizeProtocol(req);
|
|
470
470
|
}
|
|
471
|
+
if (req.kind === "basketAccess") {
|
|
472
|
+
return summarizeBasketAccess(req);
|
|
473
|
+
}
|
|
471
474
|
return summarizeSignature(req);
|
|
472
475
|
}
|
|
476
|
+
function summarizeBasketAccess(req) {
|
|
477
|
+
const intent = req.intent;
|
|
478
|
+
const baskets = intent.baskets ?? [];
|
|
479
|
+
return {
|
|
480
|
+
title: baskets.length === 1 ? "Grant Basket Access" : `Grant Access to ${baskets.length} Baskets`,
|
|
481
|
+
subtitle: `${shortenOriginator(req.originator)} wants to read and write 1Sat baskets`,
|
|
482
|
+
rows: baskets.map((b) => ({
|
|
483
|
+
key: b.basket,
|
|
484
|
+
value: b.description ?? "List, insert, and remove outputs"
|
|
485
|
+
}))
|
|
486
|
+
};
|
|
487
|
+
}
|
|
473
488
|
function tagValue(tags, key) {
|
|
474
489
|
if (!tags)
|
|
475
490
|
return;
|
|
@@ -515,21 +530,33 @@ function summarizeTokenTransfer(req, intent) {
|
|
|
515
530
|
continue;
|
|
516
531
|
const sym = tagValue(input.tags, "sym");
|
|
517
532
|
const amt = BigInt(tagValue(input.tags, "amt") ?? "0");
|
|
518
|
-
const cur = totals.get(tokenId) ?? { sym,
|
|
519
|
-
cur.
|
|
533
|
+
const cur = totals.get(tokenId) ?? { sym, inAmt: 0n, changeAmt: 0n };
|
|
534
|
+
cur.inAmt += amt;
|
|
520
535
|
if (!cur.sym && sym)
|
|
521
536
|
cur.sym = sym;
|
|
522
537
|
totals.set(tokenId, cur);
|
|
523
538
|
}
|
|
539
|
+
for (const output of intent.outputs) {
|
|
540
|
+
if (output.basket !== "bsv21")
|
|
541
|
+
continue;
|
|
542
|
+
const tokenId = tagValue(output.tags, "bsv21");
|
|
543
|
+
if (!tokenId)
|
|
544
|
+
continue;
|
|
545
|
+
const amt = BigInt(tagValue(output.tags, "amt") ?? "0");
|
|
546
|
+
const cur = totals.get(tokenId);
|
|
547
|
+
if (cur)
|
|
548
|
+
cur.changeAmt += amt;
|
|
549
|
+
}
|
|
524
550
|
const rows = [];
|
|
525
551
|
for (const [tokenId, info] of totals) {
|
|
526
552
|
rows.push({
|
|
527
553
|
key: "Token",
|
|
528
554
|
value: info.sym ? `${info.sym} — ${shortenId(tokenId)}` : shortenId(tokenId)
|
|
529
555
|
});
|
|
530
|
-
|
|
556
|
+
const sent = info.inAmt - info.changeAmt;
|
|
557
|
+
rows.push({ key: "Amount", value: sent.toString() });
|
|
531
558
|
}
|
|
532
|
-
const recipient = intent.outputs.find((o) => o.recipient)?.recipient;
|
|
559
|
+
const recipient = intent.outputs.find((o) => o.recipient && o.basket !== "bsv21")?.recipient;
|
|
533
560
|
if (recipient)
|
|
534
561
|
rows.push({ key: "Recipient", value: shortenValue(recipient) });
|
|
535
562
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1sat/permission-module-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
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.
|
|
31
|
+
"@1sat/permission-module": "0.0.20"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "^18.0.0 || ^19.0.0"
|