@unicitylabs/sphere-sdk 0.14.11 → 0.15.0
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 +55 -17
- package/dist/connect/index.cjs +17 -17
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.js +17 -17
- package/dist/connect/index.js.map +1 -1
- package/dist/core/index.cjs +69 -84
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +5 -14
- package/dist/core/index.d.ts +5 -14
- package/dist/core/index.js +69 -84
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +10 -3
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js +10 -3
- package/dist/impl/browser/connect/index.js.map +1 -1
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/connect/index.cjs +9 -2
- package/dist/impl/nodejs/connect/index.cjs.map +1 -1
- package/dist/impl/nodejs/connect/index.js +9 -2
- package/dist/impl/nodejs/connect/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/impl/wallet-api-v2/index.cjs +92 -92
- package/dist/impl/wallet-api-v2/index.cjs.map +1 -1
- package/dist/impl/wallet-api-v2/index.js +92 -92
- package/dist/impl/wallet-api-v2/index.js.map +1 -1
- package/dist/index.cjs +69 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -11
- package/dist/index.d.ts +6 -11
- package/dist/index.js +69 -84
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +116 -174
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.d.cts +3 -5
- package/dist/modules/payments-v2/index.d.ts +3 -5
- package/dist/modules/payments-v2/index.js +114 -173
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/dist/token-engine/index.cjs +43 -57
- package/dist/token-engine/index.cjs.map +1 -1
- package/dist/token-engine/index.d.cts +0 -4
- package/dist/token-engine/index.d.ts +0 -4
- package/dist/token-engine/index.js +43 -57
- package/dist/token-engine/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -40,7 +40,8 @@ __export(payments_v2_exports, {
|
|
|
40
40
|
STORE_KEYS: () => STORE_KEYS,
|
|
41
41
|
createScopedKV: () => createScopedKV,
|
|
42
42
|
isRetryableAckError: () => isRetryableAckError,
|
|
43
|
-
supportsDeterministicMint: () => supportsDeterministicMint
|
|
43
|
+
supportsDeterministicMint: () => supportsDeterministicMint,
|
|
44
|
+
sweepSupersededState: () => sweepSupersededState
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(payments_v2_exports);
|
|
46
47
|
|
|
@@ -49,9 +50,112 @@ function isRetryableAckError(err) {
|
|
|
49
50
|
return err !== null && typeof err === "object" && err.retryable === true;
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
// core/logger.ts
|
|
54
|
+
var LOGGER_KEY = "__sphere_sdk_logger__";
|
|
55
|
+
function getState() {
|
|
56
|
+
const g = globalThis;
|
|
57
|
+
if (!g[LOGGER_KEY]) {
|
|
58
|
+
g[LOGGER_KEY] = { debug: false, tags: {}, handler: null };
|
|
59
|
+
}
|
|
60
|
+
return g[LOGGER_KEY];
|
|
61
|
+
}
|
|
62
|
+
function isEnabled(tag) {
|
|
63
|
+
const state = getState();
|
|
64
|
+
if (tag in state.tags) return state.tags[tag];
|
|
65
|
+
return state.debug;
|
|
66
|
+
}
|
|
67
|
+
var logger = {
|
|
68
|
+
/**
|
|
69
|
+
* Configure the logger. Can be called multiple times (last write wins).
|
|
70
|
+
* Typically called by createBrowserProviders(), createNodeProviders(), or Sphere.init().
|
|
71
|
+
*/
|
|
72
|
+
configure(config) {
|
|
73
|
+
const state = getState();
|
|
74
|
+
if (config.debug !== void 0) state.debug = config.debug;
|
|
75
|
+
if (config.handler !== void 0) state.handler = config.handler;
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Enable/disable debug logging for a specific tag.
|
|
79
|
+
* Per-tag setting overrides the global debug flag.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* logger.setTagDebug('Nostr', true); // enable only Nostr logs
|
|
84
|
+
* logger.setTagDebug('Nostr', false); // disable Nostr logs even if global debug=true
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
setTagDebug(tag, enabled) {
|
|
88
|
+
getState().tags[tag] = enabled;
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Clear per-tag override, falling back to global debug flag.
|
|
92
|
+
*/
|
|
93
|
+
clearTagDebug(tag) {
|
|
94
|
+
delete getState().tags[tag];
|
|
95
|
+
},
|
|
96
|
+
/** Returns true if debug mode is enabled for the given tag (or globally). */
|
|
97
|
+
isDebugEnabled(tag) {
|
|
98
|
+
if (tag) return isEnabled(tag);
|
|
99
|
+
return getState().debug;
|
|
100
|
+
},
|
|
101
|
+
/**
|
|
102
|
+
* Debug-level log. Only shown when debug is enabled (globally or for this tag).
|
|
103
|
+
* Use for detailed operational information.
|
|
104
|
+
*/
|
|
105
|
+
debug(tag, message, ...args) {
|
|
106
|
+
if (!isEnabled(tag)) return;
|
|
107
|
+
const state = getState();
|
|
108
|
+
if (state.handler) {
|
|
109
|
+
state.handler("debug", tag, message, ...args);
|
|
110
|
+
} else {
|
|
111
|
+
console.log(`[${tag}]`, message, ...args);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
/**
|
|
115
|
+
* Warning-level log. ALWAYS shown regardless of debug flag.
|
|
116
|
+
* Use for important but non-critical issues (timeouts, retries, degraded state).
|
|
117
|
+
*/
|
|
118
|
+
warn(tag, message, ...args) {
|
|
119
|
+
const state = getState();
|
|
120
|
+
if (state.handler) {
|
|
121
|
+
state.handler("warn", tag, message, ...args);
|
|
122
|
+
} else {
|
|
123
|
+
console.warn(`[${tag}]`, message, ...args);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* Error-level log. ALWAYS shown regardless of debug flag.
|
|
128
|
+
* Use for critical failures that should never be silenced.
|
|
129
|
+
*/
|
|
130
|
+
error(tag, message, ...args) {
|
|
131
|
+
const state = getState();
|
|
132
|
+
if (state.handler) {
|
|
133
|
+
state.handler("error", tag, message, ...args);
|
|
134
|
+
} else {
|
|
135
|
+
console.error(`[${tag}]`, message, ...args);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
/** Reset all logger state (debug flag, tags, handler). Primarily for tests. */
|
|
139
|
+
reset() {
|
|
140
|
+
const g = globalThis;
|
|
141
|
+
delete g[LOGGER_KEY];
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
52
145
|
// modules/payments-v2/stores.ts
|
|
146
|
+
var KV_PREFIX = "pv2g2:";
|
|
147
|
+
var SUPERSEDED_KV_PREFIXES = ["pv2:"];
|
|
148
|
+
async function sweepSupersededState(storage) {
|
|
149
|
+
for (const prefix of SUPERSEDED_KV_PREFIXES) {
|
|
150
|
+
try {
|
|
151
|
+
await storage.clear(prefix);
|
|
152
|
+
} catch (err) {
|
|
153
|
+
logger.warn("PaymentsV2", `could not clear superseded state under "${prefix}": ${String(err)}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
53
157
|
function createScopedKV(storage, network, chainPubkey) {
|
|
54
|
-
const prefix =
|
|
158
|
+
const prefix = `${KV_PREFIX}${network}:${chainPubkey}:`;
|
|
55
159
|
return {
|
|
56
160
|
async get(key) {
|
|
57
161
|
const raw = await storage.get(prefix + key);
|
|
@@ -500,69 +604,6 @@ function randomUUID() {
|
|
|
500
604
|
return `${h[0]}${h[1]}${h[2]}${h[3]}-${h[4]}${h[5]}-${h[6]}${h[7]}-${h[8]}${h[9]}-${h[10]}${h[11]}${h[12]}${h[13]}${h[14]}${h[15]}`;
|
|
501
605
|
}
|
|
502
606
|
|
|
503
|
-
// token-engine/sdk.ts
|
|
504
|
-
var import_StateTransitionClient = require("@unicitylabs/state-transition-sdk/lib/StateTransitionClient.js");
|
|
505
|
-
var import_AggregatorClient = require("@unicitylabs/state-transition-sdk/lib/api/AggregatorClient.js");
|
|
506
|
-
var import_NetworkId = require("@unicitylabs/state-transition-sdk/lib/api/NetworkId.js");
|
|
507
|
-
var import_CertificationData = require("@unicitylabs/state-transition-sdk/lib/api/CertificationData.js");
|
|
508
|
-
var import_CertificationResponse = require("@unicitylabs/state-transition-sdk/lib/api/CertificationResponse.js");
|
|
509
|
-
var import_StateId = require("@unicitylabs/state-transition-sdk/lib/api/StateId.js");
|
|
510
|
-
var import_InclusionProof = require("@unicitylabs/state-transition-sdk/lib/api/InclusionProof.js");
|
|
511
|
-
var import_InclusionProofResponse = require("@unicitylabs/state-transition-sdk/lib/api/InclusionProofResponse.js");
|
|
512
|
-
var import_JsonRpcNetworkError = require("@unicitylabs/state-transition-sdk/lib/api/json-rpc/JsonRpcNetworkError.js");
|
|
513
|
-
var import_RootTrustBase = require("@unicitylabs/state-transition-sdk/lib/api/bft/RootTrustBase.js");
|
|
514
|
-
var import_InclusionProofUtils = require("@unicitylabs/state-transition-sdk/lib/util/InclusionProofUtils.js");
|
|
515
|
-
var import_InclusionProofVerificationRule = require("@unicitylabs/state-transition-sdk/lib/transaction/verification/rule/InclusionProofVerificationRule.js");
|
|
516
|
-
var import_Token = require("@unicitylabs/state-transition-sdk/lib/transaction/Token.js");
|
|
517
|
-
var import_MintTransaction = require("@unicitylabs/state-transition-sdk/lib/transaction/MintTransaction.js");
|
|
518
|
-
var import_TransferTransaction = require("@unicitylabs/state-transition-sdk/lib/transaction/TransferTransaction.js");
|
|
519
|
-
var import_CertifiedMintTransaction = require("@unicitylabs/state-transition-sdk/lib/transaction/CertifiedMintTransaction.js");
|
|
520
|
-
var import_CertifiedTransferTransaction = require("@unicitylabs/state-transition-sdk/lib/transaction/CertifiedTransferTransaction.js");
|
|
521
|
-
var import_TokenId = require("@unicitylabs/state-transition-sdk/lib/transaction/TokenId.js");
|
|
522
|
-
var import_TokenType = require("@unicitylabs/state-transition-sdk/lib/transaction/TokenType.js");
|
|
523
|
-
var import_TokenSalt = require("@unicitylabs/state-transition-sdk/lib/transaction/TokenSalt.js");
|
|
524
|
-
var import_StateMask = require("@unicitylabs/state-transition-sdk/lib/transaction/StateMask.js");
|
|
525
|
-
var import_MintJustificationVerifierService = require("@unicitylabs/state-transition-sdk/lib/transaction/verification/MintJustificationVerifierService.js");
|
|
526
|
-
var import_TokenIssuanceVerifierService = require("@unicitylabs/state-transition-sdk/lib/transaction/verification/TokenIssuanceVerifierService.js");
|
|
527
|
-
var import_VerificationContext = require("@unicitylabs/state-transition-sdk/lib/transaction/verification/VerificationContext.js");
|
|
528
|
-
var import_UnicityCertificateVerifier = require("@unicitylabs/state-transition-sdk/lib/api/bft/verification/UnicityCertificateVerifier.js");
|
|
529
|
-
var import_UnicitySealQuorumSignaturesVerificationRule = require("@unicitylabs/state-transition-sdk/lib/api/bft/verification/rule/UnicitySealQuorumSignaturesVerificationRule.js");
|
|
530
|
-
var import_VerifiedSealCache = require("@unicitylabs/state-transition-sdk/lib/api/bft/verification/VerifiedSealCache.js");
|
|
531
|
-
var import_Secp256k1SignatureVerifier = require("@unicitylabs/state-transition-sdk/lib/crypto/secp256k1/Secp256k1SignatureVerifier.js");
|
|
532
|
-
var import_WorkerTokenVerifier = require("@unicitylabs/state-transition-sdk/lib/transaction/verification/worker/WorkerTokenVerifier.js");
|
|
533
|
-
var import_EncodedPredicate = require("@unicitylabs/state-transition-sdk/lib/predicate/EncodedPredicate.js");
|
|
534
|
-
var import_SignaturePredicate = require("@unicitylabs/state-transition-sdk/lib/predicate/builtin/SignaturePredicate.js");
|
|
535
|
-
var import_SignaturePredicateUnlockScript = require("@unicitylabs/state-transition-sdk/lib/predicate/builtin/SignaturePredicateUnlockScript.js");
|
|
536
|
-
var import_BurnPredicate = require("@unicitylabs/state-transition-sdk/lib/predicate/builtin/BurnPredicate.js");
|
|
537
|
-
var import_PredicateVerifierService = require("@unicitylabs/state-transition-sdk/lib/predicate/verification/PredicateVerifierService.js");
|
|
538
|
-
var import_SigningService = require("@unicitylabs/state-transition-sdk/lib/crypto/secp256k1/SigningService.js");
|
|
539
|
-
var import_Signature = require("@unicitylabs/state-transition-sdk/lib/crypto/secp256k1/Signature.js");
|
|
540
|
-
var import_MintSigningService = require("@unicitylabs/state-transition-sdk/lib/crypto/MintSigningService.js");
|
|
541
|
-
var import_HashAlgorithm = require("@unicitylabs/state-transition-sdk/lib/crypto/hash/HashAlgorithm.js");
|
|
542
|
-
var import_DataHash = require("@unicitylabs/state-transition-sdk/lib/crypto/hash/DataHash.js");
|
|
543
|
-
var import_DataHasher = require("@unicitylabs/state-transition-sdk/lib/crypto/hash/DataHasher.js");
|
|
544
|
-
var import_DataHasherFactory = require("@unicitylabs/state-transition-sdk/lib/crypto/hash/DataHasherFactory.js");
|
|
545
|
-
var import_CborSerializer = require("@unicitylabs/state-transition-sdk/lib/serialization/cbor/CborSerializer.js");
|
|
546
|
-
var import_CborDeserializer = require("@unicitylabs/state-transition-sdk/lib/serialization/cbor/CborDeserializer.js");
|
|
547
|
-
var import_CborError = require("@unicitylabs/state-transition-sdk/lib/serialization/cbor/CborError.js");
|
|
548
|
-
var import_Asset = require("@unicitylabs/state-transition-sdk/lib/payment/asset/Asset.js");
|
|
549
|
-
var import_AssetId = require("@unicitylabs/state-transition-sdk/lib/payment/asset/AssetId.js");
|
|
550
|
-
var import_PaymentAssetCollection = require("@unicitylabs/state-transition-sdk/lib/payment/asset/PaymentAssetCollection.js");
|
|
551
|
-
var import_TokenSplit = require("@unicitylabs/state-transition-sdk/lib/payment/TokenSplit.js");
|
|
552
|
-
var import_SplitTokenRequest = require("@unicitylabs/state-transition-sdk/lib/payment/SplitTokenRequest.js");
|
|
553
|
-
var import_SplitToken = require("@unicitylabs/state-transition-sdk/lib/payment/SplitToken.js");
|
|
554
|
-
var import_SplitAllocationProof = require("@unicitylabs/state-transition-sdk/lib/payment/SplitAllocationProof.js");
|
|
555
|
-
var import_SplitMintJustification = require("@unicitylabs/state-transition-sdk/lib/payment/SplitMintJustification.js");
|
|
556
|
-
var import_SplitMintJustificationVerifier = require("@unicitylabs/state-transition-sdk/lib/payment/SplitMintJustificationVerifier.js");
|
|
557
|
-
var import_VerificationStatus = require("@unicitylabs/state-transition-sdk/lib/verification/VerificationStatus.js");
|
|
558
|
-
var import_VerificationResult = require("@unicitylabs/state-transition-sdk/lib/verification/VerificationResult.js");
|
|
559
|
-
var import_HexConverter = require("@unicitylabs/state-transition-sdk/lib/util/HexConverter.js");
|
|
560
|
-
var import_BigintConverter = require("@unicitylabs/state-transition-sdk/lib/util/BigintConverter.js");
|
|
561
|
-
var import_BitString = require("@unicitylabs/state-transition-sdk/lib/util/BitString.js");
|
|
562
|
-
|
|
563
|
-
// token-engine/token-blob.ts
|
|
564
|
-
var TOKEN_BLOB_VERSION = 1;
|
|
565
|
-
|
|
566
607
|
// modules/payments-v2/async.ts
|
|
567
608
|
var SingleFlight = class {
|
|
568
609
|
flight = null;
|
|
@@ -1207,12 +1248,7 @@ var TransferMachine = class {
|
|
|
1207
1248
|
let total = 0n;
|
|
1208
1249
|
for (const outcome of committed) {
|
|
1209
1250
|
if (outcome.recipientBlob === void 0) continue;
|
|
1210
|
-
const token = await engine.decodeToken({
|
|
1211
|
-
v: TOKEN_BLOB_VERSION,
|
|
1212
|
-
network: 0,
|
|
1213
|
-
tokenId: "",
|
|
1214
|
-
token: outcome.recipientBlob
|
|
1215
|
-
});
|
|
1251
|
+
const token = await engine.decodeToken({ tokenId: "", token: outcome.recipientBlob });
|
|
1216
1252
|
total += engine.balanceOf(token, coinId);
|
|
1217
1253
|
}
|
|
1218
1254
|
return total.toString();
|
|
@@ -1328,8 +1364,9 @@ async function fetchSources(deps, jobs) {
|
|
|
1328
1364
|
const engine = deps.engine();
|
|
1329
1365
|
for (const [tokenId, bytes] of blobs) {
|
|
1330
1366
|
try {
|
|
1331
|
-
decoded.set(tokenId, await engine.decodeToken({
|
|
1332
|
-
} catch {
|
|
1367
|
+
decoded.set(tokenId, await engine.decodeToken({ tokenId, token: bytes }));
|
|
1368
|
+
} catch (err) {
|
|
1369
|
+
logger.warn("PaymentsV2", `resume: source ${tokenId} did not decode \u2014 ${String(err)}`);
|
|
1333
1370
|
}
|
|
1334
1371
|
}
|
|
1335
1372
|
return decoded;
|
|
@@ -3153,98 +3190,6 @@ var InventoryView = class {
|
|
|
3153
3190
|
}
|
|
3154
3191
|
};
|
|
3155
3192
|
|
|
3156
|
-
// core/logger.ts
|
|
3157
|
-
var LOGGER_KEY = "__sphere_sdk_logger__";
|
|
3158
|
-
function getState() {
|
|
3159
|
-
const g = globalThis;
|
|
3160
|
-
if (!g[LOGGER_KEY]) {
|
|
3161
|
-
g[LOGGER_KEY] = { debug: false, tags: {}, handler: null };
|
|
3162
|
-
}
|
|
3163
|
-
return g[LOGGER_KEY];
|
|
3164
|
-
}
|
|
3165
|
-
function isEnabled(tag) {
|
|
3166
|
-
const state = getState();
|
|
3167
|
-
if (tag in state.tags) return state.tags[tag];
|
|
3168
|
-
return state.debug;
|
|
3169
|
-
}
|
|
3170
|
-
var logger = {
|
|
3171
|
-
/**
|
|
3172
|
-
* Configure the logger. Can be called multiple times (last write wins).
|
|
3173
|
-
* Typically called by createBrowserProviders(), createNodeProviders(), or Sphere.init().
|
|
3174
|
-
*/
|
|
3175
|
-
configure(config) {
|
|
3176
|
-
const state = getState();
|
|
3177
|
-
if (config.debug !== void 0) state.debug = config.debug;
|
|
3178
|
-
if (config.handler !== void 0) state.handler = config.handler;
|
|
3179
|
-
},
|
|
3180
|
-
/**
|
|
3181
|
-
* Enable/disable debug logging for a specific tag.
|
|
3182
|
-
* Per-tag setting overrides the global debug flag.
|
|
3183
|
-
*
|
|
3184
|
-
* @example
|
|
3185
|
-
* ```ts
|
|
3186
|
-
* logger.setTagDebug('Nostr', true); // enable only Nostr logs
|
|
3187
|
-
* logger.setTagDebug('Nostr', false); // disable Nostr logs even if global debug=true
|
|
3188
|
-
* ```
|
|
3189
|
-
*/
|
|
3190
|
-
setTagDebug(tag, enabled) {
|
|
3191
|
-
getState().tags[tag] = enabled;
|
|
3192
|
-
},
|
|
3193
|
-
/**
|
|
3194
|
-
* Clear per-tag override, falling back to global debug flag.
|
|
3195
|
-
*/
|
|
3196
|
-
clearTagDebug(tag) {
|
|
3197
|
-
delete getState().tags[tag];
|
|
3198
|
-
},
|
|
3199
|
-
/** Returns true if debug mode is enabled for the given tag (or globally). */
|
|
3200
|
-
isDebugEnabled(tag) {
|
|
3201
|
-
if (tag) return isEnabled(tag);
|
|
3202
|
-
return getState().debug;
|
|
3203
|
-
},
|
|
3204
|
-
/**
|
|
3205
|
-
* Debug-level log. Only shown when debug is enabled (globally or for this tag).
|
|
3206
|
-
* Use for detailed operational information.
|
|
3207
|
-
*/
|
|
3208
|
-
debug(tag, message, ...args) {
|
|
3209
|
-
if (!isEnabled(tag)) return;
|
|
3210
|
-
const state = getState();
|
|
3211
|
-
if (state.handler) {
|
|
3212
|
-
state.handler("debug", tag, message, ...args);
|
|
3213
|
-
} else {
|
|
3214
|
-
console.log(`[${tag}]`, message, ...args);
|
|
3215
|
-
}
|
|
3216
|
-
},
|
|
3217
|
-
/**
|
|
3218
|
-
* Warning-level log. ALWAYS shown regardless of debug flag.
|
|
3219
|
-
* Use for important but non-critical issues (timeouts, retries, degraded state).
|
|
3220
|
-
*/
|
|
3221
|
-
warn(tag, message, ...args) {
|
|
3222
|
-
const state = getState();
|
|
3223
|
-
if (state.handler) {
|
|
3224
|
-
state.handler("warn", tag, message, ...args);
|
|
3225
|
-
} else {
|
|
3226
|
-
console.warn(`[${tag}]`, message, ...args);
|
|
3227
|
-
}
|
|
3228
|
-
},
|
|
3229
|
-
/**
|
|
3230
|
-
* Error-level log. ALWAYS shown regardless of debug flag.
|
|
3231
|
-
* Use for critical failures that should never be silenced.
|
|
3232
|
-
*/
|
|
3233
|
-
error(tag, message, ...args) {
|
|
3234
|
-
const state = getState();
|
|
3235
|
-
if (state.handler) {
|
|
3236
|
-
state.handler("error", tag, message, ...args);
|
|
3237
|
-
} else {
|
|
3238
|
-
console.error(`[${tag}]`, message, ...args);
|
|
3239
|
-
}
|
|
3240
|
-
},
|
|
3241
|
-
/** Reset all logger state (debug flag, tags, handler). Primarily for tests. */
|
|
3242
|
-
reset() {
|
|
3243
|
-
const g = globalThis;
|
|
3244
|
-
delete g[LOGGER_KEY];
|
|
3245
|
-
}
|
|
3246
|
-
};
|
|
3247
|
-
|
|
3248
3193
|
// modules/payments-v2/receive/Receive.ts
|
|
3249
3194
|
var ACK_BATCH_SIZE = 200;
|
|
3250
3195
|
var REFRESH_INTERVAL_MS = 2500;
|
|
@@ -3366,13 +3311,9 @@ async function screen(deps, engine, entry) {
|
|
|
3366
3311
|
const blobBytes = await entry.fetchBlob();
|
|
3367
3312
|
let token;
|
|
3368
3313
|
try {
|
|
3369
|
-
token = await engine.decodeToken({
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
tokenId: "",
|
|
3373
|
-
token: blobBytes
|
|
3374
|
-
});
|
|
3375
|
-
} catch {
|
|
3314
|
+
token = await engine.decodeToken({ tokenId: "", token: blobBytes });
|
|
3315
|
+
} catch (err) {
|
|
3316
|
+
logger.warn("PaymentsV2", `receive: undecodable blob rejected \u2014 ${String(err)}`);
|
|
3376
3317
|
return { kind: "ack", ack: rejectAck(entry, "invalid") };
|
|
3377
3318
|
}
|
|
3378
3319
|
const verdict = await engine.verify(token);
|
|
@@ -4775,7 +4716,7 @@ var PaymentsFacade = class {
|
|
|
4775
4716
|
if (bytes === void 0) {
|
|
4776
4717
|
throw new SphereError(`Selected source ${tokenId} has no blob in storage`, "STORAGE_ERROR");
|
|
4777
4718
|
}
|
|
4778
|
-
const token = await engine.decodeToken({
|
|
4719
|
+
const token = await engine.decodeToken({ tokenId, token: bytes });
|
|
4779
4720
|
const keys = await engine.deliveryKeys(bytes);
|
|
4780
4721
|
spentStates[tokenId] = { local: keys.stateHash, protocol: keys.stateHash };
|
|
4781
4722
|
sources.set(tokenId, token);
|
|
@@ -5041,7 +4982,8 @@ var PaymentsFacade = class {
|
|
|
5041
4982
|
STORE_KEYS,
|
|
5042
4983
|
createScopedKV,
|
|
5043
4984
|
isRetryableAckError,
|
|
5044
|
-
supportsDeterministicMint
|
|
4985
|
+
supportsDeterministicMint,
|
|
4986
|
+
sweepSupersededState
|
|
5045
4987
|
});
|
|
5046
4988
|
/*! Bundled license information:
|
|
5047
4989
|
|