@bopen-io/wallet-toolbox 2.6.2-brc153.1 → 2.6.2-brc153.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/out/src/storage/methods/createAction.js +2 -1
- package/out/src/storage/methods/internalizeAction.js +2 -1
- package/out/src/storage/methods/listActionsIdb.js +1 -3
- package/out/src/storage/methods/listActionsKnex.js +1 -3
- package/out/src/utility/brc153ReferenceLabels.d.ts +13 -1
- package/out/src/utility/brc153ReferenceLabels.js +29 -5
- package/package.json +4 -3
|
@@ -8,6 +8,7 @@ const StorageProvider_1 = require("../StorageProvider");
|
|
|
8
8
|
const WERR_errors_1 = require("../../sdk/WERR_errors");
|
|
9
9
|
const utilityHelpers_1 = require("../../utility/utilityHelpers");
|
|
10
10
|
const utilityHelpers_noBuffer_1 = require("../../utility/utilityHelpers.noBuffer");
|
|
11
|
+
const brc153ReferenceLabels_1 = require("../../utility/brc153ReferenceLabels");
|
|
11
12
|
const EntityProvenTx_1 = require("../schema/entities/EntityProvenTx");
|
|
12
13
|
const Wallet_1 = require("../../Wallet");
|
|
13
14
|
const offsetKey_1 = require("./offsetKey");
|
|
@@ -464,7 +465,7 @@ async function createNewTxRecord(storage, userId, vargs, storageBeef, satoshis =
|
|
|
464
465
|
rawTx: undefined
|
|
465
466
|
};
|
|
466
467
|
newTx.transactionId = await storage.insertTransaction(newTx, trx);
|
|
467
|
-
const labelNames = [...new Set(vargs.labels)];
|
|
468
|
+
const labelNames = [...new Set((0, brc153ReferenceLabels_1.stripBrc153ReferenceLabels)(vargs.labels))];
|
|
468
469
|
const labels = await storage.findOrInsertTxLabelsBulk(userId, labelNames, trx);
|
|
469
470
|
for (const label of labelNames) {
|
|
470
471
|
const txLabel = labels[label];
|
|
@@ -7,6 +7,7 @@ const sdk_1 = require("@bsv/sdk");
|
|
|
7
7
|
const processAction_1 = require("./processAction");
|
|
8
8
|
const WERR_errors_1 = require("../../sdk/WERR_errors");
|
|
9
9
|
const utilityHelpers_1 = require("../../utility/utilityHelpers");
|
|
10
|
+
const brc153ReferenceLabels_1 = require("../../utility/brc153ReferenceLabels");
|
|
10
11
|
const EntityProvenTxReq_1 = require("../schema/entities/EntityProvenTxReq");
|
|
11
12
|
const blockHeaderUtilities_1 = require("../../services/chaintracker/chaintracks/util/blockHeaderUtilities");
|
|
12
13
|
const managedChange_1 = require("./managedChange");
|
|
@@ -581,7 +582,7 @@ class InternalizeActionContext {
|
|
|
581
582
|
}
|
|
582
583
|
}
|
|
583
584
|
async addLabels(transactionId) {
|
|
584
|
-
for (const label of this.vargs.labels) {
|
|
585
|
+
for (const label of (0, brc153ReferenceLabels_1.stripBrc153ReferenceLabels)(this.vargs.labels)) {
|
|
585
586
|
const txLabel = await this.storage.findOrInsertTxLabel(this.userId, label);
|
|
586
587
|
await this.storage.findOrInsertTxLabelMap((0, utilityHelpers_1.verifyId)(transactionId), (0, utilityHelpers_1.verifyId)(txLabel.txLabelId));
|
|
587
588
|
}
|
|
@@ -9,9 +9,7 @@ const brc153ReferenceLabels_1 = require("../../utility/brc153ReferenceLabels");
|
|
|
9
9
|
async function enrichIdbActionLabels(storage, tx, action, timeFilterRequested) {
|
|
10
10
|
action.labels = (await storage.getLabelsForTransactionId(tx.transactionId)).map(l => l.label);
|
|
11
11
|
if (tx.reference != null && tx.reference !== '') {
|
|
12
|
-
|
|
13
|
-
if (!action.labels.includes(referenceLabel))
|
|
14
|
-
action.labels.push(referenceLabel);
|
|
12
|
+
action.labels = (0, brc153ReferenceLabels_1.applyBrc153ReferenceLabel)(action.labels, tx.reference);
|
|
15
13
|
}
|
|
16
14
|
if (timeFilterRequested) {
|
|
17
15
|
const ts = tx.created_at ? new Date(tx.created_at).getTime() : Number.NaN;
|
|
@@ -10,9 +10,7 @@ const brc153ReferenceLabels_1 = require("../../utility/brc153ReferenceLabels");
|
|
|
10
10
|
async function enrichActionLabels(storage, tx, action, timeFilterRequested) {
|
|
11
11
|
action.labels = (await storage.getLabelsForTransactionId(tx.transactionId)).map(l => l.label);
|
|
12
12
|
if (tx.reference != null && tx.reference !== '') {
|
|
13
|
-
|
|
14
|
-
if (!action.labels.includes(referenceLabel))
|
|
15
|
-
action.labels.push(referenceLabel);
|
|
13
|
+
action.labels = (0, brc153ReferenceLabels_1.applyBrc153ReferenceLabel)(action.labels, tx.reference);
|
|
16
14
|
}
|
|
17
15
|
if (timeFilterRequested) {
|
|
18
16
|
const ts = (tx.created_at != null) ? new Date(tx.created_at).getTime() : Number.NaN;
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
export declare const BRC153_REFERENCE_PREFIX = "reference ";
|
|
1
2
|
/**
|
|
2
3
|
* Build the BRC-153 synthetic listActions label for an action reference.
|
|
3
4
|
* Encodes reference bytes as lowercase hex (labels are lowercased by validation).
|
|
4
5
|
*/
|
|
5
6
|
export declare function makeBrc153ReferenceLabel(referenceBase64: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* True iff the label uses the reserved BRC-153 reference prefix.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isBrc153ReferenceLabel(label: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Remove every reserved BRC-153 reference label from a label list.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stripBrc153ReferenceLabels(labels: string[]): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Strip any reserved reference labels, then append the wallet-authored synthetic label.
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyBrc153ReferenceLabel(labels: string[], referenceBase64: string): string[];
|
|
6
19
|
/**
|
|
7
20
|
* Parse a BRC-153 synthetic reference label back to the BRC-100 Base64String reference.
|
|
8
21
|
* Returns undefined if the label is not a valid reference label.
|
|
9
22
|
*/
|
|
10
23
|
export declare function parseBrc153ReferenceLabel(label: string): string | undefined;
|
|
11
|
-
//# sourceMappingURL=brc153ReferenceLabels.d.ts.map
|
|
@@ -1,27 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BRC153_REFERENCE_PREFIX = void 0;
|
|
3
4
|
exports.makeBrc153ReferenceLabel = makeBrc153ReferenceLabel;
|
|
5
|
+
exports.isBrc153ReferenceLabel = isBrc153ReferenceLabel;
|
|
6
|
+
exports.stripBrc153ReferenceLabels = stripBrc153ReferenceLabels;
|
|
7
|
+
exports.applyBrc153ReferenceLabel = applyBrc153ReferenceLabel;
|
|
4
8
|
exports.parseBrc153ReferenceLabel = parseBrc153ReferenceLabel;
|
|
5
9
|
const sdk_1 = require("@bsv/sdk");
|
|
6
|
-
|
|
10
|
+
exports.BRC153_REFERENCE_PREFIX = 'reference ';
|
|
7
11
|
/**
|
|
8
12
|
* Build the BRC-153 synthetic listActions label for an action reference.
|
|
9
13
|
* Encodes reference bytes as lowercase hex (labels are lowercased by validation).
|
|
10
14
|
*/
|
|
11
15
|
function makeBrc153ReferenceLabel(referenceBase64) {
|
|
12
16
|
const bytes = sdk_1.Utils.toArray(referenceBase64, 'base64');
|
|
13
|
-
return `${
|
|
17
|
+
return `${exports.BRC153_REFERENCE_PREFIX}${sdk_1.Utils.toHex(bytes)}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* True iff the label uses the reserved BRC-153 reference prefix.
|
|
21
|
+
*/
|
|
22
|
+
function isBrc153ReferenceLabel(label) {
|
|
23
|
+
return label.startsWith(exports.BRC153_REFERENCE_PREFIX);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Remove every reserved BRC-153 reference label from a label list.
|
|
27
|
+
*/
|
|
28
|
+
function stripBrc153ReferenceLabels(labels) {
|
|
29
|
+
return labels.filter(label => !isBrc153ReferenceLabel(label));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Strip any reserved reference labels, then append the wallet-authored synthetic label.
|
|
33
|
+
*/
|
|
34
|
+
function applyBrc153ReferenceLabel(labels, referenceBase64) {
|
|
35
|
+
const next = stripBrc153ReferenceLabels(labels);
|
|
36
|
+
next.push(makeBrc153ReferenceLabel(referenceBase64));
|
|
37
|
+
return next;
|
|
14
38
|
}
|
|
15
39
|
/**
|
|
16
40
|
* Parse a BRC-153 synthetic reference label back to the BRC-100 Base64String reference.
|
|
17
41
|
* Returns undefined if the label is not a valid reference label.
|
|
18
42
|
*/
|
|
19
43
|
function parseBrc153ReferenceLabel(label) {
|
|
20
|
-
if (!label.startsWith(
|
|
44
|
+
if (!label.startsWith(exports.BRC153_REFERENCE_PREFIX))
|
|
21
45
|
return undefined;
|
|
22
|
-
const hex = label.slice(
|
|
46
|
+
const hex = label.slice(exports.BRC153_REFERENCE_PREFIX.length);
|
|
23
47
|
if (hex.length === 0 || hex.length % 2 !== 0 || !/^[0-9a-f]+$/.test(hex))
|
|
24
48
|
return undefined;
|
|
25
49
|
return sdk_1.Utils.toBase64(sdk_1.Utils.toArray(hex, 'hex'));
|
|
26
50
|
}
|
|
27
|
-
//# sourceMappingURL=brc153ReferenceLabels.js.map
|
|
51
|
+
//# sourceMappingURL=brc153ReferenceLabels.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bopen-io/wallet-toolbox",
|
|
3
|
-
"version": "2.6.2-brc153.
|
|
3
|
+
"version": "2.6.2-brc153.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"engines": {
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
"default": "./out/src/sdk/index.js"
|
|
25
25
|
},
|
|
26
26
|
"./out/src/*": {
|
|
27
|
-
"types": "./out/src/*.d.ts",
|
|
28
|
-
"require": "./out/src
|
|
27
|
+
"types": ["./out/src/*.d.ts", "./out/src/*"],
|
|
28
|
+
"require": "./out/src/*",
|
|
29
|
+
"default": "./out/src/*"
|
|
29
30
|
},
|
|
30
31
|
"./package.json": "./package.json"
|
|
31
32
|
},
|